summaryrefslogtreecommitdiff
path: root/libs/rs
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmRS.java53
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java13
-rw-r--r--libs/rs/java/Grass/src/com/android/grass/rs/GrassRS.java29
-rw-r--r--libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java87
4 files changed, 93 insertions, 89 deletions
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index 0e5b1bd28e58..777a7cf18e20 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -27,6 +27,7 @@ import android.renderscript.Matrix;
import android.renderscript.ProgramVertexAlloc;
import android.renderscript.RenderScript;
import android.renderscript.Element;
+import android.renderscript.Allocation;
public class FilmRS {
private final int POS_TRANSLATE = 0;
@@ -77,13 +78,13 @@ public class FilmRS {
private RenderScript.ProgramVertex mPVImages;
private ProgramVertexAlloc mPVA;
- private RenderScript.Allocation mImages[];
- private RenderScript.Allocation mAllocIDs;
- private RenderScript.Allocation mAllocPos;
- private RenderScript.Allocation mAllocState;
- private RenderScript.Allocation mAllocPV;
- private RenderScript.Allocation mAllocOffsetsTex;
- private RenderScript.Allocation mAllocOffsets;
+ private Allocation mImages[];
+ private Allocation mAllocIDs;
+ private Allocation mAllocPos;
+ private Allocation mAllocState;
+ private Allocation mAllocPV;
+ private Allocation mAllocOffsetsTex;
+ private Allocation mAllocOffsets;
private RenderScript.TriangleMesh mMesh;
private RenderScript.Light mLight;
@@ -155,24 +156,24 @@ public class FilmRS {
private void loadImages() {
mBufferIDs = new int[13];
- mImages = new RenderScript.Allocation[13];
- mAllocIDs = mRS.allocationCreateSized(
+ mImages = new Allocation[13];
+ mAllocIDs = Allocation.createSized(mRS,
Element.USER_FLOAT, mBufferIDs.length);
Element ie = Element.RGB_565;
- mImages[0] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p01, ie, true);
- mImages[1] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p02, ie, true);
- mImages[2] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p03, ie, true);
- mImages[3] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p04, ie, true);
- mImages[4] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p05, ie, true);
- mImages[5] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p06, ie, true);
- mImages[6] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p07, ie, true);
- mImages[7] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p08, ie, true);
- mImages[8] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p09, ie, true);
- mImages[9] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p10, ie, true);
- mImages[10] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p11, ie, true);
- mImages[11] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p12, ie, true);
- mImages[12] = mRS.allocationCreateFromBitmapResourceBoxed(mRes, R.drawable.p13, ie, true);
+ mImages[0] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p01, ie, true);
+ mImages[1] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p02, ie, true);
+ mImages[2] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p03, ie, true);
+ mImages[3] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p04, ie, true);
+ mImages[4] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p05, ie, true);
+ mImages[5] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p06, ie, true);
+ mImages[6] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p07, ie, true);
+ mImages[7] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p08, ie, true);
+ mImages[8] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p09, ie, true);
+ mImages[9] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p10, ie, true);
+ mImages[10] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p11, ie, true);
+ mImages[11] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p12, ie, true);
+ mImages[12] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p13, ie, true);
for(int ct=0; ct < mImages.length; ct++) {
mImages[ct].uploadToTexture(1);
@@ -184,7 +185,7 @@ public class FilmRS {
private void initState()
{
mBufferState = new int[10];
- mAllocState = mRS.allocationCreateSized(
+ mAllocState = Allocation.createSized(mRS,
Element.USER_FLOAT, mBufferState.length);
mBufferState[STATE_TRIANGLE_OFFSET_COUNT] = mFSM.mTriangleOffsetsCount;
@@ -215,7 +216,7 @@ public class FilmRS {
mRS.scriptCSetRoot(true);
mScriptStrip = mRS.scriptCCreate();
- mAllocPos = mRS.allocationCreateSized(
+ mAllocPos = Allocation.createSized(mRS,
Element.USER_FLOAT, mBufferPos.length);
loadImages();
@@ -233,12 +234,12 @@ public class FilmRS {
mScriptStrip.bindAllocation(mPVA.mAlloc, 3);
- mAllocOffsets = mRS.allocationCreateSized(
+ mAllocOffsets = Allocation.createSized(mRS,
Element.USER_I32, mFSM.mTriangleOffsets.length);
mAllocOffsets.data(mFSM.mTriangleOffsets);
mScriptStrip.bindAllocation(mAllocOffsets, 4);
- mAllocOffsetsTex = mRS.allocationCreateSized(
+ mAllocOffsetsTex = Allocation.createSized(mRS,
Element.USER_FLOAT, mFSM.mTriangleOffsetsTex.length);
mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex);
mScriptStrip.bindAllocation(mAllocOffsetsTex, 5);
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
index 654d6cf12ab0..7123bf765be3 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -28,6 +28,7 @@ import android.util.Log;
import android.renderscript.RenderScript;
import android.renderscript.ProgramVertexAlloc;
import android.renderscript.Element;
+import android.renderscript.Allocation;
public class FountainRS {
@@ -53,9 +54,9 @@ public class FountainRS {
private Resources mRes;
private RenderScript mRS;
- private RenderScript.Allocation mIntAlloc;
- private RenderScript.Allocation mPartAlloc;
- private RenderScript.Allocation mVertAlloc;
+ private Allocation mIntAlloc;
+ private Allocation mPartAlloc;
+ private Allocation mVertAlloc;
private RenderScript.Script mScript;
private RenderScript.ProgramFragmentStore mPFS;
private RenderScript.ProgramFragment mPF;
@@ -67,10 +68,10 @@ public class FountainRS {
private void initRS() {
int partCount = 1024;
- mIntAlloc = mRS.allocationCreateSized(Element.USER_I32, 10);
- mPartAlloc = mRS.allocationCreateSized(Element.USER_I32, partCount * 3 * 3);
+ mIntAlloc = Allocation.createSized(mRS, Element.USER_I32, 10);
+ mPartAlloc = Allocation.createSized(mRS, Element.USER_I32, partCount * 3 * 3);
mPartAlloc.setName("PartBuffer");
- mVertAlloc = mRS.allocationCreateSized(Element.USER_I32, partCount * 5 + 1);
+ mVertAlloc = Allocation.createSized(mRS, Element.USER_I32, partCount * 5 + 1);
mRS.programFragmentStoreBegin(null, null);
mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE);
diff --git a/libs/rs/java/Grass/src/com/android/grass/rs/GrassRS.java b/libs/rs/java/Grass/src/com/android/grass/rs/GrassRS.java
index f5737da3a1c2..70cb01249666 100644
--- a/libs/rs/java/Grass/src/com/android/grass/rs/GrassRS.java
+++ b/libs/rs/java/Grass/src/com/android/grass/rs/GrassRS.java
@@ -26,6 +26,7 @@ import static android.renderscript.RenderScript.BlendDstFunc;
import android.renderscript.RenderScript;
import android.renderscript.Element;
+import android.renderscript.Allocation;
import java.util.TimeZone;
@@ -47,13 +48,13 @@ class GrassRS {
private RenderScript.ProgramFragmentStore mPfsBackground;
@SuppressWarnings({"FieldCanBeLocal"})
- private RenderScript.Allocation mSkyTexturesIDs;
+ private Allocation mSkyTexturesIDs;
@SuppressWarnings({"FieldCanBeLocal"})
- private RenderScript.Allocation[] mSkyTextures;
+ private Allocation[] mSkyTextures;
@SuppressWarnings({"FieldCanBeLocal"})
private int[] mSkyBufferIDs;
@SuppressWarnings({"FieldCanBeLocal"})
- private RenderScript.Allocation mState;
+ private Allocation mState;
public GrassRS() {
}
@@ -69,7 +70,7 @@ class GrassRS {
createProgramFragmentStore();
createProgramFragment();
createScriptStructures();
-
+
mRS.scriptCBegin();
mRS.scriptCSetClearColor(0.0f, 0.0f, 0.0f, 1.0f);
mRS.scriptCSetScript(mResources, R.raw.grass);
@@ -78,25 +79,25 @@ class GrassRS {
mScript = mRS.scriptCCreate();
- loadSkyTextures();
+ loadSkyTextures();
mScript.bindAllocation(mState, RSID_STATE);
mScript.bindAllocation(mSkyTexturesIDs, RSID_SKY_TEXTURES);
- mRS.contextBindRootScript(mScript);
+ mRS.contextBindRootScript(mScript);
}
private void createScriptStructures() {
- mState = mRS.allocationCreateSized(Element.USER_I32, 1);
+ mState = Allocation.createSized(mRS, Element.USER_I32, 1);
mState.data(new int[1]);
}
private void loadSkyTextures() {
mSkyBufferIDs = new int[SKY_TEXTURES_COUNT];
- mSkyTextures = new RenderScript.Allocation[SKY_TEXTURES_COUNT];
- mSkyTexturesIDs = mRS.allocationCreateSized(
- Element.USER_FLOAT, SKY_TEXTURES_COUNT);
+ mSkyTextures = new Allocation[SKY_TEXTURES_COUNT];
+ mSkyTexturesIDs = Allocation.createSized(
+ mRS, Element.USER_FLOAT, SKY_TEXTURES_COUNT);
- final RenderScript.Allocation[] textures = mSkyTextures;
+ final Allocation[] textures = mSkyTextures;
textures[0] = loadTexture(R.drawable.night, "night");
textures[1] = loadTexture(R.drawable.sunrise, "sunrise");
textures[2] = loadTexture(R.drawable.sky, "sky");
@@ -106,7 +107,7 @@ class GrassRS {
final int count = textures.length;
for (int i = 0; i < count; i++) {
- final RenderScript.Allocation texture = textures[i];
+ final Allocation texture = textures[i];
texture.uploadToTexture(0);
bufferIds[i] = texture.getID();
}
@@ -114,8 +115,8 @@ class GrassRS {
mSkyTexturesIDs.data(bufferIds);
}
- private RenderScript.Allocation loadTexture(int id, String name) {
- RenderScript.Allocation allocation = mRS.allocationCreateFromBitmapResource(mResources, id,
+ private Allocation loadTexture(int id, String name) {
+ Allocation allocation = Allocation.createFromBitmapResource(mRS, mResources, id,
Element.RGB_565, false);
allocation.setName(name);
return allocation;
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
index 7f9727c0ef17..cb3dd51061c5 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -21,6 +21,7 @@ import java.io.Writer;
import android.renderscript.RenderScript;
import android.renderscript.ProgramVertexAlloc;
import android.renderscript.Element;
+import android.renderscript.Allocation;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -100,20 +101,20 @@ public class RolloRS {
private ProgramVertexAlloc mPVAlloc;
private RenderScript.ProgramVertex mPVOrtho;
private ProgramVertexAlloc mPVOrthoAlloc;
- private RenderScript.Allocation[] mIcons;
- private RenderScript.Allocation[] mLabels;
+ private Allocation[] mIcons;
+ private Allocation[] mLabels;
private int[] mAllocStateBuf;
- private RenderScript.Allocation mAllocState;
+ private Allocation mAllocState;
private int[] mAllocIconIDBuf;
- private RenderScript.Allocation mAllocIconID;
+ private Allocation mAllocIconID;
private int[] mAllocLabelIDBuf;
- private RenderScript.Allocation mAllocLabelID;
+ private Allocation mAllocLabelID;
private int[] mAllocScratchBuf;
- private RenderScript.Allocation mAllocScratch;
+ private Allocation mAllocScratch;
private void initNamed() {
mRS.samplerBegin();
@@ -190,7 +191,7 @@ public class RolloRS {
mRS.contextBindProgramVertex(mPV);
mAllocScratchBuf = new int[32];
- mAllocScratch = mRS.allocationCreateSized(
+ mAllocScratch = Allocation.createSized(mRS,
Element.USER_I32, mAllocScratchBuf.length);
mAllocScratch.data(mAllocScratchBuf);
@@ -199,37 +200,37 @@ public class RolloRS {
{
- mIcons = new RenderScript.Allocation[29];
+ mIcons = new Allocation[29];
mAllocIconIDBuf = new int[mIcons.length];
- mAllocIconID = mRS.allocationCreateSized(
+ mAllocIconID = Allocation.createSized(mRS,
Element.USER_I32, mAllocIconIDBuf.length);
- mLabels = new RenderScript.Allocation[29];
+ mLabels = new Allocation[29];
mAllocLabelIDBuf = new int[mLabels.length];
- mAllocLabelID = mRS.allocationCreateSized(
+ mAllocLabelID = Allocation.createSized(mRS,
Element.USER_I32, mLabels.length);
Element ie8888 = Element.RGBA_8888;
- mIcons[0] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.browser, ie8888, true);
- mIcons[1] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.market, ie8888, true);
- mIcons[2] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.photos, ie8888, true);
- mIcons[3] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.settings, ie8888, true);
- mIcons[4] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.calendar, ie8888, true);
- mIcons[5] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.g1155, ie8888, true);
- mIcons[6] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.g2140, ie8888, true);
- mIcons[7] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.maps, ie8888, true);
- mIcons[8] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path431, ie8888, true);
- mIcons[9] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path676, ie8888, true);
- mIcons[10] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path754, ie8888, true);
- mIcons[11] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path815, ie8888, true);
- mIcons[12] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path1920, ie8888, true);
- mIcons[13] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path1927, ie8888, true);
- mIcons[14] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path3099, ie8888, true);
- mIcons[15] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path3950, ie8888, true);
- mIcons[16] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path4481, ie8888, true);
- mIcons[17] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.path5168, ie8888, true);
- mIcons[18] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.polygon2408, ie8888, true);
+ mIcons[0] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.browser, ie8888, true);
+ mIcons[1] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.market, ie8888, true);
+ mIcons[2] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.photos, ie8888, true);
+ mIcons[3] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.settings, ie8888, true);
+ mIcons[4] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.calendar, ie8888, true);
+ mIcons[5] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.g1155, ie8888, true);
+ mIcons[6] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.g2140, ie8888, true);
+ mIcons[7] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.maps, ie8888, true);
+ mIcons[8] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path431, ie8888, true);
+ mIcons[9] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path676, ie8888, true);
+ mIcons[10] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path754, ie8888, true);
+ mIcons[11] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path815, ie8888, true);
+ mIcons[12] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path1920, ie8888, true);
+ mIcons[13] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path1927, ie8888, true);
+ mIcons[14] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path3099, ie8888, true);
+ mIcons[15] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path3950, ie8888, true);
+ mIcons[16] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path4481, ie8888, true);
+ mIcons[17] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.path5168, ie8888, true);
+ mIcons[18] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.polygon2408, ie8888, true);
mLabels[0] = makeTextBitmap("browser");
mLabels[1] = makeTextBitmap("market");
@@ -274,16 +275,16 @@ public class RolloRS {
mLabels[28] = mLabels[9];
/*
- mIcons[19] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.solitaire, ie8888, true);
- mIcons[20] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.sudoku, ie8888, true);
- mIcons[21] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.taptaprevenge, ie8888, true);
- mIcons[22] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.tetris, ie8888, true);
- mIcons[23] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.tictactoe, ie8888, true);
- mIcons[24] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.tweetie, ie8888, true);
- mIcons[25] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.urbanspoon, ie8888, true);
- mIcons[26] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.waterslide_extreme, ie8888, true);
- mIcons[27] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.weather_channel, ie8888, true);
- mIcons[28] = mRS.allocationCreateFromBitmapResource(mRes, R.raw.zippo, ie8888, true);
+ mIcons[19] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.solitaire, ie8888, true);
+ mIcons[20] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.sudoku, ie8888, true);
+ mIcons[21] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.taptaprevenge, ie8888, true);
+ mIcons[22] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.tetris, ie8888, true);
+ mIcons[23] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.tictactoe, ie8888, true);
+ mIcons[24] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.tweetie, ie8888, true);
+ mIcons[25] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.urbanspoon, ie8888, true);
+ mIcons[26] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.waterslide_extreme, ie8888, true);
+ mIcons[27] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.weather_channel, ie8888, true);
+ mIcons[28] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.zippo, ie8888, true);
*/
@@ -299,7 +300,7 @@ public class RolloRS {
}
- RenderScript.Allocation makeTextBitmap(String t) {
+ Allocation makeTextBitmap(String t) {
Bitmap b = Bitmap.createBitmap(128, 32, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
Paint p = new Paint();
@@ -307,7 +308,7 @@ public class RolloRS {
p.setTextSize(20);
p.setColor(0xffffffff);
c.drawText(t, 2, 26, p);
- return mRS.allocationCreateFromBitmap(b, Element.RGBA_8888, true);
+ return Allocation.createFromBitmap(mRS, b, Element.RGBA_8888, true);
}
@@ -320,7 +321,7 @@ public class RolloRS {
mScript = mRS.scriptCCreate();
mAllocStateBuf = new int[] {0, 0, 0, 8, 0, 0, -1, 0, mAllocIconIDBuf.length, 0, 0};
- mAllocState = mRS.allocationCreateSized(
+ mAllocState = Allocation.createSized(mRS,
Element.USER_I32, mAllocStateBuf.length);
mScript.bindAllocation(mAllocState, 0);
mScript.bindAllocation(mAllocIconID, 1);