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