Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkComposeShader Class Reference

This subclass of shader returns the composition of two other shaders, combined by a xfermode. More...

#include <SkComposeShader.h>

Inheritance diagram for SkComposeShader:
SkShader SkFlattenable SkRefCnt SkRefCntBase

Classes

class  ComposeShaderContext
 

Public Member Functions

 SkComposeShader (SkShader *sA, SkShader *sB, SkXfermode *mode=NULL)
 Create a new compose shader, given shaders A, B, and a combining xfermode mode. More...
 
size_t contextSize () const override
 Return the size of a Context returned by createContext. More...
 
const GrFragmentProcessorasFragmentProcessor (GrContext *, const SkMatrix &viewM, const SkMatrix *localMatrix, SkFilterQuality) const override
 Returns a GrFragmentProcessor that implements the shader for the GPU backend. More...
 
SkShadergetShaderA ()
 
SkShadergetShaderB ()
 
bool asACompose (ComposeRec *rec) const override
 
- Public Member Functions inherited from SkShader
 SkShader (const SkMatrix *localMatrix=NULL)
 
const SkMatrixgetLocalMatrix () const
 Returns the local matrix. More...
 
virtual bool isOpaque () const
 Returns true if the shader is guaranteed to produce only opaque colors, subject to the SkPaint using the shader to apply an opaque alpha value. More...
 
ContextcreateContext (const ContextRec &, void *storage) const
 Create the actual object that does the shading. More...
 
bool isABitmap (SkBitmap *outTexture, SkMatrix *outMatrix, TileMode xy[2]) const
 Returns true if this shader is just a bitmap, and if not null, returns the bitmap, localMatrix, and tilemodes. More...
 
bool isABitmap () const
 
virtual GradientType asAGradient (GradientInfo *info) const
 
bool asLuminanceColor (SkColor *) const
 If the shader can represent its "average" luminance in a single color, return true and if color is not NULL, return that color. More...
 
SkShadernewWithLocalMatrix (const SkMatrix &) const
 Return a shader that will apply the specified localMatrix to this shader. More...
 
SkShadernewWithColorFilter (SkColorFilter *) const
 Create a new shader that produces the same colors as invoking this shader and then applying the colorfilter.
 
virtual SkShaderrefAsALocalMatrixShader (SkMatrix *localMatrix) const
 If this shader can be represented by another shader + a localMatrix, return that shader and, if not NULL, the localMatrix. More...
 
- Public Member Functions inherited from SkFlattenable
virtual Factory getFactory () const =0
 Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten().
 
const char * getTypeName () const
 Returns the name of the object's class.
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 Default construct, initializing the reference count to 1.
 
virtual ~SkRefCntBase ()
 Destruct, asserting that the reference count is 1.
 
int32_t getRefCnt () const
 Return the reference count. More...
 
bool unique () const
 May return true if the caller is the only owner. More...
 
void ref () const
 Increment the reference count. More...
 
void unref () const
 Decrement the reference count. More...
 
void validate () const
 

Protected Member Functions

 SkComposeShader (SkReadBuffer &)
 
void flatten (SkWriteBuffer &) const override
 Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).
 
ContextonCreateContext (const ContextRec &, void *) const override
 Your subclass must also override contextSize() if it overrides onCreateContext(). More...
 
- Protected Member Functions inherited from SkShader
void flatten (SkWriteBuffer &) const override
 Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).
 
bool computeTotalInverse (const ContextRec &, SkMatrix *totalInverse) const
 
virtual bool onAsLuminanceColor (SkColor *) const
 
virtual bool onIsABitmap (SkBitmap *, SkMatrix *, TileMode[2]) const
 
- Protected Member Functions inherited from SkRefCntBase
void internal_dispose_restore_refcnt_to_1 () const
 Allow subclasses to call this if they've overridden internal_dispose so they can reset fRefCnt before the destructor is called. More...
 

Private Types

typedef SkShader INHERITED
 

Private Attributes

SkShaderfShaderA
 
SkShaderfShaderB
 
SkXfermodefMode
 

Additional Inherited Members

