Title: [213522] trunk/Source/WebCore
Revision
213522
Author
[email protected]
Date
2017-03-07 09:33:45 -0800 (Tue, 07 Mar 2017)

Log Message

ShadowBlur::calculateLayerBoundingRect doesn't need to return the enclosingIntRect of layerRect
https://bugs.webkit.org/show_bug.cgi?id=168650

Patch by Fujii Hironori <[email protected]> on 2017-03-07
Reviewed by Simon Fraser.

No new tests, no behavior change.

* platform/graphics/ShadowBlur.h: Change the type of return value
from IntRect to IntSize.
* platform/graphics/ShadowBlur.cpp:
(WebCore::ShadowBlur::calculateLayerBoundingRect): Ditto.
(WebCore::ShadowBlur::drawRectShadow): Rename a variable layerRect layerSize.
(WebCore::ShadowBlur::drawInsetShadow): Ditto.
(WebCore::ShadowBlur::drawRectShadowWithoutTiling): Ditto.
(WebCore::ShadowBlur::drawInsetShadowWithoutTiling): Ditto.
(WebCore::ShadowBlur::beginShadowLayer): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (213521 => 213522)


--- trunk/Source/WebCore/ChangeLog	2017-03-07 17:22:35 UTC (rev 213521)
+++ trunk/Source/WebCore/ChangeLog	2017-03-07 17:33:45 UTC (rev 213522)
@@ -1,3 +1,22 @@
+2017-03-07  Fujii Hironori  <[email protected]>
+
+        ShadowBlur::calculateLayerBoundingRect doesn't need to return the enclosingIntRect of layerRect
+        https://bugs.webkit.org/show_bug.cgi?id=168650
+
+        Reviewed by Simon Fraser.
+
+        No new tests, no behavior change.
+
+        * platform/graphics/ShadowBlur.h: Change the type of return value
+        from IntRect to IntSize.
+        * platform/graphics/ShadowBlur.cpp:
+        (WebCore::ShadowBlur::calculateLayerBoundingRect): Ditto.
+        (WebCore::ShadowBlur::drawRectShadow): Rename a variable layerRect layerSize.
+        (WebCore::ShadowBlur::drawInsetShadow): Ditto.
+        (WebCore::ShadowBlur::drawRectShadowWithoutTiling): Ditto.
+        (WebCore::ShadowBlur::drawInsetShadowWithoutTiling): Ditto.
+        (WebCore::ShadowBlur::beginShadowLayer): Ditto.
+
 2017-03-07  Chris Dumez  <[email protected]>
 
         Replace debug assertion with release one in Frame::setView()

Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp (213521 => 213522)


--- trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2017-03-07 17:22:35 UTC (rev 213521)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2017-03-07 17:33:45 UTC (rev 213522)
@@ -388,7 +388,7 @@
     return edgeSize;
 }
 
-IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext& context, const FloatRect& shadowedRect, const IntRect& clipRect)
+IntSize ShadowBlur::calculateLayerBoundingRect(GraphicsContext& context, const FloatRect& shadowedRect, const IntRect& clipRect)
 {
     IntSize edgeSize = blurredEdgeSize();
 
@@ -418,7 +418,7 @@
     if (!clipRect.contains(enclosingIntRect(layerRect))) {
         // If we are totally outside the clip region, we aren't painting at all.
         if (intersection(layerRect, clipRect).isEmpty())
-            return IntRect();
+            return IntSize();
 
         IntRect inflatedClip = clipRect;
         // Pixels at the edges can be affected by pixels outside the buffer,
@@ -451,7 +451,7 @@
     float translationY = -shadowedRect.y() + inflation.height() - fabsf(clippedOut.height());
     m_layerContextTranslation = FloatSize(translationX, translationY);
 
-    return enclosingIntRect(layerRect);
+    return expandedIntSize(layerRect.size());
 }
 
 void ShadowBlur::drawShadowBuffer(GraphicsContext& graphicsContext)
@@ -503,8 +503,8 @@
 
 void ShadowBlur::drawRectShadow(GraphicsContext& graphicsContext, const FloatRoundedRect& shadowedRect)
 {
-    IntRect layerRect = calculateLayerBoundingRect(graphicsContext, shadowedRect.rect(), graphicsContext.clipBounds());
-    if (layerRect.isEmpty())
+    IntSize layerSize = calculateLayerBoundingRect(graphicsContext, shadowedRect.rect(), graphicsContext.clipBounds());
+    if (layerSize.isEmpty())
         return;
 
     adjustBlurRadius(graphicsContext);
@@ -512,7 +512,7 @@
     // drawRectShadowWithTiling does not work with rotations.
     // https://bugs.webkit.org/show_bug.cgi?id=45042
     if (!graphicsContext.getCTM().preservesAxisAlignment() || m_type != BlurShadow) {
-        drawRectShadowWithoutTiling(graphicsContext, shadowedRect, layerRect);
+        drawRectShadowWithoutTiling(graphicsContext, shadowedRect, layerSize);
         return;
     }
 
@@ -522,7 +522,7 @@
 
     if (templateSize.width() > rect.width() || templateSize.height() > rect.height()
         || (templateSize.width() * templateSize.height() > m_sourceRect.width() * m_sourceRect.height())) {
-        drawRectShadowWithoutTiling(graphicsContext, shadowedRect, layerRect);
+        drawRectShadowWithoutTiling(graphicsContext, shadowedRect, layerSize);
         return;
     }
 
@@ -531,8 +531,8 @@
 
 void ShadowBlur::drawInsetShadow(GraphicsContext& graphicsContext, const FloatRect& rect, const FloatRoundedRect& holeRect)
 {
-    IntRect layerRect = calculateLayerBoundingRect(graphicsContext, rect, graphicsContext.clipBounds());
-    if (layerRect.isEmpty())
+    IntSize layerSize = calculateLayerBoundingRect(graphicsContext, rect, graphicsContext.clipBounds());
+    if (layerSize.isEmpty())
         return;
 
     adjustBlurRadius(graphicsContext);
@@ -540,7 +540,7 @@
     // drawInsetShadowWithTiling does not work with rotations.
     // https://bugs.webkit.org/show_bug.cgi?id=45042
     if (!graphicsContext.getCTM().preservesAxisAlignment() || m_type != BlurShadow) {
-        drawInsetShadowWithoutTiling(graphicsContext, rect, holeRect, layerRect);
+        drawInsetShadowWithoutTiling(graphicsContext, rect, holeRect, layerSize);
         return;
     }
 
@@ -550,7 +550,7 @@
 
     if (templateSize.width() > hRect.width() || templateSize.height() > hRect.height()
         || (templateSize.width() * templateSize.height() > hRect.width() * hRect.height())) {
-        drawInsetShadowWithoutTiling(graphicsContext, rect, holeRect, layerRect);
+        drawInsetShadowWithoutTiling(graphicsContext, rect, holeRect, layerSize);
         return;
     }
 
@@ -557,9 +557,9 @@
     drawInsetShadowWithTiling(graphicsContext, rect, holeRect, templateSize, edgeSize);
 }
 
-void ShadowBlur::drawRectShadowWithoutTiling(GraphicsContext& graphicsContext, const FloatRoundedRect& shadowedRect, const IntRect& layerRect)
+void ShadowBlur::drawRectShadowWithoutTiling(GraphicsContext& graphicsContext, const FloatRoundedRect& shadowedRect, const IntSize& layerSize)
 {
-    m_layerImage = ScratchBuffer::singleton().getScratchBuffer(layerRect.size());
+    m_layerImage = ScratchBuffer::singleton().getScratchBuffer(layerSize);
     if (!m_layerImage)
         return;
 
@@ -584,7 +584,7 @@
             shadowContext.fillPath(path);
         }
 
-        blurShadowBuffer(expandedIntSize(m_layerSize));
+        blurShadowBuffer(layerSize);
     }
     
     drawShadowBuffer(graphicsContext);
@@ -592,9 +592,9 @@
     ScratchBuffer::singleton().scheduleScratchBufferPurge();
 }
 
