packages/wallpapers/MagicSmoke
Revision | ae9ba5758133ba753bd4a749a81267e08a3ee811 (tree) |
---|---|
Zeit | 2010-02-13 04:26:33 |
Autor | Marco Nelissen <marcone@goog...> |
Commiter | Android Git Automerger |
am b7cac95f: DO NOT MERGE. Port live wallpaper changes from Froyo to Eclair for Droid support.
Merge commit 'b7cac95f928bf5b02f4a2a914c3a43014c2469f8' into eclair-plus-aosp
* commit 'b7cac95f928bf5b02f4a2a914c3a43014c2469f8':
@@ -21,6 +21,8 @@ | ||
21 | 21 | xmlns:android="http://schemas.android.com/apk/res/android" |
22 | 22 | package="com.android.magicsmoke"> |
23 | 23 | |
24 | + <uses-feature android:name="android.software.live_wallpaper" /> | |
25 | + | |
24 | 26 | <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> |
25 | 27 | <uses-permission android:name="android.permission.BIND_WALLPAPER" /> |
26 | 28 |
@@ -288,9 +288,10 @@ int main(int launchID) { | ||
288 | 288 | int now = uptimeMillis(); |
289 | 289 | timedelta = ((float)(now - lastuptime)) / 44.f; |
290 | 290 | lastuptime = now; |
291 | - if (timedelta > 100) { | |
292 | - // If we didn't render anything for several seconds, just pretend time stopped. | |
293 | - timedelta = 1; | |
291 | + if (timedelta > 3) { | |
292 | + // Limit the step adjustment factor to 3, so we don't get a sudden jump | |
293 | + // after coming back from sleep. | |
294 | + timedelta = 3; | |
294 | 295 | } |
295 | 296 | |
296 | 297 | i = State->mPreset; |
@@ -16,7 +16,6 @@ | ||
16 | 16 | |
17 | 17 | package com.android.magicsmoke; |
18 | 18 | |
19 | -import static android.renderscript.ProgramFragment.EnvMode.REPLACE; | |
20 | 19 | import static android.renderscript.Sampler.Value.LINEAR; |
21 | 20 | import static android.renderscript.Sampler.Value.WRAP; |
22 | 21 |
@@ -76,7 +75,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
76 | 75 | private Sampler mSampler; |
77 | 76 | private Allocation[] mSourceTextures; |
78 | 77 | private Allocation[] mRealTextures; |
79 | - | |
78 | + | |
80 | 79 | private ProgramVertex mPVBackground; |
81 | 80 | private ProgramVertex.MatrixAllocation mPVAlloc; |
82 | 81 |
@@ -95,7 +94,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
95 | 94 | |
96 | 95 | private Context mContext; |
97 | 96 | private SharedPreferences mSharedPref; |
98 | - | |
97 | + | |
99 | 98 | static class Preset { |
100 | 99 | Preset(int processmode, int backcol, int locol, int hicol, float mul, int mask, |
101 | 100 | boolean rot, int blend, boolean texswap, boolean premul) { |
@@ -146,9 +145,9 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
146 | 145 | new Preset(2, 0x6060ff, 0x000070, 0xffffff, 2.5f, 0x1f, true, 0, false, false), |
147 | 146 | new Preset(3, 0x0000f0, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, true, false), |
148 | 147 | }; |
149 | - | |
148 | + | |
150 | 149 | private float mTouchY; |
151 | - | |
150 | + | |
152 | 151 | MagicSmokeRS(Context context, int width, int height) { |
153 | 152 | super(width, height); |
154 | 153 | mWidth = width; |
@@ -182,7 +181,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
182 | 181 | mWorldState.mPreMul = mPreset[p].mPreMul ? 1 : 0; |
183 | 182 | mWorldState.mBlendFunc = mPreset[p].mBlendFunc; |
184 | 183 | } |
185 | - | |
184 | + | |
186 | 185 | @Override |
187 | 186 | public void resize(int width, int height) { |
188 | 187 | super.resize(width, height); |
@@ -211,7 +210,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
211 | 210 | mState.data(mWorldState); |
212 | 211 | } |
213 | 212 | } |
214 | - | |
213 | + | |
215 | 214 | @Override |
216 | 215 | public void setOffset(float xOffset, float yOffset, float xStep, float yStep, |
217 | 216 | int xPixels, int yPixels) { |
@@ -233,10 +232,10 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
233 | 232 | makeNewState(); |
234 | 233 | mState.data(mWorldState); |
235 | 234 | } |
236 | - | |
235 | + | |
237 | 236 | float alphafactor; |
238 | 237 | Type mTextureType; |
239 | - | |
238 | + | |
240 | 239 | void loadBitmap(int id, int index, String name, float alphamul, int lowcol, int highcol) { |
241 | 240 | BitmapFactory.Options opts = new BitmapFactory.Options(); |
242 | 241 | opts.inPreferredConfig = Bitmap.Config.ARGB_8888; |
@@ -259,7 +258,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
259 | 258 | int highcol = mPreset[mWorldState.mPreset].mHighColor; |
260 | 259 | //Log.i("@@@@", "preset " + mWorldState.mPreset + ", mul: " + alphamul + |
261 | 260 | // ", colors: " + Integer.toHexString(lowcol) + "/" + Integer.toHexString(highcol)); |
262 | - | |
261 | + | |
263 | 262 | // TODO: using different high and low colors for each layer offers some cool effects too |
264 | 263 | loadBitmap(R.drawable.noise1, 0, "Tnoise1", alphamul, lowcol, highcol); |
265 | 264 | loadBitmap(R.drawable.noise2, 1, "Tnoise2", alphamul, lowcol, highcol); |
@@ -267,7 +266,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
267 | 266 | loadBitmap(R.drawable.noise4, 3, "Tnoise4", alphamul, lowcol, highcol); |
268 | 267 | loadBitmap(R.drawable.noise5, 4, "Tnoise5", alphamul, lowcol, highcol); |
269 | 268 | } |
270 | - | |
269 | + | |
271 | 270 | @Override |
272 | 271 | protected ScriptC createScript() { |
273 | 272 |
@@ -289,13 +288,13 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
289 | 288 | |
290 | 289 | mSourceTextures = new Allocation[5]; |
291 | 290 | mRealTextures = new Allocation[5]; |
292 | - | |
291 | + | |
293 | 292 | Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS)); |
294 | 293 | tb.add(Dimension.X, 256); |
295 | 294 | tb.add(Dimension.Y, 256); |
296 | 295 | mTextureType = tb.create(); |
297 | 296 | loadBitmaps(); |
298 | - | |
297 | + | |
299 | 298 | Sampler.Builder samplerBuilder = new Sampler.Builder(mRS); |
300 | 299 | samplerBuilder.setMin(LINEAR); |
301 | 300 | samplerBuilder.setMag(LINEAR); |
@@ -304,9 +303,9 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange | ||
304 | 303 | mSampler = samplerBuilder.create(); |
305 | 304 | |
306 | 305 | { |
307 | - ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null); | |
308 | - builder.setTexEnable(true, 0); | |
309 | - builder.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); | |
306 | + ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS); | |
307 | + builder.setTexture(ProgramFragment.Builder.EnvMode.REPLACE, | |
308 | + ProgramFragment.Builder.Format.RGBA, 0); | |
310 | 309 | mPfBackground = builder.create(); |
311 | 310 | mPfBackground.setName("PFBackground"); |
312 | 311 | mPfBackground.bindSampler(mSampler, 0); |