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

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

Issue 2787053004: Respect colorSpace in DecodingImageGenerator::onGetPixels() (Closed)
Patch Set: Response to comments Created 3 years, 8 months 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, 106 ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize,
107 bool isMultiFrame, 107 bool isMultiFrame,
108 const ColorBehavior& colorBehavior) 108 const ColorBehavior& colorBehavior)
109 : m_fullSize(fullSize), 109 : m_fullSize(fullSize),
110 m_decoderColorBehavior(colorBehavior), 110 m_decoderColorBehavior(colorBehavior),
111 m_isMultiFrame(isMultiFrame), 111 m_isMultiFrame(isMultiFrame),
112 m_decodeFailed(false), 112 m_decodeFailed(false),
113 m_yuvDecodingFailed(false), 113 m_yuvDecodingFailed(false),
114 m_frameCount(0) {} 114 m_frameCount(0),
115 m_alphaOption(ImageDecoder::AlphaPremultiplied) {}
115 116
116 ImageFrameGenerator::~ImageFrameGenerator() { 117 ImageFrameGenerator::~ImageFrameGenerator() {
117 ImageDecodingStore::instance().removeCacheIndexedByGenerator(this); 118 ImageDecodingStore::instance().removeCacheIndexedByGenerator(this);
118 } 119 }
119 120
120 bool ImageFrameGenerator::decodeAndScale(SegmentReader* data, 121 bool ImageFrameGenerator::decodeAndScale(SegmentReader* data,
121 bool allDataReceived, 122 bool allDataReceived,
122 size_t index, 123 size_t index,
123 const SkImageInfo& info, 124 const SkImageInfo& info,
124 void* pixels, 125 void* pixels,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Try to create an ImageDecoder if we are not given one. 289 // Try to create an ImageDecoder if we are not given one.
289 ASSERT(decoder); 290 ASSERT(decoder);
290 bool newDecoder = false; 291 bool newDecoder = false;
291 bool shouldCallSetData = true; 292 bool shouldCallSetData = true;
292 if (!*decoder) { 293 if (!*decoder) {
293 newDecoder = true; 294 newDecoder = true;
294 if (m_imageDecoderFactory) 295 if (m_imageDecoderFactory)
295 *decoder = m_imageDecoderFactory->create().release(); 296 *decoder = m_imageDecoderFactory->create().release();
296 297
297 if (!*decoder) { 298 if (!*decoder) {
298 *decoder = ImageDecoder::create(data, allDataReceived, 299 *decoder = ImageDecoder::create(data, allDataReceived, m_alphaOption,
299 ImageDecoder::AlphaPremultiplied,
300 m_decoderColorBehavior) 300 m_decoderColorBehavior)
301 .release(); 301 .release();
302 // 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.
303 shouldCallSetData = false; 303 shouldCallSetData = false;
304 } 304 }
305 305
306 if (!*decoder) 306 if (!*decoder)
307 return false; 307 return false;
308 } 308 }
309 309
310 DCHECK((*decoder)->frameBufferAtIndex(index)->premultiplyAlpha() ==
msarett1 2017/04/04 23:02:36 I'm expecting the DCHECK() to warn us if we've alr
scroggo_chromium 2017/04/05 19:59:01 frameBufferAtIndex may trigger a decode, so you do
msarett1 2017/04/06 22:05:29 This all sgtm. Thanks for your thoughts.
311 (m_alphaOption == ImageDecoder::AlphaPremultiplied));
310 312
311 if (shouldCallSetData) 313 if (shouldCallSetData)
312 (*decoder)->setData(data, allDataReceived); 314 (*decoder)->setData(data, allDataReceived);
313 315
314 bool usingExternalAllocator = false; 316 bool usingExternalAllocator = false;
315 317
316 // For multi-frame image decoders, we need to know how many frames are 318 // For multi-frame image decoders, we need to know how many frames are
317 // in that image in order to release the decoder when all frames are 319 // in that image in order to release the decoder when all frames are
318 // decoded. frameCount() is reliable only if all data is received and set in 320 // decoded. frameCount() is reliable only if all data is received and set in
319 // decoder, particularly with GIF. 321 // decoder, particularly with GIF.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // do YUV decoding. 385 // do YUV decoding.
384 std::unique_ptr<ImagePlanes> dummyImagePlanes = 386 std::unique_ptr<ImagePlanes> dummyImagePlanes =
385 WTF::wrapUnique(new ImagePlanes); 387 WTF::wrapUnique(new ImagePlanes);
386 decoder->setImagePlanes(std::move(dummyImagePlanes)); 388 decoder->setImagePlanes(std::move(dummyImagePlanes));
387 389
388 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, 390 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes,
389 sizeInfo->fWidthBytes); 391 sizeInfo->fWidthBytes);
390 } 392 }
391 393
392 } // namespace blink 394 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698