Merge "Use correct rounding in View for potentially negative values"
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 461506b..de4d439 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6329,8 +6329,8 @@
position.offset(mAttachInfo.mWindowLeft, mAttachInfo.mWindowTop);
- outRect.set((int) (position.left + 0.5f), (int) (position.top + 0.5f),
- (int) (position.right + 0.5f), (int) (position.bottom + 0.5f));
+ outRect.set(Math.round(position.left), Math.round(position.top),
+ Math.round(position.right), Math.round(position.bottom));
}
/**
@@ -18548,8 +18548,8 @@
position[1] -= vr.mCurScrollY;
}
- inOutLocation[0] = (int) (position[0] + 0.5f);
- inOutLocation[1] = (int) (position[1] + 0.5f);
+ inOutLocation[0] = Math.round(position[0]);
+ inOutLocation[1] = Math.round(position[1]);
}
/**
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index db978a6..25df004 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5114,10 +5114,10 @@
transformMatrix = childMatrix;
}
transformMatrix.mapRect(boundingRect);
- dirty.set((int) (boundingRect.left - 0.5f),
- (int) (boundingRect.top - 0.5f),
- (int) (boundingRect.right + 0.5f),
- (int) (boundingRect.bottom + 0.5f));
+ dirty.set((int) Math.floor(boundingRect.left),
+ (int) Math.floor(boundingRect.top),
+ (int) Math.ceil(boundingRect.right),
+ (int) Math.ceil(boundingRect.bottom));
}
do {
@@ -5154,10 +5154,10 @@
RectF boundingRect = attachInfo.mTmpTransformRect;
boundingRect.set(dirty);
m.mapRect(boundingRect);
- dirty.set((int) (boundingRect.left - 0.5f),
- (int) (boundingRect.top - 0.5f),
- (int) (boundingRect.right + 0.5f),
- (int) (boundingRect.bottom + 0.5f));
+ dirty.set((int) Math.floor(boundingRect.left),
+ (int) Math.floor(boundingRect.top),
+ (int) Math.ceil(boundingRect.right),
+ (int) Math.ceil(boundingRect.bottom));
}
}
} while (parent != null);
@@ -5457,8 +5457,8 @@
position[0] = offset.x;
position[1] = offset.y;
child.getMatrix().mapPoints(position);
- offset.x = (int) (position[0] + 0.5f);
- offset.y = (int) (position[1] + 0.5f);
+ offset.x = Math.round(position[0]);
+ offset.y = Math.round(position[1]);
}
offset.x += dx;
offset.y += dy;
@@ -5485,8 +5485,8 @@
rectIsVisible = rect.intersect(mClipBounds.left, mClipBounds.top, mClipBounds.right,
mClipBounds.bottom);
}
- r.set((int) (rect.left + 0.5f), (int) (rect.top + 0.5f), (int) (rect.right + 0.5f),
- (int) (rect.bottom + 0.5f));
+ r.set((int) Math.floor(rect.left), (int) Math.floor(rect.top),
+ (int) Math.ceil(rect.right), (int) Math.ceil(rect.bottom));
if (rectIsVisible && mParent != null) {
rectIsVisible = mParent.getChildVisibleRect(this, r, offset);
}