2011-04-07 Ian Henderson <ianh@apple.com>

        Reviewed by Simon Fraser.

        Optimize filling rounded rects that are actually ellipses
        https://bugs.webkit.org/show_bug.cgi?id=58098

        In CG, drawing an ellipse directly is faster than constructing and
        filling a rounded rect path.  Detect when the given rounded rect is
        actually an ellipse and draw it directly in this case.

        * platform/graphics/cg/GraphicsContextCG.cpp:
        (WebCore::GraphicsContext::fillRoundedRect):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 10e834e1
2011-04-07 Ian Henderson <ianh@apple.com>
Reviewed by Simon Fraser.
Optimize filling rounded rects that are actually ellipses
https://bugs.webkit.org/show_bug.cgi?id=58098
In CG, drawing an ellipse directly is faster than constructing and
filling a rounded rect path. Detect when the given rounded rect is
actually an ellipse and draw it directly in this case.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::fillRoundedRect):
2011-04-07 Ned Holbrook <nholbrook@apple.com>
Reviewed by Dan Bernstein.
......@@ -756,9 +756,6 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
Path path;
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
......@@ -771,7 +768,15 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
contextShadow.drawRectShadow(this, rect, RoundedIntRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
}
fillPath(path);
bool equalWidths = (topLeft.width() == topRight.width() && topRight.width() == bottomLeft.width() && bottomLeft.width() == bottomRight.width());
bool equalHeights = (topLeft.height() == bottomLeft.height() && bottomLeft.height() == topRight.height() && topRight.height() == bottomRight.height());
if (equalWidths && equalHeights && topLeft.width() * 2 == rect.width() && topLeft.height() * 2 == rect.height())
CGContextFillEllipseInRect(context, rect);
else {
Path path;
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
fillPath(path);
}
if (drawOwnShadow)
CGContextRestoreGState(context);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment