- Revision
- 224744
- Author
- [email protected]
- Date
- 2017-11-12 23:37:45 -0800 (Sun, 12 Nov 2017)
Log Message
[Cairo] Move state stack, CTM, transparency layer operations in GraphicsContextCairo to CairoOperations
https://bugs.webkit.org/show_bug.cgi?id=179598
Reviewed by Carlos Garcia Campos.
Move operations that save and restore state, adjust CTM and modify the
transparency layer stack to the CairoOperations file. This limits
operations to only work with a PlatformContextCairo object, along with
any required parameter, and will help with future work in this area.
No new tests -- no change in behavior.
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::save):
(WebCore::Cairo::restore):
(WebCore::Cairo::translate):
(WebCore::Cairo::rotate):
(WebCore::Cairo::scale):
(WebCore::Cairo::concatCTM):
(WebCore::Cairo::beginTransparencyLayer):
(WebCore::Cairo::endTransparencyLayer):
* platform/graphics/cairo/CairoOperations.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::savePlatformState):
(WebCore::GraphicsContext::restorePlatformState):
(WebCore::GraphicsContext::translate):
(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::rotate):
(WebCore::GraphicsContext::scale):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (224743 => 224744)
--- trunk/Source/WebCore/ChangeLog 2017-11-13 07:32:03 UTC (rev 224743)
+++ trunk/Source/WebCore/ChangeLog 2017-11-13 07:37:45 UTC (rev 224744)
@@ -1,5 +1,39 @@
2017-11-12 Zan Dobersek <[email protected]>
+ [Cairo] Move state stack, CTM, transparency layer operations in GraphicsContextCairo to CairoOperations
+ https://bugs.webkit.org/show_bug.cgi?id=179598
+
+ Reviewed by Carlos Garcia Campos.
+
+ Move operations that save and restore state, adjust CTM and modify the
+ transparency layer stack to the CairoOperations file. This limits
+ operations to only work with a PlatformContextCairo object, along with
+ any required parameter, and will help with future work in this area.
+
+ No new tests -- no change in behavior.
+
+ * platform/graphics/cairo/CairoOperations.cpp:
+ (WebCore::Cairo::save):
+ (WebCore::Cairo::restore):
+ (WebCore::Cairo::translate):
+ (WebCore::Cairo::rotate):
+ (WebCore::Cairo::scale):
+ (WebCore::Cairo::concatCTM):
+ (WebCore::Cairo::beginTransparencyLayer):
+ (WebCore::Cairo::endTransparencyLayer):
+ * platform/graphics/cairo/CairoOperations.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::savePlatformState):
+ (WebCore::GraphicsContext::restorePlatformState):
+ (WebCore::GraphicsContext::translate):
+ (WebCore::GraphicsContext::concatCTM):
+ (WebCore::GraphicsContext::beginPlatformTransparencyLayer):
+ (WebCore::GraphicsContext::endPlatformTransparencyLayer):
+ (WebCore::GraphicsContext::rotate):
+ (WebCore::GraphicsContext::scale):
+
+2017-11-12 Zan Dobersek <[email protected]>
+
[Cairo] Move line, miter operations in GraphicsContextCairo to CairoOperations
https://bugs.webkit.org/show_bug.cgi?id=179597
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (224743 => 224744)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2017-11-13 07:32:03 UTC (rev 224743)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2017-11-13 07:37:45 UTC (rev 224744)
@@ -92,6 +92,50 @@
cairo_set_miter_limit(platformContext.cr(), miterLimit);
}
+void save(PlatformContextCairo& platformContext)
+{
+ platformContext.save();
+}
+
+void restore(PlatformContextCairo& platformContext)
+{
+ platformContext.restore();
+}
+
+void translate(PlatformContextCairo& platformContext, float x, float y)
+{
+ cairo_translate(platformContext.cr(), x, y);
+}
+
+void rotate(PlatformContextCairo& platformContext, float angleInRadians)
+{
+ cairo_rotate(platformContext.cr(), angleInRadians);
+}
+
+void scale(PlatformContextCairo& platformContext, const FloatSize& size)
+{
+ cairo_scale(platformContext.cr(), size.width(), size.height());
+}
+
+void concatCTM(PlatformContextCairo& platformContext, const AffineTransform& transform)
+{
+ const cairo_matrix_t matrix = toCairoMatrix(transform);
+ cairo_transform(platformContext.cr(), &matrix);
+}
+
+void beginTransparencyLayer(PlatformContextCairo& platformContext, float opacity)
+{
+ cairo_push_group(platformContext.cr());
+ platformContext.layers().append(opacity);
+}
+
+void endTransparencyLayer(PlatformContextCairo& platformContext)
+{
+ cairo_t* cr = platformContext.cr();
+ cairo_pop_group_to_source(cr);
+ cairo_paint_with_alpha(cr, platformContext.layers().takeLast());
+}
+
void clip(PlatformContextCairo& platformContext, const FloatRect& rect)
{
cairo_t* cr = platformContext.cr();
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h (224743 => 224744)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h 2017-11-13 07:32:03 UTC (rev 224743)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h 2017-11-13 07:37:45 UTC (rev 224744)
@@ -39,7 +39,9 @@
namespace WebCore {
+class AffineTransform;
class FloatRect;
+class FloatSize;
class Image;
class Path;
class PlatformContextCairo;
@@ -51,6 +53,17 @@
void setLineJoin(PlatformContextCairo&, LineJoin);
void setMiterLimit(PlatformContextCairo&, float);
+void save(PlatformContextCairo&);
+void restore(PlatformContextCairo&);
+
+void translate(PlatformContextCairo&, float, float);
+void rotate(PlatformContextCairo&, float);
+void scale(PlatformContextCairo&, const FloatSize&);
+void concatCTM(PlatformContextCairo&, const AffineTransform&);
+
+void beginTransparencyLayer(PlatformContextCairo&, float);
+void endTransparencyLayer(PlatformContextCairo&);
+
void clip(PlatformContextCairo&, const FloatRect&);
void clipOut(PlatformContextCairo&, const FloatRect&);
void clipOut(PlatformContextCairo&, const Path&);
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (224743 => 224744)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-11-13 07:32:03 UTC (rev 224743)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-11-13 07:37:45 UTC (rev 224744)
@@ -214,7 +214,7 @@
void GraphicsContext::savePlatformState()
{
ASSERT(hasPlatformContext());
- platformContext()->save();
+ Cairo::save(*platformContext());
m_data->save();
}
@@ -221,7 +221,7 @@
void GraphicsContext::restorePlatformState()
{
ASSERT(hasPlatformContext());
- platformContext()->restore();
+ Cairo::restore(*platformContext());
m_data->restore();
platformContext()->shadowBlur().setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur),
@@ -731,8 +731,8 @@
return;
}
- cairo_t* cr = platformContext()->cr();
- cairo_translate(cr, x, y);
+ ASSERT(hasPlatformContext());
+ Cairo::translate(*platformContext(), x, y);
m_data->translate(x, y);
}
@@ -802,9 +802,8 @@
return;
}
- cairo_t* cr = platformContext()->cr();
- const cairo_matrix_t matrix = toCairoMatrix(transform);
- cairo_transform(cr, &matrix);
+ ASSERT(hasPlatformContext());
+ Cairo::concatCTM(*platformContext(), transform);
m_data->concatCTM(transform);
}
@@ -856,10 +855,7 @@
return;
ASSERT(hasPlatformContext());
-
- cairo_t* cr = platformContext()->cr();
- cairo_push_group(cr);
- platformContext()->layers().append(opacity);
+ Cairo::beginTransparencyLayer(*platformContext(), opacity);
}
void GraphicsContext::endPlatformTransparencyLayer()
@@ -868,14 +864,7 @@
return;
ASSERT(hasPlatformContext());
-
- cairo_t* cr = platformContext()->cr();
-
- cairo_pop_group_to_source(cr);
-
- auto& layers = platformContext()->layers();
- cairo_paint_with_alpha(cr, layers.last());
- layers.removeLast();
+ Cairo::endTransparencyLayer(*platformContext());
}
bool GraphicsContext::supportsTransparencyLayers()
@@ -1019,7 +1008,8 @@
return;
}
- cairo_rotate(platformContext()->cr(), radians);
+ ASSERT(hasPlatformContext());
+ Cairo::rotate(*platformContext(), radians);
m_data->rotate(radians);
}
@@ -1033,7 +1023,8 @@
return;
}
- cairo_scale(platformContext()->cr(), size.width(), size.height());
+ ASSERT(hasPlatformContext());
+ Cairo::scale(*platformContext(), size);
m_data->scale(size);
}