Since: API Level 11
package

android.renderscript

The Renderscript rendering and computational APIs offer a low-level, high performance means of carrying out mathematical calculations and 3D graphics rendering. An example of Renderscript in applications include the 3D carousel view that is present in Android 3.0 applications such as the Books and YouTube applications. This API is intended for developers who are comfortable working with native code and want to maximize their performance critical applications.

Renderscript adopts a control and slave architecture where the low-level native code is controlled by the higher level Android system that runs in the virtual machine (VM). The VM code handles resource allocation and lifecycle management of the Renderscript enabled application and calls the Renderscript code through high level entry points. The Android build tools generate these entry points through reflection on the native Renderscript code, which you write in C (C99 standard). The Renderscript code does the intensive computation and returns the result back to the Android VM.

You can find the Renderscript native APIs in the <sdk_root>/platforms/android-3.0/renderscript directory. The Android system APIs are broken into a few main groups:

Core

These classes are used internally by the system for memory allocation. They are used by the classes that are generated by the build tools:

  • Allocation
  • Element
  • Type
  • Script

Data Types

These data types are used by the classes that are generated by the build tools. They are the reflected counterparts of the native data types that are defined by the native Renderscript APIs and used by your Renderscript code. The classes include:

  • Byte2, Byte3, and Byte4
  • Float2, Float3, Float4
  • Int2, Int3, Int4
  • Long2, Long3, Long4
  • Matrix2f, Matrix3f, Matrix4f
  • Short2, Short3, Short4

For example, if you declared the following struct in your .rs Renderscript file:

struct Hello { float3 position; rs_matrix4x4 transform; }

The build tools generate a class through reflection that looks like the following:

class Hello {
    static public class Item {
        Float4 position;
        Matrix4f transform;
    }
Element createElement(RenderScript rs) {
        Element.Builder eb = new Element.Builder(rs);
        eb.add(Element.F32_3(rs), "position");
        eb.add(Element.MATRIX_4X4(rs), "transform");
        return eb.create();
    }
}

Graphics

These classes are specific to graphics Renderscripts and support a typical rendering pipeline.

  • Mesh
  • ProgramFragment
  • ProgramRaster
  • ProgramStore
  • ProgramVertex
  • RSSurfaceView
  • Sampler

For information on how to create an application that uses Renderscript, and also the see 3D with Renderscript dev guide.

Classes

Allocation

Memory allocation class for renderscript. 

AllocationAdapter  
Byte2 Class for exposing the native Renderscript byte2 type back to the Android system. 
Byte3 Class for exposing the native Renderscript byte3 type back to the Android system. 
Byte4 Class for exposing the native Renderscript byte4 type back to the Android system. 
Element

The most basic data type. 

Element.Builder Builder class for producing complex elements with matching field and name pairs. 
FieldPacker Utility class for packing arguments and structures from Android system objects to Renderscript objects. 
FileA3D FileA3D allows users to load Renderscript objects from files or resources stored on disk. 
FileA3D.IndexEntry IndexEntry contains information about one of the Renderscript objects inside the file's index. 
Float2 Class for exposing the native Renderscript float2 type back to the Android system. 
Float3 Class for exposing the native Renderscript float2 type back to the Android system. 
Float4 Class for exposing the native Renderscript float2 type back to the Android system. 
Font

This class gives users a simple way to draw hardware accelerated text. 

Int2 Class for exposing the native Renderscript int2 type back to the Android system. 
Int3 Class for exposing the native Renderscript int3 type back to the Android system. 
Int4 Class for exposing the native Renderscript int4 type back to the Android system. 
Long2 Class for exposing the native Renderscript long2 type back to the Android system. 
Long3 Class for exposing the native Renderscript long3 type back to the Android system. 
Long4 Class for exposing the native Renderscript long4 type back to the Android system. 
Matrix2f Class for exposing the native Renderscript rs_matrix2x2 type back to the Android system. 
Matrix3f Class for exposing the native Renderscript rs_matrix3x3 type back to the Android system. 
Matrix4f Class for exposing the native Renderscript rs_matrix4x4 type back to the Android system. 
Mesh

This class is a container for geometric data displayed with Renderscript. 

