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 private: |
| 109 enum { |
| 110 kStorageCount = 16 |
| 111 }; |
| 112 SkColor fColorStorage[kStorageCount]; |
| 113 SkScalar fPosStorage[kStorageCount]; |
| 114 SkMatrix fLocalMatrixStorage; |
| 115 SkAutoMalloc fDynamicStorage; |
98 }; | 116 }; |
99 | 117 |
100 public: | 118 public: |
101 SkGradientShaderBase(const Descriptor& desc); | 119 SkGradientShaderBase(const Descriptor& desc); |
102 virtual ~SkGradientShaderBase(); | 120 virtual ~SkGradientShaderBase(); |
103 | 121 |
104 // The cache is initialized on-demand when getCache16/32 is called. | 122 // The cache is initialized on-demand when getCache16/32 is called. |
105 class GradientShaderCache : public SkRefCnt { | 123 class GradientShaderCache : public SkRefCnt { |
106 public: | 124 public: |
107 GradientShaderCache(U8CPU alpha, const SkGradientShaderBase& shader); | 125 GradientShaderCache(U8CPU alpha, const SkGradientShaderBase& shader); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 245 |
228 // V23_COMPATIBILITY_CODE | 246 // V23_COMPATIBILITY_CODE |
229 // Used for 2-pt conical gradients since we sort start/end cirlces by radius | 247 // Used for 2-pt conical gradients since we sort start/end cirlces by radius |
230 // Assumes space has already been allocated for fOrigColors | 248 // Assumes space has already been allocated for fOrigColors |
231 void flipGradientColors(); | 249 void flipGradientColors(); |
232 | 250 |
233 private: | 251 private: |
234 enum { | 252 enum { |
235 kColorStorageCount = 4, // more than this many colors, and we'll use sk_
malloc for the space | 253 kColorStorageCount = 4, // more than this many colors, and we'll use sk_
malloc for the space |
236 | 254 |
237 kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(Rec)) | 255 kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(SkScalar)
+ sizeof(Rec)) |
238 }; | 256 }; |
239 SkColor fStorage[(kStorageSize + 3) >> 2]; | 257 SkColor fStorage[(kStorageSize + 3) >> 2]; |
240 SkColor* fOrigColors; // original colors, before modulation by paint in c
ontext. | 258 SkColor* fOrigColors; // original colors, before modulation by paint in c
ontext. |
| 259 SkScalar* fOrigPos; // original positions |
241 bool fColorsAreOpaque; | 260 bool fColorsAreOpaque; |
242 | 261 |
243 GradientShaderCache* refCache(U8CPU alpha) const; | 262 GradientShaderCache* refCache(U8CPU alpha) const; |
244 mutable SkMutex fCacheMutex; | 263 mutable SkMutex fCacheMutex; |
245 mutable SkAutoTUnref<GradientShaderCache> fCache; | 264 mutable SkAutoTUnref<GradientShaderCache> fCache; |
246 | 265 |
247 void initCommon(); | 266 void initCommon(); |
248 | 267 |
249 typedef SkShader INHERITED; | 268 typedef SkShader INHERITED; |
250 }; | 269 }; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 GrGLProgramDataManager::UniformHandle fColorStartUni; | 459 GrGLProgramDataManager::UniformHandle fColorStartUni; |
441 GrGLProgramDataManager::UniformHandle fColorMidUni; | 460 GrGLProgramDataManager::UniformHandle fColorMidUni; |
442 GrGLProgramDataManager::UniformHandle fColorEndUni; | 461 GrGLProgramDataManager::UniformHandle fColorEndUni; |
443 | 462 |
444 typedef GrGLEffect INHERITED; | 463 typedef GrGLEffect INHERITED; |
445 }; | 464 }; |
446 | 465 |
447 #endif | 466 #endif |
448 | 467 |
449 #endif | 468 #endif |
OLD | NEW |