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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 | 345 |
346 // Take a lock around initializing and accessing the global device color | 346 // Take a lock around initializing and accessing the global device color |
347 // profile. | 347 // profile. |
348 SpinLock::Guard guard(gTargetColorSpaceLock); | 348 SpinLock::Guard guard(gTargetColorSpaceLock); |
349 | 349 |
350 // Layout tests expect that only the first call will take effect. | 350 // Layout tests expect that only the first call will take effect. |
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::MakeICC(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 sk_sp<SkColorSpace> ImageDecoder::colorSpace() const { | 361 sk_sp<SkColorSpace> ImageDecoder::colorSpace() const { |
362 // TODO(ccameron): This should always return a non-null SkColorSpace. This is | 362 // TODO(ccameron): This should always return a non-null SkColorSpace. This is |
363 // disabled for now because specifying a non-renderable color space results in | 363 // disabled for now because specifying a non-renderable color space results in |
364 // errors. | 364 // errors. |
365 // https://bugs.chromium.org/p/skia/issues/detail?id=5907 | 365 // https://bugs.chromium.org/p/skia/issues/detail?id=5907 |
366 if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | 366 if (!RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
367 return nullptr; | 367 return nullptr; |
368 | 368 |
369 if (m_embeddedColorSpace) | 369 if (m_embeddedColorSpace) |
370 return m_embeddedColorSpace; | 370 return m_embeddedColorSpace; |
371 return SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 371 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); |
372 } | 372 } |
373 | 373 |
374 void ImageDecoder::setColorProfileAndComputeTransform(const char* iccData, | 374 void ImageDecoder::setColorProfileAndComputeTransform(const char* iccData, |
375 unsigned iccLength) { | 375 unsigned iccLength) { |
376 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(iccData, iccLength); | 376 sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(iccData, iccLength); |
377 if (!colorSpace) | 377 if (!colorSpace) |
378 DLOG(ERROR) << "Failed to parse image ICC profile"; | 378 DLOG(ERROR) << "Failed to parse image ICC profile"; |
379 setColorSpaceAndComputeTransform(colorSpace); | 379 setColorSpaceAndComputeTransform(colorSpace); |
Justin Novosad
2016/11/02 15:39:21
Not new to this CL, but missing std::move here.
| |
380 } | 380 } |
381 | 381 |
382 void ImageDecoder::setColorSpaceAndComputeTransform( | 382 void ImageDecoder::setColorSpaceAndComputeTransform( |
383 sk_sp<SkColorSpace> colorSpace) { | 383 sk_sp<SkColorSpace> colorSpace) { |
384 DCHECK(!m_ignoreColorSpace); | 384 DCHECK(!m_ignoreColorSpace); |
385 | 385 |
386 m_embeddedColorSpace = colorSpace; | 386 m_embeddedColorSpace = colorSpace; |
387 | 387 |
388 m_sourceToOutputDeviceColorTransform = nullptr; | 388 m_sourceToOutputDeviceColorTransform = nullptr; |
389 | 389 |
390 // 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 |
391 // 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 |
392 // SkImage to Skia. | 392 // SkImage to Skia. |
393 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | 393 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
394 return; | 394 return; |
395 | 395 |
396 if (!m_embeddedColorSpace) | 396 if (!m_embeddedColorSpace) |
397 return; | 397 return; |
398 | 398 |
399 // Take a lock around initializing and accessing the global device color | 399 // Take a lock around initializing and accessing the global device color |
400 // profile. | 400 // profile. |
401 SpinLock::Guard guard(gTargetColorSpaceLock); | 401 SpinLock::Guard guard(gTargetColorSpaceLock); |
402 | 402 |
403 // 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 |
404 // initialized. | 404 // initialized. |
405 if (!gTargetColorSpace) { | 405 if (!gTargetColorSpace) { |
406 gTargetColorSpace = | 406 gTargetColorSpace = |
407 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).release(); | 407 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).release(); |
408 } | 408 } |
409 | 409 |
410 if (SkColorSpace::Equals(m_embeddedColorSpace.get(), gTargetColorSpace)) { | 410 if (SkColorSpace::Equals(m_embeddedColorSpace.get(), gTargetColorSpace)) { |
411 return; | 411 return; |
412 } | 412 } |
413 | 413 |
414 m_sourceToOutputDeviceColorTransform = | 414 m_sourceToOutputDeviceColorTransform = |
415 SkColorSpaceXform::New(m_embeddedColorSpace.get(), gTargetColorSpace); | 415 SkColorSpaceXform::New(m_embeddedColorSpace.get(), gTargetColorSpace); |
416 } | 416 } |
417 | 417 |
418 } // namespace blink | 418 } // namespace blink |
OLD | NEW |