Title: [216494] releases/WebKitGTK/webkit-2.14/Source/WebCore
Revision
216494
Author
carlo...@webkit.org
Date
2017-05-09 03:11:46 -0700 (Tue, 09 May 2017)

Log Message

Merge r215613 - Do not paint the border of the box if the dirty region does not intersect with border area
https://bugs.webkit.org/show_bug.cgi?id=170988

Reviewed by Simon Fraser.

No new tests, since there is no change in behavior.

* platform/graphics/GeometryUtilities.cpp:
(WebCore::ellipseContainsPoint):
Checks if a point is within an ellipse.

* platform/graphics/GeometryUtilities.h:
Replace header-guards with #pragma once.

* platform/graphics/RoundedRect.cpp:
(WebCore::RoundedRect::contains):
Implemented to know the dirty rectangle intersects with rounded rectangle or not.
* platform/graphics/RoundedRect.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder):
When typing in decorated text box, the dirty rect generated only for the
inside of the text box, not for the decorations.  So we can avoid the
calculations to draw borders if the inner border totally covers the
target surface. It will optimize the rendering process since we don't
have to render border decorations whenever we type somethings in side of
the text input element.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (216493 => 216494)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2017-05-09 10:00:05 UTC (rev 216493)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2017-05-09 10:11:46 UTC (rev 216494)
@@ -1,3 +1,32 @@
+2017-04-21  Gwang Yoon Hwang  <y...@igalia.com>
+
+        Do not paint the border of the box if the dirty region does not intersect with border area
+        https://bugs.webkit.org/show_bug.cgi?id=170988
+
+        Reviewed by Simon Fraser.
+
+        No new tests, since there is no change in behavior.
+
+        * platform/graphics/GeometryUtilities.cpp:
+        (WebCore::ellipseContainsPoint):
+        Checks if a point is within an ellipse.
+
+        * platform/graphics/GeometryUtilities.h:
+        Replace header-guards with #pragma once.
+
+        * platform/graphics/RoundedRect.cpp:
+        (WebCore::RoundedRect::contains):
+        Implemented to know the dirty rectangle intersects with rounded rectangle or not.
+        * platform/graphics/RoundedRect.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintBorder):
+        When typing in decorated text box, the dirty rect generated only for the
+        inside of the text box, not for the decorations.  So we can avoid the
+        calculations to draw borders if the inner border totally covers the
+        target surface. It will optimize the rendering process since we don't
+        have to render border decorations whenever we type somethings in side of
+        the text input element.
+
 2017-05-05  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GStreamer] Do not report more errors after the first one

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GeometryUtilities.cpp (216493 => 216494)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GeometryUtilities.cpp	2017-05-09 10:00:05 UTC (rev 216493)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GeometryUtilities.cpp	2017-05-09 10:11:46 UTC (rev 216494)
@@ -146,4 +146,18 @@
     return destRect;
 }
 
+bool ellipseContainsPoint(const FloatPoint& center, const FloatSize& radii, const FloatPoint& point)
+{
+    FloatPoint transformedPoint(point);
+    transformedPoint.move(-center.x(), -center.y());
+    transformedPoint.scale(radii.height(), radii.width());
+    float radius = radii.width() * radii.height();
+
+    if (transformedPoint.x() > radius || transformedPoint.y() > radius)
+        return false;
+    if (transformedPoint.x() + transformedPoint.y() <= radius)
+        return true;
+    return (transformedPoint.lengthSquared() <= radius * radius);
 }
+
+}

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GeometryUtilities.h (216493 => 216494)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GeometryUtilities.h	2017-05-09 10:00:05 UTC (rev 216493)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GeometryUtilities.h	2017-05-09 10:11:46 UTC (rev 216494)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef GeometryUtilities_h
-#define GeometryUtilities_h
+#pragma once
 
 #include "FloatRect.h"
 #include "IntRect.h"
@@ -51,6 +50,5 @@
 // Compute a rect that encloses all points covered by the given rect if it were rotated a full turn around (0,0).
 FloatRect boundsOfRotatingRect(const FloatRect&);
 
