summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-05-05 10:15:02 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-05 10:17:01 +0200
commit66a2f71c1a7bc657e5b3b695111117bad0f86248 (patch)
tree24cf365feb2cf6c03e8f561a1a9fd7c388df2721 /src/modules
parent8a7b73ccbc396b8f3a0ceb95fde97c85f12b905e (diff)
evas: handle orientation while an object is cutout.
T2338 Thanks to DaveMDS to take the time to report accurately the issue. That helped a lot figuring out things. And another thanks to Vincent Torri for the help on the math side.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c220
1 files changed, 155 insertions, 65 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index b526eab..97d5c32 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -1256,54 +1256,13 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
1256 PUSH_VERTEX(pn, x , y + h, 0); PUSH_VERTEX(pn, x + w, y , 0); \ 1256 PUSH_VERTEX(pn, x , y + h, 0); PUSH_VERTEX(pn, x + w, y , 0); \
1257 PUSH_VERTEX(pn, x + w, y + h, 0); PUSH_VERTEX(pn, x , y + h, 0); \ 1257 PUSH_VERTEX(pn, x + w, y + h, 0); PUSH_VERTEX(pn, x , y + h, 0); \
1258 } while (0) 1258 } while (0)
1259#define PUSH_6_TEXUV(pn, Tex, x1, y1, x2, y2) do { \ 1259#define PUSH_6_QUAD(pn, x1, y1, x2, y2, x3, y3, x4, y4) \
1260 Evas_GL_Texture *_tex = Tex; \ 1260 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x4, y4);\
1261 if (_tex && _tex->im) \ 1261 PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x3, y3); PUSH_TEXUV(pn, x4, y4);
1262 { \ 1262
1263 switch (_tex->im->orient) \ 1263#define PUSH_6_TEXUV(pn, x1, y1, x2, y2) \
1264 { \ 1264 PUSH_6_QUAD(pn, x1, y1, x2, y1, x2, y2, x1, y2);
1265 case EVAS_IMAGE_ORIENT_NONE: \ 1265
1266 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y2); \
1267 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y2); \
1268 break; \
1269 case EVAS_IMAGE_ORIENT_90: \
1270 PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y2); \
1271 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x2, y2); \
1272 break; \
1273 case EVAS_IMAGE_ORIENT_180: \
1274 PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x2, y1); \
1275 PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y1); \
1276 break; \
1277 case EVAS_IMAGE_ORIENT_270: \
1278 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y1); \
1279 PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x1, y1); \
1280 break; \
1281 case EVAS_IMAGE_FLIP_HORIZONTAL: \
1282 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y2); \
1283 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x2, y2); \
1284 break; \
1285 case EVAS_IMAGE_FLIP_VERTICAL: \
1286 PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y1); \
1287 PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y1); \
1288 break; \
1289 case EVAS_IMAGE_FLIP_TRANSVERSE: \
1290 PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y2); \
1291 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x1, y2); \
1292 break; \
1293 case EVAS_IMAGE_FLIP_TRANSPOSE: \
1294 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x2, y1); \
1295 PUSH_TEXUV(pn, x1, y2); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x2, y1); \
1296 break; \
1297 default: \
1298 ERR("Wrong orientation"); \
1299 } \
1300 } \
1301 else \
1302 { \
1303 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y2); \
1304 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y2); \
1305 } \
1306 } while (0)
1307#define PUSH_6_TEXUV2(pn, x1, y1, x2, y2) do { \ 1266#define PUSH_6_TEXUV2(pn, x1, y1, x2, y2) do { \
1308 PUSH_TEXUV2(pn, x1, y1); PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x1, y2); \ 1267 PUSH_TEXUV2(pn, x1, y1); PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x1, y2); \
1309 PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x2, y2); PUSH_TEXUV2(pn, x1, y2); \ 1268 PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x2, y2); PUSH_TEXUV2(pn, x1, y2); \
@@ -1950,6 +1909,73 @@ again:
1950 PUSH_6_COLORS(pn, r, g, b, a); 1909 PUSH_6_COLORS(pn, r, g, b, a);
1951} 1910}
1952 1911
1912static void
1913_rotate_point_90(double *x, double *y, double w, double h)
1914{
1915 double tx, ty, t;
1916
1917 tx = *x - w / 2;
1918 ty = *y - h / 2;
1919 t = tx;
1920 tx = ty;
1921 ty = t;
1922 tx = tx + h / 2;
1923 ty = ty + w / 2;
1924 *x = tx * h / w;
1925 *y = w - ty * w / h;
1926}
1927
1928static void
1929_rotate_point_180(double *x, double *y, double w, double h)
1930{
1931 double tx, ty;
1932
1933 tx = *x - w / 2;
1934 ty = *y - h / 2;
1935 tx = -tx;
1936 ty = -ty;
1937 tx = tx + w / 2;
1938 ty = ty + h / 2;
1939 *x = tx;
1940 *y = ty;
1941}
1942
1943static void
1944_rotate_point_270(double *x, double *y, double w, double h)
1945{
1946 double tx, ty, t;
1947
1948 tx = *x - h / 2;
1949 ty = *y - w / 2;
1950 t = tx;
1951 tx = ty;
1952 ty = t;
1953 tx = tx + w / 2;
1954 ty = ty + h / 2;
1955 *x = h - tx * h / w;
1956 *y = ty * w / h;
1957}
1958
1959static void
1960_transpose(double *x, double *y, double w, double h)
1961{
1962 double t;
1963
1964 t = *x;
1965 *x = *y * h / w;
1966 *y = t * w / h;
1967}
1968
1969static void
1970_transverse(double *x, double *y, double w, double h)
1971{
1972 double t;
1973
1974 t = *x;
1975 *x = (w - *y) * h / w;
1976 *y = (h - t) * w / h;
1977}
1978
1953void 1979void
1954evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, 1980evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
1955 Evas_GL_Texture *tex, 1981 Evas_GL_Texture *tex,
@@ -1960,7 +1986,8 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
1960 Eina_Bool smooth, Eina_Bool tex_only) 1986 Eina_Bool smooth, Eina_Bool tex_only)
1961{ 1987{
1962 Evas_GL_Texture_Pool *pt; 1988 Evas_GL_Texture_Pool *pt;
1963 GLfloat tx1, tx2, ty1, ty2; 1989 double ox1, oy1, ox2, oy2, ox3, oy3, ox4, oy4;
1990 GLfloat tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4;
1964 GLfloat offsetx, offsety; 1991 GLfloat offsetx, offsety;
1965 double pw, ph; 1992 double pw, ph;
1966 Eina_Bool blend = EINA_FALSE; 1993 Eina_Bool blend = EINA_FALSE;
@@ -2050,23 +2077,86 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2050 ph = pt->w; 2077 ph = pt->w;
2051 } 2078 }
2052 2079
2053 if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert)) 2080 ox1 = sx;
2081 oy1 = sy;
2082 ox2 = sx + sw;
2083 oy2 = sy;
2084 ox3 = sx + sw;
2085 oy3 = sy + sh;
2086 ox4 = sx;
2087 oy4 = sy + sh;
2088
2089 if (tex->im)
2054 { 2090 {
2055 tx1 = ((double)(offsetx) + sx) / pw; 2091 switch (tex->im->orient)
2056 ty1 = 1.0 - ((double)(offsety) + sy) / ph; 2092 {
2057 tx2 = ((double)(offsetx) + sx + sw) / pw; 2093 case EVAS_IMAGE_ORIENT_NONE:
2058 ty2 = 1.0 - ((double)(offsety) + sy + sh) / ph; 2094 break;
2095 case EVAS_IMAGE_ORIENT_90:
2096 _rotate_point_90(&ox1, &oy1, tex->im->w, tex->im->h);
2097 _rotate_point_90(&ox2, &oy2, tex->im->w, tex->im->h);
2098 _rotate_point_90(&ox3, &oy3, tex->im->w, tex->im->h);
2099 _rotate_point_90(&ox4, &oy4, tex->im->w, tex->im->h);
2100 break;
2101 case EVAS_IMAGE_ORIENT_180:
2102 _rotate_point_180(&ox1, &oy1, tex->im->w, tex->im->h);
2103 _rotate_point_180(&ox2, &oy2, tex->im->w, tex->im->h);
2104 _rotate_point_180(&ox3, &oy3, tex->im->w, tex->im->h);
2105 _rotate_point_180(&ox4, &oy4, tex->im->w, tex->im->h);
2106 break;
2107 case EVAS_IMAGE_ORIENT_270:
2108 _rotate_point_270(&ox1, &oy1, tex->im->w, tex->im->h);
2109 _rotate_point_270(&ox2, &oy2, tex->im->w, tex->im->h);
2110 _rotate_point_270(&ox3, &oy3, tex->im->w, tex->im->h);
2111 _rotate_point_270(&ox4, &oy4, tex->im->w, tex->im->h);
2112 break;
2113 case EVAS_IMAGE_FLIP_HORIZONTAL:
2114 ox1 = tex->im->w - ox1;
2115 ox2 = tex->im->w - ox2;
2116 ox3 = tex->im->w - ox3;
2117 ox4 = tex->im->w - ox4;
2118 break;
2119 case EVAS_IMAGE_FLIP_VERTICAL:
2120 oy1 = tex->im->h - oy1;
2121 oy2 = tex->im->h - oy2;
2122 oy3 = tex->im->h - oy3;
2123 oy4 = tex->im->h - oy4;
2124 break;
2125 case EVAS_IMAGE_FLIP_TRANSVERSE:
2126 _transverse(&ox1, &oy1, tex->im->w, tex->im->h);
2127 _transverse(&ox2, &oy2, tex->im->w, tex->im->h);
2128 _transverse(&ox3, &oy3, tex->im->w, tex->im->h);
2129 _transverse(&ox4, &oy4, tex->im->w, tex->im->h);
2130 break;
2131 case EVAS_IMAGE_FLIP_TRANSPOSE:
2132 _transpose(&ox1, &oy1, tex->im->w, tex->im->h);
2133 _transpose(&ox2, &oy2, tex->im->w, tex->im->h);
2134 _transpose(&ox3, &oy3, tex->im->w, tex->im->h);
2135 _transpose(&ox4, &oy4, tex->im->w, tex->im->h);
2136 break;
2137 default:
2138 ERR("Wrong orientation ! %i", tex->im->orient);
2139 }
2059 } 2140 }
2060 else 2141
2142 tx1 = ((double)(offsetx) + ox1) / pw;
2143 ty1 = ((double)(offsety) + oy1) / ph;
2144 tx2 = ((double)(offsetx) + ox2) / pw;
2145 ty2 = ((double)(offsety) + oy2) / ph;
2146 tx3 = ((double)(offsetx) + ox3) / pw;
2147 ty3 = ((double)(offsety) + oy3) / ph;
2148 tx4 = ((double)(offsetx) + ox4) / pw;
2149 ty4 = ((double)(offsety) + oy4) / ph;
2150 if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert))
2061 { 2151 {
2062 tx1 = ((double)(offsetx) + sx) / pw; 2152 ty1 = 1.0 - ty1;
2063 ty1 = ((double)(offsety) + sy) / ph; 2153 ty2 = 1.0 - ty2;
2064 tx2 = ((double)(offsetx) + sx + sw) / pw; 2154 ty3 = 1.0 - ty3;
2065 ty2 = ((double)(offsety) + sy + sh) / ph; 2155 ty4 = 1.0 - ty4;
2066 } 2156 }
2067 2157
2068 PUSH_6_VERTICES(pn, x, y, w, h); 2158 PUSH_6_VERTICES(pn, x, y, w, h);
2069 PUSH_6_TEXUV(pn, tex, tx1, ty1, tx2, ty2); 2159 PUSH_6_QUAD(pn, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
2070 2160
2071 if (sam) 2161 if (sam)
2072 { 2162 {
@@ -2156,7 +2246,7 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
2156 } 2246 }
2157 2247
2158 PUSH_6_VERTICES(pn, x, y, w, h); 2248 PUSH_6_VERTICES(pn, x, y, w, h);
2159 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2); 2249 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2160 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2250 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2161 PUSH_6_COLORS(pn, r, g, b, a); 2251 PUSH_6_COLORS(pn, r, g, b, a);
2162} 2252}
@@ -2232,7 +2322,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
2232 t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h; 2322 t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h;
2233 2323
2234 PUSH_6_VERTICES(pn, x, y, w, h); 2324 PUSH_6_VERTICES(pn, x, y, w, h);
2235 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2); 2325 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2236 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2); 2326 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2237 PUSH_6_TEXUV3(pn, t2x1, t2y1, t2x2, t2y2); 2327 PUSH_6_TEXUV3(pn, t2x1, t2y1, t2x2, t2y2);
2238 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2328 PUSH_MASK(pn, mtex, mx, my, mw, mh);
@@ -2310,7 +2400,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
2310 t2y2 = (sy + sh) / (double)tex->ptuv->h; 2400 t2y2 = (sy + sh) / (double)tex->ptuv->h;
2311 2401
2312 PUSH_6_VERTICES(pn, x, y, w, h); 2402 PUSH_6_VERTICES(pn, x, y, w, h);
2313 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2); 2403 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2314 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2); 2404 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2315 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2405 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2316 if (!nomul) 2406 if (!nomul)
@@ -2390,7 +2480,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
2390 t2y2 = (sy + sh) / (double)tex->ptuv->h; 2480 t2y2 = (sy + sh) / (double)tex->ptuv->h;
2391 2481
2392 PUSH_6_VERTICES(pn, x, y, w, h); 2482 PUSH_6_VERTICES(pn, x, y, w, h);
2393 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2); 2483 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2394 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2); 2484 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2395 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2485 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2396 if (!nomul) 2486 if (!nomul)
@@ -2474,7 +2564,7 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
2474 t2y2 = (tex->y + sy + sh) / (double)tex->pta->h; 2564 t2y2 = (tex->y + sy + sh) / (double)tex->pta->h;
2475 2565
2476 PUSH_6_VERTICES(pn, x, y, w, h); 2566 PUSH_6_VERTICES(pn, x, y, w, h);
2477 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2); 2567 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2478 PUSH_6_TEXA(pn, t2x1, t2y1, t2x2, t2y2); 2568 PUSH_6_TEXA(pn, t2x1, t2y1, t2x2, t2y2);
2479 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2569 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2480 if (!nomul) 2570 if (!nomul)