summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Sakhartchouk <alexst@google.com> 2011-04-06 10:57:51 -0700
committer Jason Sams <rjsams@android.com> 2011-04-25 14:30:27 -0700
commite7c4a7565c7f8c8fc1ec92dc0692577fcc474750 (patch)
treed43d472a9207a28ff03141e6920a21fc6012b44c
parent466e3a22db283958a1da71cc60a23ce3976a3659 (diff)
Modifying libRS internal communication to handle network rendering.
Change-Id: I8c8b3cc3402ecf4ba774e1d668dce25ff0af0e5a
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp36
-rw-r--r--libs/rs/rs.spec31
-rw-r--r--libs/rs/rsAllocation.cpp2
-rw-r--r--libs/rs/rsContext.cpp6
-rw-r--r--libs/rs/rsElement.cpp9
-rw-r--r--libs/rs/rsFont.cpp11
-rw-r--r--libs/rs/rsHandcode.h16
-rw-r--r--libs/rs/rsScriptC.cpp7
-rw-r--r--libs/rs/spec.l14
9 files changed, 72 insertions, 60 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index c6c86b23e4d1..b7528506087c 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -197,7 +197,7 @@ nContextSetSurface(JNIEnv *_env, jobject _this, RsContext con, jint width, jint
window = (Surface*) android_Surface_getNativeWindow(_env, wnd).get();
}
- rsContextSetSurface(con, width, height, window);
+ rsContextSetSurface(con, width, height, window, 1);
}
static void
@@ -309,7 +309,11 @@ nElementCreate2(JNIEnv *_env, jobject _this, RsContext con, jintArray _ids, jobj
nameArray[ct] = _env->GetStringUTFChars(s, NULL);
sizeArray[ct] = _env->GetStringUTFLength(s);
}
- jint id = (jint)rsElementCreate2(con, fieldCount, (RsElement *)ids, nameArray, sizeArray, (const uint32_t *)arraySizes);
+ jint id = (jint)rsElementCreate2(con,
+ (RsElement *)ids, fieldCount,
+ nameArray, fieldCount,
+ sizeArray, fieldCount,
+ (const uint32_t *)arraySizes, fieldCount);
for (int ct=0; ct < fieldCount; ct++) {
jstring s = (jstring)_env->GetObjectArrayElement(_names, ct);
_env->ReleaseStringUTFChars(s, nameArray[ct]);
@@ -579,7 +583,8 @@ nAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintAr
jint len = _env->GetArrayLength(data);
LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocationRead(con, (RsAllocation)alloc, ptr);
+ jsize length = _env->GetArrayLength(data);
+ rsAllocationRead(con, (RsAllocation)alloc, ptr, length);
_env->ReleaseIntArrayElements(data, ptr, 0);
}
@@ -589,7 +594,8 @@ nAllocationRead_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jshort
jint len = _env->GetArrayLength(data);
LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
jshort *ptr = _env->GetShortArrayElements(data, NULL);
- rsAllocationRead(con, (RsAllocation)alloc, ptr);
+ jsize length = _env->GetArrayLength(data);
+ rsAllocationRead(con, (RsAllocation)alloc, ptr, length);
_env->ReleaseShortArrayElements(data, ptr, 0);
}
@@ -599,7 +605,8 @@ nAllocationRead_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jbyteA
jint len = _env->GetArrayLength(data);
LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocationRead(con, (RsAllocation)alloc, ptr);
+ jsize length = _env->GetArrayLength(data);
+ rsAllocationRead(con, (RsAllocation)alloc, ptr, length);
_env->ReleaseByteArrayElements(data, ptr, 0);
}
@@ -609,7 +616,8 @@ nAllocationRead_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jfloat
jint len = _env->GetArrayLength(data);
LOG_API("nAllocationRead_f, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocationRead(con, (RsAllocation)alloc, ptr);
+ jsize length = _env->GetArrayLength(data);
+ rsAllocationRead(con, (RsAllocation)alloc, ptr, length);
_env->ReleaseFloatArrayElements(data, ptr, 0);
}
@@ -713,7 +721,9 @@ nFontCreateFromFile(JNIEnv *_env, jobject _this, RsContext con,
jstring fileName, jfloat fontSize, jint dpi)
{
AutoJavaStringToUTF8 fileNameUTF(_env, fileName);
- jint id = (jint)rsFontCreateFromFile(con, fileNameUTF.c_str(), fontSize, dpi);
+ jint id = (jint)rsFontCreateFromFile(con,
+ fileNameUTF.c_str(), fileNameUTF.length(),
+ fontSize, dpi);
return id;
}
@@ -725,7 +735,9 @@ nFontCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con,
Asset* asset = reinterpret_cast<Asset*>(native_asset);
AutoJavaStringToUTF8 nameUTF(_env, name);
- jint id = (jint)rsFontCreateFromMemory(con, nameUTF.c_str(), fontSize, dpi,
+ jint id = (jint)rsFontCreateFromMemory(con,
+ nameUTF.c_str(), nameUTF.length(),
+ fontSize, dpi,
asset->getBuffer(false), asset->getLength());
return id;
}
@@ -745,7 +757,9 @@ nFontCreateFromAsset(JNIEnv *_env, jobject _this, RsContext con, jobject _assetM
return 0;
}
- jint id = (jint)rsFontCreateFromMemory(con, str.c_str(), fontSize, dpi,
+ jint id = (jint)rsFontCreateFromMemory(con,
+ str.c_str(), str.length(),
+ fontSize, dpi,
asset->getBuffer(false), asset->getLength());
delete asset;
return id;
@@ -877,7 +891,9 @@ nScriptCCreate(JNIEnv *_env, jobject _this, RsContext con,
//rsScriptCSetText(con, (const char *)script_ptr, length);
- ret = (jint)rsScriptCCreate(con, resNameUTF.c_str(), cacheDirUTF.c_str(),
+ ret = (jint)rsScriptCCreate(con,
+ resNameUTF.c_str(), resNameUTF.length(),
+ cacheDirUTF.c_str(), cacheDirUTF.length(),
(const char *)script_ptr, length);
exit:
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index a7f473c4f3a4..dac5cec06acc 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -51,9 +51,8 @@ ContextDestroyWorker {
}
AssignName {
- param void *obj
+ param RsObjectBase obj
param const char *name
- param size_t len
}
ObjDestroy {
@@ -69,7 +68,6 @@ ElementCreate {
}
ElementCreate2 {
- param size_t count
param const RsElement * elements
param const char ** names
param const size_t * nameLengths
@@ -80,7 +78,6 @@ ElementCreate2 {
AllocationCopyToBitmap {
param RsAllocation alloc
param void * data
- param size_t dataLen
}
@@ -90,7 +87,6 @@ Allocation1DData {
param uint32_t lod
param uint32_t count
param const void *data
- param uint32_t bytes
handcodeApi
togglePlay
}
@@ -101,7 +97,6 @@ Allocation1DElementData {
param uint32_t lod
param const void *data
param uint32_t comp_offset
- param uint32_t bytes
handcodeApi
togglePlay
}
@@ -115,7 +110,6 @@ Allocation2DData {
param uint32_t w
param uint32_t h
param const void *data
- param uint32_t bytes
}
Allocation2DElementData {
@@ -126,7 +120,6 @@ Allocation2DElementData {
param RsAllocationCubemapFace face
param const void *data
param uint32_t element_offset
- param uint32_t bytes
}
AllocationGenerateMipmaps {
@@ -184,7 +177,6 @@ ScriptBindAllocation {
ScriptSetTimeZone {
param RsScript s
param const char * timeZone
- param uint32_t length
}
@@ -197,7 +189,6 @@ ScriptInvokeV {
param RsScript s
param uint32_t slot
param const void * data
- param uint32_t dataLen
handcodeApi
togglePlay
}
@@ -236,7 +227,6 @@ ScriptSetVarV {
param RsScript s
param uint32_t slot
param const void * data
- param uint32_t dataLen
handcodeApi
togglePlay
}
@@ -246,7 +236,6 @@ ScriptCCreate {
param const char * resName
param const char * cacheDir
param const char * text
- param uint32_t length
ret RsScript
}
@@ -294,17 +283,13 @@ ProgramBindSampler {
ProgramFragmentCreate {
param const char * shaderText
- param uint32_t shaderLength
param const uint32_t * params
- param uint32_t paramLength
ret RsProgramFragment
}
ProgramVertexCreate {
param const char * shaderText
- param uint32_t shaderLength
param const uint32_t * params
- param uint32_t paramLength
ret RsProgramVertex
}
@@ -319,8 +304,7 @@ FontCreateFromMemory {
param const char *name
param float fontSize
param uint32_t dpi
- param const void *data
- param uint32_t dataLen
+ param const void *data
ret RsFont
}
@@ -346,14 +330,3 @@ MeshBindVertex {
MeshInitVertexAttribs {
param RsMesh mesh
}
-
-AnimationCreate {
- param const float *inValues
- param const float *outValues
- param uint32_t valueCount
- param RsAnimationInterpolation interp
- param RsAnimationEdge pre
- param RsAnimationEdge post
- ret RsAnimation
- }
-
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 6b37e035b4a7..a75900429006 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -780,7 +780,7 @@ void rsi_Allocation2DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t
a->data(rsc, xoff, yoff, lod, face, w, h, data, sizeBytes);
}
-void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data) {
+void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data, size_t data_length) {
Allocation *a = static_cast<Allocation *>(va);
a->read(data);
}
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 20fa3672c03f..0ca892d7eb68 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -705,9 +705,9 @@ void rsi_ContextBindFont(Context *rsc, RsFont vfont) {
rsc->setFont(font);
}
-void rsi_AssignName(Context *rsc, void * obj, const char *name, uint32_t len) {
+void rsi_AssignName(Context *rsc, RsObjectBase obj, const char *name, uint32_t name_length) {
ObjectBase *ob = static_cast<ObjectBase *>(obj);
- rsc->assignName(ob, name, len);
+ rsc->assignName(ob, name, name_length);
}
void rsi_ObjDestroy(Context *rsc, void *optr) {
@@ -724,7 +724,7 @@ void rsi_ContextResume(Context *rsc) {
rsc->resume();
}
-void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur) {
+void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur, size_t sur_length) {
rsc->setSurface(w, h, sur);
}
diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp
index 477cb6166b21..d5d5ca5c9032 100644
--- a/libs/rs/rsElement.cpp
+++ b/libs/rs/rsElement.cpp
@@ -348,12 +348,15 @@ RsElement rsi_ElementCreate(Context *rsc,
}
RsElement rsi_ElementCreate2(Context *rsc,
- size_t count,
const RsElement * ein,
+ size_t ein_length,
const char ** names,
+ size_t names_length,
const size_t * nameLengths,
- const uint32_t * arraySizes) {
- const Element *e = Element::create(rsc, count, (const Element **)ein, names, nameLengths, arraySizes);
+ size_t nameLengths_length,
+ const uint32_t * arraySizes,
+ size_t arraySizes_length) {
+ const Element *e = Element::create(rsc, ein_length, (const Element **)ein, names, nameLengths, arraySizes);
e->incUserRef();
return (RsElement)e;
}
diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp
index c30b8573a872..b7b85b68372a 100644
--- a/libs/rs/rsFont.cpp
+++ b/libs/rs/rsFont.cpp
@@ -827,7 +827,9 @@ bool FontState::CacheTextureLine::fitBitmap(FT_Bitmap_ *bitmap, uint32_t *retOri
namespace android {
namespace renderscript {
-RsFont rsi_FontCreateFromFile(Context *rsc, char const *name, float fontSize, uint32_t dpi) {
+RsFont rsi_FontCreateFromFile(Context *rsc,
+ char const *name, size_t name_length,
+ float fontSize, uint32_t dpi) {
Font *newFont = Font::create(rsc, name, fontSize, dpi);
if (newFont) {
newFont->incUserRef();
@@ -835,8 +837,11 @@ RsFont rsi_FontCreateFromFile(Context *rsc, char const *name, float fontSize, ui
return newFont;
}
-RsFont rsi_FontCreateFromMemory(Context *rsc, char const *name, float fontSize, uint32_t dpi, const void *data, uint32_t dataLen) {
- Font *newFont = Font::create(rsc, name, fontSize, dpi, data, dataLen);
+RsFont rsi_FontCreateFromMemory(Context *rsc,
+ char const *name, size_t name_length,
+ float fontSize, uint32_t dpi,
+ const void *data, size_t data_length) {
+ Font *newFont = Font::create(rsc, name, fontSize, dpi, data, data_length);
if (newFont) {
newFont->incUserRef();
}
diff --git a/libs/rs/rsHandcode.h b/libs/rs/rsHandcode.h
index 57da10a65b1f..da51d95b4e27 100644
--- a/libs/rs/rsHandcode.h
+++ b/libs/rs/rsHandcode.h
@@ -7,7 +7,7 @@ static inline void rsHCAPI_ContextFinish (RsContext rsc) {
io->mToCore.commitSync(RS_CMD_ID_ContextFinish, size);
}
-static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) {
+static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, size_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_ScriptInvokeV);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -16,7 +16,7 @@ static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t s
RS_CMD_ScriptInvokeV *cmd = static_cast<RS_CMD_ScriptInvokeV *>(io->mToCore.reserve(size));
cmd->s = va;
cmd->slot = slot;
- cmd->dataLen = sizeBytes;
+ cmd->data_length = sizeBytes;
cmd->data = data;
if (sizeBytes < DATA_SYNC_SIZE) {
cmd->data = (void *)(cmd+1);
@@ -28,7 +28,7 @@ static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t s
}
-static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) {
+static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, size_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_ScriptSetVarV);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -37,7 +37,7 @@ static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t s
RS_CMD_ScriptSetVarV *cmd = static_cast<RS_CMD_ScriptSetVarV *>(io->mToCore.reserve(size));
cmd->s = va;
cmd->slot = slot;
- cmd->dataLen = sizeBytes;
+ cmd->data_length = sizeBytes;
cmd->data = data;
if (sizeBytes < DATA_SYNC_SIZE) {
cmd->data = (void *)(cmd+1);
@@ -49,7 +49,7 @@ static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t s
}
static inline void rsHCAPI_Allocation1DData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t lod,
- uint32_t count, const void * data, uint32_t sizeBytes) {
+ uint32_t count, const void * data, size_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_Allocation1DData);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -61,7 +61,7 @@ static inline void rsHCAPI_Allocation1DData (RsContext rsc, RsAllocation va, uin
cmd->lod = lod;
cmd->count = count;
cmd->data = data;
- cmd->bytes = sizeBytes;
+ cmd->data_length = sizeBytes;
if (sizeBytes < DATA_SYNC_SIZE) {
cmd->data = (void *)(cmd+1);
memcpy(cmd+1, data, sizeBytes);
@@ -72,7 +72,7 @@ static inline void rsHCAPI_Allocation1DData (RsContext rsc, RsAllocation va, uin
}
static inline void rsHCAPI_Allocation1DElementData (RsContext rsc, RsAllocation va, uint32_t x, uint32_t lod,
- const void * data, uint32_t comp_offset, uint32_t sizeBytes) {
+ const void * data, size_t sizeBytes, uint32_t comp_offset) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_Allocation1DElementData);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -84,7 +84,7 @@ static inline void rsHCAPI_Allocation1DElementData (RsContext rsc, RsAllocation
cmd->lod = lod;
cmd->data = data;
cmd->comp_offset = comp_offset;
- cmd->bytes = sizeBytes;
+ cmd->data_length = sizeBytes;
if (sizeBytes < DATA_SYNC_SIZE) {
cmd->data = (void *)(cmd+1);
memcpy(cmd+1, data, sizeBytes);
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index c379b8bab48c..6d0701d18720 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -267,12 +267,13 @@ namespace android {
namespace renderscript {
RsScript rsi_ScriptCCreate(Context *rsc,
- const char *resName, const char *cacheDir,
- const char *text, uint32_t len)
+ const char *resName, size_t resName_length,
+ const char *cacheDir, size_t cacheDir_length,
+ const char *text, uint32_t text_length)
{
ScriptC *s = new ScriptC(rsc);
- if (!s->runCompiler(rsc, resName, cacheDir, (uint8_t *)text, len)) {
+ if (!s->runCompiler(rsc, resName, cacheDir, (uint8_t *)text, text_length)) {
// Error during compile, destroy s and return null.
delete s;
return NULL;
diff --git a/libs/rs/spec.l b/libs/rs/spec.l
index 6a9010fe822a..c8af89167e1b 100644
--- a/libs/rs/spec.l
+++ b/libs/rs/spec.l
@@ -20,6 +20,19 @@ ID [a-zA-Z_][a-zA-Z0-9_]*
int typeNextState;
+ void checkPointerType() {
+ VarType *lastType = currType;
+ if (lastType->ptrLevel) {
+ currType = &apis[apiCount].params[apis[apiCount].paramCount];
+ currType->type = 4;
+ sprintf(currType->typeName, "%s", "size_t");
+ if (lastType->name[0]) {
+ sprintf(currType->name, "%s_length", lastType->name);
+ }
+ apis[apiCount].paramCount++;
+ }
+ }
+
extern "C" int yylex();
%%
@@ -145,6 +158,7 @@ ID [a-zA-Z_][a-zA-Z0-9_]*
<api_entry_param>{ID} {
memcpy(currType->name, yytext, yyleng);
+ checkPointerType();
BEGIN(api_entry2);
}