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

Side by Side Diff: include/core/SkShader.h

Issue 263293005: add local-matrix to shader::context (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add/fix comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkBitmapProcShader.h » ('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 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
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 draw
136 const SkMatrix* fMatrix; // the current matrix in the canvas 135 const SkMatrix* fMatrix; // the current matrix in the canvas
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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698