| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 struct ComposeRec { | 327 struct ComposeRec { |
| 328 const SkShader* fShaderA; | 328 const SkShader* fShaderA; |
| 329 const SkShader* fShaderB; | 329 const SkShader* fShaderB; |
| 330 const SkXfermode* fMode; | 330 const SkXfermode* fMode; |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 virtual bool asACompose(ComposeRec*) const { return false; } | 333 virtual bool asACompose(ComposeRec*) const { return false; } |
| 334 | 334 |
| 335 | 335 |
| 336 /** | 336 /** |
| 337 * Returns a GrFragmentProcessor that implements the shader for the GPU bac
kend. NULL is | 337 * Returns true if the shader subclass succeeds in creating an effect or if
none is required. |
| 338 * returned if there is no GPU implementation. | 338 * False is returned if it fails or if there is not an implementation of th
is method in the |
| 339 * shader subclass. |
| 339 * | 340 * |
| 340 * The GPU device does not call SkShader::createContext(), instead we pass
the view matrix, | 341 * On success an implementation of this method must inspect the SkPaint and
set paintColor to |
| 341 * local matrix, and filter quality directly. | 342 * the color the effect expects as its input color. If the SkShader wishes
to emit a solid |
| 343 * color then it should set paintColor to that color and not create an effe
ct. Note that |
| 344 * GrColor is always premul. The common patterns are to convert paint's SkC
olor to GrColor or |
| 345 * to extract paint's alpha and replicate it to all channels in paintColor.
Upon failure |
| 346 * paintColor should not be modified. It is not recommended to specialize t
he effect to |
| 347 * the paint's color as then many GPU shaders may be generated. |
| 342 * | 348 * |
| 343 * The GrContext may be used by the to create textures that are required by
the returned | 349 * The GrContext may be used by the effect to create textures. The GPU devi
ce does not |
| 344 * processor. | 350 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. |
| 351 * |
| 352 * A view matrix is always required to create the correct GrFragmentProcess
or. Some shaders |
| 353 * may also use the optional localMatrix to define a matrix relevant only f
or sampling. |
| 345 */ | 354 */ |
| 346 virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*, | 355 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&
viewM, |
| 347 const SkMatrix& viewM
atric, | 356 const SkMatrix* localMatrix, GrColor*, |
| 348 const SkMatrix* local
Matrix, | 357 GrProcessorDataManager*, GrFragmentProcesso
r**) const; |
| 349 SkFilterQuality, | |
| 350 GrProcessorDataManage
r*) const; | |
| 351 | 358 |
| 352 /** | 359 /** |
| 353 * If the shader can represent its "average" luminance in a single color, r
eturn true and | 360 * If the shader can represent its "average" luminance in a single color, r
eturn true and |
| 354 * if color is not NULL, return that color. If it cannot, return false and
ignore the color | 361 * if color is not NULL, return that color. If it cannot, return false and
ignore the color |
| 355 * parameter. | 362 * parameter. |
| 356 * | 363 * |
| 357 * Note: if this returns true, the returned color will always be opaque, as
only the RGB | 364 * Note: if this returns true, the returned color will always be opaque, as
only the RGB |
| 358 * components are used to compute luminance. | 365 * components are used to compute luminance. |
| 359 */ | 366 */ |
| 360 bool asLuminanceColor(SkColor*) const; | 367 bool asLuminanceColor(SkColor*) const; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // constructors. | 464 // constructors. |
| 458 SkMatrix fLocalMatrix; | 465 SkMatrix fLocalMatrix; |
| 459 | 466 |
| 460 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 467 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
| 461 friend class SkLocalMatrixShader; | 468 friend class SkLocalMatrixShader; |
| 462 | 469 |
| 463 typedef SkFlattenable INHERITED; | 470 typedef SkFlattenable INHERITED; |
| 464 }; | 471 }; |
| 465 | 472 |
| 466 #endif | 473 #endif |
| OLD | NEW |