FileDocCategorySizeDatePackage
Shader.javaAPI DocAndroid 5.1 API3648Thu Mar 12 22:22:30 GMT 2015android.graphics

Shader

public class Shader extends Object
Shader is the based class for objects that return horizontal spans of colors during drawing. A subclass of Shader is installed in a Paint calling paint.setShader(shader). After that any object (other than a bitmap) that is drawn with that paint will get its color(s) from the shader.

Fields Summary
private long
native_instance
This is set by subclasses, but don't make it public.
private Matrix
mLocalMatrix
Constructors Summary
Methods Summary
protected android.graphics.Shadercopy()

hide

        final Shader copy = new Shader();
        copyLocalMatrix(copy);
        return copy;
    
protected voidcopyLocalMatrix(android.graphics.Shader dest)

hide

        if (mLocalMatrix != null) {
            final Matrix lm = new Matrix();
            getLocalMatrix(lm);
            dest.setLocalMatrix(lm);
        } else {
            dest.setLocalMatrix(null);
        }
    
protected voidfinalize()

        try {
            super.finalize();
        } finally {
            nativeDestructor(native_instance);
        }
    
public booleangetLocalMatrix(Matrix localM)
Return true if the shader has a non-identity local matrix.

param
localM If not null, it is set to the shader's local matrix.
return
true if the shader has a non-identity local matrix

        if (mLocalMatrix != null) {
            localM.set(mLocalMatrix);
            return !mLocalMatrix.isIdentity();
        }
        return false;
    
longgetNativeInstance()

        return native_instance;
    
protected voidinit(long ni)
Initialization step that should be called by subclasses in their constructors. Calling again may result in memory leaks.

hide

        native_instance = ni;
    
private static native voidnativeDestructor(long native_shader)

private static native voidnativeSetLocalMatrix(long native_shader, long matrix_instance)

public voidsetLocalMatrix(Matrix localM)
Set the shader's local matrix. Passing null will reset the shader's matrix to identity.

param
localM The shader's new local matrix, or null to specify identity

        mLocalMatrix = localM;
        nativeSetLocalMatrix(native_instance, localM == null ? 0 : localM.native_instance);