Chromium Code Reviews| 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 | |
|
msarett
2016/05/20 15:36:07
I don't feel strongly about removing these comment
| |
| 12 // | |
| 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... | |
| 15 // src_linear_unit_floats --> PCS --> PCS' --> dst_linear_unit_floats | |
| 16 // | |
| 17 // Some nice documents | |
| 18 // | |
| 19 // http://www.cambridgeincolour.com/tutorials/color-space-conversion.htm | |
| 20 // https://www.w3.org/Graphics/Color/srgb | |
| 21 // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html | |
| 22 // | |
| 23 | |
| 24 #include "SkMatrix44.h" | 11 #include "SkMatrix44.h" |
| 25 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
| 26 #include "../private/SkTemplates.h" | 13 #include "../private/SkTemplates.h" |
| 27 | 14 |
| 28 struct SkColorLookUpTable; | 15 struct SkColorLookUpTable; |
| 29 struct SkGammaCurve; | 16 struct SkGammaCurve; |
| 30 struct SkGammas; | 17 struct SkGammas; |
| 31 | 18 |
| 32 class SkColorSpace : public SkRefCnt { | 19 class SkColorSpace : public SkRefCnt { |
| 33 public: | 20 public: |
| 34 | 21 |
| 22 /** | |
| 23 * Common, named profiles that we can recognize. | |
| 24 */ | |
| 35 enum Named { | 25 enum Named { |
| 36 kUnknown_Named, | 26 kUnknown_Named, |
| 37 kSRGB_Named, | 27 kSRGB_Named, |
| 38 kAdobeRGB_Named, | 28 kAdobeRGB_Named, |
| 39 }; | 29 }; |
| 40 | 30 |
| 41 /** | 31 /** |
| 42 * Given the src gamma and a transform from src gamut to D50_XYZ, return a SkColorSpace. | 32 * Create an SkColorSpace from the src gamma and a transform from src gamut to D50 XYZ. |
| 43 */ | 33 */ |
| 44 static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD5 0); | 34 static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD5 0); |
| 45 | 35 |
| 36 /** | |
| 37 * Create a common, named SkColorSpace. | |
| 38 */ | |
| 46 static sk_sp<SkColorSpace> NewNamed(Named); | 39 static sk_sp<SkColorSpace> NewNamed(Named); |
| 40 | |
| 41 /** | |
| 42 * Create an SkColorSpace from an ICC profile. | |
| 43 */ | |
| 47 static sk_sp<SkColorSpace> NewICC(const void*, size_t); | 44 static sk_sp<SkColorSpace> NewICC(const void*, size_t); |
| 48 | 45 |
| 49 /** | 46 /** |
| 50 * Used only by test code. | 47 * Used interally. |
| 51 */ | 48 */ |
| 52 SkGammas* gammas() const { return fGammas.get(); } | 49 SkGammas* gammas() const { return fGammas.get(); } |
| 53 | 50 |
| 51 /** | |
| 52 * Returns the matrix used to transform src gamut to XYZ D50. | |
| 53 */ | |
| 54 SkMatrix44 xyz() const { return fToXYZD50; } | 54 SkMatrix44 xyz() const { return fToXYZD50; } |
| 55 | |
| 56 /** | |
| 57 * Returns profile name or kUnknown if it does not match one of our known p rofiles. | |
| 58 */ | |
| 55 Named named() const { return fNamed; } | 59 Named named() const { return fNamed; } |
|
reed1
2016/05/20 21:10:44
do we need this guy?
msarett
2016/05/23 14:03:48
Not right now, I'm deleting it because no one is u
| |
| 56 uint32_t uniqueID() const { return fUniqueID; } | |
| 57 | 60 |
|
reed1
2016/05/20 21:10:44
Do we have an idea for the srgb-like query we're g
msarett
2016/05/23 14:03:48
Yeah I had an idea. I'll pull it in from another
| |
| 58 private: | 61 private: |
| 59 | 62 |
| 60 static bool LoadGammas(SkGammaCurve* gammas, uint32_t num, const uint8_t* sr c, size_t len); | 63 static bool LoadGammas(SkGammaCurve* gammas, uint32_t num, const uint8_t* sr c, size_t len); |
| 61 | 64 |
| 62 static bool LoadColorLUT(SkColorLookUpTable* colorLUT, uint32_t inputChannel s, | 65 static bool LoadColorLUT(SkColorLookUpTable* colorLUT, uint32_t inputChannel s, |
| 63 uint32_t outputChannels, const uint8_t* src, size_t len); | 66 uint32_t outputChannels, const uint8_t* src, size_t len); |
| 64 | 67 |
| 65 static bool LoadA2B0(SkColorLookUpTable* colorLUT, SkGammaCurve*, SkMatrix44 * toXYZ, | 68 static bool LoadA2B0(SkColorLookUpTable* colorLUT, SkGammaCurve*, SkMatrix44 * toXYZ, |
| 66 const uint8_t* src, size_t len); | 69 const uint8_t* src, size_t len); |
| 67 | 70 |
| 68 SkColorSpace(sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, Named); | 71 SkColorSpace(sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, Named); |
| 69 | 72 |
| 70 SkColorSpace(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas, const SkM atrix44& toXYZ); | 73 SkColorSpace(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas, const SkM atrix44& toXYZ); |
| 71 | 74 |
| 72 SkAutoTDelete<SkColorLookUpTable> fColorLUT; | 75 SkAutoTDelete<SkColorLookUpTable> fColorLUT; |
| 73 sk_sp<SkGammas> fGammas; | 76 sk_sp<SkGammas> fGammas; |
| 74 const SkMatrix44 fToXYZD50; | 77 const SkMatrix44 fToXYZD50; |
| 75 | |
| 76 const uint32_t fUniqueID; | |
| 77 const Named fNamed; | 78 const Named fNamed; |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 #endif | 81 #endif |
| OLD | NEW |