From f3d1bbb77f9f3dbe065d713721e0591ea3fa348f Mon Sep 17 00:00:00 2001 From: Prashant Somashekar Date: Sat, 16 Feb 2013 16:47:44 -0500 Subject: bootanimation: performance/speedup enhancements (squashed from CM11) bootanim: Don't cache textures if they're expected to use a lot of VRAM (rmcc) https://github.com/CyanogenMod/android_frameworks_base/commit/14f9eecd3f543a25c4a2053d6155a9396a777a3a#cmds/bootanimation bootanimation: performance enhancements (turl) https://github.com/CyanogenMod/android_frameworks_base/commit/e6b54405aa70d7503a114d9c90ef7518abdd7133#cmds/bootanimation bootanimation: fix usage of LOGW (intervigilium) https://github.com/CyanogenMod/android_frameworks_base/commit/e45cf7d232490f44aecf8f2447220a8b5ace4c10#cmds/bootanimation bootanimation: allow using RGB565 instead of ARGB8888 (tpruvot) https://github.com/CyanogenMod/android_frameworks_base/commit/204282870a9c69b04ad5ddecd73fafbd7996cbc0#cmds/bootanimation [mikeioannina]: Adjust for cm-12.0 Change-Id: I203fa23f77d1349fb822a7662e2cd3998ba4c814 --- cmds/bootanimation/Android.mk | 16 +++++++++++++ cmds/bootanimation/BootAnimation.cpp | 46 +++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) (limited to 'cmds') diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk index a2d5675..0c05ded 100644 --- a/cmds/bootanimation/Android.mk +++ b/cmds/bootanimation/Android.mk @@ -30,6 +30,22 @@ ifeq ($(TARGET_CONTINUOUS_SPLASH_ENABLED),true) LOCAL_CFLAGS += -DCONTINUOUS_SPLASH endif +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 + +ifeq ($(TARGET_BOOTANIMATION_USE_RGB565),true) + LOCAL_CFLAGS += -DUSE_565 +endif + LOCAL_MODULE:= bootanimation ifdef TARGET_32_BIT_SURFACEFLINGER diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index e92e826..934539e 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -271,7 +271,11 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame) if (codec != NULL) { codec->setDitherImage(false); codec->decode(&stream, &bitmap, + #ifdef USE_565 + kRGB_565_SkColorType, + #else kN32_SkColorType, + #endif SkImageDecoder::kDecodePixels_Mode); delete codec; } @@ -425,6 +429,37 @@ status_t BootAnimation::readyToRun() { mZip = zipFile; } +#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(OEM_BOOTANIMATION_FILE, R_OK) == 0) + fd = fopen(OEM_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 { + ALOGW("Unable to allocate memory to preload the animation"); + } + fclose(fd); + } +#endif + return NO_ERROR; } @@ -717,6 +752,15 @@ bool BootAnimation::movie() for (size_t i=0 ; i 48 * 1024 * 1024) ? 1 : 0; + #endif + glBindTexture(GL_TEXTURE_2D, 0); /*calculate if we need to runtime save memory @@ -728,7 +772,7 @@ bool BootAnimation::movie() GLuint mTextureid; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); //ALOGD("freemem:%ld, %d", getFreeMemory(), mMaxTextureSize); - if(getFreeMemory() < mMaxTextureSize * mMaxTextureSize * fcount / 1024) { + if(getFreeMemory() < mMaxTextureSize * mMaxTextureSize * fcount / 1024 || noTextureCache) { ALOGD("Use save memory method, maybe small fps in actual."); needSaveMem = true; glGenTextures(1, &mTextureid); -- cgit v1.1