| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkColorSpace_DEFINED | 8 #ifndef SkColorSpace_DEFINED |
| 9 #define SkColorSpace_DEFINED | 9 #define SkColorSpace_DEFINED |
| 10 | 10 |
| 11 // Some terms | 11 // Some terms |
| 12 // | 12 // |
| 13 // PCS : Profile Connection Space : where color number values have an absolute
meaning. | 13 // PCS : Profile Connection Space : where color number values have an absolute
meaning. |
| 14 // Part of the work float is to convert colors to and from this space... | 14 // Part of the work float is to convert colors to and from this space... |
| 15 // src_linear_unit_floats --> PCS --> PCS' --> dst_linear_unit_floats | 15 // src_linear_unit_floats --> PCS --> PCS' --> dst_linear_unit_floats |
| 16 // | 16 // |
| 17 // Some nice documents | 17 // Some nice documents |
| 18 // | 18 // |
| 19 // http://www.cambridgeincolour.com/tutorials/color-space-conversion.htm | 19 // http://www.cambridgeincolour.com/tutorials/color-space-conversion.htm |
| 20 // https://www.w3.org/Graphics/Color/srgb | 20 // https://www.w3.org/Graphics/Color/srgb |
| 21 // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html | 21 // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html |
| 22 // | 22 // |
| 23 | 23 |
| 24 #include "SkMatrix44.h" | 24 #include "SkMatrix44.h" |
| 25 #include "SkRefCnt.h" | 25 #include "SkRefCnt.h" |
| 26 #include "SkTemplates.h" | 26 #include "../private/SkTemplates.h" |
| 27 | 27 |
| 28 struct SkColorLookUpTable; | 28 struct SkColorLookUpTable; |
| 29 struct SkGammaCurve; | 29 struct SkGammaCurve; |
| 30 struct SkGammas; | 30 struct SkGammas; |
| 31 | 31 |
| 32 class SkColorSpace : public SkRefCnt { | 32 class SkColorSpace : public SkRefCnt { |
| 33 public: | 33 public: |
| 34 | 34 |
| 35 enum Named { | 35 enum Named { |
| 36 kUnknown_Named, | 36 kUnknown_Named, |
| 37 kSRGB_Named, | 37 kSRGB_Named, |
| 38 kAdobeRGB_Named, | 38 kAdobeRGB_Named, |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Given the src gamma and a transform from src gamut to D50_XYZ, return a
SkColorSpace. | 42 * Given the src gamma and a transform from src gamut to D50_XYZ, return a
SkColorSpace. |
| 43 */ | 43 */ |
| 44 static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD5
0); | 44 static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD5
0); |
| 45 | 45 |
| 46 static sk_sp<SkColorSpace> NewNamed(Named); | 46 static sk_sp<SkColorSpace> NewNamed(Named); |
| 47 static sk_sp<SkColorSpace> NewICC(const void*, size_t); | 47 static sk_sp<SkColorSpace> NewICC(const void*, size_t); |
| 48 | 48 |
| 49 /** |
| 50 * Used only by test code. |
| 51 */ |
| 49 SkGammas* gammas() const { return fGammas.get(); } | 52 SkGammas* gammas() const { return fGammas.get(); } |
| 53 |
| 50 SkMatrix44 xyz() const { return fToXYZD50; } | 54 SkMatrix44 xyz() const { return fToXYZD50; } |
| 51 Named named() const { return fNamed; } | 55 Named named() const { return fNamed; } |
| 52 uint32_t uniqueID() const { return fUniqueID; } | 56 uint32_t uniqueID() const { return fUniqueID; } |
| 53 | 57 |
| 54 private: | 58 private: |
| 55 | 59 |
| 56 static bool LoadGammas(SkGammaCurve* gammas, uint32_t num, const uint8_t* sr
c, size_t len); | 60 static bool LoadGammas(SkGammaCurve* gammas, uint32_t num, const uint8_t* sr
c, size_t len); |
| 57 | 61 |
| 58 | |
| 59 static bool LoadColorLUT(SkColorLookUpTable* colorLUT, uint32_t inputChannel
s, | 62 static bool LoadColorLUT(SkColorLookUpTable* colorLUT, uint32_t inputChannel
s, |
| 60 uint32_t outputChannels, const uint8_t* src, size_t
len); | 63 uint32_t outputChannels, const uint8_t* src, size_t
len); |
| 61 | 64 |
| 62 | 65 static bool LoadA2B0(SkColorLookUpTable* colorLUT, SkGammaCurve*, SkMatrix44
* toXYZ, |
| 63 static bool LoadA2B0(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas, S
kMatrix44* toXYZ, | |
| 64 const uint8_t* src, size_t len); | 66 const uint8_t* src, size_t len); |
| 65 | 67 |
| 66 SkColorSpace(sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, Named); | 68 SkColorSpace(sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, Named); |
| 67 | 69 |
| 68 SkColorSpace(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas, const SkM
atrix44& toXYZ); | 70 SkColorSpace(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas, const SkM
atrix44& toXYZ); |
| 69 | 71 |
| 70 SkAutoTDelete<SkColorLookUpTable> fColorLUT; | 72 SkAutoTDelete<SkColorLookUpTable> fColorLUT; |
| 71 sk_sp<SkGammas> fGammas; | 73 sk_sp<SkGammas> fGammas; |
| 72 const SkMatrix44 fToXYZD50; | 74 const SkMatrix44 fToXYZD50; |
| 73 | 75 |
| 74 const uint32_t fUniqueID; | 76 const uint32_t fUniqueID; |
| 75 const Named fNamed; | 77 const Named fNamed; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 #endif | 80 #endif |
| OLD | NEW |