Skip to content
Permalink
Browse files
Merge Cairo::save and Cairo::restore into GraphicsContextCairo's methods
https://bugs.webkit.org/show_bug.cgi?id=227784

Reviewed by Žan Doberšek.

Cairo::save and Cairo::restore should be GraphicsContextCairo's
methods.

* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::fillShadowBuffer):
(WebCore::Cairo::save): Deleted.
(WebCore::Cairo::restore): Deleted.
* platform/graphics/cairo/CairoOperations.h:
* platform/graphics/cairo/GradientCairo.cpp:
(WebCore::Gradient::fill):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContextCairo::save):
(WebCore::GraphicsContextCairo::restore):
(WebCore::GraphicsContextCairo::fillRect):
(WebCore::GraphicsContextCairo::saveInternal): Deleted.
(WebCore::GraphicsContextCairo::restoreInternal): Deleted.
* platform/graphics/cairo/GraphicsContextCairo.h:
* platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
(Nicosia::CairoOperationRecorder::fillRect):
(Nicosia::CairoOperationRecorder::save):
(Nicosia::CairoOperationRecorder::restore):

Canonical link: https://commits.webkit.org/239505@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279713 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fujii committed Jul 8, 2021
1 parent 1ecf905 commit 3d652993ffa0bfdcab03a4fa403dec1bfeb34c15
Showing 7 changed files with 67 additions and 63 deletions.
@@ -1,3 +1,32 @@
2021-07-08 Fujii Hironori <Hironori.Fujii@sony.com>

Merge Cairo::save and Cairo::restore into GraphicsContextCairo's methods
https://bugs.webkit.org/show_bug.cgi?id=227784

Reviewed by Žan Doberšek.

Cairo::save and Cairo::restore should be GraphicsContextCairo's
methods.

* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::fillShadowBuffer):
(WebCore::Cairo::save): Deleted.
(WebCore::Cairo::restore): Deleted.
* platform/graphics/cairo/CairoOperations.h:
* platform/graphics/cairo/GradientCairo.cpp:
(WebCore::Gradient::fill):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContextCairo::save):
(WebCore::GraphicsContextCairo::restore):
(WebCore::GraphicsContextCairo::fillRect):
(WebCore::GraphicsContextCairo::saveInternal): Deleted.
(WebCore::GraphicsContextCairo::restoreInternal): Deleted.
* platform/graphics/cairo/GraphicsContextCairo.h:
* platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
(Nicosia::CairoOperationRecorder::fillRect):
(Nicosia::CairoOperationRecorder::save):
(Nicosia::CairoOperationRecorder::restore):

2021-07-07 Cameron McCormack <heycam@apple.com>

