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 |
11 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
12 #include "SkClampRange.h" | 12 #include "SkClampRange.h" |
13 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
14 #include "SkReadBuffer.h" | 14 #include "SkReadBuffer.h" |
15 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
16 #include "SkMallocPixelRef.h" | 16 #include "SkMallocPixelRef.h" |
| 17 #include "SkUnitMapper.h" |
17 #include "SkUtils.h" | 18 #include "SkUtils.h" |
18 #include "SkTemplates.h" | 19 #include "SkTemplates.h" |
19 #include "SkBitmapCache.h" | 20 #include "SkBitmapCache.h" |
20 #include "SkShader.h" | 21 #include "SkShader.h" |
21 #include "SkOnce.h" | 22 #include "SkOnce.h" |
22 | 23 |
23 static inline void sk_memset32_dither(uint32_t dst[], uint32_t v0, uint32_t v1, | 24 static inline void sk_memset32_dither(uint32_t dst[], uint32_t v0, uint32_t v1, |
24 int count) { | 25 int count) { |
25 if (count > 0) { | 26 if (count > 0) { |
26 if (v0 == v1) { | 27 if (v0 == v1) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 struct Descriptor { | 87 struct Descriptor { |
87 Descriptor() { | 88 Descriptor() { |
88 sk_bzero(this, sizeof(*this)); | 89 sk_bzero(this, sizeof(*this)); |
89 fTileMode = SkShader::kClamp_TileMode; | 90 fTileMode = SkShader::kClamp_TileMode; |
90 } | 91 } |
91 | 92 |
92 const SkColor* fColors; | 93 const SkColor* fColors; |
93 const SkScalar* fPos; | 94 const SkScalar* fPos; |
94 int fCount; | 95 int fCount; |
95 SkShader::TileMode fTileMode; | 96 SkShader::TileMode fTileMode; |
| 97 SkUnitMapper* fMapper; |
96 uint32_t fGradFlags; | 98 uint32_t fGradFlags; |
97 }; | 99 }; |
98 | 100 |
99 public: | 101 public: |
100 SkGradientShaderBase(const Descriptor& desc, const SkMatrix* localMatrix); | 102 SkGradientShaderBase(const Descriptor& desc, const SkMatrix* localMatrix); |
101 virtual ~SkGradientShaderBase(); | 103 virtual ~SkGradientShaderBase(); |
102 | 104 |
103 // The cache is initialized on-demand when getCache16/32 is called. | 105 // The cache is initialized on-demand when getCache16/32 is called. |
104 class GradientShaderCache : public SkRefCnt { | 106 class GradientShaderCache : public SkRefCnt { |
105 public: | 107 public: |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // also be filled with the gradient colors | 194 // also be filled with the gradient colors |
193 GpuColorType getGpuColorType(SkColor colors[3]) const; | 195 GpuColorType getGpuColorType(SkColor colors[3]) const; |
194 | 196 |
195 uint32_t getGradFlags() const { return fGradFlags; } | 197 uint32_t getGradFlags() const { return fGradFlags; } |
196 | 198 |
197 protected: | 199 protected: |
198 SkGradientShaderBase(SkReadBuffer& ); | 200 SkGradientShaderBase(SkReadBuffer& ); |
199 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 201 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
200 SK_TO_STRING_OVERRIDE() | 202 SK_TO_STRING_OVERRIDE() |
201 | 203 |
| 204 SkUnitMapper* fMapper; |
202 SkMatrix fPtsToUnit; // set by subclass | 205 SkMatrix fPtsToUnit; // set by subclass |
203 TileMode fTileMode; | 206 TileMode fTileMode; |
204 TileProc fTileProc; | 207 TileProc fTileProc; |
205 int fColorCount; | 208 int fColorCount; |
206 uint8_t fGradFlags; | 209 uint8_t fGradFlags; |
207 | 210 |
208 struct Rec { | 211 struct Rec { |
209 SkFixed fPos; // 0...1 | 212 SkFixed fPos; // 0...1 |
210 uint32_t fScale; // (1 << 24) / range | 213 uint32_t fScale; // (1 << 24) / range |
211 }; | 214 }; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 GrGLUniformManager::UniformHandle fColorStartUni; | 440 GrGLUniformManager::UniformHandle fColorStartUni; |
438 GrGLUniformManager::UniformHandle fColorMidUni; | 441 GrGLUniformManager::UniformHandle fColorMidUni; |
439 GrGLUniformManager::UniformHandle fColorEndUni; | 442 GrGLUniformManager::UniformHandle fColorEndUni; |
440 | 443 |
441 typedef GrGLEffect INHERITED; | 444 typedef GrGLEffect INHERITED; |
442 }; | 445 }; |
443 | 446 |
444 #endif | 447 #endif |
445 | 448 |
446 #endif | 449 #endif |
OLD | NEW |