• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.musicvis;
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 Resources mResources;
31     protected RenderScriptGL mRS;
32     protected ScriptC mScript;
33 
RenderScriptScene(int width, int height)34     public RenderScriptScene(int width, int height) {
35         mWidth = width;
36         mHeight = height;
37     }
38 
init(RenderScriptGL rs, Resources res, boolean isPreview)39     public void init(RenderScriptGL rs, Resources res, boolean isPreview) {
40         mRS = rs;
41         mResources = res;
42         mPreview = isPreview;
43         mScript = createScript();
44     }
45 
isPreview()46     public boolean isPreview() {
47         return mPreview;
48     }
49 
getWidth()50     public int getWidth() {
51         return mWidth;
52     }
53 
getHeight()54     public int getHeight() {
55         return mHeight;
56     }
57 
getResources()58     public Resources getResources() {
59         return mResources;
60     }
61 
getRS()62     public RenderScriptGL getRS() {
63         return mRS;
64     }
65 
getScript()66     public ScriptC getScript() {
67         return mScript;
68     }
69 
createScript()70     protected abstract ScriptC createScript();
71 
stop()72     public void stop() {
73         mRS.bindRootScript(null);
74     }
75 
start()76     public void start() {
77         mRS.bindRootScript(mScript);
78     }
79 
resize(int width, int height)80     public void resize(int width, int height) {
81         mWidth = width;
82         mHeight = height;
83     }
84 
85     @SuppressWarnings({"UnusedDeclaration"})
setOffset(float xOffset, float yOffset, int xPixels, int yPixels)86     public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
87     }
88 
89 }
90