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

Side by Side Diff: Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 284043003: Looping of animated WebP: Loop count off-by-one (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments Created 6 years, 7 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 | Annotate | Revision Log
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 ASSERT(ImageDecoder::isSizeAvailable()); 224 ASSERT(ImageDecoder::isSizeAvailable());
225 const size_t newFrameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT); 225 const size_t newFrameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT);
226 if (hasAnimation && !m_haveReadAnimationParameters && newFrameCount) { 226 if (hasAnimation && !m_haveReadAnimationParameters && newFrameCount) {
227 // As we have parsed at least one frame (even if partially), 227 // As we have parsed at least one frame (even if partially),
228 // we must already have parsed the animation properties. 228 // we must already have parsed the animation properties.
229 // This is because ANIM chunk always precedes ANMF chunks. 229 // This is because ANIM chunk always precedes ANMF chunks.
230 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT); 230 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT);
231 ASSERT(m_repetitionCount == (m_repetitionCount & 0xffff)); // Loop count is always <= 16 bits. 231 ASSERT(m_repetitionCount == (m_repetitionCount & 0xffff)); // Loop count is always <= 16 bits.
232 if (!m_repetitionCount) 232 // |m_repetitionCount| is the total number of animation cycles to show,
233 m_repetitionCount = cAnimationLoopInfinite; 233 // with 0 meaning "infinite". But ImageSource::repetitionCount()
234 // returns -1 for "infinite", and 0 and up for "show the animation one
235 // cycle more than this value". By subtracting one here, we convert
236 // both finite and infinite cases correctly.
237 --m_repetitionCount;
234 m_haveReadAnimationParameters = true; 238 m_haveReadAnimationParameters = true;
235 } 239 }
236 240
237 const size_t oldFrameCount = m_frameBufferCache.size(); 241 const size_t oldFrameCount = m_frameBufferCache.size();
238 if (newFrameCount > oldFrameCount) { 242 if (newFrameCount > oldFrameCount) {
239 m_frameBufferCache.resize(newFrameCount); 243 m_frameBufferCache.resize(newFrameCount);
240 for (size_t i = oldFrameCount; i < newFrameCount; ++i) { 244 for (size_t i = oldFrameCount; i < newFrameCount; ++i) {
241 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha); 245 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha);
242 if (!hasAnimation) { 246 if (!hasAnimation) {
243 ASSERT(!i); 247 ASSERT(!i);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return false; 537 return false;
534 } 538 }
535 // FALLTHROUGH 539 // FALLTHROUGH
536 default: 540 default:
537 clear(); 541 clear();
538 return setFailed(); 542 return setFailed();
539 } 543 }
540 } 544 }
541 545
542 } // namespace WebCore 546 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageSource.h ('k') | Source/platform/image-decoders/webp/WEBPImageDecoderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698