* 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)
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;
}
}
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;
}
}
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.