diff options
-rw-r--r-- | graphics/java/android/renderscript/Element.java | 30 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_allocation.rsh | 90 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_types.rsh | 75 | ||||
-rw-r--r-- | tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs | 10 |
4 files changed, 184 insertions, 21 deletions
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 29306e4..d76c209 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -62,12 +62,14 @@ public class Element extends BaseObj { /** * DataType represents the basic type information for a basic element. The - * naming convention follows. For numeric types its FLOAT, SIGNED, UNSIGNED - * followed by the _BITS where BITS is the size of the data. BOOLEAN is a - * true / false (1,0) represented in an 8 bit container. The UNSIGNED - * variants with multiple bit definitions are for packed graphical data - * formats and represents vectors with per vector member sizes which are - * treated as a single unit for packing and alignment purposes. + * naming convention follows. For numeric types it is FLOAT, + * SIGNED, or UNSIGNED followed by the _BITS where BITS is the + * size of the data. BOOLEAN is a true / false (1,0) + * represented in an 8 bit container. The UNSIGNED variants + * with multiple bit definitions are for packed graphical data + * formats and represent vectors with per vector member sizes + * which are treated as a single unit for packing and alignment + * purposes. * * MATRIX the three matrix types contain FLOAT_32 elements and are treated * as 32 bits for alignment purposes. @@ -228,6 +230,22 @@ public class Element extends BaseObj { } /** + * @hide + * @return element data type + */ + public DataType getDataType() { + return mType; + } + + /** + * @hide + * @return element data kind + */ + public DataKind getDataKind() { + return mKind; + } + + /** * Utility function for returning an Element containing a single Boolean. * * @param rs Context to which the element will belong. diff --git a/libs/rs/scriptc/rs_allocation.rsh b/libs/rs/scriptc/rs_allocation.rsh index 4d62bfb..d339d4f 100644 --- a/libs/rs/scriptc/rs_allocation.rsh +++ b/libs/rs/scriptc/rs_allocation.rsh @@ -168,29 +168,95 @@ extern const void * __attribute__((overloadable)) extern const void * __attribute__((overloadable)) rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z); -extern const rs_element __attribute__((overloadable)) +extern rs_element __attribute__((overloadable)) rsAllocationGetElement(rs_allocation); -extern const uint32_t __attribute__((overloadable)) +extern uint32_t __attribute__((overloadable)) rsMeshGetVertexAllocationCount(rs_mesh); -extern const uint32_t __attribute__((overloadable)) +extern uint32_t __attribute__((overloadable)) rsMeshGetPrimitiveCount(rs_mesh); -extern const uint32_t __attribute__((overloadable)) - rsMeshGetVertexAllocationCount(rs_mesh); - -extern const rs_allocation __attribute__((overloadable)) +extern rs_allocation __attribute__((overloadable)) rsMeshGetVertexAllocation(rs_mesh, uint32_t index); -extern const uint32_t __attribute__((overloadable)) - rsMeshGetPrimitiveCount(rs_mesh); - -extern const rs_allocation __attribute__((overloadable)) +extern rs_allocation __attribute__((overloadable)) rsMeshGetIndexAllocation(rs_mesh, uint32_t index); -extern const rs_primitive __attribute__((overloadable)) +extern rs_primitive __attribute__((overloadable)) rsMeshGetPrimitive(rs_mesh, uint32_t index); +/** + * @param e element to get data from + * @return number of sub-elements in this element + */ +extern uint32_t __attribute__((overloadable)) + rsElementGetSubElementCount(rs_element e); + +/** + * @param e element to get data from + * @param index index of the sub-element to return + * @return sub-element in this element at given index + */ +extern rs_element __attribute__((overloadable)) + rsElementGetSubElement(rs_element, uint32_t index); + +/** + * @param e element to get data from + * @param index index of the sub-element to return + * @return length of the sub-element name + */ +extern uint32_t __attribute__((overloadable)) + rsElementGetSubElementNameLength(rs_element e, uint32_t index); + +/** + * @param e element to get data from + * @param index index of the sub-element + * @param name array to store the name into + * @param nameLength length of the provided name array + * @return number of characters written + */ +extern uint32_t __attribute__((overloadable)) + rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength); + +/** + * @param e element to get data from + * @param index index of the sub-element + * @return array size of sub-element in this element at given + * index + */ +extern uint32_t __attribute__((overloadable)) + rsElementGetSubElementArraySize(rs_element e, uint32_t index); + +/** + * @param e element to get data from + * @param index index of the sub-element + * @return offset in bytes of sub-element in this element at + * given index + */ +extern uint32_t __attribute__((overloadable)) + rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index); + +/** + * @param e element to get data from + * @return total size of the element in bytes + */ +extern uint32_t __attribute__((overloadable)) + rsElementGetSizeBytes(rs_element e); + +/** + * @param e element to get data from + * @return element's data type + */ +extern rs_data_type __attribute__((overloadable)) + rsElementGetDataType(rs_element e); + +/** + * @param e element to get data from + * @return element's data size + */ +extern rs_data_kind __attribute__((overloadable)) + rsElementGetDataKind(rs_element e); + #endif diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh index 5c468bf..247ba8f 100644 --- a/libs/rs/scriptc/rs_types.rsh +++ b/libs/rs/scriptc/rs_types.rsh @@ -400,6 +400,8 @@ typedef enum { RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010 } rs_allocation_usage_type; +#endif //defined(RS_VERSION) && (RS_VERSION >= 14) + typedef enum { RS_PRIMITIVE_POINT, RS_PRIMITIVE_LINE, @@ -409,6 +411,77 @@ typedef enum { RS_PRIMITIVE_TRIANGLE_FAN } rs_primitive; -#endif //defined(RS_VERSION) && (RS_VERSION >= 14) +/** + * \brief Enumeration for possible element data types + * + * DataType represents the basic type information for a basic element. The + * naming convention follows. For numeric types it is FLOAT, + * SIGNED, or UNSIGNED followed by the _BITS where BITS is the + * size of the data. BOOLEAN is a true / false (1,0) + * represented in an 8 bit container. The UNSIGNED variants + * with multiple bit definitions are for packed graphical data + * formats and represent vectors with per vector member sizes + * which are treated as a single unit for packing and alignment + * purposes. + * + * MATRIX the three matrix types contain FLOAT_32 elements and are treated + * as 32 bits for alignment purposes. + * + * RS_* objects. 32 bit opaque handles. + */ +typedef enum { + RS_TYPE_NONE, + RS_TYPE_FLOAT_16, + RS_TYPE_FLOAT_32, + RS_TYPE_FLOAT_64, + RS_TYPE_SIGNED_8, + RS_TYPE_SIGNED_16, + RS_TYPE_SIGNED_32, + RS_TYPE_SIGNED_64, + RS_TYPE_UNSIGNED_8, + RS_TYPE_UNSIGNED_16, + RS_TYPE_UNSIGNED_32, + RS_TYPE_UNSIGNED_64, + + RS_TYPE_BOOLEAN, + + RS_TYPE_UNSIGNED_5_6_5, + RS_TYPE_UNSIGNED_5_5_5_1, + RS_TYPE_UNSIGNED_4_4_4_4, + + RS_TYPE_MATRIX_4X4, + RS_TYPE_MATRIX_3X3, + RS_TYPE_MATRIX_2X2, + + RS_TYPE_ELEMENT = 1000, + RS_TYPE_TYPE, + RS_TYPE_ALLOCATION, + RS_TYPE_SAMPLER, + RS_TYPE_SCRIPT, + RS_TYPE_MESH, + RS_TYPE_PROGRAM_FRAGMENT, + RS_TYPE_PROGRAM_VERTEX, + RS_TYPE_PROGRAM_RASTER, + RS_TYPE_PROGRAM_STORE, +} rs_data_type; + +/** + * \brief Enumeration for possible element data kind + * + * The special interpretation of the data if required. This is primarly + * useful for graphical data. USER indicates no special interpretation is + * expected. PIXEL is used in conjunction with the standard data types for + * representing texture formats. + */ +typedef enum { + RS_KIND_USER, + + RS_KIND_PIXEL_L = 7, + RS_KIND_PIXEL_A, + RS_KIND_PIXEL_LA, + RS_KIND_PIXEL_RGB, + RS_KIND_PIXEL_RGBA, + RS_KIND_PIXEL_DEPTH, +} rs_data_kind; #endif diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs index 4b85d72..8187fbc 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs @@ -150,8 +150,14 @@ static void sortToBucket(SgRenderable *obj) { } const SgRenderState *renderState = (const SgRenderState *)rsGetElementAt(obj->render_state, 0); if (rsIsObject(renderState->ps)) { - if ((rsgProgramStoreGetBlendSrcFunc(renderState->ps) == RS_BLEND_SRC_ONE) && - (rsgProgramStoreGetBlendDstFunc(renderState->ps) == RS_BLEND_DST_ZERO)) { +#define MR1_API +#ifndef MR1_API + bool isOpaque = (rsgProgramStoreGetBlendSrcFunc(renderState->ps) == RS_BLEND_SRC_ONE) && + (rsgProgramStoreGetBlendDstFunc(renderState->ps) == RS_BLEND_DST_ZERO); +#else + bool isOpaque = false; +#endif + if (isOpaque) { gFrontToBack[gFrontToBackCount++] = (uint32_t)obj; } else { gBackToFront[gBackToFrontCount++] = (uint32_t)obj; |