OSDN Git Service

ed59fcbdef702326aff608a95f6d48fb9b8fe299
[android-x86/packages-apps-Gallery2.git] / src / com / cooliris / media / Texture.java
1 package com.cooliris.media;
2
3 import android.graphics.Bitmap;
4
5 public abstract class Texture {
6
7     public static final int STATE_UNLOADED = 0;
8     public static final int STATE_QUEUED = 1;
9     public static final int STATE_LOADING = 2;
10     public static final int STATE_LOADED = 3;
11     public static final int STATE_ERROR = 4;
12
13     int mState = STATE_UNLOADED;
14     int mId;
15     int mWidth;
16     int mHeight;
17     float mNormalizedWidth;
18     float mNormalizedHeight;
19     Bitmap mBitmap;
20
21     public boolean isCached() {
22         return false;
23     }
24
25     public final void clear() {
26         mId = 0;
27         mState = STATE_UNLOADED;
28         mWidth = 0;
29         mHeight = 0;
30         mNormalizedWidth = 0;
31         mNormalizedHeight = 0;
32         if (mBitmap != null) {
33             mBitmap.recycle();
34             mBitmap = null;
35         }
36     }
37
38     public final boolean isLoaded() {
39         return mState == STATE_LOADED;
40     }
41
42     public final int getState() {
43         return mState;
44     }
45
46     public final int getWidth() {
47         return mWidth;
48     }
49
50     public final int getHeight() {
51         return mHeight;
52     }
53
54     public final float getNormalizedWidth() {
55         return mNormalizedWidth;
56     }
57
58     public final float getNormalizedHeight() {
59         return mNormalizedHeight;
60     }
61
62     /** If this returns true, the texture will be enqueued. */
63     protected boolean shouldQueue() {
64         return true;
65     }
66
67     /** Returns a bitmap, or null if an error occurs. */
68     protected abstract Bitmap load(RenderView view);
69
70     public boolean isUncachedVideo() {
71         return false;
72     }
73 }