summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-06-13 13:15:09 +0400
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2012-06-13 13:15:09 +0400
commit546e8b114b555b387410fc99f64e0acc5fa9a5e1 (patch)
tree2e10ef1398ea58878a1e6375862136f5b63934e8
parent8dbc203cf5699e4a63613d14f6a4e38c23dd07e0 (diff)
parent850748847a20d2c190bcd392a19c7236311fe462 (diff)
downloadframeworks_base-546e8b114b555b387410fc99f64e0acc5fa9a5e1.zip
frameworks_base-546e8b114b555b387410fc99f64e0acc5fa9a5e1.tar.gz
frameworks_base-546e8b114b555b387410fc99f64e0acc5fa9a5e1.tar.bz2
Merge "bootanimation: performance enhancements" into ics
-rw-r--r--cmds/bootanimation/Android.mk12
-rw-r--r--cmds/bootanimation/BootAnimation.cpp46
2 files changed, 54 insertions, 4 deletions
diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk
index 7d39912..7f1857d 100644
--- a/cmds/bootanimation/Android.mk
+++ b/cmds/bootanimation/Android.mk
@@ -20,6 +20,18 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_C_INCLUDES := \
$(call include-path-for, corecg graphics)
+ifeq ($(TARGET_BOOTANIMATION_PRELOAD),true)
+ LOCAL_CFLAGS += -DPRELOAD_BOOTANIMATION
+endif
+
+ifeq ($(TARGET_BOOTANIMATION_TEXTURE_CACHE),true)
+ LOCAL_CFLAGS += -DNO_TEXTURE_CACHE=0
+endif
+
+ifeq ($(TARGET_BOOTANIMATION_TEXTURE_CACHE),false)
+ LOCAL_CFLAGS += -DNO_TEXTURE_CACHE=1
+endif
+
LOCAL_MODULE:= bootanimation
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index d95184a..2f06ad5 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -281,6 +281,38 @@ status_t BootAnimation::readyToRun() {
mAndroidAnimation = false;
}
+
+#ifdef PRELOAD_BOOTANIMATION
+ // Preload the bootanimation zip on memory, so we don't stutter
+ // when showing the animation
+ FILE* fd;
+ if (encryptedAnimation && access(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, R_OK) == 0)
+ fd = fopen(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, "r");
+ else if (access(USER_BOOTANIMATION_FILE, R_OK) == 0)
+ fd = fopen(USER_BOOTANIMATION_FILE, "r");
+ else if (access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0)
+ fd = fopen(SYSTEM_BOOTANIMATION_FILE, "r");
+ else
+ return NO_ERROR;
+
+ if (fd != NULL) {
+ // We could use readahead..
+ // ... if bionic supported it :(
+ //readahead(fd, 0, INT_MAX);
+ void *crappyBuffer = malloc(2*1024*1024);
+ if (crappyBuffer != NULL) {
+ // Read all the zip
+ while (!feof(fd))
+ fread(crappyBuffer, 1024, 2*1024, fd);
+
+ free(crappyBuffer);
+ } else {
+ LOGW("Unable to allocate memory to preload the animation");
+ }
+ fclose(fd);
+ }
+#endif
+
return NO_ERROR;
}
@@ -420,7 +452,7 @@ bool BootAnimation::movie()
const String8 path(entryName.getPathDir());
const String8 leaf(entryName.getPathLeaf());
if (leaf.size() > 0) {
- for (int j=0 ; j<pcount ; j++) {
+ for (size_t j=0 ; j<pcount ; j++) {
if (path == animation.parts[j].path) {
int method;
// supports only stored png files
@@ -468,16 +500,22 @@ bool BootAnimation::movie()
Region clearReg(Rect(mWidth, mHeight));
clearReg.subtractSelf(Rect(xc, yc, xc+animation.width, yc+animation.height));
- for (int i=0 ; i<pcount && !exitPending() ; i++) {
+ for (size_t i=0 ; i<pcount && !exitPending() ; i++) {
const Animation::Part& part(animation.parts[i]);
const size_t fcount = part.frames.size();
+
+ // can be 1, 0, or not set
+ #ifdef NO_TEXTURE_CACHE
+ const int noTextureCache = NO_TEXTURE_CACHE;
+ #else
const int noTextureCache = ((animation.width * animation.height * fcount) >
48 * 1024 * 1024) ? 1 : 0;
+ #endif
glBindTexture(GL_TEXTURE_2D, 0);
for (int r=0 ; !part.count || r<part.count ; r++) {
- for (int j=0 ; j<fcount && !exitPending(); j++) {
+ for (size_t j=0 ; j<fcount && !exitPending(); j++) {
const Animation::Frame& frame(part.frames[j]);
if (r > 0 && !noTextureCache) {
@@ -523,7 +561,7 @@ bool BootAnimation::movie()
// free the textures for this part
if (part.count != 1 && !noTextureCache) {
- for (int j=0 ; j<fcount ; j++) {
+ for (size_t j=0 ; j<fcount ; j++) {
const Animation::Frame& frame(part.frames[j]);
glDeleteTextures(1, &frame.tid);
}