summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorkabeer khan <kabeer.khan@samsung.com>2015-04-22 11:25:38 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-22 15:10:19 +0200
commitce45d443c107ef0da87d407ffc5539e9eba9eef5 (patch)
tree2fd7a6dd2ae04e36d079be670f74b2dd223b7575 /src/modules
parent5e4b523d51c11d073def64e3a2dd268eb3a9ae22 (diff)
evas: fix rotation and flipping of image in gl engine
Summary: fix rotation(90, 180, 270) and flipping(vertical, horizontal, transpose, transverse) of evas image in gl engine backend. @fix T2338 Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewers: cedric, jpeg Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2400 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h5
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c92
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c1
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c169
4 files changed, 234 insertions, 33 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index b81b913..d4ca68d 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -644,8 +644,9 @@ struct _Evas_GL_Image
644 int scale_hint, content_hint; 644 int scale_hint, content_hint;
645 int csize; 645 int csize;
646 646
647 Eina_List *filtered; 647 Eina_List *filtered;
648 Eina_List *targets; 648 Eina_List *targets;
649 Evas_Image_Orient orient;
649 650
650 unsigned char dirty : 1; 651 unsigned char dirty : 1;
651 unsigned char cached : 1; 652 unsigned char cached : 1;
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 9699bdd..b526eab 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -1256,9 +1256,53 @@ 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, x1, y1, x2, y2) do { \ 1259#define PUSH_6_TEXUV(pn, Tex, x1, y1, x2, y2) do { \
1260 PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x1, y2); \ 1260 Evas_GL_Texture *_tex = Tex; \
1261 PUSH_TEXUV(pn, x2, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x1, y2); \ 1261 if (_tex && _tex->im) \
1262 { \
1263 switch (_tex->im->orient) \
1264 { \
1265 case EVAS_IMAGE_ORIENT_NONE: \
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 } \
1262 } while (0) 1306 } while (0)
1263#define PUSH_6_TEXUV2(pn, x1, y1, x2, y2) do { \ 1307#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); \ 1308 PUSH_TEXUV2(pn, x1, y1); PUSH_TEXUV2(pn, x2, y1); PUSH_TEXUV2(pn, x1, y2); \
@@ -1918,6 +1962,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
1918 Evas_GL_Texture_Pool *pt; 1962 Evas_GL_Texture_Pool *pt;
1919 GLfloat tx1, tx2, ty1, ty2; 1963 GLfloat tx1, tx2, ty1, ty2;
1920 GLfloat offsetx, offsety; 1964 GLfloat offsetx, offsety;
1965 double pw, ph;
1921 Eina_Bool blend = EINA_FALSE; 1966 Eina_Bool blend = EINA_FALSE;
1922 Evas_GL_Shader shader = SHADER_IMG; 1967 Evas_GL_Shader shader = SHADER_IMG;
1923 GLuint prog = gc->shared->shader[shader].prog; 1968 GLuint prog = gc->shared->shader[shader].prog;
@@ -1992,23 +2037,36 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
1992 pipe_region_expand(gc, pn, x, y, w, h); 2037 pipe_region_expand(gc, pn, x, y, w, h);
1993 PIPE_GROW(gc, pn, 6); 2038 PIPE_GROW(gc, pn, 6);
1994 2039
2040 pw = pt->w;
2041 ph = pt->h;
2042 if (tex->im &&
2043 (tex->im->orient == EVAS_IMAGE_ORIENT_90 ||
2044 tex->im->orient == EVAS_IMAGE_ORIENT_270 ||
2045 tex->im->orient == EVAS_IMAGE_FLIP_TRANSPOSE ||
2046 tex->im->orient == EVAS_IMAGE_FLIP_TRANSVERSE))
2047 {
2048 // Adjust size for taking rotation into account as im->w and h are already modified.
2049 pw = pt->h;
2050 ph = pt->w;
2051 }
2052
1995 if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert)) 2053 if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert))
1996 { 2054 {
1997 tx1 = ((double)(offsetx) + sx) / (double)pt->w; 2055 tx1 = ((double)(offsetx) + sx) / pw;
1998 ty1 = 1.0 - ((double)(offsety) + sy) / (double)pt->h; 2056 ty1 = 1.0 - ((double)(offsety) + sy) / ph;
1999 tx2 = ((double)(offsetx) + sx + sw) / (double)pt->w; 2057 tx2 = ((double)(offsetx) + sx + sw) / pw;
2000 ty2 = 1.0 - ((double)(offsety) + sy + sh) / (double)pt->h; 2058 ty2 = 1.0 - ((double)(offsety) + sy + sh) / ph;
2001 } 2059 }
2002 else 2060 else
2003 { 2061 {
2004 tx1 = ((double)(offsetx) + sx) / (double)pt->w; 2062 tx1 = ((double)(offsetx) + sx) / pw;
2005 ty1 = ((double)(offsety) + sy) / (double)pt->h; 2063 ty1 = ((double)(offsety) + sy) / ph;
2006 tx2 = ((double)(offsetx) + sx + sw) / (double)pt->w; 2064 tx2 = ((double)(offsetx) + sx + sw) / pw;
2007 ty2 = ((double)(offsety) + sy + sh) / (double)pt->h; 2065 ty2 = ((double)(offsety) + sy + sh) / ph;
2008 } 2066 }
2009 2067
2010 PUSH_6_VERTICES(pn, x, y, w, h); 2068 PUSH_6_VERTICES(pn, x, y, w, h);
2011 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2); 2069 PUSH_6_TEXUV(pn, tex, tx1, ty1, tx2, ty2);
2012 2070
2013 if (sam) 2071 if (sam)
2014 { 2072 {
@@ -2098,7 +2156,7 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
2098 } 2156 }
2099 2157
2100 PUSH_6_VERTICES(pn, x, y, w, h); 2158 PUSH_6_VERTICES(pn, x, y, w, h);
2101 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2); 2159 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2);
2102 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2160 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2103 PUSH_6_COLORS(pn, r, g, b, a); 2161 PUSH_6_COLORS(pn, r, g, b, a);
2104} 2162}
@@ -2174,7 +2232,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
2174 t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h; 2232 t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h;
2175 2233
2176 PUSH_6_VERTICES(pn, x, y, w, h); 2234 PUSH_6_VERTICES(pn, x, y, w, h);
2177 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2); 2235 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2);
2178 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2); 2236 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2179 PUSH_6_TEXUV3(pn, t2x1, t2y1, t2x2, t2y2); 2237 PUSH_6_TEXUV3(pn, t2x1, t2y1, t2x2, t2y2);
2180 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2238 PUSH_MASK(pn, mtex, mx, my, mw, mh);
@@ -2252,7 +2310,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
2252 t2y2 = (sy + sh) / (double)tex->ptuv->h; 2310 t2y2 = (sy + sh) / (double)tex->ptuv->h;
2253 2311
2254 PUSH_6_VERTICES(pn, x, y, w, h); 2312 PUSH_6_VERTICES(pn, x, y, w, h);
2255 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2); 2313 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2);
2256 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2); 2314 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2257 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2315 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2258 if (!nomul) 2316 if (!nomul)
@@ -2332,7 +2390,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
2332 t2y2 = (sy + sh) / (double)tex->ptuv->h; 2390 t2y2 = (sy + sh) / (double)tex->ptuv->h;
2333 2391
2334 PUSH_6_VERTICES(pn, x, y, w, h); 2392 PUSH_6_VERTICES(pn, x, y, w, h);
2335 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2); 2393 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2);
2336 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2); 2394 PUSH_6_TEXUV2(pn, t2x1, t2y1, t2x2, t2y2);
2337 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2395 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2338 if (!nomul) 2396 if (!nomul)
@@ -2416,7 +2474,7 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
2416 t2y2 = (tex->y + sy + sh) / (double)tex->pta->h; 2474 t2y2 = (tex->y + sy + sh) / (double)tex->pta->h;
2417 2475
2418 PUSH_6_VERTICES(pn, x, y, w, h); 2476 PUSH_6_VERTICES(pn, x, y, w, h);
2419 PUSH_6_TEXUV(pn, tx1, ty1, tx2, ty2); 2477 PUSH_6_TEXUV(pn, NULL, tx1, ty1, tx2, ty2);
2420 PUSH_6_TEXA(pn, t2x1, t2y1, t2x2, t2y2); 2478 PUSH_6_TEXA(pn, t2x1, t2y1, t2x2, t2y2);
2421 PUSH_MASK(pn, mtex, mx, my, mw, mh); 2479 PUSH_MASK(pn, mtex, mx, my, mw, mh);
2422 if (!nomul) 2480 if (!nomul)
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c
index 6f62844..331c48e 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -228,6 +228,7 @@ found_cspace:
228 im->gc = gc; 228 im->gc = gc;
229 im->cached = 1; 229 im->cached = 1;
230 im->cs.space = cspace; 230 im->cs.space = cspace;
231 im->orient = EVAS_IMAGE_ORIENT_NONE;
231 im->alpha = im->im->cache_entry.flags.alpha; 232 im->alpha = im->im->cache_entry.flags.alpha;
232 im->w = im->im->cache_entry.w; 233 im->w = im->im->cache_entry.w;
233 im->h = im->im->cache_entry.h; 234 im->h = im->im->cache_entry.h;
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 93521bd..31eaabc 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -43,7 +43,18 @@ static int _evas_engine_GL_log_dom = -1;
43#define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_GL_log_dom, __VA_ARGS__) 43#define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_GL_log_dom, __VA_ARGS__)
44#define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_GL_log_dom, __VA_ARGS__) 44#define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_GL_log_dom, __VA_ARGS__)
45 45
46#ifdef GL_GLES
47# ifndef GL_FRAMEBUFFER
48# define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
49# endif
50#else
51# ifndef GL_FRAMEBUFFER
52# define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
53# endif
54#endif
55
46static int eng_gl_image_direct_get(void *data EINA_UNUSED, void *image); 56static int eng_gl_image_direct_get(void *data EINA_UNUSED, void *image);
57static int eng_gl_surface_destroy(void *data, void *surface);
47 58
48static void 59static void
49eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h, Eina_Bool do_async EINA_UNUSED) 60eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h, Eina_Bool do_async EINA_UNUSED)
@@ -473,14 +484,27 @@ eng_image_free(void *data, void *image)
473static void 484static void
474eng_image_size_get(void *data EINA_UNUSED, void *image, int *w, int *h) 485eng_image_size_get(void *data EINA_UNUSED, void *image, int *w, int *h)
475{ 486{
487 Evas_GL_Image *im;
476 if (!image) 488 if (!image)
477 { 489 {
478 *w = 0; 490 *w = 0;
479 *h = 0; 491 *h = 0;
480 return; 492 return;
481 } 493 }
482 if (w) *w = ((Evas_GL_Image *)image)->w; 494 im = image;
483 if (h) *h = ((Evas_GL_Image *)image)->h; 495 if (im->orient == EVAS_IMAGE_ORIENT_90 ||
496 im->orient == EVAS_IMAGE_ORIENT_270 ||
497 im->orient == EVAS_IMAGE_FLIP_TRANSPOSE ||
498 im->orient == EVAS_IMAGE_FLIP_TRANSVERSE)
499 {
500 if (w) *w = ((Evas_GL_Image *)image)->h;
501 if (h) *h = ((Evas_GL_Image *)image)->w;
502 }
503 else
504 {
505 if (w) *w = ((Evas_GL_Image *)image)->w;
506 if (h) *h = ((Evas_GL_Image *)image)->h;
507 }
484} 508}
485 509
486static void * 510static void *
@@ -548,6 +572,91 @@ eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
548 return image; 572 return image;
549} 573}
550 574
575static Evas_GL_Image *
576_rotate_image_data(void *data, void *img)
577{
578 int alpha;
579 Evas_GL_Image *im1, *im2;
580 Evas_Engine_GL_Context *gl_context;
581 Render_Engine_GL_Generic *re = data;
582 RGBA_Draw_Context *dc;
583 DATA32 *pixels;
584 int w, h;
585
586 re->window_use(re->software.ob);
587 gl_context = re->window_gl_context_get(re->software.ob);
588 im1 = img;
589
590 w = im1->w;
591 h = im1->h;
592 alpha = eng_image_alpha_get(data, img);
593
594 if (im1->orient == EVAS_IMAGE_ORIENT_90 ||
595 im1->orient == EVAS_IMAGE_ORIENT_270 ||
596 im1->orient == EVAS_IMAGE_FLIP_TRANSPOSE ||
597 im1->orient == EVAS_IMAGE_FLIP_TRANSVERSE)
598 {
599 w = im1->h;
600 h = im1->w;
601 }
602
603 im2 = evas_gl_common_image_surface_new(gl_context, w, h, alpha);
604
605 evas_gl_common_context_target_surface_set(gl_context, im2);
606
607 // Create a new and temporary context
608 dc = evas_common_draw_context_new();
609 evas_common_draw_context_set_clip(dc, 0, 0, im2->w, im2->h);
610 gl_context->dc = dc;
611
612 // Image draw handle the rotation magically for us
613 evas_gl_common_image_draw(gl_context, im1,
614 0, 0, w, h,
615 0, 0, im2->w, im2->h,
616 0);
617 // Do not forget to flush everything or you will have nothing in your buffer
618 evas_gl_common_context_flush(gl_context);
619
620 gl_context->dc = NULL;
621 evas_common_draw_context_free(dc);
622
623 glsym_glBindFramebuffer(GL_FRAMEBUFFER, im2->tex->pt->fb);
624 GLERRV("glsym_glBindFramebuffer");
625
626 // Rely on Evas_GL_Image infrastructure to allocate pixels
627 im2->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
628 if (!im2->im) return NULL;
629 im2->im->cache_entry.flags.alpha = !!alpha;
630 evas_gl_common_image_alloc_ensure(im2);
631 pixels = im2->im->image.data;
632
633 if (im2->tex->pt->format == GL_BGRA)
634 {
635 glReadPixels(0, 0, im2->w, im2->h, GL_BGRA,
636 GL_UNSIGNED_BYTE, pixels);
637 }
638 else
639 {
640 DATA32 *ptr = pixels;
641 unsigned int k;
642
643 glReadPixels(0, 0, im2->w, im2->h, GL_RGBA,
644 GL_UNSIGNED_BYTE, pixels);
645 for (k = im2->w * im2->h; k; --k)
646 {
647 const DATA32 v = *ptr;
648 *ptr++ = (v & 0xFF00FF00)
649 | ((v & 0x00FF0000) >> 16)
650 | ((v & 0x000000FF) << 16);
651 }
652 }
653
654 glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
655 GLERRV("glsym_glBindFramebuffer");
656
657 return im2;
658}
659
551static void * 660static void *
552eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err) 661eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
553{ 662{
@@ -555,20 +664,34 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
555 Evas_GL_Image *im; 664 Evas_GL_Image *im;
556 int error; 665 int error;
557 666
667 *image_data = NULL;
668
558 if (!image) 669 if (!image)
559 { 670 {
560 *image_data = NULL;
561 if (err) *err = EVAS_LOAD_ERROR_GENERIC; 671 if (err) *err = EVAS_LOAD_ERROR_GENERIC;
562 return NULL; 672 return NULL;
563 } 673 }
564 im = image; 674 im = image;
565 if (im->native.data) 675 if (im->native.data)
566 { 676 {
567 *image_data = NULL;
568 if (err) *err = EVAS_LOAD_ERROR_NONE; 677 if (err) *err = EVAS_LOAD_ERROR_NONE;
569 return im; 678 return im;
570 } 679 }
571 680
681 if (im->orient != EVAS_IMAGE_ORIENT_NONE)
682 {
683 Evas_GL_Image *im_new = _rotate_image_data(data, image);
684 if (!im_new)
685 {
686 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
687 return im;
688 }
689 evas_gl_common_image_free(im);
690
691 *image_data = im_new->im->image.data;
692 return im_new;
693 }
694
572#ifdef GL_GLES 695#ifdef GL_GLES
573 re->window_use(re->software.ob); 696 re->window_use(re->software.ob);
574 697
@@ -771,6 +894,32 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
771 return im; 894 return im;
772} 895}
773 896
897static void *
898eng_image_orient_set(void *data, void *image, Evas_Image_Orient orient)
899{
900 Render_Engine_GL_Generic *re = data;
901 Evas_GL_Image *im;
902
903 if (!image) return NULL;
904 im = image;
905 if (im->orient == orient) return image;
906
907 re->window_use(re->software.ob);
908
909 im->orient = orient;
910 return im;
911}
912
913static Evas_Image_Orient
914eng_image_orient_get(void *data EINA_UNUSED, void *image)
915{
916 Evas_GL_Image *im;
917
918 if (!image) return EVAS_IMAGE_ORIENT_NONE;
919 im = image;
920 return im->orient;
921}
922
774static void 923static void
775eng_image_data_preload_request(void *data, void *image, const Eo *target) 924eng_image_data_preload_request(void *data, void *image, const Eo *target)
776{ 925{
@@ -1474,16 +1623,6 @@ eng_gl_surface_read_pixels(void *data, void *surface,
1474 return EINA_FALSE; 1623 return EINA_FALSE;
1475 } 1624 }
1476 1625
1477#ifdef GL_GLES
1478# ifndef GL_FRAMEBUFFER
1479# define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
1480# endif
1481#else
1482# ifndef GL_FRAMEBUFFER
1483# define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
1484# endif
1485#endif
1486
1487 /* Since this is an FBO, the pixels are already in the right Y order. 1626 /* Since this is an FBO, the pixels are already in the right Y order.
1488 * But some devices don't support GL_BGRA, so we still need to convert. 1627 * But some devices don't support GL_BGRA, so we still need to convert.
1489 */ 1628 */
@@ -2351,6 +2490,8 @@ module_open(Evas_Module *em)
2351 ORD(image_data_preload_cancel); 2490 ORD(image_data_preload_cancel);
2352 ORD(image_alpha_set); 2491 ORD(image_alpha_set);
2353 ORD(image_alpha_get); 2492 ORD(image_alpha_get);
2493 ORD(image_orient_set);
2494 ORD(image_orient_get);
2354 ORD(image_border_set); 2495 ORD(image_border_set);
2355 ORD(image_border_get); 2496 ORD(image_border_get);
2356 ORD(image_draw); 2497 ORD(image_draw);