| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/color_space.h" | 5 #include "ui/gfx/color_space.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 // Use the parametric transfer function if no other option is available. | 361 // Use the parametric transfer function if no other option is available. |
| 362 SkColorSpaceTransferFn fn; | 362 SkColorSpaceTransferFn fn; |
| 363 if (!GetTransferFunction(&fn)) { | 363 if (!GetTransferFunction(&fn)) { |
| 364 DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace"; | 364 DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace"; |
| 365 return nullptr; | 365 return nullptr; |
| 366 } | 366 } |
| 367 return SkColorSpace::MakeRGB(fn, to_xyz_d50); | 367 return SkColorSpace::MakeRGB(fn, to_xyz_d50); |
| 368 } | 368 } |
| 369 | 369 |
| 370 sk_sp<SkColorSpace> ColorSpace::ToNonlinearBlendedSkColorSpace() const { |
| 371 DCHECK(IsValid()); |
| 372 DCHECK_EQ(matrix_, MatrixID::RGB); |
| 373 DCHECK_EQ(range_, RangeID::FULL); |
| 374 SkMatrix44 primaries; |
| 375 GetPrimaryMatrix(&primaries); |
| 376 SkColorSpaceTransferFn tr_fn; |
| 377 bool get_tr_fn_result = get_tr_fn_result = GetTransferFunction(&tr_fn); |
| 378 DCHECK(get_tr_fn_result); |
| 379 sk_sp<SkColorSpace> result = SkColorSpace::MakeRGB( |
| 380 tr_fn, primaries, SkColorSpace::kNonLinearBlending_ColorSpaceFlag); |
| 381 DCHECK(result); |
| 382 return result; |
| 383 } |
| 384 |
| 370 bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const { | 385 bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const { |
| 371 if (!IsValid()) | 386 if (!IsValid()) |
| 372 return false; | 387 return false; |
| 373 | 388 |
| 374 // If this was created from an ICC profile, retrieve that exact profile. | 389 // If this was created from an ICC profile, retrieve that exact profile. |
| 375 ICCProfile result; | 390 ICCProfile result; |
| 376 if (ICCProfile::FromId(icc_profile_id_, false, icc_profile)) | 391 if (ICCProfile::FromId(icc_profile_id_, false, icc_profile)) |
| 377 return true; | 392 return true; |
| 378 | 393 |
| 379 // Otherwise, construct an ICC profile based on the best approximated | 394 // Otherwise, construct an ICC profile based on the best approximated |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 case MatrixID::BT2020_NCL: | 748 case MatrixID::BT2020_NCL: |
| 734 case MatrixID::BT2020_CL: | 749 case MatrixID::BT2020_CL: |
| 735 case MatrixID::YDZDX: | 750 case MatrixID::YDZDX: |
| 736 matrix->setScale(255.0f/219.0f, 255.0f/224.0f, 255.0f/224.0f); | 751 matrix->setScale(255.0f/219.0f, 255.0f/224.0f, 255.0f/224.0f); |
| 737 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); | 752 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); |
| 738 break; | 753 break; |
| 739 } | 754 } |
| 740 } | 755 } |
| 741 | 756 |
| 742 } // namespace gfx | 757 } // namespace gfx |
| OLD | NEW |