| 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_Base_DEFINED | 8 #ifndef SkColorSpace_Base_DEFINED |
| 9 #define SkColorSpace_Base_DEFINED | 9 #define SkColorSpace_Base_DEFINED |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Contains information for a gamma table. | 35 // Contains information for a gamma table. |
| 36 struct Table { | 36 struct Table { |
| 37 size_t fOffset; | 37 size_t fOffset; |
| 38 int fSize; | 38 int fSize; |
| 39 | 39 |
| 40 const float* table(const SkGammas* base) const { | 40 const float* table(const SkGammas* base) const { |
| 41 return SkTAddOffset<const float>(base, sizeof(SkGammas) + fOffset); | 41 return SkTAddOffset<const float>(base, sizeof(SkGammas) + fOffset); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // Contains the parameters for a parametric curve. | |
| 46 struct Params { | |
| 47 // Y = (aX + b)^g + c for X >= d | |
| 48 // Y = eX + f otherwise | |
| 49 float fG; | |
| 50 float fA; | |
| 51 float fB; | |
| 52 float fC; | |
| 53 float fD; | |
| 54 float fE; | |
| 55 float fF; | |
| 56 }; | |
| 57 | |
| 58 // Contains the actual gamma curve information. Should be interpreted | 45 // Contains the actual gamma curve information. Should be interpreted |
| 59 // based on the type of the gamma curve. | 46 // based on the type of the gamma curve. |
| 60 union Data { | 47 union Data { |
| 61 Data() | 48 Data() |
| 62 : fTable{ 0, 0 } | 49 : fTable{ 0, 0 } |
| 63 {} | 50 {} |
| 64 | 51 |
| 65 inline bool operator==(const Data& that) const { | 52 inline bool operator==(const Data& that) const { |
| 66 return this->fTable.fOffset == that.fTable.fOffset && | 53 return this->fTable.fOffset == that.fTable.fOffset && |
| 67 this->fTable.fSize == that.fTable.fSize; | 54 this->fTable.fSize == that.fTable.fSize; |
| 68 } | 55 } |
| 69 | 56 |
| 70 SkGammaNamed fNamed; | 57 SkGammaNamed fNamed; |
| 71 float fValue; | 58 float fValue; |
| 72 Table fTable; | 59 Table fTable; |
| 73 size_t fParamOffset; | 60 size_t fParamOffset; |
| 74 | 61 |
| 75 const Params& params(const SkGammas* base) const { | 62 const SkColorSpaceTransferFn& params(const SkGammas* base) const { |
| 76 return *SkTAddOffset<const Params>(base, sizeof(SkGammas) + fParamOf
fset); | 63 return *SkTAddOffset<const SkColorSpaceTransferFn>( |
| 64 base, sizeof(SkGammas) + fParamOffset); |
| 77 } | 65 } |
| 78 }; | 66 }; |
| 79 | 67 |
| 80 bool isNamed(int i) const { | 68 bool isNamed(int i) const { |
| 81 return Type::kNamed_Type == this->type(i); | 69 return Type::kNamed_Type == this->type(i); |
| 82 } | 70 } |
| 83 | 71 |
| 84 bool isValue(int i) const { | 72 bool isValue(int i) const { |
| 85 return Type::kValue_Type == this->type(i); | 73 return Type::kValue_Type == this->type(i); |
| 86 } | 74 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 105 SkASSERT(false); | 93 SkASSERT(false); |
| 106 return fRedData; | 94 return fRedData; |
| 107 } | 95 } |
| 108 } | 96 } |
| 109 | 97 |
| 110 const float* table(int i) const { | 98 const float* table(int i) const { |
| 111 SkASSERT(isTable(i)); | 99 SkASSERT(isTable(i)); |
| 112 return this->data(i).fTable.table(this); | 100 return this->data(i).fTable.table(this); |
| 113 } | 101 } |
| 114 | 102 |
| 115 const Params& params(int i) const { | 103 const SkColorSpaceTransferFn& params(int i) const { |
| 116 SkASSERT(isParametric(i)); | 104 SkASSERT(isParametric(i)); |
| 117 return this->data(i).params(this); | 105 return this->data(i).params(this); |
| 118 } | 106 } |
| 119 | 107 |
| 120 Type type(int i) const { | 108 Type type(int i) const { |
| 121 switch (i) { | 109 switch (i) { |
| 122 case 0: | 110 case 0: |
| 123 return fRedType; | 111 return fRedType; |
| 124 case 1: | 112 case 1: |
| 125 return fGreenType; | 113 return fGreenType; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 219 |
| 232 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) { | 220 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) { |
| 233 return static_cast<const SkColorSpace_Base*>(colorSpace); | 221 return static_cast<const SkColorSpace_Base*>(colorSpace); |
| 234 } | 222 } |
| 235 | 223 |
| 236 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) { | 224 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) { |
| 237 return static_cast<SkColorSpace_Base*>(colorSpace.get()); | 225 return static_cast<SkColorSpace_Base*>(colorSpace.get()); |
| 238 } | 226 } |
| 239 | 227 |
| 240 #endif | 228 #endif |
| OLD | NEW |