Title: [160260] trunk/Source/WebCore
- Revision
- 160260
- Author
- [email protected]
- Date
- 2013-12-06 16:45:11 -0800 (Fri, 06 Dec 2013)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (160259 => 160260)
--- trunk/Source/WebCore/ChangeLog 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/ChangeLog 2013-12-07 00:45:11 UTC (rev 160260)
@@ -1,3 +1,35 @@
+2013-12-06 Tim Horton <[email protected]>
+
+ [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):
+
2013-12-06 Antti Koivisto <[email protected]>
Save original text for RenderText to a map
Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (160259 => 160260)
--- trunk/Source/WebCore/loader/cache/CachedImage.h 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h 2013-12-07 00:45:11 UTC (rev 160260)
@@ -119,6 +119,8 @@
virtual bool isImage() const OVERRIDE { return true; }
virtual bool stillNeedsLoad() const OVERRIDE { return !errorOccurred() && status() == Unknown && !isLoading(); }
+ virtual bool decodedDataIsPurgeable() const OVERRIDE { return m_image && m_image->decodedDataIsPurgeable(); }
+
// ImageObserver
virtual void decodedSizeChanged(const Image*, int delta) OVERRIDE;
virtual void didDraw(const Image*) OVERRIDE;
Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (160259 => 160260)
--- trunk/Source/WebCore/loader/cache/CachedResource.h 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2013-12-07 00:45:11 UTC (rev 160260)
@@ -149,6 +149,8 @@
unsigned encodedSize() const { return m_encodedSize; }
unsigned decodedSize() const { return m_decodedSize; }
unsigned overheadSize() const;
+
+ virtual bool decodedDataIsPurgeable() const { return false; }
bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccurate. Loading might not have started yet.
Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (160259 => 160260)
--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2013-12-07 00:45:11 UTC (rev 160260)
@@ -266,6 +266,9 @@
if (elapsedTime < cMinDelayBeforeLiveDecodedPrune)
return;
+ if (current->decodedDataIsPurgeable())
+ continue;
+
// Destroy our decoded data. This will remove us from
// m_liveDecodedResources, and possibly move us to a different LRU
// list in m_allResources.
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (160259 => 160260)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2013-12-07 00:45:11 UTC (rev 160260)
@@ -102,6 +102,11 @@
// to one frame at a time.
static const unsigned cLargeAnimationCutoff = 5242880;
+ // If decoded data is purgeable, the operating system will
+ // take care of throwing it away when the system is under pressure.
+ if (decodedDataIsPurgeable())
+ return;
+
// If we have decoded frames but there is no encoded data, we shouldn't destroy
// the decoded image since we won't be able to reconstruct it later.
if (!data() && m_frames.size())
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (160259 => 160260)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.h 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h 2013-12-07 00:45:11 UTC (rev 160260)
@@ -260,6 +260,15 @@
#endif
private:
+ virtual bool decodedDataIsPurgeable() const OVERRIDE
+ {
+#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ return true;
+#else
+ return false;
+#endif
+ }
+
ImageSource m_source;
mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
mutable IntSize m_sizeRespectingOrientation;
Modified: trunk/Source/WebCore/platform/graphics/Image.h (160259 => 160260)
--- trunk/Source/WebCore/platform/graphics/Image.h 2013-12-07 00:33:42 UTC (rev 160259)
+++ trunk/Source/WebCore/platform/graphics/Image.h 2013-12-07 00:45:11 UTC (rev 160260)
@@ -124,6 +124,7 @@
virtual String filenameExtension() const { return String(); } // null string if unknown
virtual void destroyDecodedData(bool destroyAll = true) = 0;
+ virtual bool decodedDataIsPurgeable() const { return false; }
SharedBuffer* data() { return m_encodedImageData.get(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes