| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkMaskGamma_DEFINED | 8 #ifndef SkMaskGamma_DEFINED |
| 9 #define SkMaskGamma_DEFINED | 9 #define SkMaskGamma_DEFINED |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 typedef SkRefCnt INHERITED; | 162 typedef SkRefCnt INHERITED; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 | 165 |
| 166 /** | 166 /** |
| 167 * SkTMaskPreBlend is a tear-off of SkTMaskGamma. It provides the tables to | 167 * SkTMaskPreBlend is a tear-off of SkTMaskGamma. It provides the tables to |
| 168 * convert a linear alpha value for a given channel to a gamma correcting alpha | 168 * convert a linear alpha value for a given channel to a gamma correcting alpha |
| 169 * value for that channel. This class is immutable. | 169 * value for that channel. This class is immutable. |
| 170 * | 170 * |
| 171 * If fR, fG, or fB is NULL, all of them will be. This indicates that no mask | 171 * If fR, fG, or fB is nullptr, all of them will be. This indicates that no mask |
| 172 * pre blend should be applied. SkTMaskPreBlend::isApplicable() is provided as | 172 * pre blend should be applied. SkTMaskPreBlend::isApplicable() is provided as |
| 173 * a convenience function to test for the absence of this case. | 173 * a convenience function to test for the absence of this case. |
| 174 */ | 174 */ |
| 175 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskPreBlend
{ | 175 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskPreBlend
{ |
| 176 private: | 176 private: |
| 177 SkTMaskPreBlend(const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>* pare
nt, | 177 SkTMaskPreBlend(const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>* pare
nt, |
| 178 const uint8_t* r, const uint8_t* g, const uint8_t* b) | 178 const uint8_t* r, const uint8_t* g, const uint8_t* b) |
| 179 : fParent(SkSafeRef(parent)), fR(r), fG(g), fB(b) { } | 179 : fParent(SkSafeRef(parent)), fR(r), fG(g), fB(b) { } |
| 180 | 180 |
| 181 SkAutoTUnref<const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> > fParen
t; | 181 SkAutoTUnref<const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> > fParen
t; |
| 182 friend class SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>; | 182 friend class SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>; |
| 183 public: | 183 public: |
| 184 /** Creates a non applicable SkTMaskPreBlend. */ | 184 /** Creates a non applicable SkTMaskPreBlend. */ |
| 185 SkTMaskPreBlend() : fParent(), fR(NULL), fG(NULL), fB(NULL) { } | 185 SkTMaskPreBlend() : fParent(), fR(nullptr), fG(nullptr), fB(nullptr) { } |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * This copy contructor exists for correctness, but should never be called | 188 * This copy contructor exists for correctness, but should never be called |
| 189 * when return value optimization is enabled. | 189 * when return value optimization is enabled. |
| 190 */ | 190 */ |
| 191 SkTMaskPreBlend(const SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>& t
hat) | 191 SkTMaskPreBlend(const SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>& t
hat) |
| 192 : fParent(SkSafeRef(that.fParent.get())), fR(that.fR), fG(that.fG), fB(that.
fB) { } | 192 : fParent(SkSafeRef(that.fParent.get())), fR(that.fR), fG(that.fG), fB(that.
fB) { } |
| 193 | 193 |
| 194 ~SkTMaskPreBlend() { } | 194 ~SkTMaskPreBlend() { } |
| 195 | 195 |
| 196 /** True if this PreBlend should be applied. When false, fR, fG, and fB are
NULL. */ | 196 /** True if this PreBlend should be applied. When false, fR, fG, and fB are
nullptr. */ |
| 197 bool isApplicable() const { return SkToBool(this->fG); } | 197 bool isApplicable() const { return SkToBool(this->fG); } |
| 198 | 198 |
| 199 const uint8_t* fR; | 199 const uint8_t* fR; |
| 200 const uint8_t* fG; | 200 const uint8_t* fG; |
| 201 const uint8_t* fB; | 201 const uint8_t* fB; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> | 204 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> |
| 205 SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> | 205 SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> |
| 206 SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>::preBlend(SkColor color) const
{ | 206 SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>::preBlend(SkColor color) const
{ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 221 */ | 221 */ |
| 222 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { | 222 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { |
| 223 return component; | 223 return component; |
| 224 } | 224 } |
| 225 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { | 225 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { |
| 226 return lut[component]; | 226 return lut[component]; |
| 227 } | 227 } |
| 228 ///@} | 228 ///@} |
| 229 | 229 |
| 230 #endif | 230 #endif |
| OLD | NEW |