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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 float m_duration; 54 float m_duration;
55 bool m_isComplete; 55 bool m_isComplete;
56 size_t m_frameBytes; 56 size_t m_frameBytes;
57 uint32_t m_uniqueID; 57 uint32_t m_uniqueID;
58 }; 58 };
59 59
60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create( 60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create(
61 PassRefPtr<SharedBuffer> passData, 61 PassRefPtr<SharedBuffer> passData,
62 bool dataComplete, 62 bool dataComplete,
63 ImageDecoder::AlphaOption alphaOption, 63 ImageDecoder::AlphaOption alphaOption,
64 ImageDecoder::ColorSpaceOption colorOptions) { 64 ImageDecoder::ColorSpaceOption colorOptions,
65 sk_sp<SkColorSpace> targetColorSpace) {
65 RefPtr<SharedBuffer> data = passData; 66 RefPtr<SharedBuffer> data = passData;
66 67
67 std::unique_ptr<ImageDecoder> actualDecoder = 68 std::unique_ptr<ImageDecoder> actualDecoder =
68 ImageDecoder::create(data, dataComplete, alphaOption, colorOptions); 69 ImageDecoder::create(data, dataComplete, alphaOption, colorOptions,
69 70 std::move(targetColorSpace));
70 if (!actualDecoder) 71 if (!actualDecoder)
71 return nullptr; 72 return nullptr;
72 73
73 std::unique_ptr<DeferredImageDecoder> decoder( 74 std::unique_ptr<DeferredImageDecoder> decoder(
74 new DeferredImageDecoder(std::move(actualDecoder))); 75 new DeferredImageDecoder(std::move(actualDecoder)));
75 76
76 // Since we've just instantiated a fresh decoder, there's no need to reset its 77 // Since we've just instantiated a fresh decoder, there's no need to reset its
77 // data. 78 // data.
78 decoder->setDataInternal(data.release(), dataComplete, false); 79 decoder->setDataInternal(data.release(), dataComplete, false);
79 80
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return; 261 return;
261 262
262 m_size = m_actualDecoder->size(); 263 m_size = m_actualDecoder->size();
263 m_hasHotSpot = m_actualDecoder->hotSpot(m_hotSpot); 264 m_hasHotSpot = m_actualDecoder->hotSpot(m_hotSpot);
264 m_filenameExtension = m_actualDecoder->filenameExtension(); 265 m_filenameExtension = m_actualDecoder->filenameExtension();
265 // JPEG images support YUV decoding; other decoders do not. (WebP could in the 266 // JPEG images support YUV decoding; other decoders do not. (WebP could in the
266 // future.) 267 // future.)
267 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && 268 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() &&
268 (m_filenameExtension == "jpg"); 269 (m_filenameExtension == "jpg");
269 m_hasEmbeddedColorSpace = m_actualDecoder->hasEmbeddedColorSpace(); 270 m_hasEmbeddedColorSpace = m_actualDecoder->hasEmbeddedColorSpace();
271 m_colorSpaceForSkImages = m_actualDecoder->colorSpaceForSkImages();
270 272
271 const bool isSingleFrame = 273 const bool isSingleFrame =
272 m_actualDecoder->repetitionCount() == cAnimationNone || 274 m_actualDecoder->repetitionCount() == cAnimationNone ||
273 (m_allDataReceived && m_actualDecoder->frameCount() == 1u); 275 (m_allDataReceived && m_actualDecoder->frameCount() == 1u);
274 const SkISize decodedSize = 276 const SkISize decodedSize =
275 SkISize::Make(m_actualDecoder->decodedSize().width(), 277 SkISize::Make(m_actualDecoder->decodedSize().width(),
276 m_actualDecoder->decodedSize().height()); 278 m_actualDecoder->decodedSize().height());
277 m_frameGenerator = ImageFrameGenerator::create( 279 m_frameGenerator = ImageFrameGenerator::create(
278 decodedSize, m_actualDecoder->colorSpace(), !isSingleFrame); 280 decodedSize, !isSingleFrame, m_actualDecoder->colorSpaceOption(),
281 m_actualDecoder->targetColorSpace());
279 } 282 }
280 283
281 void DeferredImageDecoder::prepareLazyDecodedFrames() { 284 void DeferredImageDecoder::prepareLazyDecodedFrames() {
282 if (!m_actualDecoder || !m_actualDecoder->isSizeAvailable()) 285 if (!m_actualDecoder || !m_actualDecoder->isSizeAvailable())
283 return; 286 return;
284 287
285 activateLazyDecoding(); 288 activateLazyDecoding();
286 289
287 const size_t previousSize = m_frameData.size(); 290 const size_t previousSize = m_frameData.size();
288 m_frameData.resize(m_actualDecoder->frameCount()); 291 m_frameData.resize(m_actualDecoder->frameCount());
(...skipping 30 matching lines...) Expand all
319 ASSERT(decodedSize.width() > 0); 322 ASSERT(decodedSize.width() > 0);
320 ASSERT(decodedSize.height() > 0); 323 ASSERT(decodedSize.height() > 0);
321 324
322 sk_sp<SkROBuffer> roBuffer(m_rwBuffer->newRBufferSnapshot()); 325 sk_sp<SkROBuffer> roBuffer(m_rwBuffer->newRBufferSnapshot());
323 RefPtr<SegmentReader> segmentReader = 326 RefPtr<SegmentReader> segmentReader =
324 SegmentReader::createFromSkROBuffer(std::move(roBuffer)); 327 SegmentReader::createFromSkROBuffer(std::move(roBuffer));
325 328
326 SkImageInfo info = SkImageInfo::MakeN32( 329 SkImageInfo info = SkImageInfo::MakeN32(
327 decodedSize.width(), decodedSize.height(), 330 decodedSize.width(), decodedSize.height(),
328 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType, 331 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
329 m_frameGenerator->getColorSpace()); 332 m_colorSpaceForSkImages);
330 333
331 DecodingImageGenerator* generator = new DecodingImageGenerator( 334 DecodingImageGenerator* generator = new DecodingImageGenerator(
332 m_frameGenerator, info, segmentReader.release(), m_allDataReceived, index, 335 m_frameGenerator, info, segmentReader.release(), m_allDataReceived, index,
333 m_frameData[index].m_uniqueID); 336 m_frameData[index].m_uniqueID);
334 sk_sp<SkImage> image = SkImage::MakeFromGenerator( 337 sk_sp<SkImage> image = SkImage::MakeFromGenerator(
335 generator); // SkImage takes ownership of the generator. 338 generator); // SkImage takes ownership of the generator.
336 if (!image) 339 if (!image)
337 return nullptr; 340 return nullptr;
338 341
339 // We can consider decoded bitmap constant and reuse uniqueID only after all 342 // We can consider decoded bitmap constant and reuse uniqueID only after all
(...skipping 23 matching lines...) Expand all
363 366
364 namespace WTF { 367 namespace WTF {
365 template <> 368 template <>
366 struct VectorTraits<blink::DeferredFrameData> 369 struct VectorTraits<blink::DeferredFrameData>
367 : public SimpleClassVectorTraits<blink::DeferredFrameData> { 370 : public SimpleClassVectorTraits<blink::DeferredFrameData> {
368 STATIC_ONLY(VectorTraits); 371 STATIC_ONLY(VectorTraits);
369 static const bool canInitializeWithMemset = 372 static const bool canInitializeWithMemset =
370 false; // Not all DeferredFrameData members initialize to 0. 373 false; // Not all DeferredFrameData members initialize to 0.
371 }; 374 };
372 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698