OLD | NEW |
---|---|
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 Loading... | |
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 if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
363 setColorSpaceAndComputeTransform(SkColorSpace::NewICC(iccData, iccLength)); | 363 return nullptr; |
364 | |
365 if (m_embeddedColorSpace) | |
366 return m_embeddedColorSpace; | |
367 return SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | |
368 } | |
369 | |
370 void ImageDecoder::setColorProfileAndComputeTransform(const char* iccData, | |
371 unsigned iccLength) { | |
372 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(iccData, iccLength); | |
Justin Novosad
2016/10/31 14:55:13
I feel that at this point the nullness of ColorSpa
ccameron
2016/10/31 18:10:18
Yes, definitely. Added. We should also consider so
| |
373 setColorSpaceAndComputeTransform(colorSpace); | |
364 } | 374 } |
365 | 375 |
366 void ImageDecoder::setColorSpaceAndComputeTransform( | 376 void ImageDecoder::setColorSpaceAndComputeTransform( |
367 sk_sp<SkColorSpace> srcSpace) { | 377 sk_sp<SkColorSpace> colorSpace) { |
368 DCHECK(!m_ignoreColorSpace); | 378 DCHECK(!m_ignoreColorSpace); |
369 | 379 |
370 m_srcSpace = srcSpace; | 380 m_embeddedColorSpace = colorSpace; |
381 | |
371 m_sourceToOutputDeviceColorTransform = nullptr; | 382 m_sourceToOutputDeviceColorTransform = nullptr; |
372 | 383 |
373 // With color correct rendering, we do not transform to the output color space | 384 // 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 | 385 // at decode time. Instead, we tag the raw image pixels and pass the tagged |
375 // SkImage to Skia. | 386 // SkImage to Skia. |
376 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | 387 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
377 return; | 388 return; |
378 | 389 |
379 if (!m_srcSpace) | 390 if (!m_embeddedColorSpace) |
380 return; | 391 return; |
381 | 392 |
382 // Take a lock around initializing and accessing the global device color | 393 // Take a lock around initializing and accessing the global device color |
383 // profile. | 394 // profile. |
384 SpinLock::Guard guard(gTargetColorSpaceLock); | 395 SpinLock::Guard guard(gTargetColorSpaceLock); |
385 | 396 |
386 // Initialize the output device profile to sRGB if it has not yet been | 397 // Initialize the output device profile to sRGB if it has not yet been |
387 // initialized. | 398 // initialized. |
388 if (!gTargetColorSpace) { | 399 if (!gTargetColorSpace) { |
389 gTargetColorSpace = | 400 gTargetColorSpace = |
390 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).release(); | 401 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).release(); |
391 } | 402 } |
392 | 403 |
393 if (SkColorSpace::Equals(srcSpace.get(), gTargetColorSpace)) { | 404 if (SkColorSpace::Equals(m_embeddedColorSpace.get(), gTargetColorSpace)) { |
394 return; | 405 return; |
395 } | 406 } |
396 | 407 |
397 m_sourceToOutputDeviceColorTransform = | 408 m_sourceToOutputDeviceColorTransform = |
398 SkColorSpaceXform::New(srcSpace.get(), gTargetColorSpace); | 409 SkColorSpaceXform::New(m_embeddedColorSpace.get(), gTargetColorSpace); |
399 } | 410 } |
400 | 411 |
401 } // namespace blink | 412 } // namespace blink |
OLD | NEW |