Add logging for GraphicsLayerCA::m_uncommittedChanges
@@ -190,7 +190,7 @@ static void drawShadowImage(GraphicsContextCairo& platformContext, ImageBuffer&

static void fillShadowBuffer(GraphicsContextCairo& platformContext, ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize, const ShadowState& shadowState)
{
save(platformContext);
platformContext.save();

if (auto nativeImage = layerImage.copyNativeImage(DontCopyBackingStore))
clipToImageBuffer(platformContext, nativeImage->platformImage().get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
@@ -200,7 +200,7 @@ static void fillShadowBuffer(GraphicsContextCairo& platformContext, ImageBuffer&
fillSource.color = shadowState.color;
fillRect(platformContext, FloatRect(layerOrigin, expandedIntSize(layerSize)), fillSource, ShadowState());

restore(platformContext);
platformContext.restore();
}

static inline void drawPathShadow(GraphicsContextCairo& platformContext, const FillSource& fillSource, const StrokeSource& strokeSource, const ShadowState& shadowState, PathDrawingStyle drawingStyle)
@@ -1178,22 +1178,6 @@ void drawFocusRing(GraphicsContextCairo& platformContext, const Vector<FloatRect
drawFocusRing(platformContext, path, width, color);
}

void save(GraphicsContextCairo& platformContext)
{
platformContext.saveInternal();

if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
graphicsContextPrivate->save();
}

void restore(GraphicsContextCairo& platformContext)
{
platformContext.restoreInternal();

if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
graphicsContextPrivate->restore();
}

void translate(GraphicsContextCairo& platformContext, float x, float y)
{
cairo_translate(platformContext.cr(), x, y);
@@ -155,9 +155,6 @@ void drawEllipse(GraphicsContextCairo&, const FloatRect&, const Color&, StrokeSt
void drawFocusRing(GraphicsContextCairo&, const Path&, float, const Color&);
void drawFocusRing(GraphicsContextCairo&, const Vector<FloatRect>&, float, const Color&);

void save(GraphicsContextCairo&);
void restore(GraphicsContextCairo&);

void translate(GraphicsContextCairo&, float, float);
void rotate(GraphicsContextCairo&, float);
void scale(GraphicsContextCairo&, const FloatSize&);
@@ -246,9 +246,9 @@ void Gradient::fill(GraphicsContext& context, const FloatRect& rect)
ASSERT(context.hasPlatformContext());
auto& platformContext = *context.platformContext();

Cairo::save(platformContext);
platformContext.save();
Cairo::fillRect(platformContext, rect, pattern.get());
Cairo::restore(platformContext);
platformContext.restore();
}

} // namespace WebCore
@@ -102,7 +102,13 @@ GraphicsContextCairo* GraphicsContextCairo::platformContext() const
void GraphicsContextCairo::save()
{
GraphicsContext::save();
Cairo::save(*this);

m_cairoStateStack.append(CairoState());
m_cairoState = &m_cairoStateStack.last();

cairo_save(m_cr.get());

m_private->save();
}

void GraphicsContextCairo::restore()
@@ -111,7 +117,27 @@ void GraphicsContextCairo::restore()
return;

GraphicsContext::restore();
Cairo::restore(*this);

if (m_cairoStateStack.isEmpty())
return;

if (m_cairoState->m_mask.pattern) {
cairo_pop_group_to_source(m_cr.get());

cairo_matrix_t matrix;
cairo_get_matrix(m_cr.get(), &matrix);
cairo_set_matrix(m_cr.get(), &m_cairoState->m_mask.matrix);
cairo_mask(m_cr.get(), m_cairoState->m_mask.pattern.get());
cairo_set_matrix(m_cr.get(), &matrix);
}

m_cairoStateStack.removeLast();
ASSERT(!m_cairoStateStack.isEmpty());
m_cairoState = &m_cairoStateStack.last();

cairo_restore(m_cr.get());

m_private->restore();
}

// Draws a filled rectangle with a stroked border.
@@ -181,9 +207,9 @@ void GraphicsContextCairo::fillRect(const FloatRect& rect, Gradient& gradient)
if (!pattern)
return;

Cairo::save(*this);
save();
Cairo::fillRect(*this, rect, pattern.get());
Cairo::restore(*this);
restore();
}

void GraphicsContextCairo::fillRect(const FloatRect& rect, const Color& color, CompositeOperator compositeOperator, BlendMode blendMode)
@@ -428,36 +454,6 @@ Vector<float>& GraphicsContextCairo::layers()
return m_layers;
}

void GraphicsContextCairo::saveInternal()
{
m_cairoStateStack.append(CairoState());
m_cairoState = &m_cairoStateStack.last();

cairo_save(m_cr.get());
}

void GraphicsContextCairo::restoreInternal()
{
if (m_cairoStateStack.isEmpty())
return;

if (m_cairoState->m_mask.pattern) {
cairo_pop_group_to_source(m_cr.get());

cairo_matrix_t matrix;
cairo_get_matrix(m_cr.get(), &matrix);
cairo_set_matrix(m_cr.get(), &m_cairoState->m_mask.matrix);
cairo_mask(m_cr.get(), m_cairoState->m_mask.pattern.get());
cairo_set_matrix(m_cr.get(), &matrix);
}

m_cairoStateStack.removeLast();
ASSERT(!m_cairoStateStack.isEmpty());
m_cairoState = &m_cairoStateStack.last();

cairo_restore(m_cr.get());
}

void GraphicsContextCairo::pushImageMask(cairo_surface_t* surface, const FloatRect& rect)
{
// We must call savePlatformState at least once before we can use image masking,
@@ -114,8 +114,6 @@ class WEBCORE_EXPORT GraphicsContextCairo final : public GraphicsContext {

cairo_t* cr() const;
Vector<float>& layers();
void saveInternal();
void restoreInternal();
void pushImageMask(cairo_surface_t*, const FloatRect&);
GraphicsContextPlatformPrivate* graphicsContextPrivate();

@@ -280,9 +280,9 @@ void CairoOperationRecorder::fillRect(const FloatRect& rect, Gradient& gradient)
void execute(PaintingOperationReplay& replayer) override
{
auto& platformContext = contextForReplay(replayer);
Cairo::save(platformContext);
platformContext.save();
Cairo::fillRect(platformContext, arg<0>(), arg<1>().get());
Cairo::restore(platformContext);
platformContext.restore();
}

void dump(TextStream& ts) override
@@ -744,7 +744,7 @@ void CairoOperationRecorder::save()

void execute(PaintingOperationReplay& replayer) override
{
Cairo::save(contextForReplay(replayer));
contextForReplay(replayer).save();
}

void dump(TextStream& ts) override
@@ -767,7 +767,7 @@ void CairoOperationRecorder::restore()

void execute(PaintingOperationReplay& replayer) override
{
Cairo::restore(contextForReplay(replayer));
contextForReplay(replayer).restore();
}

void dump(TextStream& ts) override

0 comments on commit 3d65299

Please sign in to comment.