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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 10 matching lines...) Expand all
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "platform/image-decoders/webp/WEBPImageDecoder.h" 29 #include "platform/image-decoders/webp/WEBPImageDecoder.h"
30 30
31 #include "platform/graphics/BitmapImageMetrics.h"
32
31 #if CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN) 33 #if CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN)
32 #error Blink assumes a little-endian target. 34 #error Blink assumes a little-endian target.
33 #endif 35 #endif
34 36
35 #if SK_B32_SHIFT // Output little-endian RGBA pixels (Android). 37 #if SK_B32_SHIFT // Output little-endian RGBA pixels (Android).
36 inline WEBP_CSP_MODE outputMode(bool hasAlpha) { 38 inline WEBP_CSP_MODE outputMode(bool hasAlpha) {
37 return hasAlpha ? MODE_rgbA : MODE_RGBA; 39 return hasAlpha ? MODE_rgbA : MODE_RGBA;
38 } 40 }
39 #else // Output little-endian BGRA pixels. 41 #else // Output little-endian BGRA pixels.
40 inline WEBP_CSP_MODE outputMode(bool hasAlpha) { 42 inline WEBP_CSP_MODE outputMode(bool hasAlpha) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (!isDecodedSizeAvailable()) { 208 if (!isDecodedSizeAvailable()) {
207 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); 209 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH);
208 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT); 210 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT);
209 if (!setSize(width, height)) 211 if (!setSize(width, height))
210 return setFailed(); 212 return setFailed();
211 213
212 m_formatFlags = WebPDemuxGetI(m_demux, WEBP_FF_FORMAT_FLAGS); 214 m_formatFlags = WebPDemuxGetI(m_demux, WEBP_FF_FORMAT_FLAGS);
213 if (!(m_formatFlags & ANIMATION_FLAG)) { 215 if (!(m_formatFlags & ANIMATION_FLAG)) {
214 m_repetitionCount = cAnimationNone; 216 m_repetitionCount = cAnimationNone;
215 } else { 217 } else {
218 BitmapImageMetrics::countAnimatedImageType(
219 BitmapImageMetrics::AnimatedWEBP);
220
216 // Since we have parsed at least one frame, even if partially, 221 // Since we have parsed at least one frame, even if partially,
217 // the global animation (ANIM) properties have been read since 222 // the global animation (ANIM) properties have been read since
218 // an ANIM chunk must precede the ANMF frame chunks. 223 // an ANIM chunk must precede the ANMF frame chunks.
219 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT); 224 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT);
220 // Repetition count is always <= 16 bits. 225 // Repetition count is always <= 16 bits.
221 DCHECK_EQ(m_repetitionCount, m_repetitionCount & 0xffff); 226 DCHECK_EQ(m_repetitionCount, m_repetitionCount & 0xffff);
222 if (!m_repetitionCount) 227 if (!m_repetitionCount)
223 m_repetitionCount = cAnimationLoopInfinite; 228 m_repetitionCount = cAnimationLoopInfinite;
224 // FIXME: Implement ICC profile support for animated images. 229 // FIXME: Implement ICC profile support for animated images.
225 m_formatFlags &= ~ICCP_FLAG; 230 m_formatFlags &= ~ICCP_FLAG;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return false; 517 return false;
513 } 518 }
514 // FALLTHROUGH 519 // FALLTHROUGH
515 default: 520 default:
516 clear(); 521 clear();
517 return setFailed(); 522 return setFailed();
518 } 523 }
519 } 524 }
520 525
521 } // namespace blink 526 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.cpp ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698