| 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 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 // Use the parametric transfer function if no other option is available. | 418 // Use the parametric transfer function if no other option is available. |
| 419 SkColorSpaceTransferFn fn; | 419 SkColorSpaceTransferFn fn; |
| 420 if (!GetTransferFunction(&fn)) { | 420 if (!GetTransferFunction(&fn)) { |
| 421 DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace"; | 421 DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace"; |
| 422 return nullptr; | 422 return nullptr; |
| 423 } | 423 } |
| 424 return SkColorSpace::MakeRGB(fn, to_xyz_d50); | 424 return SkColorSpace::MakeRGB(fn, to_xyz_d50); |
| 425 } | 425 } |
| 426 | 426 |
| 427 sk_sp<SkColorSpace> ColorSpace::ToNonlinearBlendedSkColorSpace() const { | |
| 428 if (!IsValid()) { | |
| 429 DLOG(ERROR) << "Cannot create SkColorSpace for invalid space."; | |
| 430 return nullptr; | |
| 431 } | |
| 432 if (matrix_ != MatrixID::RGB) { | |
| 433 DLOG(ERROR) << "Not creating non-RGB SkColorSpace"; | |
| 434 return nullptr; | |
| 435 } | |
| 436 if (range_ != RangeID::FULL) { | |
| 437 DLOG(ERROR) << "Not creating non-full-range SkColorSpace"; | |
| 438 return nullptr; | |
| 439 } | |
| 440 | |
| 441 SkMatrix44 primaries; | |
| 442 GetPrimaryMatrix(&primaries); | |
| 443 SkColorSpaceTransferFn tr_fn; | |
| 444 if (!GetTransferFunction(&tr_fn)) { | |
| 445 DLOG(ERROR) << "Not creating non-parametric nonlinear-blended SkColorSpace"; | |
| 446 return nullptr; | |
| 447 } | |
| 448 return SkColorSpace::MakeRGB(tr_fn, primaries, | |
| 449 SkColorSpace::kNonLinearBlending_ColorSpaceFlag); | |
| 450 } | |
| 451 | |
| 452 bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const { | 427 bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const { |
| 453 if (!IsValid()) { | 428 if (!IsValid()) { |
| 454 DLOG(ERROR) << "Cannot fetch ICCProfile for invalid space."; | 429 DLOG(ERROR) << "Cannot fetch ICCProfile for invalid space."; |
| 455 return false; | 430 return false; |
| 456 } | 431 } |
| 457 if (matrix_ != MatrixID::RGB) { | 432 if (matrix_ != MatrixID::RGB) { |
| 458 DLOG(ERROR) << "Not creating non-RGB ICCProfile"; | 433 DLOG(ERROR) << "Not creating non-RGB ICCProfile"; |
| 459 return false; | 434 return false; |
| 460 } | 435 } |
| 461 if (range_ != RangeID::FULL) { | 436 if (range_ != RangeID::FULL) { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); | 812 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); |
| 838 break; | 813 break; |
| 839 } | 814 } |
| 840 } | 815 } |
| 841 | 816 |
| 842 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { | 817 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { |
| 843 return out << color_space.ToString(); | 818 return out << color_space.ToString(); |
| 844 } | 819 } |
| 845 | 820 |
| 846 } // namespace gfx | 821 } // namespace gfx |
| OLD | NEW |