summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2010-05-17 15:12:54 -0700
committerAlex Sakhartchouk <alexst@google.com>2010-05-17 15:12:54 -0700
commit31be678ff706bdf7e7c9f34c9ffcd8d2794643e2 (patch)
treebbb138bd1f72fef63d76a9da747754052317b1fe
parent8bc6296d6120655dc30b2d4f7905c07224783705 (diff)
downloadandroid_packages_wallpapers_MagicSmoke-31be678ff706bdf7e7c9f34c9ffcd8d2794643e2.tar.gz
android_packages_wallpapers_MagicSmoke-31be678ff706bdf7e7c9f34c9ffcd8d2794643e2.tar.bz2
android_packages_wallpapers_MagicSmoke-31be678ff706bdf7e7c9f34c9ffcd8d2794643e2.zip
Removing setName based on feedback.
After compiler fix, everything seems to match reference. Mostly working, but patterns mismatch reference. Magic smoke bug repro case. Added missing files. Change-Id: I3260848b40040d10abe8e15f2ac3b24d6c51d040
-rw-r--r--res/raw/clouds.rs181
-rw-r--r--res/raw/clouds_bc.bcbin0 -> 10184 bytes
-rw-r--r--src/com/android/magicsmoke/MagicSmokeRS.java142
-rw-r--r--src/com/android/magicsmoke/RenderScriptScene.java13
-rw-r--r--src/com/android/magicsmoke/RenderScriptWallpaper.java16
-rw-r--r--src/com/android/magicsmoke/ScriptC_MagicSmoke.java203
6 files changed, 428 insertions, 127 deletions
diff --git a/res/raw/clouds.rs b/res/raw/clouds.rs
index a1f3b18..017c88e 100644
--- a/res/raw/clouds.rs
+++ b/res/raw/clouds.rs
@@ -13,9 +13,10 @@
// limitations under the License.
#pragma version(1)
-#pragma stateVertex(PVBackground)
-#pragma stateRaster(parent)
-#pragma stateFragment(PFBackground)
+
+#include "../../../../../frameworks/base/libs/rs/scriptc/rs_types.rsh"
+#include "../../../../../frameworks/base/libs/rs/scriptc/rs_math.rsh"
+#include "../../../../../frameworks/base/libs/rs/scriptc/rs_graphics.rsh"
#define RSID_NOISESRC1 1
#define RSID_NOISESRC2 2
@@ -28,6 +29,52 @@
#define RSID_NOISEDST4 9
#define RSID_NOISEDST5 10
+// State set from java
+float gXOffset;
+float gTilt;
+int gPreset;
+int gTextureMask;
+int gRotate;
+int gTextureSwap;
+int gProcessTextureMode;
+int gBackCol;
+int gLowCol;
+int gHighCol;
+float gAlphaMul;
+int gPreMul;
+int gBlendFunc;
+
+rs_program_vertex gPVBackground;
+rs_program_fragment gPFBackground;
+rs_program_store gPFSBackgroundOne;
+rs_program_store gPFSBackgroundSrc;
+
+rs_allocation gTnoise1;
+rs_allocation gTnoise2;
+rs_allocation gTnoise3;
+rs_allocation gTnoise4;
+rs_allocation gTnoise5;
+
+// can't export int pointers yet
+typedef struct Integers_s {
+ int value;
+} Integers_t;
+
+Integers_t *gNoisesrc1;
+Integers_t *gNoisesrc2;
+Integers_t *gNoisesrc3;
+Integers_t *gNoisesrc4;
+Integers_t *gNoisesrc5;
+
+Integers_t *gNoisedst1;
+Integers_t *gNoisedst2;
+Integers_t *gNoisedst3;
+Integers_t *gNoisedst4;
+Integers_t *gNoisedst5;
+
+#pragma rs export_var(gXOffset, gTilt, gPreset, gTextureMask, gRotate, gTextureSwap, gProcessTextureMode, gBackCol, gLowCol, gHighCol, gAlphaMul, gPreMul, gBlendFunc, gPVBackground, gPFBackground, gPFSBackgroundOne, gPFSBackgroundSrc, gTnoise1, gTnoise2, gTnoise3, gTnoise4, gTnoise5, gNoisesrc1, gNoisesrc2, gNoisesrc3, gNoisesrc4, gNoisesrc5, gNoisedst1, gNoisedst2, gNoisedst3, gNoisedst4, gNoisedst5)
+
+// Local script variables
float xshift[5];
float rotation[5];
float scale[5];
@@ -36,15 +83,30 @@ int currentpreset;
int lastuptime;
float timedelta;
+void debugAll()
+{
+ debugP(10, (void *)gPreset);
+ debugP(10, (void *)gTextureMask);
+ debugP(10, (void *)gRotate);
+ debugP(10, (void *)gTextureSwap);
+ debugP(10, (void *)gProcessTextureMode);
+ debugP(10, (void *)gBackCol);
+ debugP(10, (void *)gLowCol);
+ debugP(10, (void *)gHighCol);
+ debugPf(10, gAlphaMul);
+ debugP(10, (void *)gPreMul);
+ debugP(10, (void *)gBlendFunc);
+}
+
void drawCloud(float *ident, int id, int idx) {
float mat1[16];
float z = -8.f * idx;
matrixLoadMat(mat1,ident);
- matrixTranslate(mat1, -State->mXOffset * 8.f * idx, -State->mTilt * idx / 3.f, 0.f);
+ matrixTranslate(mat1, -gXOffset * 8.f * idx, -gTilt * idx / 3.f, 0.f);
matrixRotate(mat1, rotation[idx], 0.f, 0.f, 1.f);
vpLoadModelMatrix(mat1);
- bindTexture(NAMED_PFBackground, 0, id);
+ bindTexture(gPFBackground, 0, id);
drawQuadTexCoords(
-1200.0f, -1200.0f, z, // space
0.f + xshift[idx], 0.f, // texture
@@ -64,7 +126,7 @@ void drawClouds(float* ident) {
matrixLoadMat(mat1,ident);
- if (State->mRotate != 0) {
+ if (gRotate != 0) {
rotation[0] += 0.10 * timedelta;
rotation[1] += 0.102f * timedelta;
rotation[2] += 0.106f * timedelta;
@@ -72,46 +134,47 @@ void drawClouds(float* ident) {
rotation[4] += 0.123f * timedelta;
}
- int mask = State->mTextureMask;
+ int mask = gTextureMask;
if (mask & 1) {
xshift[0] += 0.0010f * timedelta;
- if (State->mTextureSwap != 0) {
- drawCloud(mat1, NAMED_Tnoise5, 0);
+ if (gTextureSwap != 0) {
+ drawCloud(mat1, gTnoise5, 0);
} else {
- drawCloud(mat1, NAMED_Tnoise1, 0);
+ drawCloud(mat1, gTnoise1, 0);
}
}
if (mask & 2) {
xshift[1] += 0.00106 * timedelta;
- drawCloud(mat1, NAMED_Tnoise2, 1);
+ drawCloud(mat1, gTnoise2, 1);
}
if (mask & 4) {
xshift[2] += 0.00114f * timedelta;
- drawCloud(mat1, NAMED_Tnoise3, 2);
+ drawCloud(mat1, gTnoise3, 2);
}
if (mask & 8) {
xshift[3] += 0.00118f * timedelta;
- drawCloud(mat1, NAMED_Tnoise4, 3);
+ drawCloud(mat1, gTnoise4, 3);
}
if (mask & 16) {
xshift[4] += 0.00127f * timedelta;
- drawCloud(mat1, NAMED_Tnoise5, 4);
+ drawCloud(mat1, gTnoise5, 4);
}
// Make sure the texture coordinates don't continuously increase
for(i = 0; i < 5; i++) {
- while (xshift[i] >= 1.f) {
- xshift[i] -= 1.f;
+ if (xshift[i] > 1.f) {
+ xshift[i] -= floor(xshift[i]);
}
}
// Make sure the rotation angles don't continuously increase
for(i = 0; i < 5; i++) {
- while (rotation[i] >= 360.f) {
- rotation[i] -= 360.f;
+ if (rotation[i] > 360.f) {
+ float multiplier = floor(rotation[i]/360.f);
+ rotation[i] -= 360.f * multiplier;
}
}
}
@@ -126,18 +189,19 @@ int premul(int rgb, int a) {
return r << 16 | g << 8 | b;
}
+
void makeTexture(int *src, int *dst, int rsid) {
-
+
int x;
int y;
- int pm = State->mPreMul;
+ int pm = gPreMul;
+
+ if (gProcessTextureMode == 1) {
+ int lowcol = gLowCol;
+ int highcol = gHighCol;
- if (State->mProcessTextureMode == 1) {
- int lowcol = State->mLowCol;
- int highcol = State->mHighCol;
-
for (y=0;y<256;y++) {
- for (x=0;x<256;x++) {
+ for (x=0;x<256;x++) {
int pix = src[y*256+x];
int lum = pix & 0x00ff;
int newpix;
@@ -159,14 +223,14 @@ void makeTexture(int *src, int *dst, int rsid) {
dst[y*256+x] = newpix;
}
}
- alphafactor *= State->mAlphaMul;
- } else if (State->mProcessTextureMode == 2) {
- int lowcol = State->mLowCol;
- int highcol = State->mHighCol;
+ alphafactor *= gAlphaMul;
+ } else if (gProcessTextureMode == 2) {
+ int lowcol = gLowCol;
+ int highcol = gHighCol;
float scale = 255.f / (255.f - lowcol);
-
+
for (y=0;y<256;y++) {
- for (x=0;x<256;x++) {
+ for (x=0;x<256;x++) {
int pix = src[y*256+x];
int alpha = pix & 0x00ff;
if (alpha < lowcol) {
@@ -183,14 +247,14 @@ void makeTexture(int *src, int *dst, int rsid) {
dst[y*256+x] = newpix;
}
}
- alphafactor *= State->mAlphaMul;
- } else if (State->mProcessTextureMode == 3) {
- int lowcol = State->mLowCol;
- int highcol = State->mHighCol;
+ alphafactor *= gAlphaMul;
+ } else if (gProcessTextureMode == 3) {
+ int lowcol = gLowCol;
+ int highcol = gHighCol;
float scale = 255.f / (255.f - lowcol);
-
+
for (y=0;y<256;y++) {
- for (x=0;x<256;x++) {
+ for (x=0;x<256;x++) {
int pix = src[y*256+x];
int lum = pix & 0x00ff;
int newpix;
@@ -214,9 +278,8 @@ void makeTexture(int *src, int *dst, int rsid) {
dst[y*256+x] = newpix;
}
}
- alphafactor *= State->mAlphaMul;
+ alphafactor *= gAlphaMul;
} else {
-
for (y=0;y<256;y++) {
for (x=0;x<256;x++) {
int rgb = *src++;
@@ -229,17 +292,17 @@ void makeTexture(int *src, int *dst, int rsid) {
}
}
}
+
uploadToTexture(rsid, 0);
}
void makeTextures() {
- debugI32("makeTextures", State->mPreset);
alphafactor = 1.f;
- makeTexture((int*)noisesrc1, (int*)noisedst1, NAMED_Tnoise1);
- makeTexture((int*)noisesrc2, (int*)noisedst2, NAMED_Tnoise2);
- makeTexture((int*)noisesrc3, (int*)noisedst3, NAMED_Tnoise3);
- makeTexture((int*)noisesrc4, (int*)noisedst4, NAMED_Tnoise4);
- makeTexture((int*)noisesrc5, (int*)noisedst5, NAMED_Tnoise5);
+ makeTexture((int*)gNoisesrc1, (int*)gNoisedst1, gTnoise1);
+ makeTexture((int*)gNoisesrc2, (int*)gNoisedst2, gTnoise2);
+ makeTexture((int*)gNoisesrc3, (int*)gNoisedst3, gTnoise3);
+ makeTexture((int*)gNoisesrc4, (int*)gNoisedst4, gTnoise4);
+ makeTexture((int*)gNoisesrc5, (int*)gNoisedst5, gTnoise5);
}
@@ -252,10 +315,12 @@ struct color {
void init() {
int i;
- for (i=0;i<4;i++) {
+
+ for (i=0;i<5;i++) {
xshift[i] = 0.f;
rotation[i] = 360.f * i / 5.f;
}
+
scale[0] = 4.0f; // changed below based on preset
scale[1] = 3.0f;
scale[2] = 3.4f;
@@ -268,21 +333,25 @@ void init() {
}
-int main(int launchID) {
+int root(int launchID) {
int i;
float ident[16];
- float masterscale = 0.0041f;// / (State->mXOffset * 4.f + 1.f);
+ float masterscale = 0.0041f;// / (gXOffset * 4.f + 1.f);
+
+ bindProgramVertex(gPVBackground);
+ bindProgramFragment(gPFBackground);
+
matrixLoadIdentity(ident);
- matrixTranslate(ident, -State->mXOffset, 0.f, 0.f);
+ matrixTranslate(ident, -gXOffset, 0.f, 0.f);
matrixScale(ident, masterscale, masterscale, masterscale);
//matrixRotate(ident, 0.f, 0.f, 0.f, 1.f);
- matrixRotate(ident, -State->mTilt, 1.f, 0.f, 0.f);
+ matrixRotate(ident, -gTilt, 1.f, 0.f, 0.f);
- if (State->mBlendFunc) {
- bindProgramStore(NAMED_PFSBackgroundOne);
+ if (gBlendFunc) {
+ bindProgramStore(gPFSBackgroundOne);
} else {
- bindProgramStore(NAMED_PFSBackgroundSrc);
+ bindProgramStore(gPFSBackgroundSrc);
}
int now = uptimeMillis();
@@ -294,10 +363,10 @@ int main(int launchID) {
timedelta = 3;
}
- i = State->mPreset;
+ i = gPreset;
if (i != currentpreset) {
currentpreset = i;
- int rgb = State->mBackCol;
+ int rgb = gBackCol;
pfClearColor(
((float)((rgb >> 16) & 0xff)) / 255.0f,
((float)((rgb >> 8) & 0xff)) / 255.0f,
@@ -306,7 +375,7 @@ int main(int launchID) {
makeTextures();
}
- if (State->mTextureSwap != 0) {
+ if (gTextureSwap != 0) {
scale[0] = .25f;
} else {
scale[0] = 4.f;
diff --git a/res/raw/clouds_bc.bc b/res/raw/clouds_bc.bc
new file mode 100644
index 0000000..e8b327f
--- /dev/null
+++ b/res/raw/clouds_bc.bc
Binary files differ
diff --git a/src/com/android/magicsmoke/MagicSmokeRS.java b/src/com/android/magicsmoke/MagicSmokeRS.java
index 3ab431c..4089d65 100644
--- a/src/com/android/magicsmoke/MagicSmokeRS.java
+++ b/src/com/android/magicsmoke/MagicSmokeRS.java
@@ -45,6 +45,7 @@ import android.renderscript.ProgramStore.BlendDstFunc;
import android.renderscript.ProgramStore.BlendSrcFunc;
import android.util.Log;
import android.view.MotionEvent;
+import android.os.Bundle;
import java.util.TimeZone;
@@ -66,8 +67,8 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
public int mBlendFunc;
}
WorldState mWorldState = new WorldState();
- private Type mStateType;
- private Allocation mState;
+ //private Type mStateType;
+ //private Allocation mState;
private ProgramStore mPfsBackgroundOne;
private ProgramStore mPfsBackgroundSrc;
@@ -76,6 +77,8 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
private Allocation[] mSourceTextures;
private Allocation[] mRealTextures;
+ private ScriptC_MagicSmoke mScript;
+
private ProgramVertex mPVBackground;
private ProgramVertex.MatrixAllocation mPVAlloc;
@@ -161,7 +164,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
makeNewState();
- mState.data(mWorldState);
}
void makeNewState() {
@@ -180,6 +182,20 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
mWorldState.mAlphaMul = mPreset[p].mAlphaMul;
mWorldState.mPreMul = mPreset[p].mPreMul ? 1 : 0;
mWorldState.mBlendFunc = mPreset[p].mBlendFunc;
+
+ if(mScript != null) {
+ mScript.set_gPreset(mWorldState.mPreset);
+ mScript.set_gTextureMask(mWorldState.mTextureMask);
+ mScript.set_gRotate(mWorldState.mRotate);
+ mScript.set_gTextureSwap(mWorldState.mTextureSwap);
+ mScript.set_gProcessTextureMode(mWorldState.mProcessTextureMode);
+ mScript.set_gBackCol(mWorldState.mBackCol);
+ mScript.set_gLowCol(mWorldState.mLowCol);
+ mScript.set_gHighCol(mWorldState.mHighCol);
+ mScript.set_gAlphaMul(mWorldState.mAlphaMul);
+ mScript.set_gPreMul(mWorldState.mPreMul);
+ mScript.set_gBlendFunc(mWorldState.mBlendFunc);
+ }
}
@Override
@@ -191,6 +207,18 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
}
@Override
+ public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
+ boolean resultRequested) {
+
+ if ("android.wallpaper.tap".equals(action)) {
+ mTouchY = y;
+ }
+ mWorldState.mTilt = 0;
+ mScript.set_gTilt(mWorldState.mTilt);
+ return null;
+ }
+
+ /*@Override
public void onTouchEvent(MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
@@ -207,16 +235,16 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
dy = -4;
}
mWorldState.mTilt = dy;
- mState.data(mWorldState);
+ mScript.set_gTilt(mWorldState.mTilt);
+ //mState.data(mWorldState);
}
- }
+ }*/
@Override
- public void setOffset(float xOffset, float yOffset, float xStep, float yStep,
- int xPixels, int yPixels) {
+ public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
// update our state, then push it to the renderscript
mWorldState.mXOffset = xOffset;
- mState.data(mWorldState);
+ mScript.set_gXOffset(mWorldState.mXOffset);
}
@Override
@@ -230,7 +258,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
super.start();
mSharedPref.registerOnSharedPreferenceChangeListener(this);
makeNewState();
- mState.data(mWorldState);
}
float alphafactor;
@@ -245,9 +272,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
in.getPixels(pixels, 0, 256, 0, 0, 256, 256);
mRealTextures[index] = Allocation.createTyped(mRS, mTextureType);
mSourceTextures[index] = Allocation.createTyped(mRS, mTextureType);
- mSourceTextures[index].setName(name+"_src");
mSourceTextures[index].data(pixels);
- mRealTextures[index].setName(name);
in.recycle();
}
@@ -265,27 +290,40 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
loadBitmap(R.drawable.noise3, 2, "Tnoise3", alphamul, lowcol, highcol);
loadBitmap(R.drawable.noise4, 3, "Tnoise4", alphamul, lowcol, highcol);
loadBitmap(R.drawable.noise5, 4, "Tnoise5", alphamul, lowcol, highcol);
+
+ mScript.set_gTnoise1(mRealTextures[0]);
+ mScript.set_gTnoise2(mRealTextures[1]);
+ mScript.set_gTnoise3(mRealTextures[2]);
+ mScript.set_gTnoise4(mRealTextures[3]);
+ mScript.set_gTnoise5(mRealTextures[4]);
+
+ mScript.bind_gNoisesrc1(mSourceTextures[0]);
+ mScript.bind_gNoisesrc2(mSourceTextures[1]);
+ mScript.bind_gNoisesrc3(mSourceTextures[2]);
+ mScript.bind_gNoisesrc4(mSourceTextures[3]);
+ mScript.bind_gNoisesrc5(mSourceTextures[4]);
+
+ mScript.bind_gNoisedst1(mRealTextures[0]);
+ mScript.bind_gNoisedst2(mRealTextures[1]);
+ mScript.bind_gNoisedst3(mRealTextures[2]);
+ mScript.bind_gNoisedst4(mRealTextures[3]);
+ mScript.bind_gNoisedst5(mRealTextures[4]);
}
@Override
protected ScriptC createScript() {
-/*
- // Create a renderscript type from a java class. The specified name doesn't
- // really matter; the name by which we refer to the object in RenderScript
- // will be specified later.
- mStateType = Type.createFromClass(mRS, WorldState.class, 1, "WorldState");
- // Create an allocation from the type we just created.
- mState = Allocation.createTyped(mRS, mStateType);
- mState.data(mWorldState);
+
+ mScript = new ScriptC_MagicSmoke(mRS, mResources, R.raw.clouds_bc, true);
// First set up the coordinate system and such
ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
mPVBackground = pvb.create();
- mPVBackground.setName("PVBackground");
mPVAlloc = new ProgramVertex.MatrixAllocation(mRS);
mPVBackground.bindAllocation(mPVAlloc);
mPVAlloc.setupProjectionNormalized(mWidth, mHeight);
+ mScript.set_gPVBackground(mPVBackground);
+
mSourceTextures = new Allocation[5];
mRealTextures = new Allocation[5];
@@ -307,10 +345,11 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
builder.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
ProgramFragment.Builder.Format.RGBA, 0);
mPfBackground = builder.create();
- mPfBackground.setName("PFBackground");
mPfBackground.bindSampler(mSampler, 0);
}
+ mScript.set_gPFBackground(mPfBackground);
+
{
ProgramStore.Builder builder = new ProgramStore.Builder(mRS, null, null);
builder.setDepthFunc(ProgramStore.DepthFunc.EQUAL);
@@ -318,50 +357,29 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
builder.setDitherEnable(true); // without dithering there is severe banding
builder.setDepthMask(false);
mPfsBackgroundOne = builder.create();
- mPfsBackgroundOne.setName("PFSBackgroundOne");
builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
mPfsBackgroundSrc = builder.create();
- mPfsBackgroundSrc.setName("PFSBackgroundSrc");
}
- // Time to create the script
- ScriptC.Builder sb = new ScriptC.Builder(mRS);
- // Specify the name by which to refer to the WorldState object in the
- // renderscript.
- sb.setType(mStateType, "State", RSID_STATE);
- sb.setType(mTextureType, "noisesrc1", RSID_NOISESRC1);
- sb.setType(mTextureType, "noisedst1", RSID_NOISEDST1);
- sb.setType(mTextureType, "noisesrc2", RSID_NOISESRC2);
- sb.setType(mTextureType, "noisedst2", RSID_NOISEDST2);
- sb.setType(mTextureType, "noisesrc3", RSID_NOISESRC3);
- sb.setType(mTextureType, "noisedst3", RSID_NOISEDST3);
- sb.setType(mTextureType, "noisesrc4", RSID_NOISESRC4);
- sb.setType(mTextureType, "noisedst4", RSID_NOISEDST4);
- sb.setType(mTextureType, "noisesrc5", RSID_NOISESRC5);
- sb.setType(mTextureType, "noisedst5", RSID_NOISEDST5);
- sb.setScript(mResources, R.raw.clouds);
- sb.setRoot(true);
-
- ScriptC script = sb.create();
- script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- script.setTimeZone(TimeZone.getDefault().getID());
-
- script.bindAllocation(mState, RSID_STATE);
- script.bindAllocation(mSourceTextures[0], RSID_NOISESRC1);
- script.bindAllocation(mRealTextures[0], RSID_NOISEDST1);
- script.bindAllocation(mSourceTextures[1], RSID_NOISESRC2);
- script.bindAllocation(mRealTextures[1], RSID_NOISEDST2);
- script.bindAllocation(mSourceTextures[2], RSID_NOISESRC3);
- script.bindAllocation(mRealTextures[2], RSID_NOISEDST3);
- script.bindAllocation(mSourceTextures[3], RSID_NOISESRC4);
- script.bindAllocation(mRealTextures[3], RSID_NOISEDST4);
- script.bindAllocation(mSourceTextures[4], RSID_NOISESRC5);
- script.bindAllocation(mRealTextures[4], RSID_NOISEDST5);
- //script.bindAllocation(mPVAlloc.mAlloc, RSID_PROGRAMVERTEX);
-
-
- return script;
- */
- return null;
+ mScript.set_gPFSBackgroundOne(mPfsBackgroundOne);
+ mScript.set_gPFSBackgroundSrc(mPfsBackgroundSrc);
+
+ mScript.setClearColor(0.5f, 0.0f, 0.0f, 1.0f);
+
+ mScript.set_gPreset(mWorldState.mPreset);
+ mScript.set_gTextureMask(mWorldState.mTextureMask);
+ mScript.set_gRotate(mWorldState.mRotate);
+ mScript.set_gTextureSwap(mWorldState.mTextureSwap);
+ mScript.set_gProcessTextureMode(mWorldState.mProcessTextureMode);
+ mScript.set_gBackCol(mWorldState.mBackCol);
+ mScript.set_gLowCol(mWorldState.mLowCol);
+ mScript.set_gHighCol(mWorldState.mHighCol);
+ mScript.set_gAlphaMul(mWorldState.mAlphaMul);
+ mScript.set_gPreMul(mWorldState.mPreMul);
+ mScript.set_gBlendFunc(mWorldState.mBlendFunc);
+ mScript.set_gTilt(mWorldState.mTilt);
+ mScript.set_gXOffset(mWorldState.mXOffset);
+
+ return mScript;
}
}
diff --git a/src/com/android/magicsmoke/RenderScriptScene.java b/src/com/android/magicsmoke/RenderScriptScene.java
index 8a5e213..23b3360 100644
--- a/src/com/android/magicsmoke/RenderScriptScene.java
+++ b/src/com/android/magicsmoke/RenderScriptScene.java
@@ -18,9 +18,10 @@
package com.android.magicsmoke;
import android.content.res.Resources;
+import android.os.Bundle;
import android.renderscript.RenderScriptGL;
import android.renderscript.ScriptC;
-import android.view.MotionEvent;
+//import android.view.MotionEvent;
public abstract class RenderScriptScene {
protected int mWidth;
@@ -82,10 +83,12 @@ public abstract class RenderScriptScene {
}
@SuppressWarnings({"UnusedDeclaration"})
- public void setOffset(float xOffset, float yOffset,
- float xStep, float yStep, int xPixels, int yPixels) {
- }
- public void onTouchEvent(MotionEvent event) {
+ public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
}
+ @SuppressWarnings({"UnusedDeclaration"})
+ public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
+ boolean resultRequested) {
+ return null;
+ }
}
diff --git a/src/com/android/magicsmoke/RenderScriptWallpaper.java b/src/com/android/magicsmoke/RenderScriptWallpaper.java
index 1f24812..75abf0d 100644
--- a/src/com/android/magicsmoke/RenderScriptWallpaper.java
+++ b/src/com/android/magicsmoke/RenderScriptWallpaper.java
@@ -18,6 +18,7 @@
package com.android.magicsmoke;
import android.service.wallpaper.WallpaperService;
+import android.os.Bundle;
import android.renderscript.RenderScriptGL;
import android.renderscript.RenderScript;
import android.util.Log;
@@ -39,7 +40,7 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
super.onCreate(surfaceHolder);
- setTouchEventsEnabled(true);
+ setTouchEventsEnabled(false);
surfaceHolder.setSizeFromLayout();
}
@@ -87,15 +88,15 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
}
}
- @Override
+ /*@Override
public void onTouchEvent(MotionEvent event) {
mRenderer.onTouchEvent(event);
- }
+ }*/
@Override
public void onOffsetsChanged(float xOffset, float yOffset,
float xStep, float yStep, int xPixels, int yPixels) {
- mRenderer.setOffset(xOffset, yOffset, xStep, yStep, xPixels, yPixels);
+ mRenderer.setOffset(xOffset, yOffset, xPixels, yPixels);
}
@Override
@@ -115,5 +116,12 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
super.onSurfaceDestroyed(holder);
destroyRenderer();
}
+
+ @Override
+ public Bundle onCommand(String action, int x, int y, int z,
+ Bundle extras, boolean resultRequested) {
+ return mRenderer.onCommand(action, x, y, z, extras, resultRequested);
+ }
+
}
}
diff --git a/src/com/android/magicsmoke/ScriptC_MagicSmoke.java b/src/com/android/magicsmoke/ScriptC_MagicSmoke.java
new file mode 100644
index 0000000..7a6cd54
--- /dev/null
+++ b/src/com/android/magicsmoke/ScriptC_MagicSmoke.java
@@ -0,0 +1,203 @@
+
+package com.android.magicsmoke;
+
+import android.content.res.Resources;
+import android.renderscript.*;
+import android.util.Log;
+
+public class ScriptC_MagicSmoke
+ extends android.renderscript.ScriptC
+{
+
+ public ScriptC_MagicSmoke(RenderScript rs, Resources resources, int id, boolean isRoot) {
+ super(rs, resources, id, isRoot);
+ }
+
+ private float mField_gXOffset;
+ public void set_gXOffset(float v) {
+ mField_gXOffset = v;
+ setVar(0, v);
+ }
+ private float mField_gTilt;
+ public void set_gTilt(float v) {
+ mField_gTilt = v;
+ setVar(1, v);
+ }
+ private int mField_gPreset;
+ public void set_gPreset(int v) {
+ mField_gPreset = v;
+ setVar(2, v);
+ }
+ private int mField_gTextureMask;
+ public void set_gTextureMask(int v) {
+ mField_gTextureMask = v;
+ setVar(3, v);
+ }
+ private int mField_gRotate;
+ public void set_gRotate(int v) {
+ mField_gRotate = v;
+ setVar(4, v);
+ }
+ private int mField_gTextureSwap;
+ public void set_gTextureSwap(int v) {
+ mField_gTextureSwap = v;
+ setVar(5, v);
+ }
+ private int mField_gProcessTextureMode;
+ public void set_gProcessTextureMode(int v) {
+ mField_gProcessTextureMode = v;
+ setVar(6, v);
+ }
+ private int mField_gBackCol;
+ public void set_gBackCol(int v) {
+ mField_gBackCol = v;
+ setVar(7, v);
+ }
+ private int mField_gLowCol;
+ public void set_gLowCol(int v) {
+ mField_gLowCol = v;
+ setVar(8, v);
+ }
+ private int mField_gHighCol;
+ public void set_gHighCol(int v) {
+ mField_gHighCol = v;
+ setVar(9, v);
+ }
+ private float mField_gAlphaMul;
+ public void set_gAlphaMul(float v) {
+ mField_gAlphaMul = v;
+ setVar(10, v);
+ }
+ private int mField_gPreMul;
+ public void set_gPreMul(int v) {
+ mField_gPreMul = v;
+ setVar(11, v);
+ }
+ private int mField_gBlendFunc;
+ public void set_gBlendFunc(int v) {
+ mField_gBlendFunc = v;
+ setVar(12, v);
+ }
+
+ private ProgramVertex mField_gPVBackground;
+ public void set_gPVBackground(ProgramVertex v) {
+ mField_gPVBackground = v;
+ setVar(13, v.getID());
+ }
+ private ProgramFragment mField_gPFBackground;
+ public void set_gPFBackground(ProgramFragment v) {
+ mField_gPFBackground = v;
+ setVar(14, v.getID());
+ }
+ private ProgramStore mField_gPFSBackgroundOne;
+ public void set_gPFSBackgroundOne(ProgramStore v) {
+ mField_gPFSBackgroundOne = v;
+ setVar(15, v.getID());
+ }
+ private ProgramStore mField_gPFSBackgroundSrc;
+ public void set_gPFSBackgroundSrc(ProgramStore v) {
+ mField_gPFSBackgroundSrc = v;
+ setVar(16, v.getID());
+ }
+
+ private Allocation mField_gTnoise1;
+ public void set_gTnoise1(Allocation v) {
+ mField_gTnoise1 = v;
+ setVar(17, v.getID());
+ }
+ private Allocation mField_gTnoise2;
+ public void set_gTnoise2(Allocation v) {
+ mField_gTnoise2 = v;
+ setVar(18, v.getID());
+ }
+ private Allocation mField_gTnoise3;
+ public void set_gTnoise3(Allocation v) {
+ mField_gTnoise3 = v;
+ setVar(19, v.getID());
+ }
+ private Allocation mField_gTnoise4;
+ public void set_gTnoise4(Allocation v) {
+ mField_gTnoise4 = v;
+ setVar(20, v.getID());
+ }
+ private Allocation mField_gTnoise5;
+ public void set_gTnoise5(Allocation v) {
+ mField_gTnoise5 = v;
+ setVar(21, v.getID());
+ }
+
+ // Pointers
+ public void bind_gNoisesrc1(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 22);
+ } else {
+ bindAllocation(v, 22);
+ }
+ }
+ public void bind_gNoisesrc2(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 23);
+ } else {
+ bindAllocation(v, 23);
+ }
+ }
+ public void bind_gNoisesrc3(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 24);
+ } else {
+ bindAllocation(v, 24);
+ }
+ }
+ public void bind_gNoisesrc4(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 25);
+ } else {
+ bindAllocation(v, 25);
+ }
+ }
+ public void bind_gNoisesrc5(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 26);
+ } else {
+ bindAllocation(v, 26);
+ }
+ }
+
+ public void bind_gNoisedst1(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 27);
+ } else {
+ bindAllocation(v, 27);
+ }
+ }
+ public void bind_gNoisedst2(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 28);
+ } else {
+ bindAllocation(v, 28);
+ }
+ }
+ public void bind_gNoisedst3(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 29);
+ } else {
+ bindAllocation(v, 29);
+ }
+ }
+ public void bind_gNoisedst4(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 30);
+ } else {
+ bindAllocation(v, 30);
+ }
+ }
+ public void bind_gNoisedst5(Allocation v) {
+ if (v == null) {
+ bindAllocation(null, 31);
+ } else {
+ bindAllocation(v, 31);
+ }
+ }
+
+}
+