diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-09-22 07:55:58 -0400 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-09-22 07:55:58 -0400 |
commit | 585c67f70f18b8879ced854c5865141d6c650cd8 (patch) | |
tree | 9f340df8b5a7828b230df6c93a459ee581ee7891 /core | |
parent | 976e363fe8206fcac5f2342ed3a0c3e0df66d32d (diff) | |
parent | b5c17a64edbdac47d8aa48951b50ea0a8e982655 (diff) | |
download | frameworks_base-585c67f70f18b8879ced854c5865141d6c650cd8.zip frameworks_base-585c67f70f18b8879ced854c5865141d6c650cd8.tar.gz frameworks_base-585c67f70f18b8879ced854c5865141d6c650cd8.tar.bz2 |
Merge change 26300 into eclair
* changes:
experimental fix for compatibility mode. When we scale up by 1.5 (240 dpi), we put stretched ninepatches on exact pixel boundaries when we walk the inverse matrix (e.g. 2/3, 1+1/3, 2, 2+2/3, 3+1/3, 4, ...).
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 50faf57..11c67cc 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -274,6 +274,25 @@ public class CompatibilityInfo { * Apply translation to the canvas that is necessary to draw the content. */ public void translateCanvas(Canvas canvas) { + if (applicationScale == 1.5f) { + /* When we scale for compatibility, we can put our stretched + bitmaps and ninepatches on exacty 1/2 pixel boundaries, + which can give us inconsistent drawing due to imperfect + float precision in the graphics engine's inverse matrix. + + As a work-around, we translate by a tiny amount to avoid + landing on exact pixel centers and boundaries, giving us + the slop we need to draw consistently. + + This constant is meant to resolve to 1/255 after it is + scaled by 1.5 (applicationScale). Note, this is just a guess + as to what is small enough not to create its own artifacts, + and big enough to avoid the precision problems. Feel free + to experiment with smaller values as you choose. + */ + final float tinyOffset = 2.0f / (3 * 255); + canvas.translate(tinyOffset, tinyOffset); + } canvas.scale(applicationScale, applicationScale); } |