OSDN Git Service

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