Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 | 88 |
| 89 return dst->installPixels(info, pixels_, row_bytes_); | 89 return dst->installPixels(info, pixels_, row_bytes_); |
| 90 } | 90 } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 SkImageInfo info_; | 93 SkImageInfo info_; |
| 94 void* pixels_; | 94 void* pixels_; |
| 95 size_t row_bytes_; | 95 size_t row_bytes_; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 static bool UpdateYUVComponentSizes(ImageDecoder* decoder, | 98 static void UpdateYUVComponentSizes(ImageDecoder* decoder, |
| 99 SkISize component_sizes[3], | 99 SkISize component_sizes[3], |
| 100 size_t component_width_bytes[3]) { | 100 size_t component_width_bytes[3]) { |
| 101 if (!decoder->CanDecodeToYUV()) | |
| 102 return false; | |
| 103 | |
| 104 for (int yuv_index = 0; yuv_index < 3; ++yuv_index) { | 101 for (int yuv_index = 0; yuv_index < 3; ++yuv_index) { |
| 105 IntSize size = decoder->DecodedYUVSize(yuv_index); | 102 IntSize size = decoder->DecodedYUVSize(yuv_index); |
| 106 component_sizes[yuv_index].set(size.Width(), size.Height()); | 103 component_sizes[yuv_index].set(size.Width(), size.Height()); |
| 107 component_width_bytes[yuv_index] = decoder->DecodedYUVWidthBytes(yuv_index); | 104 component_width_bytes[yuv_index] = decoder->DecodedYUVWidthBytes(yuv_index); |
| 108 } | 105 } |
| 109 | |
| 110 return true; | |
| 111 } | 106 } |
| 112 | 107 |
| 113 ImageFrameGenerator::ImageFrameGenerator(const SkISize& full_size, | 108 ImageFrameGenerator::ImageFrameGenerator(const SkISize& full_size, |
| 114 bool is_multi_frame, | 109 bool is_multi_frame, |
| 115 const ColorBehavior& color_behavior) | 110 const ColorBehavior& color_behavior) |
| 116 : full_size_(full_size), | 111 : full_size_(full_size), |
| 117 decoder_color_behavior_(color_behavior), | 112 decoder_color_behavior_(color_behavior), |
| 118 is_multi_frame_(is_multi_frame), | 113 is_multi_frame_(is_multi_frame), |
| 119 decode_failed_(false), | 114 decode_failed_(false), |
| 120 yuv_decoding_failed_(false), | |
| 121 frame_count_(0) {} | 115 frame_count_(0) {} |
| 122 | 116 |
| 123 ImageFrameGenerator::~ImageFrameGenerator() { | 117 ImageFrameGenerator::~ImageFrameGenerator() { |
| 124 ImageDecodingStore::Instance().RemoveCacheIndexedByGenerator(this); | 118 ImageDecodingStore::Instance().RemoveCacheIndexedByGenerator(this); |
| 125 } | 119 } |
| 126 | 120 |
| 127 bool ImageFrameGenerator::DecodeAndScale( | 121 bool ImageFrameGenerator::DecodeAndScale( |
| 128 SegmentReader* data, | 122 SegmentReader* data, |
| 129 bool all_data_received, | 123 bool all_data_received, |
| 130 size_t index, | 124 size_t index, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 decoder->SetImagePlanes(std::move(image_planes)); | 188 decoder->SetImagePlanes(std::move(image_planes)); |
| 195 | 189 |
| 196 DCHECK(decoder->CanDecodeToYUV()); | 190 DCHECK(decoder->CanDecodeToYUV()); |
| 197 | 191 |
| 198 if (decoder->DecodeToYUV()) { | 192 if (decoder->DecodeToYUV()) { |
| 199 SetHasAlpha(0, false); // YUV is always opaque | 193 SetHasAlpha(0, false); // YUV is always opaque |
| 200 return true; | 194 return true; |
| 201 } | 195 } |
| 202 | 196 |
| 203 DCHECK(decoder->Failed()); | 197 DCHECK(decoder->Failed()); |
| 204 yuv_decoding_failed_ = true; | |
|
scroggo_chromium
2017/06/15 16:50:38
It sounds like you're saying that yuv_decoding_fai
naga
2017/06/15 17:49:02
yuv_decoding_failed _ is set to true once DecodeTo
scroggo_chromium
2017/06/15 20:40:00
Isn't that what I just said? This method is Decode
| |
| 205 return false; | 198 return false; |
| 206 } | 199 } |
| 207 | 200 |
| 208 SkBitmap ImageFrameGenerator::TryToResumeDecode( | 201 SkBitmap ImageFrameGenerator::TryToResumeDecode( |
| 209 SegmentReader* data, | 202 SegmentReader* data, |
| 210 bool all_data_received, | 203 bool all_data_received, |
| 211 size_t index, | 204 size_t index, |
| 212 const SkISize& scaled_size, | 205 const SkISize& scaled_size, |
| 213 SkBitmap::Allocator* allocator, | 206 SkBitmap::Allocator* allocator, |
| 214 ImageDecoder::AlphaOption alpha_option) { | 207 ImageDecoder::AlphaOption alpha_option) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 if (index < has_alpha_.size()) | 368 if (index < has_alpha_.size()) |
| 376 return has_alpha_[index]; | 369 return has_alpha_[index]; |
| 377 return true; | 370 return true; |
| 378 } | 371 } |
| 379 | 372 |
| 380 bool ImageFrameGenerator::GetYUVComponentSizes(SegmentReader* data, | 373 bool ImageFrameGenerator::GetYUVComponentSizes(SegmentReader* data, |
| 381 SkYUVSizeInfo* size_info) { | 374 SkYUVSizeInfo* size_info) { |
| 382 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width", | 375 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width", |
| 383 full_size_.width(), "height", full_size_.height()); | 376 full_size_.width(), "height", full_size_.height()); |
| 384 | 377 |
| 385 if (yuv_decoding_failed_) | |
| 386 return false; | |
| 387 | |
| 388 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::Create( | 378 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::Create( |
| 389 data, true, ImageDecoder::kAlphaPremultiplied, decoder_color_behavior_); | 379 data, true, ImageDecoder::kAlphaPremultiplied, decoder_color_behavior_); |
| 390 if (!decoder) | 380 if (!decoder || !decoder->CanDecodeToYUV()) |
|
scroggo_chromium
2017/06/15 14:45:22
This change (moving caller of CanDecodeToYUV from
scroggo_chromium
2017/07/06 21:10:18
It looks like you've partially done that in crrev.
| |
| 391 return false; | 381 return false; |
| 392 | 382 |
| 393 // Setting a dummy ImagePlanes object signals to the decoder that we want to | 383 // Setting a dummy ImagePlanes object signals to the decoder that we want to |
| 394 // do YUV decoding. | 384 // do YUV decoding. |
| 395 std::unique_ptr<ImagePlanes> dummy_image_planes = | 385 std::unique_ptr<ImagePlanes> dummy_image_planes = |
| 396 WTF::WrapUnique(new ImagePlanes); | 386 WTF::WrapUnique(new ImagePlanes); |
| 397 decoder->SetImagePlanes(std::move(dummy_image_planes)); | 387 decoder->SetImagePlanes(std::move(dummy_image_planes)); |
| 398 | 388 |
| 399 return UpdateYUVComponentSizes(decoder.get(), size_info->fSizes, | 389 UpdateYUVComponentSizes(decoder.get(), size_info->fSizes, |
| 400 size_info->fWidthBytes); | 390 size_info->fWidthBytes); |
| 391 | |
| 392 return true; | |
| 401 } | 393 } |
| 402 | 394 |
| 403 } // namespace blink | 395 } // namespace blink |
| OLD | NEW |