Commit 920475bf authored by Khushal's avatar Khushal Committed by Commit Bot

blink/images: Centralize decision for using YUV decoding.

YUV decoding is currently hardcoded to jpegs and the decision is
spilled to a couple of places. Since we want to add it for WebP,
centralize it to DeferredImageDecoder which makes the decision at paint
time based on whether it is supported by the ImageDecoder implementation
for each format.

R=pdr@chromium.org

Change-Id: I156d397c578c45a1490385aecbd96546c4ce798b
Reviewed-on: https://chromium-review.googlesource.com/c/1320750Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606263}
parent c4453e28
......@@ -196,9 +196,7 @@ bool DecodingImageGenerator::QueryYUVA8(
SkYUVASizeInfo* size_info,
SkYUVAIndex indices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* color_space) const {
// YUV decoding does not currently support progressive decoding. See comment
// in ImageFrameGenerator.h.
if (!can_yuv_decode_ || !all_data_received_)
if (!can_yuv_decode_)
return false;
TRACE_EVENT0("blink", "DecodingImageGenerator::queryYUVA8");
......
......@@ -266,10 +266,6 @@ void DeferredImageDecoder::ActivateLazyDecoding() {
image_is_high_bit_depth_ = metadata_decoder_->ImageIsHighBitDepth();
has_hot_spot_ = metadata_decoder_->HotSpot(hot_spot_);
filename_extension_ = metadata_decoder_->FilenameExtension();
// JPEG images support YUV decoding; other decoders do not. (WebP could in the
// future.)
can_yuv_decode_ = RuntimeEnabledFeatures::DecodeToYUVEnabled() &&
(filename_extension_ == "jpg");
has_embedded_color_profile_ = metadata_decoder_->HasEmbeddedColorProfile();
color_space_for_sk_images_ = metadata_decoder_->ColorSpaceForSkImages();
......@@ -311,6 +307,12 @@ void DeferredImageDecoder::PrepareLazyDecodedFrames() {
metadata_decoder_->FrameIsReceivedAtIndex(last_frame);
}
// YUV decoding does not currently support progressive decoding. See comment
// in image_frame_generator.h.
can_yuv_decode_ = RuntimeEnabledFeatures::DecodeToYUVEnabled() &&
metadata_decoder_->CanDecodeToYUV() && all_data_received_ &&
!frame_generator_->IsMultiFrame();
// If we've received all of the data, then we can reset the metadata decoder,
// since everything we care about should now be stored in |frame_data_|.
if (all_data_received_) {
......
......@@ -41,8 +41,7 @@ namespace blink {
static bool UpdateYUVComponentSizes(ImageDecoder* decoder,
SkISize component_sizes[4],
size_t component_width_bytes[4]) {
if (!decoder->CanDecodeToYUV())
return false;
DCHECK(decoder->CanDecodeToYUV());
for (int yuv_index = 0; yuv_index < 3; ++yuv_index) {
IntSize size = decoder->DecodedYUVSize(yuv_index);
......@@ -151,6 +150,7 @@ bool ImageFrameGenerator::DecodeToYUV(SegmentReader* data,
void* planes[3],
const size_t row_bytes[3]) {
MutexLocker lock(generator_mutex_);
DCHECK_EQ(index, 0u);
// TODO (scroggo): The only interesting thing this uses from the
// ImageFrameGenerator is m_decodeFailed. Move this into
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment