summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/support/glrenderer/ResourceTexture.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/support/glrenderer/ResourceTexture.java')
-rw-r--r--src/com/android/camera/support/glrenderer/ResourceTexture.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/android/camera/support/glrenderer/ResourceTexture.java b/src/com/android/camera/support/glrenderer/ResourceTexture.java
new file mode 100644
index 000000000..121c184cd
--- /dev/null
+++ b/src/com/android/camera/support/glrenderer/ResourceTexture.java
@@ -0,0 +1,37 @@
+package com.android.camera.support.glrenderer;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+import junit.framework.Assert;
+
+// ResourceTexture is a texture whose Bitmap is decoded from a resource.
+// By default ResourceTexture is not opaque.
+public class ResourceTexture extends UploadedTexture {
+
+ protected final Context mContext;
+ protected final int mResId;
+
+ public ResourceTexture(Context context, int resId) {
+ Assert.assertNotNull(context);
+ mContext = context;
+ mResId = resId;
+ setOpaque(false);
+ }
+
+ @Override
+ protected Bitmap onGetBitmap() {
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+ return BitmapFactory.decodeResource(
+ mContext.getResources(), mResId, options);
+ }
+
+ @Override
+ protected void onFreeBitmap(Bitmap bitmap) {
+ if (!inFinalizer()) {
+ bitmap.recycle();
+ }
+ }
+}