Skip to content
Permalink
Browse files
[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:

Canonical link: https://commits.webkit.org/239561@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fujii committed Jul 9, 2021
1 parent 3280e7a commit 0d88c81cf5b652f437a176da17121a778bdc3d69
@@ -1,3 +1,41 @@
2021-07-09 Fujii Hironori <Hironori.Fujii@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 <mmaxfield@apple.com>

SVGImageForContainer reports true for is<SVGImage>() but it doesn't inherit from SVGImage
@@ -372,7 +372,7 @@ void BifurcatedGraphicsContext::updateState(const GraphicsContextState& state, G
m_secondaryContext.updateState(state, flags);
}

#if OS(WINDOWS)
#if OS(WINDOWS) && !USE(CAIRO)
GraphicsContextPlatformPrivate* BifurcatedGraphicsContext::deprecatedPrivateContext() const
{
return m_primaryContext.deprecatedPrivateContext();
@@ -132,7 +132,7 @@ class WEBCORE_EXPORT BifurcatedGraphicsContext : public GraphicsContext {

void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) final;

#if OS(WINDOWS)
#if OS(WINDOWS) && !USE(CAIRO)
GraphicsContextPlatformPrivate* deprecatedPrivateContext() const final;
#endif

@@ -533,11 +533,13 @@ class GraphicsContext {
#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.
@@ -147,9 +147,9 @@ class NullGraphicsContext : public GraphicsContext {
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 };
@@ -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 @@ void setCTM(GraphicsContextCairo& platformContext, const AffineTransform& transf
{
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,34 +1177,22 @@ void drawFocusRing(GraphicsContextCairo& platformContext, const Vector<FloatRect
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)
{
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 @@ void clip(GraphicsContextCairo& platformContext, const FloatRect& rect)
// 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 @@ void clipPath(GraphicsContextCairo& platformContext, const Path& path, WindRule
// 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)
@@ -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 @@ class GraphicsContextCairo::CairoState {

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 @@ void GraphicsContextCairo::save()
m_cairoState = &m_cairoStateStack.last();

cairo_save(m_cr.get());

m_private->save();
}

void GraphicsContextCairo::restore()
@@ -136,8 +132,6 @@ void GraphicsContextCairo::restore()
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 @@ void GraphicsContextCairo::pushImageMask(cairo_surface_t* surface, const FloatRe
cairo_push_group(m_cr.get());
}

GraphicsContextPlatformPrivate* GraphicsContextCairo::graphicsContextPrivate()
{
return m_private.get();
}

} // namespace WebCore

#endif // USE(CAIRO)
@@ -108,14 +108,9 @@ class WEBCORE_EXPORT GraphicsContextCairo final : public GraphicsContext {

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 @@ class WEBCORE_EXPORT GraphicsContextCairo final : public GraphicsContext {

// Transparency layers.
Vector<float> m_layers;

std::unique_ptr<GraphicsContextPlatformPrivate> m_private;
};

} // namespace WebCore

This file was deleted.

@@ -33,8 +33,6 @@
#include "RefPtrCairo.h"

#include <cairo-win32.h>
#include "GraphicsContextPlatformPrivateCairo.h"


namespace WebCore {

@@ -114,11 +112,7 @@ static void drawBitmapToContext(GraphicsContextCairo& platformContext, const DIB

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 @@ void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, boo
::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();
}

}

0 comments on commit 0d88c81

Please sign in to comment.