Begin using reflected files.
Change-Id: I5307a0eac9c206b85c0cf7451d3f8300134bf8e3
diff --git a/RenderScript.h b/RenderScript.h
index e7c0274..f01eadd 100644
--- a/RenderScript.h
+++ b/RenderScript.h
@@ -103,19 +103,12 @@
enum RsDataKind {
RS_KIND_USER,
- RS_KIND_COLOR,
- RS_KIND_POSITION,
- RS_KIND_TEXTURE,
- RS_KIND_NORMAL,
- RS_KIND_INDEX,
- RS_KIND_POINT_SIZE,
- RS_KIND_PIXEL_L,
+ RS_KIND_PIXEL_L = 7,
RS_KIND_PIXEL_A,
RS_KIND_PIXEL_LA,
RS_KIND_PIXEL_RGB,
RS_KIND_PIXEL_RGBA,
-
};
enum RsSamplerParam {
diff --git a/java/Fountain/res/raw/fountain.rs b/java/Fountain/res/raw/fountain.rs
index fe2ca33..7573398 100644
--- a/java/Fountain/res/raw/fountain.rs
+++ b/java/Fountain/res/raw/fountain.rs
@@ -40,17 +40,7 @@
return 1;
}
-// Putting the overloadable attribute on this function breaks rendering
-// appears to be a bug.
-static uchar4 /*__attribute__((overloadable))*/ pack(float r, float g, float b)
-{
- uchar4 c;
- c.x = (uchar)(r * 255.f);
- c.y = (uchar)(g * 255.f);
- c.z = (uchar)(b * 255.f);
- c.w = 255;
- return c;
-}
+#pragma rs export_func(addParticles)
void addParticles(int rate, int x, int y)
{
@@ -63,10 +53,7 @@
float rMax = ((float)rate) * 0.005f;
int size = rsAllocationGetDimX(rsGetAllocation(point));
- //uchar4 c = rsPackColorTo8888(partColor.x, partColor.y, partColor.z);
- uchar4 c = pack(partColor.x, partColor.y, partColor.z);
- c.x = 255;
- c.w = 255;
+ uchar4 c = rsPackColorTo8888(partColor.x, partColor.y, partColor.z);
//rsDebug("color ", ((int *)&c)[0]);
Point_t * np = &point[newPart];
diff --git a/java/Fountain/res/raw/fountain_bc.bc b/java/Fountain/res/raw/fountain_bc.bc
index d223460..b01098b 100644
--- a/java/Fountain/res/raw/fountain_bc.bc
+++ b/java/Fountain/res/raw/fountain_bc.bc
Binary files differ
diff --git a/java/Fountain/src/com/android/fountain/FountainRS.java b/java/Fountain/src/com/android/fountain/FountainRS.java
index 6f60134..5433597 100644
--- a/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -34,7 +34,7 @@
mRS = rs;
mRes = res;
- ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);
+ ScriptField_Point_s points = new ScriptField_Point_s(mRS, PART_COUNT);
SimpleMesh.Builder smb = new SimpleMesh.Builder(mRS);
int vtxSlot = smb.addVertexType(points.getType());
@@ -59,7 +59,7 @@
tmpColor.z = mRand.nextFloat();
mScript.set_partColor(tmpColor);
}
- mScript.invokable_addParticles(rate, x, y);
+ mScript.invoke_addParticles(rate, x, y);
holdingColor = true;
} else {
holdingColor = false;
diff --git a/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java b/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java
index cace1ec..f6bef27 100644
--- a/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java
+++ b/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java
@@ -1,46 +1,77 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.android.fountain;
-import android.content.res.Resources;
import android.renderscript.*;
+import android.content.res.Resources;
import android.util.Log;
-public class ScriptC_Fountain
- extends android.renderscript.ScriptC
-{
- public ScriptC_Fountain(RenderScript rs, Resources resources, boolean isRoot) {
+public class ScriptC_Fountain extends ScriptC {
+ // Constructor
+ public ScriptC_Fountain(RenderScript rs, Resources resources, boolean isRoot) {
super(rs, resources, R.raw.fountain_bc, isRoot);
}
+ private final static int mExportVarIdx_partColor = 0;
+ private Float4 mExportVar_partColor;
public void set_partColor(Float4 v) {
+ mExportVar_partColor = v;
FieldPacker fp = new FieldPacker(16);
fp.addF32(v);
- setVar(0, fp);
+ setVar(mExportVarIdx_partColor, fp);
}
+
+ public Float4 get_partColor() {
+ return mExportVar_partColor;
+ }
+
+ private final static int mExportVarIdx_partMesh = 1;
+ private SimpleMesh mExportVar_partMesh;
public void set_partMesh(SimpleMesh v) {
- setVar(1, v.getID());
+ mExportVar_partMesh = v;
+ int id = 0;
+ if (v != null) id = v.getID();
+ setVar(mExportVarIdx_partMesh, id);
}
- private ScriptField_Point mField_point;
- public void bind_point(ScriptField_Point f) {
- mField_point = f;
- if (f == null) {
- bindAllocation(null, 2);
- } else {
- bindAllocation(f.getAllocation(), 2);
- }
- }
- public ScriptField_Point get_point() {
- return mField_point;
+ public SimpleMesh get_partMesh() {
+ return mExportVar_partMesh;
}
-
- public void invokable_addParticles(int count, int x, int y) {
- FieldPacker fp = new FieldPacker(12);
- fp.addI32(count);
- fp.addI32(x);
- fp.addI32(y);
- invokeV(0, fp);
+ private final static int mExportVarIdx_point = 2;
+ private ScriptField_Point_s mExportVar_point;
+ public void bind_point(ScriptField_Point_s v) {
+ mExportVar_point = v;
+ if(v == null) bindAllocation(null, mExportVarIdx_point);
+ else bindAllocation(v.getAllocation(), mExportVarIdx_point);
}
+
+ public ScriptField_Point_s get_point() {
+ return mExportVar_point;
+ }
+
+ private final static int mExportFuncIdx_addParticles = 0;
+ public void invoke_addParticles(int rate, int x, int y) {
+ FieldPacker addParticles_fp = new FieldPacker(12);
+ addParticles_fp.addI32(rate);
+ addParticles_fp.addI32(x);
+ addParticles_fp.addI32(y);
+ invokeV(mExportFuncIdx_addParticles, addParticles_fp);
+ }
+
}
diff --git a/java/Fountain/src/com/android/fountain/ScriptField_Point.java b/java/Fountain/src/com/android/fountain/ScriptField_Point.java
deleted file mode 100644
index 91db2c6..0000000
--- a/java/Fountain/src/com/android/fountain/ScriptField_Point.java
+++ /dev/null
@@ -1,67 +0,0 @@
-
-package com.android.fountain;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-public class ScriptField_Point
- extends android.renderscript.Script.FieldBase
-{
-
- static public class Item {
- Item() {
- delta = new Float2();
- pos = new Float2();
- color = new Short4();
- }
-
- public static final int sizeof = (5*4);
- Float2 delta;
- Float2 pos;
- Short4 color;
- }
- private Item mItemArray[];
-
-
- public ScriptField_Point(RenderScript rs, int count) {
- // Allocate a pack/unpack buffer
- mIOBuffer = new FieldPacker(Item.sizeof * count);
- mItemArray = new Item[count];
-
- Element.Builder eb = new Element.Builder(rs);
- eb.add(Element.F32_2(rs), "delta");
- eb.add(Element.F32_2(rs), "position");
- eb.add(Element.U8_4(rs), "color");
- mElement = eb.create();
-
- init(rs, count);
- }
-
- private void copyToArray(Item i, int index) {
- mIOBuffer.reset(index * Item.sizeof);
- mIOBuffer.addF32(i.delta);
- mIOBuffer.addF32(i.pos);
- mIOBuffer.addU8(i.color);
- }
-
- public void set(Item i, int index, boolean copyNow) {
- mItemArray[index] = i;
- if (copyNow) {
- copyToArray(i, index);
- mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
- }
- }
-
- public void copyAll() {
- for (int ct=0; ct < mItemArray.length; ct++) {
- copyToArray(mItemArray[ct], ct);
- }
- mAllocation.data(mIOBuffer.getData());
- }
-
-
- private FieldPacker mIOBuffer;
-
-
-}
diff --git a/java/Fountain/src/com/android/fountain/ScriptField_Point_s.java b/java/Fountain/src/com/android/fountain/ScriptField_Point_s.java
new file mode 100644
index 0000000..9697a4d
--- /dev/null
+++ b/java/Fountain/src/com/android/fountain/ScriptField_Point_s.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.fountain;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+import android.util.Log;
+
+public class ScriptField_Point_s extends android.renderscript.Script.FieldBase {
+ static public class Item {
+ public static final int sizeof = 20;
+
+ Float2 delta;
+ Float2 position;
+ Short4 color;
+
+ Item() {
+ delta = new Float2();
+ position = new Float2();
+ color = new Short4();
+ }
+
+ }
+
+ private Item mItemArray[];
+ private FieldPacker mIOBuffer;
+ public ScriptField_Point_s(RenderScript rs, int count) {
+ mItemArray = null;
+ mIOBuffer = null;
+ {
+ Element.Builder eb = new Element.Builder(rs);
+ eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "delta");
+ eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "position");
+ eb.add(Element.createVector(rs, Element.DataType.UNSIGNED_8, 4), "color");
+ mElement = eb.create();
+ }
+
+ init(rs, count);
+ }
+
+ private void copyToArray(Item i, int index) {
+ if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * mType.getX() /* count */);
+ mIOBuffer.reset(index * Item.sizeof);
+ mIOBuffer.addF32(i.delta);
+ mIOBuffer.addF32(i.position);
+ mIOBuffer.addU8(i.color);
+ }
+
+ public void set(Item i, int index, boolean copyNow) {
+ if (mItemArray == null) mItemArray = new Item[mType.getX() /* count */];
+ mItemArray[index] = i;
+ if (copyNow) {
+ copyToArray(i, index);
+ mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
+ }
+
+ }
+
+ public void copyAll() {
+ for (int ct=0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
+ mAllocation.data(mIOBuffer.getData());
+ }
+
+}
+
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 374a07f..ef37286 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -196,32 +196,9 @@
setupScript(rsc);
Script * oldTLS = setTLS(this);
- const uint32_t * dPtr = (const uint32_t *)data;
- switch(len) {
- case 0:
- mEnviroment.mInvokeFunctions[slot]();
- break;
- case 4:
- ((void (*)(uint32_t))
- mEnviroment.mInvokeFunctions[slot])(dPtr[0]);
- break;
- case 8:
- ((void (*)(uint32_t, uint32_t))
- mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1]);
- break;
- case 12:
- ((void (*)(uint32_t, uint32_t, uint32_t))
- mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2]);
- break;
- case 16:
- ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t))
- mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3]);
- break;
- case 20:
- ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t))
- mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3], dPtr[4]);
- break;
- }
+ ((void (*)(const void *, uint32_t))
+ mEnviroment.mInvokeFunctions[slot])(data, len);
+
setTLS(oldTLS);
}
diff --git a/scriptc/rs_core.rsh b/scriptc/rs_core.rsh
index c0ba4af..8005a70 100644
--- a/scriptc/rs_core.rsh
+++ b/scriptc/rs_core.rsh
@@ -1,8 +1,6 @@
#ifndef __RS_CORE_RSH__
#define __RS_CORE_RSH__
-//uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
-//uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
static uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b)
{
@@ -24,8 +22,6 @@
return c;
}
-
-/*
static uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color)
{
color *= 255.f;
@@ -51,10 +47,11 @@
return ret;
}
-extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float r, float g, float b);
-extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float3);
-extern float4 rsUnpackColor565(uchar4);
-*/
+//extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float r, float g, float b);
+//extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float3);
+//extern float4 rsUnpackColor565(uchar4);
+
+
#endif