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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 2462803002: Plumb color space to DecodingImageGenerator and ImageFrameGenerator (Closed)
Patch Set: Incorporate review feedback Created 4 years, 1 month 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) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (gTargetColorSpace) 351 if (gTargetColorSpace)
352 return; 352 return;
353 353
354 gTargetColorSpace = 354 gTargetColorSpace =
355 SkColorSpace::NewICC(profile.data(), profile.size()).release(); 355 SkColorSpace::NewICC(profile.data(), profile.size()).release();
356 356
357 // UMA statistics. 357 // UMA statistics.
358 BitmapImageMetrics::countGamma(gTargetColorSpace); 358 BitmapImageMetrics::countGamma(gTargetColorSpace);
359 } 359 }
360 360
361 void ImageDecoder::setColorSpaceAndComputeTransform(const char* iccData, 361 sk_sp<SkColorSpace> ImageDecoder::colorSpace() const {
362 unsigned iccLength) { 362 // TODO(ccameron): This should always return a non-null SkColorSpace. This is
363 setColorSpaceAndComputeTransform(SkColorSpace::NewICC(iccData, iccLength)); 363 // disabled for now because specifying a non-renderable color space results in
364 // errors.
365 // https://bugs.chromium.org/p/skia/issues/detail?id=5907
366 if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
367 return nullptr;
368
369 if (m_embeddedColorSpace)
370 return m_embeddedColorSpace;
371 return SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
372 }
373
374 void ImageDecoder::setColorProfileAndComputeTransform(const char* iccData,
375 unsigned iccLength) {
376 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(iccData, iccLength);
377 if (!colorSpace)
378 DLOG(ERROR) << "Failed to parse image ICC profile";
379 setColorSpaceAndComputeTransform(colorSpace);
364 } 380 }
365 381
366 void ImageDecoder::setColorSpaceAndComputeTransform( 382 void ImageDecoder::setColorSpaceAndComputeTransform(
367 sk_sp<SkColorSpace> srcSpace) { 383 sk_sp<SkColorSpace> colorSpace) {
368 DCHECK(!m_ignoreColorSpace); 384 DCHECK(!m_ignoreColorSpace);
369 385
370 m_srcSpace = srcSpace; 386 m_embeddedColorSpace = colorSpace;
387
371 m_sourceToOutputDeviceColorTransform = nullptr; 388 m_sourceToOutputDeviceColorTransform = nullptr;
372 389
373 // With color correct rendering, we do not transform to the output color space 390 // With color correct rendering, we do not transform to the output color space
374 // at decode time. Instead, we tag the raw image pixels and pass the tagged 391 // at decode time. Instead, we tag the raw image pixels and pass the tagged
375 // SkImage to Skia. 392 // SkImage to Skia.
376 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) 393 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
377 return; 394 return;
378 395
379 if (!m_srcSpace) 396 if (!m_embeddedColorSpace)
380 return; 397 return;
381 398
382 // Take a lock around initializing and accessing the global device color 399 // Take a lock around initializing and accessing the global device color
383 // profile. 400 // profile.
384 SpinLock::Guard guard(gTargetColorSpaceLock); 401 SpinLock::Guard guard(gTargetColorSpaceLock);
385 402
386 // Initialize the output device profile to sRGB if it has not yet been 403 // Initialize the output device profile to sRGB if it has not yet been
387 // initialized. 404 // initialized.
388 if (!gTargetColorSpace) { 405 if (!gTargetColorSpace) {
389 gTargetColorSpace = 406 gTargetColorSpace =
390 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).release(); 407 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).release();
391 } 408 }
392 409
393 if (SkColorSpace::Equals(srcSpace.get(), gTargetColorSpace)) { 410 if (SkColorSpace::Equals(m_embeddedColorSpace.get(), gTargetColorSpace)) {
394 return; 411 return;
395 } 412 }
396 413
397 m_sourceToOutputDeviceColorTransform = 414 m_sourceToOutputDeviceColorTransform =
398 SkColorSpaceXform::New(srcSpace.get(), gTargetColorSpace); 415 SkColorSpaceXform::New(m_embeddedColorSpace.get(), gTargetColorSpace);
399 } 416 }
400 417
401 } // namespace blink 418 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698