public class GraphicBuffer extends Object implements Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<GraphicBuffer> |
CREATOR |
static int |
USAGE_HW_2D |
static int |
USAGE_HW_COMPOSER |
static int |
USAGE_HW_MASK |
static int |
USAGE_HW_RENDER |
static int |
USAGE_HW_TEXTURE |
static int |
USAGE_HW_VIDEO_ENCODER |
static int |
USAGE_PROTECTED |
static int |
USAGE_SOFTWARE_MASK |
static int |
USAGE_SW_READ_MASK |
static int |
USAGE_SW_READ_NEVER |
static int |
USAGE_SW_READ_OFTEN |
static int |
USAGE_SW_READ_RARELY |
static int |
USAGE_SW_WRITE_MASK |
static int |
USAGE_SW_WRITE_NEVER |
static int |
USAGE_SW_WRITE_OFTEN |
static int |
USAGE_SW_WRITE_RARELY |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
static GraphicBuffer |
create(int width,
int height,
int format,
int usage)
Creates new
GraphicBuffer instance. |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
void |
destroy()
Destroyes this buffer immediately.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
int |
getFormat()
Returns the pixel format of this buffer.
|
int |
getHeight()
Returns the height of this buffer in pixels.
|
int |
getUsage()
Returns the usage hint set on this buffer.
|
int |
getWidth()
Returns the width of this buffer in pixels.
|
boolean |
isDestroyed()
Indicates whether this buffer has been destroyed.
|
Canvas |
lockCanvas()
Start editing the pixels in the buffer.
|
Canvas |
lockCanvas(Rect dirty)
Just like
lockCanvas() but allows specification of a dirty
rectangle. |
void |
unlockCanvasAndPost(Canvas canvas)
Finish editing pixels in the buffer.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final int USAGE_SW_READ_NEVER
public static final int USAGE_SW_READ_RARELY
public static final int USAGE_SW_READ_OFTEN
public static final int USAGE_SW_READ_MASK
public static final int USAGE_SW_WRITE_NEVER
public static final int USAGE_SW_WRITE_RARELY
public static final int USAGE_SW_WRITE_OFTEN
public static final int USAGE_SW_WRITE_MASK
public static final int USAGE_SOFTWARE_MASK
public static final int USAGE_PROTECTED
public static final int USAGE_HW_TEXTURE
public static final int USAGE_HW_RENDER
public static final int USAGE_HW_2D
public static final int USAGE_HW_COMPOSER
public static final int USAGE_HW_VIDEO_ENCODER
public static final int USAGE_HW_MASK
public static final Parcelable.Creator<GraphicBuffer> CREATOR
public static GraphicBuffer create(int width, int height, int format, int usage)
GraphicBuffer
instance. This method will return null
if the buffer cannot be created.width
- The width in pixels of the bufferheight
- The height in pixels of the bufferformat
- The format of each pixel as specified in PixelFormat
usage
- Hint indicating how the buffer will be usedGraphicBuffer
instance or nullpublic int getWidth()
public int getHeight()
public int getFormat()
PixelFormat
.public int getUsage()
public 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 destroy()
, the return value will
always be null.
lockCanvas(android.graphics.Rect)
,
unlockCanvasAndPost(android.graphics.Canvas)
,
isDestroyed()
public Canvas lockCanvas(Rect dirty)
lockCanvas()
but allows specification of a dirty
rectangle.
If this method is called after destroy()
, the return value will
always be null.
dirty
- Area of the buffer that may be modified.lockCanvas()
,
unlockCanvasAndPost(android.graphics.Canvas)
,
isDestroyed()
public void unlockCanvasAndPost(Canvas canvas)
This method doesn't do anything if destroy()
was
previously called.
canvas
- The Canvas previously returned by lockCanvas()lockCanvas()
,
lockCanvas(android.graphics.Rect)
,
isDestroyed()
public void destroy()
lockCanvas()
must not be called,
etc.)isDestroyed()
public boolean isDestroyed()
GraphicBuffer
is in a destroyed state,
false otherwise.destroy()
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Calling this method will throw an IllegalStateException
if
destroy()
has been previously called.
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.