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 | 17 |
18 class SkPath; | 18 class SkPath; |
19 class SkPicture; | 19 class SkPicture; |
| 20 class SkXfermode; |
20 class GrContext; | 21 class GrContext; |
21 class GrEffectRef; | 22 class GrEffectRef; |
22 | 23 |
23 /** \class SkShader | 24 /** \class SkShader |
24 * | 25 * |
25 * Shaders specify the source color(s) for what is being drawn. If a paint | 26 * Shaders specify the source color(s) for what is being drawn. If a paint |
26 * has no shader, then the paint's color is used. If the paint has a | 27 * has no shader, then the paint's color is used. If the paint has a |
27 * shader, then the shader's color(s) are use instead, but they are | 28 * shader, then the shader's color(s) are use instead, but they are |
28 * modulated by the paint's alpha. This makes it easy to create a shader | 29 * modulated by the paint's alpha. This makes it easy to create a shader |
29 * once (e.g. bitmap tiling or gradient) and then change its transparency | 30 * once (e.g. bitmap tiling or gradient) and then change its transparency |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 SkScalar* fColorOffsets; //!< The unit offset for color transitions. | 348 SkScalar* fColorOffsets; //!< The unit offset for color transitions. |
348 SkPoint fPoint[2]; //!< Type specific, see above. | 349 SkPoint fPoint[2]; //!< Type specific, see above. |
349 SkScalar fRadius[2]; //!< Type specific, see above. | 350 SkScalar fRadius[2]; //!< Type specific, see above. |
350 TileMode fTileMode; //!< The tile mode used. | 351 TileMode fTileMode; //!< The tile mode used. |
351 uint32_t fGradientFlags; //!< see SkGradientShader::Flags | 352 uint32_t fGradientFlags; //!< see SkGradientShader::Flags |
352 }; | 353 }; |
353 | 354 |
354 virtual GradientType asAGradient(GradientInfo* info) const; | 355 virtual GradientType asAGradient(GradientInfo* info) const; |
355 | 356 |
356 /** | 357 /** |
| 358 * If the shader subclass is composed of two shaders, return true, and if r
ec is not NULL, |
| 359 * fill it out with info about the shader. |
| 360 */ |
| 361 |
| 362 struct ComposeRec { |
| 363 const SkShader* fShaderA; |
| 364 const SkShader* fShaderB; |
| 365 const SkXfermode* fMode; |
| 366 }; |
| 367 |
| 368 virtual bool asACompose(ComposeRec* rec) const { return false; } |
| 369 |
| 370 |
| 371 /** |
357 * If the shader subclass has a GrEffect implementation, this resturns the
effect to install. | 372 * If the shader subclass has a GrEffect implementation, this resturns the
effect to install. |
358 * The incoming color to the effect has r=g=b=a all extracted from the SkPa
int's alpha. | 373 * The incoming color to the effect has r=g=b=a all extracted from the SkPa
int's alpha. |
359 * The output color should be the computed SkShader premul color modulated
by the incoming | 374 * The output color should be the computed SkShader premul color modulated
by the incoming |
360 * color. The GrContext may be used by the effect to create textures. The G
PU device does not | 375 * color. The GrContext may be used by the effect to create textures. The G
PU device does not |
361 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. | 376 * call createContext. Instead we pass the SkPaint here in case the shader
needs paint info. |
362 */ | 377 */ |
363 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c
onst; | 378 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c
onst; |
364 | 379 |
| 380 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 381 /** |
| 382 * If the shader is a custom shader which has data the caller might want, c
all this function |
| 383 * to get that data. |
| 384 */ |
| 385 virtual bool asACustomShader(void** customData) const { return false; } |
| 386 #endif |
| 387 |
365 ////////////////////////////////////////////////////////////////////////// | 388 ////////////////////////////////////////////////////////////////////////// |
366 // Factory methods for stock shaders | 389 // Factory methods for stock shaders |
367 | 390 |
368 /** | 391 /** |
369 * Call this to create a new "empty" shader, that will not draw anything. | 392 * Call this to create a new "empty" shader, that will not draw anything. |
370 */ | 393 */ |
371 static SkShader* CreateEmptyShader(); | 394 static SkShader* CreateEmptyShader(); |
372 | 395 |
373 /** Call this to create a new shader that will draw with the specified bitma
p. | 396 /** Call this to create a new shader that will draw with the specified bitma
p. |
374 * | 397 * |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 */ | 456 */ |
434 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 457 virtual Context* onCreateContext(const ContextRec&, void* storage) const; |
435 | 458 |
436 private: | 459 private: |
437 SkMatrix fLocalMatrix; | 460 SkMatrix fLocalMatrix; |
438 | 461 |
439 typedef SkFlattenable INHERITED; | 462 typedef SkFlattenable INHERITED; |
440 }; | 463 }; |
441 | 464 |
442 #endif | 465 #endif |
OLD | NEW |