From 22ec9421f44eba76c3daac3ac8615bbbf9014a3a Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 12 Mar 2020 11:18:01 +0900 Subject: [PATCH] video: make up for rounding error by comparing if two values are close enough. not sure that this error actually caused by rounding error of e_util_transform, but anyway there was a failure converting 4 vertices of evas_map to elements of rectangle and rotation. And it turned out that was because of 1 pixel difference between two vertices when it is compared to find out whether it's rectangle or not. Change-Id: I1876b35f36fa76a10e00b5ef89c0a2c35a7edd18 --- src/bin/video/iface/e_video_hwc.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/bin/video/iface/e_video_hwc.c b/src/bin/video/iface/e_video_hwc.c index e8d26afab8..0725933881 100644 --- a/src/bin/video/iface/e_video_hwc.c +++ b/src/bin/video/iface/e_video_hwc.c @@ -1008,17 +1008,33 @@ normal: * 1. The given coordinates are not represented by rectangle. * 2. All angles except for 0, 90, 180, 270. */ +#ifdef IS_CLOSE +#undef IS_CLOSE +#endif +#define IS_CLOSE(x, y) (abs((x - y)) < 2) + #ifdef IS_PORTRAIT_RECT #undef IS_PORTRAIT_RECT #endif #define IS_PORTRAIT_RECT(p) \ - ((p[0].y == p[1].y) && (p[1].x == p[2].x) && (p[2].y == p[3].y) && (p[3].x == p[0].x)) + (IS_CLOSE(p[0].y, p[1].y) && IS_CLOSE(p[1].x, p[2].x) && \ + IS_CLOSE(p[2].y, p[3].y) && IS_CLOSE(p[3].x, p[0].x)) #ifdef IS_LANDSCAPE_RECT #undef IS_LANDSCAPE_RECT #endif #define IS_LANDSCAPE_RECT(p) \ - ((p[0].x == p[1].x) && (p[1].y == p[2].y) && (p[2].x == p[3].x) && (p[3].y == p[0].y)) + (IS_CLOSE(p[0].x, p[1].x) && IS_CLOSE(p[1].y, p[2].y) && \ + IS_CLOSE(p[2].x, p[3].x) && IS_CLOSE(p[3].y, p[0].y)) + +#ifdef VERTICES_TO_RECT +#undef VERTICES_TO_RECT +#endif +#define VERTICES_TO_RECT(r, vs) \ + r->x = MIN(vs[0].x, vs[2].x); \ + r->y = MIN(vs[0].y, vs[2].y); \ + r->w = MAX(vs[0].x, vs[2].x) - r->x; \ + r->h = MAX(vs[0].y, vs[2].y) - r->y static Eina_Bool _e_video_hwc_coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *transform) @@ -1031,13 +1047,13 @@ _e_video_hwc_coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, if ((p[0].x < p[2].x) && (p[0].y < p[2].y)) { *transform = TDM_TRANSFORM_NORMAL; - EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y); + VERTICES_TO_RECT(rect, p); ret = EINA_TRUE; } else if ((p[0].x > p[2].x) && (p[0].y > p[2].y)) { *transform = TDM_TRANSFORM_180; - EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y); + VERTICES_TO_RECT(rect, p); ret = EINA_TRUE; } } @@ -1047,13 +1063,13 @@ _e_video_hwc_coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, if ((p[0].x > p[2].x) && (p[0].y < p[2].y)) { *transform = TDM_TRANSFORM_90; - EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y); + VERTICES_TO_RECT(rect, p); ret = EINA_TRUE; } else if ((p[0].x < p[2].x) && (p[0].y > p[2].y)) { *transform = TDM_TRANSFORM_270; - EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y); + VERTICES_TO_RECT(rect, p); ret = EINA_TRUE; } } @@ -1061,8 +1077,10 @@ _e_video_hwc_coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, return ret; } +#undef IS_CLOSE #undef IS_PORTRAIT_RECT #undef IS_LANDSCAPE_RECT +#undef VERTICES_TO_RECT /** * Merge transform value of E_Comp_Wl_Buffer_Viewport with given transform. -- 2.34.1