RenderScript
public
class
RenderScript
extends Object
java.lang.Object | |
↳ | android.renderscript.RenderScript |
This class was deprecated
in API level 31.
Renderscript has been deprecated in API level 31. Please refer to the migration
guide for the proposed alternatives.
This class provides access to a RenderScript context, which controls RenderScript initialization, resource management, and teardown. An instance of the RenderScript class must be created before any other RS objects can be created.
Developer Guides
For more information about creating an application that uses RenderScript, read the RenderScript developer guide.
Summary
Nested classes | |
---|---|
class |
RenderScript.RSErrorHandler
The runtime error handler base class. |
class |
RenderScript.RSMessageHandler
The base class from which an application should derive in order to receive RS messages from scripts. |
Constants | |
---|---|
int |
CREATE_FLAG_LOW_LATENCY
|
int |
CREATE_FLAG_LOW_POWER
|
int |
CREATE_FLAG_NONE
|
Public methods | |
---|---|
void
|
contextDump()
Print the currently available debugging information about the state of the RS context to the log. |
static
RenderScript
|
create(Context ctx, RenderScript.ContextType ct, int flags)
Gets or creates a RenderScript context of the specified type. |
static
RenderScript
|
create(Context ctx, RenderScript.ContextType ct)
calls create(ctx, ct, CREATE_FLAG_NONE) See documentation for @create for details |
static
RenderScript
|
create(Context ctx)
calls create(ctx, ContextType.NORMAL, CREATE_FLAG_NONE) See documentation for @create for details |
static
RenderScript
|
createMultiContext(Context ctx, RenderScript.ContextType ct, int flags, int API_number)
Create a RenderScript context. |
void
|
destroy()
Destroys this RenderScript context. |
void
|
finish()
Wait for any pending asynchronous opeations (such as copies to a RS allocation or RS script executions) to complete. |
final
Context
|
getApplicationContext()
Gets the application context associated with the RenderScript context. |
RenderScript.RSErrorHandler
|
getErrorHandler()
|
RenderScript.RSMessageHandler
|
getMessageHandler()
|
static
long
|
getMinorVersion()
Returns an identifier that can be used to identify a particular minor version of RS. |
static
void
|
releaseAllContexts()
Releases all the process contexts. |
void
|
sendMessage(int id, int[] data)
Place a message into the message queue to be sent back to the message handler once all previous commands have been executed. |
void
|
setErrorHandler(RenderScript.RSErrorHandler msg)
|
void
|
setMessageHandler(RenderScript.RSMessageHandler msg)
|
void
|
setPriority(RenderScript.Priority p)
Change the priority of the worker threads for this context. |
Protected methods | |
---|---|
void
|
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
Inherited methods | |
---|---|
Constants
CREATE_FLAG_LOW_LATENCY
public static final int CREATE_FLAG_LOW_LATENCY
Constant Value: 2 (0x00000002)
CREATE_FLAG_LOW_POWER
public static final int CREATE_FLAG_LOW_POWER
Constant Value: 4 (0x00000004)
CREATE_FLAG_NONE
public static final int CREATE_FLAG_NONE
Constant Value: 0 (0x00000000)
Public methods
contextDump
public void contextDump ()
Print the currently available debugging information about the state of the RS context to the log.
create
public static RenderScript create (Context ctx, RenderScript.ContextType ct, int flags)
Gets or creates a RenderScript context of the specified type. The returned context will be cached for future reuse within the process. When an application is finished using RenderScript it should call releaseAllContexts() A process context is a context designed for easy creation and lifecycle management. Multiple calls to this function will return the same object provided they are called with the same options. This allows it to be used any time a RenderScript context is needed. Prior to API 23 this always created a new context.
Parameters | |
---|---|
ctx |
Context : The context. |
ct |
RenderScript.ContextType : The type of context to be created. |
flags |
int : The OR of the CREATE_FLAG_* options desired |
Returns | |
---|---|
RenderScript |
RenderScript |
create
public static RenderScript create (Context ctx, RenderScript.ContextType ct)
calls create(ctx, ct, CREATE_FLAG_NONE) See documentation for @create for details
Parameters | |
---|---|
ctx |
Context : The context. |
ct |
RenderScript.ContextType : The type of context to be created. |
Returns | |
---|---|
RenderScript |
RenderScript |
create
public static RenderScript create (Context ctx)
calls create(ctx, ContextType.NORMAL, CREATE_FLAG_NONE) See documentation for @create for details
Parameters | |
---|---|
ctx |
Context : The context. |
Returns | |
---|---|
RenderScript |
RenderScript |
createMultiContext
public static RenderScript createMultiContext (Context ctx, RenderScript.ContextType ct, int flags, int API_number)
Create a RenderScript context. This is an advanced function intended for applications which need to create more than one RenderScript context to be used at the same time. If you need a single context please use create()
Parameters | |
---|---|
ctx |
Context : The context. |
ct |
RenderScript.ContextType |
flags |
int |
API_number |
int |
Returns | |
---|---|
RenderScript |
RenderScript |
destroy
public void destroy ()
Destroys this RenderScript context. Once this function is called, using this context or any objects belonging to this context is illegal. API 23+, this function is a NOP if the context was created with create(). Please use releaseAllContexts() to clean up contexts created with the create function.
finish
public void finish ()
Wait for any pending asynchronous opeations (such as copies to a RS allocation or RS script executions) to complete.
getApplicationContext
public final Context getApplicationContext ()
Gets the application context associated with the RenderScript context.
Returns | |
---|---|
Context |
The application context. |
getErrorHandler
public RenderScript.RSErrorHandler getErrorHandler ()
Returns | |
---|---|
RenderScript.RSErrorHandler |
getMessageHandler
public RenderScript.RSMessageHandler getMessageHandler ()
Returns | |
---|---|
RenderScript.RSMessageHandler |
getMinorVersion
public static long getMinorVersion ()
Returns an identifier that can be used to identify a particular minor version of RS.
Returns | |
---|---|
long |
The minor RenderScript version number |
releaseAllContexts
public static void releaseAllContexts ()
Releases all the process contexts. This is the same as calling .destroy() on each unique context retreived with create(...). If no contexts have been created this function does nothing. Typically you call this when your application is losing focus and will not be using a context for some time. This has no effect on a context created with createMultiContext()
sendMessage
public void sendMessage (int id, int[] data)
Place a message into the message queue to be sent back to the message handler once all previous commands have been executed.
setErrorHandler
public void setErrorHandler (RenderScript.RSErrorHandler msg)
Parameters | |
---|---|
msg |
RenderScript.RSErrorHandler |
setMessageHandler
public void setMessageHandler (RenderScript.RSMessageHandler msg)
Parameters | |
---|---|
msg |
RenderScript.RSMessageHandler |
setPriority
public void setPriority (RenderScript.Priority p)
Change the priority of the worker threads for this context.
Parameters | |
---|---|
p |
RenderScript.Priority : New priority to be set. |
Protected methods
finalize
protected void finalize ()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the 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 Java 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.
Throws | |
---|---|
Throwable |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-04 UTC.