FileDocCategorySizeDatePackage
HardwareLayer.javaAPI DocAndroid 5.1 API5290Thu Mar 12 22:22:10 GMT 2015android.view

HardwareLayer

public final class HardwareLayer extends Object
A hardware layer can be used to render graphics operations into a hardware friendly buffer. For instance, with an OpenGL backend a hardware layer would use a Frame Buffer Object (FBO.) The hardware layer can be used as a drawing cache when a complex set of graphics operations needs to be drawn several times.
hide

Fields Summary
private HardwareRenderer
mRenderer
private com.android.internal.util.VirtualRefBasePtr
mFinalizer
Constructors Summary
private HardwareLayer(HardwareRenderer renderer, long deferredUpdater)

        if (renderer == null || deferredUpdater == 0) {
            throw new IllegalArgumentException("Either hardware renderer: " + renderer
                    + " or deferredUpdater: " + deferredUpdater + " is invalid");
        }
        mRenderer = renderer;
        mFinalizer = new VirtualRefBasePtr(deferredUpdater);
    
Methods Summary
static android.view.HardwareLayeradoptTextureLayer(HardwareRenderer renderer, long layer)

        return new HardwareLayer(renderer, layer);
    
public booleancopyInto(android.graphics.Bitmap bitmap)
Copies this layer into the specified bitmap.

param
bitmap The bitmap to copy they layer into
return
True if the copy was successful, false otherwise

        return mRenderer.copyLayerInto(this, bitmap);
    
public voiddestroy()
Destroys resources without waiting for a GC.

        if (!isValid()) {
            // Already destroyed
            return;
        }
        mRenderer.onLayerDestroyed(this);
        mRenderer = null;
        mFinalizer.release();
        mFinalizer = null;
    
public voiddetachSurfaceTexture()
Indicates that this layer has lost its texture.

        mRenderer.detachSurfaceTexture(mFinalizer.get());
    
public longgetDeferredLayerUpdater()

        return mFinalizer.get();
    
public longgetLayerHandle()

        return mFinalizer.get();
    
public booleanisValid()
Indicates whether this layer can be rendered.

return
True if the layer can be rendered into, false otherwise

        return mFinalizer != null && mFinalizer.get() != 0;
    
private static native intnGetTexName(long layerUpdater)

private static native booleannPrepare(long layerUpdater, int width, int height, boolean isOpaque)

private static native voidnSetLayerPaint(long layerUpdater, long paint)

private static native voidnSetSurfaceTexture(long layerUpdater, android.graphics.SurfaceTexture surface, boolean isAlreadyAttached)

private static native voidnSetTransform(long layerUpdater, long matrix)

private static native voidnUpdateRenderLayer(long layerUpdater, long displayList, int left, int top, int right, int bottom)

private static native voidnUpdateSurfaceTexture(long layerUpdater)

public booleanprepare(int width, int height, boolean isOpaque)
Update the layer's properties. Note that after calling this isValid() may return false if the requested width/height cannot be satisfied

param
width The new width of this layer
param
height The new height of this layer
param
isOpaque Whether this layer is opaque
return
true if the layer's properties will change, false if they already match the desired values.

        return nPrepare(mFinalizer.get(), width, height, isOpaque);
    
public voidsetLayerPaint(android.graphics.Paint paint)
Update the paint used when drawing this layer.

param
paint The paint used when the layer is drawn into the destination canvas.
see
View#setLayerPaint(android.graphics.Paint)

        nSetLayerPaint(mFinalizer.get(), paint.mNativePaint);
        mRenderer.pushLayerUpdate(this);
    
public voidsetSurfaceTexture(android.graphics.SurfaceTexture surface)

        nSetSurfaceTexture(mFinalizer.get(), surface, false);
        mRenderer.pushLayerUpdate(this);
    
public voidsetTransform(android.graphics.Matrix matrix)
Sets an optional transform on this layer.

param
matrix The transform to apply to the layer.

        nSetTransform(mFinalizer.get(), matrix.native_instance);
        mRenderer.pushLayerUpdate(this);
    
public voidupdateSurfaceTexture()

        nUpdateSurfaceTexture(mFinalizer.get());
        mRenderer.pushLayerUpdate(this);