Chromium Code Reviews| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 }; | 112 }; | 
| 113 | 113 | 
| 114 /** | 114 /** | 
| 115 * Returns true if the shader is guaranteed to produce only opaque | 115 * Returns true if the shader is guaranteed to produce only opaque | 
| 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 struct ContextRec { | |
| 
 
scroggo
2014/05/01 18:49:38
Could you add some comments?
 
reed1
2014/05/01 18:57:41
Done.
 
 | |
| 123 ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL) {} | |
| 124 ContextRec(const ContextRec& other) | |
| 125 : fDevice(other.fDevice), fPaint(other.fPaint), fMatrix(other.fMatri x) {} | |
| 126 ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) | |
| 127 : fDevice(&device) | |
| 128 , fPaint(&paint) | |
| 129 , fMatrix(&matrix) {} | |
| 130 | |
| 131 const SkBitmap* fDevice; | |
| 132 const SkPaint* fPaint; | |
| 133 const SkMatrix* fMatrix; | |
| 134 }; | |
| 135 | |
| 122 class Context : public ::SkNoncopyable { | 136 class Context : public ::SkNoncopyable { | 
| 123 public: | 137 public: | 
| 124 Context(const SkShader& shader, const SkBitmap& device, | 138 Context(const SkShader& shader, const ContextRec&); | 
| 125 const SkPaint& paint, const SkMatrix& matrix); | |
| 126 | 139 | 
| 127 virtual ~Context(); | 140 virtual ~Context(); | 
| 128 | 141 | 
| 129 /** | 142 /** | 
| 130 * Called sometimes before drawing with this shader. Return the type of | 143 * Called sometimes before drawing with this shader. Return the type of | 
| 131 * alpha your shader will return. The default implementation returns 0. | 144 * alpha your shader will return. The default implementation returns 0. | 
| 132 * Your subclass should override if it can (even sometimes) report a | 145 * Your subclass should override if it can (even sometimes) report a | 
| 133 * non-zero value, since that will enable various blitters to perform | 146 * non-zero value, since that will enable various blitters to perform | 
| 134 * faster. | 147 * faster. | 
| 135 */ | 148 */ | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 uint8_t fPaintAlpha; | 206 uint8_t fPaintAlpha; | 
| 194 uint8_t fTotalInverseClass; | 207 uint8_t fTotalInverseClass; | 
| 195 | 208 | 
| 196 typedef SkNoncopyable INHERITED; | 209 typedef SkNoncopyable INHERITED; | 
| 197 }; | 210 }; | 
| 198 | 211 | 
| 199 /** | 212 /** | 
| 200 * Subclasses should be sure to call their INHERITED::validContext() if | 213 * Subclasses should be sure to call their INHERITED::validContext() if | 
| 201 * they override this method. | 214 * they override this method. | 
| 202 */ | 215 */ | 
| 203 virtual bool validContext(const SkBitmap& device, const SkPaint& paint, | 216 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const; | 
| 204 const SkMatrix& matrix, SkMatrix* totalInverse = N ULL) const; | |
| 205 | 217 | 
| 206 /** | 218 /** | 
| 207 * Create the actual object that does the shading. | 219 * Create the actual object that does the shading. | 
| 208 * Returns NULL if validContext() returns false. | 220 * Returns NULL if validContext() returns false. | 
| 209 * Size of storage must be >= contextSize. | 221 * Size of storage must be >= contextSize. | 
| 210 * Your subclass must also override contextSize() if it overrides createCon text(). | 222 * Your subclass must also override contextSize() if it overrides createCon text(). | 
| 211 * | 223 * | 
| 212 * Base class implementation returns NULL. | 224 * Base class implementation returns NULL. | 
| 213 */ | 225 */ | 
| 214 virtual Context* createContext(const SkBitmap& device, | 226 virtual Context* createContext(const ContextRec&, void* storage) const; | 
| 215 const SkPaint& paint, | |
| 216 const SkMatrix& matrix, | |
| 217 void* storage) const; | |
| 218 | 227 | 
| 219 /** | 228 /** | 
| 220 * Return the size of a Context returned by createContext. | 229 * Return the size of a Context returned by createContext. | 
| 221 * | 230 * | 
| 222 * Override this if your subclass overrides createContext, to return the co rrect size of | 231 * Override this if your subclass overrides createContext, to return the co rrect size of | 
| 223 * your subclass' context. | 232 * your subclass' context. | 
| 224 */ | 233 */ | 
| 225 virtual size_t contextSize() const; | 234 virtual size_t contextSize() const; | 
| 226 | 235 | 
| 227 /** | 236 /** | 
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 | 411 | 
| 403 private: | 412 private: | 
| 404 SkMatrix fLocalMatrix; | 413 SkMatrix fLocalMatrix; | 
| 405 | 414 | 
| 406 bool computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) con st; | 415 bool computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) con st; | 
| 407 | 416 | 
| 408 typedef SkFlattenable INHERITED; | 417 typedef SkFlattenable INHERITED; | 
| 409 }; | 418 }; | 
| 410 | 419 | 
| 411 #endif | 420 #endif | 
| OLD | NEW |