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 | 18 |
18 class SkPath; | 19 class SkPath; |
19 class SkPicture; | 20 class SkPicture; |
20 class SkXfermode; | 21 class SkXfermode; |
21 class GrContext; | 22 class GrContext; |
22 class GrEffectRef; | 23 class GrEffectRef; |
23 | 24 |
24 /** \class SkShader | 25 /** \class SkShader |
25 * | 26 * |
26 * 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 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 struct ComposeRec { | 367 struct ComposeRec { |
367 const SkShader* fShaderA; | 368 const SkShader* fShaderA; |
368 const SkShader* fShaderB; | 369 const SkShader* fShaderB; |
369 const SkXfermode* fMode; | 370 const SkXfermode* fMode; |
370 }; | 371 }; |
371 | 372 |
372 virtual bool asACompose(ComposeRec* rec) const { return false; } | 373 virtual bool asACompose(ComposeRec* rec) const { return false; } |
373 | 374 |
374 | 375 |
375 /** | 376 /** |
376 * If the shader subclass has a GrEffect implementation, this resturns the effect to install. | 377 * Returns true if the shader subclass is able to set the grEffect output p arameter to an |
378 * effect, in case it fails or the final *grEffect value is null it returns false. | |
379 * It always sets the value of grColor, the default is the paint color. | |
bsalomon
2014/06/09 14:11:30
It really always sets the color? Seems like the ca
dandov
2014/06/09 19:10:54
Change contract of function, returns false if it f
| |
377 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha. | 380 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha. |
378 * The output color should be the computed SkShader premul color modulated by the incoming | 381 * The output color should be the computed SkShader premul color modulated by the incoming |
379 * color. The GrContext may be used by the effect to create textures. The G PU device does not | 382 * color. The GrContext may be used by the effect to create textures. The G PU device does not |
380 * 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. |
381 */ | 384 */ |
382 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint, | 385 virtual bool asNewEffect(GrContext* context, const SkPaint& paint, |
383 const SkMatrix* localMatrixOrNull) const; | 386 const SkMatrix* localMatrixOrNull, GrColor* grColor , |
387 GrEffectRef** grEffect) const; | |
384 | 388 |
385 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 389 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
386 /** | 390 /** |
387 * If the shader is a custom shader which has data the caller might want, c all this function | 391 * If the shader is a custom shader which has data the caller might want, c all this function |
388 * to get that data. | 392 * to get that data. |
389 */ | 393 */ |
390 virtual bool asACustomShader(void** customData) const { return false; } | 394 virtual bool asACustomShader(void** customData) const { return false; } |
391 #endif | 395 #endif |
392 | 396 |
393 ////////////////////////////////////////////////////////////////////////// | 397 ////////////////////////////////////////////////////////////////////////// |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 SkShader(SkReadBuffer& ); | 457 SkShader(SkReadBuffer& ); |
454 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 458 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
455 | 459 |
456 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; | 460 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const; |
457 | 461 |
458 /** | 462 /** |
459 * Your subclass must also override contextSize() if it overrides onCreateC ontext(). | 463 * Your subclass must also override contextSize() if it overrides onCreateC ontext(). |
460 * Base class impl returns NULL. | 464 * Base class impl returns NULL. |
461 */ | 465 */ |
462 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 466 virtual Context* onCreateContext(const ContextRec&, void* storage) const; |
467 | |
468 /** | |
469 * Returns a GrColor with all of its values set to the alpha of paint. | |
470 */ | |
471 GrColor getColorAsAlpha(SkPaint paint) const; | |
dandov
2014/06/06 21:50:44
function to get the SkPaint's alpha in the 4 chann
bsalomon
2014/06/09 14:11:30
I don't think this should be a member of SkShader.
dandov
2014/06/09 19:10:54
Done.
| |
463 | 472 |
464 private: | 473 private: |
465 SkMatrix fLocalMatrix; | 474 SkMatrix fLocalMatrix; |
466 | 475 |
467 typedef SkFlattenable INHERITED; | 476 typedef SkFlattenable INHERITED; |
468 }; | 477 }; |
469 | 478 |
470 #endif | 479 #endif |
OLD | NEW |