+bool ellipseContainsPoint(const FloatPoint& center, const FloatSize& radii, const FloatPoint&);
 }
-
-#endif // GeometryUtilities_h

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/RoundedRect.cpp (216493 => 216494)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/RoundedRect.cpp	2017-05-09 10:00:05 UTC (rev 216493)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/RoundedRect.cpp	2017-05-09 10:11:46 UTC (rev 216494)
@@ -29,6 +29,7 @@
 #include "RoundedRect.h"
 
 #include "FloatRoundedRect.h"
+#include "GeometryUtilities.h"
 #include "LayoutRect.h"
 #include "LayoutUnit.h"
 
@@ -236,6 +237,50 @@
     return true;
 }
 
+bool RoundedRect::contains(const LayoutRect& otherRect) const
+{
+    if (!rect().contains(otherRect))
+        return false;
+
+    const LayoutSize& topLeft = m_radii.topLeft();
+    if (!topLeft.isEmpty()) {
+        FloatPoint center = { m_rect.x() + topLeft.width(), m_rect.y() + topLeft.height() };
+        if (otherRect.x() <= center.x() && otherRect.y() <= center.y()) {
+            if (!ellipseContainsPoint(center, topLeft, otherRect.location()))
+                return false;
+        }
+    }
+
+    const LayoutSize& topRight = m_radii.topRight();
+    if (!topRight.isEmpty()) {
+        FloatPoint center = { m_rect.maxX() - topRight.width(), m_rect.y() + topRight.height() };
+        if (otherRect.maxX() >= center.x() && otherRect.y() <= center.y()) {
+            if (!ellipseContainsPoint(center, topRight, otherRect.location()))
+                return false;
+        }
+    }
+
+    const LayoutSize& bottomLeft = m_radii.bottomLeft();
+    if (!bottomLeft.isEmpty()) {
+        FloatPoint center = { m_rect.x() + bottomLeft.width(), m_rect.maxY() - bottomLeft.height() };
+        if (otherRect.maxX() >= center.x() && otherRect.maxY() >= center.y()) {
+            if (!ellipseContainsPoint(center, bottomLeft, otherRect.location()))
+                return false;
+        }
+    }
+
+    const LayoutSize& bottomRight = m_radii.bottomRight();
+    if (!bottomRight.isEmpty()) {
+        FloatPoint center = { m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height() };
+        if (otherRect.x() <= center.x() && otherRect.maxY() >= center.y()) {
+            if (!ellipseContainsPoint(center, bottomRight, otherRect.location()))
+                return false;
+        }
+    }
+
+    return true;
+}
+
 FloatRoundedRect RoundedRect::pixelSnappedRoundedRectForPainting(float deviceScaleFactor) const
 {
     LayoutRect originalRect = rect();

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/RoundedRect.h (216493 => 216494)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/RoundedRect.h	2017-05-09 10:00:05 UTC (rev 216493)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/RoundedRect.h	2017-05-09 10:11:46 UTC (rev 216494)
@@ -106,6 +106,7 @@
     // Tests whether the quad intersects any part of this rounded rectangle.
     // This only works for convex quads.
     bool intersectsQuad(const FloatQuad&) const;
+    bool contains(const LayoutRect&) const;
 
     FloatRoundedRect pixelSnappedRoundedRectForPainting(float deviceScaleFactor) const;
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderBoxModelObject.cpp (216493 => 216494)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderBoxModelObject.cpp	2017-05-09 10:00:05 UTC (rev 216493)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderBoxModelObject.cpp	2017-05-09 10:11:46 UTC (rev 216494)
@@ -1691,6 +1691,10 @@
     RoundedRect outerBorder = style.getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
     RoundedRect innerBorder = style.getRoundedInnerBorderFor(borderInnerRectAdjustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLeftEdge, includeLogicalRightEdge);
 
+    // If no borders intersects with the dirty area, we can skip the border painting.
+    if (innerBorder.contains(info.rect))
+        return;
+
     bool haveAlphaColor = false;
     bool haveAllSolidEdges = true;
     bool haveAllDoubleEdges = true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to