FileDocCategorySizeDatePackage
ComposeShader.javaAPI DocAndroid 5.1 API3988Thu Mar 12 22:22:30 GMT 2015android.graphics

ComposeShader

public class ComposeShader extends Shader
A subclass of shader that returns the composition of two other shaders, combined by an {@link android.graphics.Xfermode} subclass.

Fields Summary
private static final int
TYPE_XFERMODE
private static final int
TYPE_PORTERDUFFMODE
private int
mType
Type of the ComposeShader: can be either TYPE_XFERMODE or TYPE_PORTERDUFFMODE
private Xfermode
mXferMode
private PorterDuff.Mode
mPorterDuffMode
private final Shader
mShaderA
Hold onto the shaders to avoid GC.
private final Shader
mShaderB
Constructors Summary
public ComposeShader(Shader shaderA, Shader shaderB, Xfermode mode)
Create a new compose shader, given shaders A, B, and a combining mode. When the mode is applied, it will be given the result from shader A as its "dst", and the result from shader B as its "src".

param
shaderA The colors from this shader are seen as the "dst" by the mode
param
shaderB The colors from this shader are seen as the "src" by the mode
param
mode The mode that combines the colors from the two shaders. If mode is null, then SRC_OVER is assumed.

        mType = TYPE_XFERMODE;
        mShaderA = shaderA;
        mShaderB = shaderB;
        mXferMode = mode;
        init(nativeCreate1(shaderA.getNativeInstance(), shaderB.getNativeInstance(),
                (mode != null) ? mode.native_instance : 0));
    
public ComposeShader(Shader shaderA, Shader shaderB, PorterDuff.Mode mode)
Create a new compose shader, given shaders A, B, and a combining PorterDuff mode. When the mode is applied, it will be given the result from shader A as its "dst", and the result from shader B as its "src".

param
shaderA The colors from this shader are seen as the "dst" by the mode
param
shaderB The colors from this shader are seen as the "src" by the mode
param
mode The PorterDuff mode that combines the colors from the two shaders.

        mType = TYPE_PORTERDUFFMODE;
        mShaderA = shaderA;
        mShaderB = shaderB;
        mPorterDuffMode = mode;
        init(nativeCreate2(shaderA.getNativeInstance(), shaderB.getNativeInstance(),
                mode.nativeInt));
    
Methods Summary
protected Shadercopy()

hide

        final ComposeShader copy;
        switch (mType) {
            case TYPE_XFERMODE:
                copy = new ComposeShader(mShaderA.copy(), mShaderB.copy(), mXferMode);
                break;
            case TYPE_PORTERDUFFMODE:
                copy = new ComposeShader(mShaderA.copy(), mShaderB.copy(), mPorterDuffMode);
                break;
            default:
                throw new IllegalArgumentException(
                        "ComposeShader should be created with either Xfermode or PorterDuffMode");
        }
        copyLocalMatrix(copy);
        return copy;
    
private static native longnativeCreate1(long native_shaderA, long native_shaderB, long native_mode)

private static native longnativeCreate2(long native_shaderA, long native_shaderB, int porterDuffMode)