| 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 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
| 13 #include "SkMask.h" | 13 #include "SkMask.h" |
| 14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "../gpu/GrColor.h" | 16 #include "../gpu/GrColor.h" |
| 17 | 17 |
| 18 class SkPath; | 18 class SkPath; |
| 19 class SkPicture; | 19 class SkPicture; |
| 20 class SkXfermode; | 20 class SkXfermode; |
| 21 class GrContext; | 21 class GrContext; |
| 22 class GrFragmentProcessor; | 22 class GrFragmentProcessor; |
| 23 class GrShaderDataManager; | 23 class GrProcessorDataManager; |
| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 * the paint's color as then many GPU shaders may be generated. | 358 * the paint's color as then many GPU shaders may be generated. |
| 359 * | 359 * |
| 360 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not | 360 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not |
| 361 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. | 361 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. |
| 362 * | 362 * |
| 363 * A view matrix is always required to create the correct GrFragmentProcess
or. Some shaders | 363 * A view matrix is always required to create the correct GrFragmentProcess
or. Some shaders |
| 364 * may also use the optional localMatrix to define a matrix relevant only f
or sampling. | 364 * may also use the optional localMatrix to define a matrix relevant only f
or sampling. |
| 365 */ | 365 */ |
| 366 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&
viewM, | 366 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&
viewM, |
| 367 const SkMatrix* localMatrix, GrColor*, | 367 const SkMatrix* localMatrix, GrColor*, |
| 368 GrShaderDataManager*, GrFragmentProcessor**
) const; | 368 GrProcessorDataManager*, GrFragmentProcesso
r**) const; |
| 369 | 369 |
| 370 /** | 370 /** |
| 371 * If the shader can represent its "average" luminance in a single color, r
eturn true and | 371 * If the shader can represent its "average" luminance in a single color, r
eturn true and |
| 372 * if color is not NULL, return that color. If it cannot, return false and
ignore the color | 372 * if color is not NULL, return that color. If it cannot, return false and
ignore the color |
| 373 * parameter. | 373 * parameter. |
| 374 * | 374 * |
| 375 * Note: if this returns true, the returned color will always be opaque, as
only the RGB | 375 * Note: if this returns true, the returned color will always be opaque, as
only the RGB |
| 376 * components are used to compute luminance. | 376 * components are used to compute luminance. |
| 377 */ | 377 */ |
| 378 bool asLuminanceColor(SkColor*) const; | 378 bool asLuminanceColor(SkColor*) const; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // constructors. | 475 // constructors. |
| 476 SkMatrix fLocalMatrix; | 476 SkMatrix fLocalMatrix; |
| 477 | 477 |
| 478 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 478 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
| 479 friend class SkLocalMatrixShader; | 479 friend class SkLocalMatrixShader; |
| 480 | 480 |
| 481 typedef SkFlattenable INHERITED; | 481 typedef SkFlattenable INHERITED; |
| 482 }; | 482 }; |
| 483 | 483 |
| 484 #endif | 484 #endif |
| OLD | NEW |