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

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

Issue 2618633004: Add support for Animated PNG (Closed)
Patch Set: Reject bad data. Cleanups Created 3 years, 10 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 231
232 ASSERT(isDecodedSizeAvailable()); 232 ASSERT(isDecodedSizeAvailable());
233 233
234 size_t frameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT); 234 size_t frameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT);
235 updateAggressivePurging(frameCount); 235 updateAggressivePurging(frameCount);
236 236
237 return true; 237 return true;
238 } 238 }
239 239
240 void WEBPImageDecoder::onInitFrameBuffer(size_t frameIndex) { 240 bool WEBPImageDecoder::onInitFrameBuffer(size_t frameIndex) {
241 // ImageDecoder::initFrameBuffer does a DCHECK if |frameIndex| exists. 241 // ImageDecoder::initFrameBuffer does a DCHECK if |frameIndex| exists.
242 ImageFrame& buffer = m_frameBufferCache[frameIndex]; 242 ImageFrame& buffer = m_frameBufferCache[frameIndex];
243 243
244 const size_t requiredPreviousFrameIndex = buffer.requiredPreviousFrameIndex(); 244 const size_t requiredPreviousFrameIndex = buffer.requiredPreviousFrameIndex();
245 if (requiredPreviousFrameIndex == kNotFound) { 245 if (requiredPreviousFrameIndex == kNotFound) {
246 m_frameBackgroundHasAlpha = 246 m_frameBackgroundHasAlpha =
247 !buffer.originalFrameRect().contains(IntRect(IntPoint(), size())); 247 !buffer.originalFrameRect().contains(IntRect(IntPoint(), size()));
248 } else { 248 } else {
249 const ImageFrame& prevBuffer = 249 const ImageFrame& prevBuffer =
250 m_frameBufferCache[requiredPreviousFrameIndex]; 250 m_frameBufferCache[requiredPreviousFrameIndex];
251 m_frameBackgroundHasAlpha = 251 m_frameBackgroundHasAlpha =
252 prevBuffer.hasAlpha() || 252 prevBuffer.hasAlpha() ||
253 (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor); 253 (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor);
254 } 254 }
255 255
256 // The buffer is transparent outside the decoded area while the image is 256 // The buffer is transparent outside the decoded area while the image is
257 // loading. The correct alpha value for the frame will be set when it is fully 257 // loading. The correct alpha value for the frame will be set when it is fully
258 // decoded. 258 // decoded.
259 buffer.setHasAlpha(true); 259 buffer.setHasAlpha(true);
260 return true;
260 } 261 }
261 262
262 bool WEBPImageDecoder::canReusePreviousFrameBuffer(size_t frameIndex) const { 263 bool WEBPImageDecoder::canReusePreviousFrameBuffer(size_t frameIndex) const {
263 DCHECK(frameIndex < m_frameBufferCache.size()); 264 DCHECK(frameIndex < m_frameBufferCache.size());
264 return m_frameBufferCache[frameIndex].getAlphaBlendSource() != 265 return m_frameBufferCache[frameIndex].getAlphaBlendSource() !=
265 ImageFrame::BlendAtopPreviousFrame; 266 ImageFrame::BlendAtopPreviousFrame;
266 } 267 }
267 268
268 void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex) { 269 void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex) {
269 if (m_demux && m_demuxState >= WEBP_DEMUX_PARSED_HEADER && 270 if (m_demux && m_demuxState >= WEBP_DEMUX_PARSED_HEADER &&
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return false; 510 return false;
510 } 511 }
511 // FALLTHROUGH 512 // FALLTHROUGH
512 default: 513 default:
513 clear(); 514 clear();
514 return setFailed(); 515 return setFailed();
515 } 516 }
516 } 517 }
517 518
518 } // namespace blink 519 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698