summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-08-12 15:55:17 -0700
committerRomain Guy <romainguy@android.com>2009-08-12 15:55:17 -0700
commite697ca33b05c64480d20bf22282036f5601ab788 (patch)
tree25ed6f1ac86181286a59786633a24f5aa0d1348b
parent2b16dfb3a169e4c8de352db3fbc03fab52c62be1 (diff)
downloadrs-e697ca33b05c64480d20bf22282036f5601ab788.tar.gz
Grass has graduated from an RS experiment to a real live wallpaper.
-rw-r--r--java/Grass/Android.mk25
-rw-r--r--java/Grass/AndroidManifest.xml20
-rw-r--r--java/Grass/res/drawable-hdpi/night.jpgbin76591 -> 0 bytes
-rw-r--r--java/Grass/res/drawable-hdpi/sky.jpgbin27766 -> 0 bytes
-rw-r--r--java/Grass/res/drawable-hdpi/sunrise.jpgbin30351 -> 0 bytes
-rw-r--r--java/Grass/res/drawable-hdpi/sunset.jpgbin33914 -> 0 bytes
-rw-r--r--java/Grass/res/raw/grass.c202
-rw-r--r--java/Grass/src/com/android/grass/rs/Grass.java46
-rw-r--r--java/Grass/src/com/android/grass/rs/GrassRS.java243
-rw-r--r--java/Grass/src/com/android/grass/rs/GrassView.java43
10 files changed, 0 insertions, 579 deletions
diff --git a/java/Grass/Android.mk b/java/Grass/Android.mk
deleted file mode 100644
index ce5294ed..00000000
--- a/java/Grass/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
-
-LOCAL_PACKAGE_NAME := GrassRS
-
-include $(BUILD_PACKAGE)
diff --git a/java/Grass/AndroidManifest.xml b/java/Grass/AndroidManifest.xml
deleted file mode 100644
index a40f3785..00000000
--- a/java/Grass/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.grass.rs">
-
- <application android:label="GrassRS">
-
- <activity
- android:name="Grass"
- android:theme="@android:style/Theme.NoTitleBar">
-
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
-
- </activity>
-
- </application>
-
-</manifest>
diff --git a/java/Grass/res/drawable-hdpi/night.jpg b/java/Grass/res/drawable-hdpi/night.jpg
deleted file mode 100644
index 77cd7f46..00000000
--- a/java/Grass/res/drawable-hdpi/night.jpg
+++ /dev/null
Binary files differ
diff --git a/java/Grass/res/drawable-hdpi/sky.jpg b/java/Grass/res/drawable-hdpi/sky.jpg
deleted file mode 100644
index a12fe201..00000000
--- a/java/Grass/res/drawable-hdpi/sky.jpg
+++ /dev/null
Binary files differ
diff --git a/java/Grass/res/drawable-hdpi/sunrise.jpg b/java/Grass/res/drawable-hdpi/sunrise.jpg
deleted file mode 100644
index db016b26..00000000
--- a/java/Grass/res/drawable-hdpi/sunrise.jpg
+++ /dev/null
Binary files differ
diff --git a/java/Grass/res/drawable-hdpi/sunset.jpg b/java/Grass/res/drawable-hdpi/sunset.jpg
deleted file mode 100644
index 49bb0c63..00000000
--- a/java/Grass/res/drawable-hdpi/sunset.jpg
+++ /dev/null
Binary files differ
diff --git a/java/Grass/res/raw/grass.c b/java/Grass/res/raw/grass.c
deleted file mode 100644
index 14900121..00000000
--- a/java/Grass/res/raw/grass.c
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (C) 2009 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#pragma version(1)
-#pragma stateVertex(PVBackground)
-#pragma stateFragment(PFBackground)
-#pragma stateFragmentStore(PFSBackground)
-
-#define RSID_STATE 0
-#define RSID_FRAME_COUNT 0
-#define RSID_BLADES_COUNT 1
-#define RSID_WIDTH 2
-#define RSID_HEIGHT 3
-
-#define RSID_BLADES 1
-#define BLADE_STRUCT_FIELDS_COUNT 12
-#define BLADE_STRUCT_ANGLE 0
-#define BLADE_STRUCT_SIZE 1
-#define BLADE_STRUCT_XPOS 2
-#define BLADE_STRUCT_YPOS 3
-#define BLADE_STRUCT_OFFSET 4
-#define BLADE_STRUCT_SCALE 5
-#define BLADE_STRUCT_LENGTHX 6
-#define BLADE_STRUCT_LENGTHY 7
-#define BLADE_STRUCT_HARDNESS 8
-#define BLADE_STRUCT_H 9
-#define BLADE_STRUCT_S 10
-#define BLADE_STRUCT_B 11
-
-#define TESSELATION 2.0f
-
-#define MAX_BEND 0.09f
-
-#define MIDNIGHT 0.0f
-#define MORNING 0.375f
-#define AFTERNOON 0.6f
-#define DUSK 0.8f
-
-#define SECONDS_IN_DAY 24.0f * 3600.0f
-
-#define PI 3.1415926f
-
-#define REAL_TIME 0
-
-float time(int frameCount) {
- if (REAL_TIME) {
- return (hour() * 3600.0f + minute() * 60.0f + second()) / SECONDS_IN_DAY;
- }
- return (frameCount % 180) / 180.0f;
-}
-
-void alpha(float a) {
- color(1.0f, 1.0f, 1.0f, a);
-}
-
-void drawNight(int width, int height) {
- bindTexture(NAMED_PFBackground, 0, NAMED_TNight);
- drawRect(width - 512.0f, -32.0f, width, 1024.0f - 32.0f, 0.0f);
-}
-
-void drawSunrise(int width, int height) {
- bindTexture(NAMED_PFBackground, 0, NAMED_TSunrise);
- drawRect(0.0f, 0.0f, width, height, 0.0f);
-}
-
-void drawNoon(int width, int height) {
- bindTexture(NAMED_PFBackground, 0, NAMED_TSky);
- drawRect(0.0f, 0.0f, width, height, 0.0f);
-}
-
-void drawSunset(int width, int height) {
- bindTexture(NAMED_PFBackground, 0, NAMED_TSunset);
- drawRect(0.0f, 0.0f, width, height, 0.0f);
-}
-
-void drawBlade(int index, float now, int frameCount) {
- float *bladeStruct = loadArrayF(RSID_BLADES, index);
- float offset = bladeStruct[BLADE_STRUCT_OFFSET];
- float scale = bladeStruct[BLADE_STRUCT_SCALE];
- float angle = bladeStruct[BLADE_STRUCT_ANGLE];
- float hardness = bladeStruct[BLADE_STRUCT_HARDNESS];
-
- float xpos = bladeStruct[BLADE_STRUCT_XPOS];
- float ypos = bladeStruct[BLADE_STRUCT_YPOS];
-
- float lengthX = bladeStruct[BLADE_STRUCT_LENGTHX];
- float lengthY = bladeStruct[BLADE_STRUCT_LENGTHY];
-
- int size = bladeStruct[BLADE_STRUCT_SIZE];
-
- float h = bladeStruct[BLADE_STRUCT_H];
- float s = bladeStruct[BLADE_STRUCT_S];
- float b = bladeStruct[BLADE_STRUCT_B];
-
- float newB = 1.0f;
- if (now >= MIDNIGHT && now < MORNING) {
- newB = now / MORNING;
- }
-
- if (now >= AFTERNOON && now < DUSK) {
- newB = 1.0f - normf(AFTERNOON, DUSK, now);
- }
-
- if (now >= DUSK) {
- newB = 0.0f;
- }
-
- hsb(h, s, lerpf(0, b, newB), 1.0f);
-
- float newAngle = turbulencef2(xpos * 0.006f, frameCount * 0.006f, 4.0f) - 0.5f;
- newAngle /= 2.0f;
- angle = clampf(angle + (newAngle + offset - angle) * 0.15f, -MAX_BEND, MAX_BEND);
-
- float currentAngle = PI / 2.0f;
-
- float bottomX = xpos;
- float bottomY = ypos;
-
- int i = size * TESSELATION;
- float lx = lengthX / TESSELATION;
- float ly = lengthY / TESSELATION;
- float ss = 4.0f / i + scale / TESSELATION;
- float sh = 0.5f / TESSELATION;
- float d = angle * hardness / TESSELATION;
-
- for ( ; i > 0; i--) {
- float topX = bottomX - cosf(currentAngle) * size * lx;
- float topY = bottomY - sinf(currentAngle) * size * ly;
- currentAngle += d;
-
- float spi = (i - 1) * ss;
- float si = i * ss;
-
- drawQuad(topX + spi, topY, 0.0f,
- topX - spi, topY, 0.0f,
- bottomX - si, bottomY + sh, 0.0f,
- bottomX + si, bottomY + sh, 0.0f);
-
- bottomX = topX;
- bottomY = topY;
- }
-
- storeF(RSID_BLADES, index + BLADE_STRUCT_ANGLE, angle);
-}
-
-void drawBlades(float now, int frameCount) {
- // For anti-aliasing
- bindTexture(NAMED_PFBackground, 0, NAMED_TAa);
-
- int bladesCount = loadI32(RSID_STATE, RSID_BLADES_COUNT);
- int count = bladesCount * BLADE_STRUCT_FIELDS_COUNT;
-
- int i = 0;
- for ( ; i < count; i += BLADE_STRUCT_FIELDS_COUNT) {
- drawBlade(i, now, frameCount);
- }
-}
-
-int main(int launchID) {
- int width = loadI32(RSID_STATE, RSID_WIDTH);
- int height = loadI32(RSID_STATE, RSID_HEIGHT);
-
- int frameCount = loadI32(RSID_STATE, RSID_FRAME_COUNT);
- float now = time(frameCount);
- alpha(1.0f);
-
- if (now >= MIDNIGHT && now < MORNING) {
- drawNight(width, height);
- alpha(normf(MIDNIGHT, MORNING, now));
- drawSunrise(width, height);
- } else if (now >= MORNING && now < AFTERNOON) {
- drawSunrise(width, height);
- alpha(normf(MORNING, AFTERNOON, now));
- drawNoon(width, height);
- } else if (now >= AFTERNOON && now < DUSK) {
- drawNoon(width, height);
- alpha(normf(AFTERNOON, DUSK, now));
- drawSunset(width, height);
- } else if (now >= DUSK) {
- drawNight(width, height);
- alpha(1.0f - normf(DUSK, 1.0f, now));
- drawSunset(width, height);
- }
-
- drawBlades(now, frameCount);
-
- frameCount++;
- storeI32(RSID_STATE, RSID_FRAME_COUNT, frameCount);
-
- return 1;
-}
diff --git a/java/Grass/src/com/android/grass/rs/Grass.java b/java/Grass/src/com/android/grass/rs/Grass.java
deleted file mode 100644
index 260fcee9..00000000
--- a/java/Grass/src/com/android/grass/rs/Grass.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.grass.rs;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class Grass extends Activity {
- private GrassView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- mView = new GrassView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mView.onPause();
-
- Runtime.getRuntime().exit(0);
- }
-}
diff --git a/java/Grass/src/com/android/grass/rs/GrassRS.java b/java/Grass/src/com/android/grass/rs/GrassRS.java
deleted file mode 100644
index 7af600f2..00000000
--- a/java/Grass/src/com/android/grass/rs/GrassRS.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.grass.rs;
-
-import android.content.res.Resources;
-import android.renderscript.Sampler;
-import static android.renderscript.ProgramFragment.EnvMode.*;
-import static android.renderscript.ProgramStore.DepthFunc.*;
-import static android.renderscript.ProgramStore.BlendSrcFunc;
-import static android.renderscript.ProgramStore.BlendDstFunc;
-import android.renderscript.RenderScript;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.Allocation;
-import android.renderscript.ProgramVertex;
-import static android.renderscript.Element.*;
-import static android.util.MathUtils.*;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.renderscript.Dimension;
-import static android.renderscript.Sampler.Value.*;
-
-import java.util.TimeZone;
-
-class GrassRS {
- private static final int RSID_STATE = 0;
- private static final int RSID_STATE_FRAMECOUNT = 0;
- private static final int RSID_STATE_BLADES_COUNT = 1;
- private static final int RSID_STATE_WIDTH = 2;
- private static final int RSID_STATE_HEIGHT = 3;
-
- private static final int TEXTURES_COUNT = 5;
-
- private static final int RSID_BLADES = 1;
- private static final int BLADES_COUNT = 100;
- private static final int BLADE_STRUCT_FIELDS_COUNT = 12;
- private static final int BLADE_STRUCT_ANGLE = 0;
- private static final int BLADE_STRUCT_SIZE = 1;
- private static final int BLADE_STRUCT_XPOS = 2;
- private static final int BLADE_STRUCT_YPOS = 3;
- private static final int BLADE_STRUCT_OFFSET = 4;
- private static final int BLADE_STRUCT_SCALE = 5;
- private static final int BLADE_STRUCT_LENGTHX = 6;
- private static final int BLADE_STRUCT_LENGTHY = 7;
- private static final int BLADE_STRUCT_HARDNESS = 8;
- private static final int BLADE_STRUCT_H = 9;
- private static final int BLADE_STRUCT_S = 10;
- private static final int BLADE_STRUCT_B = 11;
-
- private Resources mResources;
- private RenderScript mRS;
-
- private final int mWidth;
- private final int mHeight;
-
- private ScriptC mScript;
- private Sampler mSampler;
- private ProgramFragment mPfBackground;
- private ProgramStore mPfsBackground;
- private ProgramVertex mPvBackground;
- private ProgramVertex.MatrixAllocation mPvOrthoAlloc;
-
- private Allocation[] mTextures;
-
- private Allocation mState;
- private Allocation mBlades;
-
- public GrassRS(int width, int height) {
- mWidth = width;
- mHeight = height;
- }
-
- public void init(RenderScript rs, Resources res) {
- mRS = rs;
- mResources = res;
- initRS();
- }
-
- public void destroy() {
- mScript.destroy();
- mSampler.destroy();
- mPfBackground.destroy();
- mPfsBackground.destroy();
- mPvBackground.destroy();
- mPvOrthoAlloc.mAlloc.destroy();
- for (Allocation a : mTextures) {
- a.destroy();
- }
- mState.destroy();
- mBlades.destroy();
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- destroy();
- } finally {
- super.finalize();
- }
- }
-
- private void initRS() {
- createProgramVertex();
- createProgramFragmentStore();
- createProgramFragment();
- createScriptStructures();
- loadTextures();
-
- ScriptC.Builder sb = new ScriptC.Builder(mRS);
- sb.setScript(mResources, R.raw.grass);
- sb.setRoot(true);
- mScript = sb.create();
- mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- mScript.setTimeZone(TimeZone.getDefault().getID());
-
- mScript.bindAllocation(mState, RSID_STATE);
- mScript.bindAllocation(mBlades, RSID_BLADES);
-
- mRS.contextBindRootScript(mScript);
- }
-
- private void createScriptStructures() {
- final int[] data = new int[4];
- mState = Allocation.createSized(mRS, USER_I32, data.length);
- data[RSID_STATE_FRAMECOUNT] = 0;
- data[RSID_STATE_BLADES_COUNT] = BLADES_COUNT;
- data[RSID_STATE_WIDTH] = mWidth;
- data[RSID_STATE_HEIGHT] = mHeight;
- mState.data(data);
-
- final float[] blades = new float[BLADES_COUNT * BLADE_STRUCT_FIELDS_COUNT];
- mBlades = Allocation.createSized(mRS, USER_FLOAT, blades.length);
- for (int i = 0; i < blades.length; i+= BLADE_STRUCT_FIELDS_COUNT) {
- createBlade(blades, i);
- }
- mBlades.data(blades);
- }
-
- private void createBlade(float[] blades, int index) {
- //noinspection PointlessArithmeticExpression
- blades[index + BLADE_STRUCT_ANGLE] = 0.0f;
- blades[index + BLADE_STRUCT_SIZE] = random(4.0f) + 4.0f;
- blades[index + BLADE_STRUCT_XPOS] = random(mWidth);
- blades[index + BLADE_STRUCT_YPOS] = mHeight;
- blades[index + BLADE_STRUCT_OFFSET] = random(0.2f) - 0.1f;
- blades[index + BLADE_STRUCT_SCALE] = random(0.6f) + 0.2f;
- blades[index + BLADE_STRUCT_LENGTHX] = random(4.5f) + 3.0f;
- blades[index + BLADE_STRUCT_LENGTHY] = random(5.5f) + 2.0f;
- blades[index + BLADE_STRUCT_HARDNESS] = random(1.0f) + 0.2f;
- blades[index + BLADE_STRUCT_H] = random(0.02f) + 0.2f;
- blades[index + BLADE_STRUCT_S] = random(0.22f) + 0.78f;
- blades[index + BLADE_STRUCT_B] = random(0.65f) + 0.35f;
- }
-
- private void loadTextures() {
- mTextures = new Allocation[TEXTURES_COUNT];
-
- final Allocation[] textures = mTextures;
- textures[0] = loadTexture(R.drawable.night, "TNight");
- textures[1] = loadTexture(R.drawable.sunrise, "TSunrise");
- textures[2] = loadTexture(R.drawable.sky, "TSky");
- textures[3] = loadTexture(R.drawable.sunset, "TSunset");
- textures[4] = generateTextureAlpha(4, 1, new int[] { 0x00FFFF00 }, "TAa");
-
- final int count = textures.length;
- for (int i = 0; i < count; i++) {
- final Allocation texture = textures[i];
- texture.uploadToTexture(0);
- }
- }
-
- private Allocation generateTextureAlpha(int width, int height, int[] data, String name) {
- final Type.Builder builder = new Type.Builder(mRS, A_8);
- builder.add(Dimension.X, width);
- builder.add(Dimension.Y, height);
-
- final Allocation allocation = Allocation.createTyped(mRS, builder.create());
- allocation.data(data);
- allocation.setName(name);
- return allocation;
- }
-
- private Allocation loadTexture(int id, String name) {
- final Allocation allocation = Allocation.createFromBitmapResource(mRS, mResources,
- id, RGB_565, false);
- allocation.setName(name);
- return allocation;
- }
-
- private void createProgramFragment() {
- Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMin(LINEAR);
- bs.setMag(LINEAR);
- bs.setWrapS(CLAMP);
- bs.setWrapT(CLAMP);
- mSampler = bs.create();
-
- ProgramFragment.Builder b;
- b = new ProgramFragment.Builder(mRS, null, null);
- b.setTexEnable(true, 0);
- b.setTexEnvMode(REPLACE, 0);
- mPfBackground = b.create();
- mPfBackground.setName("PFBackground");
- mPfBackground.bindSampler(mSampler, 0);
- }
-
- private void createProgramFragmentStore() {
- ProgramStore.Builder b;
- b = new ProgramStore.Builder(mRS, null, null);
-
- b.setDepthFunc(ALWAYS);
- b.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
- b.setDitherEnable(true);
- b.setDepthMask(false);
- mPfsBackground = b.create();
- mPfsBackground.setName("PFSBackground");
- }
-
- private void createProgramVertex() {
- mPvOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS);
- mPvOrthoAlloc.setupOrthoWindow(mWidth, mHeight);
-
- ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
- pvb.setTextureMatrixEnable(true);
- mPvBackground = pvb.create();
- mPvBackground.bindAllocation(mPvOrthoAlloc);
- mPvBackground.setName("PVBackground");
- }
-}
diff --git a/java/Grass/src/com/android/grass/rs/GrassView.java b/java/Grass/src/com/android/grass/rs/GrassView.java
deleted file mode 100644
index c2b9a661..00000000
--- a/java/Grass/src/com/android/grass/rs/GrassView.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.grass.rs;
-
-import android.content.Context;
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.view.SurfaceHolder;
-
-class GrassView extends RSSurfaceView {
- private GrassRS mRender;
-
- public GrassView(Context context) {
- super(context);
- }
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
-
- RenderScript RS = createRenderScript();
- mRender = new GrassRS(w, h);
- mRender.init(RS, getResources());
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- if (mRender != null) mRender.destroy();
- }
-}