Changeset 41295 in webkit


Ignore:
Timestamp:
Feb 27, 2009 12:42:51 PM (15 years ago)
Author:
treat@webkit.org
Message:

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

Reviewed 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):
  • 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

    r41294 r41295  
     12009-02-27  Adam Treat  <adam.treat@torchmobile.com>
     2
     3        Reviewed 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        * platform/graphics/cg/ImageCG.cpp:
     24        (WebCore::BitmapImage::BitmapImage):
     25        (WebCore::BitmapImage::checkForSolidColor):
     26        * platform/graphics/qt/ImageQt.cpp:
     27        (WebCore::BitmapImage::checkForSolidColor):
     28        * platform/graphics/skia/ImageSkia.cpp:
     29        (WebCore::BitmapImage::checkForSolidColor):
     30        * platform/graphics/wx/ImageWx.cpp:
     31        (WebCore::BitmapImage::checkForSolidColor):
     32
    1332009-02-27  Dirk Schulze  <krit@webkit.org>
    234
  • trunk/WebCore/platform/graphics/BitmapImage.cpp

    r39964 r41295  
    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

    r40759 r41295  
    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) {
     218            ASSERT(m_haveFrameCount);
     219            checkForSolidColor();
     220            ASSERT(m_checkedForSolidColor);
     221        }
     222        return m_isSolidColor && m_currentFrame == 0;
     223    }
    214224    virtual Color solidColor() const { return m_solidColor; }
    215225   
     
    233243    Color m_solidColor;  // If we're a 1x1 solid color, this is the color to use to fill.
    234244    bool m_isSolidColor;  // Whether or not we are a 1x1 solid image.
     245    bool m_checkedForSolidColor; // Whether we've checked the frame for solid color.
    235246
    236247    bool m_animationFinished;  // Whether or not we've completed the entire animation.
  • trunk/WebCore/platform/graphics/Image.h

    r40011 r41295  
    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

    r39751 r41295  
    6161    , m_repetitionsComplete(0)
    6262    , m_isSolidColor(false)
     63    , m_checkedForSolidColor(false)
    6364    , m_animationFinished(true)
    6465    , m_allDataReceived(true)
  • trunk/WebCore/platform/graphics/cg/ImageCG.cpp

    r39751 r41295  
    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

    r40759 r41295  
    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.
     
    158159void BitmapImage::checkForSolidColor()
    159160{
    160     // FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
    161161    m_isSolidColor = false;
     162    m_checkedForSolidColor = true;
     163
     164    if (frameCount() > 1)
     165        return;
     166
     167    QPixmap* framePixmap = frameAtIndex(0);
     168    if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1)
     169        return;
     170
     171    m_isSolidColor = true;
     172    m_solidColor = QColor(framePixmap->toImage().pixel(0, 0));
    162173}
    163174
  • trunk/WebCore/platform/graphics/skia/ImageSkia.cpp

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

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