aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/cyanogenmod/wallpapers/photophase/TextureManager.java
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2014-09-10 23:52:05 +0200
committerJorge Ruesga <jorge@ruesga.com>2014-09-14 10:52:53 +0200
commitfaa982e7beda54bf28e0dbf1488428093bbbf485 (patch)
treefe23f0f6c899f2b93da12c789a529564054a107e /src/org/cyanogenmod/wallpapers/photophase/TextureManager.java
parent94c617a88428b64dfd486f4a3ed28547e09ef9c8 (diff)
downloadandroid_packages_wallpapers_PhotoPhase-faa982e7beda54bf28e0dbf1488428093bbbf485.tar.gz
android_packages_wallpapers_PhotoPhase-faa982e7beda54bf28e0dbf1488428093bbbf485.tar.bz2
android_packages_wallpapers_PhotoPhase-faa982e7beda54bf28e0dbf1488428093bbbf485.zip
photophase: use etc1 compression when available
When avaliable this help to decrease the memory footprint. ETC1 compression requieres to: - be supported by opengl - picture couldn't have an alpha channel - compression times shouldn't be too higher (< 1000 ms) - initial pictures doesn't be compressed (to speed up boot) Change-Id: I87e41db3ca7f2ccb82d4af2763609f11d7e67121 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/TextureManager.java')
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/TextureManager.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/TextureManager.java b/src/org/cyanogenmod/wallpapers/photophase/TextureManager.java
index 417cfb9..65987c3 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/TextureManager.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/TextureManager.java
@@ -89,22 +89,27 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
effect = mEffects.getNextEffect();
}
+ boolean enqueue = false;
+ synchronized (mSync) {
+ enqueue = mPendingRequests.size() == 0;
+ }
+
// Load and bind to the GLES context. The effect is applied when the image
// is associated to the destination target (only if aspect ratio will be applied)
if (!Preferences.General.isFixAspectRatio()) {
ti = GLESUtil.loadTexture(
- mImage, mDimensions, effect, mDimensions, false);
+ mImage, mDimensions, effect, mDimensions, false, enqueue);
} else {
- ti = GLESUtil.loadTexture(mImage, mDimensions, null, null, false);
+ ti = GLESUtil.loadTexture(mImage, mDimensions, null, null, false, enqueue);
ti.effect = effect;
}
synchronized (mSync) {
// Notify the new images to all pending frames
- if (mPendingRequests.size() > 0) {
+ if (!enqueue) {
// Invalid textures are also reported, so requestor can handle it
TextureRequestor requestor = mPendingRequests.remove(0);
- fixAspectRatio(requestor, ti);
+ fixAspectRatio(requestor, ti, false);
requestor.setTextureHandle(ti);
// Clean up memory
@@ -247,7 +252,7 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
synchronized (mSync) {
try {
GLESTextureInfo ti = mQueue.remove();
- fixAspectRatio(requestor, ti);
+ fixAspectRatio(requestor, ti, true);
requestor.setTextureHandle(ti);
// Clean up memory
@@ -431,8 +436,9 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
* @param request The requestor target
* @param ti The original texture information
* @param effect The effect to apply to the destination picture
+ * @param compress Compress the texture
*/
- void fixAspectRatio(TextureRequestor requestor, GLESTextureInfo ti) {
+ void fixAspectRatio(TextureRequestor requestor, GLESTextureInfo ti, boolean compress) {
// Check if we have to apply any correction to the image
if (Preferences.General.isFixAspectRatio()) {
// Transform requestor dimensions to screen dimensions
@@ -449,7 +455,7 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
pixels.width(),
pixels.height(),
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
- GLESTextureInfo dst = GLESUtil.loadTexture(thumb, ti.effect, pixels);
+ GLESTextureInfo dst = GLESUtil.loadTexture(thumb, ti.effect, pixels, compress);
// Destroy references
int[] textures = new int[]{ti.handle};