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 |
399 | 409 |
400 /** | 410 /** |
401 * Call this to create a new "empty" shader, that will not draw anything. | 411 * Call this to create a new "empty" shader, that will not draw anything. |
402 */ | 412 */ |
403 static SkShader* CreateEmptyShader(); | 413 static SkShader* CreateEmptyShader(); |
404 | 414 |
| 415 /** |
| 416 * Call this to create a new shader that just draws the specified color. Th
is should always |
| 417 * draw the same as a paint with this color (and no shader). |
| 418 */ |
| 419 static SkShader* CreateColorShader(SkColor); |
| 420 |
405 /** Call this to create a new shader that will draw with the specified bitma
p. | 421 /** Call this to create a new shader that will draw with the specified bitma
p. |
406 * | 422 * |
407 * If the bitmap cannot be used (e.g. has no pixels, or its dimensions | 423 * If the bitmap cannot be used (e.g. has no pixels, or its dimensions |
408 * exceed implementation limits (currently at 64K - 1)) then SkEmptyShader | 424 * exceed implementation limits (currently at 64K - 1)) then SkEmptyShader |
409 * may be returned. | 425 * may be returned. |
410 * | 426 * |
411 * If the src is kA8_Config then that mask will be colorized using the colo
r on | 427 * If the src is kA8_Config then that mask will be colorized using the colo
r on |
412 * the paint. | 428 * the paint. |
413 * | 429 * |
414 * @param src The bitmap to use inside the shader | 430 * @param src The bitmap to use inside the shader |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 483 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
468 | 484 |
469 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; | 485 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; |
470 | 486 |
471 /** | 487 /** |
472 * Your subclass must also override contextSize() if it overrides onCreateC
ontext(). | 488 * Your subclass must also override contextSize() if it overrides onCreateC
ontext(). |
473 * Base class impl returns NULL. | 489 * Base class impl returns NULL. |
474 */ | 490 */ |
475 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 491 virtual Context* onCreateContext(const ContextRec&, void* storage) const; |
476 | 492 |
| 493 virtual bool onAsLuminanceColor(SkColor*) const { |
| 494 return false; |
| 495 } |
477 private: | 496 private: |
478 // This is essentially const, but not officially so it can be modified in | 497 // This is essentially const, but not officially so it can be modified in |
479 // constructors. | 498 // constructors. |
480 SkMatrix fLocalMatrix; | 499 SkMatrix fLocalMatrix; |
481 | 500 |
482 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 501 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
483 friend class SkLocalMatrixShader; | 502 friend class SkLocalMatrixShader; |
484 | 503 |
485 typedef SkFlattenable INHERITED; | 504 typedef SkFlattenable INHERITED; |
486 }; | 505 }; |
487 | 506 |
488 #endif | 507 #endif |
OLD | NEW |