summaryrefslogtreecommitdiffstats
path: root/core/jni/android
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2010-03-10 10:28:10 -0500
committerMike Reed <reed@google.com>2010-03-10 13:11:47 -0500
commit36ad54acef82f80dbf0ecdd8c44f5764df1be119 (patch)
tree8bc00f3c4ea24862e1520fe8982a81205e7e6c1d /core/jni/android
parent49658cb55bdabfd8e086f896b8ea49458db2de6f (diff)
downloadframeworks_base-36ad54acef82f80dbf0ecdd8c44f5764df1be119.zip
frameworks_base-36ad54acef82f80dbf0ecdd8c44f5764df1be119.tar.gz
frameworks_base-36ad54acef82f80dbf0ecdd8c44f5764df1be119.tar.bz2
force purgeability for assets
Change-Id: I1067cfb91846a05290ed26ce9a62eb82d3170719 http://b/issue?id=1860187
Diffstat (limited to 'core/jni/android')
-rw-r--r--core/jni/android/graphics/BitmapFactory.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 9965fe5..b6f3997 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -331,12 +331,14 @@ static SkPixelRef* installPixelRef(SkBitmap* bitmap, SkStream* stream,
// i.e. dynamically allocated, since its lifetime may exceed the current stack
// frame.
static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
- jobject options, bool allowPurgeable) {
+ jobject options, bool allowPurgeable,
+ bool forcePurgeable = false) {
int sampleSize = 1;
SkImageDecoder::Mode mode = SkImageDecoder::kDecodePixels_Mode;
SkBitmap::Config prefConfig = SkBitmap::kNo_Config;
bool doDither = true;
- bool isPurgeable = allowPurgeable && optionsPurgeable(env, options);
+ bool isPurgeable = forcePurgeable ||
+ (allowPurgeable && optionsPurgeable(env, options));
bool reportSizeToVM = optionsReportSizeToVM(env, options);
if (NULL != options) {
@@ -568,8 +570,10 @@ 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 (optionsPurgeable(env, options)) {
+ if (forcePurgeable || 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);
@@ -582,7 +586,7 @@ static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz,
stream = new AssetStreamAdaptor(asset);
}
SkAutoUnref aur(stream);
- return doDecode(env, stream, padding, options, true);
+ return doDecode(env, stream, padding, options, true, forcePurgeable);
}
static jobject nativeDecodeByteArray(JNIEnv* env, jobject, jbyteArray byteArray,