Title: [224754] trunk/Source/WebCore
Revision
224754
Author
[email protected]
Date
2017-11-13 06:50:30 -0800 (Mon, 13 Nov 2017)

Log Message

[Cairo] Remove GraphicsContext::mustUseShadowBlur()
https://bugs.webkit.org/show_bug.cgi?id=179612

Reviewed by Michael Catanzaro.

Remove the Cairo-specific mustUseShadowBlur() method on the
GraphicsContext class. It can now be implemented as a static function
in CairoOperations, using only a PlatformContextCairo object and a
const reference to the relevant GraphicsContextState.

No new tests -- no change in behavior.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::mustUseShadowBlur const): Deleted.
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::mustUseShadowBlur):
(WebCore::Cairo::drawGlyphsShadow):
(WebCore::Cairo::fillRectWithRoundedHole):
(WebCore::Cairo::drawGlyphs):
* platform/graphics/cairo/CairoOperations.h:
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::FontCascade::drawGlyphs):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::fillRectWithRoundedHole):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224753 => 224754)


--- trunk/Source/WebCore/ChangeLog	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/ChangeLog	2017-11-13 14:50:30 UTC (rev 224754)
@@ -1,5 +1,33 @@
 2017-11-13  Zan Dobersek  <[email protected]>
 
+        [Cairo] Remove GraphicsContext::mustUseShadowBlur()
+        https://bugs.webkit.org/show_bug.cgi?id=179612
+
+        Reviewed by Michael Catanzaro.
+
+        Remove the Cairo-specific mustUseShadowBlur() method on the
+        GraphicsContext class. It can now be implemented as a static function
+        in CairoOperations, using only a PlatformContextCairo object and a
+        const reference to the relevant GraphicsContextState.
+
+        No new tests -- no change in behavior.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::mustUseShadowBlur const): Deleted.
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/cairo/CairoOperations.cpp:
+        (WebCore::Cairo::mustUseShadowBlur):
+        (WebCore::Cairo::drawGlyphsShadow):
+        (WebCore::Cairo::fillRectWithRoundedHole):
+        (WebCore::Cairo::drawGlyphs):
+        * platform/graphics/cairo/CairoOperations.h:
+        * platform/graphics/cairo/FontCairo.cpp:
+        (WebCore::FontCascade::drawGlyphs):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::fillRectWithRoundedHole):
+
+2017-11-13  Zan Dobersek  <[email protected]>
+
         [Cairo] Move state change operations from GraphicsContextCairo to CairoOperations
         https://bugs.webkit.org/show_bug.cgi?id=179610
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (224753 => 224754)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2017-11-13 14:50:30 UTC (rev 224754)
@@ -497,24 +497,6 @@
     return hasShadow();
 }
 
-#if USE(CAIRO)
-bool GraphicsContext::mustUseShadowBlur() const
-{
-    // We can't avoid ShadowBlur if the shadow has blur.
-    if (hasBlurredShadow())
-        return true;
-    // We can avoid ShadowBlur and optimize, since we're not drawing on a
-    // canvas and box shadows are affected by the transformation matrix.
-    if (!m_state.shadowsIgnoreTransforms)
-        return false;
-    // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
-    if (getCTM().isIdentity())
-        return false;
-    // Otherwise, no chance avoiding ShadowBlur.
-    return true;
-}
-#endif
-
 void GraphicsContext::setFillColor(const Color& color)
 {
     m_state.fillColor = color;

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (224753 => 224754)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2017-11-13 14:50:30 UTC (rev 224754)
@@ -439,10 +439,6 @@
     bool hasShadow() const { return hasVisibleShadow() && (m_state.shadowBlur || m_state.shadowOffset.width() || m_state.shadowOffset.height()); }
     bool hasBlurredShadow() const { return hasVisibleShadow() && m_state.shadowBlur; }
 
-#if USE(CAIRO)
-    bool mustUseShadowBlur() const;
-#endif
-
     void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&);
     void drawFocusRing(const Path&, float width, float offset, const Color&);
 #if PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (224753 => 224754)


--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp	2017-11-13 14:50:30 UTC (rev 224754)
@@ -162,6 +162,25 @@
 #endif
 }
 
+static bool mustUseShadowBlur(PlatformContextCairo& platformContext, const GraphicsContextState& state)
+{
+    // We can't avoid ShadowBlur if the shadow has blur.
+    if (state.shadowColor.isVisible() && state.shadowBlur)
+        return true;
+
+    // We can avoid ShadowBlur and optimize, since we're not drawing on a
+    // canvas and box shadows are affected by the transformation matrix.
+    if (!state.shadowsIgnoreTransforms)
+        return false;
+
+    // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
+    if (State::getCTM(platformContext).isIdentity())
+        return false;
+
+    // Otherwise, no chance avoiding ShadowBlur.
+    return true;
+}
+
 static void drawGlyphsToContext(cairo_t* context, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs)
 {
     cairo_matrix_t originalTransform;
@@ -179,7 +198,7 @@
     }
 }
 
