Chromium Code Reviews| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 const ImageFrame& prev_buffer = | 250 const ImageFrame& prev_buffer = |
| 251 frame_buffer_cache_[required_previous_frame_index]; | 251 frame_buffer_cache_[required_previous_frame_index]; |
| 252 frame_background_has_alpha_ = | 252 frame_background_has_alpha_ = |
| 253 prev_buffer.HasAlpha() || (prev_buffer.GetDisposalMethod() == | 253 prev_buffer.HasAlpha() || (prev_buffer.GetDisposalMethod() == |
| 254 ImageFrame::kDisposeOverwriteBgcolor); | 254 ImageFrame::kDisposeOverwriteBgcolor); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // The buffer is transparent outside the decoded area while the image is | 257 // The buffer is transparent outside the decoded area while the image is |
| 258 // loading. The correct alpha value for the frame will be set when it is fully | 258 // loading. The correct alpha value for the frame will be set when it is fully |
| 259 // decoded. | 259 // decoded. |
| 260 buffer.SetHasAlpha(true); | 260 buffer.SetHasAlpha(true); |
|
scroggo_chromium
2017/05/31 14:27:50
If we're going to remove the other call to SetHasA
| |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool WEBPImageDecoder::CanReusePreviousFrameBuffer(size_t frame_index) const { | 263 bool WEBPImageDecoder::CanReusePreviousFrameBuffer(size_t frame_index) const { |
| 264 DCHECK(frame_index < frame_buffer_cache_.size()); | 264 DCHECK(frame_index < frame_buffer_cache_.size()); |
| 265 return frame_buffer_cache_[frame_index].GetAlphaBlendSource() != | 265 return frame_buffer_cache_[frame_index].GetAlphaBlendSource() != |
| 266 ImageFrame::kBlendAtopPreviousFrame; | 266 ImageFrame::kBlendAtopPreviousFrame; |
| 267 } | 267 } |
| 268 | 268 |
| 269 void WEBPImageDecoder::ClearFrameBuffer(size_t frame_index) { | 269 void WEBPImageDecoder::ClearFrameBuffer(size_t frame_index) { |
| 270 if (demux_ && demux_state_ >= WEBP_DEMUX_PARSED_HEADER && | 270 if (demux_ && demux_state_ >= WEBP_DEMUX_PARSED_HEADER && |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 | 457 |
| 458 DCHECK_GT(frame_buffer_cache_.size(), frame_index); | 458 DCHECK_GT(frame_buffer_cache_.size(), frame_index); |
| 459 ImageFrame& buffer = frame_buffer_cache_[frame_index]; | 459 ImageFrame& buffer = frame_buffer_cache_[frame_index]; |
| 460 DCHECK_NE(buffer.GetStatus(), ImageFrame::kFrameComplete); | 460 DCHECK_NE(buffer.GetStatus(), ImageFrame::kFrameComplete); |
| 461 | 461 |
| 462 if (buffer.GetStatus() == ImageFrame::kFrameEmpty) { | 462 if (buffer.GetStatus() == ImageFrame::kFrameEmpty) { |
| 463 if (!buffer.AllocatePixelData(Size().Width(), Size().Height(), | 463 if (!buffer.AllocatePixelData(Size().Width(), Size().Height(), |
| 464 ColorSpaceForSkImages())) | 464 ColorSpaceForSkImages())) |
| 465 return SetFailed(); | 465 return SetFailed(); |
| 466 buffer.ZeroFillPixelData(); | 466 buffer.ZeroFillPixelData(); |
| 467 buffer.SetStatus(ImageFrame::kFramePartial); | |
| 468 // The buffer is transparent outside the decoded area while the image is | 467 // The buffer is transparent outside the decoded area while the image is |
| 469 // loading. The correct alpha value for the frame will be set when it is | 468 // loading. The correct alpha value for the frame will be set when it is |
| 470 // fully decoded. | 469 // fully decoded. |
| 471 buffer.SetHasAlpha(true); | 470 buffer.SetStatus(ImageFrame::kFramePartial); |
| 472 buffer.SetOriginalFrameRect(IntRect(IntPoint(), Size())); | 471 buffer.SetOriginalFrameRect(IntRect(IntPoint(), Size())); |
| 473 } | 472 } |
| 474 | 473 |
| 475 const IntRect& frame_rect = buffer.OriginalFrameRect(); | 474 const IntRect& frame_rect = buffer.OriginalFrameRect(); |
| 476 if (!decoder_) { | 475 if (!decoder_) { |
| 477 WEBP_CSP_MODE mode = outputMode(format_flags_ & ALPHA_FLAG); | 476 WEBP_CSP_MODE mode = outputMode(format_flags_ & ALPHA_FLAG); |
| 478 if (!premultiply_alpha_) | 477 if (!premultiply_alpha_) |
| 479 mode = outputMode(false); | 478 mode = outputMode(false); |
| 480 if (ColorTransform()) { | 479 if (ColorTransform()) { |
| 481 // Swizzling between RGBA and BGRA is zero cost in a color transform. | 480 // Swizzling between RGBA and BGRA is zero cost in a color transform. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 return false; | 515 return false; |
| 517 } | 516 } |
| 518 // FALLTHROUGH | 517 // FALLTHROUGH |
| 519 default: | 518 default: |
| 520 Clear(); | 519 Clear(); |
| 521 return SetFailed(); | 520 return SetFailed(); |
| 522 } | 521 } |
| 523 } | 522 } |
| 524 | 523 |
| 525 } // namespace blink | 524 } // namespace blink |
| OLD | NEW |