packages/wallpapers/Basic
Revision | fd1b3b35498508878dc41f22a270df95db316e4b (tree) |
---|---|
Time | 2009-09-10 10:31:58 |
Author | Romain Guy <romainguy@andr...> |
Commiter | Romain Guy |
Fix the galaxy.
Change-Id: If7e28c8587c070a540feb66017f561a67415dc7c
@@ -103,10 +103,10 @@ int main(int index) { | ||
103 | 103 | drawParticles(x, width, height); |
104 | 104 | drawLights(x, width, height); |
105 | 105 | |
106 | -// if (angle < 68.0f) { | |
107 | -// angle += 0.4f; | |
108 | -// distance = angle / 68.0f; | |
109 | -// } | |
106 | + if (angle < 68.0f) { | |
107 | + angle += 0.4f; | |
108 | + distance = angle / 68.0f; | |
109 | + } | |
110 | 110 | |
111 | 111 | return 1; |
112 | 112 | } |
@@ -35,6 +35,8 @@ import static android.renderscript.ProgramStore.BlendSrcFunc; | ||
35 | 35 | import static android.renderscript.ProgramFragment.EnvMode.*; |
36 | 36 | import static android.renderscript.Element.*; |
37 | 37 | import static android.util.MathUtils.*; |
38 | +import android.graphics.Bitmap; | |
39 | +import android.graphics.BitmapFactory; | |
38 | 40 | |
39 | 41 | import java.util.TimeZone; |
40 | 42 |
@@ -55,6 +57,8 @@ class GalaxyRS extends RenderScriptScene { | ||
55 | 57 | private static final int RSID_TEXTURE_LIGHT1 = 1; |
56 | 58 | private static final int RSID_TEXTURE_FLARES = 2; |
57 | 59 | |
60 | + private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options(); | |
61 | + | |
58 | 62 | @SuppressWarnings({"FieldCanBeLocal"}) |
59 | 63 | private ProgramFragment mPfBackground; |
60 | 64 | @SuppressWarnings({"FieldCanBeLocal"}) |
@@ -91,6 +95,9 @@ class GalaxyRS extends RenderScriptScene { | ||
91 | 95 | |
92 | 96 | GalaxyRS(int width, int height) { |
93 | 97 | super(width, height); |
98 | + | |
99 | + mOptionsARGB.inScaled = false; | |
100 | + mOptionsARGB.inPreferredConfig = Bitmap.Config.ARGB_8888; | |
94 | 101 | } |
95 | 102 | |
96 | 103 | @Override |
@@ -261,7 +268,7 @@ class GalaxyRS extends RenderScriptScene { | ||
261 | 268 | final Allocation[] textures = mTextures; |
262 | 269 | textures[RSID_TEXTURE_SPACE] = loadTexture(R.drawable.space, "TSpace"); |
263 | 270 | textures[RSID_TEXTURE_LIGHT1] = loadTexture(R.drawable.light1, "TLight1"); |
264 | - textures[RSID_TEXTURE_FLARES] = loadTexture(R.drawable.flares, "TFlares"); | |
271 | + textures[RSID_TEXTURE_FLARES] = loadTextureARGB(R.drawable.flares, "TFlares"); | |
265 | 272 | |
266 | 273 | final int count = textures.length; |
267 | 274 | for (int i = 0; i < count; i++) { |
@@ -276,6 +283,14 @@ class GalaxyRS extends RenderScriptScene { | ||
276 | 283 | return allocation; |
277 | 284 | } |
278 | 285 | |
286 | + // TODO: Fix Allocation.createFromBitmapResource() to do this when RGBA_8888 is specified | |
287 | + private Allocation loadTextureARGB(int id, String name) { | |
288 | + Bitmap b = BitmapFactory.decodeResource(mResources, id, mOptionsARGB); | |
289 | + final Allocation allocation = Allocation.createFromBitmap(mRS, b, RGBA_8888, false); | |
290 | + allocation.setName(name); | |
291 | + return allocation; | |
292 | + } | |
293 | + | |
279 | 294 | private void createProgramFragment() { |
280 | 295 | Sampler.Builder samplerBuilder = new Sampler.Builder(mRS); |
281 | 296 | samplerBuilder.setMin(NEAREST); |