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

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

Issue 1962563002: Fix ImageDecoder::frameIsCompleteAtIndex - fully received instead of decoded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BMPDecoder + remove partial Created 4 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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void WEBPImageDecoder::onSetData(SegmentReader*) 159 void WEBPImageDecoder::onSetData(SegmentReader*)
160 { 160 {
161 m_haveAlreadyParsedThisData = false; 161 m_haveAlreadyParsedThisData = false;
162 } 162 }
163 163
164 int WEBPImageDecoder::repetitionCount() const 164 int WEBPImageDecoder::repetitionCount() const
165 { 165 {
166 return failed() ? cAnimationLoopOnce : m_repetitionCount; 166 return failed() ? cAnimationLoopOnce : m_repetitionCount;
167 } 167 }
168 168
169 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const 169 bool WEBPImageDecoder::frameIsFullyReceivedAtIndex(size_t index) const
170 { 170 {
171 if (!m_demux || m_demuxState <= WEBP_DEMUX_PARSING_HEADER) 171 if (!m_demux || m_demuxState <= WEBP_DEMUX_PARSING_HEADER)
172 return false; 172 return ImageDecoder::frameIsFullyReceivedAtIndex(index);
173 if (!(m_formatFlags & ANIMATION_FLAG)) 173 return ((m_formatFlags & ANIMATION_FLAG) && index < m_frameBufferCache.size( )) || ImageDecoder::frameIsFullyReceivedAtIndex(index);
scroggo_chromium 2016/05/16 20:32:08 I brought this up previously, but I don't think yo
aleksandar.stojiljkovic 2016/05/22 15:41:53 I refactored it a bit, but it is still based on in
scroggo_chromium 2016/05/23 16:40:42 That's not obvious to me. An entry is created base
aleksandar.stojiljkovic 2016/05/24 11:08:24 This confused me too. Notice in WEBPImageDecoder::
scroggo_chromium 2016/05/24 13:55:14 Very confusing. Can you add a comment?
aleksandar.stojiljkovic 2016/05/24 19:24:34 Done.
174 return ImageDecoder::frameIsCompleteAtIndex(index);
175 bool frameIsLoadedAtIndex = index < m_frameBufferCache.size();
176 return frameIsLoadedAtIndex;
177 } 174 }
178 175
179 float WEBPImageDecoder::frameDurationAtIndex(size_t index) const 176 float WEBPImageDecoder::frameDurationAtIndex(size_t index) const
180 { 177 {
181 return index < m_frameBufferCache.size() ? m_frameBufferCache[index].duratio n() : 0; 178 return index < m_frameBufferCache.size() ? m_frameBufferCache[index].duratio n() : 0;
182 } 179 }
183 180
184 bool WEBPImageDecoder::updateDemuxer() 181 bool WEBPImageDecoder::updateDemuxer()
185 { 182 {
186 if (failed()) 183 if (failed())
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 m_decoderBuffer.u.RGBA.rgba = reinterpret_cast<uint8_t*>(buffer.getAddr(fram eRect.x(), frameRect.y())); 490 m_decoderBuffer.u.RGBA.rgba = reinterpret_cast<uint8_t*>(buffer.getAddr(fram eRect.x(), frameRect.y()));
494 491
495 switch (WebPIUpdate(m_decoder, dataBytes, dataSize)) { 492 switch (WebPIUpdate(m_decoder, dataBytes, dataSize)) {
496 case VP8_STATUS_OK: 493 case VP8_STATUS_OK:
497 applyPostProcessing(frameIndex); 494 applyPostProcessing(frameIndex);
498 buffer.setHasAlpha((m_formatFlags & ALPHA_FLAG) || m_frameBackgroundHasA lpha); 495 buffer.setHasAlpha((m_formatFlags & ALPHA_FLAG) || m_frameBackgroundHasA lpha);
499 buffer.setStatus(ImageFrame::FrameComplete); 496 buffer.setStatus(ImageFrame::FrameComplete);
500 clearDecoder(); 497 clearDecoder();
501 return true; 498 return true;
502 case VP8_STATUS_SUSPENDED: 499 case VP8_STATUS_SUSPENDED:
503 if (!isAllDataReceived() && !frameIsCompleteAtIndex(frameIndex)) { 500 if (!isAllDataReceived() && !frameIsFullyReceivedAtIndex(frameIndex)) {
504 applyPostProcessing(frameIndex); 501 applyPostProcessing(frameIndex);
505 return false; 502 return false;
506 } 503 }
507 // FALLTHROUGH 504 // FALLTHROUGH
508 default: 505 default:
509 clear(); 506 clear();
510 return setFailed(); 507 return setFailed();
511 } 508 }
512 } 509 }
513 510
514 } // namespace blink 511 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698