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