-static void drawGlyphsShadow(PlatformContextCairo& platformContext, const GraphicsContextState& state, bool mustUseShadowBlur, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, GraphicsContext& targetContext)
+static void drawGlyphsShadow(PlatformContextCairo& platformContext, const GraphicsContextState& state, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, GraphicsContext& targetContext)
 {
     ShadowBlur& shadow = platformContext.shadowBlur();
 
@@ -186,7 +205,7 @@
     if (!(state.textDrawingMode & TextModeFill) || shadow.type() == ShadowBlur::NoShadow)
         return;
 
-    if (!mustUseShadowBlur) {
+    if (!mustUseShadowBlur(platformContext, state)) {
         // Optimize non-blurry shadows, by just drawing text without the ShadowBlur.
         cairo_t* context = platformContext.cr();
         cairo_save(context);
@@ -439,11 +458,11 @@
     cairo_restore(cr);
 }
 
-void fillRectWithRoundedHole(PlatformContextCairo& platformContext, const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const GraphicsContextState& contextState, bool mustUseShadowBlur, GraphicsContext& targetContext)
+void fillRectWithRoundedHole(PlatformContextCairo& platformContext, const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const GraphicsContextState& contextState, GraphicsContext& targetContext)
 {
     // FIXME: this should leverage the specified color.
 
-    if (mustUseShadowBlur)
+    if (mustUseShadowBlur(platformContext, contextState))
         platformContext.shadowBlur().drawInsetShadow(targetContext, rect, roundedHoleRect);
 
     Path path;
@@ -505,9 +524,9 @@
     cairo_restore(cr);
 }
 
-void drawGlyphs(PlatformContextCairo& platformContext, const GraphicsContextState& state, bool mustUseShadowBlur, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, float xOffset, GraphicsContext& targetContext)
+void drawGlyphs(PlatformContextCairo& platformContext, const GraphicsContextState& state, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, float xOffset, GraphicsContext& targetContext)
 {
-    drawGlyphsShadow(platformContext, state, mustUseShadowBlur, point, scaledFont, syntheticBoldOffset, glyphs, targetContext);
+    drawGlyphsShadow(platformContext, state, point, scaledFont, syntheticBoldOffset, glyphs, targetContext);
 
     cairo_t* cr = platformContext.cr();
     cairo_save(cr);

Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h (224753 => 224754)


--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h	2017-11-13 14:50:30 UTC (rev 224754)
@@ -87,7 +87,7 @@
 void fillRect(PlatformContextCairo&, const FloatRect&, const Color&, bool, GraphicsContext&);
 void fillRect(PlatformContextCairo&, const FloatRect&, cairo_pattern_t*);
 void fillRoundedRect(PlatformContextCairo&, const FloatRoundedRect&, const Color&, bool, GraphicsContext&);
-void fillRectWithRoundedHole(PlatformContextCairo&, const FloatRect&, const FloatRoundedRect&, const GraphicsContextState&, bool, GraphicsContext&);
+void fillRectWithRoundedHole(PlatformContextCairo&, const FloatRect&, const FloatRoundedRect&, const GraphicsContextState&, GraphicsContext&);
 void fillPath(PlatformContextCairo&, const Path&, const GraphicsContextState&, GraphicsContext&);
 void strokeRect(PlatformContextCairo&, const FloatRect&, float, const GraphicsContextState&, GraphicsContext&);
 void strokePath(PlatformContextCairo&, const Path&, const GraphicsContextState&, GraphicsContext&);

Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (224753 => 224754)


--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp	2017-11-13 14:50:30 UTC (rev 224754)
@@ -71,7 +71,7 @@
     double syntheticBoldOffset = font.syntheticBoldOffset();
 
     ASSERT(context.hasPlatformContext());
-    Cairo::drawGlyphs(*context.platformContext(), context.state(), context.mustUseShadowBlur(), point, scaledFont, syntheticBoldOffset, glyphs, xOffset, context);
+    Cairo::drawGlyphs(*context.platformContext(), context.state(), point, scaledFont, syntheticBoldOffset, glyphs, xOffset, context);
 }
 
 #if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (224753 => 224754)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2017-11-13 13:41:41 UTC (rev 224753)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2017-11-13 14:50:30 UTC (rev 224754)
@@ -929,7 +929,7 @@
     }
 
     ASSERT(hasPlatformContext());
-    Cairo::fillRectWithRoundedHole(*platformContext(), rect, roundedHoleRect, state(), mustUseShadowBlur(), *this);
+    Cairo::fillRectWithRoundedHole(*platformContext(), rect, roundedHoleRect, state(), *this);
 }
 
 void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to