| 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 SkGradientShaderPriv_DEFINED | 8 #ifndef SkGradientShaderPriv_DEFINED |
| 9 #define SkGradientShaderPriv_DEFINED | 9 #define SkGradientShaderPriv_DEFINED |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 sk_bzero(this, sizeof(*this)); | 88 sk_bzero(this, sizeof(*this)); |
| 89 fTileMode = SkShader::kClamp_TileMode; | 89 fTileMode = SkShader::kClamp_TileMode; |
| 90 } | 90 } |
| 91 | 91 |
| 92 const SkMatrix* fLocalMatrix; | 92 const SkMatrix* fLocalMatrix; |
| 93 const SkColor* fColors; | 93 const SkColor* fColors; |
| 94 const SkScalar* fPos; | 94 const SkScalar* fPos; |
| 95 int fCount; | 95 int fCount; |
| 96 SkShader::TileMode fTileMode; | 96 SkShader::TileMode fTileMode; |
| 97 uint32_t fGradFlags; | 97 uint32_t fGradFlags; |
| 98 |
| 99 void flatten(SkWriteBuffer&) const; |
| 100 }; |
| 101 |
| 102 class DescriptorScope : public Descriptor { |
| 103 public: |
| 104 DescriptorScope() {} |
| 105 |
| 106 bool unflatten(SkReadBuffer&); |
| 107 |
| 108 // fColors and fPos always point into local memory, so they can be safel
y mutated |
| 109 // |
| 110 SkColor* mutableColors() { return const_cast<SkColor*>(fColors); } |
| 111 SkScalar* mutablePos() { return const_cast<SkScalar*>(fPos); } |
| 112 |
| 113 private: |
| 114 enum { |
| 115 kStorageCount = 16 |
| 116 }; |
| 117 SkColor fColorStorage[kStorageCount]; |
| 118 SkScalar fPosStorage[kStorageCount]; |
| 119 SkMatrix fLocalMatrixStorage; |
| 120 SkAutoMalloc fDynamicStorage; |
| 98 }; | 121 }; |
| 99 | 122 |
| 100 public: | 123 public: |
| 101 SkGradientShaderBase(const Descriptor& desc); | 124 SkGradientShaderBase(const Descriptor& desc); |
| 102 virtual ~SkGradientShaderBase(); | 125 virtual ~SkGradientShaderBase(); |
| 103 | 126 |
| 104 // The cache is initialized on-demand when getCache16/32 is called. | 127 // The cache is initialized on-demand when getCache16/32 is called. |
| 105 class GradientShaderCache : public SkRefCnt { | 128 class GradientShaderCache : public SkRefCnt { |
| 106 public: | 129 public: |
| 107 GradientShaderCache(U8CPU alpha, const SkGradientShaderBase& shader); | 130 GradientShaderCache(U8CPU alpha, const SkGradientShaderBase& shader); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 250 |
| 228 // V23_COMPATIBILITY_CODE | 251 // V23_COMPATIBILITY_CODE |
| 229 // Used for 2-pt conical gradients since we sort start/end cirlces by radius | 252 // Used for 2-pt conical gradients since we sort start/end cirlces by radius |
| 230 // Assumes space has already been allocated for fOrigColors | 253 // Assumes space has already been allocated for fOrigColors |
| 231 void flipGradientColors(); | 254 void flipGradientColors(); |
| 232 | 255 |
| 233 private: | 256 private: |
| 234 enum { | 257 enum { |
| 235 kColorStorageCount = 4, // more than this many colors, and we'll use sk_
malloc for the space | 258 kColorStorageCount = 4, // more than this many colors, and we'll use sk_
malloc for the space |
| 236 | 259 |
| 237 kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(Rec)) | 260 kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(SkScalar)
+ sizeof(Rec)) |
| 238 }; | 261 }; |
| 239 SkColor fStorage[(kStorageSize + 3) >> 2]; | 262 SkColor fStorage[(kStorageSize + 3) >> 2]; |
| 240 SkColor* fOrigColors; // original colors, before modulation by paint in c
ontext. | 263 SkColor* fOrigColors; // original colors, before modulation by paint in c
ontext. |
| 264 SkScalar* fOrigPos; // original positions |
| 241 bool fColorsAreOpaque; | 265 bool fColorsAreOpaque; |
| 242 | 266 |
| 243 GradientShaderCache* refCache(U8CPU alpha) const; | 267 GradientShaderCache* refCache(U8CPU alpha) const; |
| 244 mutable SkMutex fCacheMutex; | 268 mutable SkMutex fCacheMutex; |
| 245 mutable SkAutoTUnref<GradientShaderCache> fCache; | 269 mutable SkAutoTUnref<GradientShaderCache> fCache; |
| 246 | 270 |
| 247 void initCommon(); | 271 void initCommon(); |
| 248 | 272 |
| 249 typedef SkShader INHERITED; | 273 typedef SkShader INHERITED; |
| 250 }; | 274 }; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 GrGLProgramDataManager::UniformHandle fColorStartUni; | 464 GrGLProgramDataManager::UniformHandle fColorStartUni; |
| 441 GrGLProgramDataManager::UniformHandle fColorMidUni; | 465 GrGLProgramDataManager::UniformHandle fColorMidUni; |
| 442 GrGLProgramDataManager::UniformHandle fColorEndUni; | 466 GrGLProgramDataManager::UniformHandle fColorEndUni; |
| 443 | 467 |
| 444 typedef GrGLEffect INHERITED; | 468 typedef GrGLEffect INHERITED; |
| 445 }; | 469 }; |
| 446 | 470 |
| 447 #endif | 471 #endif |
| 448 | 472 |
| 449 #endif | 473 #endif |
| OLD | NEW |