Chromium Code Reviews| 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 true if the shader subclass succeeds in creating an effect or if none is required. | 337 * Returns a GrFragmentProcessor that implements the shader for the GPU bac kend. NULL is |
| 338 * False is returned if it fails or if there is not an implementation of th is method in the | 338 * returned if there is no GPU implementation. |
| 339 * shader subclass. | |
| 340 * | 339 * |
| 341 * On success an implementation of this method must inspect the SkPaint and set paintColor to | 340 * The GPU device does not call SkShader::createContext(), instead we pass the view matrix, |
| 342 * the color the effect expects as its input color. If the SkShader wishes to emit a solid | 341 * local matrix, and filter quality directly. |
| 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. | |
| 348 * | 342 * |
| 349 * The GrContext may be used by the effect to create textures. The GPU devi ce does not | 343 * The GrContext may be used by the to create textures that are required by the returned |
| 350 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info. | 344 * processor. |
| 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. | |
| 354 */ | 345 */ |
| 355 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, | 346 virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*, |
|
robertphillips
2015/08/28 21:33:05
viewMatric ?
bsalomon
2015/08/29 01:42:50
Done.
| |
| 356 const SkMatrix* localMatrix, GrColor*, | 347 const SkMatrix& viewM atric, |
| 357 GrProcessorDataManager*, GrFragmentProcesso r**) const; | 348 const SkMatrix* local Matrix, |
| 349 SkFilterQuality, | |
| 350 GrProcessorDataManage r*) const; | |
| 358 | 351 |
| 359 /** | 352 /** |
| 360 * If the shader can represent its "average" luminance in a single color, r eturn true and | 353 * If the shader can represent its "average" luminance in a single color, r eturn true and |
| 361 * if color is not NULL, return that color. If it cannot, return false and ignore the color | 354 * if color is not NULL, return that color. If it cannot, return false and ignore the color |
| 362 * parameter. | 355 * parameter. |
| 363 * | 356 * |
| 364 * Note: if this returns true, the returned color will always be opaque, as only the RGB | 357 * Note: if this returns true, the returned color will always be opaque, as only the RGB |
| 365 * components are used to compute luminance. | 358 * components are used to compute luminance. |
| 366 */ | 359 */ |
| 367 bool asLuminanceColor(SkColor*) const; | 360 bool asLuminanceColor(SkColor*) const; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 // constructors. | 457 // constructors. |
| 465 SkMatrix fLocalMatrix; | 458 SkMatrix fLocalMatrix; |
| 466 | 459 |
| 467 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. | 460 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. |
| 468 friend class SkLocalMatrixShader; | 461 friend class SkLocalMatrixShader; |
| 469 | 462 |
| 470 typedef SkFlattenable INHERITED; | 463 typedef SkFlattenable INHERITED; |
| 471 }; | 464 }; |
| 472 | 465 |
| 473 #endif | 466 #endif |
| OLD | NEW |