Texture2D.java revision ce047cb47b761f00593f247a3901fe8155371d47
1/*
2 * Copyright (C) 2011 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
17package com.android.scenegraph;
18
19import java.lang.Math;
20
21import com.android.scenegraph.SceneManager;
22
23import android.content.res.Resources;
24import android.renderscript.*;
25import android.util.Log;
26
27/**
28 * @hide
29 */
30public class Texture2D extends SceneGraphBase {
31    String mFileName;
32    String mFileDir;
33    Allocation mRsTexture;
34
35    public Texture2D() {
36    }
37
38    public Texture2D(Allocation tex) {
39        setTexture(tex);
40    }
41
42    public void setFileDir(String dir) {
43        mFileDir = dir;
44    }
45
46    public void setFileName(String file) {
47        mFileName = file;
48    }
49
50    public String getFileName() {
51        return mFileName;
52    }
53
54    public void setTexture(Allocation tex) {
55        mRsTexture = tex;
56    }
57
58    Allocation getRsData(RenderScriptGL rs, Resources res) {
59        if (mRsTexture != null) {
60            return mRsTexture;
61        }
62
63        String shortName = mFileName.substring(mFileName.lastIndexOf('/') + 1);
64        mRsTexture = SceneManager.loadTexture2D(mFileDir + shortName, rs, res);
65
66        return mRsTexture;
67    }
68}
69
70
71
72
73
74