Modifying libRS internal communication to handle network rendering.

Change-Id: I8c8b3cc3402ecf4ba774e1d668dce25ff0af0e5a
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index a7f473c..dac5cec 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -51,9 +51,8 @@
 }
 
 AssignName {
-	param void *obj
+	param RsObjectBase obj
 	param const char *name
-	param size_t len
 	}
 
 ObjDestroy {
@@ -69,7 +68,6 @@
 	}
 
 ElementCreate2 {
-	param size_t count
 	param const RsElement * elements
 	param const char ** names
 	param const size_t * nameLengths
@@ -80,7 +78,6 @@
 AllocationCopyToBitmap {
 	param RsAllocation alloc
 	param void * data
-	param size_t dataLen
 	}
 
 
@@ -90,7 +87,6 @@
 	param uint32_t lod
 	param uint32_t count
 	param const void *data
-	param uint32_t bytes
 	handcodeApi
 	togglePlay
 	}
@@ -101,7 +97,6 @@
 	param uint32_t lod
 	param const void *data
 	param uint32_t comp_offset
-	param uint32_t bytes
 	handcodeApi
 	togglePlay
 	}
@@ -115,7 +110,6 @@
 	param uint32_t w
 	param uint32_t h
 	param const void *data
-	param uint32_t bytes
 	}
 
 Allocation2DElementData {
@@ -126,7 +120,6 @@
 	param RsAllocationCubemapFace face
 	param const void *data
 	param uint32_t element_offset
-	param uint32_t bytes
 	}
 
 AllocationGenerateMipmaps {
@@ -184,7 +177,6 @@
 ScriptSetTimeZone {
 	param RsScript s
 	param const char * timeZone
-	param uint32_t length
 	}
 
 
@@ -197,7 +189,6 @@
 	param RsScript s
 	param uint32_t slot
 	param const void * data
-	param uint32_t dataLen
 	handcodeApi
 	togglePlay
 	}
@@ -236,7 +227,6 @@
 	param RsScript s
 	param uint32_t slot
 	param const void * data
-	param uint32_t dataLen
 	handcodeApi
 	togglePlay
 	}
@@ -246,7 +236,6 @@
         param const char * resName
         param const char * cacheDir
 	param const char * text
-	param uint32_t length
 	ret RsScript
 	}
 
@@ -294,17 +283,13 @@
 
 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 @@
 	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 @@
 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 6b37e03..a759004 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -780,7 +780,7 @@
     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 20fa367..0ca892d 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -705,9 +705,9 @@
     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 @@
     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 477cb61..d5d5ca5 100644
--- a/libs/rs/rsElement.cpp
+++ b/libs/rs/rsElement.cpp
@@ -348,12 +348,15 @@
 }
 
 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 c30b857..b7b85b6 100644
--- a/libs/rs/rsFont.cpp
+++ b/libs/rs/rsFont.cpp
@@ -827,7 +827,9 @@
 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 @@
     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 57da10a..da51d95 100644
--- a/libs/rs/rsHandcode.h
+++ b/libs/rs/rsHandcode.h
@@ -7,7 +7,7 @@
     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 @@
     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_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 @@
     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_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 @@
     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_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 @@
     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 c379b8b..6d0701d 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -267,12 +267,13 @@
 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 6a9010fe..c8af891 100644
--- a/libs/rs/spec.l
+++ b/libs/rs/spec.l
@@ -20,6 +20,19 @@
 
    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 @@
 
 <api_entry_param>{ID} {
     memcpy(currType->name, yytext, yyleng);
+    checkPointerType();
     BEGIN(api_entry2);
     }