Commit f793b273 authored by treat@webkit.org's avatar treat@webkit.org
Browse files

2009-03-02 Adam Treat <adam.treat@torchmobile.com>

        Reviewed by Adam Roben and previously by Eric Seidel and Simon Fraser.

        https://bugs.webkit.org/show_bug.cgi?id=24227
        Ensure that the checkForSolidColor() optimization is correctly triggered
        for all cases of drawPattern.  Currently, the optimization was not triggered
        when the check had not been previously performed via a request for the
        image's NativeImagePtr.

        Implement the Qt version of the checkForSolidColor() method.  Combined with
        the bug fix this reduces the time it takes to draw a repeating background
        of a 1x1 image from ~50msecs to ~0msecs on my machine.

        * platform/graphics/BitmapImage.cpp:
        (WebCore::BitmapImage::BitmapImage):
        * platform/graphics/BitmapImage.h:
        (WebCore::BitmapImage::mayFillWithSolidColor):
        * platform/graphics/Image.h:
        (WebCore::Image::mayFillWithSolidColor):
        * platform/graphics/cairo/ImageCairo.cpp:
        (WebCore::BitmapImage::BitmapImage):
        (WebCore::BitmapImage::checkForSolidColor):
        * platform/graphics/cg/ImageCG.cpp:
        (WebCore::BitmapImage::BitmapImage):
        (WebCore::BitmapImage::checkForSolidColor):
        * platform/graphics/qt/ImageQt.cpp:
        (WebCore::BitmapImage::checkForSolidColor):
        * platform/graphics/skia/ImageSkia.cpp:
        (WebCore::BitmapImage::checkForSolidColor):
        * platform/graphics/wx/ImageWx.cpp:
        (WebCore::BitmapImage::checkForSolidColor):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 485273b3
2009-03-02 Adam Treat <adam.treat@torchmobile.com>
Reviewed by Adam Roben and previously by Eric Seidel and Simon Fraser.
https://bugs.webkit.org/show_bug.cgi?id=24227
Ensure that the checkForSolidColor() optimization is correctly triggered
for all cases of drawPattern. Currently, the optimization was not triggered
when the check had not been previously performed via a request for the
image's NativeImagePtr.
Implement the Qt version of the checkForSolidColor() method. Combined with
the bug fix this reduces the time it takes to draw a repeating background
of a 1x1 image from ~50msecs to ~0msecs on my machine.
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/BitmapImage.h:
(WebCore::BitmapImage::mayFillWithSolidColor):
* platform/graphics/Image.h:
(WebCore::Image::mayFillWithSolidColor):
* platform/graphics/cairo/ImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::checkForSolidColor):
* platform/graphics/cg/ImageCG.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::checkForSolidColor):
* platform/graphics/qt/ImageQt.cpp:
(WebCore::BitmapImage::checkForSolidColor):
* platform/graphics/skia/ImageSkia.cpp:
(WebCore::BitmapImage::checkForSolidColor):
* platform/graphics/wx/ImageWx.cpp:
(WebCore::BitmapImage::checkForSolidColor):
2009-03-02 Gustavo Noronha Silva <gns@gnome.org>
 
Unreviewed build fix; adding missing files to EXTRA_DIST, so that
......@@ -53,6 +53,7 @@ BitmapImage::BitmapImage(ImageObserver* observer)
, m_repetitionsComplete(0)
, m_desiredFrameStartTime(0)
, m_isSolidColor(false)
, m_checkedForSolidColor(false)
, m_animationFinished(false)
, m_allDataReceived(false)
, m_haveSize(false)
......
......@@ -208,9 +208,18 @@ protected:
void invalidatePlatformData();
// Checks to see if the image is a 1x1 solid color. We optimize these images and just do a fill rect instead.
// This check should happen regardless whether m_checkedForSolidColor is already set, as the frame may have
// changed.
void checkForSolidColor();
virtual bool mayFillWithSolidColor() const { return m_isSolidColor && m_currentFrame == 0; }
virtual bool mayFillWithSolidColor()
{
if (!m_checkedForSolidColor && frameCount() > 0) {
checkForSolidColor();
ASSERT(m_checkedForSolidColor);
}
return m_isSolidColor && m_currentFrame == 0;
}
virtual Color solidColor() const { return m_solidColor; }
ImageSource m_source;
......@@ -232,6 +241,7 @@ protected:
Color m_solidColor; // If we're a 1x1 solid color, this is the color to use to fill.
bool m_isSolidColor; // Whether or not we are a 1x1 solid image.
bool m_checkedForSolidColor; // Whether we've checked the frame for solid color.
bool m_animationFinished; // Whether or not we've completed the entire animation.
......
......@@ -155,7 +155,7 @@ protected:
void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, CompositeOperator);
// Supporting tiled drawing
virtual bool mayFillWithSolidColor() const { return false; }
virtual bool mayFillWithSolidColor() { return false; }
virtual Color solidColor() const { return Color(); }
virtual void startAnimation(bool /*catchUpIfNecessary*/ = true) { }
......
......@@ -60,6 +60,7 @@ BitmapImage::BitmapImage(cairo_surface_t* surface, ImageObserver* observer)
, m_repetitionCountStatus(Unknown)
, m_repetitionsComplete(0)
, m_isSolidColor(false)
, m_checkedForSolidColor(false)
, m_animationFinished(true)
, m_allDataReceived(true)
, m_haveSize(true)
......@@ -182,6 +183,7 @@ void BitmapImage::checkForSolidColor()
{
// FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
m_isSolidColor = false;
m_checkedForSolidColor = true;
}
}
......
......@@ -73,6 +73,7 @@ BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer)
, m_repetitionCountStatus(Unknown)
, m_repetitionsComplete(0)
, m_isSolidColor(false)
, m_checkedForSolidColor(false)
, m_animationFinished(true)
, m_allDataReceived(true)
, m_haveSize(true)
......@@ -99,6 +100,7 @@ BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer)
void BitmapImage::checkForSolidColor()
{
m_checkedForSolidColor = true;
if (frameCount() > 1)
m_isSolidColor = false;
else {
......
......@@ -2,6 +2,7 @@
* Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
* Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
*
* All rights reserved.
*
......@@ -162,8 +163,18 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
void BitmapImage::checkForSolidColor()
{
// FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
m_isSolidColor = false;
m_checkedForSolidColor = true;
if (frameCount() > 1)
return;
QPixmap* framePixmap = frameAtIndex(0);
if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1)
return;
m_isSolidColor = true;
m_solidColor = QColor(framePixmap->toImage().pixel(0, 0));
}
}
......
......@@ -400,6 +400,7 @@ void BitmapImage::invalidatePlatformData()
void BitmapImage::checkForSolidColor()
{
m_checkedForSolidColor = true;
}
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
......
......@@ -237,7 +237,7 @@ void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, c
void BitmapImage::checkForSolidColor()
{
m_checkedForSolidColor = true;
}
void BitmapImage::invalidatePlatformData()
......
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