Merge "Fix rounding error" into gb-ub-photos-denali
diff --git a/src/com/android/camera/CaptureLayoutHelper.java b/src/com/android/camera/CaptureLayoutHelper.java
index ea7d867..be4c708 100644
--- a/src/com/android/camera/CaptureLayoutHelper.java
+++ b/src/com/android/camera/CaptureLayoutHelper.java
@@ -325,6 +325,26 @@
}
rotate.mapRect(config.mBottomBarRect);
}
+
+ // Round the rect first to avoid rounding errors later on.
+ round(config.mBottomBarRect);
+ round(config.mPreviewRect);
+
return config;
}
+
+ /**
+ * Round the float coordinates in the given rect, and store the rounded value
+ * back in the rect.
+ */
+ public static void round(RectF rect) {
+ if (rect == null) {
+ return;
+ }
+ float left = Math.round(rect.left);
+ float top = Math.round(rect.top);
+ float right = Math.round(rect.right);
+ float bottom = Math.round(rect.bottom);
+ rect.set(left, top, right, bottom);
+ }
}