Methods Summary |
---|
public static android.view.GraphicBuffer | create(int width, int height, int format, int usage)Creates new GraphicBuffer instance. This method will return null
if the buffer cannot be created.
long nativeObject = nCreateGraphicBuffer(width, height, format, usage);
if (nativeObject != 0) {
return new GraphicBuffer(width, height, format, usage, nativeObject);
}
return null;
|
public int | describeContents()
return 0;
|
public void | destroy()Destroyes this buffer immediately. Calling this method frees up any
underlying native resources. After calling this method, this buffer
must not be used in any way ({@link #lockCanvas()} must not be called,
etc.)
if (!mDestroyed) {
mDestroyed = true;
nDestroyGraphicBuffer(mNativeObject);
}
|
protected void | finalize()
try {
if (!mDestroyed) nDestroyGraphicBuffer(mNativeObject);
} finally {
super.finalize();
}
|
public int | getFormat()Returns the pixel format of this buffer. The pixel format must be one of
the formats defined in {@link PixelFormat}.
return mFormat;
|
public int | getHeight()Returns the height of this buffer in pixels.
return mHeight;
|
public int | getUsage()Returns the usage hint set on this buffer.
return mUsage;
|
public int | getWidth()Returns the width of this buffer in pixels.
return mWidth;
|
public boolean | isDestroyed()Indicates whether this buffer has been destroyed. A destroyed buffer
cannot be used in any way: locking a Canvas will return null, the buffer
cannot be written to a parcel, etc.
return mDestroyed;
|
public android.graphics.Canvas | lockCanvas()Start editing the pixels in the buffer. A null is returned if the buffer
cannot be locked for editing.
The content of the buffer is preserved between unlockCanvas()
and lockCanvas().
If this method is called after {@link #destroy()}, the return value will
always be null.
return lockCanvas(null);
|
public android.graphics.Canvas | lockCanvas(android.graphics.Rect dirty)Just like {@link #lockCanvas()} but allows specification of a dirty
rectangle.
If this method is called after {@link #destroy()}, the return value will
always be null.
if (mDestroyed) {
return null;
}
if (mCanvas == null) {
mCanvas = new Canvas();
}
if (nLockCanvas(mNativeObject, mCanvas, dirty)) {
mSaveCount = mCanvas.save();
return mCanvas;
}
return null;
|
private static native long | nCreateGraphicBuffer(int width, int height, int format, int usage)
|
private static native void | nDestroyGraphicBuffer(long nativeObject)
|
private static native boolean | nLockCanvas(long nativeObject, android.graphics.Canvas canvas, android.graphics.Rect dirty)
|
private static native long | nReadGraphicBufferFromParcel(android.os.Parcel in)
|
private static native boolean | nUnlockCanvasAndPost(long nativeObject, android.graphics.Canvas canvas)
|
private static native void | nWriteGraphicBufferToParcel(long nativeObject, android.os.Parcel dest)
|
public void | unlockCanvasAndPost(android.graphics.Canvas canvas)Finish editing pixels in the buffer.
This method doesn't do anything if {@link #destroy()} was
previously called.
if (!mDestroyed && mCanvas != null && canvas == mCanvas) {
canvas.restoreToCount(mSaveCount);
mSaveCount = 0;
nUnlockCanvasAndPost(mNativeObject, mCanvas);
}
|
public void | writeToParcel(android.os.Parcel dest, int flags)Flatten this object in to a Parcel.
Calling this method will throw an IllegalStateException if
{@link #destroy()} has been previously called.
if (mDestroyed) {
throw new IllegalStateException("This GraphicBuffer has been destroyed and cannot be "
+ "written to a parcel.");
}
dest.writeInt(mWidth);
dest.writeInt(mHeight);
dest.writeInt(mFormat);
dest.writeInt(mUsage);
nWriteGraphicBufferToParcel(mNativeObject, dest);
|