FileDocCategorySizeDatePackage
Surface.javaAPI DocAndroid 1.5 API10423Wed May 06 22:41:56 BST 2009android.view

Surface

public class Surface extends Object implements android.os.Parcelable
Handle on to a raw buffer that is being managed by the screen compositor.

Fields Summary
private static final String
LOG_TAG
public static final int
HIDDEN
Surface is created hidden
public static final int
HARDWARE
The surface is to be used by hardware accelerators or DMA engines
public static final int
GPU
Implies "HARDWARE", the surface is to be used by the GPU additionally the backbuffer is never preserved for these surfaces.
public static final int
SECURE
The surface contains secure content, special measures will be taken to disallow the surface's content to be copied from another process. In particular, screenshots and VNC servers will be disabled, but other measures can take place, for instance the surface might not be hardware accelerated.
public static final int
NON_PREMULTIPLIED
Creates a surface where color components are interpreted as "non pre-multiplied" by their alpha channel. Of course this flag is meaningless for surfaces without an alpha channel. By default surfaces are pre-multiplied, which means that each color component is already multiplied by its alpha value. In this case the blending equation used is: DEST = SRC + DEST * (1-SRC_ALPHA) By contrast, non pre-multiplied surfaces use the following equation: DEST = SRC * SRC_ALPHA * DEST * (1-SRC_ALPHA) pre-multiplied surfaces must always be used if transparent pixels are composited on top of each-other into the surface. A pre-multiplied surface can never lower the value of the alpha component of a given pixel. In some rare situations, a non pre-multiplied surface is preferable.
public static final int
PUSH_BUFFERS
Creates a surface without a rendering buffer. Instead, the content of the surface must be pushed by an external entity. This is type of surface can be used for efficient camera preview or movie play back.
public static final int
FX_SURFACE_NORMAL
Creates a normal surface. This is the default
public static final int
FX_SURFACE_BLUR
Creates a Blur surface. Everything behind this surface is blurred by some amount. The quality and refresh speed of the blur effect is not settable or guaranteed. It is an error to lock a Blur surface, since it doesn't have a backing store.
public static final int
FX_SURFACE_DIM
Creates a Dim surface. Everything behind this surface is dimmed by the amount specified in setAlpha(). It is an error to lock a Dim surface, since it doesn't have a backing store.
public static final int
FX_SURFACE_MASK
Mask used for FX values above
public static final int
SURFACE_HIDDEN
Hide the surface. Equivalent to calling hide()
public static final int
SURACE_FROZEN
Freeze the surface. Equivalent to calling freeze()
public static final int
SURFACE_DITHER
Enable dithering when compositing this surface
public static final int
SURFACE_BLUR_FREEZE
public static final int
ROTATION_0
public static final int
ROTATION_90
public static final int
ROTATION_180
public static final int
ROTATION_270
public static final int
FLAGS_ORIENTATION_ANIMATION_DISABLE
Disable the orientation animation {@hide}
private int
mSurface
private int
mSaveCount
private Canvas
mCanvas
public static final Parcelable.Creator
CREATOR
Constructors Summary
public Surface(SurfaceSession s, int pid, int display, int w, int h, int format, int flags)
create a surface {@hide}

 nativeClassInit(); 
        mCanvas = new Canvas();
        init(s,pid,display,w,h,format,flags);
    
public Surface()
Create an empty surface, which will later be filled in by readFromParcel(). {@hide}

        mCanvas = new Canvas();
    
private Surface(android.os.Parcel source)

        init(source);
    
Methods Summary
public native voidclear()
Call this free the surface up. {@hide}

public static native voidcloseTransaction()
{@hide}

public native voidcopyFrom(android.view.Surface o)
Copy another surface to this one. This surface now holds a reference to the same data as the original surface, and is -not- the owner. {@hide}

public intdescribeContents()

        return 0;
    
protected voidfinalize()


    /* no user serviceable parts here ... */
    
         
        clear();
    
public native voidfreeze()

public static native voidfreezeDisplay(int display)
Freezes the specified display, No updating of the screen will occur until unfreezeDisplay() is called. Everything else works as usual though, in particular transactions.

param
display {@hide}

public native voidhide()

private native voidinit(SurfaceSession s, int pid, int display, int w, int h, int format, int flags)

private native voidinit(android.os.Parcel source)

public native booleanisValid()
Does this object hold a valid surface? Returns true if it holds a physical surface, so lockCanvas() will succeed. Otherwise returns false.

public CanvaslockCanvas(Rect dirty)
draw into a surface

        /* the dirty rectangle may be expanded to the surface's size, if
         * for instance it has been resized or if the bits were lost, since
         * the last call.
         */
        return lockCanvasNative(dirty);
    
private native CanvaslockCanvasNative(Rect dirty)

private static native voidnativeClassInit()

public static native voidopenTransaction()
start/end a transaction {@hide}

public native voidreadFromParcel(android.os.Parcel source)

public native voidsetAlpha(float alpha)

public native voidsetFlags(int flags, int mask)

public native voidsetFreezeTint(int tint)

public native voidsetLayer(int zorder)
set surface parameters. needs to be inside open/closeTransaction block

public native voidsetMatrix(float dsdx, float dtdx, float dsdy, float dtdy)

public static native voidsetOrientation(int display, int orientation, int flags)
set the orientation of the given display.

param
display
param
orientation
param
flags {@hide}

public static voidsetOrientation(int display, int orientation)
set the orientation of the given display.

param
display
param
orientation

        setOrientation(display, orientation, 0);
    
public native voidsetPosition(int x, int y)

public native voidsetSize(int w, int h)

public native voidsetTransparentRegionHint(Region region)

public native voidshow()

public java.lang.StringtoString()

        return "Surface(native-token=" + mSurface + ")";
    
public native voidunfreeze()

public static native voidunfreezeDisplay(int display)
resume updating the specified display.

param
display {@hide}

public native voidunlockCanvas(Canvas canvas)
unlock the surface. the screen won't be updated until post() or postAll() is called

public native voidunlockCanvasAndPost(Canvas canvas)
unlock the surface and asks a page flip

public native voidwriteToParcel(android.os.Parcel dest, int flags)