Diff
Modified: trunk/Source/WebCore/ChangeLog (279793 => 279794)
--- trunk/Source/WebCore/ChangeLog 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/ChangeLog 2021-07-09 20:37:57 UTC (rev 279794)
@@ -1,3 +1,41 @@
+2021-07-09 Fujii Hironori <hironori.fu...@sony.com>
+
+ [Cairo][Win] Remove unneeded GraphicsContextPlatformPrivate
+ https://bugs.webkit.org/show_bug.cgi?id=227828
+
+ Reviewed by Don Olmstead.
+
+ GraphicsContextPlatformPrivate keeps HDC's transform syncing with
+ GraphicsContext's transform. However, WinCairo doesn't use it.
+
+ * platform/graphics/BifurcatedGraphicsContext.cpp:
+ * platform/graphics/BifurcatedGraphicsContext.h:
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/NullGraphicsContext.h:
+ * platform/graphics/cairo/CairoOperations.cpp:
+ (WebCore::Cairo::State::setCTM):
+ (WebCore::Cairo::translate):
+ (WebCore::Cairo::rotate):
+ (WebCore::Cairo::scale):
+ (WebCore::Cairo::concatCTM):
+ (WebCore::Cairo::clip):
+ (WebCore::Cairo::clipPath):
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContextCairo::GraphicsContextCairo):
+ (WebCore::GraphicsContextCairo::save):
+ (WebCore::GraphicsContextCairo::restore):
+ (WebCore::GraphicsContextCairo::graphicsContextPrivate): Deleted.
+ * platform/graphics/cairo/GraphicsContextCairo.h:
+ * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Removed.
+ * platform/graphics/win/GraphicsContextCairoWin.cpp:
+ (WebCore::GraphicsContext::releaseWindowsContext):
+ (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): Deleted.
+ (WebCore::GraphicsContextPlatformPrivate::flush): Deleted.
+ (WebCore::GraphicsContextCairo::deprecatedPrivateContext const): Deleted.
+ * platform/graphics/win/GraphicsContextWin.cpp:
+ (WebCore::GraphicsContext::getWindowsContext):
+ * platform/win/DragImageCairoWin.cpp:
+
2021-07-09 Myles C. Maxfield <mmaxfi...@apple.com>
SVGImageForContainer reports true for is<SVGImage>() but it doesn't inherit from SVGImage
Modified: trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp 2021-07-09 20:37:57 UTC (rev 279794)
@@ -372,7 +372,7 @@
m_secondaryContext.updateState(state, flags);
}
-#if OS(WINDOWS)
+#if OS(WINDOWS) && !USE(CAIRO)
GraphicsContextPlatformPrivate* BifurcatedGraphicsContext::deprecatedPrivateContext() const
{
return m_primaryContext.deprecatedPrivateContext();
Modified: trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h 2021-07-09 20:37:57 UTC (rev 279794)
@@ -132,7 +132,7 @@
void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) final;
-#if OS(WINDOWS)
+#if OS(WINDOWS) && !USE(CAIRO)
GraphicsContextPlatformPrivate* deprecatedPrivateContext() const final;
#endif
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2021-07-09 20:37:57 UTC (rev 279794)
@@ -533,11 +533,13 @@
#if OS(WINDOWS)
HDC getWindowsContext(const IntRect&, bool supportAlphaBlend); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend); // The passed in HDC should be the one handed back by getWindowsContext.
+#endif
+#if OS(WINDOWS) && !USE(CAIRO)
// FIXME: This should not exist; we need a different place to
// put code shared between Windows CG and Windows Cairo backends.
virtual GraphicsContextPlatformPrivate* deprecatedPrivateContext() const { return nullptr; }
-#endif // OS(WINDOWS)
+#endif
#if USE(DIRECT2D)
GraphicsContext(HDC, ID2D1DCRenderTarget**, RECT, bool hasAlpha = false); // FIXME: To be removed.
Modified: trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h 2021-07-09 20:37:57 UTC (rev 279794)
@@ -147,9 +147,9 @@
void paintFrameForMedia(MediaPlayer&, const FloatRect&) final { }
#endif
-#if OS(WINDOWS)
+#if OS(WINDOWS) && !USE(CAIRO)
GraphicsContextPlatformPrivate* deprecatedPrivateContext() const final { return nullptr; }
-#endif // OS(WINDOWS)
+#endif
private:
const PaintInvalidationReasons m_paintInvalidationReasons { PaintInvalidationReasons::None };
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2021-07-09 20:37:57 UTC (rev 279794)
@@ -43,7 +43,6 @@
#include "Gradient.h"
#include "GraphicsContext.h"
#include "GraphicsContextCairo.h"
-#include "GraphicsContextPlatformPrivateCairo.h"
#include "Image.h"
#include "ImageBuffer.h"
#include "NativeImage.h"
@@ -495,9 +494,6 @@
{
const cairo_matrix_t matrix = toCairoMatrix(transform);
cairo_set_matrix(platformContext.cr(), &matrix);
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->setCTM(transform);
}
AffineTransform getCTM(GraphicsContextCairo& platformContext)
@@ -1181,25 +1177,16 @@
void translate(GraphicsContextCairo& platformContext, float x, float y)
{
cairo_translate(platformContext.cr(), x, y);
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->translate(x, y);
}
void rotate(GraphicsContextCairo& platformContext, float angleInRadians)
{
cairo_rotate(platformContext.cr(), angleInRadians);
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->rotate(angleInRadians);
}
void scale(GraphicsContextCairo& platformContext, const FloatSize& size)
{
cairo_scale(platformContext.cr(), size.width(), size.height());
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->scale(size);
}
void concatCTM(GraphicsContextCairo& platformContext, const AffineTransform& transform)
@@ -1206,9 +1193,6 @@
{
const cairo_matrix_t matrix = toCairoMatrix(transform);
cairo_transform(platformContext.cr(), &matrix);
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->concatCTM(transform);
}
void beginTransparencyLayer(GraphicsContextCairo& platformContext, float opacity)
@@ -1245,9 +1229,6 @@
// while drawing the transformed layer.
doClipWithAntialias(cr, CAIRO_ANTIALIAS_NONE);
cairo_set_fill_rule(cr, savedFillRule);
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->clip(rect);
}
void clipOut(GraphicsContextCairo& platformContext, const FloatRect& rect)
@@ -1290,9 +1271,6 @@
// Enforce default antialias when clipping paths, since they can contain curves.
doClipWithAntialias(cr, CAIRO_ANTIALIAS_DEFAULT);
cairo_set_fill_rule(cr, savedFillRule);
-
- if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
- graphicsContextPrivate->clip(path);
}
void clipToImageBuffer(GraphicsContextCairo& platformContext, cairo_surface_t* image, const FloatRect& destRect)
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2021-07-09 20:37:57 UTC (rev 279794)
@@ -40,7 +40,6 @@
#include "FloatRect.h"
#include "FloatRoundedRect.h"
#include "Gradient.h"
-#include "GraphicsContextPlatformPrivateCairo.h"
#include "ImageBuffer.h"
#include "IntRect.h"
#include "NotImplemented.h"
@@ -70,7 +69,6 @@
GraphicsContextCairo::GraphicsContextCairo(RefPtr<cairo_t>&& context)
: m_cr(WTFMove(context))
- , m_private(makeUnique<GraphicsContextPlatformPrivate>(cr()))
{
m_cairoStateStack.append(CairoState());
m_cairoState = &m_cairoStateStack.last();
@@ -107,8 +105,6 @@
m_cairoState = &m_cairoStateStack.last();
cairo_save(m_cr.get());
-
- m_private->save();
}
void GraphicsContextCairo::restore()
@@ -136,8 +132,6 @@
m_cairoState = &m_cairoStateStack.last();
cairo_restore(m_cr.get());
-
- m_private->restore();
}
// Draws a filled rectangle with a stroked border.
@@ -469,11 +463,6 @@
cairo_push_group(m_cr.get());
}
-GraphicsContextPlatformPrivate* GraphicsContextCairo::graphicsContextPrivate()
-{
- return m_private.get();
-}
-
} // namespace WebCore
#endif // USE(CAIRO)
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.h (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.h 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.h 2021-07-09 20:37:57 UTC (rev 279794)
@@ -108,14 +108,9 @@
FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) final;
-#if OS(WINDOWS)
- GraphicsContextPlatformPrivate* deprecatedPrivateContext() const final;
-#endif
-
cairo_t* cr() const;
Vector<float>& layers();
void pushImageMask(cairo_surface_t*, const FloatRect&);
- GraphicsContextPlatformPrivate* graphicsContextPrivate();
private:
RefPtr<cairo_t> m_cr;
@@ -126,8 +121,6 @@
// Transparency layers.
Vector<float> m_layers;
-
- std::unique_ptr<GraphicsContextPlatformPrivate> m_private;
};
} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h 2021-07-09 20:37:57 UTC (rev 279794)
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <a...@atoker.com>
- * Copyright (C) 2008 Brent Fulgham <bfulg...@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if USE(CAIRO)
-
-namespace WebCore {
-
-class GraphicsContextPlatformPrivate {
- WTF_MAKE_FAST_ALLOCATED;
-public:
-#if PLATFORM(WIN)
- // On Windows, we need to update the HDC for form controls to draw in the right place.
- GraphicsContextPlatformPrivate(cairo_t*);
- void save();
- void restore();
- void flush();
- void clip(const FloatRect&);
- void clip(const Path&);
- void scale(const FloatSize&);
- void rotate(float);
- void translate(float, float);
- void concatCTM(const AffineTransform&);
- void setCTM(const AffineTransform&);
-#else
- // On everything else, we do nothing.
- GraphicsContextPlatformPrivate(cairo_t*) { }
- void save() { }
- void restore() { }
- void flush() { }
- void clip(const FloatRect&) { }
- void clip(const Path&) { }
- void scale(const FloatSize&) { }
- void rotate(float) { }
- void translate(float, float) { }
- void concatCTM(const AffineTransform&) { }
- void setCTM(const AffineTransform&) { }
-#endif
-
-#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS))
- // NOTE: These may note be needed: review and remove once Cairo implementation is complete
- HDC m_hdc { 0 };
-#endif
-};
-
-} // namespace WebCore
-
-#endif // USE(CAIRO)
Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp 2021-07-09 20:37:57 UTC (rev 279794)
@@ -33,9 +33,7 @@
#include "RefPtrCairo.h"
#include <cairo-win32.h>
-#include "GraphicsContextPlatformPrivateCairo.h"
-
namespace WebCore {
#if PLATFORM(WIN)
@@ -114,11 +112,7 @@
void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend)
{
- bool createdBitmap = !deprecatedPrivateContext()->m_hdc || isInTransparencyLayer();
- if (!hdc || !createdBitmap) {
- deprecatedPrivateContext()->restore();
- return;
- }
+ ASSERT(hdc);
if (dstRect.isEmpty())
return;
@@ -140,29 +134,4 @@
::DeleteDC(hdc);
}
-#if PLATFORM(WIN)
-GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(cairo_t* cr)
-{
- if (!cr)
- return;
-
- cairo_surface_t* surface = cairo_get_target(cr);
- m_hdc = cairo_win32_surface_get_dc(surface);
-
- SetGraphicsMode(m_hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
}
-
-void GraphicsContextPlatformPrivate::flush()
-{
- cairo_surface_t* surface = cairo_win32_surface_create(m_hdc);
- cairo_surface_flush(surface);
- cairo_surface_destroy(surface);
-}
-#endif
-
-GraphicsContextPlatformPrivate* GraphicsContextCairo::deprecatedPrivateContext() const
-{
- return m_private.get();
-}
-
-}
Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp (279793 => 279794)
--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp 2021-07-09 20:37:57 UTC (rev 279794)
@@ -30,8 +30,6 @@
#include "GraphicsContextPlatformPrivateCG.h"
#elif USE(DIRECT2D)
#include "GraphicsContextPlatformPrivateDirect2D.h"
-#elif USE(CAIRO)
-#include "GraphicsContextPlatformPrivateCairo.h"
#endif
#include "AffineTransform.h"
@@ -55,44 +53,46 @@
HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend)
{
- HDC hdc = deprecatedPrivateContext()->m_hdc;
+ HDC hdc = nullptr;
+#if !USE(CAIRO)
+ hdc = deprecatedPrivateContext()->m_hdc;
+ if (hdc && isInTransparencyLayer()) {
+ deprecatedPrivateContext()->flush();
+ deprecatedPrivateContext()->save();
+ return deprecatedPrivateContext()->m_hdc;
+ }
+#endif
// FIXME: Should a bitmap be created also when a shadow is set?
- if (!hdc || isInTransparencyLayer()) {
- if (dstRect.isEmpty())
- return 0;
+ if (dstRect.isEmpty())
+ return 0;
- // Create a bitmap DC in which to draw.
- BitmapInfo bitmapInfo = BitmapInfo::create(dstRect.size());
+ // Create a bitmap DC in which to draw.
+ BitmapInfo bitmapInfo = BitmapInfo::create(dstRect.size());
- void* pixels = 0;
- HBITMAP bitmap = ::CreateDIBSection(NULL, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
- if (!bitmap)
- return 0;
+ void* pixels = 0;
+ HBITMAP bitmap = ::CreateDIBSection(nullptr, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
+ if (!bitmap)
+ return 0;
- auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(hdc));
- ::SelectObject(bitmapDC.get(), bitmap);
+ auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(hdc));
+ ::SelectObject(bitmapDC.get(), bitmap);
- // Fill our buffer with clear if we're going to alpha blend.
- if (supportAlphaBlend)
- fillWithClearColor(bitmap);
+ // Fill our buffer with clear if we're going to alpha blend.
+ if (supportAlphaBlend)
+ fillWithClearColor(bitmap);
- // Make sure we can do world transforms.
- ::SetGraphicsMode(bitmapDC.get(), GM_ADVANCED);
+ // Make sure we can do world transforms.
+ ::SetGraphicsMode(bitmapDC.get(), GM_ADVANCED);
- // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
- XFORM xform = TransformationMatrix().translate(-dstRect.x(), -dstRect.y());
+ // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
+ XFORM xform = TransformationMatrix().translate(-dstRect.x(), -dstRect.y());
- ::SetWorldTransform(bitmapDC.get(), &xform);
+ ::SetWorldTransform(bitmapDC.get(), &xform);
- return bitmapDC.leak();
- }
-
- deprecatedPrivateContext()->flush();
- deprecatedPrivateContext()->save();
- return deprecatedPrivateContext()->m_hdc;
+ return bitmapDC.leak();
}
-#if PLATFORM(WIN) && !USE(DIRECT2D)
+#if PLATFORM(WIN) && USE(CG)
void GraphicsContextPlatformPrivate::save()
{
if (!m_hdc)
Modified: trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp (279793 => 279794)
--- trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp 2021-07-09 20:05:39 UTC (rev 279793)
+++ trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp 2021-07-09 20:37:57 UTC (rev 279794)
@@ -29,7 +29,6 @@
#include "BitmapInfo.h"
#include "CachedImage.h"
#include "GraphicsContextCairo.h"
-#include "GraphicsContextPlatformPrivateCairo.h"
#include "HWndDC.h"
#include "Image.h"
#include <cairo-win32.h>