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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 * paintColor should not be modified. It is not recommended to specialize t
he effect to | 379 * paintColor should not be modified. It is not recommended to specialize t
he effect to |
380 * the paint's color as then many GPU shaders may be generated. | 380 * the paint's color as then many GPU shaders may be generated. |
381 * | 381 * |
382 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not | 382 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not |
383 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. | 383 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. |
384 */ | 384 */ |
385 virtual bool asNewEffect(GrContext* context, const SkPaint& paint, | 385 virtual bool asNewEffect(GrContext* context, const SkPaint& paint, |
386 const SkMatrix* localMatrixOrNull, GrColor* paintCo
lor, | 386 const SkMatrix* localMatrixOrNull, GrColor* paintCo
lor, |
387 GrEffect** effect) const; | 387 GrEffect** effect) const; |
388 | 388 |
| 389 /** |
| 390 * If the shader can represent its "average" luminance in a single color, r
eturn true and |
| 391 * if color is not NULL, return that color. If it cannot, return false and
ignore the color |
| 392 * parameter. |
| 393 * |
| 394 * Note: if this returns true, the returned color will always be opaque, as
only the RGB |
| 395 * components are used to compute luminance. |
| 396 */ |
| 397 bool asLuminanceColor(SkColor*) const; |
| 398 |
389 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 399 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
390 /** | 400 /** |
391 * If the shader is a custom shader which has data the caller might want, c
all this function | 401 * If the shader is a custom shader which has data the caller might want, c
all this function |
392 * to get that data. | 402 * to get that data. |
393 */ | 403 */ |
394 virtual bool asACustomShader(void** customData) const { return false; } | 404 virtual bool asACustomShader(void** customData) const { return false; } |
395 #endif | 405 #endif |
396 | 406 |
397 ////////////////////////////////////////////////////////////////////////// | 407 ////////////////////////////////////////////////////////////////////////// |
398 // Factory methods for stock shaders | 408 // Factory methods for stock shaders |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 475 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
466 | 476 |
467 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; | 477 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; |
468 | 478 |
469 /** | 479 /** |
470 * Your subclass must also override contextSize() if it overrides onCreateC
ontext(). | 480 * Your subclass must also override contextSize() if it overrides onCreateC
ontext(). |
471 * Base class impl returns NULL. | 481 * Base class impl returns NULL. |
472 */ | 482 */ |
473 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 483 virtual Context* onCreateContext(const ContextRec&, void* storage) const; |
474 | 484 |
| 485 virtual bool onAsLuminanceColor(SkColor*) const { |
| 486 return false; |
| 487 } |
475 private: | 488 private: |
476 // This is essentially const, but not officially so it can be modified in | 489 // This is essentially const, but not officially so it can be modified in |
477 // constructors. | 490 // constructors. |
478 SkMatrix fLocalMatrix; | 491 SkMatrix fLocalMatrix; |
479 | 492 |
480 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 493 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
481 friend class SkLocalMatrixShader; | 494 friend class SkLocalMatrixShader; |
482 | 495 |
483 typedef SkFlattenable INHERITED; | 496 typedef SkFlattenable INHERITED; |
484 }; | 497 }; |
485 | 498 |
486 #endif | 499 #endif |
OLD | NEW |