• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/wallpapers/Basic


Commit MetaInfo

修订版44da17844aa73a047a1f1ff67b4794ea330be3b5 (tree)
时间2009-08-29 03:03:21
作者Romain Guy <romainguy@andr...>
CommiterRomain Guy

Log Message

Refactor RenderScript wallpapers to share more code between the implementations.

Change-Id: I5995f68438531396cfae80c27e5d7781effaaa31

更改概述

差异

--- a/res/raw/grass.rs
+++ b/res/raw/grass.rs
@@ -53,11 +53,12 @@
5353
5454 #define REAL_TIME 0
5555
56-float time(int frameCount) {
56+float time() {
5757 if (REAL_TIME) {
5858 return (hour() * 3600.0f + minute() * 60.0f + second()) / SECONDS_IN_DAY;
5959 }
60- return (frameCount % 180) / 180.0f;
60+ float t = uptimeMillis() / 20000.0f;
61+ return t - (int) t;
6162 }
6263
6364 void alpha(float a) {
@@ -92,14 +93,14 @@ void drawSunset(int width, int height) {
9293 drawRect(0.0f, 0.0f, width, height, 0.0f);
9394 }
9495
95-int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor, float now, int frameCount) {
96+int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor, float now, float xOffset) {
9697 float offset = bladeStruct[BLADE_STRUCT_OFFSET];
9798 float scale = bladeStruct[BLADE_STRUCT_SCALE];
9899 float angle = bladeStruct[BLADE_STRUCT_ANGLE];
99100 float hardness = bladeStruct[BLADE_STRUCT_HARDNESS];
100101 float turbulenceX = bladeStruct[BLADE_STRUCT_TURBULENCEX];
101102
102- float xpos = bladeStruct[BLADE_STRUCT_XPOS];
103+ float xpos = bladeStruct[BLADE_STRUCT_XPOS] + xOffset;
103104 float ypos = bladeStruct[BLADE_STRUCT_YPOS];
104105
105106 float lengthX = bladeStruct[BLADE_STRUCT_LENGTHX];
@@ -126,7 +127,7 @@ int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor, float now
126127
127128 int color = hsbToAbgr(h, s, lerpf(0, b, newB), 1.0f);
128129
129- float newAngle = turbulencef2(turbulenceX, frameCount * 0.006f, 4.0f) - 0.5f;
130+ float newAngle = turbulencef2(turbulenceX, uptimeMillis() * 0.00004f, 4.0f) - 0.5f;
130131 newAngle *= 0.5f;
131132 angle = clampf(angle + (newAngle + offset - angle) * 0.15f, -MAX_BEND, MAX_BEND);
132133
@@ -202,7 +203,7 @@ int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor, float now
202203 return triangles * 15;
203204 }
204205
205-void drawBlades(float now, int frameCount) {
206+void drawBlades(float now, float xOffset) {
206207 // For anti-aliasing
207208 bindTexture(NAMED_PFBackground, 0, NAMED_TAa);
208209
@@ -215,7 +216,7 @@ void drawBlades(float now, int frameCount) {
215216 int *bladeColor = loadArrayI32(RSID_BLADES_BUFFER, 0);
216217
217218 for ( ; i < bladesCount; i += 1) {
218- int offset = drawBlade(bladeStruct, bladeBuffer, bladeColor, now, frameCount);
219+ int offset = drawBlade(bladeStruct, bladeBuffer, bladeColor, now, xOffset);
219220 bladeBuffer += offset;
220221 bladeColor += offset;
221222 bladeStruct += BLADE_STRUCT_FIELDS_COUNT;
@@ -229,8 +230,9 @@ int main(int launchID) {
229230 int width = State_width;
230231 int height = State_height;
231232
232- int frameCount = State_frameCount;
233- float now = time(frameCount);
233+ float x = lerpf(width, 0, State_xOffset);
234+
235+ float now = time();
234236 alpha(1.0f);
235237
236238 if (now >= MIDNIGHT && now < MORNING) {
@@ -251,10 +253,7 @@ int main(int launchID) {
251253 drawSunset(width, height);
252254 }
253255
254- drawBlades(now, frameCount);
255-
256- frameCount++;
257- storeI32(RSID_STATE, OFFSETOF_WorldState_frameCount, frameCount);
256+ drawBlades(now, x);
258257
259258 return 1;
260259 }
--- /dev/null
+++ b/src/com/android/wallpaper/RenderScriptScene.java
@@ -0,0 +1,80 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+
18+package com.android.wallpaper;
19+
20+import android.content.res.Resources;
21+import android.renderscript.RenderScript;
22+import android.renderscript.ScriptC;
23+
24+public abstract class RenderScriptScene {
25+ protected int mWidth;
26+ protected int mHeight;
27+ protected Resources mResources;
28+ protected RenderScript mRS;
29+ protected ScriptC mScript;
30+
31+ public RenderScriptScene(int width, int height) {
32+ mWidth = width;
33+ mHeight = height;
34+ }
35+
36+ public void init(RenderScript rs, Resources res) {
37+ mRS = rs;
38+ mResources = res;
39+ mScript = createScript();
40+ }
41+
42+ public int getWidth() {
43+ return mWidth;
44+ }
45+
46+ public int getHeight() {
47+ return mHeight;
48+ }
49+
50+ public Resources getResources() {
51+ return mResources;
52+ }
53+
54+ public RenderScript getRS() {
55+ return mRS;
56+ }
57+
58+ public ScriptC getScript() {
59+ return mScript;
60+ }
61+
62+ protected abstract ScriptC createScript();
63+
64+ public void stop() {
65+ mRS.contextBindRootScript(null);
66+ }
67+
68+ public void start() {
69+ mRS.contextBindRootScript(mScript);
70+ }
71+
72+ public void resize(int width, int height) {
73+ mWidth = width;
74+ mHeight = height;
75+ }
76+
77+ @SuppressWarnings({"UnusedDeclaration"})
78+ public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
79+ }
80+}
--- /dev/null
+++ b/src/com/android/wallpaper/RenderScriptWallpaper.java
@@ -0,0 +1,104 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+
18+package com.android.wallpaper;
19+
20+import android.service.wallpaper.WallpaperService;
21+import android.renderscript.RenderScript;
22+import android.view.SurfaceHolder;
23+import android.view.Surface;
24+
25+public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends WallpaperService {
26+ public Engine onCreateEngine() {
27+ return new RenderScriptEngine();
28+ }
29+
30+ protected abstract T createScene(int width, int height);
31+
32+ private class RenderScriptEngine extends Engine {
33+ private RenderScript mRs;
34+ private T mRenderer;
35+
36+ @Override
37+ public void onCreate(SurfaceHolder surfaceHolder) {
38+ super.onCreate(surfaceHolder);
39+ setTouchEventsEnabled(false);
40+ surfaceHolder.setSizeFromLayout();
41+ }
42+
43+ @Override
44+ public void onDestroy() {
45+ super.onDestroy();
46+ destroyRenderer();
47+ }
48+
49+ private void destroyRenderer() {
50+ if (mRenderer != null) {
51+ mRenderer.stop();
52+ mRenderer = null;
53+ }
54+ if (mRs != null) {
55+ mRs.destroy();
56+ mRs = null;
57+ }
58+ }
59+
60+ @Override
61+ public void onVisibilityChanged(boolean visible) {
62+ super.onVisibilityChanged(visible);
63+ if (visible) {
64+ mRenderer.start();
65+ } else {
66+ mRenderer.stop();
67+ }
68+ }
69+
70+ @Override
71+ public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
72+ super.onSurfaceChanged(holder, format, width, height);
73+ if (mRenderer == null) {
74+ mRenderer = createScene(width, height);
75+ mRenderer.init(mRs, getResources());
76+ mRenderer.start();
77+ } else {
78+ mRenderer.resize(width, height);
79+ }
80+ }
81+
82+ @Override
83+ public void onOffsetsChanged(float xOffset, float yOffset, int xPixels, int yPixels) {
84+ mRenderer.setOffset(xOffset, yOffset, xPixels, yPixels);
85+ }
86+
87+ @Override
88+ public void onSurfaceCreated(SurfaceHolder holder) {
89+ super.onSurfaceCreated(holder);
90+
91+ Surface surface = null;
92+ while (surface == null) {
93+ surface = holder.getSurface();
94+ }
95+ mRs = new RenderScript(surface, false);
96+ }
97+
98+ @Override
99+ public void onSurfaceDestroyed(SurfaceHolder holder) {
100+ super.onSurfaceDestroyed(holder);
101+ destroyRenderer();
102+ }
103+ }
104+}
--- a/src/com/android/wallpaper/galaxy/GalaxyRS.java
+++ b/src/com/android/wallpaper/galaxy/GalaxyRS.java
@@ -16,8 +16,6 @@
1616
1717 package com.android.wallpaper.galaxy;
1818
19-import android.content.res.Resources;
20-import android.renderscript.RenderScript;
2119 import android.renderscript.ScriptC;
2220 import android.renderscript.ProgramFragment;
2321 import android.renderscript.ProgramStore;
@@ -43,8 +41,9 @@ import static android.util.MathUtils.*;
4341 import java.util.TimeZone;
4442
4543 import com.android.wallpaper.R;
44+import com.android.wallpaper.RenderScriptScene;
4645
47-class GalaxyRS {
46+class GalaxyRS extends RenderScriptScene {
4847 private static final int GALAXY_RADIUS = 300;
4948 private static final int PARTICLES_COUNT = 12000;
5049 private static final float ELLIPSE_TWIST = 0.023333333f;
@@ -67,16 +66,8 @@ class GalaxyRS {
6766
6867 private static final int RSID_PARTICLES_BUFFER = 2;
6968
70- private Resources mResources;
71- private RenderScript mRS;
72-
7369 private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
7470
75- private int mWidth;
76- private int mHeight;
77-
78- @SuppressWarnings({"FieldCanBeLocal"})
79- private ScriptC mScript;
8071 @SuppressWarnings({"FieldCanBeLocal"})
8172 private ProgramFragment mPfBackground;
8273 @SuppressWarnings({"FieldCanBeLocal"})
@@ -107,28 +98,14 @@ class GalaxyRS {
10798
10899 private final float[] mFloatData5 = new float[5];
109100
110- public GalaxyRS(int width, int height) {
111- mWidth = width;
112- mHeight = height;
101+ GalaxyRS(int width, int height) {
102+ super(width, height);
113103 mOptionsARGB.inScaled = false;
114104 mOptionsARGB.inPreferredConfig = Bitmap.Config.ARGB_8888;
115105 }
116106
117- public void init(RenderScript rs, Resources res) {
118- mRS = rs;
119- mResources = res;
120- initRS();
121- }
122-
123- void stop() {
124- mRS.contextBindRootScript(null);
125- }
126-
127- void start() {
128- mRS.contextBindRootScript(mScript);
129- }
130-
131- private void initRS() {
107+ @Override
108+ protected ScriptC createScript() {
132109 createProgramVertex();
133110 createProgramFragmentStore();
134111 createProgramFragment();
@@ -140,13 +117,15 @@ class GalaxyRS {
140117 sb.setScript(mResources, R.raw.galaxy);
141118 sb.setRoot(true);
142119
143- mScript = sb.create();
144- mScript.setClearColor(1.0f, 0.0f, 0.0f, 1.0f);
145- mScript.setTimeZone(TimeZone.getDefault().getID());
120+ ScriptC script = sb.create();
121+ script.setClearColor(1.0f, 0.0f, 0.0f, 1.0f);
122+ script.setTimeZone(TimeZone.getDefault().getID());
146123
147- mScript.bindAllocation(mState, RSID_STATE);
148- mScript.bindAllocation(mParticles, RSID_PARTICLES);
149- mScript.bindAllocation(mParticlesBuffer, RSID_PARTICLES_BUFFER);
124+ script.bindAllocation(mState, RSID_STATE);
125+ script.bindAllocation(mParticles, RSID_PARTICLES);
126+ script.bindAllocation(mParticlesBuffer, RSID_PARTICLES_BUFFER);
127+
128+ return script;
150129 }
151130
152131 private void createScriptStructures() {
@@ -173,14 +152,15 @@ class GalaxyRS {
173152 mParticlesMesh.bindVertexAllocation(mParticlesBuffer, 0);
174153 }
175154
176- void setOffsetX(float xOffset) {
155+ @Override
156+ public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
177157 mGalaxyState.xOffset = xOffset;
178158 mState.data(mGalaxyState);
179159 }
180160
181- void resize(int width, int height) {
182- mWidth = width;
183- mHeight = height;
161+ @Override
162+ public void resize(int width, int height) {
163+ super.resize(width, height);
184164
185165 mGalaxyState.width = width;
186166 mGalaxyState.height = height;
--- a/src/com/android/wallpaper/galaxy/GalaxyWallpaper.java
+++ b/src/com/android/wallpaper/galaxy/GalaxyWallpaper.java
@@ -16,85 +16,10 @@
1616
1717 package com.android.wallpaper.galaxy;
1818
19-import android.service.wallpaper.WallpaperService;
20-import android.view.SurfaceHolder;
21-import android.view.Surface;
22-import android.renderscript.RenderScript;
19+import com.android.wallpaper.RenderScriptWallpaper;
2320
24-public class GalaxyWallpaper extends WallpaperService {
25- public Engine onCreateEngine() {
26- return new RenderScriptEngine();
21+public class GalaxyWallpaper extends RenderScriptWallpaper<GalaxyRS> {
22+ protected GalaxyRS createScene(int width, int height) {
23+ return new GalaxyRS(width, height);
2724 }
28-
29- private class RenderScriptEngine extends Engine {
30- private RenderScript mRs;
31- private GalaxyRS mRenderer;
32-
33- @Override
34- public void onCreate(SurfaceHolder surfaceHolder) {
35- super.onCreate(surfaceHolder);
36- surfaceHolder.setSizeFromLayout();
37- }
38-
39- @Override
40- public void onDestroy() {
41- super.onDestroy();
42- destroyRenderer();
43- }
44-
45- private void destroyRenderer() {
46- if (mRenderer != null) {
47- mRenderer.stop();
48- mRenderer = null;
49- }
50- if (mRs != null) {
51- mRs.destroy();
52- mRs = null;
53- }
54- }
55-
56- @Override
57- public void onVisibilityChanged(boolean visible) {
58- super.onVisibilityChanged(visible);
59- if (visible) {
60- mRenderer.start();
61- } else {
62- mRenderer.stop();
63- }
64- }
65-
66- @Override
67- public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
68- super.onSurfaceChanged(holder, format, width, height);
69- if (mRenderer == null) {
70- mRenderer = new GalaxyRS(width, height);
71- mRenderer.init(mRs, getResources());
72- mRenderer.start();
73- } else {
74- mRenderer.resize(width, height);
75- }
76- }
77-
78- @Override
79- public void onOffsetsChanged(float xOffset, float yOffset, int xPixels, int yPixels) {
80- mRenderer.setOffsetX(xOffset);
81- }
82-
83- @Override
84- public void onSurfaceCreated(SurfaceHolder holder) {
85- super.onSurfaceCreated(holder);
86-
87- Surface surface = null;
88- while (surface == null) {
89- surface = holder.getSurface();
90- }
91- mRs = new RenderScript(surface, false);
92- }
93-
94- @Override
95- public void onSurfaceDestroyed(SurfaceHolder holder) {
96- super.onSurfaceDestroyed(holder);
97- destroyRenderer();
98- }
99- }
100-}
\ No newline at end of file
25+}
--- a/src/com/android/wallpaper/grass/GrassRS.java
+++ b/src/com/android/wallpaper/grass/GrassRS.java
@@ -16,13 +16,11 @@
1616
1717 package com.android.wallpaper.grass;
1818
19-import android.content.res.Resources;
2019 import android.renderscript.Sampler;
2120 import static android.renderscript.ProgramFragment.EnvMode.*;
2221 import static android.renderscript.ProgramStore.DepthFunc.*;
2322 import static android.renderscript.ProgramStore.BlendSrcFunc;
2423 import static android.renderscript.ProgramStore.BlendDstFunc;
25-import android.renderscript.RenderScript;
2624 import android.renderscript.ProgramFragment;
2725 import android.renderscript.ProgramStore;
2826 import android.renderscript.Allocation;
@@ -37,10 +35,11 @@ import android.renderscript.SimpleMesh;
3735 import android.renderscript.Primitive;
3836 import static android.renderscript.Sampler.Value.*;
3937 import com.android.wallpaper.R;
38+import com.android.wallpaper.RenderScriptScene;
4039
4140 import java.util.TimeZone;
4241
43-class GrassRS {
42+class GrassRS extends RenderScriptScene {
4443 private static final float TESSELATION = 0.5f;
4544
4645 private static final int RSID_STATE = 0;
@@ -66,14 +65,6 @@ class GrassRS {
6665
6766 private static final int RSID_BLADES_BUFFER = 2;
6867
69- private Resources mResources;
70- private RenderScript mRS;
71-
72- private int mWidth;
73- private int mHeight;
74-
75- @SuppressWarnings({ "FieldCanBeLocal" })
76- private ScriptC mScript;
7768 @SuppressWarnings({ "FieldCanBeLocal" })
7869 private ProgramFragment mPfBackground;
7970 @SuppressWarnings({ "FieldCanBeLocal" })
@@ -100,39 +91,25 @@ class GrassRS {
10091 private final float[] mFloatData5 = new float[5];
10192 private WorldState mWorldState;
10293
103- public GrassRS(int width, int height) {
104- mWidth = width;
105- mHeight = height;
106- }
107-
108- public void init(RenderScript rs, Resources res) {
109- mRS = rs;
110- mResources = res;
111- initRS();
112- }
113-
114- void stop() {
115- mRS.contextBindRootScript(null);
116- }
117-
118- void start() {
119- mRS.contextBindRootScript(mScript);
94+ GrassRS(int width, int height) {
95+ super(width, height);
12096 }
12197
122- void resize(int width, int height) {
123- mWidth = width;
124- mHeight = height;
125-
98+ @Override
99+ public void resize(int width, int height) {
100+ super.resize(width, height);
101+
126102 mWorldState.width = width;
127103 mWorldState.height = height;
128104 mState.data(mWorldState);
129105
130106 mPvOrthoAlloc.setupOrthoWindow(mWidth, mHeight);
131107
132- // TODO: REPOSITION BLADES
108+ // TODO: REPOSITION BLADES
133109 }
134-
135- private void initRS() {
110+
111+ @Override
112+ protected ScriptC createScript() {
136113 createProgramVertex();
137114 createProgramFragmentStore();
138115 createProgramFragment();
@@ -144,13 +121,15 @@ class GrassRS {
144121 sb.setScript(mResources, R.raw.grass);
145122 sb.setRoot(true);
146123
147- mScript = sb.create();
148- mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
149- mScript.setTimeZone(TimeZone.getDefault().getID());
124+ ScriptC script = sb.create();
125+ script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
126+ script.setTimeZone(TimeZone.getDefault().getID());
150127
151- mScript.bindAllocation(mState, RSID_STATE);
152- mScript.bindAllocation(mBlades, RSID_BLADES);
153- mScript.bindAllocation(mBladesBuffer, RSID_BLADES_BUFFER);
128+ script.bindAllocation(mState, RSID_STATE);
129+ script.bindAllocation(mBlades, RSID_BLADES);
130+ script.bindAllocation(mBladesBuffer, RSID_BLADES_BUFFER);
131+
132+ return script;
154133 }
155134
156135 private void createScriptStructures() {
@@ -158,12 +137,18 @@ class GrassRS {
158137 createState();
159138 }
160139
140+ @Override
141+ public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
142+ mWorldState.xOffset = xOffset;
143+ mState.data(mWorldState);
144+ }
145+
161146 static class WorldState {
162- public int frameCount;
163147 public int bladesCount;
164148 public int trianglesCount;
165149 public int width;
166150 public int height;
151+ public float xOffset;
167152 }
168153
169154 private void createState() {
@@ -251,7 +236,7 @@ class GrassRS {
251236
252237 private int createBlade(float[] blades, int index) {
253238 final float size = random(4.0f) + 4.0f;
254- final int xpos = random(mWidth);
239+ final int xpos = random(-mWidth, mWidth);
255240
256241 //noinspection PointlessArithmeticExpression
257242 blades[index + BLADE_STRUCT_ANGLE] = 0.0f;
--- a/src/com/android/wallpaper/grass/GrassWallpaper.java
+++ b/src/com/android/wallpaper/grass/GrassWallpaper.java
@@ -16,80 +16,12 @@
1616
1717 package com.android.wallpaper.grass;
1818
19-import android.service.wallpaper.WallpaperService;
20-import android.view.SurfaceHolder;
21-import android.view.Surface;
22-import android.renderscript.RenderScript;
19+import com.android.wallpaper.RenderScriptWallpaper;
20+import com.android.wallpaper.RenderScriptScene;
2321
24-public class GrassWallpaper extends WallpaperService {
25- public Engine onCreateEngine() {
26- return new RenderScriptEngine();
27- }
28-
29- private class RenderScriptEngine extends Engine {
30- private RenderScript mRs;
31- private GrassRS mRenderer;
32-
33- @Override
34- public void onCreate(SurfaceHolder surfaceHolder) {
35- super.onCreate(surfaceHolder);
36- }
37-
38- @Override
39- public void onDestroy() {
40- super.onDestroy();
41- destroyRenderer();
42- }
43-
44- private void destroyRenderer() {
45- if (mRenderer != null) {
46- mRenderer.stop();
47- mRenderer = null;
48- }
49- if (mRs != null) {
50- mRs.destroy();
51- mRs = null;
52- }
53- }
54-
55- @Override
56- public void onVisibilityChanged(boolean visible) {
57- super.onVisibilityChanged(visible);
58- if (visible) {
59- mRenderer.start();
60- } else {
61- mRenderer.stop();
62- }
63- }
64-
65- @Override
66- public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
67- super.onSurfaceChanged(holder, format, width, height);
68- if (mRenderer == null) {
69- mRenderer = new GrassRS(width, height);
70- mRenderer.init(mRs, getResources());
71- mRenderer.start();
72- } else {
73- mRenderer.resize(width, height);
74- }
75- }
76-
77- @Override
78- public void onSurfaceCreated(SurfaceHolder holder) {
79- super.onSurfaceCreated(holder);
80-
81- Surface surface = null;
82- while (surface == null) {
83- surface = holder.getSurface();
84- }
85- mRs = new RenderScript(surface, false);
86- }
87-
88- @Override
89- public void onSurfaceDestroyed(SurfaceHolder holder) {
90- super.onSurfaceDestroyed(holder);
91- destroyRenderer();
92- }
22+public class GrassWallpaper extends RenderScriptWallpaper {
23+ protected RenderScriptScene createScene(int width, int height) {
24+ return new GrassRS(width, height);
9325 }
9426 }
9527