Title: [201043] trunk/Source/WebCore
Revision
201043
Author
[email protected]
Date
2016-05-17 14:28:57 -0700 (Tue, 17 May 2016)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201042 => 201043)


--- trunk/Source/WebCore/ChangeLog	2016-05-17 21:24:09 UTC (rev 201042)
+++ trunk/Source/WebCore/ChangeLog	2016-05-17 21:28:57 UTC (rev 201043)
@@ -1,3 +1,23 @@
+2016-05-16  Simon Fraser  <[email protected]>
+
+        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):
+
 2016-05-17  Dave Hyatt  <[email protected]>
 
         Optimize layer repaint rect computation and painting.

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (201042 => 201043)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2016-05-17 21:24:09 UTC (rev 201042)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2016-05-17 21:28:57 UTC (rev 201043)
@@ -157,10 +157,10 @@
 
     unsigned allFrameBytes = 0;
     for (size_t i = 0; i < m_frames.size(); ++i)
-        allFrameBytes += m_frames[i].m_frameBytes;
+        allFrameBytes += m_frames[i].usedFrameBytes();
 
     if (allFrameBytes > largeAnimationCutoff) {
-        LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destryingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
+        LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destroyingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
         destroyDecodedData(destroyAll);
     }
 }

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (201042 => 201043)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2016-05-17 21:24:09 UTC (rev 201042)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2016-05-17 21:28:57 UTC (rev 201043)
@@ -72,13 +72,9 @@
 struct FrameData {
 public:
     FrameData()
-        : m_orientation(DefaultImageOrientation)
-        , m_subsamplingLevel(0)
-        , m_duration(0)
-        , m_haveMetadata(false)
+        : m_haveMetadata(false)
         , m_isComplete(false)
         , m_hasAlpha(true)
-        , m_frameBytes(0)
     {
     }
 
@@ -90,15 +86,17 @@
     // Clear the cached image data on the frame, and (optionally) the metadata.
     // Returns whether there was cached image data to clear.
     bool clear(bool clearMetadata);
+    
+    unsigned usedFrameBytes() const { return m_image ? m_frameBytes : 0; }
 
     NativeImagePtr m_image;
-    ImageOrientation m_orientation;
-    SubsamplingLevel m_subsamplingLevel;
-    float m_duration;
+    ImageOrientation m_orientation { DefaultImageOrientation };
+    SubsamplingLevel m_subsamplingLevel { 0 };
+    float m_duration { 0 };
     bool m_haveMetadata : 1;
     bool m_isComplete : 1;
     bool m_hasAlpha : 1;
-    unsigned m_frameBytes;
+    unsigned m_frameBytes { 0 };
 };
 
 // =================================================
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to