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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp

Issue 2523943002: Explicitly specify target color space to ImageDecoder at creation (Closed)
Patch Set: Rebase Created 4 years 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) 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 componentWidthBytes[0] = decoder->decodedYUVWidthBytes(0); 96 componentWidthBytes[0] = decoder->decodedYUVWidthBytes(0);
97 size = decoder->decodedYUVSize(1); 97 size = decoder->decodedYUVSize(1);
98 componentSizes[1].set(size.width(), size.height()); 98 componentSizes[1].set(size.width(), size.height());
99 componentWidthBytes[1] = decoder->decodedYUVWidthBytes(1); 99 componentWidthBytes[1] = decoder->decodedYUVWidthBytes(1);
100 size = decoder->decodedYUVSize(2); 100 size = decoder->decodedYUVSize(2);
101 componentSizes[2].set(size.width(), size.height()); 101 componentSizes[2].set(size.width(), size.height());
102 componentWidthBytes[2] = decoder->decodedYUVWidthBytes(2); 102 componentWidthBytes[2] = decoder->decodedYUVWidthBytes(2);
103 return true; 103 return true;
104 } 104 }
105 105
106 ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, 106 ImageFrameGenerator::ImageFrameGenerator(
107 sk_sp<SkColorSpace> colorSpace, 107 const SkISize& fullSize,
108 bool isMultiFrame) 108 bool isMultiFrame,
109 ImageDecoder::ColorSpaceOption decoderColorSpaceOption,
110 sk_sp<SkColorSpace> decoderTargetColorSpace)
109 : m_fullSize(fullSize), 111 : m_fullSize(fullSize),
110 m_colorSpace(std::move(colorSpace)), 112 m_decoderColorSpaceOption(decoderColorSpaceOption),
113 m_decoderTargetColorSpace(std::move(decoderTargetColorSpace)),
111 m_isMultiFrame(isMultiFrame), 114 m_isMultiFrame(isMultiFrame),
112 m_decodeFailed(false), 115 m_decodeFailed(false),
113 m_yuvDecodingFailed(false), 116 m_yuvDecodingFailed(false),
114 m_frameCount(0) {} 117 m_frameCount(0) {}
115 118
116 ImageFrameGenerator::~ImageFrameGenerator() { 119 ImageFrameGenerator::~ImageFrameGenerator() {
117 ImageDecodingStore::instance().removeCacheIndexedByGenerator(this); 120 ImageDecodingStore::instance().removeCacheIndexedByGenerator(this);
118 } 121 }
119 122
120 bool ImageFrameGenerator::decodeAndScale(SegmentReader* data, 123 bool ImageFrameGenerator::decodeAndScale(SegmentReader* data,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return false; 170 return false;
168 171
169 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index", 172 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index",
170 static_cast<int>(index)); 173 static_cast<int>(index));
171 174
172 if (!planes || !planes[0] || !planes[1] || !planes[2] || !rowBytes || 175 if (!planes || !planes[0] || !planes[1] || !planes[2] || !rowBytes ||
173 !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { 176 !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) {
174 return false; 177 return false;
175 } 178 }
176 179
177 std::unique_ptr<ImageDecoder> decoder = 180 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(
178 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, 181 data, true, ImageDecoder::AlphaPremultiplied, m_decoderColorSpaceOption,
179 ImageDecoder::ColorSpaceApplied); 182 m_decoderTargetColorSpace);
180 // getYUVComponentSizes was already called and was successful, so 183 // getYUVComponentSizes was already called and was successful, so
181 // ImageDecoder::create must succeed. 184 // ImageDecoder::create must succeed.
182 ASSERT(decoder); 185 ASSERT(decoder);
183 186
184 std::unique_ptr<ImagePlanes> imagePlanes = 187 std::unique_ptr<ImagePlanes> imagePlanes =
185 makeUnique<ImagePlanes>(planes, rowBytes); 188 makeUnique<ImagePlanes>(planes, rowBytes);
186 decoder->setImagePlanes(std::move(imagePlanes)); 189 decoder->setImagePlanes(std::move(imagePlanes));
187 190
188 ASSERT(decoder->canDecodeToYUV()); 191 ASSERT(decoder->canDecodeToYUV());
189 192
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Try to create an ImageDecoder if we are not given one. 292 // Try to create an ImageDecoder if we are not given one.
290 ASSERT(decoder); 293 ASSERT(decoder);
291 bool newDecoder = false; 294 bool newDecoder = false;
292 bool shouldCallSetData = true; 295 bool shouldCallSetData = true;
293 if (!*decoder) { 296 if (!*decoder) {
294 newDecoder = true; 297 newDecoder = true;
295 if (m_imageDecoderFactory) 298 if (m_imageDecoderFactory)
296 *decoder = m_imageDecoderFactory->create().release(); 299 *decoder = m_imageDecoderFactory->create().release();
297 300
298 if (!*decoder) { 301 if (!*decoder) {
299 *decoder = ImageDecoder::create(data, allDataReceived, 302 *decoder = ImageDecoder::create(
300 ImageDecoder::AlphaPremultiplied, 303 data, allDataReceived, ImageDecoder::AlphaPremultiplied,
301 ImageDecoder::ColorSpaceApplied) 304 m_decoderColorSpaceOption, m_decoderTargetColorSpace)
302 .release(); 305 .release();
303 // The newly created decoder just grabbed the data. No need to reset it. 306 // The newly created decoder just grabbed the data. No need to reset it.
304 shouldCallSetData = false; 307 shouldCallSetData = false;
305 } 308 }
306 309
307 if (!*decoder) 310 if (!*decoder)
308 return false; 311 return false;
309 } 312 }
310 313
311 if (!m_isMultiFrame && newDecoder && allDataReceived) { 314 if (!m_isMultiFrame && newDecoder && allDataReceived) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 362 }
360 363
361 bool ImageFrameGenerator::getYUVComponentSizes(SegmentReader* data, 364 bool ImageFrameGenerator::getYUVComponentSizes(SegmentReader* data,
362 SkYUVSizeInfo* sizeInfo) { 365 SkYUVSizeInfo* sizeInfo) {
363 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width", 366 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width",
364 m_fullSize.width(), "height", m_fullSize.height()); 367 m_fullSize.width(), "height", m_fullSize.height());
365 368
366 if (m_yuvDecodingFailed) 369 if (m_yuvDecodingFailed)
367 return false; 370 return false;
368 371
369 std::unique_ptr<ImageDecoder> decoder = 372 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(
370 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, 373 data, true, ImageDecoder::AlphaPremultiplied, m_decoderColorSpaceOption,
371 ImageDecoder::ColorSpaceApplied); 374 m_decoderTargetColorSpace);
372 if (!decoder) 375 if (!decoder)
373 return false; 376 return false;
374 377
375 // Setting a dummy ImagePlanes object signals to the decoder that we want to 378 // Setting a dummy ImagePlanes object signals to the decoder that we want to
376 // do YUV decoding. 379 // do YUV decoding.
377 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes); 380 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes);
378 decoder->setImagePlanes(std::move(dummyImagePlanes)); 381 decoder->setImagePlanes(std::move(dummyImagePlanes));
379 382
380 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, 383 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes,
381 sizeInfo->fWidthBytes); 384 sizeInfo->fWidthBytes);
382 } 385 }
383 386
384 } // namespace blink 387 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698