summaryrefslogtreecommitdiffstats
path: root/libs/rs
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2011-04-27 13:20:39 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-04-27 13:20:39 -0700
commit36f873c765fee84ec26b0e21021ef4c6edc78123 (patch)
treef5c355ca532e2a737be3deea6b51b6c1075b1480 /libs/rs
parentc7d1d6288ee097e97560ab01f3d0953014ce3cf7 (diff)
parent65bdaf1c6d463d9441125d2c87a36015bfef2d95 (diff)
downloadframeworks_base-36f873c765fee84ec26b0e21021ef4c6edc78123.zip
frameworks_base-36f873c765fee84ec26b0e21021ef4c6edc78123.tar.gz
frameworks_base-36f873c765fee84ec26b0e21021ef4c6edc78123.tar.bz2
Merge "Cleanup rs.spec file and code generator."
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/RenderScript.h28
-rw-r--r--libs/rs/rs.spec119
-rw-r--r--libs/rs/rsAllocation.cpp4
-rw-r--r--libs/rs/rsContext.cpp12
-rw-r--r--libs/rs/rsg_generator.c60
-rw-r--r--libs/rs/spec.h3
-rw-r--r--libs/rs/spec.l9
7 files changed, 171 insertions, 64 deletions
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h
index cb6d7e0..f4e3f57 100644
--- a/libs/rs/RenderScript.h
+++ b/libs/rs/RenderScript.h
@@ -26,20 +26,6 @@ extern "C" {
#include "RenderScriptDefines.h"
-RsDevice rsDeviceCreate();
-void rsDeviceDestroy(RsDevice);
-void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value);
-
-RsContext rsContextCreate(RsDevice, uint32_t version);
-RsContext rsContextCreateGL(RsDevice, uint32_t version,
- RsSurfaceConfig sc, uint32_t dpi);
-void rsContextDestroy(RsContext);
-
-RsMessageToClientType rsContextGetMessage(RsContext vrsc, void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait);
-RsMessageToClientType rsContextPeekMessage(RsContext vrsc, size_t *receiveLen, uint32_t *subID, bool wait);
-void rsContextInitToClient(RsContext);
-void rsContextDeinitToClient(RsContext);
-
//
// A3D loading and object update code.
// Should only be called at object creation, not thread safe
@@ -63,18 +49,8 @@ void rsaTypeGetNativeData(RsContext, RsType, uint32_t *typeData, uint32_t typeDa
void rsaElementGetNativeData(RsContext, RsElement, uint32_t *elemData, uint32_t elemDataSize);
void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char **names, uint32_t dataSize);
-// Async commands for returning new IDS
-RsType rsaTypeCreate(RsContext, RsElement, uint32_t dimX, uint32_t dimY,
- uint32_t dimZ, bool mips, bool faces);
-RsAllocation rsaAllocationCreateTyped(RsContext rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- uint32_t usages);
-RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype,
- RsAllocationMipmapControl mips,
- const void *data, uint32_t usages);
-RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype,
- RsAllocationMipmapControl mips,
- const void *data, uint32_t usages);
+
+
#ifdef ANDROID_RS_SERIALIZE
#define NO_RS_FUNCS
#endif
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index dac5cec..998296b 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -1,4 +1,110 @@
+DeviceCreate {
+ direct
+ nocontext
+ ret RsDevice
+}
+
+DeviceDestroy {
+ direct
+ nocontext
+ param RsDevice dev
+}
+
+DeviceSetConfig {
+ direct
+ nocontext
+ param RsDevice dev
+ param RsDeviceParam p
+ param int32_t value
+}
+
+ContextCreate {
+ direct
+ nocontext
+ param RsDevice dev
+ param uint32_t version
+ ret RsContext
+}
+
+ContextCreateGL {
+ direct
+ nocontext
+ param RsDevice dev
+ param uint32_t version
+ param RsSurfaceConfig sc
+ param uint32_t dpi
+ ret RsContext
+}
+
+ContextDestroy {
+ direct
+}
+
+ContextGetMessage {
+ direct
+ param void *data
+ param size_t *receiveLen
+ param uint32_t *subID
+ param bool wait
+ ret RsMessageToClientType
+}
+
+ContextPeekMessage {
+ direct
+ param size_t *receiveLen
+ param uint32_t *subID
+ param bool wait
+ ret RsMessageToClientType
+}
+
+ContextInitToClient {
+ direct
+}
+
+ContextDeinitToClient {
+ direct
+}
+
+aTypeCreate {
+ direct
+ param RsElement e
+ param uint32_t dimX
+ param uint32_t dimY
+ param uint32_t dimZ
+ param bool mips
+ param bool faces
+ ret RsType
+}
+
+aAllocationCreateTyped {
+ direct
+ param RsType vtype
+ param RsAllocationMipmapControl mips
+ param uint32_t usages
+ ret RsAllocation
+}
+
+aAllocationCreateFromBitmap {
+ direct
+ param RsType vtype
+ param RsAllocationMipmapControl mips
+ param const void *data
+ param uint32_t usages
+ ret RsAllocation
+}
+
+aAllocationCubeCreateFromBitmap {
+ direct
+ param RsType vtype
+ param RsAllocationMipmapControl mips
+ param const void *data
+ param uint32_t usages
+ ret RsAllocation
+}
+
+
+
ContextFinish {
handcodeApi
}
@@ -82,23 +188,21 @@ AllocationCopyToBitmap {
Allocation1DData {
+ handcodeApi
param RsAllocation va
param uint32_t xoff
param uint32_t lod
param uint32_t count
param const void *data
- handcodeApi
- togglePlay
}
Allocation1DElementData {
+ handcodeApi
param RsAllocation va
param uint32_t x
param uint32_t lod
param const void *data
param uint32_t comp_offset
- handcodeApi
- togglePlay
}
Allocation2DData {
@@ -186,11 +290,10 @@ ScriptInvoke {
}
ScriptInvokeV {
+ handcodeApi
param RsScript s
param uint32_t slot
param const void * data
- handcodeApi
- togglePlay
}
ScriptSetVarI {
@@ -224,11 +327,10 @@ ScriptSetVarD {
}
ScriptSetVarV {
+ handcodeApi
param RsScript s
param uint32_t slot
param const void * data
- handcodeApi
- togglePlay
}
@@ -330,3 +432,4 @@ MeshBindVertex {
MeshInitVertexAttribs {
param RsMesh mesh
}
+
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index a759004..743b2c4 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -833,7 +833,7 @@ RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype,
RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype,
RsAllocationMipmapControl mips,
- const void *data, uint32_t usages) {
+ const void *data, size_t data_length, uint32_t usages) {
Context *rsc = static_cast<Context *>(con);
Type *t = static_cast<Type *>(vtype);
@@ -855,7 +855,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype,
RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype,
RsAllocationMipmapControl mips,
- const void *data, uint32_t usages) {
+ const void *data, size_t data_length, uint32_t usages) {
Context *rsc = static_cast<Context *>(con);
Type *t = static_cast<Type *>(vtype);
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 0ca892d..50f5f55 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -768,14 +768,20 @@ RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
return rsc;
}
-RsMessageToClientType rsContextPeekMessage(RsContext vrsc, size_t *receiveLen, uint32_t *subID, bool wait) {
+RsMessageToClientType rsContextPeekMessage(RsContext vrsc,
+ size_t * receiveLen, size_t receiveLen_length,
+ uint32_t * subID, size_t subID_length, bool wait) {
Context * rsc = static_cast<Context *>(vrsc);
return rsc->peekMessageToClient(receiveLen, subID, wait);
}
-RsMessageToClientType rsContextGetMessage(RsContext vrsc, void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait) {
+RsMessageToClientType rsContextGetMessage(RsContext vrsc, void * data, size_t data_length,
+ size_t * receiveLen, size_t receiveLen_length,
+ uint32_t * subID, size_t subID_length, bool wait) {
Context * rsc = static_cast<Context *>(vrsc);
- return rsc->getMessageToClient(data, receiveLen, subID, bufferLen, wait);
+ rsAssert(subID_length == sizeof(uint32_t));
+ rsAssert(receiveLen_length == sizeof(size_t));
+ return rsc->getMessageToClient(data, receiveLen, subID, data_length, wait);
}
void rsContextInitToClient(RsContext vrsc) {
diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c
index 4ac5b7f..14b380a 100644
--- a/libs/rs/rsg_generator.c
+++ b/libs/rs/rsg_generator.c
@@ -4,7 +4,7 @@
void printFileHeader(FILE *f) {
fprintf(f, "/*\n");
- fprintf(f, " * Copyright (C) 2010 The Android Open Source Project\n");
+ fprintf(f, " * Copyright (C) 2011 The Android Open Source Project\n");
fprintf(f, " *\n");
fprintf(f, " * Licensed under the Apache License, Version 2.0 (the \"License\");\n");
fprintf(f, " * you may not use this file except in compliance with the License.\n");
@@ -96,12 +96,14 @@ void printStructures(FILE *f) {
void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext) {
printVarType(f, &api->ret);
fprintf(f, " %s%s (", prefix, api->name);
- if (addContext) {
- fprintf(f, "Context *");
- } else {
- fprintf(f, "RsContext rsc");
+ if (!api->nocontext) {
+ if (addContext) {
+ fprintf(f, "Context *");
+ } else {
+ fprintf(f, "RsContext rsc");
+ }
}
- printArgList(f, api, 1);
+ printArgList(f, api, !api->nocontext);
fprintf(f, ")");
}
@@ -117,6 +119,10 @@ void printFuncDecls(FILE *f, const char *prefix, int addContext) {
void printPlaybackFuncs(FILE *f, const char *prefix) {
int ct;
for (ct=0; ct < apiCount; ct++) {
+ if (apis[ct].direct) {
+ continue;
+ }
+
fprintf(f, "void %s%s (Context *, const void *);\n", prefix, apis[ct].name);
}
}
@@ -140,6 +146,10 @@ void printApiCpp(FILE *f) {
int needFlush = 0;
const ApiEntry * api = &apis[ct];
+ if (api->direct) {
+ continue;
+ }
+
printFuncDecl(f, api, "rs", 0);
fprintf(f, "\n{\n");
if (api->handcodeApi) {
@@ -198,31 +208,37 @@ void printPlaybackCpp(FILE *f) {
for (ct=0; ct < apiCount; ct++) {
const ApiEntry * api = &apis[ct];
+ if (api->direct) {
+ continue;
+ }
+
fprintf(f, "void rsp_%s(Context *con, const void *vp)\n", api->name);
fprintf(f, "{\n");
- if (api->handcodePlay) {
- fprintf(f, " rsHCPLAY_%s(con, vp);\n", api->name);
- } else {
- //fprintf(f, " LOGE(\"play command %s\\n\");\n", api->name);
- fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "con->mIO.mToCoreRet = (intptr_t)");
- }
- fprintf(f, "rsi_%s(con", api->name);
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- fprintf(f, ",\n cmd->%s", vt->name);
- }
- fprintf(f, ");\n");
+
+ //fprintf(f, " LOGE(\"play command %s\\n\");\n", api->name);
+ fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
+ fprintf(f, " ");
+ if (api->ret.typeName[0]) {
+ fprintf(f, "con->mIO.mToCoreRet = (intptr_t)");
}
+ fprintf(f, "rsi_%s(con", api->name);
+ for (ct2=0; ct2 < api->paramCount; ct2++) {
+ const VarType *vt = &api->params[ct2];
+ fprintf(f, ",\n cmd->%s", vt->name);
+ }
+ fprintf(f, ");\n");
+
fprintf(f, "};\n\n");
}
fprintf(f, "RsPlaybackFunc gPlaybackFuncs[%i] = {\n", apiCount + 1);
fprintf(f, " NULL,\n");
for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " %s%s,\n", "rsp_", apis[ct].name);
+ if (apis[ct].direct) {
+ fprintf(f, " NULL,\n");
+ } else {
+ fprintf(f, " %s%s,\n", "rsp_", apis[ct].name);
+ }
}
fprintf(f, "};\n");
diff --git a/libs/rs/spec.h b/libs/rs/spec.h
index 82650a7..ecc5cc7 100644
--- a/libs/rs/spec.h
+++ b/libs/rs/spec.h
@@ -25,7 +25,8 @@ typedef struct {
char name[256];
int sync;
int handcodeApi;
- int handcodePlay;
+ int direct;
+ int nocontext;
int paramCount;
VarType ret;
VarType params[16];
diff --git a/libs/rs/spec.l b/libs/rs/spec.l
index c8af891..dcd4435 100644
--- a/libs/rs/spec.l
+++ b/libs/rs/spec.l
@@ -44,6 +44,7 @@ ID [a-zA-Z_][a-zA-Z0-9_]*
<comment>"*"+"/" BEGIN(INITIAL);
<*>" " //printf("found ' '\n");
+<*>"\t" //printf("found ' '\n");
<*>"\n" ++num_lines; //printf("found lf \n");
{ID} {
@@ -64,8 +65,12 @@ ID [a-zA-Z_][a-zA-Z0-9_]*
apis[apiCount].handcodeApi = 1;
}
-<api_entry2>"handcodePlay" {
- apis[apiCount].handcodePlay = 1;
+<api_entry2>"direct" {
+ apis[apiCount].direct = 1;
+ }
+
+<api_entry2>"nocontext" {
+ apis[apiCount].nocontext = 1;
}
<api_entry2>"ret" {