This patch reworks the WebCore memory cache to significantly reduce the amoun...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2007 07:42:45 +0000 (07:42 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2007 07:42:45 +0000 (07:42 +0000)
commit26913eacaf4aac91ac48db91302a57e689a163c2
tree4f78970e4fb9254ddd55fd179a99af08aa4bfd35
parent673267337838f2fb2b3e88818b4924dd042a4788
    This patch reworks the WebCore memory cache to significantly reduce the amount of memory consumed by
        images in the cache and to enhance the accuracy of the cache size as an absolute bound for the objects
        contained within it.  WebCore's memory use over time should significantly improve as a result of these
        changes.

        Cached resources now have both an encoded size (the original data stream) and a decoded size (an estimate of
        the amount of memory consumed by an expanded version of that resource, e.g., the decoded frames of an image).
        Both sizes now count towards the total size of the object and towards the allowed memory cache total.

        By including both totals the reported size of resources will now be larger, and the cache will therefore become
        much more aggressive about flushing.

        Objects are stored in size-adjusted and popularity-aware LRU lists as before, but encoded size is now always
        used when determining the correct LRU list.

        The flush algorithm for the memory cache has been rewritten to first destroy decoded data before evicting
        resources.  By being able to compact its resources without evicting them, the memory cache can now hold many more
        unique resources (encoded) in the same amount of space.  Depending on how much of a hit we want to take from
        re-decoding images, the memory cache could in theory have its size significantly reduced now while still holding
        more resources than it did at the larger size!

        Reviewed by mjs

        * WebCore.xcodeproj/project.pbxproj:
        * loader/Cache.cpp:
        (WebCore::Cache::requestResource):
        (WebCore::Cache::prune):
        (WebCore::Cache::remove):
        (WebCore::Cache::lruListFor):
        (WebCore::Cache::adjustSize):
        * loader/Cache.h:
        * loader/CachedCSSStyleSheet.cpp:
        (WebCore::CachedCSSStyleSheet::data):
        * loader/CachedImage.cpp:
        (WebCore::CachedImage::CachedImage):
        (WebCore::CachedImage::allReferencesRemoved):
        (WebCore::CachedImage::clear):
        (WebCore::CachedImage::data):
        (WebCore::CachedImage::destroyDecodedData):
        (WebCore::CachedImage::decodedSize):
        (WebCore::CachedImage::decodedSizeChanged):
        (WebCore::CachedImage::shouldPauseAnimation):
        * loader/CachedImage.h:
        * loader/CachedResource.cpp:
        (WebCore::CachedResource::CachedResource):
        (WebCore::CachedResource::deref):
        (WebCore::CachedResource::setEncodedSize):
        * loader/CachedResource.h:
        (WebCore::CachedResource::allReferencesRemoved):
        (WebCore::CachedResource::size):
        (WebCore::CachedResource::encodedSize):
        (WebCore::CachedResource::decodedSize):
        (WebCore::CachedResource::destroyDecodedData):
        * loader/CachedScript.cpp:
        (WebCore::CachedScript::data):
        * loader/CachedXSLStyleSheet.cpp:
        (WebCore::CachedXSLStyleSheet::data):
        * platform/graphics/BitmapImage.cpp:
        (WebCore::BitmapImage::BitmapImage):
        (WebCore::BitmapImage::~BitmapImage):
        (WebCore::BitmapImage::destroyDecodedData):
        (WebCore::BitmapImage::pruneDecodedDataIfNeeded):
        (WebCore::BitmapImage::cacheFrame):
        (WebCore::BitmapImage::setNativeData):
        (WebCore::BitmapImage::shouldAnimate):
        (WebCore::BitmapImage::advanceAnimation):
        * platform/graphics/BitmapImage.h:
        (WebCore::BitmapImage::decodedSize):
        * platform/graphics/Image.cpp:
        (WebCore::Image::Image):
        * platform/graphics/Image.h:
        (WebCore::Image::destroyDecodedData):
        (WebCore::Image::decodedSize):
        (WebCore::Image::imageObserver):
        * platform/graphics/ImageAnimationObserver.h: Removed.
        * platform/graphics/ImageObserver.h: Added.
        (WebCore::ImageObserver::~ImageObserver):
        * platform/graphics/svg/SVGImage.cpp:
        (WebCore::SVGImage::SVGImage):
        * platform/graphics/svg/SVGImage.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20009 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/Cache.cpp
WebCore/loader/Cache.h
WebCore/loader/CachedCSSStyleSheet.cpp
WebCore/loader/CachedImage.cpp
WebCore/loader/CachedImage.h
WebCore/loader/CachedResource.cpp
WebCore/loader/CachedResource.h
WebCore/loader/CachedScript.cpp
WebCore/loader/CachedXSLStyleSheet.cpp
WebCore/platform/graphics/BitmapImage.cpp
WebCore/platform/graphics/BitmapImage.h
WebCore/platform/graphics/Image.cpp
WebCore/platform/graphics/Image.h
WebCore/platform/graphics/ImageObserver.h [moved from WebCore/platform/graphics/ImageAnimationObserver.h with 87% similarity]
WebCore/platform/graphics/svg/SVGImage.cpp
WebCore/platform/graphics/svg/SVGImage.h