summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Hong <leonhong@google.com>2011-09-29 18:13:08 -0700
committerLeon Hong <leonhong@google.com>2011-09-30 12:07:50 -0700
commit8810182edad49e8415b327b29cc2113304c6ea55 (patch)
tree9a0ecc50d5e86970241576b581377921b80ba3a5
parent46f29fce15d2b2011318de1394690bbb804c91ed (diff)
downloadandroid_packages_wallpapers_PhaseBeam-8810182edad49e8415b327b29cc2113304c6ea55.tar.gz
android_packages_wallpapers_PhaseBeam-8810182edad49e8415b327b29cc2113304c6ea55.tar.bz2
android_packages_wallpapers_PhaseBeam-8810182edad49e8415b327b29cc2113304c6ea55.zip
Background and assets changes, darker look
- Darker colors for background mesh - More chroma shifts in assets - Updated thumbnail to reflect new look - Loading mesh data from external file - Class variable name cleanup Change-Id: I67e57e0dca069fd2056e39307946e69fec73a35b
-rw-r--r--res/drawable-nodpi/beam.pngbin2764 -> 7082 bytes
-rw-r--r--res/drawable-nodpi/dot.pngbin5847 -> 7045 bytes
-rw-r--r--res/drawable-nodpi/wallpaper_thumb.pngbin55334 -> 34739 bytes
-rw-r--r--res/raw/bgmesh.csv102
-rw-r--r--src/com/android/phasebeam/PhaseBeamRS.java219
-rw-r--r--src/com/android/phasebeam/PhaseBeamWallpaper.java6
-rw-r--r--src/com/android/phasebeam/phasebeam.rs62
7 files changed, 202 insertions, 187 deletions
diff --git a/res/drawable-nodpi/beam.png b/res/drawable-nodpi/beam.png
index 5e6a563..98196eb 100644
--- a/res/drawable-nodpi/beam.png
+++ b/res/drawable-nodpi/beam.png
Binary files differ
diff --git a/res/drawable-nodpi/dot.png b/res/drawable-nodpi/dot.png
index a452f86..2eec7d3 100644
--- a/res/drawable-nodpi/dot.png
+++ b/res/drawable-nodpi/dot.png
Binary files differ
diff --git a/res/drawable-nodpi/wallpaper_thumb.png b/res/drawable-nodpi/wallpaper_thumb.png
index 28cefdf..26055f1 100644
--- a/res/drawable-nodpi/wallpaper_thumb.png
+++ b/res/drawable-nodpi/wallpaper_thumb.png
Binary files differ
diff --git a/res/raw/bgmesh.csv b/res/raw/bgmesh.csv
new file mode 100644
index 0000000..0949d63
--- /dev/null
+++ b/res/raw/bgmesh.csv
@@ -0,0 +1,102 @@
+-0.75,1.0,0.0,0.643,1.1
+-1.25,1.0,0.0,0.776,1.035
+-1.0,0.6,0.0,0.643,1.1
+0.0,1.0,0.0,0.6,1.1
+-0.75,1.0,0.0,0.643,1.1
+-0.5,0.6,0.0,0.643,1.1
+0.625,1.0,0.194,0.423,0.569
+0.0,1.0,0.0,0.6,1.1
+0.375,0.6,0.207,0.207,0.487
+1.25,1.0,0.009,0.09,0.166
+0.625,1.0,0.194,0.423,0.569
+0.875,0.4,0.104,0.091,0.259
+-1.0,0.6,0.0,0.643,1.1
+-1.25,1.0,0.0,0.776,1.035
+-1.25,0.2,0.362,0.315,0.66
+-0.75,0.4,0.056,0.6,1.018
+-1.0,0.6,0.0,0.643,1.1
+-1.25,0.2,0.362,0.315,0.66
+-0.5,0.6,0.0,0.643,1.1
+-0.75,1.0,0.0,0.643,1.1
+-1.0,0.6,0.0,0.643,1.1
+-0.5,0.6,0.0,0.643,1.1
+-1.0,0.6,0.0,0.643,1.1
+-0.75,0.4,0.056,0.6,1.018
+0.0,0.3,0.138,0.155,0.522
+0.0,1.0,0.0,0.6,1.1
+-0.5,0.6,0.0,0.643,1.1
+0.0,0.3,0.138,0.155,0.522
+0.375,0.6,0.207,0.207,0.487
+0.0,1.0,0.0,0.6,1.1
+0.875,0.4,0.104,0.091,0.259
+0.625,1.0,0.194,0.423,0.569
+0.375,0.6,0.207,0.207,0.487
+1.25,0.1,0.16,0.0,0.25
+1.25,1.0,0.009,0.09,0.166
+0.875,0.4,0.104,0.091,0.259
+0.375,-0.0,0.104,0.022,0.198
+0.375,0.6,0.207,0.207,0.487
+0.0,0.3,0.138,0.155,0.522
+-0.375,-0.0,0.207,0.207,0.487
+-0.5,0.6,0.0,0.643,1.1
+-0.75,0.4,0.056,0.6,1.018
+0.0,0.3,0.138,0.155,0.522
+-0.5,0.6,0.0,0.643,1.1
+-0.375,-0.0,0.207,0.207,0.487
+-0.75,-0.1,0.393,0.189,0.725
+-0.75,0.4,0.056,0.6,1.018
+-1.25,0.2,0.362,0.315,0.66
+-0.75,-0.1,0.393,0.189,0.725
+-1.25,0.2,0.362,0.315,0.66
+-1.25,-0.64,0.143,0.121,0.574
+-0.375,-0.0,0.207,0.207,0.487
+-0.75,0.4,0.056,0.6,1.018
+-0.75,-0.1,0.393,0.189,0.725
+0.375,-0.0,0.104,0.022,0.198
+0.0,0.3,0.138,0.155,0.522
+-0.375,-0.0,0.207,0.207,0.487
+0.875,0.4,0.104,0.091,0.259
+0.375,0.6,0.207,0.207,0.487
+0.375,-0.0,0.104,0.022,0.198
+1.25,0.1,0.16,0.0,0.25
+0.875,0.4,0.104,0.091,0.259
+0.375,-0.0,0.104,0.022,0.198
+-0.375,-0.5,0.086,0.017,0.315
+-0.75,-0.1,0.393,0.189,0.725
+-1.25,-0.64,0.143,0.121,0.574
+-0.375,-0.5,0.086,0.017,0.315
+-0.375,-0.0,0.207,0.207,0.487
+-0.75,-0.1,0.393,0.189,0.725
+0.125,-0.5,0.035,0.004,0.181
+-0.375,-0.0,0.207,0.207,0.487
+-0.375,-0.5,0.086,0.017,0.315
+0.125,-0.5,0.035,0.004,0.181
+0.375,-0.0,0.104,0.022,0.198
+-0.375,-0.0,0.207,0.207,0.487
+0.625,-0.4,0.022,0.009,0.095
+0.375,-0.0,0.104,0.022,0.198
+0.125,-0.5,0.035,0.004,0.181
+0.625,-0.4,0.022,0.009,0.095
+1.25,0.1,0.16,0.0,0.25
+0.375,-0.0,0.104,0.022,0.198
+1.25,-1.0,0.0,0.129,0.259
+1.25,0.1,0.16,0.0,0.25
+0.625,-0.4,0.022,0.009,0.095
+1.25,-1.0,0.0,0.129,0.259
+0.625,-0.4,0.022,0.009,0.095
+0.375,-1.0,0.0,0.0,0.0
+0.375,-1.0,0.0,0.0,0.0
+0.625,-0.4,0.022,0.009,0.095
+0.125,-0.5,0.035,0.004,0.181
+0.375,-1.0,0.0,0.0,0.0
+0.125,-0.5,0.035,0.004,0.181
+-0.5,-1.0,0.017,0.004,0.078
+-0.5,-1.0,0.017,0.004,0.078
+0.125,-0.5,0.035,0.004,0.181
+-0.375,-0.5,0.086,0.017,0.315
+-0.5,-1.0,0.017,0.004,0.078
+-0.375,-0.5,0.086,0.017,0.315
+-1.25,-1.0,0.16,0.008,0.008
+-1.25,-0.64,0.143,0.121,0.574
+-1.25,-1.0,0.16,0.008,0.008
+-0.375,-0.5,0.086,0.017,0.315 \ No newline at end of file
diff --git a/src/com/android/phasebeam/PhaseBeamRS.java b/src/com/android/phasebeam/PhaseBeamRS.java
index 547f5f5..647f145 100644
--- a/src/com/android/phasebeam/PhaseBeamRS.java
+++ b/src/com/android/phasebeam/PhaseBeamRS.java
@@ -22,9 +22,15 @@ import android.renderscript.Mesh.Primitive;
import android.graphics.Color;
import android.renderscript.Float3;
import android.renderscript.Float4;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import android.util.Log;
public class PhaseBeamRS {
-
+ public static String LOG_TAG = "PhaseBeam";
public static final int DOT_COUNT = 28;
private Resources mRes;
private RenderScriptGL mRS;
@@ -33,24 +39,24 @@ public class PhaseBeamRS {
int mWidth;
private ScriptField_VpConsts mPvConsts;
- private Allocation dotAllocation;
- private Allocation beamAllocation;
+ private Allocation mDotAllocation;
+ private Allocation mBeamAllocation;
- private ScriptField_Particle dotParticles;
- private Mesh dotMesh;
+ private ScriptField_Particle mDotParticles;
+ private Mesh mDotMesh;
- private ScriptField_Particle beamParticles;
- private Mesh beamMesh;
+ private ScriptField_Particle mBeamParticles;
+ private Mesh mBeamMesh;
- private ScriptField_VertexColor_s vertexColors;
+ private ScriptField_VertexColor_s mVertexColors;
- private int densityDPI;
+ private int mDensityDPI;
- boolean inited = false;
+ boolean mInited = false;
public void init(int dpi, RenderScriptGL rs, Resources res, int width, int height) {
- if (!inited) {
- densityDPI = dpi;
+ if (!mInited) {
+ mDensityDPI = dpi;
mRS = rs;
mRes = res;
@@ -58,23 +64,23 @@ public class PhaseBeamRS {
mWidth = width;
mHeight = height;
- dotParticles = new ScriptField_Particle(mRS, DOT_COUNT);
+ mDotParticles = new ScriptField_Particle(mRS, DOT_COUNT);
Mesh.AllocationBuilder smb2 = new Mesh.AllocationBuilder(mRS);
- smb2.addVertexAllocation(dotParticles.getAllocation());
+ smb2.addVertexAllocation(mDotParticles.getAllocation());
smb2.addIndexSetType(Mesh.Primitive.POINT);
- dotMesh = smb2.create();
+ mDotMesh = smb2.create();
- beamParticles = new ScriptField_Particle(mRS, DOT_COUNT);
+ mBeamParticles = new ScriptField_Particle(mRS, DOT_COUNT);
Mesh.AllocationBuilder smb3 = new Mesh.AllocationBuilder(mRS);
- smb3.addVertexAllocation(beamParticles.getAllocation());
+ smb3.addVertexAllocation(mBeamParticles.getAllocation());
smb3.addIndexSetType(Mesh.Primitive.POINT);
- beamMesh = smb3.create();
+ mBeamMesh = smb3.create();
mScript = new ScriptC_phasebeam(mRS, mRes, R.raw.phasebeam);
- mScript.set_dotMesh(dotMesh);
- mScript.set_beamMesh(beamMesh);
- mScript.bind_dotParticles(dotParticles);
- mScript.bind_beamParticles(beamParticles);
+ mScript.set_dotMesh(mDotMesh);
+ mScript.set_beamMesh(mBeamMesh);
+ mScript.bind_dotParticles(mDotParticles);
+ mScript.bind_beamParticles(mBeamParticles);
mPvConsts = new ScriptField_VpConsts(mRS, 1);
@@ -85,12 +91,12 @@ public class PhaseBeamRS {
createBackgroundMesh();
loadTextures();
- mScript.set_densityDPI(densityDPI);
+ mScript.set_densityDPI(mDensityDPI);
mRS.bindRootScript(mScript);
mScript.invoke_positionParticles();
- inited = true;
+ mInited = true;
}
}
@@ -122,134 +128,51 @@ public class PhaseBeamRS {
Matrix4f projNorm = getProjectionNormalized(mWidth, mHeight);
ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
i.MVP = projNorm;
- i.scaleSize = densityDPI / 240.0f;
+ i.scaleSize = mDensityDPI / 240.0f;
mPvConsts.set(i, 0, true);
}
private void createBackgroundMesh() {
// The composition and colors of the background mesh were plotted on paper and photoshop
- // first then translated to the code you see below. Points and colors are not random.
-
- vertexColors = new ScriptField_VertexColor_s(mRS, 48);
-
- Float3 a = new Float3(-1.25f, 1.0f, 0.0f);
- Float3 b = new Float3(0.0f, 1.0f, 0.0f);
- Float3 c = new Float3(1.25f, 1.0f, 0.0f);
- Float3 d = new Float3(-0.875f, 0.3f, 0.0f);
- Float3 e = new Float3(-0.5f, 0.4f, 0.0f);
- Float3 f = new Float3(0.25f, 0.2f, 0.0f);
- Float3 g = new Float3(0.0f, 0.2f, 0.0f);
- Float3 h = new Float3(-0.625f, 0.1f, 0.0f);
- Float3 i = new Float3(-1.25f, -0.2f, 0.0f);
- Float3 j = new Float3(-0.125f, -0.6f, 0.0f);
- Float3 k = new Float3(-1.25f, -1.0f, 0.0f);
- Float3 l = new Float3(1.25f, -1.0f, 0.0f);
- vertexColors.set_position(0, a, false);
- vertexColors.set_color(0, (new Float4(0.0f,0.584f,1.0f, 1.0f)), false);
- vertexColors.set_position(1, i, false);
- vertexColors.set_color(1, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(2, d, false);
- vertexColors.set_color(2, (new Float4(0.51f,0.549f,0.929f, 1.0f)), false);
- vertexColors.set_position(3, a, false);
- vertexColors.set_color(3, (new Float4(0.0f,0.584f,1.0f, 1.0f)), false);
- vertexColors.set_position(4, d, false);
- vertexColors.set_color(4, (new Float4(0.51f,0.549f,0.929f, 1.0f)), false);
- vertexColors.set_position(5, e, false);
- vertexColors.set_color(5, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(6, a, false);
- vertexColors.set_color(6, (new Float4(0.0f,0.584f,1.0f, 1.0f)), false);
- vertexColors.set_position(7, e, false);
- vertexColors.set_color(7, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(8, b, false);
- vertexColors.set_color(8, (new Float4(0.573f,0.863f,1.0f, 1.0f)), false);
- vertexColors.set_position(9, b, false);
- vertexColors.set_color(9, (new Float4(0.573f,0.863f,1.0f, 1.0f)), false);
- vertexColors.set_position(10, e, false);
- vertexColors.set_color(10, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(11, f, false);
- vertexColors.set_color(11, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(12, b, false);
- vertexColors.set_color(12, (new Float4(0.573f,0.863f,1.0f, 1.0f)), false);
- vertexColors.set_position(13, f, false);
- vertexColors.set_color(13, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(14, c, false);
- vertexColors.set_color(14, (new Float4(0.188f,0.533f,0.882f, 1.0f)), false);
- vertexColors.set_position(15, c, false);
- vertexColors.set_color(15, (new Float4(0.188f,0.533f,0.882f, 1.0f)), false);
- vertexColors.set_position(16, f, false);
- vertexColors.set_color(16, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(17, l, false);
- vertexColors.set_color(17, (new Float4(0.29f,0.31f,0.392f, 1.0f)), false);
- vertexColors.set_position(18, f, false);
- vertexColors.set_color(18, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(19, e, false);
- vertexColors.set_color(19, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(20, g, false);
- vertexColors.set_color(20, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(21, f, false);
- vertexColors.set_color(21, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(22, g, false);
- vertexColors.set_color(22, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(23, l, false);
- vertexColors.set_color(23, (new Float4(0.29f,0.31f,0.392f, 1.0f)), false);
- vertexColors.set_position(24, g, false);
- vertexColors.set_color(24, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(25, e, false);
- vertexColors.set_color(25, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(26, h, false);
- vertexColors.set_color(26, (new Float4(0.251f,0.62f,0.851f, 1.0f)), false);
- vertexColors.set_position(27, h, false);
- vertexColors.set_color(27, (new Float4(0.251f,0.62f,0.851f, 1.0f)), false);
- vertexColors.set_position(28, e, false);
- vertexColors.set_color(28, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(29, d, false);
- vertexColors.set_color(29, (new Float4(0.51f,0.549f,0.929f, 1.0f)), false);
- vertexColors.set_position(30, d, false);
- vertexColors.set_color(30, (new Float4(0.51f,0.549f,0.929f, 1.0f)), false);
- vertexColors.set_position(31, i, false);
- vertexColors.set_color(31, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(32, h, false);
- vertexColors.set_color(32, (new Float4(0.251f,0.62f,0.851f, 1.0f)), false);
- vertexColors.set_position(33, j, false);
- vertexColors.set_color(33, (new Float4(0.157f,0.122f,0.506f, 1.0f)), false);
- vertexColors.set_position(34, h, false);
- vertexColors.set_color(34, (new Float4(0.251f,0.62f,0.851f, 1.0f)), false);
- vertexColors.set_position(35, i, false);
- vertexColors.set_color(35, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(36, j, false);
- vertexColors.set_color(36, (new Float4(0.157f,0.122f,0.506f, 1.0f)), false);
- vertexColors.set_position(37, i, false);
- vertexColors.set_color(37, (new Float4(0.196f,0.745f,1.0f, 1.0f)), false);
- vertexColors.set_position(38, k, false);
- vertexColors.set_color(38, (new Float4(0.357f,0.0f,0.408f, 1.0f)), false);
- vertexColors.set_position(39, l, false);
- vertexColors.set_color(39, (new Float4(0.29f,0.31f,0.392f, 1.0f)), false);
- vertexColors.set_position(40, j, false);
- vertexColors.set_color(40, (new Float4(0.157f,0.122f,0.506f, 1.0f)), false);
- vertexColors.set_position(41, k, false);
- vertexColors.set_color(41, (new Float4(0.357f,0.0f,0.408f, 1.0f)), false);
- vertexColors.set_position(42, g, false);
- vertexColors.set_color(42, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(43, h, false);
- vertexColors.set_color(43, (new Float4(0.251f,0.62f,0.851f, 1.0f)), false);
- vertexColors.set_position(44, j, false);
- vertexColors.set_color(44, (new Float4(0.157f,0.122f,0.506f, 1.0f)), false);
- vertexColors.set_position(45, l, false);
- vertexColors.set_color(45, (new Float4(0.29f,0.31f,0.392f, 1.0f)), false);
- vertexColors.set_position(46, g, false);
- vertexColors.set_color(46, (new Float4(0.467f,0.522f,0.827f, 1.0f)), false);
- vertexColors.set_position(47, j, false);
- vertexColors.set_color(47, (new Float4(0.157f,0.122f,0.506f, 1.0f)), false);
-
- vertexColors.copyAll();
+ // first then translated to the csv file in raw. Points and colors are not random.
+ ArrayList meshData = new ArrayList();
+ InputStream inputStream = mRes.openRawResource(R.raw.bgmesh);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ meshData.add(line);
+ }
+ } catch (IOException e) {
+ Log.e(LOG_TAG, "Unable to load background mesh from csv file.");
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ Log.e(LOG_TAG, "Unable to close background mesh csv file.");
+ }
+ }
+
+ int meshDataSize = meshData.size();
+ mVertexColors = new ScriptField_VertexColor_s(mRS, meshDataSize);
+ for(int i=0; i<meshDataSize; i++) {
+ String line = (String) meshData.get(i);
+ String[] values = line.split(",");
+ float xPos = new Float(values[0]);
+ float yPos = new Float(values[1]);
+ float red = new Float(values[2]);
+ float green = new Float(values[3]);
+ float blue = new Float(values[4]);
+ mVertexColors.set_position(i, new Float3(xPos, yPos, 0.0f), false);
+ mVertexColors.set_color(i, new Float4(red, green, blue, 1.0f), false);
+ }
+ mVertexColors.copyAll();
Mesh.AllocationBuilder backgroundBuilder = new Mesh.AllocationBuilder(mRS);
backgroundBuilder.addIndexSetType(Primitive.TRIANGLE);
- backgroundBuilder.addVertexAllocation(vertexColors.getAllocation());
+ backgroundBuilder.addVertexAllocation(mVertexColors.getAllocation());
mScript.set_gBackgroundMesh(backgroundBuilder.create());
-
- mScript.bind_vertexColors(vertexColors);
-
+ mScript.bind_vertexColors(mVertexColors);
}
private Allocation loadTexture(int id) {
@@ -258,10 +181,10 @@ public class PhaseBeamRS {
}
private void loadTextures() {
- dotAllocation = loadTexture(R.drawable.dot);
- beamAllocation = loadTexture(R.drawable.beam);
- mScript.set_textureDot(dotAllocation);
- mScript.set_textureBeam(beamAllocation);
+ mDotAllocation = loadTexture(R.drawable.dot);
+ mBeamAllocation = loadTexture(R.drawable.beam);
+ mScript.set_textureDot(mDotAllocation);
+ mScript.set_textureBeam(mBeamAllocation);
}
private void createProgramVertex() {
@@ -276,7 +199,7 @@ public class PhaseBeamRS {
ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS);
builder.setShader(mRes, R.raw.dot_vs);
builder.addConstant(mPvConsts.getType());
- builder.addInput(dotMesh.getVertexAllocation(0).getType().getElement());
+ builder.addInput(mDotMesh.getVertexAllocation(0).getType().getElement());
ProgramVertex pvs = builder.create();
pvs.bindConstants(mPvConsts.getAllocation(), 0);
mRS.bindProgramVertex(pvs);
diff --git a/src/com/android/phasebeam/PhaseBeamWallpaper.java b/src/com/android/phasebeam/PhaseBeamWallpaper.java
index 6b291e7..2e6cfbd 100644
--- a/src/com/android/phasebeam/PhaseBeamWallpaper.java
+++ b/src/com/android/phasebeam/PhaseBeamWallpaper.java
@@ -20,7 +20,7 @@ public class PhaseBeamWallpaper extends WallpaperService {
private class RenderScriptEngine extends Engine {
private RenderScriptGL mRenderScript = null;
private PhaseBeamRS mWallpaperRS = null;
- private int densityDPI;
+ private int mDensityDPI;
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
@@ -32,7 +32,7 @@ public class PhaseBeamWallpaper extends WallpaperService {
DisplayMetrics metrics = new DisplayMetrics();
((WindowManager) getApplication().getSystemService(Service.WINDOW_SERVICE))
.getDefaultDisplay().getMetrics(metrics);
- densityDPI = metrics.densityDpi;
+ mDensityDPI = metrics.densityDpi;
}
@Override
@@ -80,7 +80,7 @@ public class PhaseBeamWallpaper extends WallpaperService {
if (mWallpaperRS == null) {
mWallpaperRS = new PhaseBeamRS();
- mWallpaperRS.init(densityDPI, mRenderScript, getResources(), width, height);
+ mWallpaperRS.init(mDensityDPI, mRenderScript, getResources(), width, height);
mWallpaperRS.start();
}
diff --git a/src/com/android/phasebeam/phasebeam.rs b/src/com/android/phasebeam/phasebeam.rs
index 77472ca..037f303 100644
--- a/src/com/android/phasebeam/phasebeam.rs
+++ b/src/com/android/phasebeam/phasebeam.rs
@@ -17,6 +17,7 @@ rs_program_fragment fragDots;
static int numBeamParticles;
static int numDotParticles;
+static int numVertColors;
typedef struct __attribute__((packed, aligned(4))) Particle {
float3 position;
@@ -55,7 +56,7 @@ static float halfScreenHeight;
static float newOffset = 0.5;
static float oldOffset = 0.5;
-void positionParticles(){
+void positionParticles() {
screenWidth = rsgGetWidth();
screenHeight = rsgGetHeight();
halfScreenWidth = screenWidth/2.0f;
@@ -64,24 +65,23 @@ void positionParticles(){
quarterScreenHeight = screenHeight/4.0f;
Particle_t* particle = dotParticles;
numDotParticles = rsAllocationGetDimX(rsGetAllocation(dotParticles));
- for(int i=0; i<numDotParticles; i++){
-
-
+ numVertColors = rsAllocationGetDimX(rsGetAllocation(vertexColors));
+ for(int i=0; i<numDotParticles; i++) {
particle->position.x = rsRand(0.0f, 3.0f);
particle->position.y = rsRand(-1.25f, 1.25f);
float z;
- if(i < 3){
+ if (i < 3) {
z = 14.0f;
- } if(i < 7){
+ } else if(i < 7) {
z = 25.0f;
- } else if(i < 4){
+ } else if(i < 4) {
z = rsRand(10.f, 20.f);
- } else if(i == 10){
+ } else if(i == 10) {
z = 24.0f;
particle->position.x = 1.0;
} else {
- z = rsRand(4.0f, 10.0f);
+ z = rsRand(6.0f, 14.0f);
}
particle->position.z = z;
particle->offsetX = 0;
@@ -89,12 +89,11 @@ void positionParticles(){
particle++;
}
-
Particle_t* beam = beamParticles;
numBeamParticles = rsAllocationGetDimX(rsGetAllocation(beamParticles));
- for(int i=0; i<numBeamParticles; i++){
+ for(int i=0; i<numBeamParticles; i++) {
float z;
- if(i < 20){
+ if(i < 20) {
z = rsRand(4.0f, 10.0f)/2.0f;
} else {
z = rsRand(4.0f, 35.0f)/2.0f;
@@ -108,60 +107,53 @@ void positionParticles(){
}
}
-int root(){
+int root() {
newOffset = xOffset*2;
rsgClearColor(0.0f, 0.f, 0.f,1.0f);
-
-
- VertexColor* vert = vertexColors;
- for(int i=0; i<48; i++){
- vert->offsetX = -xOffset/2.0;
- vert++;
+ if(newOffset != oldOffset) {
+ VertexColor* vert = vertexColors;
+ for(int i=0; i<numVertColors; i++) {
+ vert->offsetX = -xOffset/2.0;
+ vert++;
+ }
}
-
rsgBindProgramVertex(vertBg);
rsgBindProgramFragment(fragBg);
rsgDrawMesh(gBackgroundMesh);
-
Particle_t* beam = beamParticles;
Particle_t* particle = dotParticles;
- for(int i=0; i<numDotParticles; i++){
+ for(int i=0; i<numDotParticles; i++) {
- if(newOffset==oldOffset){
- if(beam->position.x/beam->position.z > 0.5){
+ if(newOffset==oldOffset) {
+ if(beam->position.x/beam->position.z > 0.5) {
beam->position.x = -1.0;
}
- if(particle->position.x/particle->position.z > 0.5){
+ if(particle->position.x/particle->position.z > 0.5) {
particle->position.x = -1.0;
}
- if(beam->position.y > 1.05){
+ if(beam->position.y > 1.05) {
beam->position.y = -1.05;
beam->position.x = rsRand(-1.25f, 1.25f);
} else {
beam->position.y = beam->position.y + 0.000160*beam->position.z;
}
- if(particle->position.y > 1.25){
+ if(particle->position.y > 1.25) {
particle->position.y = -1.25;
particle->position.x = rsRand(0.0f, 3.0f);
} else {
particle->position.y = particle->position.y + 0.00022*particle->position.z;
}
-
-
}
-
-
-
- beam->position.x = beam->position.x + 0.0001010*beam->position.z;
+ beam->position.x = beam->position.x + 0.0001*beam->position.z;
beam->offsetX = newOffset;
beam++;
particle->offsetX = newOffset;
@@ -169,8 +161,6 @@ int root(){
particle++;
}
-
-
rsgBindProgramVertex(vertDots);
rsgBindProgramFragment(fragDots);
@@ -182,6 +172,6 @@ int root(){
oldOffset = newOffset;
- return 55;
+ return 66;
}