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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp

Issue 2800343004: Add histograms for animated image types
Patch Set: Created 3 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/image-decoders/gif/GIFImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
index 307e6a4f93d4c67f6793c152bb4172390813ec37..60a3fa35c12bdcccebfd9aeac72bfdc586d8c10f 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -25,10 +25,11 @@
#include "platform/image-decoders/gif/GIFImageDecoder.h"
+#include <limits>
+#include "platform/graphics/BitmapImageMetrics.h"
#include "platform/image-decoders/gif/GIFImageReader.h"
#include "wtf/NotFound.h"
#include "wtf/PtrUtil.h"
-#include <limits>
namespace blink {
@@ -210,12 +211,19 @@ void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) {
}
size_t GIFImageDecoder::decodeFrameCount() {
+ const bool alreadyParsedFrameTwo = m_reader && m_reader->imagesCount() > 1;
parse(GIFFrameCountQuery);
// If decoding fails, |m_reader| will have been destroyed. Instead of
// returning 0 in this case, return the existing number of frames. This way
// if we get halfway through the image before decoding fails, we won't
// suddenly start reporting that the image has zero frames.
- return failed() ? m_frameBufferCache.size() : m_reader->imagesCount();
+ if (failed())
+ return m_frameBufferCache.size();
+
+ const size_t newCount = m_reader->imagesCount();
+ if (!alreadyParsedFrameTwo && newCount > 1)
+ BitmapImageMetrics::countAnimatedImageType(BitmapImageMetrics::AnimatedGIF);
+ return newCount;
}
void GIFImageDecoder::initializeNewFrame(size_t index) {

Powered by Google App Engine
This is Rietveld 408576698