Add OpenGL SDL engine
[framework/uifw/evas.git] / src / modules / engines / gl_sdl / evas_engine.c
1 #include "evas_common.h"
2 #include "evas_engine.h"
3
4 #include <dlfcn.h>      /* dlopen,dlclose,etc */
5
6 static void*                     _sdl_output_setup      (int w, int h, int fullscreen, int noframe);
7                 
8 int _evas_engine_GL_SDL_log_dom = -1;
9 /* function tables - filled in later (func and parent func) */
10 static Evas_Func func, pfunc;
11
12 static void *
13 eng_info(Evas *e)
14 {
15    Evas_Engine_Info_GL_SDL *info;
16
17    info = calloc(1, sizeof(Evas_Engine_Info_GL_SDL));
18    if (!info) return NULL;
19    info->magic.magic = rand();
20    return info;
21 }
22
23 static void
24 eng_info_free(Evas *e __UNUSED__, void *info)
25 {
26    Evas_Engine_Info_GL_SDL *in;
27    in = (Evas_Engine_Info_GL_SDL *)info;
28    free(in);
29 }
30
31 static int
32 eng_setup(Evas *e, void *in)
33 {
34    Render_Engine *re;
35    Evas_Engine_Info_GL_SDL *info;
36
37    info = (Evas_Engine_Info_GL_SDL *)in;
38
39    SDL_Init(SDL_INIT_NOPARACHUTE);
40
41    if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
42      {
43         ERR("SDL_Init failed with %s", SDL_GetError());
44         SDL_Quit();
45         return 0;
46      }
47
48    re = _sdl_output_setup(e->output.w, e->output.h,
49                              info->flags.fullscreen,
50                              info->flags.noframe);
51    re->info = info;
52    e->engine.data.output = re;
53    if (!e->engine.data.output)
54      return 0;
55
56    e->engine.func = &func;
57    e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
58    
59    return 1;
60 }
61
62 static void
63 eng_output_free(void *data)
64 {
65    Render_Engine *re;
66
67    re = (Render_Engine *)data;
68    evas_gl_common_context_free(re->gl_context);
69    free(re);
70
71    evas_common_font_shutdown();
72    evas_common_image_shutdown();
73
74    SDL_QuitSubSystem(SDL_INIT_VIDEO);
75 }
76
77 static void
78 eng_output_resize(void *data, int w, int h)
79 {
80    Render_Engine        *re;
81    SDL_Surface          *surface;
82
83    re = (Render_Engine *)data;
84    re->w = w;
85    re->h = h;
86
87    surface = SDL_SetVideoMode(w, h, 32, EVAS_SDL_GL_FLAG
88                               | (re->info->flags.fullscreen ? SDL_FULLSCREEN : 0)
89                               | (re->info->flags.noframe ? SDL_NOFRAME : 0));
90    if (!surface)
91      {
92         ERR("Unable to change the resolution to : %ix%i", w, h);
93         exit(-1);
94      }
95
96    evas_gl_common_context_resize(re->gl_context, w, h);
97 }
98
99 static void
100 eng_output_tile_size_set(void *data, int w __UNUSED__, int h __UNUSED__)
101 {
102 //   Render_Engine *re;
103 //
104 //   re = (Render_Engine *)data;
105 }
106
107 static void
108 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
109 {
110    Render_Engine *re;
111
112    re = (Render_Engine *)data;
113    evas_gl_common_context_resize(re->gl_context, re->w, re->h);
114    /* smple bounding box */
115    if (!re->draw.redraw)
116      {
117 #if 0
118         re->draw.x1 = x;
119         re->draw.y1 = y;
120         re->draw.x2 = x + w - 1;
121         re->draw.y2 = y + h - 1;
122 #else
123         re->draw.x1 = 0;
124         re->draw.y1 = 0;
125         re->draw.x2 = re->w - 1;
126         re->draw.y2 = re->h - 1;
127 #endif
128      }
129    else
130      {
131         if (x < re->draw.x1) re->draw.x1 = x;
132         if (y < re->draw.y1) re->draw.y1 = y;
133         if ((x + w - 1) > re->draw.x2) re->draw.x2 = x + w - 1;
134         if ((y + h - 1) > re->draw.y2) re->draw.y2 = y + h - 1;
135      }
136    re->draw.redraw = 1;
137 }
138
139 static void
140 eng_output_redraws_rect_del(void *data, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
141 {
142 //   Render_Engine *re;
143 //
144 //   re = (Render_Engine *)data;
145 }
146
147 static void
148 eng_output_redraws_clear(void *data)
149 {
150    Render_Engine *re;
151
152    re = (Render_Engine *)data;
153    re->draw.redraw = 0;
154 //   INF("GL: finish update cycle!");
155 }
156
157 /* at least the nvidia drivers are so abysmal that copying from the backbuffer
158  * to the front using glCopyPixels() that you literally can WATCH it draw the
159  * pixels slowly across the screen with a window update taking multiple
160  * seconds - so workaround by doing a full buffer render as frankly GL isn't
161  * up to doing anything that isn't done by quake (etc.)
162  */
163 #define SLOW_GL_COPY_RECT 1
164 /* vsync games - not for now though */
165 //#define VSYNC_TO_SCREEN 1
166
167 static void *
168 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
169 {
170    Render_Engine *re;
171
172    re = (Render_Engine *)data;
173    evas_gl_common_context_flush(re->gl_context);
174    /* get the upate rect surface - return engine data as dummy */
175    if (!re->draw.redraw)
176      {
177 //      printf("GL: NO updates!\n");
178         return NULL;
179      }
180 //   printf("GL: update....!\n");
181 #ifdef SLOW_GL_COPY_RECT
182    /* if any update - just return the whole canvas - works with swap
183     * buffers then */
184    if (x) *x = 0;
185    if (y) *y = 0;
186    if (w) *w = re->w;
187    if (h) *h = re->h;
188    if (cx) *cx = 0;
189    if (cy) *cy = 0;
190    if (cw) *cw = re->w;
191    if (ch) *ch = re->h;
192 #else
193    /* 1 update - INCREDIBLY SLOW if combined with swap_rect in flush. a gl
194     * problem where there just is no hardware path for somethnig that
195     * obviously SHOULD be there */
196    /* only 1 update to minimise gl context games and rendering multiple update
197     * regions as evas does with other engines
198     */
199    if (x) *x = re->draw.x1;
200    if (y) *y = re->draw.y1;
201    if (w) *w = re->draw.x2 - re->draw.x1 + 1;
202    if (h) *h = re->draw.y2 - re->draw.y1 + 1;
203    if (cx) *cx = re->draw.x1;
204    if (cy) *cy = re->draw.y1;
205    if (cw) *cw = re->draw.x2 - re->draw.x1 + 1;
206    if (ch) *ch = re->draw.y2 - re->draw.y1 + 1;
207 #endif
208 // clear buffer. only needed for dest alpha
209 //   glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
210 //   glClear(GL_COLOR_BUFFER_BIT);
211 //x//   printf("frame -> new\n");
212    return re->gl_context->def_surface;
213 }
214
215 static void
216 eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
217 {
218    Render_Engine *re;
219
220    re = (Render_Engine *)data;
221    /* put back update surface.. in this case just unflag redraw */
222    re->draw.redraw = 0;
223    re->draw.drew = 1;
224    evas_gl_common_context_flush(re->gl_context);
225 //x//   printf("frame -> push\n");
226 }
227
228 static void
229 eng_output_flush(void *data)
230 {
231    Render_Engine *re;
232
233    re = (Render_Engine *)data;
234    if (!re->draw.drew) return;
235 //x//   printf("frame -> flush\n");
236    re->draw.drew = 0;
237
238 #if 0
239 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
240 //   glFlush();
241    eglSwapBuffers(re->egl_disp, re->egl_surface[0]);
242 #else
243    glXSwapBuffers(re->win->disp, re->win);
244 #endif   
245 #else
246    SDL_GL_SwapBuffers();
247 #endif
248 }
249
250 static void
251 eng_output_idle_flush(void *data)
252 {
253 //   Render_Engine *re;
254 //
255 //   re = (Render_Engine *)data;
256 }
257
258 static void
259 eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h)
260 {
261 //   Render_Engine *re;
262 //
263 //   re = (Render_Engine *)data;
264 //   re->gl_context->dc = context;
265    evas_common_draw_context_add_cutout(context, x, y, w, h);
266 }
267
268 static void
269 eng_context_cutout_clear(void *data, void *context)
270 {
271 //   Render_Engine *re;
272 //
273 //   re = (Render_Engine *)data;
274 //   re->gl_context->dc = context;
275    evas_common_draw_context_clear_cutouts(context);
276 }
277
278 static void
279 eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
280 {
281    Render_Engine *re;
282
283    re = (Render_Engine *)data;
284    evas_gl_common_context_target_surface_set(re->gl_context, surface);
285    re->gl_context->dc = context;
286    evas_gl_common_rect_draw(re->gl_context, x, y, w, h);
287 }
288
289 static void
290 eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
291 {
292    Render_Engine *re;
293
294    re = (Render_Engine *)data;
295    evas_gl_common_context_target_surface_set(re->gl_context, surface);
296    re->gl_context->dc = context;
297    evas_gl_common_line_draw(re->gl_context, x1, y1, x2, y2);
298 }
299
300 static void *
301 eng_polygon_point_add(void *data, void *context __UNUSED__, void *polygon, int x, int y)
302 {
303    Render_Engine *re;
304
305    re = (Render_Engine *)data;
306    return evas_gl_common_poly_point_add(polygon, x, y);
307 }
308
309 static void *
310 eng_polygon_points_clear(void *data, void *context __UNUSED__, void *polygon)
311 {
312    Render_Engine *re;
313
314    re = (Render_Engine *)data;
315    return evas_gl_common_poly_points_clear(polygon);
316 }
317
318 static void
319 eng_polygon_draw(void *data, void *context, void *surface, void *polygon)
320 {
321    Render_Engine *re;
322
323    re = (Render_Engine *)data;
324    evas_gl_common_context_target_surface_set(re->gl_context, surface);
325    re->gl_context->dc = context;
326    evas_gl_common_poly_draw(re->gl_context, polygon);
327 }
328
329 static void
330 eng_gradient2_color_np_stop_insert(void *data __UNUSED__, void *gradient __UNUSED__, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__, float pos __UNUSED__)
331 {
332    evas_common_gradient2_color_np_stop_insert(gradient, r, g, b, a, pos);
333 }
334
335 static void
336 eng_gradient2_clear(void *data __UNUSED__, void *gradient __UNUSED__)
337 {
338    evas_common_gradient2_clear(gradient);
339 }
340
341 static void
342 eng_gradient2_fill_transform_set(void *data __UNUSED__, void *gradient __UNUSED__, void *transform __UNUSED__)
343 {
344    evas_common_gradient2_fill_transform_set(gradient, transform);
345 }
346
347 static void
348 eng_gradient2_fill_spread_set(void *data __UNUSED__, void *gradient __UNUSED__, int spread __UNUSED__)
349 {
350    evas_common_gradient2_fill_spread_set(gradient, spread);
351 }
352
353 static void *
354 eng_gradient2_linear_new(void *data __UNUSED__)
355 {
356    return evas_common_gradient2_linear_new();
357 }
358
359 static void
360 eng_gradient2_linear_free(void *data __UNUSED__, void *linear_gradient __UNUSED__)
361 {
362    evas_common_gradient2_free(linear_gradient);
363 }
364
365 static void
366 eng_gradient2_linear_fill_set(void *data __UNUSED__, void *linear_gradient __UNUSED__, float x0 __UNUSED__, float y0 __UNUSED__, float x1 __UNUSED__, float y1 __UNUSED__)
367 {
368    evas_common_gradient2_linear_fill_set(linear_gradient, x0, y0, x1, y1);
369 }
370
371 static int
372 eng_gradient2_linear_is_opaque(void *data __UNUSED__, void *context __UNUSED__, void *linear_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
373 {
374    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
375    RGBA_Gradient2 *gr = (RGBA_Gradient2 *)linear_gradient;
376
377    if (!dc || !gr || !gr->type.geometer)  return 0;
378    return !(gr->type.geometer->has_alpha(gr, dc->render_op) |
379             gr->type.geometer->has_mask(gr, dc->render_op));
380 }
381
382 static int
383 eng_gradient2_linear_is_visible(void *data __UNUSED__, void *context __UNUSED__, void *linear_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
384 {
385    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
386
387    if (!dc || !linear_gradient)  return 0;
388    return 1;
389 }
390
391 static void
392 eng_gradient2_linear_render_pre(void *data __UNUSED__, void *context __UNUSED__, void *linear_gradient __UNUSED__)
393 {
394    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
395    RGBA_Gradient2 *gr = (RGBA_Gradient2 *)linear_gradient;
396    int  len;
397    
398    if (!dc || !gr || !gr->type.geometer)  return;
399    gr->type.geometer->geom_update(gr);
400    len = gr->type.geometer->get_map_len(gr);
401    evas_common_gradient2_map(dc, gr, len);
402 }
403
404 static void
405 eng_gradient2_linear_render_post(void *data __UNUSED__, void *linear_gradient __UNUSED__)
406 {
407 }
408
409 static void
410 eng_gradient2_linear_draw(void *data __UNUSED__, void *context __UNUSED__, void *surface __UNUSED__, void *linear_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
411 {
412    Render_Engine *re;
413
414    re = (Render_Engine *)data;
415    re->gl_context->dc = context;
416      {
417         Evas_GL_Image *gim;
418         RGBA_Image *im;
419         RGBA_Draw_Context *dc = context;
420         int op = dc->render_op, cuse = dc->clip.use;
421         
422         im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
423         im = (RGBA_Image *)evas_cache_image_size_set(&im->cache_entry, w, h);
424         
425         dc->render_op = _EVAS_RENDER_FILL;
426         dc->clip.use = 0;
427         
428         // draw to buf, copy to tex, draw tex
429         evas_common_gradient2_draw(im, dc, 0, 0, w, h, linear_gradient);
430
431         gim = evas_gl_common_image_new_from_data(re->gl_context, w, h,
432                                                  im->image.data, 1,
433                                                  EVAS_COLORSPACE_ARGB8888);
434         dc->render_op = op;
435         dc->clip.use = cuse;
436         evas_gl_common_image_draw(re->gl_context, gim, 0, 0, w, h, x, y, w, h, 0);
437         evas_cache_image_drop(&im->cache_entry);
438         evas_gl_common_image_free(gim);
439      }
440 }
441
442 static void *
443 eng_gradient2_radial_new(void *data __UNUSED__)
444 {
445    return evas_common_gradient2_radial_new();
446 }
447
448 static void
449 eng_gradient2_radial_free(void *data __UNUSED__, void *radial_gradient __UNUSED__)
450 {
451    evas_common_gradient2_free(radial_gradient);
452 }
453
454 static void
455 eng_gradient2_radial_fill_set(void *data __UNUSED__, void *radial_gradient __UNUSED__, float cx __UNUSED__, float cy __UNUSED__, float rx __UNUSED__, float ry __UNUSED__)
456 {
457    evas_common_gradient2_radial_fill_set(radial_gradient, cx, cy, rx, ry);
458 }
459
460 static int
461 eng_gradient2_radial_is_opaque(void *data __UNUSED__, void *context __UNUSED__, void *radial_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
462 {
463    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
464    RGBA_Gradient2 *gr = (RGBA_Gradient2 *)radial_gradient;
465    
466    if (!dc || !gr || !gr->type.geometer)  return 0;
467    return !(gr->type.geometer->has_alpha(gr, dc->render_op) |
468             gr->type.geometer->has_mask(gr, dc->render_op));
469 }
470
471 static int
472 eng_gradient2_radial_is_visible(void *data __UNUSED__, void *context __UNUSED__, void *radial_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
473 {
474    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
475    
476    if (!dc || !radial_gradient)  return 0;
477    return 1;
478 }
479
480 static void
481 eng_gradient2_radial_render_pre(void *data __UNUSED__, void *context __UNUSED__, void *radial_gradient __UNUSED__)
482 {
483    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
484    RGBA_Gradient2 *gr = (RGBA_Gradient2 *)radial_gradient;
485    int  len;
486    
487    if (!dc || !gr || !gr->type.geometer)  return;
488    gr->type.geometer->geom_update(gr);
489    len = gr->type.geometer->get_map_len(gr);
490    evas_common_gradient2_map(dc, gr, len);
491 }
492
493 static void
494 eng_gradient2_radial_render_post(void *data __UNUSED__, void *radial_gradient __UNUSED__)
495 {
496 }
497
498 static void
499 eng_gradient2_radial_draw(void *data __UNUSED__, void *context __UNUSED__, void *surface __UNUSED__, void *radial_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
500 {
501    Render_Engine *re;
502
503    re = (Render_Engine *)data;
504    re->gl_context->dc = context;
505      {
506         Evas_GL_Image *gim;
507         RGBA_Image *im;
508         RGBA_Draw_Context *dc = context;
509         int op = dc->render_op, cuse = dc->clip.use;
510         
511         im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
512         im = (RGBA_Image *)evas_cache_image_size_set(&im->cache_entry, w, h);
513         
514         dc->render_op = _EVAS_RENDER_FILL;
515         dc->clip.use = 0;
516         
517         // draw to buf, copy to tex, draw tex
518         evas_common_gradient2_draw(im, dc, 0, 0, w, h, radial_gradient);
519
520         gim = evas_gl_common_image_new_from_data(re->gl_context, w, h,
521                                                  im->image.data, 1,
522                                                  EVAS_COLORSPACE_ARGB8888);
523         dc->render_op = op;
524         dc->clip.use = cuse;
525         evas_gl_common_image_draw(re->gl_context, gim, 0, 0, w, h, x, y, w, h, 0);
526         evas_cache_image_drop(&im->cache_entry);
527         evas_gl_common_image_free(gim);
528      }
529 }
530
531 static void *
532 eng_gradient_new(void *data __UNUSED__)
533 {
534    return evas_common_gradient_new();
535 }
536
537 static void
538 eng_gradient_free(void *data __UNUSED__, void *gradient)
539 {
540    evas_common_gradient_free(gradient);
541 }
542
543 static void
544 eng_gradient_color_stop_add(void *data __UNUSED__, void *gradient, int r, int g, int b, int a, int delta)
545 {
546    evas_common_gradient_color_stop_add(gradient, r, g, b, a, delta);
547 }
548
549 static void
550 eng_gradient_alpha_stop_add(void *data __UNUSED__, void *gradient, int a, int delta)
551 {
552    evas_common_gradient_alpha_stop_add(gradient, a, delta);
553 }
554
555 static void
556 eng_gradient_color_data_set(void *data __UNUSED__, void *gradient, void *map, int len, int has_alpha)
557 {
558    evas_common_gradient_color_data_set(gradient, map, len, has_alpha);
559 }
560
561 static void
562 eng_gradient_alpha_data_set(void *data __UNUSED__, void *gradient, void *alpha_map, int len)
563 {
564    evas_common_gradient_alpha_data_set(gradient, alpha_map, len);
565 }
566
567 static void
568 eng_gradient_clear(void *data __UNUSED__, void *gradient)
569 {
570    evas_common_gradient_clear(gradient);
571 }
572
573 static void
574 eng_gradient_fill_set(void *data __UNUSED__, void *gradient, int x, int y, int w, int h)
575 {
576    evas_common_gradient_fill_set(gradient, x, y, w, h);
577 }
578
579 static void
580 eng_gradient_fill_angle_set(void *data __UNUSED__, void *gradient, double angle)
581 {
582    evas_common_gradient_fill_angle_set(gradient, angle);
583 }
584
585 static void
586 eng_gradient_fill_spread_set(void *data __UNUSED__, void *gradient, int spread)
587 {
588    evas_common_gradient_fill_spread_set(gradient, spread);
589 }
590
591 static void
592 eng_gradient_angle_set(void *data __UNUSED__, void *gradient, double angle)
593 {
594    evas_common_gradient_map_angle_set(gradient, angle);
595 }
596
597 static void
598 eng_gradient_offset_set(void *data __UNUSED__, void *gradient, float offset)
599 {
600    evas_common_gradient_map_offset_set(gradient, offset);
601 }
602
603 static void
604 eng_gradient_direction_set(void *data __UNUSED__, void *gradient, int direction)
605 {
606    evas_common_gradient_map_direction_set(gradient, direction);
607 }
608
609 static void
610 eng_gradient_type_set(void *data __UNUSED__, void *gradient, char *name, char *params)
611 {
612    evas_common_gradient_type_set(gradient, name, params);
613 }
614
615 static int
616 eng_gradient_is_opaque(void *data, void *context, void *gradient, int x, int y, int w, int h)
617 {
618    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
619    RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
620    
621    if (!dc || !gr || !gr->type.geometer)  return 0;
622    return !(gr->type.geometer->has_alpha(gr, dc->render_op) |
623             gr->type.geometer->has_mask(gr, dc->render_op));
624 }
625
626 static int
627 eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int y, int w, int h)
628 {
629    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
630    
631    if (!dc || !gradient)  return 0;
632    return 1;
633 }
634
635 static void
636 eng_gradient_render_pre(void *data, void *context, void *gradient)
637 {
638    RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
639    RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
640    int  len;
641    
642    if (!dc || !gr || !gr->type.geometer)  return;
643    gr->type.geometer->geom_set(gr);
644    len = gr->type.geometer->get_map_len(gr);
645    evas_common_gradient_map(dc, gr, len);
646 }
647
648 static void
649 eng_gradient_render_post(void *data __UNUSED__, void *gradient)
650 {
651 }
652
653 static void
654 eng_gradient_draw(void *data, void *context, void *surface __UNUSED__, void *gradient, int x, int y, int w, int h)
655 {
656    Render_Engine *re;
657
658    re = (Render_Engine *)data;
659    re->gl_context->dc = context;
660      {
661         Evas_GL_Image *gim;
662         RGBA_Image *im;
663         RGBA_Draw_Context *dc = context;
664         int op = dc->render_op, cuse = dc->clip.use;
665         
666         im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
667         im = (RGBA_Image *)evas_cache_image_size_set(&im->cache_entry, w, h);
668         
669         dc->render_op = _EVAS_RENDER_FILL;
670         dc->clip.use = 0;
671         
672         // draw to buf, copy to tex, draw tex
673         evas_common_gradient_draw(im, dc, 0, 0, w, h, gradient);
674
675         gim = evas_gl_common_image_new_from_data(re->gl_context, w, h,
676                                                  im->image.data, 1,
677                                                  EVAS_COLORSPACE_ARGB8888);
678         dc->render_op = op;
679         dc->clip.use = cuse;
680         evas_gl_common_image_draw(re->gl_context, gim, 0, 0, w, h, x, y, w, h, 0);
681         evas_cache_image_drop(&im->cache_entry);
682         evas_gl_common_image_free(gim);
683      }
684 }
685
686 static int
687 eng_image_alpha_get(void *data, void *image)
688 {
689 //   Render_Engine *re;
690    Evas_GL_Image *im;
691
692 //   re = (Render_Engine *)data;
693    if (!image) return 1;
694    im = image;
695    return im->alpha;
696 }
697
698 static int
699 eng_image_colorspace_get(void *data, void *image)
700 {
701 //   Render_Engine *re;
702    Evas_GL_Image *im;
703
704 //   re = (Render_Engine *)data;
705    if (!image) return EVAS_COLORSPACE_ARGB8888;
706    im = image;
707    return im->cs.space;
708 }
709
710 static void *
711 eng_image_alpha_set(void *data, void *image, int has_alpha)
712 {
713    Render_Engine *re;
714    Evas_GL_Image *im;
715
716    re = (Render_Engine *)data;
717    if (!image) return NULL;
718    im = image;
719    if (im->native.data)
720      {
721         im->alpha = has_alpha;
722         return image;
723      }
724    /* FIXME: can move to gl_common */
725    if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
726    if ((has_alpha) && (im->im->cache_entry.flags.alpha)) return image;
727    else if ((!has_alpha) && (!im->im->cache_entry.flags.alpha)) return image;
728    if (im->references > 1)
729      {
730         Evas_GL_Image *im_new;
731         
732         im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->cache_entry.w, im->im->cache_entry.h, im->im->image.data,
733                                                            eng_image_alpha_get(data, image),
734                                                            eng_image_colorspace_get(data, image));
735         if (!im_new) return im;
736         evas_gl_common_image_free(im);
737         im = im_new;
738      }
739    else
740      evas_gl_common_image_dirty(im, 0, 0, 0, 0);
741    im->im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
742    return image;
743 }
744
745 static void *
746 eng_image_border_set(void *data, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
747 {
748 //   Render_Engine *re;
749 //
750 //   re = (Render_Engine *)data;
751    return image;
752 }
753
754 static void
755 eng_image_border_get(void *data, void *image __UNUSED__, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
756 {
757 //   Render_Engine *re;
758 //
759 //   re = (Render_Engine *)data;
760 }
761
762 static char *
763 eng_image_comment_get(void *data, void *image, char *key __UNUSED__)
764 {
765 //   Render_Engine *re;
766    Evas_GL_Image *im;
767
768 //   re = (Render_Engine *)data;
769    if (!image) return NULL;
770    im = image;
771    if (!im->im) return NULL;
772    return im->im->info.comment;
773 }
774
775 static char *
776 eng_image_format_get(void *data, void *image)
777 {
778 //   Render_Engine *re;
779    Evas_GL_Image *im;
780
781 //   re = (Render_Engine *)data;
782    im = image;
783    return NULL;
784 }
785
786 static void
787 eng_image_colorspace_set(void *data, void *image, int cspace)
788 {
789    Render_Engine *re;
790    Evas_GL_Image *im;
791
792    re = (Render_Engine *)data;
793    if (!image) return;
794    im = image;
795    if (im->native.data) return;
796    /* FIXME: can move to gl_common */
797    if (im->cs.space == cspace) return;
798    evas_cache_image_colorspace(&im->im->cache_entry, cspace);
799    switch (cspace)
800      {
801       case EVAS_COLORSPACE_ARGB8888:
802         if (im->cs.data)
803           {
804              if (!im->cs.no_free) free(im->cs.data);
805              im->cs.data = NULL;
806              im->cs.no_free = 0;
807           }
808         break;
809       case EVAS_COLORSPACE_YCBCR422P601_PL:
810       case EVAS_COLORSPACE_YCBCR422P709_PL:
811         if (im->tex) evas_gl_common_texture_free(im->tex);
812         im->tex = NULL;
813         if (im->cs.data)
814           {
815              if (!im->cs.no_free) free(im->cs.data);
816           }
817         im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
818         im->cs.no_free = 0;
819         break;
820       default:
821         abort();
822         break;
823      }
824    im->cs.space = cspace;
825 }
826
827 /////////////////////////////////////////////////////////////////////////
828 //
829 //
830 typedef struct _Native Native;
831
832 struct _Native
833 {
834    Evas_Native_Surface ns;
835    
836 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
837    EGLSurface  egl_surface;
838 #endif
839 };
840
841 static void
842 _native_bind_cb(void *data, void *image)
843 {
844 }
845
846 static void
847 _native_unbind_cb(void *data, void *image)
848 {
849 }
850
851 static void
852 _native_free_cb(void *data, void *image)
853 {
854 }
855
856 static void
857 eng_image_native_set(void *data, void *image, void *native)
858 {
859 }
860
861 static void *
862 eng_image_native_get(void *data, void *image)
863 {
864    return NULL;
865 }
866
867 //
868 //
869 /////////////////////////////////////////////////////////////////////////
870
871 static void *
872 eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
873 {
874    Render_Engine *re;
875
876    re = (Render_Engine *)data;
877    *error = EVAS_LOAD_ERROR_NONE;
878    return evas_gl_common_image_load(re->gl_context, file, key, lo, error);
879 }
880
881 static void *
882 eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
883 {
884    Render_Engine *re;
885
886    re = (Render_Engine *)data;
887    return evas_gl_common_image_new_from_data(re->gl_context, w, h, image_data, alpha, cspace);
888 }
889
890 static void *
891 eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
892 {
893    Render_Engine *re;
894
895    re = (Render_Engine *)data;
896    return evas_gl_common_image_new_from_copied_data(re->gl_context, w, h, image_data, alpha, cspace);
897 }
898
899 static void
900 eng_image_free(void *data, void *image)
901 {
902    Render_Engine *re;
903
904    re = (Render_Engine *)data;
905    if (!image) return;
906    evas_gl_common_image_free(image);
907 }
908
909 static void
910 eng_image_size_get(void *data, void *image, int *w, int *h)
911 {
912 //   Render_Engine *re;
913 //
914 //   re = (Render_Engine *)data;
915    if (!image)
916      {
917         *w = 0;
918         *h = 0;
919         return;
920      }
921    if (w) *w = ((Evas_GL_Image *)image)->w;
922    if (h) *h = ((Evas_GL_Image *)image)->h;
923 }
924
925 static void *
926 eng_image_size_set(void *data, void *image, int w, int h)
927 {
928    Render_Engine *re;
929    Evas_GL_Image *im = image;
930    Evas_GL_Image *im_old;
931    
932    re = (Render_Engine *)data;
933    if (!im) return NULL;
934    if (im->native.data)
935      {
936         im->w = w;
937         im->h = h;
938         return image;
939      }
940    im_old = image;
941    if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
942        (eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
943      w &= ~0x1;
944    if ((im_old) && (im_old->im->cache_entry.w == w) && (im_old->im->cache_entry.h == h))
945      return image;
946    if (im_old)
947      {
948         im = evas_gl_common_image_new(re->gl_context, w, h,
949                                       eng_image_alpha_get(data, image),
950                                       eng_image_colorspace_get(data, image));
951 /*
952         evas_common_load_image_data_from_file(im_old->im);
953         if (im_old->im->image->data)
954           {
955              evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
956              evas_common_cpu_end_opt();
957           }
958  */
959         evas_gl_common_image_free(im_old);
960      }
961    else
962      im = evas_gl_common_image_new(re->gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888);
963    return im;
964 }
965
966 static void *
967 eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
968 {
969    Render_Engine *re;
970    Evas_GL_Image *im = image;
971
972    re = (Render_Engine *)data;
973    if (!image) return NULL;
974    if (im->native.data) return image;
975    evas_gl_common_image_dirty(image, x, y, w, h);
976    return image;
977 }
978
979 static void *
980 eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
981 {
982    Render_Engine *re;
983    Evas_GL_Image *im;
984
985    re = (Render_Engine *)data;
986    if (!image)
987      {
988         *image_data = NULL;
989         return NULL;
990      }
991    im = image;
992    if (im->native.data)
993      {
994         *image_data = NULL;
995         return im;
996      }
997    evas_cache_image_load_data(&im->im->cache_entry);
998    switch (im->cs.space)
999      {
1000       case EVAS_COLORSPACE_ARGB8888:
1001         if (to_write)
1002           {
1003              if (im->references > 1)
1004                {
1005                   Evas_GL_Image *im_new;
1006
1007                   im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->cache_entry.w, im->im->cache_entry.h, im->im->image.data,
1008                                                                      eng_image_alpha_get(data, image),
1009                                                                      eng_image_colorspace_get(data, image));
1010                   if (!im_new)
1011                     {
1012                        *image_data = NULL;
1013                        return im;
1014                     }
1015                   evas_gl_common_image_free(im);
1016                   im = im_new;
1017                }
1018              else
1019                evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1020           }
1021         *image_data = im->im->image.data;
1022         break;
1023       case EVAS_COLORSPACE_YCBCR422P601_PL:
1024       case EVAS_COLORSPACE_YCBCR422P709_PL:
1025         *image_data = im->cs.data;
1026         break;
1027       default:
1028         abort();
1029         break;
1030      }
1031    return im;
1032 }
1033
1034 static void *
1035 eng_image_data_put(void *data, void *image, DATA32 *image_data)
1036 {
1037    Render_Engine *re;
1038    Evas_GL_Image *im, *im2;
1039
1040    re = (Render_Engine *)data;
1041    if (!image) return NULL;
1042    im = image;
1043    if (im->native.data) return image;
1044    switch (im->cs.space)
1045      {
1046       case EVAS_COLORSPACE_ARGB8888:
1047         if (image_data != im->im->image.data)
1048           {
1049              int w, h;
1050
1051              w = im->im->cache_entry.w;
1052              h = im->im->cache_entry.h;
1053              im2 = eng_image_new_from_data(data, w, h, image_data,
1054                                            eng_image_alpha_get(data, image),
1055                                            eng_image_colorspace_get(data, image));
1056              if (!im2) return im;
1057              evas_gl_common_image_free(im);
1058              im = im2;
1059           }
1060         break;
1061       case EVAS_COLORSPACE_YCBCR422P601_PL:
1062       case EVAS_COLORSPACE_YCBCR422P709_PL:
1063         if (image_data != im->cs.data)
1064           {
1065              if (im->cs.data)
1066                {
1067                   if (!im->cs.no_free) free(im->cs.data);
1068                }
1069              im->cs.data = image_data;
1070           }
1071         break;
1072       default:
1073         abort();
1074         break;
1075      }
1076    /* hmmm - but if we wrote... why bother? */
1077    evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1078    return im;
1079 }
1080
1081 static void
1082 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
1083 {
1084    Evas_GL_Image *gim = image;
1085    RGBA_Image *im;
1086
1087    if (!gim) return;
1088    if (gim->native.data) return;
1089    im = (RGBA_Image *)gim->im;
1090    if (!im) return;
1091    evas_cache_image_preload_data(&im->cache_entry, target);
1092 }
1093
1094 static void
1095 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
1096 {
1097    Evas_GL_Image *gim = image;
1098    RGBA_Image *im;
1099
1100    if (!gim) return;
1101    if (gim->native.data) return;
1102    im = (RGBA_Image *)gim->im;
1103    if (!im) return;
1104    evas_cache_image_preload_cancel(&im->cache_entry, target);
1105 }
1106
1107 static void
1108 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)
1109 {
1110    Render_Engine *re;
1111
1112    re = (Render_Engine *)data;
1113    if (!image) return;
1114    evas_gl_common_context_target_surface_set(re->gl_context, surface);
1115    re->gl_context->dc = context;
1116    evas_gl_common_image_draw(re->gl_context, image,
1117                              src_x, src_y, src_w, src_h,
1118                              dst_x, dst_y, dst_w, dst_h,
1119                              smooth);
1120 }
1121
1122 static void
1123 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
1124 {
1125 }
1126
1127 static void
1128 eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *image, RGBA_Map_Point *p, int smooth, int level)
1129 {
1130    Render_Engine *re;
1131    
1132    re = (Render_Engine *)data;
1133    evas_gl_common_context_target_surface_set(re->gl_context, surface);
1134    re->gl_context->dc = context;
1135    evas_gl_common_image_map4_draw(re->gl_context, image, p, smooth, level);
1136 }
1137
1138 static void *
1139 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
1140 {
1141    Render_Engine *re;
1142    
1143    re = (Render_Engine *)data;
1144    return evas_gl_common_image_surface_new(re->gl_context, w, h, alpha);
1145 }
1146
1147 static void
1148 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
1149 {
1150    evas_gl_common_image_free(surface);
1151 }
1152
1153 static int
1154 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
1155 {
1156    return EVAS_IMAGE_SCALE_HINT_NONE;
1157 }
1158
1159 static void
1160 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 char *text)
1161 {
1162    Render_Engine *re;
1163
1164    re = (Render_Engine *)data;
1165    evas_gl_common_context_target_surface_set(re->gl_context, surface);
1166    re->gl_context->dc = context;
1167      {
1168         // FIXME: put im into context so we can free it
1169         static RGBA_Image *im = NULL;
1170         
1171         if (!im)
1172           im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
1173         im->cache_entry.w = re->w;
1174         im->cache_entry.h = re->h;
1175         evas_common_draw_context_font_ext_set(context,
1176                                               re->gl_context,
1177                                               evas_gl_font_texture_new,
1178                                               evas_gl_font_texture_free,
1179                                               evas_gl_font_texture_draw);
1180         evas_common_font_draw(im, context, font, x, y, text);
1181         evas_common_draw_context_font_ext_set(context,
1182                                               NULL,
1183                                               NULL,
1184                                               NULL,
1185                                               NULL);
1186      }
1187 }
1188
1189 static Eina_Bool
1190 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
1191 {
1192    // FIXME: support ARGB gl targets!!!
1193    return EINA_FALSE;
1194 }
1195
1196 static int
1197 module_open(Evas_Module *em)
1198 {
1199    if (!em) return 0;
1200    /* get whatever engine module we inherit from */
1201    if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
1202    if (_evas_engine_GL_SDL_log_dom < 0)
1203      _evas_engine_GL_SDL_log_dom = eina_log_domain_register("EvasEngineGLSDL", EVAS_DEFAULT_LOG_COLOR);
1204    if (_evas_engine_GL_SDL_log_dom < 0)
1205      {
1206         EINA_LOG_ERR("Impossible to create a log domain for GL SDL engine.\n");
1207         return 0;
1208      }
1209    /* store it for later use */
1210    func = pfunc;
1211    /* now to override methods */
1212    #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
1213    ORD(info);
1214    ORD(info_free);
1215    ORD(setup);
1216    ORD(canvas_alpha_get);
1217    ORD(output_free);
1218    ORD(output_resize);
1219    ORD(output_tile_size_set);
1220    ORD(output_redraws_rect_add);
1221    ORD(output_redraws_rect_del);
1222    ORD(output_redraws_clear);
1223    ORD(output_redraws_next_update_get);
1224    ORD(output_redraws_next_update_push);
1225    ORD(context_cutout_add);
1226    ORD(context_cutout_clear);
1227    ORD(output_flush);
1228    ORD(output_idle_flush);
1229    ORD(rectangle_draw);
1230    ORD(line_draw);
1231    ORD(polygon_point_add);
1232    ORD(polygon_points_clear);
1233    ORD(polygon_draw);
1234
1235    ORD(gradient2_color_np_stop_insert);
1236    ORD(gradient2_clear);
1237    ORD(gradient2_fill_transform_set);
1238    ORD(gradient2_fill_spread_set);
1239    ORD(gradient2_linear_new);
1240    ORD(gradient2_linear_free);
1241    ORD(gradient2_linear_fill_set);
1242    ORD(gradient2_linear_is_opaque);
1243    ORD(gradient2_linear_is_visible);
1244    ORD(gradient2_linear_render_pre);
1245    ORD(gradient2_linear_render_post);
1246    ORD(gradient2_linear_draw);
1247    ORD(gradient2_radial_new);
1248    ORD(gradient2_radial_free);
1249    ORD(gradient2_radial_fill_set);
1250    ORD(gradient2_radial_is_opaque);
1251    ORD(gradient2_radial_is_visible);
1252    ORD(gradient2_radial_render_pre);
1253    ORD(gradient2_radial_render_post);
1254    ORD(gradient2_radial_draw);
1255
1256    ORD(gradient_new);
1257    ORD(gradient_free);
1258    ORD(gradient_color_stop_add);
1259    ORD(gradient_alpha_stop_add);
1260    ORD(gradient_color_data_set);
1261    ORD(gradient_alpha_data_set);
1262    ORD(gradient_clear);
1263    ORD(gradient_fill_set);
1264    ORD(gradient_fill_angle_set);
1265    ORD(gradient_fill_spread_set);
1266    ORD(gradient_angle_set);
1267    ORD(gradient_offset_set);
1268    ORD(gradient_direction_set);
1269    ORD(gradient_type_set);
1270    ORD(gradient_is_opaque);
1271    ORD(gradient_is_visible);
1272    ORD(gradient_render_pre);
1273    ORD(gradient_render_post);
1274    ORD(gradient_draw);
1275    ORD(image_load);
1276    ORD(image_new_from_data);
1277    ORD(image_new_from_copied_data);
1278    ORD(image_free);
1279    ORD(image_size_get);
1280    ORD(image_size_set);
1281    ORD(image_dirty_region);
1282    ORD(image_data_get);
1283    ORD(image_data_put);
1284    ORD(image_data_preload_request);
1285    ORD(image_data_preload_cancel);
1286    ORD(image_alpha_set);
1287    ORD(image_alpha_get);
1288    ORD(image_border_set);
1289    ORD(image_border_get);
1290    ORD(image_draw);
1291    ORD(image_comment_get);
1292    ORD(image_format_get);
1293    ORD(image_colorspace_set);
1294    ORD(image_colorspace_get);
1295    ORD(image_native_set);
1296    ORD(image_native_get);
1297    ORD(font_draw);
1298    
1299    ORD(image_scale_hint_set);
1300    ORD(image_scale_hint_get);
1301    
1302    ORD(image_map4_draw);
1303    ORD(image_map_surface_new);
1304    ORD(image_map_surface_free);
1305    
1306    /* now advertise out own api */
1307    em->functions = (void *)(&func);
1308    return 1;
1309 }
1310
1311 static void
1312 module_close(Evas_Module *em)
1313 {
1314     eina_log_domain_unregister(_evas_engine_GL_SDL_log_dom);
1315 }
1316
1317 static Evas_Module_Api evas_modapi =
1318 {
1319    EVAS_MODULE_API_VERSION,
1320    "gl_sdl",
1321    "none",
1322    {
1323      module_open,
1324      module_close
1325    }
1326 };
1327
1328 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, gl_sdl);
1329
1330 #ifndef EVAS_STATIC_BUILD_GL_SDL
1331 EVAS_EINA_MODULE_DEFINE(engine, gl_sdl);
1332 #endif
1333
1334 static void*
1335 _sdl_output_setup               (int w, int h, int fullscreen, int noframe)
1336 {
1337    Render_Engine                *re = calloc(1, sizeof(Render_Engine));
1338    SDL_Surface                  *surface;
1339    int                          context_attrs[3];
1340    int                          config_attrs[20];
1341    int                          major_version, minor_version;
1342    int                          num_config;
1343
1344    /* if we haven't initialized - init (automatic abort if already done) */
1345    evas_common_cpu_init();
1346    evas_common_blend_init();
1347    evas_common_image_init();
1348    evas_common_convert_init();
1349    evas_common_scale_init();
1350    evas_common_rectangle_init();
1351    evas_common_gradient_init();
1352    evas_common_polygon_init();
1353    evas_common_line_init();
1354    evas_common_font_init();
1355    evas_common_draw_init();
1356    evas_common_tilebuf_init();
1357
1358    if (w <= 0) w = 640;
1359    if (h <= 0) h = 480;
1360    
1361    /* GL Initialization */
1362 #ifdef HAVE_SDL_GL_CONTEXT_VERSION
1363    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
1364    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
1365 #endif
1366    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
1367    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
1368    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
1369    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
1370    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
1371    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
1372
1373    surface = SDL_SetVideoMode(w, h, 32, EVAS_SDL_GL_FLAG
1374                               | (fullscreen ? SDL_FULLSCREEN : 0)
1375                               | (noframe ? SDL_NOFRAME : 0));
1376
1377    if (!surface)
1378      {
1379         CRIT("SDL_SetVideoMode [ %i x %i x 32 ] failed.", w, h);
1380         exit(-1);
1381      }
1382
1383    re->gl_context = evas_gl_common_context_new();
1384    if (!re->gl_context)
1385      {
1386         free(re);
1387         return NULL;
1388      }
1389    evas_gl_common_context_use(re->gl_context);
1390    evas_gl_common_context_resize(re->gl_context, w, h);
1391
1392    /* End GL Initialization */
1393    re->w = w;
1394    re->h = h;
1395    return re;
1396 }
1397