-void ShadowBlur::drawInsetShadowWithoutTiling(GraphicsContext& graphicsContext, const FloatRect& rect, const FloatRoundedRect& holeRect, const IntRect& layerRect)
+void ShadowBlur::drawInsetShadowWithoutTiling(GraphicsContext& graphicsContext, const FloatRect& rect, const FloatRoundedRect& holeRect, const IntSize& layerSize)
 {
-    m_layerImage = ScratchBuffer::singleton().getScratchBuffer(layerRect.size());
+    m_layerImage = ScratchBuffer::singleton().getScratchBuffer(layerSize);
     if (!m_layerImage)
         return;
 
@@ -625,7 +625,7 @@
         shadowContext.setFillColor(Color::black);
         shadowContext.fillPath(path);
 
-        blurShadowBuffer(expandedIntSize(m_layerSize));
+        blurShadowBuffer(layerSize);
     }
     
     drawShadowBuffer(graphicsContext);
@@ -881,9 +881,9 @@
 {
     adjustBlurRadius(context);
 
-    IntRect layerRect = calculateLayerBoundingRect(context, layerArea, context.clipBounds());
+    IntSize layerSize = calculateLayerBoundingRect(context, layerArea, context.clipBounds());
 
-    if (layerRect.isEmpty())
+    if (layerSize.isEmpty())
         return nullptr;
 
     // We reset the scratch buffer values here, because the buffer will no longer contain
@@ -890,7 +890,7 @@
     // data from any previous rectangle or inset shadows drawn via the tiling path.
     auto& scratchBuffer = ScratchBuffer::singleton();
     scratchBuffer.setCachedShadowValues(FloatSize(), Color::black, IntRect(), FloatRoundedRect::Radii(), m_layerSize);
-    m_layerImage = scratchBuffer.getScratchBuffer(layerRect.size());
+    m_layerImage = scratchBuffer.getScratchBuffer(layerSize);
 
     GraphicsContext& shadowContext = m_layerImage->context();
     shadowContext.save();

Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.h (213521 => 213522)


--- trunk/Source/WebCore/platform/graphics/ShadowBlur.h	2017-03-07 17:22:35 UTC (rev 213521)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.h	2017-03-07 17:33:45 UTC (rev 213522)
@@ -83,13 +83,13 @@
         InnerShadow
     };
     
-    IntRect calculateLayerBoundingRect(GraphicsContext&, const FloatRect& layerArea, const IntRect& clipRect);
+    IntSize calculateLayerBoundingRect(GraphicsContext&, const FloatRect& layerArea, const IntRect& clipRect);
     IntSize templateSize(const IntSize& blurredEdgeSize, const FloatRoundedRect::Radii&) const;
 
-    void drawRectShadowWithoutTiling(GraphicsContext&, const FloatRoundedRect&, const IntRect& layerRect);
+    void drawRectShadowWithoutTiling(GraphicsContext&, const FloatRoundedRect&, const IntSize& layerSize);
     void drawRectShadowWithTiling(GraphicsContext&, const FloatRoundedRect&, const IntSize& shadowTemplateSize, const IntSize& blurredEdgeSize);
 
-    void drawInsetShadowWithoutTiling(GraphicsContext&, const FloatRect&, const FloatRoundedRect& holeRect, const IntRect& layerRect);
+    void drawInsetShadowWithoutTiling(GraphicsContext&, const FloatRect&, const FloatRoundedRect& holeRect, const IntSize& layerSize);
     void drawInsetShadowWithTiling(GraphicsContext&, const FloatRect&, const FloatRoundedRect& holeRect, const IntSize& shadowTemplateSize, const IntSize& blurredEdgeSize);
     
     void drawLayerPieces(GraphicsContext&, const FloatRect& shadowBounds, const FloatRoundedRect::Radii&, const IntSize& roundedRadius, const IntSize& templateSize, ShadowDirection);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to