summaryrefslogtreecommitdiff
path: root/src/com/android/bitmap/drawable
diff options
context:
space:
mode:
authorOleksandr Kyreiev <shoora@google.com>2014-12-18 17:54:56 +0100
committerOleksandr Kyreiev <shoora@google.com>2014-12-18 17:54:56 +0100
commita8b1e1f5cad36086e89c052007473609c379ccbd (patch)
tree2938160ebeb973ba402a64b880311cfd994b8ab0 /src/com/android/bitmap/drawable
parent4309c1f708f469a5ab3ac52b6b22cc6ede1d50ff (diff)
downloadbitmap-a8b1e1f5cad36086e89c052007473609c379ccbd.tar.gz
Import latest changes.
Change-Id: I27973b3441d3738a85481de9c774da0ac08afd7c
Diffstat (limited to 'src/com/android/bitmap/drawable')
-rw-r--r--src/com/android/bitmap/drawable/BasicBitmapDrawable.java19
-rw-r--r--src/com/android/bitmap/drawable/CircularBitmapDrawable.java16
-rw-r--r--src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java5
3 files changed, 13 insertions, 27 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
index 3ecc15b..67884df 100644
--- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
@@ -58,8 +58,6 @@ import java.util.concurrent.TimeUnit;
public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
Drawable.Callback, RequestKey.Callback {
- protected static Rect sRect;
-
protected RequestKey mCurrKey;
protected RequestKey mPrevKey;
protected int mDecodeWidth;
@@ -67,6 +65,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
protected final Paint mPaint = new Paint();
private final BitmapCache mCache;
+ private final Rect mRect = new Rect();
private final boolean mLimitDensity;
private final float mDensity;
@@ -100,10 +99,6 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
mPaint.setFilterBitmap(true);
mPaint.setAntiAlias(true);
mPaint.setDither(true);
-
- if (sRect == null) {
- sRect = new Rect();
- }
}
public final RequestKey getKey() {
@@ -265,12 +260,6 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
}
mCreateFileDescriptorFactoryTask = null;
- if (factory == null) {
- // Failed.
- onDecodeFailed();
- return;
- }
-
if (key.equals(mCurrKey)) {
decode(factory);
}
@@ -359,7 +348,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
bounds.width(), bounds.height(),
bounds.height(), Integer.MAX_VALUE, getDecodeHorizontalCenter(),
getDrawVerticalCenter(), false /* absoluteFraction */,
- getDrawVerticalOffsetMultiplier(), sRect);
+ getDrawVerticalOffsetMultiplier(), mRect);
final int orientation = mBitmap.getOrientation();
// calculateCroppedSrcRect() gave us the source rectangle "as if" the orientation has
@@ -367,7 +356,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
// coordinates.
RectUtils.rotateRectForOrientation(orientation,
new Rect(0, 0, mBitmap.getLogicalWidth(), mBitmap.getLogicalHeight()),
- sRect);
+ mRect);
// We may need to rotate the canvas, so we also have to rotate the bounds.
final Rect rotatedBounds = new Rect(bounds);
@@ -376,7 +365,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
// Rotate the canvas.
canvas.save();
canvas.rotate(orientation, bounds.centerX(), bounds.centerY());
- onDrawBitmap(canvas, sRect, rotatedBounds);
+ onDrawBitmap(canvas, mRect, rotatedBounds);
canvas.restore();
}
}
diff --git a/src/com/android/bitmap/drawable/CircularBitmapDrawable.java b/src/com/android/bitmap/drawable/CircularBitmapDrawable.java
index cb8ede7..dec8acf 100644
--- a/src/com/android/bitmap/drawable/CircularBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/CircularBitmapDrawable.java
@@ -37,10 +37,10 @@ import com.android.bitmap.BitmapCache;
* This draws all bitmaps as a circle with an optional border stroke.
*/
public class CircularBitmapDrawable extends ExtendedBitmapDrawable {
- private static Matrix sMatrix = new Matrix();
-
private final Paint mBitmapPaint = new Paint();
private final Paint mBorderPaint = new Paint();
+ private final Rect mRect = new Rect();
+ private final Matrix mMatrix = new Matrix();
private float mBorderWidth;
private Bitmap mShaderBitmap;
@@ -104,8 +104,8 @@ public class CircularBitmapDrawable extends ExtendedBitmapDrawable {
(BitmapDrawable) drawable.getInnerDrawable();
Bitmap bitmap = placeholder.getBitmap();
float alpha = placeholder.getPaint().getAlpha() / 255f;
- sRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
- onDrawCircularBitmap(bitmap, canvas, sRect, bounds, alpha);
+ mRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
+ onDrawCircularBitmap(bitmap, canvas, mRect, bounds, alpha);
} else {
super.onDrawPlaceholderOrProgress(canvas, drawable);
}
@@ -137,14 +137,14 @@ public class CircularBitmapDrawable extends ExtendedBitmapDrawable {
mShaderBitmap = bitmap;
}
- sMatrix.reset();
+ mMatrix.reset();
// Fit bitmap to bounds.
float scale = Math.max((float) dst.width() / src.width(),
(float) dst.height() / src.height());
- sMatrix.postScale(scale, scale);
+ mMatrix.postScale(scale, scale);
// Translate bitmap to dst bounds.
- sMatrix.postTranslate(dst.left, dst.top);
- shader.setLocalMatrix(sMatrix);
+ mMatrix.postTranslate(dst.left, dst.top);
+ shader.setLocalMatrix(mMatrix);
mBitmapPaint.setShader(shader);
int oldAlpha = mBitmapPaint.getAlpha();
diff --git a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
index fc54419..2fcc412 100644
--- a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
@@ -712,11 +712,8 @@ public class ExtendedBitmapDrawable extends BasicBitmapDrawable implements
* This should not be confused with {@link #setParallaxFraction(float)}. This field
* determines the general section for decode. The parallax fraction then determines the
* slice from within that section for display.
- *
- * The default value of 1f / 3 provides a good heuristic for the subject's face in a
- * portrait photo.
*/
- public float decodeVerticalCenter = 1f / 3;
+ public float decodeVerticalCenter = 1f / 2;
/**
* Required field if {@link #FEATURE_ORDERED_DISPLAY} is supported.