summaryrefslogtreecommitdiffstats
path: root/src/com/android/galaxy4/GalaxyView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/galaxy4/GalaxyView.java')
-rw-r--r--src/com/android/galaxy4/GalaxyView.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/com/android/galaxy4/GalaxyView.java b/src/com/android/galaxy4/GalaxyView.java
new file mode 100644
index 0000000..ce0d33f
--- /dev/null
+++ b/src/com/android/galaxy4/GalaxyView.java
@@ -0,0 +1,45 @@
+package com.android.galaxy4;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.renderscript.RSSurfaceView;
+import android.renderscript.RenderScriptGL;
+import android.renderscript.RenderScriptGL.SurfaceConfig;
+import android.view.SurfaceHolder;
+
+public class GalaxyView extends RSSurfaceView {
+
+ private RenderScriptGL mRS;
+ private GalaxyRS mRender;
+
+ public GalaxyView(Context context) {
+ super(context);
+ setFocusable(true);
+ setFocusableInTouchMode(true);
+ // getHolder().setFormat(PixelFormat.TRANSPARENT);
+ }
+
+ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+ super.surfaceChanged(holder, format, w, h);
+
+ if (mRS == null) {
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ mRS = createRenderScriptGL(sc);
+ mRS.setSurface(holder, w, h);
+
+ mRender = new GalaxyRS();
+ mRender.init(mRS, getResources(), w, h);
+ }
+
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ if (mRS != null) {
+ mRS.setSurface(null, 0, 0);
+ mRS = null;
+ destroyRenderScriptGL();
+ }
+ }
+
+}