Merge "Fix VectorDrawable size rounding issue" into oc-dev
am: be030126fe
Change-Id: I6a9c6e4b6ea7c224406b703bada47f42d0fb0bf7
This commit is contained in:
@@ -483,10 +483,10 @@ public class VectorDrawable extends Drawable {
|
|||||||
final int sourceDensity = mVectorState.mDensity;
|
final int sourceDensity = mVectorState.mDensity;
|
||||||
final int targetDensity = mTargetDensity;
|
final int targetDensity = mTargetDensity;
|
||||||
if (targetDensity != sourceDensity) {
|
if (targetDensity != sourceDensity) {
|
||||||
mDpiScaledWidth = Drawable.scaleFromDensity(
|
mDpiScaledWidth = Drawable.scaleFromDensity(mVectorState.mBaseWidth, sourceDensity,
|
||||||
(int) mVectorState.mBaseWidth, sourceDensity, targetDensity, true);
|
targetDensity, true);
|
||||||
mDpiScaledHeight = Drawable.scaleFromDensity(
|
mDpiScaledHeight = Drawable.scaleFromDensity(mVectorState.mBaseHeight,sourceDensity,
|
||||||
(int) mVectorState.mBaseHeight,sourceDensity, targetDensity, true);
|
targetDensity, true);
|
||||||
final int left = Drawable.scaleFromDensity(
|
final int left = Drawable.scaleFromDensity(
|
||||||
opticalInsets.left, sourceDensity, targetDensity, false);
|
opticalInsets.left, sourceDensity, targetDensity, false);
|
||||||
final int right = Drawable.scaleFromDensity(
|
final int right = Drawable.scaleFromDensity(
|
||||||
@@ -497,8 +497,8 @@ public class VectorDrawable extends Drawable {
|
|||||||
opticalInsets.bottom, sourceDensity, targetDensity, false);
|
opticalInsets.bottom, sourceDensity, targetDensity, false);
|
||||||
mDpiScaledInsets = Insets.of(left, top, right, bottom);
|
mDpiScaledInsets = Insets.of(left, top, right, bottom);
|
||||||
} else {
|
} else {
|
||||||
mDpiScaledWidth = (int) mVectorState.mBaseWidth;
|
mDpiScaledWidth = mVectorState.mBaseWidth;
|
||||||
mDpiScaledHeight = (int) mVectorState.mBaseHeight;
|
mDpiScaledHeight = mVectorState.mBaseHeight;
|
||||||
mDpiScaledInsets = opticalInsets;
|
mDpiScaledInsets = opticalInsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,9 +675,9 @@ public class VectorDrawable extends Drawable {
|
|||||||
"<vector> tag requires viewportHeight > 0");
|
"<vector> tag requires viewportHeight > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
state.mBaseWidth = a.getDimension(
|
state.mBaseWidth = a.getDimensionPixelSize(
|
||||||
R.styleable.VectorDrawable_width, state.mBaseWidth);
|
R.styleable.VectorDrawable_width, state.mBaseWidth);
|
||||||
state.mBaseHeight = a.getDimension(
|
state.mBaseHeight = a.getDimensionPixelSize(
|
||||||
R.styleable.VectorDrawable_height, state.mBaseHeight);
|
R.styleable.VectorDrawable_height, state.mBaseHeight);
|
||||||
|
|
||||||
if (state.mBaseWidth <= 0) {
|
if (state.mBaseWidth <= 0) {
|
||||||
@@ -819,8 +819,8 @@ public class VectorDrawable extends Drawable {
|
|||||||
Mode mTintMode = DEFAULT_TINT_MODE;
|
Mode mTintMode = DEFAULT_TINT_MODE;
|
||||||
boolean mAutoMirrored;
|
boolean mAutoMirrored;
|
||||||
|
|
||||||
float mBaseWidth = 0;
|
int mBaseWidth = 0;
|
||||||
float mBaseHeight = 0;
|
int mBaseHeight = 0;
|
||||||
float mViewportWidth = 0;
|
float mViewportWidth = 0;
|
||||||
float mViewportHeight = 0;
|
float mViewportHeight = 0;
|
||||||
Insets mOpticalInsets = Insets.NONE;
|
Insets mOpticalInsets = Insets.NONE;
|
||||||
@@ -1004,8 +1004,9 @@ public class VectorDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void applyDensityScaling(int sourceDensity, int targetDensity) {
|
private void applyDensityScaling(int sourceDensity, int targetDensity) {
|
||||||
mBaseWidth = Drawable.scaleFromDensity(mBaseWidth, sourceDensity, targetDensity);
|
mBaseWidth = Drawable.scaleFromDensity(mBaseWidth, sourceDensity, targetDensity, true);
|
||||||
mBaseHeight = Drawable.scaleFromDensity(mBaseHeight, sourceDensity, targetDensity);
|
mBaseHeight = Drawable.scaleFromDensity(mBaseHeight, sourceDensity, targetDensity,
|
||||||
|
true);
|
||||||
|
|
||||||
final int insetLeft = Drawable.scaleFromDensity(
|
final int insetLeft = Drawable.scaleFromDensity(
|
||||||
mOpticalInsets.left, sourceDensity, targetDensity, false);
|
mOpticalInsets.left, sourceDensity, targetDensity, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user