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

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

Issue 2155973002: Save a bitmap copy when advancing to dependent GIF and WebP animation frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +webp. fix test failures. Created 4 years, 3 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (buffer.getStatus() != ImageFrame::FrameEmpty) // Already initialized. 245 if (buffer.getStatus() != ImageFrame::FrameEmpty) // Already initialized.
246 return true; 246 return true;
247 247
248 const size_t requiredPreviousFrameIndex = buffer.requiredPreviousFrameIndex( ); 248 const size_t requiredPreviousFrameIndex = buffer.requiredPreviousFrameIndex( );
249 if (requiredPreviousFrameIndex == kNotFound) { 249 if (requiredPreviousFrameIndex == kNotFound) {
250 // This frame doesn't rely on any previous data. 250 // This frame doesn't rely on any previous data.
251 if (!buffer.setSizeAndColorProfile(size().width(), size().height(), colo rProfile())) 251 if (!buffer.setSizeAndColorProfile(size().width(), size().height(), colo rProfile()))
252 return setFailed(); 252 return setFailed();
253 m_frameBackgroundHasAlpha = !buffer.originalFrameRect().contains(IntRect (IntPoint(), size())); 253 m_frameBackgroundHasAlpha = !buffer.originalFrameRect().contains(IntRect (IntPoint(), size()));
254 } else { 254 } else {
255 const ImageFrame& prevBuffer = m_frameBufferCache[requiredPreviousFrameI ndex]; 255 ImageFrame& prevBuffer = m_frameBufferCache[requiredPreviousFrameIndex];
256 ASSERT(prevBuffer.getStatus() == ImageFrame::FrameComplete); 256 ASSERT(prevBuffer.getStatus() == ImageFrame::FrameComplete);
257 257
258 // Preserve the last frame as the starting state for this frame. 258 // Preserve the last frame as the starting state for this frame. We try
259 if (!buffer.copyBitmapData(prevBuffer)) 259 // to reuse |prevBuffer| as starting state and avoid copy.
Peter Kasting 2016/08/26 19:04:04 Nit: and avoid copy -> to avoid copying
aleksandar.stojiljkovic 2016/08/26 21:53:51 Done.
260 return setFailed(); 260 // For BlendAtopPreviousFrame, both frames are required, so we can't
261 // take over its image data using takeBitmapDataIfWritable.
262 if (buffer.getAlphaBlendSource() == ImageFrame::BlendAtopPreviousFrame | | !buffer.takeBitmapDataIfWritable(&prevBuffer)) {
263 if (!buffer.copyBitmapData(prevBuffer))
Peter Kasting 2016/08/26 19:04:04 Nit: I'd just combine these two conditionals
aleksandar.stojiljkovic 2016/08/26 21:53:51 Done.
264 return setFailed();
265 }
261 266
262 if (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolo r) { 267 if (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolo r) {
263 // We want to clear the previous frame to transparent, without 268 // We want to clear the previous frame to transparent, without
264 // affecting pixels in the image outside of the frame. 269 // affecting pixels in the image outside of the frame.
265 const IntRect& prevRect = prevBuffer.originalFrameRect(); 270 const IntRect& prevRect = prevBuffer.originalFrameRect();
266 ASSERT(!prevRect.contains(IntRect(IntPoint(), size()))); 271 ASSERT(!prevRect.contains(IntRect(IntPoint(), size())));
267 buffer.zeroFillFrameRect(prevRect); 272 buffer.zeroFillFrameRect(prevRect);
268 } 273 }
269 274
270 m_frameBackgroundHasAlpha = prevBuffer.hasAlpha() || (prevBuffer.getDisp osalMethod() == ImageFrame::DisposeOverwriteBgcolor); 275 m_frameBackgroundHasAlpha = prevBuffer.hasAlpha() || (prevBuffer.getDisp osalMethod() == ImageFrame::DisposeOverwriteBgcolor);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return false; 504 return false;
500 } 505 }
501 // FALLTHROUGH 506 // FALLTHROUGH
502 default: 507 default:
503 clear(); 508 clear();
504 return setFailed(); 509 return setFailed();
505 } 510 }
506 } 511 }
507 512
508 } // namespace blink 513 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698