OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 | 8 |
9 #ifndef SkShader_DEFINED | 9 #ifndef SkShader_DEFINED |
10 #define SkShader_DEFINED | 10 #define SkShader_DEFINED |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 * colors, subject to the SkPaint using the shader to apply an opaque | 116 * colors, subject to the SkPaint using the shader to apply an opaque |
117 * alpha value. Subclasses should override this to allow some | 117 * alpha value. Subclasses should override this to allow some |
118 * optimizations. | 118 * optimizations. |
119 */ | 119 */ |
120 virtual bool isOpaque() const { return false; } | 120 virtual bool isOpaque() const { return false; } |
121 | 121 |
122 /** | 122 /** |
123 * ContextRec acts as a parameter bundle for creating Contexts. | 123 * ContextRec acts as a parameter bundle for creating Contexts. |
124 */ | 124 */ |
125 struct ContextRec { | 125 struct ContextRec { |
126 ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL) {} | 126 ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL), fLocalMatrix( NULL) {} |
127 ContextRec(const ContextRec& other) | |
128 : fDevice(other.fDevice), fPaint(other.fPaint), fMatrix(other.fMatri x) {} | |
129 ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) | 127 ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) |
130 : fDevice(&device) | 128 : fDevice(&device) |
131 , fPaint(&paint) | 129 , fPaint(&paint) |
132 , fMatrix(&matrix) {} | 130 , fMatrix(&matrix) |
131 , fLocalMatrix(NULL) {} | |
133 | 132 |
134 const SkBitmap* fDevice; // the bitmap we are drawing into | 133 const SkBitmap* fDevice; // the bitmap we are drawing into |
135 const SkPaint* fPaint; // the current paint associated with the dra w | 134 const SkPaint* fPaint; // the current paint associated with the dra w |
136 const SkMatrix* fMatrix; // the current matrix in the canvas | 135 const SkMatrix* fMatrix; // the current matrix in the canvas |
scroggo
2014/05/06 15:40:30
nit: spacing
reed1
2014/05/06 17:04:50
Done.
| |
136 const SkMatrix* fLocalMatrix; // optional local matrix | |
137 }; | 137 }; |
138 | 138 |
139 class Context : public ::SkNoncopyable { | 139 class Context : public ::SkNoncopyable { |
140 public: | 140 public: |
141 Context(const SkShader& shader, const ContextRec&); | 141 Context(const SkShader& shader, const ContextRec&); |
142 | 142 |
143 virtual ~Context(); | 143 virtual ~Context(); |
144 | 144 |
145 /** | 145 /** |
146 * Called sometimes before drawing with this shader. Return the type of | 146 * Called sometimes before drawing with this shader. Return the type of |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 const SkShader& fShader; | 193 const SkShader& fShader; |
194 | 194 |
195 enum MatrixClass { | 195 enum MatrixClass { |
196 kLinear_MatrixClass, // no perspective | 196 kLinear_MatrixClass, // no perspective |
197 kFixedStepInX_MatrixClass, // fast perspective, need to call fi xedStepInX() each | 197 kFixedStepInX_MatrixClass, // fast perspective, need to call fi xedStepInX() each |
198 // scanline | 198 // scanline |
199 kPerspective_MatrixClass // slow perspective, need to mappoin ts each pixel | 199 kPerspective_MatrixClass // slow perspective, need to mappoin ts each pixel |
200 }; | 200 }; |
201 static MatrixClass ComputeMatrixClass(const SkMatrix&); | 201 static MatrixClass ComputeMatrixClass(const SkMatrix&); |
202 | 202 |
203 uint8_t getPaintAlpha() const { return fPaintAlpha; } | 203 uint8_t getPaintAlpha() const { return fPaintAlpha; } |
204 const SkMatrix& getTotalInverse() const { return fTotalInverse; } | 204 const SkMatrix& getTotalInverse() const { return fTotalInverse; } |
205 MatrixClass getInverseClass() const { return (MatrixClass)fTotal InverseClass; } | 205 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; } |
206 | 206 const SkMatrix& getCTM() const { return fCTM; } |
207 private: | 207 private: |
208 SkMatrix fTotalInverse; | 208 SkMatrix fCTM; |
209 uint8_t fPaintAlpha; | 209 SkMatrix fTotalInverse; |
210 uint8_t fTotalInverseClass; | 210 uint8_t fPaintAlpha; |
211 uint8_t fTotalInverseClass; | |
211 | 212 |
212 typedef SkNoncopyable INHERITED; | 213 typedef SkNoncopyable INHERITED; |
213 }; | 214 }; |
214 | 215 |
215 /** | 216 /** |
216 * Create the actual object that does the shading. | 217 * Create the actual object that does the shading. |
217 * Size of storage must be >= contextSize. | 218 * Size of storage must be >= contextSize. |
218 */ | 219 */ |
219 Context* createContext(const ContextRec&, void* storage) const; | 220 Context* createContext(const ContextRec&, void* storage) const; |
220 | 221 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 */ | 416 */ |
416 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 417 virtual Context* onCreateContext(const ContextRec&, void* storage) const; |
417 | 418 |
418 private: | 419 private: |
419 SkMatrix fLocalMatrix; | 420 SkMatrix fLocalMatrix; |
420 | 421 |
421 typedef SkFlattenable INHERITED; | 422 typedef SkFlattenable INHERITED; |
422 }; | 423 }; |
423 | 424 |
424 #endif | 425 #endif |
OLD | NEW |