Changeset 201043 in webkit


Ignore:
Timestamp:
May 17, 2016 2:28:57 PM (8 years ago)
Author:
Simon Fraser
Message:

BitmapImage::destroyDecodedDataIfNecessary() should only count frames with image data
https://bugs.webkit.org/show_bug.cgi?id=157779

Reviewed by Tim Horton.

BitmapImage::destroyDecodedDataIfNecessary() throws away all frames of an image if the
decoded frame size exceeds a threshold. However, it counts all frames, whether or not
they have an image (some frames may only have metadata, but m_frameBytes still returns
height*width*4).

Fix by only count m_frameBytes for frames that have an image.

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::destroyDecodedDataIfNecessary):

  • platform/graphics/BitmapImage.h:

(WebCore::FrameData::FrameData):
(WebCore::FrameData::usedFrameBytes):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201040 r201043  
     12016-05-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        BitmapImage::destroyDecodedDataIfNecessary() should only count frames with image data
     4        https://bugs.webkit.org/show_bug.cgi?id=157779
     5
     6        Reviewed by Tim Horton.
     7
     8        BitmapImage::destroyDecodedDataIfNecessary() throws away all frames of an image if the
     9        decoded frame size exceeds a threshold. However, it counts all frames, whether or not
     10        they have an image (some frames may only have metadata, but m_frameBytes still returns
     11        height*width*4).
     12
     13        Fix by only count m_frameBytes for frames that have an image.
     14
     15        * platform/graphics/BitmapImage.cpp:
     16        (WebCore::BitmapImage::destroyDecodedDataIfNecessary):
     17        * platform/graphics/BitmapImage.h:
     18        (WebCore::FrameData::FrameData):
     19        (WebCore::FrameData::usedFrameBytes):
     20
    1212016-05-17  Dave Hyatt  <hyatt@apple.com>
    222
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r200967 r201043  
    158158    unsigned allFrameBytes = 0;
    159159    for (size_t i = 0; i < m_frames.size(); ++i)
    160         allFrameBytes += m_frames[i].m_frameBytes;
     160        allFrameBytes += m_frames[i].usedFrameBytes();
    161161
    162162    if (allFrameBytes > largeAnimationCutoff) {
    163         LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destryingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
     163        LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destroyingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
    164164        destroyDecodedData(destroyAll);
    165165    }
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r200939 r201043  
    7373public:
    7474    FrameData()
    75         : m_orientation(DefaultImageOrientation)
    76         , m_subsamplingLevel(0)
    77         , m_duration(0)
    78         , m_haveMetadata(false)
     75        : m_haveMetadata(false)
    7976        , m_isComplete(false)
    8077        , m_hasAlpha(true)
    81         , m_frameBytes(0)
    8278    {
    8379    }
     
    9187    // Returns whether there was cached image data to clear.
    9288    bool clear(bool clearMetadata);
     89   
     90    unsigned usedFrameBytes() const { return m_image ? m_frameBytes : 0; }
    9391
    9492    NativeImagePtr m_image;
    95     ImageOrientation m_orientation;
    96     SubsamplingLevel m_subsamplingLevel;
    97     float m_duration;
     93    ImageOrientation m_orientation { DefaultImageOrientation };
     94    SubsamplingLevel m_subsamplingLevel { 0 };
     95    float m_duration { 0 };
    9896    bool m_haveMetadata : 1;
    9997    bool m_isComplete : 1;
    10098    bool m_hasAlpha : 1;
    101     unsigned m_frameBytes;
     99    unsigned m_frameBytes { 0 };
    102100};
    103101
Note: See TracChangeset for help on using the changeset viewer.