Title: [135167] trunk/Source/WebCore
Revision
135167
Author
commit-qu...@webkit.org
Date
2012-11-19 08:56:46 -0800 (Mon, 19 Nov 2012)

Log Message

Improve performance of RenderBoxModelObject::paintTranslucentBorderSides()
https://bugs.webkit.org/show_bug.cgi?id=98660

Patch by Tom Hudson <tomhud...@chromium.org> on 2012-11-19
Reviewed by Simon Fraser.

Accumulate edges[i].shouldRender() in a flag field and pass that to paintBorderSides()
and paintTranslucentBorderSides() so that we don't do unnecessary work.

If we can avoid setting up and tearing down an unnecessary transparent layer we save
30ms on some mobile platforms.

* rendering/RenderBoxModelObject.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder):
(WebCore::RenderBoxModelObject::paintTranslucentBorderSides):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135166 => 135167)


--- trunk/Source/WebCore/ChangeLog	2012-11-19 16:54:54 UTC (rev 135166)
+++ trunk/Source/WebCore/ChangeLog	2012-11-19 16:56:46 UTC (rev 135167)
@@ -1,3 +1,21 @@
+2012-11-19  Tom Hudson  <tomhud...@chromium.org>
+
+        Improve performance of RenderBoxModelObject::paintTranslucentBorderSides()
+        https://bugs.webkit.org/show_bug.cgi?id=98660
+
+        Reviewed by Simon Fraser.
+
+        Accumulate edges[i].shouldRender() in a flag field and pass that to paintBorderSides()
+        and paintTranslucentBorderSides() so that we don't do unnecessary work.
+
+        If we can avoid setting up and tearing down an unnecessary transparent layer we save
+        30ms on some mobile platforms.
+
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintBorder):
+        (WebCore::RenderBoxModelObject::paintTranslucentBorderSides):
+
 2012-11-19  Hans Muller  <hmul...@adobe.com>
 
         [CSS Exclusions] remove null exclusion shape check from ExclusionShape::createExclusionShape

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (135166 => 135167)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-11-19 16:54:54 UTC (rev 135166)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-11-19 16:56:46 UTC (rev 135167)
@@ -1790,9 +1790,8 @@
 }
 
 void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext* graphicsContext, const RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment,
-                                                       const BorderEdge edges[], BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias)
+    const BorderEdge edges[], BorderEdgeFlags edgesToDraw, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias)
 {
-    BorderEdgeFlags edgesToDraw = AllBorderEdges;
     while (edgesToDraw) {
         // Find undrawn edges sharing a color.
         Color commonColor;
@@ -1851,9 +1850,14 @@
     int numEdgesVisible = 4;
     bool allEdgesShareColor = true;
     int firstVisibleEdge = -1;
+    BorderEdgeFlags edgesToDraw = 0;
 
     for (int i = BSTop; i <= BSLeft; ++i) {
         const BorderEdge& currEdge = edges[i];
+
+        if (edges[i].shouldRender())
+            edgesToDraw |= edgeFlagForSide(static_cast<BoxSide>(i));
+
         if (currEdge.presentButInvisible()) {
             --numEdgesVisible;
             allEdgesShareColor = false;
@@ -1982,9 +1986,9 @@
     RoundedRect unadjustedInnerBorder = (bleedAvoidance == BackgroundBleedBackgroundOverBorder) ? style->getRoundedInnerBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge) : innerBorder;
     IntPoint innerBorderAdjustment(innerBorder.rect().x() - unadjustedInnerBorder.rect().x(), innerBorder.rect().y() - unadjustedInnerBorder.rect().y());
     if (haveAlphaColor)
-        paintTranslucentBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
+        paintTranslucentBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, edgesToDraw, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
     else
-        paintBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, AllBorderEdges, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
+        paintBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, edgesToDraw, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
 }
 
 void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, const LayoutRect& borderRect, const Path& borderPath, const BorderEdge edges[],

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (135166 => 135167)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-11-19 16:54:54 UTC (rev 135166)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-11-19 16:56:46 UTC (rev 135167)
@@ -298,7 +298,7 @@
                                 const IntRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const class BorderEdge[],
                                 const Path*, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor = 0);
     void paintTranslucentBorderSides(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment,
-                          const class BorderEdge[], BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false);
+        const class BorderEdge[], BorderEdgeFlags, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false);
     void paintBorderSides(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
         const IntPoint& innerBorderAdjustment, const class BorderEdge[], BorderEdgeFlags, BackgroundBleedAvoidance,
         bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false, const Color* overrideColor = 0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to