Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: src/effects/gradients/SkGradientShaderPriv.h

Issue 2370063002: Gradients are serialized (and can be constructed) as SkColor4f + SkColorSpace (Closed)
Patch Set: Widen storage for flags. Shift used bits to be contiguous. Document layout. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 class SkGradientShaderBase : public SkShader { 78 class SkGradientShaderBase : public SkShader {
79 public: 79 public:
80 struct Descriptor { 80 struct Descriptor {
81 Descriptor() { 81 Descriptor() {
82 sk_bzero(this, sizeof(*this)); 82 sk_bzero(this, sizeof(*this));
83 fTileMode = SkShader::kClamp_TileMode; 83 fTileMode = SkShader::kClamp_TileMode;
84 } 84 }
85 85
86 const SkMatrix* fLocalMatrix; 86 const SkMatrix* fLocalMatrix;
87 const SkColor* fColors; 87 const SkColor4f* fColors;
88 const SkColor4f* fColors4f;
89 sk_sp<SkColorSpace> fColorSpace; 88 sk_sp<SkColorSpace> fColorSpace;
90 const SkScalar* fPos; 89 const SkScalar* fPos;
91 int fCount; 90 int fCount;
92 SkShader::TileMode fTileMode; 91 SkShader::TileMode fTileMode;
93 uint32_t fGradFlags; 92 uint32_t fGradFlags;
94 93
95 void flatten(SkWriteBuffer&) const; 94 void flatten(SkWriteBuffer&) const;
96 }; 95 };
97 96
98 class DescriptorScope : public Descriptor { 97 class DescriptorScope : public Descriptor {
99 public: 98 public:
100 DescriptorScope() {} 99 DescriptorScope() {}
101 100
102 bool unflatten(SkReadBuffer&); 101 bool unflatten(SkReadBuffer&);
103 102
104 // fColors and fPos always point into local memory, so they can be safel y mutated 103 // fColors and fPos always point into local memory, so they can be safel y mutated
105 // 104 //
106 SkColor* mutableColors() { return const_cast<SkColor*>(fColors); } 105 SkColor4f* mutableColors() { return const_cast<SkColor4f*>(fColors); }
107 SkScalar* mutablePos() { return const_cast<SkScalar*>(fPos); } 106 SkScalar* mutablePos() { return const_cast<SkScalar*>(fPos); }
108 107
109 private: 108 private:
110 enum { 109 enum {
111 kStorageCount = 16 110 kStorageCount = 16
112 }; 111 };
113 SkColor fColorStorage[kStorageCount]; 112 SkColor4f fColorStorage[kStorageCount];
114 SkScalar fPosStorage[kStorageCount]; 113 SkScalar fPosStorage[kStorageCount];
115 SkMatrix fLocalMatrixStorage; 114 SkMatrix fLocalMatrixStorage;
116 SkAutoMalloc fDynamicStorage; 115 SkAutoMalloc fDynamicStorage;
117 }; 116 };
118 117
119 public: 118 public:
120 SkGradientShaderBase(const Descriptor& desc, const SkMatrix& ptsToUnit); 119 SkGradientShaderBase(const Descriptor& desc, const SkMatrix& ptsToUnit);
121 virtual ~SkGradientShaderBase(); 120 virtual ~SkGradientShaderBase();
122 121
123 // The cache is initialized on-demand when getCache32 is called. 122 // The cache is initialized on-demand when getCache32 is called.
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 GrGLSLProgramDataManager::UniformHandle fColorsUni; 499 GrGLSLProgramDataManager::UniformHandle fColorsUni;
501 GrGLSLProgramDataManager::UniformHandle fFSYUni; 500 GrGLSLProgramDataManager::UniformHandle fFSYUni;
502 GrGLSLProgramDataManager::UniformHandle fColorSpaceXformUni; 501 GrGLSLProgramDataManager::UniformHandle fColorSpaceXformUni;
503 502
504 typedef GrGLSLFragmentProcessor INHERITED; 503 typedef GrGLSLFragmentProcessor INHERITED;
505 }; 504 };
506 505
507 #endif 506 #endif
508 507
509 #endif 508 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698