diff options
author | Mark Wei <markwei@google.com> | 2014-06-25 15:40:38 -0700 |
---|---|---|
committer | Mark Wei <markwei@google.com> | 2014-06-25 15:40:38 -0700 |
commit | df01966f999ddcc69b3e479c9efbd733ad86bc84 (patch) | |
tree | 2485e1250e97b3ba29e0a58c335da9980e2c675f /src/com/android/bitmap/drawable/CircularBitmapDrawable.java | |
parent | 2d10993c4276db5b28ef7cb909362fbbc26c460c (diff) | |
download | bitmap-df01966f999ddcc69b3e479c9efbd733ad86bc84.tar.gz |
Import latest changes to the bitmap library.
Main development is now going on in the Bigtop fork. This import includes the
following changes:
cl/68071490
Cache BitmapShader instance in CircularBitmapDrawable.
This simple implementation is eliminating almost all of the BitmapShader
construction during startup.
cl/69907083
Add compatibility mode to StyledCornersBitmapDrawable for b/15023700 in 4.4.3
The rounded corners and flaps are now drawn on the canvas, instead of clipped
with a path. This part is in the bitmap library.
The drawn corners must match the color of the background color of the
container. The bt_megalist_selected_item_background color has been pre-mixed
with @android:color/white so it's in a ColorDrawable instead of a
LayerDrawable, and so its color can be used to draw the fake corners. This part
is in the Bigtop codebase.
Change-Id: I21a22d8550fbe1dd3de7410cd82969ff947c27ea
Diffstat (limited to 'src/com/android/bitmap/drawable/CircularBitmapDrawable.java')
-rw-r--r-- | src/com/android/bitmap/drawable/CircularBitmapDrawable.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/com/android/bitmap/drawable/CircularBitmapDrawable.java b/src/com/android/bitmap/drawable/CircularBitmapDrawable.java index 8536f58..a4af368 100644 --- a/src/com/android/bitmap/drawable/CircularBitmapDrawable.java +++ b/src/com/android/bitmap/drawable/CircularBitmapDrawable.java @@ -43,6 +43,7 @@ public class CircularBitmapDrawable extends ExtendedBitmapDrawable { private final Paint mBorderPaint = new Paint(); private float mBorderWidth; + private Bitmap mShaderBitmap; public CircularBitmapDrawable(Resources res, BitmapCache cache, boolean limitDensity) { @@ -120,20 +121,22 @@ public class CircularBitmapDrawable extends ExtendedBitmapDrawable { protected void onDrawCircularBitmap(final Bitmap bitmap, final Canvas canvas, final Rect src, final Rect dst, final float alpha) { // Draw bitmap through shader first. - BitmapShader shader = new BitmapShader(bitmap, TileMode.CLAMP, - TileMode.CLAMP); - sMatrix.reset(); + BitmapShader shader = (BitmapShader) mBitmapPaint.getShader(); + if (shader == null || mShaderBitmap != bitmap) { + shader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP); + mShaderBitmap = bitmap; + mBitmapPaint.setShader(shader); + } + sMatrix.reset(); // Fit bitmap to bounds. float scale = Math.max((float) dst.width() / src.width(), (float) dst.height() / src.height()); sMatrix.postScale(scale, scale); - // Translate bitmap to dst bounds. sMatrix.postTranslate(dst.left, dst.top); - shader.setLocalMatrix(sMatrix); - mBitmapPaint.setShader(shader); + int oldAlpha = mBitmapPaint.getAlpha(); mBitmapPaint.setAlpha((int) (oldAlpha * alpha)); canvas.drawCircle(dst.centerX(), dst.centerY(), dst.width() / 2, |