1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_engine.h"
4 #include <dlfcn.h> /* dlopen,dlclose,etc */
6 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
8 # if defined(GLES_VARIETY_S3C6410)
9 # elif defined(GLES_VARIETY_SGX)
15 typedef struct _Render_Engine Render_Engine;
19 Evas_GL_X11_Window *win;
20 Evas_Engine_Info_GL_X11 *info;
24 XrmDatabase xrdb; // xres - dpi
25 struct { // xres - dpi
26 int dpi; // xres - dpi
33 static int initted = 0;
34 static int gl_wins = 0;
36 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
38 #ifndef EGL_NATIVE_PIXMAP_KHR
39 # define EGL_NATIVE_PIXMAP_KHR 0x30b0
41 typedef void (*_eng_fn) (void);
43 typedef _eng_fn (*glsym_func_eng_fn) ();
44 typedef void (*glsym_func_void) ();
45 typedef void *(*glsym_func_void_ptr) ();
47 _eng_fn (*glsym_eglGetProcAddress) (const char *a) = NULL;
48 void (*glsym_eglBindTexImage) (EGLDisplay a, EGLSurface b, int c) = NULL;
49 void (*glsym_eglReleaseTexImage) (EGLDisplay a, EGLSurface b, int c) = NULL;
50 void *(*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const int *e) = NULL;
51 void (*glsym_eglDestroyImage) (EGLDisplay a, void *b) = NULL;
52 void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
54 typedef void (*_eng_fn) (void);
56 typedef _eng_fn (*glsym_func_eng_fn) ();
57 typedef void (*glsym_func_void) ();
58 typedef int (*glsym_func_int) ();
59 typedef XID (*glsym_func_xid) ();
61 _eng_fn (*glsym_glXGetProcAddress) (const char *a) = NULL;
62 void (*glsym_glXBindTexImage) (Display *a, GLXDrawable b, int c, int *d) = NULL;
63 void (*glsym_glXReleaseTexImage) (Display *a, GLXDrawable b, int c) = NULL;
64 int (*glsym_glXGetVideoSync) (unsigned int *a) = NULL;
65 int (*glsym_glXWaitVideoSync) (int a, int b, unsigned int *c) = NULL;
66 XID (*glsym_glXCreatePixmap) (Display *a, void *b, Pixmap c, const int *d) = NULL;
67 void (*glsym_glXDestroyPixmap) (Display *a, XID b) = NULL;
68 void (*glsym_glXQueryDrawable) (Display *a, XID b, int c, unsigned int *d) = NULL;
78 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
79 #define FINDSYM(dst, sym, typ) \
80 if ((!dst) && (glsym_eglGetProcAddress)) dst = (typ)glsym_eglGetProcAddress(sym); \
81 if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
83 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
84 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
85 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
86 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressKHR", glsym_func_eng_fn);
88 FINDSYM(glsym_eglBindTexImage, "eglBindTexImage", glsym_func_void);
89 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageEXT", glsym_func_void);
90 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageARB", glsym_func_void);
91 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageKHR", glsym_func_void);
93 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImage", glsym_func_void);
94 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageEXT", glsym_func_void);
95 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageARB", glsym_func_void);
96 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageKHR", glsym_func_void);
98 FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
99 FINDSYM(glsym_eglCreateImage, "eglCreateImageEXT", glsym_func_void_ptr);
100 FINDSYM(glsym_eglCreateImage, "eglCreateImageARB", glsym_func_void_ptr);
101 FINDSYM(glsym_eglCreateImage, "eglCreateImageKHR", glsym_func_void_ptr);
103 FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void);
104 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageEXT", glsym_func_void);
105 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageARB", glsym_func_void);
106 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void);
108 FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
110 #define FINDSYM(dst, sym, typ) \
111 if ((!dst) && (glsym_glXGetProcAddress)) dst = (typ)glsym_glXGetProcAddress(sym); \
112 if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
114 FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddress", glsym_func_eng_fn);
115 FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressEXT", glsym_func_eng_fn);
116 FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressARB", glsym_func_eng_fn);
118 FINDSYM(glsym_glXBindTexImage, "glXBindTexImage", glsym_func_void);
119 FINDSYM(glsym_glXBindTexImage, "glXBindTexImageEXT", glsym_func_void);
120 FINDSYM(glsym_glXBindTexImage, "glXBindTexImageARB", glsym_func_void);
122 FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImage", glsym_func_void);
123 FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageEXT", glsym_func_void);
124 FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageARB", glsym_func_void);
126 FINDSYM(glsym_glXGetVideoSync, "glXGetVideoSyncSGI", glsym_func_int);
128 FINDSYM(glsym_glXWaitVideoSync, "glXWaitVideoSyncSGI", glsym_func_int);
130 FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmap", glsym_func_xid);
131 FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapEXT", glsym_func_xid);
132 FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapARB", glsym_func_xid);
134 FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmap", glsym_func_void);
135 FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapEXT", glsym_func_void);
136 FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapARB", glsym_func_void);
138 FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawable", glsym_func_void);
139 FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableEXT", glsym_func_void);
140 FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableARB", glsym_func_void);
144 int _evas_engine_GL_X11_log_dom = -1;
145 /* function tables - filled in later (func and parent func) */
146 static Evas_Func func, pfunc;
154 static struct xrdb_user xrdb_user = {0, 0, NULL};
157 xrdb_user_query(const char *name, const char *cls, char **type, XrmValue *val)
159 time_t last = xrdb_user.last_stat, now = time(NULL);
161 xrdb_user.last_stat = now;
162 if (last != now) /* don't stat() more than once every second */
165 const char *home = getenv("HOME");
168 if (!home) goto failed;
169 snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", home);
170 if (stat(tmp, &st) != 0) goto failed;
171 if (xrdb_user.last_mtime != st.st_mtime)
173 if (xrdb_user.db) XrmDestroyDatabase(xrdb_user.db);
174 xrdb_user.db = XrmGetFileDatabase(tmp);
175 if (!xrdb_user.db) goto failed;
176 xrdb_user.last_mtime = st.st_mtime;
180 if (!xrdb_user.db) return EINA_FALSE;
181 return XrmGetResource(xrdb_user.db, name, cls, type, val);
186 XrmDestroyDatabase(xrdb_user.db);
189 xrdb_user.last_mtime = 0;
196 Evas_Engine_Info_GL_X11 *info;
198 info = calloc(1, sizeof(Evas_Engine_Info_GL_X11));
199 info->magic.magic = rand();
200 info->func.best_visual_get = eng_best_visual_get;
201 info->func.best_colormap_get = eng_best_colormap_get;
202 info->func.best_depth_get = eng_best_depth_get;
203 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
209 eng_info_free(Evas *e __UNUSED__, void *info)
211 Evas_Engine_Info_GL_X11 *in;
212 // dont free! why bother? its not worth it
213 // eina_log_domain_unregister(_evas_engine_GL_X11_log_dom);
214 in = (Evas_Engine_Info_GL_X11 *)info;
219 _re_wincheck(Render_Engine *re)
221 if (re->win->surf) return 1;
222 eng_window_resurf(re->win);
225 ERR("GL engine can't re-create window surface!");
231 _re_winfree(Render_Engine *re)
233 if (!re->win->surf) return;
234 eng_window_unsurf(re->win);
238 eng_setup(Evas *e, void *in)
241 Evas_Engine_Info_GL_X11 *info;
243 info = (Evas_Engine_Info_GL_X11 *)in;
244 if (!e->engine.data.output)
246 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
250 if (!glXQueryExtension(info->info.display, &eb, &evb)) return 0;
252 re = calloc(1, sizeof(Render_Engine));
256 e->engine.data.output = re;
259 re->win = eng_window_new(re->info->info.display,
260 re->info->info.drawable,
261 re->info->info.screen,
262 re->info->info.visual,
263 re->info->info.colormap,
264 re->info->info.depth,
268 re->info->info.destination_alpha,
269 re->info->info.rotation);
273 e->engine.data.output = NULL;
283 re->xr.dpi = 75000; // dpy * 1000
285 status = xrdb_user_query("Xft.dpi", "Xft.Dpi", &type, &val);
286 if ((!status) || (!type))
288 if (!re->xrdb) re->xrdb = XrmGetDatabase(re->info->info.display);
290 status = XrmGetResource(re->xrdb,
291 "Xft.dpi", "Xft.Dpi", &type, &val);
294 if ((status) && (type))
296 if (!strcmp(type, "String"))
298 const char *str, *dp;
301 dp = strchr(str, '.');
302 if (!dp) dp = strchr(str, ',');
309 buf = alloca(dp - str + 1);
310 strncpy(buf, str, dp - str);
312 len = strlen(dp + 1);
313 subdpi = atoi(dp + 1);
317 for (i = len; i < 3; i++) subdpi *= 10;
321 for (i = len; i > 3; i--) subdpi /= 10;
323 re->xr.dpi = atoi(buf) * 1000;
326 re->xr.dpi = atoi(str) * 1000;
327 evas_common_font_dpi_set(re->xr.dpi / 1000);
334 evas_common_cpu_init();
336 evas_common_blend_init();
337 evas_common_image_init();
338 evas_common_convert_init();
339 evas_common_scale_init();
340 evas_common_rectangle_init();
341 evas_common_polygon_init();
342 evas_common_line_init();
343 evas_common_font_init();
344 evas_common_draw_init();
345 evas_common_tilebuf_init();
351 re = e->engine.data.output;
352 if (_re_wincheck(re))
354 if ((re->info->info.display != re->win->disp) ||
355 (re->info->info.drawable != re->win->win) ||
356 (re->info->info.screen != re->win->screen) ||
357 (re->info->info.visual != re->win->visual) ||
358 (re->info->info.colormap != re->win->colormap) ||
359 (re->info->info.depth != re->win->depth) ||
360 (re->info->info.destination_alpha != re->win->alpha) ||
361 (re->info->info.rotation != re->win->rot))
367 re->win->gl_context->references++;
368 eng_window_free(re->win);
374 re->win = eng_window_new(re->info->info.display,
375 re->info->info.drawable,
376 re->info->info.screen,
377 re->info->info.visual,
378 re->info->info.colormap,
379 re->info->info.depth,
383 re->info->info.destination_alpha,
384 re->info->info.rotation);
385 if (re->win) gl_wins++;
386 if ((re->win) && (inc))
387 re->win->gl_context->references--;
389 else if ((re->win->w != e->output.w) ||
390 (re->win->h != e->output.h))
394 re->win->w = e->output.w;
395 re->win->h = e->output.h;
396 eng_window_use(re->win);
397 evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
407 if (!e->engine.data.output)
411 eng_window_free(re->win);
417 if (!e->engine.data.context)
418 e->engine.data.context =
419 e->engine.func->context_new(e->engine.data.output);
420 eng_window_use(re->win);
425 glClearColor(0.0, 0.0, 0.0, 0.0);
426 glClear(GL_COLOR_BUFFER_BIT);
435 eng_output_free(void *data)
439 re = (Render_Engine *)data;
443 // NOTE: XrmGetDatabase() result is shared per connection, do not free it.
444 // if (re->xrdb) XrmDestroyDatabase(re->xrdb);
448 eng_window_free(re->win);
453 if ((initted == 1) && (gl_wins == 0))
455 evas_common_image_shutdown();
456 evas_common_font_shutdown();
462 eng_output_resize(void *data, int w, int h)
466 re = (Render_Engine *)data;
469 eng_window_use(re->win);
470 evas_gl_common_context_resize(re->win->gl_context, w, h, re->win->rot);
474 eng_output_tile_size_set(void *data __UNUSED__, int w __UNUSED__, int h __UNUSED__)
479 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
483 re = (Render_Engine *)data;
484 evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
485 /* smple bounding box */
486 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, re->win->w, re->win->h);
487 if ((w <= 0) || (h <= 0)) return;
488 if (!re->win->draw.redraw)
491 re->win->draw.x1 = x;
492 re->win->draw.y1 = y;
493 re->win->draw.x2 = x + w - 1;
494 re->win->draw.y2 = y + h - 1;
496 re->win->draw.x1 = 0;
497 re->win->draw.y1 = 0;
498 re->win->draw.x2 = re->win->w - 1;
499 re->win->draw.y2 = re->win->h - 1;
504 if (x < re->win->draw.x1) re->win->draw.x1 = x;
505 if (y < re->win->draw.y1) re->win->draw.y1 = y;
506 if ((x + w - 1) > re->win->draw.x2) re->win->draw.x2 = x + w - 1;
507 if ((y + h - 1) > re->win->draw.y2) re->win->draw.y2 = y + h - 1;
509 re->win->draw.redraw = 1;
513 eng_output_redraws_rect_del(void *data __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
518 eng_output_redraws_clear(void *data)
522 re = (Render_Engine *)data;
523 re->win->draw.redraw = 0;
524 // INF("GL: finish update cycle!");
527 /* vsync games - not for now though */
528 #define VSYNC_TO_SCREEN 1
531 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
535 re = (Render_Engine *)data;
536 /* get the upate rect surface - return engine data as dummy */
537 if (!re->win->draw.redraw) return NULL;
538 if (!_re_wincheck(re)) return NULL;
539 evas_gl_common_context_flush(re->win->gl_context);
540 eng_window_use(re->win);
541 evas_gl_common_context_newframe(re->win->gl_context);
542 if (x) *x = re->win->draw.x1;
543 if (y) *y = re->win->draw.y1;
544 if (w) *w = re->win->draw.x2 - re->win->draw.x1 + 1;
545 if (h) *h = re->win->draw.y2 - re->win->draw.y1 + 1;
546 if (cx) *cx = re->win->draw.x1;
547 if (cy) *cy = re->win->draw.y1;
548 if (cw) *cw = re->win->draw.x2 - re->win->draw.x1 + 1;
549 if (ch) *ch = re->win->draw.y2 - re->win->draw.y1 + 1;
550 return re->win->gl_context->def_surface;
553 //#define FRAMECOUNT 1
559 struct timeval timev;
561 gettimeofday(&timev, NULL);
562 return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
566 static int safe_native = -1;
569 eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
573 static double pt = 0.0;
577 re = (Render_Engine *)data;
578 /* put back update surface.. in this case just unflag redraw */
579 if (!_re_wincheck(re)) return;
580 re->win->draw.redraw = 0;
581 re->win->draw.drew = 1;
582 evas_gl_common_context_flush(re->win->gl_context);
583 if (safe_native == -1)
585 const char *s = getenv("EVAS_GL_SAFE_NATIVE");
587 if (s) safe_native = atoi(s);
590 s = (const char *)glGetString(GL_RENDERER);
593 if (strstr(s, "PowerVR SGX 540"))
598 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
599 // this is needed to make sure all previous rendering is flushed to
602 double t0 = get_time();
606 // previous rendering should be done and swapped
607 if (!safe_native) eglWaitNative(EGL_CORE_NATIVE_ENGINE);
609 double t1 = get_time();
611 printf("... %1.5f -> %1.5f | ", ta, tb);
613 // if (eglGetError() != EGL_SUCCESS)
615 // printf("Error: eglWaitNative(EGL_CORE_NATIVE_ENGINE) fail.\n");
618 // previous rendering should be done and swapped
619 if (!safe_native) glXWaitX();
621 //x// printf("frame -> push\n");
625 eng_output_flush(void *data)
629 re = (Render_Engine *)data;
630 if (!_re_wincheck(re)) return;
631 if (!re->win->draw.drew) return;
632 //x// printf("frame -> flush\n");
633 re->win->draw.drew = 0;
634 eng_window_use(re->win);
636 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
638 double t0 = get_time();
642 if (re->info->vsync) eglSwapInterval(re->win->egl_disp, 1);
643 else eglSwapInterval(re->win->egl_disp, 0);
646 eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
647 if (!safe_native) eglWaitGL();
649 double t1 = get_time();
650 printf("%1.5f\n", t1 - t0);
652 // if (eglGetError() != EGL_SUCCESS)
654 // printf("Error: eglSwapBuffers() fail.\n");
657 #ifdef VSYNC_TO_SCREEN
658 if ((re->info->vsync)/* || (1)*/)
660 if ((glsym_glXGetVideoSync) && (glsym_glXWaitVideoSync))
664 glsym_glXGetVideoSync(&rc);
665 glsym_glXWaitVideoSync(1, 0, &rc);
669 if (re->info->callback.pre_swap)
671 re->info->callback.pre_swap(re->info->callback.data, re->evas);
675 // (re->win->draw.x1 == 0) &&
676 // (re->win->draw.y1 == 0) &&
677 // (re->win->draw.x2 == (re->win->w - 1)) &&
678 // (re->win->draw.y2 == (re->win->h - 1))
682 glXSwapBuffers(re->win->disp, re->win->win);
683 if (!safe_native) glXWaitGL();
688 // FIXME: this doesn't work.. why oh why?
691 // fimxe - reset when done
692 // glEnable(GL_SCISSOR_TEST);
693 glDrawBuffer(GL_FRONT);
695 sx = re->win->draw.x1;
696 sy = re->win->draw.y1;
697 sw = (re->win->draw.x2 - re->win->draw.x1) + 1;
698 sh = (re->win->draw.y2 - re->win->draw.y1) + 1;
699 sy = re->win->h - sy - sh;
701 // glScissor(sx, sy, sw, sh);
702 glRasterPos2i(sx, re->win->h - sy);
703 glCopyPixels(sx, sy, sw, sh, GL_COLOR);
706 // glDisable(GL_SCISSOR_TEST);
707 glDrawBuffer(GL_BACK);
711 if (re->info->callback.post_swap)
713 re->info->callback.post_swap(re->info->callback.data, re->evas);
719 glClearColor(0.0, 0.0, 0.0, 0.0);
720 glClear(GL_COLOR_BUFFER_BIT);
725 eng_output_idle_flush(void *data)
729 re = (Render_Engine *)data;
733 eng_output_dump(void *data)
737 re = (Render_Engine *)data;
738 evas_common_image_image_all_unload();
739 evas_common_font_font_all_unload();
740 evas_gl_common_image_all_unload(re->win->gl_context);
745 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
747 // Render_Engine *re;
749 // re = (Render_Engine *)data;
750 // re->win->gl_context->dc = context;
751 evas_common_draw_context_add_cutout(context, x, y, w, h);
755 eng_context_cutout_clear(void *data __UNUSED__, void *context)
757 // Render_Engine *re;
759 // re = (Render_Engine *)data;
760 // re->win->gl_context->dc = context;
761 evas_common_draw_context_clear_cutouts(context);
765 eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
769 re = (Render_Engine *)data;
770 eng_window_use(re->win);
771 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
772 re->win->gl_context->dc = context;
773 evas_gl_common_rect_draw(re->win->gl_context, x, y, w, h);
777 eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
781 re = (Render_Engine *)data;
782 eng_window_use(re->win);
783 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
784 re->win->gl_context->dc = context;
785 evas_gl_common_line_draw(re->win->gl_context, x1, y1, x2, y2);
789 eng_polygon_point_add(void *data, void *context __UNUSED__, void *polygon, int x, int y)
793 re = (Render_Engine *)data;
794 return evas_gl_common_poly_point_add(polygon, x, y);
798 eng_polygon_points_clear(void *data, void *context __UNUSED__, void *polygon)
802 re = (Render_Engine *)data;
803 return evas_gl_common_poly_points_clear(polygon);
807 eng_polygon_draw(void *data, void *context, void *surface __UNUSED__, void *polygon, int x, int y)
811 re = (Render_Engine *)data;
812 eng_window_use(re->win);
813 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
814 re->win->gl_context->dc = context;
815 evas_gl_common_poly_draw(re->win->gl_context, polygon, x, y);
819 eng_image_alpha_get(void *data __UNUSED__, void *image)
821 // Render_Engine *re;
824 // re = (Render_Engine *)data;
825 if (!image) return 1;
831 eng_image_colorspace_get(void *data __UNUSED__, void *image)
833 // Render_Engine *re;
836 // re = (Render_Engine *)data;
837 if (!image) return EVAS_COLORSPACE_ARGB8888;
843 eng_image_mask_create(void *data __UNUSED__, void *image)
849 if (!im->im->image.data)
850 evas_cache_image_load_data(&im->im->cache_entry);
852 im->tex = evas_gl_common_texture_new(im->gc, im->im);
857 eng_image_alpha_set(void *data, void *image, int has_alpha)
862 re = (Render_Engine *)data;
863 if (!image) return NULL;
865 if (im->alpha == has_alpha) return image;
868 im->alpha = has_alpha;
871 eng_window_use(re->win);
872 if ((im->tex) && (im->tex->pt->dyn.img))
874 im->alpha = has_alpha;
875 im->tex->alpha = im->alpha;
878 /* FIXME: can move to gl_common */
879 if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
880 if ((has_alpha) && (im->im->cache_entry.flags.alpha)) return image;
881 else if ((!has_alpha) && (!im->im->cache_entry.flags.alpha)) return image;
882 if (im->references > 1)
884 Evas_GL_Image *im_new;
886 im_new = evas_gl_common_image_new_from_copied_data
887 (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
889 eng_image_alpha_get(data, image),
890 eng_image_colorspace_get(data, image));
891 if (!im_new) return im;
892 evas_gl_common_image_free(im);
896 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
897 return evas_gl_common_image_alpha_set(im, has_alpha ? 1 : 0);
898 // im->im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
903 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
905 // Render_Engine *re;
907 // re = (Render_Engine *)data;
912 eng_image_border_get(void *data __UNUSED__, void *image __UNUSED__, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
914 // Render_Engine *re;
916 // re = (Render_Engine *)data;
920 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
922 // Render_Engine *re;
925 // re = (Render_Engine *)data;
926 if (!image) return NULL;
928 if (!im->im) return NULL;
929 return im->im->info.comment;
933 eng_image_format_get(void *data __UNUSED__, void *image)
935 // Render_Engine *re;
938 // re = (Render_Engine *)data;
944 eng_image_colorspace_set(void *data, void *image, int cspace)
949 re = (Render_Engine *)data;
952 if (im->native.data) return;
953 /* FIXME: can move to gl_common */
954 if (im->cs.space == cspace) return;
955 eng_window_use(re->win);
956 evas_cache_image_colorspace(&im->im->cache_entry, cspace);
959 case EVAS_COLORSPACE_ARGB8888:
962 if (!im->cs.no_free) free(im->cs.data);
967 case EVAS_COLORSPACE_YCBCR422P601_PL:
968 case EVAS_COLORSPACE_YCBCR422P709_PL:
969 if (im->tex) evas_gl_common_texture_free(im->tex);
973 if (!im->cs.no_free) free(im->cs.data);
975 if (im->im->cache_entry.h > 0)
977 calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
986 im->cs.space = cspace;
989 /////////////////////////////////////////////////////////////////////////
992 typedef struct _Native Native;
996 Evas_Native_Surface ns;
1000 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1008 // FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW
1009 // (i am sure this is the reason) not to mention seemingly superfluous. but
1010 // i need to enable it for it to work on fglrx at least. havent tried nvidia.
1012 // why is this the case? does anyone know? has anyone tried it on other gfx
1015 //#define GLX_TEX_PIXMAP_RECREATE 1
1018 _native_bind_cb(void *data, void *image)
1020 Evas_GL_Image *im = image;
1021 Native *n = im->native.data;
1023 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1026 if (glsym_glEGLImageTargetTexture2DOES)
1028 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface);
1029 if (eglGetError() != EGL_SUCCESS)
1030 ERR("glEGLImageTargetTexture2DOES() failed.");
1033 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
1036 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1037 Render_Engine *re = data;
1039 if (glsym_glXBindTexImage)
1041 glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
1042 GLX_FRONT_LEFT_EXT, NULL);
1043 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1046 ERR("Try glXBindTexImage on GLX with no support");
1052 _native_unbind_cb(void *data, void *image)
1054 Evas_GL_Image *im = image;
1056 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1059 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1060 Render_Engine *re = data;
1061 Native *n = im->native.data;
1063 if (glsym_glXReleaseTexImage)
1065 glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
1066 GLX_FRONT_LEFT_EXT);
1067 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1070 ERR("Try glXReleaseTexImage on GLX with no support");
1076 _native_free_cb(void *data, void *image)
1078 Render_Engine *re = data;
1079 Evas_GL_Image *im = image;
1080 Native *n = im->native.data;
1084 eina_hash_del(re->win->gl_context->shared->native_hash, &pmid, im);
1085 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1088 if (glsym_eglDestroyImage)
1090 glsym_eglDestroyImage(re->win->egl_disp,
1092 if (eglGetError() != EGL_SUCCESS)
1093 ERR("eglDestroyImage() failed.");
1096 ERR("Try eglDestroyImage on EGL with no support");
1099 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1102 if (im->native.loose)
1104 if (glsym_glXReleaseTexImage)
1106 glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
1107 GLX_FRONT_LEFT_EXT);
1108 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1111 ERR("Try glXReleaseTexImage on GLX with no support");
1113 if (glsym_glXDestroyPixmap)
1115 glsym_glXDestroyPixmap(re->win->disp, n->glx_pixmap);
1116 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1119 ERR("Try glXDestroyPixmap on GLX with no support");
1124 im->native.data = NULL;
1125 im->native.func.data = NULL;
1126 im->native.func.bind = NULL;
1127 im->native.func.unbind = NULL;
1128 im->native.func.free = NULL;
1133 eng_image_native_set(void *data, void *image, void *native)
1135 Render_Engine *re = (Render_Engine *)data;
1136 Evas_Native_Surface *ns = native;
1137 Evas_GL_Image *im = image, *im2 = NULL;
1143 if (!im) return NULL;
1147 vis = ns->data.x11.visual;
1148 pm = ns->data.x11.pixmap;
1149 if (im->native.data)
1151 Evas_Native_Surface *ens = im->native.data;
1152 if ((ens->data.x11.visual == vis) && (ens->data.x11.pixmap == pm))
1156 if ((!ns) && (!im->native.data)) return im;
1158 eng_window_use(re->win);
1160 if (im->native.data)
1162 if (im->native.func.free)
1163 im->native.func.free(im->native.func.data, im);
1164 evas_gl_common_image_native_disable(im);
1168 im2 = eina_hash_find(re->win->gl_context->shared->native_hash, &pmid);
1169 if (im2 == im) return im;
1172 n = im2->native.data;
1176 evas_gl_common_image_free(im);
1180 im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
1181 im->w, im->h, NULL, im->alpha,
1182 EVAS_COLORSPACE_ARGB8888);
1183 evas_gl_common_image_free(im);
1185 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1188 n = calloc(1, sizeof(Native));
1191 EGLConfig egl_config;
1192 int config_attrs[20];
1193 int num_config, i = 0;
1195 eina_hash_add(re->win->gl_context->shared->native_hash, &pmid, im);
1197 config_attrs[i++] = EGL_RED_SIZE;
1198 config_attrs[i++] = 8;
1199 config_attrs[i++] = EGL_GREEN_SIZE;
1200 config_attrs[i++] = 8;
1201 config_attrs[i++] = EGL_BLUE_SIZE;
1202 config_attrs[i++] = 8;
1203 config_attrs[i++] = EGL_ALPHA_SIZE;
1204 config_attrs[i++] = 8;
1205 config_attrs[i++] = EGL_DEPTH_SIZE;
1206 config_attrs[i++] = 0;
1207 config_attrs[i++] = EGL_STENCIL_SIZE;
1208 config_attrs[i++] = 0;
1209 config_attrs[i++] = EGL_RENDERABLE_TYPE;
1210 config_attrs[i++] = EGL_OPENGL_ES2_BIT;
1211 config_attrs[i++] = EGL_SURFACE_TYPE;
1212 config_attrs[i++] = EGL_PIXMAP_BIT;
1213 config_attrs[i++] = EGL_NONE;
1215 if (!eglChooseConfig(re->win->egl_disp, config_attrs,
1216 &egl_config, 1, &num_config))
1217 ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config);
1220 if (glsym_eglCreateImage)
1221 n->egl_surface = glsym_eglCreateImage(re->win->egl_disp,
1223 EGL_NATIVE_PIXMAP_KHR,
1227 ERR("Try eglCreateImage on EGL with no support");
1228 if (!n->egl_surface)
1229 ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm);
1230 im->native.yinvert = 1;
1231 im->native.loose = 0;
1232 im->native.data = n;
1233 im->native.func.data = re;
1234 im->native.func.bind = _native_bind_cb;
1235 im->native.func.unbind = _native_unbind_cb;
1236 im->native.func.free = _native_free_cb;
1237 im->native.target = GL_TEXTURE_2D;
1238 im->native.mipmap = 0;
1239 evas_gl_common_image_native_enable(im);
1243 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1247 unsigned int w, h, depth = 32, border;
1250 // fixme: round trip :(
1251 XGetGeometry(re->win->disp, pm, &wdummy, &dummy, &dummy,
1252 &w, &h, &border, &depth);
1253 n = calloc(1, sizeof(Native));
1257 unsigned int target = 0;
1260 eina_hash_add(re->win->gl_context->shared->native_hash, &pmid, im);
1261 if ((re->win->depth_cfg[depth].tex_target &
1262 GLX_TEXTURE_2D_BIT_EXT)
1263 // && (1) // we assume npo2 for now
1264 // size is pow2 || mnpo2 supported
1266 target = GLX_TEXTURE_2D_EXT;
1267 else if ((re->win->depth_cfg[depth].tex_target &
1268 GLX_TEXTURE_RECTANGLE_BIT_EXT))
1270 ERR("rect!!! (not handled)");
1271 target = GLX_TEXTURE_RECTANGLE_EXT;
1275 ERR("broken text-from-pixmap");
1276 if (!(re->win->depth_cfg[depth].tex_target &
1277 GLX_TEXTURE_2D_BIT_EXT))
1278 target = GLX_TEXTURE_RECTANGLE_EXT;
1279 else if (!(re->win->depth_cfg[depth].tex_target &
1280 GLX_TEXTURE_RECTANGLE_BIT_EXT))
1281 target = GLX_TEXTURE_2D_EXT;
1285 pixmap_att[i++] = GLX_TEXTURE_FORMAT_EXT;
1286 pixmap_att[i++] = re->win->depth_cfg[depth].tex_format;
1287 pixmap_att[i++] = GLX_MIPMAP_TEXTURE_EXT;
1288 pixmap_att[i++] = re->win->depth_cfg[depth].mipmap;
1292 pixmap_att[i++] = GLX_TEXTURE_TARGET_EXT;
1293 pixmap_att[i++] = target;
1296 pixmap_att[i++] = 0;
1298 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
1301 n->fbc = re->win->depth_cfg[depth].fbc;
1302 if (glsym_glXCreatePixmap)
1303 n->glx_pixmap = glsym_glXCreatePixmap(re->win->disp,
1308 ERR("Try glXCreatePixmap on GLX with no support");
1311 // printf("%p: new native texture for %x | %4i x %4i @ %2i = %p\n",
1312 // n, pm, w, h, depth, n->glx_pixmap);
1315 ERR("no target :(");
1316 if (glsym_glXQueryDrawable)
1317 glsym_glXQueryDrawable(re->win->disp,
1319 GLX_TEXTURE_TARGET_EXT,
1322 if (target == GLX_TEXTURE_2D_EXT)
1324 im->native.target = GL_TEXTURE_2D;
1325 im->native.mipmap = re->win->depth_cfg[depth].mipmap;
1327 # ifdef GL_TEXTURE_RECTANGLE_ARB
1328 else if (target == GLX_TEXTURE_RECTANGLE_EXT)
1330 im->native.target = GL_TEXTURE_RECTANGLE_ARB;
1331 im->native.mipmap = 0;
1336 im->native.target = GL_TEXTURE_2D;
1337 im->native.mipmap = 0;
1338 ERR("still unknown target");
1342 ERR("GLX Pixmap create fail");
1343 im->native.yinvert = re->win->depth_cfg[depth].yinvert;
1344 im->native.loose = re->win->detected.loose_binding;
1345 im->native.data = n;
1346 im->native.func.data = re;
1347 im->native.func.bind = _native_bind_cb;
1348 im->native.func.unbind = _native_unbind_cb;
1349 im->native.func.free = _native_free_cb;
1351 evas_gl_common_image_native_enable(im);
1360 eng_image_native_get(void *data __UNUSED__, void *image)
1362 Evas_GL_Image *im = image;
1364 if (!im) return NULL;
1365 n = im->native.data;
1366 if (!n) return NULL;
1372 /////////////////////////////////////////////////////////////////////////
1375 eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
1379 re = (Render_Engine *)data;
1380 *error = EVAS_LOAD_ERROR_NONE;
1381 eng_window_use(re->win);
1382 return evas_gl_common_image_load(re->win->gl_context, file, key, lo, error);
1386 eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
1390 re = (Render_Engine *)data;
1391 eng_window_use(re->win);
1392 return evas_gl_common_image_new_from_data(re->win->gl_context, w, h, image_data, alpha, cspace);
1396 eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
1400 re = (Render_Engine *)data;
1401 eng_window_use(re->win);
1402 return evas_gl_common_image_new_from_copied_data(re->win->gl_context, w, h, image_data, alpha, cspace);
1406 eng_image_free(void *data, void *image)
1410 re = (Render_Engine *)data;
1412 eng_window_use(re->win);
1413 evas_gl_common_image_free(image);
1417 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
1425 if (w) *w = ((Evas_GL_Image *)image)->w;
1426 if (h) *h = ((Evas_GL_Image *)image)->h;
1430 eng_image_size_set(void *data, void *image, int w, int h)
1433 Evas_GL_Image *im = image;
1434 Evas_GL_Image *im_old;
1436 re = (Render_Engine *)data;
1437 if (!im) return NULL;
1438 if (im->native.data)
1444 eng_window_use(re->win);
1445 if ((im->tex) && (im->tex->pt->dyn.img))
1447 evas_gl_common_texture_free(im->tex);
1451 im->tex = evas_gl_common_texture_dynamic_new(im->gc, im);
1455 if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
1456 (eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
1459 ((int)im_old->im->cache_entry.w == w) &&
1460 ((int)im_old->im->cache_entry.h == h))
1464 im = evas_gl_common_image_new(re->win->gl_context, w, h,
1465 eng_image_alpha_get(data, image),
1466 eng_image_colorspace_get(data, image));
1468 evas_common_load_image_data_from_file(im_old->im);
1469 if (im_old->im->image->data)
1471 evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
1472 evas_common_cpu_end_opt();
1475 evas_gl_common_image_free(im_old);
1478 im = evas_gl_common_image_new(re->win->gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888);
1483 eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
1486 Evas_GL_Image *im = image;
1488 re = (Render_Engine *)data;
1489 if (!image) return NULL;
1490 if (im->native.data) return image;
1491 eng_window_use(re->win);
1492 evas_gl_common_image_dirty(image, x, y, w, h);
1497 eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
1502 re = (Render_Engine *)data;
1509 if (im->native.data)
1514 if ((im->tex) && (im->tex->pt) && (im->tex->pt->dyn.data))
1516 *image_data = im->tex->pt->dyn.data;
1519 eng_window_use(re->win);
1520 evas_cache_image_load_data(&im->im->cache_entry);
1521 switch (im->cs.space)
1523 case EVAS_COLORSPACE_ARGB8888:
1526 if (im->references > 1)
1528 Evas_GL_Image *im_new;
1530 im_new = evas_gl_common_image_new_from_copied_data
1531 (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
1533 eng_image_alpha_get(data, image),
1534 eng_image_colorspace_get(data, image));
1540 evas_gl_common_image_free(im);
1544 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1546 *image_data = im->im->image.data;
1548 case EVAS_COLORSPACE_YCBCR422P601_PL:
1549 case EVAS_COLORSPACE_YCBCR422P709_PL:
1550 *image_data = im->cs.data;
1560 eng_image_data_put(void *data, void *image, DATA32 *image_data)
1563 Evas_GL_Image *im, *im2;
1565 re = (Render_Engine *)data;
1566 if (!image) return NULL;
1568 if (im->native.data) return image;
1569 eng_window_use(re->win);
1570 if ((im->tex) && (im->tex->pt) && (im->tex->pt->dyn.data))
1572 if (im->tex->pt->dyn.data == image_data)
1580 w = im->im->cache_entry.w;
1581 h = im->im->cache_entry.h;
1582 im2 = eng_image_new_from_data(data, w, h, image_data,
1583 eng_image_alpha_get(data, image),
1584 eng_image_colorspace_get(data, image));
1585 if (!im2) return im;
1586 evas_gl_common_image_free(im);
1588 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1592 switch (im->cs.space)
1594 case EVAS_COLORSPACE_ARGB8888:
1595 if (image_data != im->im->image.data)
1599 w = im->im->cache_entry.w;
1600 h = im->im->cache_entry.h;
1601 im2 = eng_image_new_from_data(data, w, h, image_data,
1602 eng_image_alpha_get(data, image),
1603 eng_image_colorspace_get(data, image));
1604 if (!im2) return im;
1605 evas_gl_common_image_free(im);
1609 case EVAS_COLORSPACE_YCBCR422P601_PL:
1610 case EVAS_COLORSPACE_YCBCR422P709_PL:
1611 if (image_data != im->cs.data)
1615 if (!im->cs.no_free) free(im->cs.data);
1617 im->cs.data = image_data;
1624 /* hmmm - but if we wrote... why bother? */
1625 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1630 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
1632 Evas_GL_Image *gim = image;
1636 if (gim->native.data) return;
1637 im = (RGBA_Image *)gim->im;
1639 evas_cache_image_preload_data(&im->cache_entry, target);
1643 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
1645 Evas_GL_Image *gim = image;
1649 if (gim->native.data) return;
1650 im = (RGBA_Image *)gim->im;
1652 evas_cache_image_preload_cancel(&im->cache_entry, target);
1656 eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
1660 re = (Render_Engine *)data;
1662 eng_window_use(re->win);
1663 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1664 re->win->gl_context->dc = context;
1665 evas_gl_common_image_draw(re->win->gl_context, image,
1666 src_x, src_y, src_w, src_h,
1667 dst_x, dst_y, dst_w, dst_h,
1672 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
1674 if (image) evas_gl_common_image_scale_hint_set(image, hint);
1678 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
1680 Evas_GL_Image *gim = image;
1681 if (!gim) return EVAS_IMAGE_SCALE_HINT_NONE;
1682 return gim->scale_hint;
1686 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
1688 Evas_GL_Image *gim = image;
1691 re = (Render_Engine *)data;
1693 eng_window_use(re->win);
1694 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1695 re->win->gl_context->dc = context;
1696 if ((p[0].x == p[3].x) &&
1697 (p[1].x == p[2].x) &&
1698 (p[0].y == p[1].y) &&
1699 (p[3].y == p[2].y) &&
1700 (p[0].x <= p[1].x) &&
1701 (p[0].y <= p[2].y) &&
1704 (p[1].u == (gim->w << FP)) &&
1706 (p[2].u == (gim->w << FP)) &&
1707 (p[2].v == (gim->h << FP)) &&
1709 (p[3].v == (gim->h << FP)) &&
1710 (p[0].col == 0xffffffff) &&
1711 (p[1].col == 0xffffffff) &&
1712 (p[2].col == 0xffffffff) &&
1713 (p[3].col == 0xffffffff))
1719 dw = (p[2].x >> FP) - dx;
1720 dh = (p[2].y >> FP) - dy;
1722 (data, context, surface, image,
1723 0, 0, gim->w, gim->h,
1724 dx, dy, dw, dh, smooth);
1728 evas_gl_common_image_map4_draw(re->win->gl_context, image, p,
1734 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
1738 re = (Render_Engine *)data;
1739 return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha);
1743 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
1745 evas_gl_common_image_free(surface);
1749 eng_image_content_hint_set(void *data __UNUSED__, void *image, int hint)
1751 if (image) evas_gl_common_image_content_hint_set(image, hint);
1755 eng_image_content_hint_get(void *data __UNUSED__, void *image)
1757 Evas_GL_Image *gim = image;
1758 if (!gim) return EVAS_IMAGE_CONTENT_HINT_NONE;
1759 return gim->content_hint;
1763 eng_image_stride_get(void *data __UNUSED__, void *image, int *stride)
1765 Evas_GL_Image *im = image;
1766 *stride = im->w * 4;
1767 if ((im->tex) && (im->tex->pt->dyn.img))
1769 *stride = im->tex->pt->dyn.w * 4;
1770 // FIXME: for other image formats (yuv etc.) different stride needed
1775 eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props)
1779 re = (Render_Engine *)data;
1780 eng_window_use(re->win);
1781 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1782 re->win->gl_context->dc = context;
1784 // FIXME: put im into context so we can free it
1785 static RGBA_Image *im = NULL;
1788 im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
1789 im->cache_entry.w = re->win->w;
1790 im->cache_entry.h = re->win->h;
1791 evas_common_draw_context_font_ext_set(context,
1792 re->win->gl_context,
1793 evas_gl_font_texture_new,
1794 evas_gl_font_texture_free,
1795 evas_gl_font_texture_draw);
1796 evas_common_font_draw(im, context, font, x, y, text, intl_props);
1797 evas_common_draw_context_font_ext_set(context,
1806 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
1808 // FIXME: support ARGB gl targets!!!
1813 module_open(Evas_Module *em)
1815 static Eina_Bool xrm_inited = EINA_FALSE;
1818 xrm_inited = EINA_TRUE;
1823 if (!evas_gl_common_module_open()) return 0;
1824 /* get whatever engine module we inherit from */
1825 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
1826 if (_evas_engine_GL_X11_log_dom < 0)
1827 _evas_engine_GL_X11_log_dom = eina_log_domain_register
1828 ("evas-gl_x11", EVAS_DEFAULT_LOG_COLOR);
1829 if (_evas_engine_GL_X11_log_dom < 0)
1831 EINA_LOG_ERR("Can not create a module log domain.");
1834 /* store it for later use */
1836 /* now to override methods */
1837 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
1841 ORD(canvas_alpha_get);
1844 ORD(output_tile_size_set);
1845 ORD(output_redraws_rect_add);
1846 ORD(output_redraws_rect_del);
1847 ORD(output_redraws_clear);
1848 ORD(output_redraws_next_update_get);
1849 ORD(output_redraws_next_update_push);
1850 ORD(context_cutout_add);
1851 ORD(context_cutout_clear);
1853 ORD(output_idle_flush);
1855 ORD(rectangle_draw);
1857 ORD(polygon_point_add);
1858 ORD(polygon_points_clear);
1862 ORD(image_new_from_data);
1863 ORD(image_new_from_copied_data);
1865 ORD(image_size_get);
1866 ORD(image_size_set);
1867 ORD(image_dirty_region);
1868 ORD(image_data_get);
1869 ORD(image_data_put);
1870 ORD(image_data_preload_request);
1871 ORD(image_data_preload_cancel);
1872 ORD(image_alpha_set);
1873 ORD(image_alpha_get);
1874 ORD(image_border_set);
1875 ORD(image_border_get);
1877 ORD(image_comment_get);
1878 ORD(image_format_get);
1879 ORD(image_colorspace_set);
1880 ORD(image_colorspace_get);
1881 ORD(image_mask_create);
1882 ORD(image_native_set);
1883 ORD(image_native_get);
1887 ORD(image_scale_hint_set);
1888 ORD(image_scale_hint_get);
1889 ORD(image_stride_get);
1891 ORD(image_map_draw);
1892 ORD(image_map_surface_new);
1893 ORD(image_map_surface_free);
1895 ORD(image_content_hint_set);
1896 ORD(image_content_hint_get);
1898 /* now advertise out own api */
1899 em->functions = (void *)(&func);
1904 module_close(Evas_Module *em __UNUSED__)
1906 eina_log_domain_unregister(_evas_engine_GL_X11_log_dom);
1909 XrmDestroyDatabase(xrdb_user.db);
1910 xrdb_user.last_stat = 0;
1911 xrdb_user.last_mtime = 0;
1912 xrdb_user.db = NULL;
1914 evas_gl_common_module_close();
1917 static Evas_Module_Api evas_modapi =
1919 EVAS_MODULE_API_VERSION,
1928 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, gl_x11);
1930 #ifndef EVAS_STATIC_BUILD_GL_X11
1931 EVAS_EINA_MODULE_DEFINE(engine, gl_x11);