summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-05-22 13:28:04 -0700
committerOwen Lin <owenlin@google.com>2012-05-22 17:49:50 -0700
commitc64d08694f22ad3ba6f5e29b78ad4da83c42bf09 (patch)
tree1b46ed859ef7bf8a71e38169a88d751f491eface /src
parent048ca675a9e659fb0d3b150880d71cd42770023d (diff)
downloadandroid_packages_apps_Snap-c64d08694f22ad3ba6f5e29b78ad4da83c42bf09.tar.gz
android_packages_apps_Snap-c64d08694f22ad3ba6f5e29b78ad4da83c42bf09.tar.bz2
android_packages_apps_Snap-c64d08694f22ad3ba6f5e29b78ad4da83c42bf09.zip
Recycle textures when we don't need them.
bug: 6307447 Change-Id: Id0c1abab54e1fbb75364dffda9f1f72d6b39310b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java29
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java7
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java21
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlotRenderer.java5
-rw-r--r--src/com/android/gallery3d/ui/FadeOutTexture.java2
-rw-r--r--src/com/android/gallery3d/ui/FadeTexture.java9
6 files changed, 38 insertions, 35 deletions
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index cefb9cd8a..6561a23f3 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -70,7 +70,8 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
public MediaSet album;
public MediaItem coverItem;
public Texture content;
- public Texture label;
+ public BitmapTexture labelTexture;
+ public BitmapTexture bitmapTexture;
public Path setPath;
public String title;
public int totalCount;
@@ -226,6 +227,8 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
AlbumSetEntry entry = mData[slotIndex % mData.length];
if (entry.coverLoader != null) entry.coverLoader.recycle();
if (entry.labelLoader != null) entry.labelLoader.recycle();
+ if (entry.labelTexture != null) entry.labelTexture.recycle();
+ if (entry.bitmapTexture != null) entry.bitmapTexture.recycle();
mData[slotIndex % mData.length] = null;
}
@@ -256,7 +259,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
if (entry.labelLoader != null) {
entry.labelLoader.recycle();
entry.labelLoader = null;
- entry.label = null;
+ entry.labelTexture = null;
}
if (album != null) {
entry.labelLoader = new AlbumLabelLoader(
@@ -273,6 +276,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
if (entry.coverLoader != null) {
entry.coverLoader.recycle();
entry.coverLoader = null;
+ entry.bitmapTexture = null;
entry.content = null;
}
if (cover != null) {
@@ -296,11 +300,11 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
private void uploadBackgroundTextureInSlot(int index) {
if (index < mContentStart || index >= mContentEnd) return;
AlbumSetEntry entry = mData[index % mData.length];
- if (entry.content instanceof BitmapTexture) {
- mTextureUploader.addBgTexture((BitmapTexture) entry.content);
+ if (entry.bitmapTexture != null) {
+ mTextureUploader.addBgTexture(entry.bitmapTexture);
}
- if (entry.label instanceof BitmapTexture) {
- mTextureUploader.addBgTexture((BitmapTexture) entry.label);
+ if (entry.labelTexture != null) {
+ mTextureUploader.addBgTexture(entry.labelTexture);
}
}
@@ -311,11 +315,11 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
// Upload foreground texture
for (int i = mActiveStart, n = mActiveEnd; i < n; ++i) {
AlbumSetEntry entry = mData[i % mData.length];
- if (entry.content instanceof BitmapTexture) {
- mTextureUploader.addFgTexture((BitmapTexture) entry.content);
+ if (entry.bitmapTexture != null) {
+ mTextureUploader.addFgTexture(entry.bitmapTexture);
}
- if (entry.label instanceof BitmapTexture) {
- mTextureUploader.addFgTexture((BitmapTexture) entry.label);
+ if (entry.labelTexture != null) {
+ mTextureUploader.addFgTexture(entry.labelTexture);
}
}
@@ -440,6 +444,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
AlbumSetEntry entry = mData[mSlotIndex % mData.length];
BitmapTexture texture = new BitmapTexture(bitmap);
+ entry.bitmapTexture = texture;
entry.content = texture;
if (isActiveSlot(mSlotIndex)) {
@@ -509,7 +514,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
AlbumSetEntry entry = mData[mSlotIndex % mData.length];
BitmapTexture texture = new BitmapTexture(bitmap);
texture.setOpaque(false);
- entry.label = texture;
+ entry.labelTexture = texture;
if (isActiveSlot(mSlotIndex)) {
mTextureUploader.addFgTexture(texture);
@@ -536,7 +541,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
if (entry.labelLoader != null) {
entry.labelLoader.recycle();
entry.labelLoader = null;
- entry.label = null;
+ entry.labelTexture = null;
}
if (entry.album != null) {
entry.labelLoader = new AlbumLabelLoader(i,
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index ac810336d..7b4a86651 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -148,9 +148,8 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
entry.isWaitLoadingDisplayed = true;
} else if (entry.isWaitLoadingDisplayed) {
entry.isWaitLoadingDisplayed = false;
- entry.content = new FadeInTexture(
- PLACEHOLDER_COLOR, (BitmapTexture) entry.content);
- content = entry.content;
+ content = new FadeInTexture(PLACEHOLDER_COLOR, entry.bitmapTexture);
+ entry.content = content;
}
drawContent(canvas, content, width, height, entry.rotation);
if ((content instanceof FadeInTexture) &&
@@ -173,7 +172,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
GLCanvas canvas, AlbumSetEntry entry, int width, int height) {
// We show the loading message only when the album is still loading
// (Not when we are still preparing the label)
- Texture content = checkTexture(entry.label);
+ Texture content = checkTexture(entry.labelTexture);
if (entry.album == null) {
content = mDataWindow.getLoadingTexture();
}
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index 240cf34e2..deec1712d 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -48,6 +48,7 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
public int rotation;
public int mediaType;
public boolean isWaitDisplayed;
+ public BitmapTexture bitmapTexture;
public Texture content;
private BitmapLoader contentLoader;
}
@@ -164,8 +165,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
private void uploadBgTextureInSlot(int index) {
if (index < mContentEnd && index >= mContentStart) {
AlbumEntry entry = mData[index % mData.length];
- if (entry.content instanceof BitmapTexture) {
- mTextureUploader.addBgTexture((BitmapTexture) entry.content);
+ if (entry.bitmapTexture != null) {
+ mTextureUploader.addBgTexture(entry.bitmapTexture);
}
}
}
@@ -177,8 +178,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
// add foreground textures
for (int i = mActiveStart, n = mActiveEnd; i < n; ++i) {
AlbumEntry entry = mData[i % mData.length];
- if (entry.content instanceof BitmapTexture) {
- mTextureUploader.addFgTexture((BitmapTexture) entry.content);
+ if (entry.bitmapTexture != null) {
+ mTextureUploader.addFgTexture(entry.bitmapTexture);
}
}
@@ -234,9 +235,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
AlbumEntry data[] = mData;
int index = slotIndex % data.length;
AlbumEntry entry = data[index];
- if (entry.contentLoader != null) {
- entry.contentLoader.recycle();
- }
+ if (entry.contentLoader != null) entry.contentLoader.recycle();
+ if (entry.bitmapTexture != null) entry.bitmapTexture.recycle();
data[index] = null;
}
@@ -296,15 +296,16 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
if (bitmap == null) return; // error or recycled
AlbumEntry entry = mData[mSlotIndex % mData.length];
- entry.content = new BitmapTexture(bitmap);
+ entry.bitmapTexture = new BitmapTexture(bitmap);
+ entry.content = entry.bitmapTexture;
if (isActiveSlot(mSlotIndex)) {
- mTextureUploader.addFgTexture((BitmapTexture) entry.content);
+ mTextureUploader.addFgTexture(entry.bitmapTexture);
--mActiveRequestCount;
if (mActiveRequestCount == 0) requestNonactiveImages();
if (mListener != null) mListener.onContentChanged();
} else {
- mTextureUploader.addBgTexture((BitmapTexture) entry.content);
+ mTextureUploader.addBgTexture(entry.bitmapTexture);
}
}
}
diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
index 9723f4cb3..ab9976621 100644
--- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
@@ -110,9 +110,8 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
entry.isWaitDisplayed = true;
} else if (entry.isWaitDisplayed) {
entry.isWaitDisplayed = false;
- entry.content = new FadeInTexture(
- PLACEHOLDER_COLOR, (BitmapTexture) entry.content);
- content = entry.content;
+ content = new FadeInTexture(PLACEHOLDER_COLOR, entry.bitmapTexture);
+ entry.content = content;
}
drawContent(canvas, content, width, height, entry.rotation);
if ((content instanceof FadeInTexture) &&
diff --git a/src/com/android/gallery3d/ui/FadeOutTexture.java b/src/com/android/gallery3d/ui/FadeOutTexture.java
index c438977b5..47e6acb54 100644
--- a/src/com/android/gallery3d/ui/FadeOutTexture.java
+++ b/src/com/android/gallery3d/ui/FadeOutTexture.java
@@ -18,7 +18,7 @@ package com.android.gallery3d.ui;
// FadeOutTexture is a texture which begins with a given texture, then gradually animates
// into fading out totally.
-public class FadeOutTexture extends FadeTexture implements Texture {
+public class FadeOutTexture extends FadeTexture {
@SuppressWarnings("unused")
private static final String TAG = "FadeOutTexture";
diff --git a/src/com/android/gallery3d/ui/FadeTexture.java b/src/com/android/gallery3d/ui/FadeTexture.java
index ad0d3584b..cbf507352 100644
--- a/src/com/android/gallery3d/ui/FadeTexture.java
+++ b/src/com/android/gallery3d/ui/FadeTexture.java
@@ -42,23 +42,22 @@ public abstract class FadeTexture implements Texture {
mIsAnimating = true;
}
+ @Override
public void draw(GLCanvas canvas, int x, int y) {
draw(canvas, x, y, mWidth, mHeight);
}
- /**
- * Subclasses should implement how to fade the texture.
- */
- public abstract void draw(GLCanvas canvas, int x, int y, int w, int h);
-
+ @Override
public boolean isOpaque() {
return mIsOpaque;
}
+ @Override
public int getWidth() {
return mWidth;
}
+ @Override
public int getHeight() {
return mHeight;
}