summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-02-11 21:32:15 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-12 11:23:03 +0900
commit9eaadb2eb764d1a9fac0ebdabca5432d0b0edf7d (patch)
tree2bc5817af094e48d37e277667ab346626d077c70 /src
parent7e26c305220b4dd8e7e2a85b7b50444e855e26fe (diff)
Evas GL common: Simplify GL pipe code with macros
A lot of the code was just brutal copy & paste. Reduced by using simpler macros, which I believe are even more readable.
Diffstat (limited to 'src')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c189
1 files changed, 39 insertions, 150 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 4ad661dbd2..1a8df2f442 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -1251,6 +1251,27 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
1251 gc->pipe[n].array.texm[nm++] = u; \ 1251 gc->pipe[n].array.texm[nm++] = u; \
1252 gc->pipe[n].array.texm[nm++] = v; } while(0) 1252 gc->pipe[n].array.texm[nm++] = v; } while(0)
1253 1253
1254#define PUSH_6_VERTICES(pn, x, y, w, h) do { \
1255 PUSH_VERTEX(pn, x , y , 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); \
1258 } while (0)
1259#define PUSH_6_TEXUV(pn, x1, y1, x2, y2) do { \
1260 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y2); \
1261 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y2); \
1262 } while (0)
1263#define PUSH_6_TEXUV2(pn, x1, y1, x2, y2) do { \
1264 PUSH_TEXUV2(pn, x1, y1); PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x1, y2); \
1265 PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x2, y2); PUSH_TEXUV2(pn, x1, y2); \
1266 } while (0)
1267#define PUSH_6_TEXUV3(pn, x1, y1, x2, y2) do { \
1268 PUSH_TEXUV3(pn, x1, y1); PUSH_TEXUV3(pn, x2, y1); PUSH_TEXUV3(pn, x1, y2); \
1269 PUSH_TEXUV3(pn, x2, y1); PUSH_TEXUV3(pn, x2, y2); PUSH_TEXUV3(pn, x1, y2); \
1270 } while (0)
1271#define PUSH_6_TEXA(pn, x1, y1, x2, y2) do { \
1272 PUSH_TEXA(pn, x1, y1); PUSH_TEXA(pn, x2, y1); PUSH_TEXA(pn, x1, y2); \
1273 PUSH_TEXA(pn, x2, y1); PUSH_TEXA(pn, x2, y2); PUSH_TEXA(pn, x1, y2); \
1274 } while (0)
1254#define PUSH_6_COLORS(pn, r, g, b, a) \ 1275#define PUSH_6_COLORS(pn, r, g, b, a) \
1255 do { int i; for (i = 0; i < 6; i++) PUSH_COLOR(pn, r, g, b, a); } while(0) 1276 do { int i; for (i = 0; i < 6; i++) PUSH_COLOR(pn, r, g, b, a); } while(0)
1256 1277
@@ -1821,17 +1842,8 @@ again:
1821 1842
1822 pipe_region_expand(gc, pn, x, y, w, h); 1843 pipe_region_expand(gc, pn, x, y, w, h);
1823 PIPE_GROW(gc, pn, 6); 1844 PIPE_GROW(gc, pn, 6);
1824 1845 PUSH_6_VERTICES(pn, x, y, w, h);
1825 PUSH_VERTEX(pn, x , y , 0);
1826 PUSH_VERTEX(pn, x + w, y , 0);
1827 PUSH_VERTEX(pn, x , y + h, 0);
1828
1829 PUSH_VERTEX(pn, x + w, y , 0);
1830 PUSH_VERTEX(pn, x + w, y + h, 0);
1831 PUSH_VERTEX(pn, x , y + h, 0);
1832
1833 PUSH_MASK(pn, mtex, mx, my, mw, mh); 1846 PUSH_MASK(pn, mtex, mx, my, mw, mh);
1834
1835 PUSH_6_COLORS(pn, r, g, b, a); 1847 PUSH_6_COLORS(pn, r, g, b, a);
1836} 1848}
1837 1849
@@ -2089,21 +2101,8 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2089 ty2 = ((double)(offsety) + sy + sh) / (double)pt->h; 2101 ty2 = ((double)(offsety) + sy + sh) / (double)pt->h;
2090 } 2102 }
2091 2103
2092 PUSH_VERTEX(pn, x , y , 0); 2104 PUSH_6_VERTICES(pn, x, y, w, h);
2093 PUSH_VERTEX(pn, x + w, y , 0); 2105 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2094 PUSH_VERTEX(pn, x , y + h, 0);
2095
2096 PUSH_TEXUV(pn, tx1, ty1);
2097 PUSH_TEXUV(pn, tx2, ty1);
2098 PUSH_TEXUV(pn, tx1, ty2);
2099
2100 PUSH_VERTEX(pn, x + w, y , 0);
2101 PUSH_VERTEX(pn, x + w, y + h, 0);
2102 PUSH_VERTEX(pn, x , y + h, 0);
2103
2104 PUSH_TEXUV(pn, tx2, ty1);
2105 PUSH_TEXUV(pn, tx2, ty2);
2106 PUSH_TEXUV(pn, tx1, ty2);
2107 2106
2108 if (sam) 2107 if (sam)
2109 { 2108 {
@@ -2181,24 +2180,9 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
2181 ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h; 2180 ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
2182 } 2181 }
2183 2182
2184 PUSH_VERTEX(pn, x , y , 0); 2183 PUSH_6_VERTICES(pn, x, y, w, h);
2185 PUSH_VERTEX(pn, x + w, y , 0); 2184 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2186 PUSH_VERTEX(pn, x , y + h, 0);
2187
2188 PUSH_TEXUV(pn, tx1, ty1);
2189 PUSH_TEXUV(pn, tx2, ty1);
2190 PUSH_TEXUV(pn, tx1, ty2);
2191
2192 PUSH_VERTEX(pn, x + w, y , 0);
2193 PUSH_VERTEX(pn, x + w, y + h, 0);
2194 PUSH_VERTEX(pn, x , y + h, 0);
2195
2196 PUSH_TEXUV(pn, tx2, ty1);
2197 PUSH_TEXUV(pn, tx2, ty2);
2198 PUSH_TEXUV(pn, tx1, ty2);
2199
2200 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2185 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2201
2202 PUSH_6_COLORS(pn, r, g, b, a); 2186 PUSH_6_COLORS(pn, r, g, b, a);
2203} 2187}
2204 2188
@@ -2269,40 +2253,11 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
2269 t2x2 = ((sx + sw) / 2) / (double)tex->ptu->w; 2253 t2x2 = ((sx + sw) / 2) / (double)tex->ptu->w;
2270 t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h; 2254 t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h;
2271 2255
2272 PUSH_VERTEX(pn, x , y , 0); 2256 PUSH_6_VERTICES(pn, x, y, w, h);
2273 PUSH_VERTEX(pn, x + w, y , 0); 2257 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2274 PUSH_VERTEX(pn, x , y + h, 0); 2258 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2275 2259 PUSH_6_TEXUV3(pn, t2x1, t2y1, t2x2, t2y2);
2276 PUSH_TEXUV(pn, tx1, ty1);
2277 PUSH_TEXUV(pn, tx2, ty1);
2278 PUSH_TEXUV(pn, tx1, ty2);
2279
2280 PUSH_TEXUV2(pn, t2x1, t2y1);
2281 PUSH_TEXUV2(pn, t2x2, t2y1);
2282 PUSH_TEXUV2(pn, t2x1, t2y2);
2283
2284 PUSH_TEXUV3(pn, t2x1, t2y1);
2285 PUSH_TEXUV3(pn, t2x2, t2y1);
2286 PUSH_TEXUV3(pn, t2x1, t2y2);
2287
2288 PUSH_VERTEX(pn, x + w, y , 0);
2289 PUSH_VERTEX(pn, x + w, y + h, 0);
2290 PUSH_VERTEX(pn, x , y + h, 0);
2291
2292 PUSH_TEXUV(pn, tx2, ty1);
2293 PUSH_TEXUV(pn, tx2, ty2);
2294 PUSH_TEXUV(pn, tx1, ty2);
2295
2296 PUSH_TEXUV2(pn, t2x2, t2y1);
2297 PUSH_TEXUV2(pn, t2x2, t2y2);
2298 PUSH_TEXUV2(pn, t2x1, t2y2);
2299
2300 PUSH_TEXUV3(pn, t2x2, t2y1);
2301 PUSH_TEXUV3(pn, t2x2, t2y2);
2302 PUSH_TEXUV3(pn, t2x1, t2y2);
2303
2304 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2260 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2305
2306 PUSH_6_COLORS(pn, r, g, b, a); 2261 PUSH_6_COLORS(pn, r, g, b, a);
2307} 2262}
2308 2263
@@ -2372,32 +2327,10 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
2372 t2x2 = (sx + sw) / (double)tex->ptuv->w; 2327 t2x2 = (sx + sw) / (double)tex->ptuv->w;
2373 t2y2 = (sy + sh) / (double)tex->ptuv->h; 2328 t2y2 = (sy + sh) / (double)tex->ptuv->h;
2374 2329
2375 PUSH_VERTEX(pn, x , y , 0); 2330 PUSH_6_VERTICES(pn, x, y, w, h);
2376 PUSH_VERTEX(pn, x + w, y , 0); 2331 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2377 PUSH_VERTEX(pn, x , y + h, 0); 2332 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2378
2379 PUSH_TEXUV(pn, tx1, ty1);
2380 PUSH_TEXUV(pn, tx2, ty1);
2381 PUSH_TEXUV(pn, tx1, ty2);
2382
2383 PUSH_TEXUV2(pn, t2x1, t2y1);
2384 PUSH_TEXUV2(pn, t2x2, t2y1);
2385 PUSH_TEXUV2(pn, t2x1, t2y2);
2386
2387 PUSH_VERTEX(pn, x + w, y , 0);
2388 PUSH_VERTEX(pn, x + w, y + h, 0);
2389 PUSH_VERTEX(pn, x , y + h, 0);
2390
2391 PUSH_TEXUV(pn, tx2, ty1);
2392 PUSH_TEXUV(pn, tx2, ty2);
2393 PUSH_TEXUV(pn, tx1, ty2);
2394
2395 PUSH_TEXUV2(pn, t2x2, t2y1);
2396 PUSH_TEXUV2(pn, t2x2, t2y2);
2397 PUSH_TEXUV2(pn, t2x1, t2y2);
2398
2399 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2333 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2400
2401 PUSH_6_COLORS(pn, r, g, b, a); 2334 PUSH_6_COLORS(pn, r, g, b, a);
2402} 2335}
2403 2336
@@ -2469,32 +2402,10 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
2469 t2x2 = (sx + sw) / (double)tex->ptuv->w; 2402 t2x2 = (sx + sw) / (double)tex->ptuv->w;
2470 t2y2 = (sy + sh) / (double)tex->ptuv->h; 2403 t2y2 = (sy + sh) / (double)tex->ptuv->h;
2471 2404
2472 PUSH_VERTEX(pn, x , y , 0); 2405 PUSH_6_VERTICES(pn, x, y, w, h);
2473 PUSH_VERTEX(pn, x + w, y , 0); 2406 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2474 PUSH_VERTEX(pn, x , y + h, 0); 2407 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2475
2476 PUSH_TEXUV(pn, tx1, ty1);
2477 PUSH_TEXUV(pn, tx2, ty1);
2478 PUSH_TEXUV(pn, tx1, ty2);
2479
2480 PUSH_TEXUV2(pn, t2x1, t2y1);
2481 PUSH_TEXUV2(pn, t2x2, t2y1);
2482 PUSH_TEXUV2(pn, t2x1, t2y2);
2483
2484 PUSH_VERTEX(pn, x + w, y , 0);
2485 PUSH_VERTEX(pn, x + w, y + h, 0);
2486 PUSH_VERTEX(pn, x , y + h, 0);
2487
2488 PUSH_TEXUV(pn, tx2, ty1);
2489 PUSH_TEXUV(pn, tx2, ty2);
2490 PUSH_TEXUV(pn, tx1, ty2);
2491
2492 PUSH_TEXUV2(pn, t2x2, t2y1);
2493 PUSH_TEXUV2(pn, t2x2, t2y2);
2494 PUSH_TEXUV2(pn, t2x1, t2y2);
2495
2496 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2408 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2497
2498 PUSH_6_COLORS(pn, r, g, b, a); 2409 PUSH_6_COLORS(pn, r, g, b, a);
2499} 2410}
2500 2411
@@ -2573,32 +2484,10 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
2573 t2x2 = (tex->x + sx + sw) / (double)tex->pta->w; 2484 t2x2 = (tex->x + sx + sw) / (double)tex->pta->w;
2574 t2y2 = (tex->y + sy + sh) / (double)tex->pta->h; 2485 t2y2 = (tex->y + sy + sh) / (double)tex->pta->h;
2575 2486
2576 PUSH_VERTEX(pn, x , y , 0); 2487 PUSH_6_VERTICES(pn, x, y, w, h);
2577 PUSH_VERTEX(pn, x + w, y , 0); 2488 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2);
2578 PUSH_VERTEX(pn, x , y + h, 0); 2489 PUSH_6_TEXA(pn, t2x1, t2y1, t2x2, t2y2);
2579
2580 PUSH_TEXUV(pn, tx1, ty1);
2581 PUSH_TEXUV(pn, tx2, ty1);
2582 PUSH_TEXUV(pn, tx1, ty2);
2583
2584 PUSH_TEXA(pn, t2x1, t2y1);
2585 PUSH_TEXA(pn, t2x2, t2y1);
2586 PUSH_TEXA(pn, t2x1, t2y2);
2587
2588 PUSH_VERTEX(pn, x + w, y , 0);
2589 PUSH_VERTEX(pn, x + w, y + h, 0);
2590 PUSH_VERTEX(pn, x , y + h, 0);
2591
2592 PUSH_TEXUV(pn, tx2, ty1);
2593 PUSH_TEXUV(pn, tx2, ty2);
2594 PUSH_TEXUV(pn, tx1, ty2);
2595
2596 PUSH_TEXA(pn, t2x2, t2y1);
2597 PUSH_TEXA(pn, t2x2, t2y2);
2598 PUSH_TEXA(pn, t2x1, t2y2);
2599
2600 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2490 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2601
2602 PUSH_6_COLORS(pn, r, g, b, a); 2491 PUSH_6_COLORS(pn, r, g, b, a);
2603} 2492}
2604 2493