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