Mesh.AllocationBuilder Mesh builder object. 
Mesh.Builder Mesh builder object. 
Mesh.TriangleMeshBuilder Builder that allows creation of a mesh object point by point and triangle by triangle  
Program Program is a base class for all the objects that modify various stages of the graphics pipeline  
Program.BaseProgramBuilder  
ProgramFragment

The Renderscript fragment program, also known as fragment shader is responsible for manipulating pixel data in a user defined way. 

ProgramFragment.Builder  
ProgramFragmentFixedFunction

ProgramFragmentFixedFunction is a helper class that provides a way to make a simple fragment shader without writing any GLSL code. 

ProgramFragmentFixedFunction.Builder  
ProgramRaster Program raster is primarily used to specify whether point sprites are enabled and to control the culling mode. 
ProgramRaster.Builder  
ProgramStore

ProgramStore contains a set of parameters that control how the graphics hardware handles writes to the framebuffer. 

ProgramStore.Builder Builder class for ProgramStore object. 
ProgramVertex ProgramVertex, also know as a vertex shader, describes a stage in the graphics pipeline responsible for manipulating geometric data in a user-defined way. 
ProgramVertex.Builder Builder class for creating ProgramVertex objects. 
ProgramVertexFixedFunction ProgramVertexFixedFunction is a helper class that provides a simple way to create a fixed function emulation vertex shader without writing any GLSL code. 
ProgramVertexFixedFunction.Builder  
ProgramVertexFixedFunction.Constants Helper class to store modelview, projection and texture matrices for ProgramVertexFixedFunction  
RenderScript RenderScript base master class. 
RenderScript.RSErrorHandler Runtime error base class. 
RenderScript.RSMessageHandler Base class application should derive from for handling RS messages comming from their scripts. 
RenderScriptGL The Graphics derivitive of RenderScript. 
RenderScriptGL.SurfaceConfig Class which is used to describe a pixel format for a graphical buffer. 
RSSurfaceView The Surface View for a graphics renderscript (RenderScriptGL) to draw on. 
Sampler Sampler object which defines how data is extracted from textures. 
Sampler.Builder Builder for creating non-standard samplers. 
Script  
Script.Builder  
Script.FieldBase  
ScriptC  
Short2 Class for exposing the native Renderscript Short2 type back to the Android system. 
Short3 Class for exposing the native Renderscript short3 type back to the Android system. 
Short4 Class for exposing the native Renderscript short4 type back to the Android system. 
Type

Type is an allocation template. 

Type.Builder Builder class for Type. 

Enums

Allocation.MipmapControl Controls mipmap behavior when using the bitmap creation and update functions. 
Element.DataKind The special interpretation of the data if required. 
Element.DataType DataType represents the basic type information for a basic element. 
FileA3D.EntryType Specifies what renderscript object type is contained within the FileA3D IndexEntry  
Font.Style  
Mesh.Primitive Describes the way mesh vertex data is interpreted when rendering  
Program.TextureType TextureType specifies what textures are attached to Program objects  
ProgramFragmentFixedFunction.Builder.EnvMode EnvMode describes how textures are combined with the existing color in the fixed function fragment shader  
ProgramFragmentFixedFunction.Builder.Format Format describes the pixel format of textures in the fixed function fragment shader and how they are sampled  
ProgramRaster.CullMode  
ProgramStore.BlendDstFunc Specifies the functions used to combine incoming pixels with those already in the frame buffer. 
ProgramStore.BlendSrcFunc Specifies the functions used to combine incoming pixels with those already in the frame buffer. 
ProgramStore.DepthFunc Specifies the function used to determine whether a fragment will be drawn during the depth testing stage in the rendering pipeline by comparing its value with that already in the depth buffer. 
RenderScript.Priority RenderScript worker threads priority enumeration. 
Sampler.Value  
Type.CubemapFace  

Exceptions

RSDriverException Base class for all exceptions thrown by the Android Renderscript  
RSIllegalArgumentException Base class for all exceptions thrown by the Android Renderscript  
RSInvalidStateException Base class for all exceptions thrown by the Android Renderscript  
RSRuntimeException Base class for all exceptions thrown by the Android Renderscript