Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp

Issue 1925533003: High CPU and increased memory usage fix for high-res (GIF, WEBP...) animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
index f1d76fd87415897d55de43781599b662de78c1d1..0be98893f44c0a6b9dcd9c665a1fa68c5df2a479 100644
--- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
@@ -27,7 +27,6 @@
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/DecodingImageGenerator.h"
-#include "platform/graphics/FrameData.h"
#include "platform/graphics/ImageDecodingStore.h"
#include "platform/graphics/ImageFrameGenerator.h"
#include "third_party/skia/include/core/SkImage.h"
@@ -35,6 +34,23 @@
namespace blink {
+struct DeferredFrameData {
Peter Kasting 2016/04/28 23:07:55 This probably needs comments about why you can't u
aleksandar.stojiljkovic 2016/04/29 17:17:43 After second patch these two diverged further - D
+ DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
+ WTF_MAKE_NONCOPYABLE(DeferredFrameData);
+public:
+ DeferredFrameData()
+ : m_orientation(DefaultImageOrientation)
+ , m_duration(0)
+ , m_isComplete(false)
+ , m_frameBytes(0)
+ {}
+
+ ImageOrientation m_orientation;
+ float m_duration;
+ bool m_isComplete : 1;
+ size_t m_frameBytes;
+};
+
bool DeferredImageDecoder::s_enabled = true;
PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer& data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorProfileOption colorOptions)
@@ -89,16 +105,15 @@ PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index)
prepareLazyDecodedFrames();
if (index < m_frameData.size()) {
- FrameData* frameData = &m_frameData[index];
- // ImageFrameGenerator has the latest known alpha state. There will be a
- // performance boost if this frame is opaque.
- ASSERT(m_frameGenerator);
- frameData->m_hasAlpha = m_frameGenerator->hasAlpha(index);
+ DeferredFrameData* frameData = &m_frameData[index];
if (m_actualDecoder)
frameData->m_frameBytes = m_actualDecoder->frameBytesAtIndex(index);
else
frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData);
- return createFrameImageAtIndex(index, !frameData->m_hasAlpha);
+ // ImageFrameGenerator has the latest known alpha state. There will be a
+ // performance boost if this frame is opaque.
+ ASSERT(m_frameGenerator);
+ return createFrameImageAtIndex(index, !m_frameGenerator->hasAlpha(index));
}
if (!m_actualDecoder || m_actualDecoder->failed())
@@ -251,7 +266,6 @@ void DeferredImageDecoder::prepareLazyDecodedFrames()
return;
for (size_t i = previousSize; i < m_frameData.size(); ++i) {
- m_frameData[i].m_haveMetadata = true;
m_frameData[i].m_duration = m_actualDecoder->frameDurationAtIndex(i);
m_frameData[i].m_orientation = m_actualDecoder->orientation();
m_frameData[i].m_isComplete = m_actualDecoder->frameIsCompleteAtIndex(i);
@@ -300,3 +314,10 @@ bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
}
} // namespace blink
+
+namespace WTF {
+template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVectorTraits<blink::DeferredFrameData> {
+ STATIC_ONLY(VectorTraits);
+ static const bool canInitializeWithMemset = false; // Not all DeferredFrameData members initialize to 0.
+};
+}

Powered by Google App Engine
This is Rietveld 408576698