diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-07-29 15:41:19 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-07-29 19:44:01 -0700 |
commit | 0d221012ff5fd314711c00ed30e9b807b9c454c1 (patch) | |
tree | 328d42900c9765e3bde9ad98a936a9122c679e5e /core/jni/android_util_AssetManager.cpp | |
parent | c6eb5ac988518f41938c4f021003d6c202d84819 (diff) | |
download | frameworks_base-0d221012ff5fd314711c00ed30e9b807b9c454c1.zip frameworks_base-0d221012ff5fd314711c00ed30e9b807b9c454c1.tar.gz frameworks_base-0d221012ff5fd314711c00ed30e9b807b9c454c1.tar.bz2 |
Fix #2018814: System cannot correctly render assets with "wrap_content" attribute in QVGA
It turns out we were not returning the density for anything retrieved from a
TypedArray... which basically means any bitmap references from a layout or style...!!!
This is now fixed.
Also fiddle with the density compatibility mode to turn on smoothing in certain situations,
helping the look of things when they need to scale and we couldn't do the scaling at
load time.
Diffstat (limited to 'core/jni/android_util_AssetManager.cpp')
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 59f4067..66b2506 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -74,12 +74,13 @@ static void doThrow(JNIEnv* env, const char* exc, const char* msg = NULL) } enum { - STYLE_NUM_ENTRIES = 5, + STYLE_NUM_ENTRIES = 6, STYLE_TYPE = 0, STYLE_DATA = 1, STYLE_ASSET_COOKIE = 2, STYLE_RESOURCE_ID = 3, - STYLE_CHANGING_CONFIGURATIONS = 4 + STYLE_CHANGING_CONFIGURATIONS = 4, + STYLE_DENSITY = 5 }; static jint copyValue(JNIEnv* env, jobject outValue, const ResTable* table, @@ -896,6 +897,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla ResTable::Theme* theme = (ResTable::Theme*)themeToken; const ResTable& res = theme->getResTable(); ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; + ResTable_config config; Res_value value; const jsize NI = env->GetArrayLength(attrs); @@ -995,6 +997,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla value.dataType = Res_value::TYPE_NULL; value.data = 0; typeSetFlags = 0; + config.density = 0; // Skip through XML attributes until the end or the next possible match. while (ix < NX && curIdent > curXmlAttr) { @@ -1042,7 +1045,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. //printf("Resolving attribute reference\n"); - ssize_t newBlock = theme->resolveAttributeReference(&value, block, &resid, &typeSetFlags); + ssize_t newBlock = theme->resolveAttributeReference(&value, block, + &resid, &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } else { // If we still don't have a value for this attribute, try to find @@ -1051,7 +1055,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla ssize_t newBlock = theme->getAttribute(curIdent, &value, &typeSetFlags); if (newBlock >= 0) { //printf("Resolving resource reference\n"); - newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags); + newBlock = res.resolveReference(&value, block, &resid, + &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } } @@ -1070,6 +1075,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1; dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; + dest[STYLE_DENSITY] = config.density; if (indices != NULL && value.dataType != Res_value::TYPE_NULL) { indicesIdx++; @@ -1108,6 +1114,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job } const ResTable& res(am->getResources()); ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; + ResTable_config config; Res_value value; const jsize NI = env->GetArrayLength(attrs); @@ -1160,6 +1167,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job value.dataType = Res_value::TYPE_NULL; value.data = 0; typeSetFlags = 0; + config.density = 0; // Skip through XML attributes until the end or the next possible match. while (ix < NX && curIdent > curXmlAttr) { @@ -1179,7 +1187,8 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. //printf("Resolving attribute reference\n"); - ssize_t newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags); + ssize_t newBlock = res.resolveReference(&value, block, &resid, + &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } @@ -1197,6 +1206,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1; dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; + dest[STYLE_DENSITY] = config.density; if (indices != NULL && value.dataType != Res_value::TYPE_NULL) { indicesIdx++; @@ -1250,6 +1260,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz return JNI_FALSE; } const ResTable& res(am->getResources()); + ResTable_config config; Res_value value; ssize_t block; @@ -1276,13 +1287,15 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz while (i < NV && arrayEnt < endArrayEnt) { block = arrayEnt->stringBlock; typeSetFlags = arrayTypeSetFlags; + config.density = 0; value = arrayEnt->map.value; uint32_t resid = 0; if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. //printf("Resolving attribute reference\n"); - ssize_t newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags); + ssize_t newBlock = res.resolveReference(&value, block, &resid, + &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } @@ -1299,6 +1312,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz dest[STYLE_ASSET_COOKIE] = (jint)res.getTableCookie(block); dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; + dest[STYLE_DENSITY] = config.density; dest += STYLE_NUM_ENTRIES; i+= STYLE_NUM_ENTRIES; arrayEnt++; |