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.magicsmoke; 19 20 import android.content.res.Resources; 21 import android.os.Bundle; 22 import android.renderscript.RenderScriptGL; 23 import android.renderscript.ScriptC; 24 //import android.view.MotionEvent; 25 26 public abstract class RenderScriptScene { 27 protected int mWidth; 28 protected int mHeight; 29 protected boolean mPreview; 30 protected boolean mIsStarted; 31 protected Resources mResources; 32 protected RenderScriptGL mRS; 33 protected ScriptC mScript; 34 RenderScriptScene(int width, int height)35 public RenderScriptScene(int width, int height) { 36 mWidth = width; 37 mHeight = height; 38 } 39 init(RenderScriptGL rs, Resources res, boolean isPreview)40 public void init(RenderScriptGL rs, Resources res, boolean isPreview) { 41 mRS = rs; 42 mResources = res; 43 mPreview = isPreview; 44 mScript = createScript(); 45 } 46 isPreview()47 public boolean isPreview() { 48 return mPreview; 49 } 50 getWidth()51 public int getWidth() { 52 return mWidth; 53 } 54 getHeight()55 public int getHeight() { 56 return mHeight; 57 } 58 getResources()59 public Resources getResources() { 60 return mResources; 61 } 62 getRS()63 public RenderScriptGL getRS() { 64 return mRS; 65 } 66 getScript()67 public ScriptC getScript() { 68 return mScript; 69 } 70 createScript()71 protected abstract ScriptC createScript(); 72 stop(boolean forReal)73 public void stop(boolean forReal) { 74 mRS.bindRootScript(null); 75 mIsStarted = false; 76 } 77 start()78 public void start() { 79 mRS.bindRootScript(mScript); 80 mIsStarted = true; 81 } 82 resize(int width, int height)83 public void resize(int width, int height) { 84 mWidth = width; 85 mHeight = height; 86 } 87 88 @SuppressWarnings({"UnusedDeclaration"}) setOffset(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels)89 public void setOffset(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) { 90 } 91 92 @SuppressWarnings({"UnusedDeclaration"}) onCommand(String action, int x, int y, int z, Bundle extras, boolean resultRequested)93 public Bundle onCommand(String action, int x, int y, int z, Bundle extras, 94 boolean resultRequested) { 95 return null; 96 } 97 } 98