ShadowBlur::calculateLayerBoundingRect doesn't need to return the enclosingIntRect...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 17:33:45 +0000 (17:33 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 17:33:45 +0000 (17:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168650

Patch by Fujii Hironori <Hironori.Fujii@sony.com> 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213522 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ShadowBlur.cpp
Source/WebCore/platform/graphics/ShadowBlur.h

index ef3a81a..ba44151 100644 (file)
@@ -1,3 +1,22 @@
+2017-03-07  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        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  <cdumez@apple.com>
 
         Replace debug assertion with release one in Frame::setView()
index 329ca10..f17b3ff 100644 (file)
@@ -388,7 +388,7 @@ IntSize ShadowBlur::blurredEdgeSize() const
     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 @@ IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext& context, const F
     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 @@ IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext& context, const F
     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 @@ IntSize ShadowBlur::templateSize(const IntSize& radiusPadding, const FloatRounde
 
 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 @@ void ShadowBlur::drawRectShadow(GraphicsContext& graphicsContext, const FloatRou
     // 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 @@ void ShadowBlur::drawRectShadow(GraphicsContext& graphicsContext, const FloatRou
 
     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::drawRectShadow(GraphicsContext& graphicsContext, const FloatRou
 
 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 @@ void ShadowBlur::drawInsetShadow(GraphicsContext& graphicsContext, const FloatRe
     // 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,16 +550,16 @@ void ShadowBlur::drawInsetShadow(GraphicsContext& graphicsContext, const FloatRe
 
     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;
     }
 
     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 @@ void ShadowBlur::drawRectShadowWithoutTiling(GraphicsContext& graphicsContext, c
             shadowContext.fillPath(path);
         }
 
-        blurShadowBuffer(expandedIntSize(m_layerSize));
+        blurShadowBuffer(layerSize);
     }
     
     drawShadowBuffer(graphicsContext);
@@ -592,9 +592,9 @@ void ShadowBlur::drawRectShadowWithoutTiling(GraphicsContext& graphicsContext, c
     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 @@ void ShadowBlur::drawInsetShadowWithoutTiling(GraphicsContext& graphicsContext,
         shadowContext.setFillColor(Color::black);
         shadowContext.fillPath(path);
 
-        blurShadowBuffer(expandedIntSize(m_layerSize));
+        blurShadowBuffer(layerSize);
     }
     
     drawShadowBuffer(graphicsContext);
@@ -881,16 +881,16 @@ GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext& context, const Fl
 {
     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
     // 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();
index 184933a..3486949 100644 (file)
@@ -83,13 +83,13 @@ private:
         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);