ComposeShaderpublic 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 | mTypeType of the ComposeShader: can be either TYPE_XFERMODE or TYPE_PORTERDUFFMODE | private Xfermode | mXferMode | private PorterDuff.Mode | mPorterDuffMode | private final Shader | mShaderAHold 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".
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".
mType = TYPE_PORTERDUFFMODE;
mShaderA = shaderA;
mShaderB = shaderB;
mPorterDuffMode = mode;
init(nativeCreate2(shaderA.getNativeInstance(), shaderB.getNativeInstance(),
mode.nativeInt));
|
Methods Summary |
---|
protected Shader | copy()
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 long | nativeCreate1(long native_shaderA, long native_shaderB, long native_mode)
| private static native long | nativeCreate2(long native_shaderA, long native_shaderB, int porterDuffMode)
|
|