hwc: Add type casting to aspect ratio calculations
Type casting to float prevents rounding off errors which could
result in invalid or unexpected results when doing calculations
with integers.
Change-Id: I6d5c233c013322c4e9c7f7db61b5c604f915643c
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index fa021cc..3cbf494 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -427,8 +427,8 @@
xRatio = (inPos.x - viewFrame.left)/actualWidth;
yRatio = (inPos.y - viewFrame.top)/actualHeight;
// Use viewframe width and height to compute wRatio and hRatio.
- wRatio = inPos.w/(viewFrame.right - viewFrame.left);
- hRatio = inPos.h/(viewFrame.bottom - viewFrame.top);
+ wRatio = (float)inPos.w/(float)(viewFrame.right - viewFrame.left);
+ hRatio = (float)inPos.h/(float)(viewFrame.bottom - viewFrame.top);
//Calculate the position...