OLD | NEW |
---|---|
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 Loading... | |
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 to avoid copying. |
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)) && !buffer.copyBitmapData(prev Buffer)) | |
Ken Russell (switch to Gerrit)
2016/09/29 00:40:04
Same comment.
| |
260 return setFailed(); | 263 return setFailed(); |
261 | 264 |
262 if (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolo r) { | 265 if (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolo r) { |
263 // We want to clear the previous frame to transparent, without | 266 // We want to clear the previous frame to transparent, without |
264 // affecting pixels in the image outside of the frame. | 267 // affecting pixels in the image outside of the frame. |
265 const IntRect& prevRect = prevBuffer.originalFrameRect(); | 268 const IntRect& prevRect = prevBuffer.originalFrameRect(); |
266 ASSERT(!prevRect.contains(IntRect(IntPoint(), size()))); | 269 ASSERT(!prevRect.contains(IntRect(IntPoint(), size()))); |
267 buffer.zeroFillFrameRect(prevRect); | 270 buffer.zeroFillFrameRect(prevRect); |
Ken Russell (switch to Gerrit)
2016/09/29 00:40:04
Same comment.
| |
268 } | 271 } |
269 | 272 |
270 m_frameBackgroundHasAlpha = prevBuffer.hasAlpha() || (prevBuffer.getDisp osalMethod() == ImageFrame::DisposeOverwriteBgcolor); | 273 m_frameBackgroundHasAlpha = prevBuffer.hasAlpha() || (prevBuffer.getDisp osalMethod() == ImageFrame::DisposeOverwriteBgcolor); |
271 } | 274 } |
272 | 275 |
273 buffer.setStatus(ImageFrame::FramePartial); | 276 buffer.setStatus(ImageFrame::FramePartial); |
274 // The buffer is transparent outside the decoded area while the image is loa ding. | 277 // The buffer is transparent outside the decoded area while the image is loa ding. |
275 // The correct value of 'hasAlpha' for the frame will be set when it is full y decoded. | 278 // The correct value of 'hasAlpha' for the frame will be set when it is full y decoded. |
276 buffer.setHasAlpha(true); | 279 buffer.setHasAlpha(true); |
277 return true; | 280 return true; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 return false; | 502 return false; |
500 } | 503 } |
501 // FALLTHROUGH | 504 // FALLTHROUGH |
502 default: | 505 default: |
503 clear(); | 506 clear(); |
504 return setFailed(); | 507 return setFailed(); |
505 } | 508 } |
506 } | 509 } |
507 | 510 |
508 } // namespace blink | 511 } // namespace blink |
OLD | NEW |