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 #ifndef SkShader_DEFINED | 8 #ifndef SkShader_DEFINED |
9 #define SkShader_DEFINED | 9 #define SkShader_DEFINED |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 */ | 216 */ |
217 virtual size_t contextSize() const; | 217 virtual size_t contextSize() const; |
218 | 218 |
219 /** | 219 /** |
220 * Helper to check the flags to know if it is legal to call shadeSpan16() | 220 * Helper to check the flags to know if it is legal to call shadeSpan16() |
221 */ | 221 */ |
222 static bool CanCallShadeSpan16(uint32_t flags) { | 222 static bool CanCallShadeSpan16(uint32_t flags) { |
223 return (flags & kHasSpan16_Flag) != 0; | 223 return (flags & kHasSpan16_Flag) != 0; |
224 } | 224 } |
225 | 225 |
226 #ifdef SK_SUPPORT_LEGACY_SHADERBITMAPTYPE | |
227 public: | |
228 #else | |
229 protected: | |
230 #endif | |
231 /** | 226 /** |
232 Gives method bitmap should be read to implement a shader. | 227 * Returns true if this shader is just a bitmap, and if not null, returns t
he bitmap, |
233 Also determines number and interpretation of "extra" parameters returned | 228 * localMatrix, and tilemodes. If this is not a bitmap, returns false and i
gnores the |
234 by asABitmap | 229 * out-parameters. |
235 */ | 230 */ |
236 enum BitmapType { | 231 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co
nst { |
237 kNone_BitmapType, //<! Shader is not represented as a bitmap | 232 return this->onIsABitmap(outTexture, outMatrix, xy); |
238 kDefault_BitmapType,//<! Access bitmap using local coords transformed | 233 } |
239 }; | |
240 /** Optional methods for shaders that can pretend to be a bitmap/texture | |
241 to play along with opengl. Default just returns kNone_BitmapType and | |
242 ignores the out parameters. | |
243 | 234 |
244 @param outTexture if non-NULL will be the bitmap representing the shader | |
245 after return. | |
246 @param outMatrix if non-NULL will be the matrix to apply to vertices | |
247 to access the bitmap after return. | |
248 @param xy if non-NULL will be the tile modes that should be | |
249 used to access the bitmap after return. | |
250 @param twoPointRadialParams Two extra return values needed for two point | |
251 radial bitmaps. The first is the x-offset of | |
252 the second point and the second is the radiu
s | |
253 about the first point. | |
254 */ | |
255 virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, | |
256 TileMode xy[2]) const; | |
257 | |
258 public: | |
259 bool isABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode xy[2]) const { | |
260 return this->asABitmap(bitmap, matrix, xy) == kDefault_BitmapType; | |
261 } | |
262 bool isABitmap() const { | 235 bool isABitmap() const { |
263 return this->isABitmap(nullptr, nullptr, nullptr); | 236 return this->isABitmap(nullptr, nullptr, nullptr); |
264 } | 237 } |
265 | 238 |
266 /** | 239 /** |
267 * If the shader subclass can be represented as a gradient, asAGradient | 240 * If the shader subclass can be represented as a gradient, asAGradient |
268 * returns the matching GradientType enum (or kNone_GradientType if it | 241 * returns the matching GradientType enum (or kNone_GradientType if it |
269 * cannot). Also, if info is not null, asAGradient populates info with | 242 * cannot). Also, if info is not null, asAGradient populates info with |
270 * the relevant (see below) parameters for the gradient. fColorCount | 243 * the relevant (see below) parameters for the gradient. fColorCount |
271 * is both an input and output parameter. On input, it indicates how | 244 * is both an input and output parameter. On input, it indicates how |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 420 |
448 /** | 421 /** |
449 * Your subclass must also override contextSize() if it overrides onCreateC
ontext(). | 422 * Your subclass must also override contextSize() if it overrides onCreateC
ontext(). |
450 * Base class impl returns NULL. | 423 * Base class impl returns NULL. |
451 */ | 424 */ |
452 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 425 virtual Context* onCreateContext(const ContextRec&, void* storage) const; |
453 | 426 |
454 virtual bool onAsLuminanceColor(SkColor*) const { | 427 virtual bool onAsLuminanceColor(SkColor*) const { |
455 return false; | 428 return false; |
456 } | 429 } |
| 430 |
| 431 virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const { |
| 432 return false; |
| 433 } |
| 434 |
457 private: | 435 private: |
458 // This is essentially const, but not officially so it can be modified in | 436 // This is essentially const, but not officially so it can be modified in |
459 // constructors. | 437 // constructors. |
460 SkMatrix fLocalMatrix; | 438 SkMatrix fLocalMatrix; |
461 | 439 |
462 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 440 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
463 friend class SkLocalMatrixShader; | 441 friend class SkLocalMatrixShader; |
464 | 442 |
465 typedef SkFlattenable INHERITED; | 443 typedef SkFlattenable INHERITED; |
466 }; | 444 }; |
467 | 445 |
468 #endif | 446 #endif |
OLD | NEW |