Changeset 41358 in webkit


Ignore:
Timestamp:
Mar 2, 2009 7:37:02 AM (15 years ago)
Author:
treat@webkit.org
Message:

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):
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r41357 r41358  
     12009-03-02  Adam Treat  <adam.treat@torchmobile.com>
     2
     3        Reviewed by Adam Roben and previously by Eric Seidel and Simon Fraser.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=24227
     6        Ensure that the checkForSolidColor() optimization is correctly triggered
     7        for all cases of drawPattern.  Currently, the optimization was not triggered
     8        when the check had not been previously performed via a request for the
     9        image's NativeImagePtr.
     10
     11        Implement the Qt version of the checkForSolidColor() method.  Combined with
     12        the bug fix this reduces the time it takes to draw a repeating background
     13        of a 1x1 image from ~50msecs to ~0msecs on my machine.
     14
     15        * platform/graphics/BitmapImage.cpp:
     16        (WebCore::BitmapImage::BitmapImage):
     17        * platform/graphics/BitmapImage.h:
     18        (WebCore::BitmapImage::mayFillWithSolidColor):
     19        * platform/graphics/Image.h:
     20        (WebCore::Image::mayFillWithSolidColor):
     21        * platform/graphics/cairo/ImageCairo.cpp:
     22        (WebCore::BitmapImage::BitmapImage):
     23        (WebCore::BitmapImage::checkForSolidColor):
     24        * platform/graphics/cg/ImageCG.cpp:
     25        (WebCore::BitmapImage::BitmapImage):
     26        (WebCore::BitmapImage::checkForSolidColor):
     27        * platform/graphics/qt/ImageQt.cpp:
     28        (WebCore::BitmapImage::checkForSolidColor):
     29        * platform/graphics/skia/ImageSkia.cpp:
     30        (WebCore::BitmapImage::checkForSolidColor):
     31        * platform/graphics/wx/ImageWx.cpp:
     32        (WebCore::BitmapImage::checkForSolidColor):
     33
    1342009-03-02  Gustavo Noronha Silva  <gns@gnome.org>
    235
  • trunk/WebCore/platform/graphics/BitmapImage.cpp

    r41304 r41358  
    5454    , m_desiredFrameStartTime(0)
    5555    , m_isSolidColor(false)
     56    , m_checkedForSolidColor(false)
    5657    , m_animationFinished(false)
    5758    , m_allDataReceived(false)
  • trunk/WebCore/platform/graphics/BitmapImage.h

    r41304 r41358  
    209209   
    210210    // Checks to see if the image is a 1x1 solid color.  We optimize these images and just do a fill rect instead.
     211    // This check should happen regardless whether m_checkedForSolidColor is already set, as the frame may have
     212    // changed.
    211213    void checkForSolidColor();
    212214   
    213     virtual bool mayFillWithSolidColor() const { return m_isSolidColor && m_currentFrame == 0; }
     215    virtual bool mayFillWithSolidColor()
     216    {
     217        if (!m_checkedForSolidColor && frameCount() > 0) {
     218            checkForSolidColor();
     219            ASSERT(m_checkedForSolidColor);
     220        }
     221        return m_isSolidColor && m_currentFrame == 0;
     222    }
    214223    virtual Color solidColor() const { return m_solidColor; }
    215224   
     
    233242    Color m_solidColor;  // If we're a 1x1 solid color, this is the color to use to fill.
    234243    bool m_isSolidColor;  // Whether or not we are a 1x1 solid image.
     244    bool m_checkedForSolidColor; // Whether we've checked the frame for solid color.
    235245
    236246    bool m_animationFinished;  // Whether or not we've completed the entire animation.
  • trunk/WebCore/platform/graphics/Image.h

    r41304 r41358  
    156156
    157157    // Supporting tiled drawing
    158     virtual bool mayFillWithSolidColor() const { return false; }
     158    virtual bool mayFillWithSolidColor() { return false; }
    159159    virtual Color solidColor() const { return Color(); }
    160160   
  • trunk/WebCore/platform/graphics/cairo/ImageCairo.cpp

    r41304 r41358  
    6161    , m_repetitionsComplete(0)
    6262    , m_isSolidColor(false)
     63    , m_checkedForSolidColor(false)
    6364    , m_animationFinished(true)
    6465    , m_allDataReceived(true)
     
    183184    // FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
    184185    m_isSolidColor = false;
     186    m_checkedForSolidColor = true;
    185187}
    186188
  • trunk/WebCore/platform/graphics/cg/ImageCG.cpp

    r41304 r41358  
    7474    , m_repetitionsComplete(0)
    7575    , m_isSolidColor(false)
     76    , m_checkedForSolidColor(false)
    7677    , m_animationFinished(true)
    7778    , m_allDataReceived(true)
     
    100101void BitmapImage::checkForSolidColor()
    101102{
     103    m_checkedForSolidColor = true;
    102104    if (frameCount() > 1)
    103105        m_isSolidColor = false;
  • trunk/WebCore/platform/graphics/qt/ImageQt.cpp

    r41304 r41358  
    33 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
    44 * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
     5 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
    56 *
    67 * All rights reserved.
     
    163164void BitmapImage::checkForSolidColor()
    164165{
    165     // FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
    166166    m_isSolidColor = false;
     167    m_checkedForSolidColor = true;
     168
     169    if (frameCount() > 1)
     170        return;
     171
     172    QPixmap* framePixmap = frameAtIndex(0);
     173    if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1)
     174        return;
     175
     176    m_isSolidColor = true;
     177    m_solidColor = QColor(framePixmap->toImage().pixel(0, 0));
    167178}
    168179
  • trunk/WebCore/platform/graphics/skia/ImageSkia.cpp

    r41304 r41358  
    401401void BitmapImage::checkForSolidColor()
    402402{
     403    m_checkedForSolidColor = true;
    403404}
    404405
  • trunk/WebCore/platform/graphics/wx/ImageWx.cpp

    r41304 r41358  
    238238void BitmapImage::checkForSolidColor()
    239239{
    240 
     240    m_checkedForSolidColor = true;
    241241}
    242242
Note: See TracChangeset for help on using the changeset viewer.