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 | 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 SkScalar* fColorOffsets; //!< The unit offset for color transitions. | 350 SkScalar* fColorOffsets; //!< The unit offset for color transitions. | 
| 350 SkPoint fPoint[2]; //!< Type specific, see above. | 351 SkPoint fPoint[2]; //!< Type specific, see above. | 
| 351 SkScalar fRadius[2]; //!< Type specific, see above. | 352 SkScalar fRadius[2]; //!< Type specific, see above. | 
| 352 TileMode fTileMode; //!< The tile mode used. | 353 TileMode fTileMode; //!< The tile mode used. | 
| 353 uint32_t fGradientFlags; //!< see SkGradientShader::Flags | 354 uint32_t fGradientFlags; //!< see SkGradientShader::Flags | 
| 354 }; | 355 }; | 
| 355 | 356 | 
| 356 virtual GradientType asAGradient(GradientInfo* info) const; | 357 virtual GradientType asAGradient(GradientInfo* info) const; | 
| 357 | 358 | 
| 358 /** | 359 /** | 
| 360 * If the shader subclass is composed of two shaders, return true, and if r ec is not NULL, | |
| 361 * fill it out with info about the shader. | |
| 
 
reed1
2014/05/13 18:00:24
? What is the ownership-rule for the returned poin
 
scroggo
2014/05/14 13:51:26
Uploaded https://codereview.chromium.org/288713002
 
 | |
| 362 */ | |
| 363 | |
| 364 struct ComposeRec { | |
| 365 const SkShader* fShaderA; | |
| 366 const SkShader* fShaderB; | |
| 367 const SkXfermode* fMode; | |
| 368 }; | |
| 369 | |
| 370 virtual bool asACompose(ComposeRec* rec) const { return false; } | |
| 371 | |
| 372 | |
| 373 /** | |
| 359 * If the shader subclass has a GrEffect implementation, this resturns the effect to install. | 374 * If the shader subclass has a GrEffect implementation, this resturns the effect to install. | 
| 360 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha. | 375 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha. | 
| 361 * The output color should be the computed SkShader premul color modulated by the incoming | 376 * The output color should be the computed SkShader premul color modulated by the incoming | 
| 362 * color. The GrContext may be used by the effect to create textures. The G PU device does not | 377 * color. The GrContext may be used by the effect to create textures. The G PU device does not | 
| 363 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info. | 378 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info. | 
| 364 */ | 379 */ | 
| 365 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint, | 380 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint, | 
| 366 const SkMatrix* localMatrixOrNull) const; | 381 const SkMatrix* localMatrixOrNull) const; | 
| 367 | 382 | 
| 383 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | |
| 384 /** | |
| 385 * If the shader is a custom shader which has data the caller might want, c all this function | |
| 386 * to get that data. | |
| 387 */ | |
| 388 virtual bool asACustomShader(void** customData) const { return false; } | |
| 389 #endif | |
| 390 | |
| 368 ////////////////////////////////////////////////////////////////////////// | 391 ////////////////////////////////////////////////////////////////////////// | 
| 369 // Factory methods for stock shaders | 392 // Factory methods for stock shaders | 
| 370 | 393 | 
| 371 /** | 394 /** | 
| 372 * Call this to create a new "empty" shader, that will not draw anything. | 395 * Call this to create a new "empty" shader, that will not draw anything. | 
| 373 */ | 396 */ | 
| 374 static SkShader* CreateEmptyShader(); | 397 static SkShader* CreateEmptyShader(); | 
| 375 | 398 | 
| 376 /** Call this to create a new shader that will draw with the specified bitma p. | 399 /** Call this to create a new shader that will draw with the specified bitma p. | 
| 377 * | 400 * | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 */ | 459 */ | 
| 437 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 460 virtual Context* onCreateContext(const ContextRec&, void* storage) const; | 
| 438 | 461 | 
| 439 private: | 462 private: | 
| 440 SkMatrix fLocalMatrix; | 463 SkMatrix fLocalMatrix; | 
| 441 | 464 | 
| 442 typedef SkFlattenable INHERITED; | 465 typedef SkFlattenable INHERITED; | 
| 443 }; | 466 }; | 
| 444 | 467 | 
| 445 #endif | 468 #endif | 
| OLD | NEW |