- Public Types inherited from SkShader
enum  TileMode { kClamp_TileMode, kRepeat_TileMode, kMirror_TileMode }
 
enum  { kTileModeCount = kMirror_TileMode + 1 }
 
enum  Flags { kOpaqueAlpha_Flag = 1 << 0, kConstInY32_Flag = 1 << 1, kSupports4f_Flag = 1 << 2 }
 
enum  GradientType {
  kNone_GradientType, kColor_GradientType, kLinear_GradientType, kRadial_GradientType,
  kSweep_GradientType, kConical_GradientType, kLast_GradientType = kConical_GradientType
}
 If the shader subclass can be represented as a gradient, asAGradient returns the matching GradientType enum (or kNone_GradientType if it cannot). More...
 
- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type, kSkDrawLooper_Type, kSkImageFilter_Type, kSkMaskFilter_Type,
  kSkPathEffect_Type, kSkPixelRef_Type, kSkRasterizer_Type, kSkShader_Type,
  kSkUnused_Type, kSkXfermode_Type
}
 
typedef SkFlattenable *(* Factory )(SkReadBuffer &)
 
- Static Public Member Functions inherited from SkShader
static SkShaderCreateEmptyShader ()
 Call this to create a new "empty" shader, that will not draw anything.
 
static SkShaderCreateColorShader (SkColor)
 Call this to create a new shader that just draws the specified color. More...
 
static SkShaderCreateComposeShader (SkShader *dst, SkShader *src, SkXfermode::Mode)
 
static SkShaderCreateComposeShader (SkShader *dst, SkShader *src, SkXfermode *xfer)
 Create a new compose shader, given shaders dst, src, and a combining xfermode mode. More...
 
static SkShaderCreateBitmapShader (const SkBitmap &src, TileMode tmx, TileMode tmy, const SkMatrix *localMatrix=NULL)
 Call this to create a new shader that will draw with the specified bitmap. More...
 
static SkShaderCreatePictureShader (const SkPicture *src, TileMode tmx, TileMode tmy, const SkMatrix *localMatrix, const SkRect *tile)
 Call this to create a new shader that will draw with the specified picture. More...
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static bool NameToType (const char name[], Type *type)
 
static void Register (const char name[], Factory, Type)
 

Detailed Description

This subclass of shader returns the composition of two other shaders, combined by a xfermode.

Constructor & Destructor Documentation

SkComposeShader::SkComposeShader ( SkShader sA,
SkShader sB,
SkXfermode mode = NULL 
)

Create a new compose shader, given shaders A, B, and a combining xfermode mode.

When the xfermode is called, it will be given the result from shader A as its "dst", and the result from shader B as its "src". mode->xfer32(sA_result, sB_result, ...)

Parameters
shaderAThe colors from this shader are seen as the "dst" by the xfermode
shaderBThe colors from this shader are seen as the "src" by the xfermode
modeThe xfermode that combines the colors from the two shaders. If mode is null, then SRC_OVER is assumed.

Member Function Documentation

const GrFragmentProcessor* SkComposeShader::asFragmentProcessor ( GrContext ,
const SkMatrix viewMatrix,
const SkMatrix localMatrix,
SkFilterQuality   
) const
overridevirtual

Returns a GrFragmentProcessor that implements the shader for the GPU backend.

NULL is returned if there is no GPU implementation.

The GPU device does not call SkShader::createContext(), instead we pass the view matrix, local matrix, and filter quality directly.

The GrContext may be used by the to create textures that are required by the returned processor.

The returned GrFragmentProcessor should expect an unpremultiplied input color and produce a premultiplied output.

Reimplemented from SkShader.

size_t SkComposeShader::contextSize ( ) const
overridevirtual

Return the size of a Context returned by createContext.

Override this if your subclass overrides createContext, to return the correct size of your subclass' context.

Reimplemented from SkShader.

Context* SkComposeShader::onCreateContext ( const ContextRec ,
void *  storage 
) const
overrideprotectedvirtual

Your subclass must also override contextSize() if it overrides onCreateContext().

Base class impl returns NULL.

Reimplemented from SkShader.


The documentation for this class was generated from the following file: