blob: b89df4a43f30a3c0e572ea6fd959b09139da271d [file] [log] [blame]
Romain Guy44da1782009-08-28 11:03:21 -07001/*
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.wallpaper;
19
20import android.content.res.Resources;
Mike Cleronc9e42c22009-10-23 16:54:59 -070021import android.os.Bundle;
Jason Samsb418c5c2010-02-09 16:01:16 -080022import android.renderscript.RenderScriptGL;
Romain Guy44da1782009-08-28 11:03:21 -070023import android.renderscript.ScriptC;
24
25public abstract class RenderScriptScene {
26 protected int mWidth;
27 protected int mHeight;
Romain Guy0ac0b3f2009-09-13 03:40:04 -070028 protected boolean mPreview;
Romain Guy44da1782009-08-28 11:03:21 -070029 protected Resources mResources;
Jason Samsb418c5c2010-02-09 16:01:16 -080030 protected RenderScriptGL mRS;
Romain Guy44da1782009-08-28 11:03:21 -070031 protected ScriptC mScript;
32
33 public RenderScriptScene(int width, int height) {
34 mWidth = width;
35 mHeight = height;
36 }
37
Jason Samsb418c5c2010-02-09 16:01:16 -080038 public void init(RenderScriptGL rs, Resources res, boolean isPreview) {
Romain Guy44da1782009-08-28 11:03:21 -070039 mRS = rs;
40 mResources = res;
Romain Guy0ac0b3f2009-09-13 03:40:04 -070041 mPreview = isPreview;
Romain Guy44da1782009-08-28 11:03:21 -070042 mScript = createScript();
43 }
Jason Samsb418c5c2010-02-09 16:01:16 -080044
Romain Guy0ac0b3f2009-09-13 03:40:04 -070045 public boolean isPreview() {
46 return mPreview;
47 }
Romain Guy44da1782009-08-28 11:03:21 -070048
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
Jason Samsb418c5c2010-02-09 16:01:16 -080061 public RenderScriptGL getRS() {
Romain Guy44da1782009-08-28 11:03:21 -070062 return mRS;
63 }
64
65 public ScriptC getScript() {
66 return mScript;
67 }
68
69 protected abstract ScriptC createScript();
Jason Samsb418c5c2010-02-09 16:01:16 -080070
Romain Guy44da1782009-08-28 11:03:21 -070071 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 }
Jason Samsb418c5c2010-02-09 16:01:16 -080087
Mike Cleronc9e42c22009-10-23 16:54:59 -070088 @SuppressWarnings({"UnusedDeclaration"})
89 public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
90 boolean resultRequested) {
91 return null;
92 }
Romain Guy44da1782009-08-28 11:03:21 -070093}