Merge "Cleanup rs.spec file and code generator."
This commit is contained in:
@@ -237,7 +237,11 @@ nContextGetErrorMessage(JNIEnv *_env, jobject _this, RsContext con)
|
||||
|
||||
size_t receiveLen;
|
||||
uint32_t subID;
|
||||
int id = rsContextGetMessage(con, buf, &receiveLen, &subID, sizeof(buf), true);
|
||||
int id = rsContextGetMessage(con,
|
||||
buf, sizeof(buf),
|
||||
&receiveLen, sizeof(receiveLen),
|
||||
&subID, sizeof(subID),
|
||||
true);
|
||||
if (!id && receiveLen) {
|
||||
LOGV("message receive buffer too small. %i", receiveLen);
|
||||
}
|
||||
@@ -252,7 +256,11 @@ nContextGetUserMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray dat
|
||||
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
||||
size_t receiveLen;
|
||||
uint32_t subID;
|
||||
int id = rsContextGetMessage(con, ptr, &receiveLen, &subID, len * 4, true);
|
||||
int id = rsContextGetMessage(con,
|
||||
ptr, len * 4,
|
||||
&receiveLen, sizeof(receiveLen),
|
||||
&subID, sizeof(subID),
|
||||
true);
|
||||
if (!id && receiveLen) {
|
||||
LOGV("message receive buffer too small. %i", receiveLen);
|
||||
}
|
||||
@@ -266,7 +274,8 @@ nContextPeekMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray auxDat
|
||||
jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL);
|
||||
size_t receiveLen;
|
||||
uint32_t subID;
|
||||
int id = rsContextPeekMessage(con, &receiveLen, &subID, wait);
|
||||
int id = rsContextPeekMessage(con, &receiveLen, sizeof(receiveLen),
|
||||
&subID, sizeof(subID), wait);
|
||||
auxDataPtr[0] = (jint)subID;
|
||||
auxDataPtr[1] = (jint)receiveLen;
|
||||
_env->ReleaseIntArrayElements(auxData, auxDataPtr, 0);
|
||||
@@ -426,7 +435,9 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint typ
|
||||
|
||||
bitmap.lockPixels();
|
||||
const void* ptr = bitmap.getPixels();
|
||||
jint id = (jint)rsaAllocationCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapControl)mip, ptr, usage);
|
||||
jint id = (jint)rsaAllocationCreateFromBitmap(con,
|
||||
(RsType)type, (RsAllocationMipmapControl)mip,
|
||||
ptr, bitmap.getSize(), usage);
|
||||
bitmap.unlockPixels();
|
||||
return id;
|
||||
}
|
||||
@@ -440,7 +451,9 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint
|
||||
|
||||
bitmap.lockPixels();
|
||||
const void* ptr = bitmap.getPixels();
|
||||
jint id = (jint)rsaAllocationCubeCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapControl)mip, ptr, usage);
|
||||
jint id = (jint)rsaAllocationCubeCreateFromBitmap(con,
|
||||
(RsType)type, (RsAllocationMipmapControl)mip,
|
||||
ptr, bitmap.getSize(), usage);
|
||||
bitmap.unlockPixels();
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
119
libs/rs/rs.spec
119
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
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user