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

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

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

Powered by Google App Engine
This is Rietveld 408576698