Changeset 215613 in webkit
- Timestamp:
- Apr 21, 2017, 9:58:49 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r215612 r215613 1 2017-04-21 Gwang Yoon Hwang <yoon@igalia.com> 2 3 Do not paint the border of the box if the dirty region does not intersect with border area 4 https://bugs.webkit.org/show_bug.cgi?id=170988 5 6 Reviewed by Simon Fraser. 7 8 No new tests, since there is no change in behavior. 9 10 * platform/graphics/GeometryUtilities.cpp: 11 (WebCore::ellipseContainsPoint): 12 Checks if a point is within an ellipse. 13 14 * platform/graphics/GeometryUtilities.h: 15 Replace header-guards with #pragma once. 16 17 * platform/graphics/RoundedRect.cpp: 18 (WebCore::RoundedRect::contains): 19 Implemented to know the dirty rectangle intersects with rounded rectangle or not. 20 * platform/graphics/RoundedRect.h: 21 * rendering/RenderBoxModelObject.cpp: 22 (WebCore::RenderBoxModelObject::paintBorder): 23 When typing in decorated text box, the dirty rect generated only for the 24 inside of the text box, not for the decorations. So we can avoid the 25 calculations to draw borders if the inner border totally covers the 26 target surface. It will optimize the rendering process since we don't 27 have to render border decorations whenever we type somethings in side of 28 the text input element. 29 1 30 2017-04-21 Anders Carlsson <andersca@apple.com> 2 31 -
trunk/Source/WebCore/platform/graphics/GeometryUtilities.cpp
r181770 r215613 147 147 } 148 148 149 bool ellipseContainsPoint(const FloatPoint& center, const FloatSize& radii, const FloatPoint& point) 150 { 151 FloatPoint transformedPoint(point); 152 transformedPoint.move(-center.x(), -center.y()); 153 transformedPoint.scale(radii.height(), radii.width()); 154 float radius = radii.width() * radii.height(); 155 156 if (transformedPoint.x() > radius || transformedPoint.y() > radius) 157 return false; 158 if (transformedPoint.x() + transformedPoint.y() <= radius) 159 return true; 160 return (transformedPoint.lengthSquared() <= radius * radius); 149 161 } 162 163 } -
trunk/Source/WebCore/platform/graphics/GeometryUtilities.h
r181770 r215613 24 24 */ 25 25 26 #ifndef GeometryUtilities_h 27 #define GeometryUtilities_h 26 #pragma once 28 27 29 28 #include "FloatRect.h" … … 52 51 FloatRect boundsOfRotatingRect(const FloatRect&); 53 52 53 bool ellipseContainsPoint(const FloatPoint& center, const FloatSize& radii, const FloatPoint&); 54 54 } 55 56 #endif // GeometryUtilities_h -
trunk/Source/WebCore/platform/graphics/RoundedRect.cpp
r173047 r215613 30 30 31 31 #include "FloatRoundedRect.h" 32 #include "GeometryUtilities.h" 32 33 #include "LayoutRect.h" 33 34 #include "LayoutUnit.h" … … 237 238 } 238 239 240 bool RoundedRect::contains(const LayoutRect& otherRect) const 241 { 242 if (!rect().contains(otherRect)) 243 return false; 244 245 const LayoutSize& topLeft = m_radii.topLeft(); 246 if (!topLeft.isEmpty()) { 247 FloatPoint center = { m_rect.x() + topLeft.width(), m_rect.y() + topLeft.height() }; 248 if (otherRect.x() <= center.x() && otherRect.y() <= center.y()) { 249 if (!ellipseContainsPoint(center, topLeft, otherRect.location())) 250 return false; 251 } 252 } 253 254 const LayoutSize& topRight = m_radii.topRight(); 255 if (!topRight.isEmpty()) { 256 FloatPoint center = { m_rect.maxX() - topRight.width(), m_rect.y() + topRight.height() }; 257 if (otherRect.maxX() >= center.x() && otherRect.y() <= center.y()) { 258 if (!ellipseContainsPoint(center, topRight, otherRect.location())) 259 return false; 260 } 261 } 262 263 const LayoutSize& bottomLeft = m_radii.bottomLeft(); 264 if (!bottomLeft.isEmpty()) { 265 FloatPoint center = { m_rect.x() + bottomLeft.width(), m_rect.maxY() - bottomLeft.height() }; 266 if (otherRect.maxX() >= center.x() && otherRect.maxY() >= center.y()) { 267 if (!ellipseContainsPoint(center, bottomLeft, otherRect.location())) 268 return false; 269 } 270 } 271 272 const LayoutSize& bottomRight = m_radii.bottomRight(); 273 if (!bottomRight.isEmpty()) { 274 FloatPoint center = { m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height() }; 275 if (otherRect.x() <= center.x() && otherRect.maxY() >= center.y()) { 276 if (!ellipseContainsPoint(center, bottomRight, otherRect.location())) 277 return false; 278 } 279 } 280 281 return true; 282 } 283 239 284 FloatRoundedRect RoundedRect::pixelSnappedRoundedRectForPainting(float deviceScaleFactor) const 240 285 { -
trunk/Source/WebCore/platform/graphics/RoundedRect.h
r170458 r215613 107 107 // This only works for convex quads. 108 108 bool intersectsQuad(const FloatQuad&) const; 109 bool contains(const LayoutRect&) const; 109 110 110 111 FloatRoundedRect pixelSnappedRoundedRectForPainting(float deviceScaleFactor) const; -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r214450 r215613 1735 1735 RoundedRect innerBorder = style.getRoundedInnerBorderFor(borderInnerRectAdjustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLeftEdge, includeLogicalRightEdge); 1736 1736 1737 // If no borders intersects with the dirty area, we can skip the border painting. 1738 if (innerBorder.contains(info.rect)) 1739 return; 1740 1737 1741 bool haveAlphaColor = false; 1738 1742 bool haveAllSolidEdges = true;
Note:
See TracChangeset
for help on using the changeset viewer.