| 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 |
| 11 | 11 |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
| 14 #include "SkMask.h" | 14 #include "SkMask.h" |
| 15 #include "SkMatrix.h" | 15 #include "SkMatrix.h" |
| 16 #include "SkPaint.h" | 16 #include "SkPaint.h" |
| 17 #include "../gpu/GrColor.h" | 17 #include "../gpu/GrColor.h" |
| 18 | 18 |
| 19 class SkPath; | 19 class SkPath; |
| 20 class SkPicture; | 20 class SkPicture; |
| 21 class SkXfermode; | 21 class SkXfermode; |
| 22 class GrContext; | 22 class GrContext; |
| 23 class GrEffect; | 23 class GrFragmentProcessor; |
| 24 | 24 |
| 25 /** \class SkShader | 25 /** \class SkShader |
| 26 * | 26 * |
| 27 * Shaders specify the source color(s) for what is being drawn. If a paint | 27 * Shaders specify the source color(s) for what is being drawn. If a paint |
| 28 * has no shader, then the paint's color is used. If the paint has a | 28 * has no shader, then the paint's color is used. If the paint has a |
| 29 * shader, then the shader's color(s) are use instead, but they are | 29 * shader, then the shader's color(s) are use instead, but they are |
| 30 * modulated by the paint's alpha. This makes it easy to create a shader | 30 * modulated by the paint's alpha. This makes it easy to create a shader |
| 31 * once (e.g. bitmap tiling or gradient) and then change its transparency | 31 * once (e.g. bitmap tiling or gradient) and then change its transparency |
| 32 * w/o having to modify the original shader... only the paint's alpha needs | 32 * w/o having to modify the original shader... only the paint's alpha needs |
| 33 * to be modified. | 33 * to be modified. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 * the color the effect expects as its input color. If the SkShader wishes
to emit a solid | 378 * the color the effect expects as its input color. If the SkShader wishes
to emit a solid |
| 379 * color then it should set paintColor to that color and not create an effe
ct. Note that | 379 * color then it should set paintColor to that color and not create an effe
ct. Note that |
| 380 * GrColor is always premul. The common patterns are to convert paint's SkC
olor to GrColor or | 380 * GrColor is always premul. The common patterns are to convert paint's SkC
olor to GrColor or |
| 381 * to extract paint's alpha and replicate it to all channels in paintColor.
Upon failure | 381 * to extract paint's alpha and replicate it to all channels in paintColor.
Upon failure |
| 382 * paintColor should not be modified. It is not recommended to specialize t
he effect to | 382 * paintColor should not be modified. It is not recommended to specialize t
he effect to |
| 383 * the paint's color as then many GPU shaders may be generated. | 383 * the paint's color as then many GPU shaders may be generated. |
| 384 * | 384 * |
| 385 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not | 385 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not |
| 386 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. | 386 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. |
| 387 */ | 387 */ |
| 388 virtual bool asNewEffect(GrContext* context, const SkPaint& paint, | 388 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*
, GrColor*, |
| 389 const SkMatrix* localMatrixOrNull, GrColor* paintCo
lor, | 389 GrFragmentProcessor**) const; |
| 390 GrEffect** effect) const; | |
| 391 | 390 |
| 392 /** | 391 /** |
| 393 * If the shader can represent its "average" luminance in a single color, r
eturn true and | 392 * If the shader can represent its "average" luminance in a single color, r
eturn true and |
| 394 * if color is not NULL, return that color. If it cannot, return false and
ignore the color | 393 * if color is not NULL, return that color. If it cannot, return false and
ignore the color |
| 395 * parameter. | 394 * parameter. |
| 396 * | 395 * |
| 397 * Note: if this returns true, the returned color will always be opaque, as
only the RGB | 396 * Note: if this returns true, the returned color will always be opaque, as
only the RGB |
| 398 * components are used to compute luminance. | 397 * components are used to compute luminance. |
| 399 */ | 398 */ |
| 400 bool asLuminanceColor(SkColor*) const; | 399 bool asLuminanceColor(SkColor*) const; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // constructors. | 500 // constructors. |
| 502 SkMatrix fLocalMatrix; | 501 SkMatrix fLocalMatrix; |
| 503 | 502 |
| 504 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 503 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
| 505 friend class SkLocalMatrixShader; | 504 friend class SkLocalMatrixShader; |
| 506 | 505 |
| 507 typedef SkFlattenable INHERITED; | 506 typedef SkFlattenable INHERITED; |
| 508 }; | 507 }; |
| 509 | 508 |
| 510 #endif | 509 #endif |
| OLD | NEW |