Changeset 160260 in webkit


Ignore:
Timestamp:
Dec 6, 2013 4:45:11 PM (10 years ago)
Author:
timothy_horton@apple.com
Message:

[mac] Keep around more decoded image data, since it's purgeable
https://bugs.webkit.org/show_bug.cgi?id=125273
<rdar://problem/13205438>

Reviewed by Simon Fraser.

No new tests, just an optimization.

Instead of throwing away decoded image data eagerly, allow the operating
system to manage the memory via the standard purgeability mechanism,
where it can.

This improves the performance on some pathological cases (extremely large
animated GIFs) by up to 8x.

  • loader/cache/MemoryCache.cpp:

(WebCore::MemoryCache::pruneLiveResourcesToSize):
Don't prune live resources' decoded data if it is purgeable.

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::destroyDecodedDataIfNecessary):
Don't eagerly throw away decoded image data if it's purgeable.

  • loader/cache/CachedImage.h:
  • loader/cache/CachedResource.h:

(WebCore::CachedResource::decodedDataIsPurgeable):

  • platform/graphics/BitmapImage.h:
  • platform/graphics/Image.h:

(WebCore::Image::decodedDataIsPurgeable):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r160259 r160260  
     12013-12-06  Tim Horton  <timothy_horton@apple.com>
     2
     3        [mac] Keep around more decoded image data, since it's purgeable
     4        https://bugs.webkit.org/show_bug.cgi?id=125273
     5        <rdar://problem/13205438>
     6
     7        Reviewed by Simon Fraser.
     8
     9        No new tests, just an optimization.
     10
     11        Instead of throwing away decoded image data eagerly, allow the operating
     12        system to manage the memory via the standard purgeability mechanism,
     13        where it can.
     14
     15        This improves the performance on some pathological cases (extremely large
     16        animated GIFs) by up to 8x.
     17
     18        * loader/cache/MemoryCache.cpp:
     19        (WebCore::MemoryCache::pruneLiveResourcesToSize):
     20        Don't prune live resources' decoded data if it is purgeable.
     21
     22        * platform/graphics/BitmapImage.cpp:
     23        (WebCore::BitmapImage::destroyDecodedDataIfNecessary):
     24        Don't eagerly throw away decoded image data if it's purgeable.
     25
     26        * loader/cache/CachedImage.h:
     27        * loader/cache/CachedResource.h:
     28        (WebCore::CachedResource::decodedDataIsPurgeable):
     29        * platform/graphics/BitmapImage.h:
     30        * platform/graphics/Image.h:
     31        (WebCore::Image::decodedDataIsPurgeable):
     32
    1332013-12-06  Antti Koivisto  <antti@apple.com>
    234
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r159503 r160260  
    120120    virtual bool stillNeedsLoad() const OVERRIDE { return !errorOccurred() && status() == Unknown && !isLoading(); }
    121121
     122    virtual bool decodedDataIsPurgeable() const OVERRIDE { return m_image && m_image->decodedDataIsPurgeable(); }
     123
    122124    // ImageObserver
    123125    virtual void decodedSizeChanged(const Image*, int delta) OVERRIDE;
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r157653 r160260  
    150150    unsigned decodedSize() const { return m_decodedSize; }
    151151    unsigned overheadSize() const;
     152
     153    virtual bool decodedDataIsPurgeable() const { return false; }
    152154   
    153155    bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccurate. Loading might not have started yet.
  • trunk/Source/WebCore/loader/cache/MemoryCache.cpp

    r159679 r160260  
    267267                return;
    268268
     269            if (current->decodedDataIsPurgeable())
     270                continue;
     271
    269272            // Destroy our decoded data. This will remove us from
    270273            // m_liveDecodedResources, and possibly move us to a different LRU
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r160207 r160260  
    103103    static const unsigned cLargeAnimationCutoff = 5242880;
    104104
     105    // If decoded data is purgeable, the operating system will
     106    // take care of throwing it away when the system is under pressure.
     107    if (decodedDataIsPurgeable())
     108        return;
     109
    105110    // If we have decoded frames but there is no encoded data, we shouldn't destroy
    106111    // the decoded image since we won't be able to reconstruct it later.
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r160212 r160260  
    261261
    262262private:
     263    virtual bool decodedDataIsPurgeable() const OVERRIDE
     264    {
     265#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     266    return true;
     267#else
     268    return false;
     269#endif
     270    }
     271
    263272    ImageSource m_source;
    264273    mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
  • trunk/Source/WebCore/platform/graphics/Image.h

    r160212 r160260  
    125125
    126126    virtual void destroyDecodedData(bool destroyAll = true) = 0;
     127    virtual bool decodedDataIsPurgeable() const { return false; }
    127128
    128129    SharedBuffer* data() { return m_encodedImageData.get(); }
Note: See TracChangeset for help on using the changeset viewer.