Load assets in place instead of deferring until draw.

Before this change, all framework assets would be decoded at drawing time
outside of zygote. This was forcing all apps to re-decode the assets and
zygote to keep an in-memory copy of each asset. This behavior is now
opt-in by setting the inPurgeable flag on BitmapFactory.Options.

Change-Id: Ic703f57adb26b2a701ecff0a653d35a93e26d47c
This commit is contained in:
Romain Guy
2010-08-19 14:41:16 -07:00
parent 4b7cc64028
commit 207b3ab604
2 changed files with 13 additions and 17 deletions

View File

@@ -218,6 +218,7 @@ static SkPixelRef* installPixelRef(SkBitmap* bitmap, SkStream* stream,
}
pr->setDitherImage(ditherImage);
bitmap->setPixelRef(pr)->unref();
pr->isOpaque(bitmap);
return pr;
}
@@ -464,10 +465,7 @@ static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz,
jobject options) { // BitmapFactory$Options
SkStream* stream;
Asset* asset = reinterpret_cast<Asset*>(native_asset);
// assets can always be rebuilt, so force this
bool forcePurgeable = true;
if (forcePurgeable || optionsPurgeable(env, options)) {
if (optionsPurgeable(env, options)) {
// if we could "ref/reopen" the asset, we may not need to copy it here
// and we could assume optionsShareable, since assets are always RO
stream = copyAssetToStream(asset);