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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user