Skip to content

Commit 847fbbe

Browse files
Christopher TateAndroid (Google) Code Review
authored andcommitted
Merge "Localized optimizations in views and bitmaps" into ics-mr1
2 parents 48b651c + 1373a8e commit 847fbbe

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

core/java/android/widget/EdgeEffect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public EdgeEffect(Context context) {
129129
mEdge = res.getDrawable(R.drawable.overscroll_edge);
130130
mGlow = res.getDrawable(R.drawable.overscroll_glow);
131131

132-
mMinWidth = (int) (context.getResources().getDisplayMetrics().density * MIN_WIDTH + 0.5f);
132+
mMinWidth = (int) (res.getDisplayMetrics().density * MIN_WIDTH + 0.5f);
133133
mInterpolator = new DecelerateInterpolator();
134134
}
135135

core/java/android/widget/TextView.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.content.Intent;
2525
import android.content.pm.PackageManager;
2626
import android.content.res.ColorStateList;
27+
import android.content.res.CompatibilityInfo;
2728
import android.content.res.Resources;
2829
import android.content.res.TypedArray;
2930
import android.content.res.XmlResourceParser;
@@ -449,18 +450,19 @@ public TextView(Context context,
449450
super(context, attrs, defStyle);
450451
mText = "";
451452

453+
final Resources res = getResources();
454+
final CompatibilityInfo compat = res.getCompatibilityInfo();
455+
452456
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
453-
mTextPaint.density = getResources().getDisplayMetrics().density;
454-
mTextPaint.setCompatibilityScaling(
455-
getResources().getCompatibilityInfo().applicationScale);
457+
mTextPaint.density = res.getDisplayMetrics().density;
458+
mTextPaint.setCompatibilityScaling(compat.applicationScale);
456459

457460
// If we get the paint from the skin, we should set it to left, since
458461
// the layout always wants it to be left.
459462
// mTextPaint.setTextAlign(Paint.Align.LEFT);
460463

461464
mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
462-
mHighlightPaint.setCompatibilityScaling(
463-
getResources().getCompatibilityInfo().applicationScale);
465+
mHighlightPaint.setCompatibilityScaling(compat.applicationScale);
464466

465467
mMovement = getDefaultMovementMethod();
466468
mTransformation = null;

graphics/java/android/graphics/Bitmap.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,13 @@ private static Bitmap createBitmap(int width, int height, Config config, boolean
604604
}
605605
Bitmap bm = nativeCreate(null, 0, width, width, height, config.nativeInt, true);
606606
if (config == Config.ARGB_8888 && !hasAlpha) {
607-
bm.eraseColor(0xff000000);
607+
nativeErase(bm.mNativeBitmap, 0xff000000);
608608
nativeSetHasAlpha(bm.mNativeBitmap, hasAlpha);
609609
} else {
610-
bm.eraseColor(0);
610+
// No need to initialize it to zeroes; it is backed by a VM byte array
611+
// which is by definition preinitialized to all zeroes.
612+
//
613+
//nativeErase(bm.mNativeBitmap, 0);
611614
}
612615
return bm;
613616
}

0 commit comments

Comments
 (0)