2010-07-12 Andreas Kling <andreas.kling@nokia.com>

        Reviewed by Oliver Hunt.

        Canvas: Move fillRect() save/restore into GraphicsContext implementations
        https://bugs.webkit.org/show_bug.cgi?id=42088

        Saving the platform painter state is an expensive operation,
        so don't do it in fillRect() for platforms that don't need it. (CG, Qt)

        * html/canvas/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::fillRect):
        * platform/graphics/cairo/GraphicsContextCairo.cpp:
        (WebCore::GraphicsContext::fillRect):
        * platform/graphics/skia/GraphicsContextSkia.cpp:
        (WebCore::GraphicsContext::fillRect):
        * platform/graphics/wince/GraphicsContextWince.cpp:
        (WebCore::GraphicsContext::fillRect):
        * platform/graphics/wx/GraphicsContextWx.cpp:
        (WebCore::GraphicsContext::fillRect):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a936e6a5
2010-07-12 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Oliver Hunt.
Canvas: Move fillRect() save/restore into GraphicsContext implementations
https://bugs.webkit.org/show_bug.cgi?id=42088
Saving the platform painter state is an expensive operation,
so don't do it in fillRect() for platforms that don't need it. (CG, Qt)
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::fillRect):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::fillRect):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::fillRect):
* platform/graphics/wince/GraphicsContextWince.cpp:
(WebCore::GraphicsContext::fillRect):
* platform/graphics/wx/GraphicsContextWx.cpp:
(WebCore::GraphicsContext::fillRect):
2010-07-12 Nate Chapin <japhet@chromium.org>
Reviewed by Darin Fisher.
......@@ -767,9 +767,7 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei
FloatRect rect(x, y, width, height);
willDraw(rect);
c->save();
c->fillRect(rect);
c->restore();
}
void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float height)
......
......@@ -563,8 +563,10 @@ void GraphicsContext::fillRect(const FloatRect& rect)
return;
cairo_t* cr = m_data->cr;
cairo_save(cr);
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
fillPath();
cairo_restore(cr);
}
static void drawBorderlessRectShadow(GraphicsContext* context, const FloatRect& rect, const Color& rectColor)
......
......@@ -737,6 +737,8 @@ void GraphicsContext::fillRect(const FloatRect& rect)
if (paintingDisabled())
return;
platformContext()->save();
SkRect r = rect;
if (!isRectSkiaSafe(getCTM(), r)) {
// See the other version of fillRect below.
......@@ -746,6 +748,8 @@ void GraphicsContext::fillRect(const FloatRect& rect)
SkPaint paint;
platformContext()->setupPaintForFilling(&paint);
platformContext()->canvas()->drawRect(r, paint);
platformContext()->restore();
}
void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
......
......@@ -1555,10 +1555,14 @@ void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*)
void GraphicsContext::fillRect(const FloatRect& rect)
{
savePlatformState();
if (m_common->state.fillGradient)
fillRect(rect, m_common->state.fillGradient.get());
else
fillRect(rect, fillColor(), DeviceColorSpace);
restorePlatformState();
}
void GraphicsContext::setPlatformShadow(const FloatSize&, float, const Color&, ColorSpace)
......
......@@ -272,9 +272,13 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
if (paintingDisabled())
return;
savePlatformState();
m_data->context->SetPen(*wxTRANSPARENT_PEN);
m_data->context->SetBrush(wxBrush(color));
m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height());
restorePlatformState();
}
void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
......
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