Changeset 199821 in webkit


Ignore:
Timestamp:
Apr 21, 2016 10:02:57 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION(198782): ImageSource::subsamplingLevelForScale() does not cache the MaximumSubsamplingLevel for this ImageSource
https://bugs.webkit.org/show_bug.cgi?id=156766

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2016-04-21
Reviewed by Darin Adler.

Ensure the MaximumSubsamplingLevel for the ImageSource is calculated
only once and is cached for subsequent uses.

The image subsampling is on by default only for iOS. So the and this
patch currently affects the iOS port.

  • platform/graphics/ImageSource.cpp:

(WebCore::ImageSource::cacheMetadata): Cache m_maximumSubsamplingLevel.
Use m_frameCount as a flag for having_the_cache_done.
(WebCore::ImageSource::subsamplingLevelForScale): Call cacheMetadata()
before using m_maximumSubsamplingLevel.
(WebCore::ImageSource::frameCount): Call cacheMetadata() before returning
m_frameCount.

  • platform/graphics/ImageSource.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r199819 r199821  
     12016-04-21  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION(198782): ImageSource::subsamplingLevelForScale() does not cache the MaximumSubsamplingLevel for this ImageSource
     4        https://bugs.webkit.org/show_bug.cgi?id=156766
     5
     6        Reviewed by Darin Adler.
     7
     8        Ensure the MaximumSubsamplingLevel for the ImageSource is calculated
     9        only once and is cached for subsequent uses.
     10       
     11        The image subsampling is on by default only for iOS. So the and this
     12        patch currently affects the iOS port.
     13
     14        * platform/graphics/ImageSource.cpp:
     15        (WebCore::ImageSource::cacheMetadata): Cache m_maximumSubsamplingLevel.
     16        Use m_frameCount as a flag for having_the_cache_done.
     17        (WebCore::ImageSource::subsamplingLevelForScale): Call cacheMetadata()
     18        before using m_maximumSubsamplingLevel.
     19        (WebCore::ImageSource::frameCount): Call cacheMetadata() before returning
     20        m_frameCount.
     21        * platform/graphics/ImageSource.h:
     22
    1232016-04-21  Antoine Quint  <graouts@apple.com>
    224
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r199764 r199821  
    105105}
    106106
    107 SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const
     107void ImageSource::cacheMetadata()
     108{
     109    if (m_frameCount || !isSizeAvailable())
     110        return;
     111   
     112    m_frameCount = m_decoder->frameCount();
     113    m_maximumSubsamplingLevel = calculateMaximumSubsamplingLevel();
     114}
     115   
     116SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale)
    108117{
    109118    if (!(scale > 0 && scale <= 1))
    110119        return 0;
    111120   
    112     SubsamplingLevel maximumSubsamplingLevel = calculateMaximumSubsamplingLevel();
    113     if (!maximumSubsamplingLevel)
     121    cacheMetadata();
     122    if (!m_maximumSubsamplingLevel)
    114123        return 0;
    115124
    116125    // There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
    117126    SubsamplingLevel result = std::ceil(std::log2(1 / scale));
    118     return std::min(result, maximumSubsamplingLevel);
     127    return std::min(result, m_maximumSubsamplingLevel);
    119128}
    120129
     
    139148}
    140149
    141 size_t ImageSource::frameCount() const
    142 {
    143     return initialized() ? m_decoder->frameCount() : 0;
     150size_t ImageSource::frameCount()
     151{
     152    cacheMetadata();
     153    return m_frameCount;
    144154}
    145155
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r199764 r199821  
    111111    void setData(SharedBuffer* data, bool allDataReceived);
    112112
    113     SubsamplingLevel subsamplingLevelForScale(float) const;
     113    SubsamplingLevel subsamplingLevelForScale(float);
    114114    void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; }
    115115    static size_t bytesDecodedToDetermineProperties();
     
    120120    IntSize sizeRespectingOrientation() const;
    121121
    122     size_t frameCount() const;
     122    size_t frameCount();
    123123    int repetitionCount();
    124124    String filenameExtension() const;
     
    146146    void clearFrameBufferCache(size_t);
    147147    SubsamplingLevel calculateMaximumSubsamplingLevel() const;
     148    void cacheMetadata();
    148149    void dump(TextStream&) const;
    149150   
    150151    std::unique_ptr<ImageDecoder> m_decoder;
     152   
     153    size_t m_frameCount { 0 };
     154    SubsamplingLevel m_maximumSubsamplingLevel { 0 };
    151155
    152156    // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
Note: See TracChangeset for help on using the changeset viewer.