java.lang.Object | |
↳ | android.renderscript.RenderScript |
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.
For more information about creating an application that uses RenderScript, read the RenderScript developer guide.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RenderScript.ContextType | ContextType specifies the specific type of context to be created. | ||||||||||
RenderScript.Priority | RenderScript worker thread priority enumeration. | ||||||||||
RenderScript.RSErrorHandler | The runtime error handler base 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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Print the currently available debugging information about the state of
the RS context to the log.
| |||||||||||
Gets or creates a RenderScript context of the specified type.
| |||||||||||
calls create(ctx, ct, CREATE_FLAG_NONE)
See documentation for @create for details
| |||||||||||
calls create(ctx, ContextType.NORMAL, CREATE_FLAG_NONE)
See documentation for @create for details
| |||||||||||
Create a RenderScript context.
| |||||||||||
Destroys this RenderScript context.
| |||||||||||
Wait for any pending asynchronous opeations (such as copies to a RS
allocation or RS script executions) to complete.
| |||||||||||
Gets the application context associated with the RenderScript context.
| |||||||||||
Returns an identifier that can be used to identify a particular
minor version of RS.
| |||||||||||
Releases all the process contexts.
| |||||||||||
Place a message into the message queue to be sent back to the message
handler once all previous commands have been executed.
| |||||||||||
Change the priority of the worker threads for this context.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Print the currently available debugging information about the state of the RS context to the log.
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.
ctx | The context. |
---|---|
ct | The type of context to be created. |
flags | The OR of the CREATE_FLAG_* options desired |
calls create(ctx, ct, CREATE_FLAG_NONE) See documentation for @create for details
ctx | The context. |
---|---|
ct | The type of context to be created. |
calls create(ctx, ContextType.NORMAL, CREATE_FLAG_NONE) See documentation for @create for details
ctx | The context. |
---|
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()
ctx | The context. |
---|
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.
Wait for any pending asynchronous opeations (such as copies to a RS allocation or RS script executions) to complete.
Gets the application context associated with the RenderScript context.
Returns an identifier that can be used to identify a particular minor version of RS.
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()
Place a message into the message queue to be sent back to the message handler once all previous commands have been executed.
Change the priority of the worker threads for this context.
p | New priority to be set. |
---|
Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.
Note that objects that override finalize
are significantly more expensive than
objects that don't. Finalizers may be run a long time after the object is no longer
reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
Note also that finalizers are run on a single VM-wide finalizer thread,
so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
for a class that has a native peer and needs to call a native method to destroy that peer.
Even then, it's better to provide an explicit close
method (and implement
Closeable
), and insist that callers manually dispose of instances. This
works well for something like files, but less well for something like a BigInteger
where typical calling code would have to deal with lots of temporaries. Unfortunately,
code that creates lots of temporaries is the worst kind of code from the point of view of
the single finalizer thread.
If you must use finalizers, consider at least providing your own
ReferenceQueue
and having your own thread process that queue.
Unlike constructors, finalizers are not automatically chained. You are responsible for
calling super.finalize()
yourself.
Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.
Throwable |
---|