Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 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; |
Mike Cleron | c9e42c2 | 2009-10-23 16:54:59 -0700 | [diff] [blame] | 21 | import android.os.Bundle; |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 22 | import android.renderscript.RenderScriptGL; |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 23 | import android.renderscript.ScriptC; |
| 24 | |
| 25 | public abstract class RenderScriptScene { |
| 26 | protected int mWidth; |
| 27 | protected int mHeight; |
Romain Guy | 0ac0b3f | 2009-09-13 03:40:04 -0700 | [diff] [blame] | 28 | protected boolean mPreview; |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 29 | protected Resources mResources; |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 30 | protected RenderScriptGL mRS; |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 31 | protected ScriptC mScript; |
| 32 | |
| 33 | public RenderScriptScene(int width, int height) { |
| 34 | mWidth = width; |
| 35 | mHeight = height; |
| 36 | } |
| 37 | |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 38 | public void init(RenderScriptGL rs, Resources res, boolean isPreview) { |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 39 | mRS = rs; |
| 40 | mResources = res; |
Romain Guy | 0ac0b3f | 2009-09-13 03:40:04 -0700 | [diff] [blame] | 41 | mPreview = isPreview; |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 42 | mScript = createScript(); |
| 43 | } |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 44 | |
Romain Guy | 0ac0b3f | 2009-09-13 03:40:04 -0700 | [diff] [blame] | 45 | public boolean isPreview() { |
| 46 | return mPreview; |
| 47 | } |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 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 | |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 61 | public RenderScriptGL getRS() { |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 62 | return mRS; |
| 63 | } |
| 64 | |
| 65 | public ScriptC getScript() { |
| 66 | return mScript; |
| 67 | } |
| 68 | |
| 69 | protected abstract ScriptC createScript(); |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 70 | |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 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 | } |
Jason Sams | b418c5c | 2010-02-09 16:01:16 -0800 | [diff] [blame] | 87 | |
Mike Cleron | c9e42c2 | 2009-10-23 16:54:59 -0700 | [diff] [blame] | 88 | @SuppressWarnings({"UnusedDeclaration"}) |
| 89 | public Bundle onCommand(String action, int x, int y, int z, Bundle extras, |
| 90 | boolean resultRequested) { |
| 91 | return null; |
| 92 | } |
Romain Guy | 44da178 | 2009-08-28 11:03:21 -0700 | [diff] [blame] | 93 | } |