Title: [89221] trunk/Source/WebCore
Revision
89221
Author
[email protected]
Date
2011-06-19 13:48:17 -0700 (Sun, 19 Jun 2011)

Log Message

2011-06-19  Una Sabovic  <[email protected]>

        Reviewed by Darin Adler.

        Optimization: avoid call to clearRect() when bgColor is valid when painting the root background in RenderBoxModelObject::paintFillLayerExtended
        https://bugs.webkit.org/show_bug.cgi?id=62908

        When root layers base color is fully transparent backgroundRect was cleared before bgColor is applied.
        Instead of clearing the rect we apply CompositeCopy operation when painting the background color.

        No new tests. This is an optimization, it doesn't change any existing functionality.

        * platform/graphics/GraphicsContext.cpp:
        (WebCore::GraphicsContext::fillRect):
        * platform/graphics/GraphicsContext.h:
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::RenderBoxModelObject::paintFillLayerExtended):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89220 => 89221)


--- trunk/Source/WebCore/ChangeLog	2011-06-19 20:11:24 UTC (rev 89220)
+++ trunk/Source/WebCore/ChangeLog	2011-06-19 20:48:17 UTC (rev 89221)
@@ -1,3 +1,21 @@
+2011-06-19  Una Sabovic  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Optimization: avoid call to clearRect() when bgColor is valid when painting the root background in RenderBoxModelObject::paintFillLayerExtended
+        https://bugs.webkit.org/show_bug.cgi?id=62908
+
+        When root layers base color is fully transparent backgroundRect was cleared before bgColor is applied.
+        Instead of clearing the rect we apply CompositeCopy operation when painting the background color.
+
+        No new tests. This is an optimization, it doesn't change any existing functionality.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::fillRect):
+        * platform/graphics/GraphicsContext.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+
 2011-06-19  Dirk Schulze  <[email protected]>
 
         Reviewed by Nikolas Zimmermann.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (89220 => 89221)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2011-06-19 20:11:24 UTC (rev 89220)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2011-06-19 20:48:17 UTC (rev 89221)
@@ -613,6 +613,17 @@
     generator.fill(this, rect);
 }
 
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op)
+{
+    if (paintingDisabled())
+        return;
+
+    CompositeOperator previousOperator = compositeOperation();
+    setCompositeOperation(op);
+    fillRect(rect, color, styleColorSpace);
+    setCompositeOperation(previousOperator);
+}
+
 void GraphicsContext::fillRoundedRect(const RoundedIntRect& rect, const Color& color, ColorSpace colorSpace)
 {
     fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (89220 => 89221)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2011-06-19 20:11:24 UTC (rev 89220)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2011-06-19 20:48:17 UTC (rev 89221)
@@ -293,6 +293,7 @@
         void fillRect(const FloatRect&);
         void fillRect(const FloatRect&, const Color&, ColorSpace);
         void fillRect(const FloatRect&, Generator&);
+        void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator);
         void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
         void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace);
         void fillRectWithRoundedHole(const IntRect&, const RoundedIntRect& roundedHoleRect, const Color&, ColorSpace);

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (89220 => 89221)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2011-06-19 20:11:24 UTC (rev 89220)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2011-06-19 20:48:17 UTC (rev 89221)
@@ -742,22 +742,23 @@
         backgroundRect.intersect(paintInfo.rect);
         // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
         Color baseColor;
+        bool shouldClearBackground = false;
         if (isOpaqueRoot) {
             baseColor = view()->frameView()->baseBackgroundColor();
             if (!baseColor.alpha())
-                context->clearRect(backgroundRect);
+                shouldClearBackground = true;
         }
 
-        if (baseColor.alpha() > 0) {
+        if (baseColor.alpha()) {
             if (bgColor.alpha())
                 baseColor = baseColor.blend(bgColor);
 
-            CompositeOperator previousOperator = context->compositeOperation();
-            context->setCompositeOperation(CompositeCopy);
-            context->fillRect(backgroundRect, baseColor, style()->colorSpace());
-            context->setCompositeOperation(previousOperator);
-        } else if (bgColor.alpha() > 0)
-            context->fillRect(backgroundRect, bgColor, style()->colorSpace());
+            context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy);
+        } else if (bgColor.alpha()) {
+            CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
+            context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation);
+        } else if (shouldClearBackground)
+            context->clearRect(backgroundRect);
     }
 
     // no progressive loading of the background image
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to