summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-04-30 10:58:30 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-04-30 10:58:31 +0000
commitd0f7f41828493b0679e908f7bb3ed3b8e838c463 (patch)
tree3a59dbad3788ed44780ea728f306e3eb84d915fe
parentade631eed0df228e343f2a00db653058ff588846 (diff)
parent0c1eeb3c8ab53954218d3b8f4be08ff21be3e985 (diff)
downloadbase-d0f7f41828493b0679e908f7bb3ed3b8e838c463.tar.gz
Merge "Freeing frame map"
-rw-r--r--cmds/bootanimation/BootAnimation.cpp14
-rw-r--r--cmds/bootanimation/BootAnimation.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 1a2ab81badc3..7f7ae2c2f150 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -156,12 +156,12 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
return NO_ERROR;
}
-status_t BootAnimation::initTexture(void* buffer, size_t len)
+status_t BootAnimation::initTexture(const Animation::Frame& frame)
{
//StopWatch watch("blah");
SkBitmap bitmap;
- SkMemoryStream stream(buffer, len);
+ SkMemoryStream stream(frame.map->getDataPtr(), frame.map->getDataLength());
SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
if (codec) {
codec->setDitherImage(false);
@@ -171,6 +171,11 @@ status_t BootAnimation::initTexture(void* buffer, size_t len)
delete codec;
}
+ // FileMap memory is never released until application exit.
+ // Release it now as the texture is already loaded and the memory used for
+ // the packed resource can be released.
+ frame.map->release();
+
// ensure we can call getPixels(). No need to call unlock, since the
// bitmap will go out of scope when we return from this method.
bitmap.lockPixels();
@@ -406,6 +411,7 @@ bool BootAnimation::movie()
String8 desString((char const*)descMap->getDataPtr(),
descMap->getDataLength());
+ descMap->release();
char const* s = desString.string();
Animation animation;
@@ -530,9 +536,7 @@ bool BootAnimation::movie()
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
- initTexture(
- frame.map->getDataPtr(),
- frame.map->getDataLength());
+ initTexture(frame);
}
if (!clearReg.isEmpty()) {
diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h
index 22963c220b40..ba1c507d778c 100644
--- a/cmds/bootanimation/BootAnimation.h
+++ b/cmds/bootanimation/BootAnimation.h
@@ -79,7 +79,7 @@ private:
};
status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
- status_t initTexture(void* buffer, size_t len);
+ status_t initTexture(const Animation::Frame& frame);
bool android();
bool movie();