1 #ifndef EVAS_GL_COMMON_H
2 #define EVAS_GL_COMMON_H
3
4 #include "evas_common_private.h"
5 #include "evas_private.h"
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <math.h>
11 #include <sys/time.h>
12 #include <unistd.h>
13 #include <Eet.h>
14
15 #define GL_GLEXT_PROTOTYPES
16
17 #if !defined(HAVE_ECORE_X_XLIB) && !defined(MESA_EGL_NO_X11_HEADERS)
18 # define MESA_EGL_NO_X11_HEADERS
19 #endif
20
21 #ifndef EVAS_GL_NO_HEADERS
22
23 #ifdef BUILD_ENGINE_GL_COCOA
24 # include <OpenGL/gl.h>
25 # include <OpenGL/glext.h>
26 #else
27 # ifdef _EVAS_ENGINE_SDL_H
28 # ifdef GL_GLES
29 # include <SDL2/SDL_opengles.h>
30 # else
31 # include <SDL2/SDL_opengl.h>
32 # endif
33 # else
34 # ifdef GL_GLES
35 # include <EGL/egl.h>
36 # include <GLES2/gl2.h>
37 # include <GLES2/gl2ext.h>
38 # else
39 # include <GL/gl.h>
40 # include <GL/glext.h>
41 # endif
42 # endif
43 #endif
44
45 #endif
46
47 #include "evas_gl_define.h"
48
49 #define EVAS_GL_TILE_SIZE 16
50
51 #define SHAD_VERTEX 0
52 #define SHAD_COLOR 1
53 #define SHAD_TEXUV 2
54 #define SHAD_TEXUV2 3
55 #define SHAD_TEXUV3 4
56 #define SHAD_TEXA 5
57 #define SHAD_TEXSAM 6
58 #define SHAD_MASK 7
59 #define SHAD_MASKSAM 8
60
61 typedef struct _Evas_GL_Program Evas_GL_Program;
62 typedef struct _Evas_GL_Shared Evas_GL_Shared;
63 typedef struct _Evas_Engine_GL_Context Evas_Engine_GL_Context;
64 typedef struct _Evas_GL_Texture_Pool Evas_GL_Texture_Pool;
65 typedef struct _Evas_GL_Texture_Alloca Evas_GL_Texture_Alloca;
66 typedef struct _Evas_GL_Texture Evas_GL_Texture;
67 typedef struct _Evas_GL_Image Evas_GL_Image;
68 typedef struct _Evas_GL_Font_Texture Evas_GL_Font_Texture;
69 typedef struct _Evas_GL_Polygon Evas_GL_Polygon;
70 typedef struct _Evas_GL_Polygon_Point Evas_GL_Polygon_Point;
71 typedef struct _Evas_GL_Texture_Async_Preload Evas_GL_Texture_Async_Preload;
72 typedef struct _Evas_GL_Image_Data_Map Evas_GL_Image_Data_Map;
73 typedef struct _Evas_GL_Filter Evas_GL_Filter;
74
75 typedef Eina_Bool (*evas_gl_make_current_cb)(void *engine_data, void *doit);
76
77 #ifdef EAPI
78 # undef EAPI
79 #endif
80
81 #ifdef _WIN32
82 # ifdef EFL_BUILD
83 # ifdef DLL_EXPORT
84 # define EAPI __declspec(dllexport)
85 # else
86 # define EAPI
87 # endif
88 # else
89 # define EAPI __declspec(dllimport)
90 # endif
91 #else
92 # ifdef __GNUC__
93 # if __GNUC__ >= 4
94 # define EAPI __attribute__ ((visibility("default")))
95 # else
96 # define EAPI
97 # endif
98 # else
99 # define EAPI
100 # endif
101 #endif
102
103 #define PROGRAM_HITCOUNT_MAX 0x1000000
104
105 struct _Evas_GL_Filter
106 {
107 struct {
108 GLint loc[3];
109 Eina_Bool known_locations;
110 } attribute;
111 struct {
112 GLint blur_count_loc;
113 GLint blur_count_value;
114 GLint blur_texlen_loc;
115 GLfloat blur_texlen_value;
116 GLint blur_div_loc;
117 GLfloat blur_div_value;
118 Eina_Bool known_locations;
119 } uniform;
120 struct {
121 GLuint tex_ids[1];
122 } texture;
123 double blur_radius;
124 };
125
126 struct _Evas_GL_Program
127 {
128 unsigned int flags, hitcount, tex_count;
129 struct {
130 GLuint mvp, rotation_id;
131 } uniform;
132 Evas_GL_Filter *filter;
133 GLuint prog;
134
135 Eina_Bool reset : 1;
136 Eina_Bool bin_saved : 1;
137 Eina_Bool delete_me : 1;
138 };
139
140 struct _Evas_GL_Shared
141 {
142 Eina_List *images;
143
144 int images_size;
145
146 struct {
147 GLint max_texture_units;
148 GLint max_texture_size;
149 GLint max_vertex_elements;
150 GLfloat anisotropic;
151 Eina_Bool rgb : 1;
152 Eina_Bool bgra : 1;
153 Eina_Bool tex_npo2 : 1;
154 Eina_Bool tex_rect : 1;
155 Eina_Bool sec_image_map : 1;
156 Eina_Bool sec_tbm_surface : 1;
157 Eina_Bool egl_tbm_ext : 1;
158 Eina_Bool bin_program : 1;
159 Eina_Bool unpack_row_length : 1;
160 Eina_Bool etc1 : 1;
161 Eina_Bool etc2 : 1;
162 Eina_Bool etc1_subimage : 1;
163 Eina_Bool s3tc : 1;
164 // tuning params - per gpu/cpu combo?
165 #define DEF_CUTOUT 4096
166
167 #define MAX_PIPES 32
168 #define DEF_PIPES 8
169 #define DEF_PIPES_SGX_540 24
170 #define DEF_PIPES_TEGRA_2 8
171 #define DEF_PIPES_TEGRA_3 24
172
173 #define MIN_ATLAS_ALLOC 16
174 #define MAX_ATLAS_ALLOC 1024
175 #define DEF_ATLAS_ALLOC 256
176
177 #define MIN_ATLAS_ALLOC_ALPHA 16
178 #define MAX_ATLAS_ALLOC_ALPHA 4096
179 #define DEF_ATLAS_ALLOC_ALPHA 512
180
181 #define MAX_ATLAS_W 512
182 #define DEF_ATLAS_W 512
183
184 #define MAX_ATLAS_H 512
185 #define DEF_ATLAS_H 512
186
187 #define ATLAS_FORMATS_COUNT 12
188
189 Eina_List *cspaces; // depend on the values of etc1, etc2 and st3c
190
191 struct {
192 struct {
193 int max;
194 } cutout;
195 struct {
196 int max;
197 } pipes;
198 struct {
199 int max_alloc_size;
200 int max_alloc_alpha_size;
201 int max_w;
202 int max_h;
203 } atlas;
204 } tune;
205 } info;
206
207 struct {
208 Eina_List *whole;
209 Eina_List *atlas[ATLAS_FORMATS_COUNT];
210 } tex;
211
212 Eina_Hash *native_pm_hash;
213 Eina_Hash *native_tex_hash;
214 Eina_Hash *native_wl_hash;
215 Eina_Hash *native_tbm_hash;
216 Eina_Hash *native_evasgl_hash;
217
218 Eet_File *shaders_cache;
219 Eina_Hash *shaders_hash;
220 Eina_Stringshare *shaders_checksum;
221
222 #ifdef GL_GLES
223 // FIXME: hack.
224 void *eglctxt;
225 #endif
226
227 int references;
228 int w, h;
229 int rot;
230 int mflip;
231 // persp map
232 int foc, z0, px, py;
233 int ax, ay;
234 int offx, offy;
235 GLfloat proj[16];
236 Eina_Bool needs_shaders_flush : 1;
237 };
238
239 typedef enum _Shader_Sampling Shader_Sampling;
240 typedef enum _Shader_Type Shader_Type;
241
242 enum _Shader_Sampling {
243 SHD_SAM11,
244 SHD_SAM12,
245 SHD_SAM21,
246 SHD_SAM22,
247 SHD_SAM_LAST
248 };
249
250 enum _Shader_Type {
251 SHD_UNKNOWN,
252 SHD_RECT,
253 SHD_LINE,
254 SHD_FONT,
255 SHD_IMAGE,
256 SHD_IMAGENATIVE,
257 SHD_YUV,
258 SHD_YUY2,
259 SHD_NV12,
260 SHD_YUV_709,
261 SHD_YUY2_709,
262 SHD_NV12_709,
263 SHD_RGB_A_PAIR,
264 SHD_MAP,
265 SHD_FILTER_DISPLACE,
266 SHD_FILTER_CURVE,
267 SHD_FILTER_BLUR_X,
268 SHD_FILTER_BLUR_Y,
269 SHD_FILTER_GRAYSCALE,
270 SHD_FILTER_INVERSE_COLOR
271 };
272
273 #define ARRAY_BUFFER_USE 500
274 #define ARRAY_BUFFER_USE_SHIFT 100
275
276 struct _Evas_Engine_GL_Context
277 {
278 int references;
279 int w, h;
280 int rot;
281 int foc, z0, px, py;
282 RGBA_Draw_Context *dc;
283
284 Evas_GL_Shared *shared;
285
286 int flushnum;
287 struct {
288 int top_pipe;
289 struct {
290 Evas_GL_Program *prog;
291 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm;
292 int tex_target;
293 int cx, cy, cw, ch;
294 signed char render_op;
295 Eina_Bool smooth : 2;
296 Eina_Bool blend : 2;
297 Eina_Bool clip : 2;
298 Eina_Bool anti_alias : 2;
299 Eina_Bool has_filter_data : 1;
300 } current;
301 } state;
302
303 struct {
304 int x, y, w, h;
305 Eina_Bool enabled : 1;
306 Eina_Bool used : 1;
307 } master_clip;
308
309 struct {
310 Eina_Bool size : 1;
311 } change;
312
313 struct {
314 struct {
315 int x, y, w, h;
316 Shader_Type type;
317 } region;
318 struct {
319 Evas_GL_Program *prog;
320 Evas_GL_Image *surface;
321 void *cur_tex_dyn, *cur_texu_dyn, *cur_texv_dyn;
322 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm;
323 int tex_target;
324 int cx, cy, cw, ch;
325 signed char render_op;
326 Eina_Bool smooth : 2;
327 Eina_Bool blend : 2;
328 Eina_Bool mask_smooth : 2;
329 Eina_Bool clip : 2;
330 struct {
331 GLuint map_tex;
332 Eina_Bool map_nearest : 1;
333 Eina_Bool map_delete : 1;
334 } filter;
335 } shader;
336 struct {
337 int num, alloc;
338 GLfloat *vertex;
339 GLubyte *color;
340 GLfloat *texuv;
341 GLfloat *texuv2;
342 GLfloat *texuv3;
343 GLfloat *texa;
344 GLfloat *texsam;
345 GLfloat *mask;
346 GLfloat *masksam;
347 int filter_data_count; // number of vec2
348 GLfloat *filter_data;
349 Evas_GL_Image *im;
350 GLuint buffer;
351 int buffer_alloc;
352 int buffer_use;
353 Eina_Bool line : 1;
354 Eina_Bool use_vertex : 1; // always true
355 Eina_Bool use_color : 1;
356 Eina_Bool use_texuv : 1;
357 Eina_Bool use_texuv2 : 1;
358 Eina_Bool use_texuv3 : 1;
359 Eina_Bool use_texa : 1;
360 Eina_Bool use_texsam : 1;
361 Eina_Bool use_mask : 1;
362 Eina_Bool use_masksam : 1;
363 Eina_Bool anti_alias : 1;
364 } array;
365 } pipe[MAX_PIPES];
366
367 Eina_List *font_glyph_textures;
368 Eina_List *font_glyph_images;
369 Evas_GL_Image *def_surface;
370 RGBA_Image *font_surface;
371 int font_glyph_textures_size;
372 int font_glyph_atlas_size;
373 Eina_Bool font_glyph_gc_requested :1;
374
375 #ifdef GL_GLES
376 // FIXME: hack. expose egl display to gl core for egl image sec extn.
377 void *egldisp;
378 void *eglctxt;
379 #else
380 int glxcfg_rgb;
381 int glxcfg_rgba;
382 #endif
383
384 GLuint preserve_bit;
385 int gles_version;
386
387 Eina_Bool havestuff : 1;
388 Eina_Bool msaa : 1;
389 };
390
391 struct _Evas_GL_Texture_Pool
392 {
393 Evas_Engine_GL_Context *gc;
394 GLuint texture, fb, stencil;
395 GLuint intformat, format, dataformat;
396 int w, h;
397 int references;
398 int slot, fslot;
399 struct {
400 void *img;
401 void *buffer;
402 unsigned int *data;
403 int w, h;
404 int stride;
405 int checked_out;
406 int target;
407 } dyn;
408 Eina_List *allocations;
409 Eina_Rectangle_Pool *eina_pool;
410 Eina_Bool whole : 1;
411 Eina_Bool render : 1;
412 Eina_Bool native : 1;
413 Eina_Bool dynamic : 1;
414 };
415
416 struct _Evas_GL_Texture_Alloca
417 {
418 Evas_GL_Texture *tex;
419 int x, w;
420 };
421
422 struct _Evas_GL_Texture
423 {
424 Evas_Engine_GL_Context *gc;
425 Evas_GL_Image *im;
426 Evas_GL_Texture_Pool *pt, *ptu, *ptv, *ptt;
427 Evas_GL_Texture_Pool *pt2, *ptu2, *ptv2;
428 union {
429 Evas_GL_Texture_Pool *ptuv;
430 Evas_GL_Texture_Pool *pta;
431 };
432 RGBA_Font_Glyph *fglyph;
433 int references;
434 int x, y, w, h;
435 int tx, ty;
436 double sx1, sy1, sx2, sy2;
437
438 struct {
439 Evas_GL_Texture_Pool *pt[2], *ptuv[2];
440 int source;
441 } double_buffer;
442
443 Eina_List *targets;
444 Eina_Rectangle *apt, *aptt;
445
446 Eina_Bool alpha : 1;
447 Eina_Bool dyn : 1;
448 Eina_Bool uploaded : 1;
449 Eina_Bool was_preloaded : 1;
450 };
451
452 struct _Evas_GL_Image
453 {
454 Evas_Engine_GL_Context *gc;
455 RGBA_Image *im;
456 Evas_GL_Texture *tex;
457 Evas_Image_Load_Opts load_opts;
458 RGBA_Font_Glyph *fglyph;
459 int references;
460 // if im->im == NULL, it's a render-surface so these here are used
461 int w, h;
462 struct {
463 Evas_Colorspace space;
464 void *data;
465 unsigned char no_free : 1;
466 } cs;
467
468 struct {
469 void *data;
470 struct {
471 void (*bind) (void *image);
472 void (*unbind) (void *image);
473 void (*free) (void *image);
474 int (*yinvert) (void *image);
475 } func;
476 void *disp;
477 Evas_GL_Shared *shared;
478 int target;
479 Eina_Bool yinvert : 1;
480 Eina_Bool mipmap : 1;
481 Eina_Bool loose : 1;
482 } native;
483
484 struct {
485 Evas_GL_Image *origin;
486 Eina_Bool smooth : 1;
487 } scaled;
488
489 Eina_List *filtered;
490 Eina_List *targets;
491 Eina_Inlist *maps; /* Evas_GL_Image_Data_Map */
492
493 Evas_Image_Orient orient;
494 int scale_hint, content_hint;
495 int csize;
496
497 Eina_Bool dirty : 1;
498 Eina_Bool cached : 1;
499 Eina_Bool alpha : 1;
500 Eina_Bool tex_only : 1;
501 Eina_Bool locked : 1; // gl_surface_lock/unlock
502 Eina_Bool direct : 1; // evas gl direct renderable
503 /*Disable generate atlas for texture unit, EINA_FALSE by default*/
504 Eina_Bool disable_atlas : 1;
505 };
506
507 struct _Evas_GL_Font_Texture
508 {
509 Evas_GL_Texture *tex;
510 };
511
512 struct _Evas_GL_Polygon
513 {
514 Eina_List *points;
515 Eina_Bool changed : 1;
516 };
517
518 struct _Evas_GL_Polygon_Point
519 {
520 int x, y;
521 };
522
523 struct _Evas_GL_Texture_Async_Preload
524 {
525 Evas_GL_Texture *tex;
526 RGBA_Image *im;
527
528 Eina_Bool unpack_row_length;
529 };
530
531 struct _Evas_GL_Image_Data_Map
532 {
533 EINA_INLIST;
534 Evas_GL_Texture *tex; // one or the other
535 RGBA_Image *im; // one or the other
536 Evas_GL_Image *glim;
537 Eina_Rw_Slice slice;
538 int stride; // in bytes
539 int rx, ry, rw, rh; // actual map region
540 Evas_Colorspace cspace;
541 Efl_Gfx_Buffer_Access_Mode mode;
542 };
543
544 /* GL_Common function that are used by gl_generic inherited module */
545 EAPI void evas_gl_common_image_all_unload(Evas_Engine_GL_Context *gc);
546 EAPI void evas_gl_common_image_ref(Evas_GL_Image *im);
547 EAPI void evas_gl_common_image_unref(Evas_GL_Image *im);
548 EAPI Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace);
549 EAPI void evas_gl_common_image_native_disable(Evas_GL_Image *im);
550 EAPI void evas_gl_common_image_free(Evas_GL_Image *im);
551 EAPI void evas_gl_common_image_native_enable(Evas_GL_Image *im);
552
553 EAPI int evas_gl_preload_init(void);
554 EAPI int evas_gl_preload_shutdown(void);
555 EAPI Eina_Bool evas_gl_preload_enabled(void);
556
557 EAPI Evas_Engine_GL_Context *evas_gl_common_context_new(void);
558
559 EAPI void evas_gl_common_context_flush(Evas_Engine_GL_Context *gc);
560 EAPI void evas_gl_common_context_free(Evas_Engine_GL_Context *gc);
561 EAPI void evas_gl_common_context_use(Evas_Engine_GL_Context *gc);
562 EAPI void evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc);
563 EAPI void evas_gl_common_context_done(Evas_Engine_GL_Context *gc);
564
565 EAPI void evas_gl_common_context_resize(Evas_Engine_GL_Context *gc, int w, int h, int rot);
566 EAPI int evas_gl_common_buffer_dump(Evas_Engine_GL_Context *gc, const char* dname, const char* fname, int frame, const char* suffix);
567
568 EAPI void evas_gl_preload_render_lock(evas_gl_make_current_cb make_current, void *engine_data);
569 EAPI void evas_gl_preload_render_unlock(evas_gl_make_current_cb make_current, void *engine_data);
570 EAPI void evas_gl_preload_render_relax(evas_gl_make_current_cb make_current, void *engine_data);
571 EAPI void evas_gl_symbols(void *(*GetProcAddress)(const char *name), const char *extsn);
572 EAPI Eina_Bool evas_gl_extension_string_check(const char *ext, const char *exts);
573
574 EAPI void evas_gl_common_error_set(int error_enum);
575 EAPI int evas_gl_common_error_get(void);
576 EAPI void *evas_gl_common_current_context_get(void);
577
578 typedef int (*Evas_GL_Preload)(void);
579 typedef void (*Evas_GL_Common_Image_Call)(Evas_GL_Image *im);
580 typedef void (*Evas_GL_Common_Context_Call)(Evas_Engine_GL_Context *gc);
581 typedef Evas_GL_Image *(*Evas_GL_Common_Image_New_From_Data)(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace);
582 typedef void (*Evas_GL_Preload_Render_Call)(evas_gl_make_current_cb make_current, void *engine_data);
583 typedef Evas_Engine_GL_Context *(*Evas_GL_Common_Context_New)(void);
584 typedef void (*Evas_GL_Common_Context_Resize_Call)(Evas_Engine_GL_Context *gc, int w, int h, int rot);
585 typedef int (*Evas_GL_Common_Buffer_Dump_Call)(Evas_Engine_GL_Context *gc,const char* dname, const char* fname, int frame, const char* suffix);
586 typedef void (*Evas_Gl_Symbols)(void *(*GetProcAddress)(const char *sym), const char *extsn);
587 typedef Eina_Bool (*Evas_Gl_Extension_String_Check)(const char *exts, const char *ext);
588
589 EAPI void __evas_gl_err(int err, const char *file, const char *func, int line, const char *op);
590
591 int evas_gl_common_version_check(int *minor_version);
592 void evas_gl_common_tiling_start(Evas_Engine_GL_Context *gc,
593 int rot, int gw, int gh,
594 int cx, int cy, int cw, int ch,
595 int bitmask);
596 void evas_gl_common_tiling_done(Evas_Engine_GL_Context *gc);
597 void evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc, Evas_GL_Image *surface);
598
599 void evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
600 int x1, int y1, int x2, int y2,
601 int clip, int cx, int cy, int cw, int ch,
602 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
603 Eina_Bool mask_smooth, Eina_Bool mask_color,
604 int r, int g, int b, int a);
605 void evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
606 int x, int y, int w, int h,
607 int r, int g, int b, int a,
608 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
609 Eina_Bool mask_smooth, Eina_Bool mask_color);
610 void evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
611 Evas_GL_Texture *tex,
612 double sx, double sy, double sw, double sh,
613 int x, int y, int w, int h,
614 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
615 Eina_Bool mask_smooth, Eina_Bool mask_color,
616 int r, int g, int b, int a,
617 Eina_Bool smooth, Eina_Bool tex_only, Eina_Bool alphaonly);
618 void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
619 Evas_GL_Texture *tex,
620 double sx, double sy, double sw, double sh,
621 int x, int y, int w, int h,
622 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
623 Eina_Bool mask_smooth, Eina_Bool mask_color,
624 int r, int g, int b, int a);
625 void evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
626 Evas_GL_Texture *tex,
627 double sx, double sy, double sw, double sh,
628 int x, int y, int w, int h,
629 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
630 Eina_Bool mask_smooth, Eina_Bool mask_color,
631 int r, int g, int b, int a,
632 Eina_Bool smooth);
633 void evas_gl_common_context_yuv_709_push(Evas_Engine_GL_Context *gc,
634 Evas_GL_Texture *tex,
635 double sx, double sy, double sw, double sh,
636 int x, int y, int w, int h,
637 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
638 Eina_Bool mask_smooth, Eina_Bool mask_color,
639 int r, int g, int b, int a,
640 Eina_Bool smooth);
641 void evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
642 Evas_GL_Texture *tex,
643 double sx, double sy, double sw, double sh,
644 int x, int y, int w, int h,
645 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
646 Eina_Bool mask_smooth, Eina_Bool mask_color,
647 int r, int g, int b, int a,
648 Eina_Bool smooth);
649 void evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
650 Evas_GL_Texture *tex,
651 double sx, double sy, double sw, double sh,
652 int x, int y, int w, int h,
653 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
654 Eina_Bool mask_smooth, Eina_Bool mask_color,
655 int r, int g, int b, int a,
656 Eina_Bool smooth);
657 void evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
658 Evas_GL_Texture *tex,
659 double sx, double sy, double sw, double sh,
660 int x, int y, int w, int h,
661 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
662 Eina_Bool mask_smooth, Eina_Bool mask_color,
663 int r, int g, int b, int a,
664 Eina_Bool smooth);
665 void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
666 Evas_GL_Texture *tex,
667 int npoints,
668 RGBA_Map_Point *p,
669 int clip, int cx, int cy, int cw, int ch,
670 Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
671 Eina_Bool mask_smooth, Eina_Bool mask_color,
672 int r, int g, int b, int a,
673 Eina_Bool smooth,
674 Eina_Bool tex_only,
675 Evas_Colorspace cspace);
676
677 // Gfx Filters
678 void evas_gl_common_filter_blend_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex,
679 double sx, double sy, double sw, double sh, double dx,
680 double dy, double dw, double dh, Eina_Bool alphaonly);
681 void evas_gl_common_filter_displace_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, Evas_GL_Texture *map_tex,
682 int x, int y, int w, int h, double dx, double dy, Eina_Bool nearest);
683 void evas_gl_common_filter_curve_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex,
684 int x, int y, int w, int h, const uint8_t *points, int channel);
685 void evas_gl_common_filter_blur_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh,
686 double dx, double dy, double dw, double dh, const double * const values, const double * const offsets, int count, double radius,
687 Eina_Bool horiz, Eina_Bool alphaonly);
688 void evas_gl_common_filter_grayscale_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, int x, int y, int w, int h);
689 void evas_gl_common_filter_inverse_color_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, int x, int y, int w, int h);
690
691 int evas_gl_common_shader_program_init(Evas_GL_Shared *shared);
692 void evas_gl_common_shader_program_shutdown(Evas_GL_Shared *shared);
693 EAPI void evas_gl_common_shaders_flush(Evas_GL_Shared *shared);
694
695 Evas_GL_Program *evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
696 Shader_Type type,
697 RGBA_Map_Point *p, int npoints,
698 int r, int g, int b, int a,
699 int sw, int sh, int w, int h, Eina_Bool smooth,
700 Evas_GL_Texture *tex, Eina_Bool tex_only,
701 Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
702 Eina_Bool mask_color, int mw, int mh,
703 Eina_Bool alphaonly,
704 Shader_Sampling *psam, int *pnomul,
705 Shader_Sampling *pmasksam);
706 void evas_gl_common_shader_textures_bind(Evas_GL_Program *p, Eina_Bool recover_prog);
707
708 Eina_Bool evas_gl_common_file_cache_is_dir(const char *file);
709 Eina_Bool evas_gl_common_file_cache_mkdir(const char *dir);
710 Eina_Bool evas_gl_common_file_cache_file_exists(const char *file);
711 Eina_Bool evas_gl_common_file_cache_mkpath_if_not_exists(const char *path);
712 Eina_Bool evas_gl_common_file_cache_mkpath(const char *path);
713 int evas_gl_common_file_cache_dir_check(char *cache_dir, int num);
714 int evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num);
715
716 void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h);
717
718 void evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt);
719 Evas_GL_Texture *evas_gl_common_texture_new(Evas_Engine_GL_Context *gc, RGBA_Image *im, Eina_Bool disable_atlas);
720 Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_GL_Image *im);
721 Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil);
722 Evas_GL_Texture *evas_gl_common_texture_render_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha);
723 Evas_GL_Texture *evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
724 void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im);
725 void evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int bytes_count);
726 void evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force);
727 Evas_GL_Texture *evas_gl_common_texture_alpha_new(Evas_Engine_GL_Context *gc, DATA8 *pixels, unsigned int w, unsigned int h, int fh);
728 void evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels, unsigned int w, unsigned int h, int fh);
729 Evas_GL_Texture *evas_gl_common_texture_yuv_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigned int w, unsigned int h);
730 void evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned int w, unsigned int h);
731 Evas_GL_Texture *evas_gl_common_texture_yuy2_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigned int w, unsigned int h);
732 void evas_gl_common_texture_yuy2_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned int w, unsigned int h);
733 Evas_GL_Texture *evas_gl_common_texture_nv12_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigned int w, unsigned int h);
734 void evas_gl_common_texture_nv12_update(Evas_GL_Texture *tex, DATA8 **row, unsigned int w, unsigned int h);
735 Evas_GL_Texture *evas_gl_common_texture_nv12tiled_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigned int w, unsigned int h);
736 void evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **row, unsigned int w, unsigned int h);
737 Evas_GL_Texture *evas_gl_common_texture_rgb_a_pair_new(Evas_Engine_GL_Context *gc, RGBA_Image *im);
738 void evas_gl_common_texture_rgb_a_pair_update(Evas_GL_Texture *tex, RGBA_Image *im);
739 Evas_Colorspace evas_gl_common_gl_format_to_colorspace(GLuint f);
740
741 void evas_gl_common_image_alloc_ensure(Evas_GL_Image *im);
742 Evas_GL_Image *evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error);
743 Evas_GL_Image *evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *key, Evas_Image_Load_Opts *lo, int *error);
744 Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace);
745 Evas_GL_Image *evas_gl_common_image_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_Colorspace cspace);
746 Evas_GL_Image *evas_gl_common_image_new_from_rgbaimage(Evas_Engine_GL_Context *gc, RGBA_Image *im, Evas_Image_Load_Opts *lo, int *error);
747 void evas_gl_common_image_preload_done(void *data /*Evas_GL_Image *im*/);
748 void evas_gl_common_image_preload_unwatch(Evas_GL_Image *im);
749 Evas_GL_Image *evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha);
750 void evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hint);
751 void evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint);
752 void evas_gl_common_image_cache_flush(Evas_Engine_GL_Context *gc);
753 Evas_GL_Image *evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil);
754 Evas_GL_Image *evas_gl_common_image_surface_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha);
755 void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
756 void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
757 void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level);
758 void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
759 Evas_GL_Image *evas_gl_common_image_surface_update(Evas_GL_Image *im);
760 Evas_GL_Image *evas_gl_common_image_surface_detach(Evas_GL_Image *im);
761 Evas_GL_Image *evas_gl_common_image_virtual_scaled_get(Evas_GL_Image *scaled, Evas_GL_Image *image, int dst_w, int dst_h, Eina_Bool smooth);
762
763 void *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg);
764 void evas_gl_font_texture_free(void *);
765 void evas_gl_font_texture_draw(void *gc, void *surface, void *dc, RGBA_Font_Glyph *fg, int x, int y, int w, int h);
766 void *evas_gl_font_image_new(void *gc, RGBA_Font_Glyph *fg, int alpha, Evas_Colorspace cspace);
767 void evas_gl_font_image_free(void *im);
768 void evas_gl_font_image_draw(void *gc, void *im, int dx, int dy, int dw, int dh, int smooth);
769
770 Evas_GL_Polygon *evas_gl_common_poly_point_add(Evas_GL_Polygon *poly, int x, int y);
771 Evas_GL_Polygon *evas_gl_common_poly_points_clear(Evas_GL_Polygon *poly);
772 void evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int x, int y);
773
774 void evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int y2);
775
776 extern void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b);
777 extern void (*glsym_glBindFramebuffer) (GLenum a, GLuint b);
778 extern void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e);
779 extern void (*glsym_glDeleteFramebuffers) (GLsizei a, const GLuint *b);
780 extern void (*glsym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei *c, GLenum *d, void *e);
781 extern void (*glsym_glProgramBinary) (GLuint a, GLenum b, const void *c, GLint d);
782 extern void (*glsym_glProgramParameteri) (GLuint a, GLuint b, GLint d);
783 extern void (*glsym_glReleaseShaderCompiler)(void);
784 extern void *(*glsym_glMapBuffer) (GLenum a, GLenum b);
785 extern GLboolean (*glsym_glUnmapBuffer) (GLenum a);
786 extern void (*glsym_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
787
788 #ifdef GL_GLES
789 EAPI void * evas_gl_common_eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
790 EAPI int evas_gl_common_eglDestroyImage (EGLDisplay dpy, void *im);
791 extern unsigned int (*eglsym_eglDestroyImage) (void *a, void *b);
792 extern void (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b);
793 extern void *(*secsym_eglMapImageSEC) (void *a, void *b, int c, int d);
794 extern unsigned int (*secsym_eglUnmapImageSEC) (void *a, void *b, int c);
795 extern unsigned int (*secsym_eglGetImageAttribSEC) (void *a, void *b, int c, int *d);
796
797 // TBM Surface stuff
798 #define TBM_SURF_PLANE_MAX 4 /**< maximum number of planes */
799
800 /* option to map the tbm_surface */
801 #define TBM_SURF_OPTION_READ (1 << 0) /**< access option to read */
802 #define TBM_SURF_OPTION_WRITE (1 << 1) /**< access option to write */
803
804 #define __tbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
805 ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
806
807 #define TBM_FORMAT_C8 __tbm_fourcc_code('C', '8', ' ', ' ')
808 #define TBM_FORMAT_RGBA8888 __tbm_fourcc_code('R', 'A', '2', '4')
809 #define TBM_FORMAT_BGRA8888 __tbm_fourcc_code('B', 'A', '2', '4')
810 #define TBM_FORMAT_RGB888 __tbm_fourcc_code('R', 'G', '2', '4')
811
812 typedef struct _tbm_surface * tbm_surface_h;
813 typedef uint32_t tbm_format;
814 typedef struct _tbm_surface_plane
815 {
816 unsigned char *ptr; /**< Plane pointer */
817 uint32_t size; /**< Plane size */
818 uint32_t offset; /**< Plane offset */
819 uint32_t stride; /**< Plane stride */
820
821 void *reserved1; /**< Reserved pointer1 */
822 void *reserved2; /**< Reserved pointer2 */
823 void *reserved3; /**< Reserved pointer3 */
824 } tbm_surface_plane_s;
825
826 typedef struct _tbm_surface_info
827 {
828 uint32_t width; /**< TBM surface width */
829 uint32_t height; /**< TBM surface height */
830 tbm_format format; /**< TBM surface format*/
831 uint32_t bpp; /**< TBM surface bbp */
832 uint32_t size; /**< TBM surface size */
833
834 uint32_t num_planes; /**< The number of planes */
835 tbm_surface_plane_s planes[TBM_SURF_PLANE_MAX]; /**< Array of planes */
836
837 void *reserved4; /**< Reserved pointer4 */
838 void *reserved5; /**< Reserved pointer5 */
839 void *reserved6; /**< Reserved pointer6 */
840 } tbm_surface_info_s;
841
842
843 extern void *(*secsym_tbm_surface_create) (int width, int height, unsigned int format);
844 extern int (*secsym_tbm_surface_destroy) (void *surface);
845 extern int (*secsym_tbm_surface_map) (void *surface, int opt, void *info);
846 extern int (*secsym_tbm_surface_unmap) (void *surface);
847 extern int (*secsym_tbm_surface_get_info) (void *surface, void *info);
848 #endif
849
850 Eina_Bool evas_gl_preload_push(Evas_GL_Texture_Async_Preload *async);
851 void evas_gl_preload_pop(Evas_GL_Texture *tex);
852 void evas_gl_preload_target_register(Evas_GL_Texture *tex, Eo *target);
853 void evas_gl_preload_target_unregister(Evas_GL_Texture *tex, Eo *target);
854
855 void pt_unref(Evas_GL_Texture_Pool *pt);
856
857 // Enable GL errors logging
858 //#define GL_ERRORS 1
859 // Enable very basic GL calls logging (requires GL_ERRORS)
860 //#define GL_ERRORS_TRACE 1
861
862 #ifdef GL_ERRORS
863
864 # ifndef _WIN32
865 # include <dlfcn.h>
866 # endif
867
868 static inline void
__evas_gl_errdyn(int err,const char * file,const char * func,int line,const char * op)869 __evas_gl_errdyn(int err, const char *file, const char *func, int line, const char *op)
870 {
871 static void (*sym)(int,const char*,const char*,int,const char*) = NULL;
872 if (!sym) sym = dlsym(RTLD_DEFAULT, "__evas_gl_err");
873 sym(err, file, func, line, op);
874 }
875 # define GLERRV(op) do { \
876 int __gl_err = glGetError(); \
877 if (__gl_err != GL_NO_ERROR) \
878 __evas_gl_errdyn(__gl_err, __FILE__, __func__, __LINE__, op); \
879 } while (0)
880 /* Redefine common gl funcs */
881 # ifndef GL_ERRORS_NODEF
882 # ifndef GL_ERRORS_TRACE
883 # define GL_ERROR_TRACE(f, _args, ...) do { GLERRV("Uncaught error before this point:"); f(__VA_ARGS__); GLERRV(#f); } while(0)
884 # define GL_ERROR_TRACE_RET(t, f, _args, ...) ({ t _r = f(__VA_ARGS__); GLERRV(#f); _r; })
885 # else
886 # define GL_ERROR_TRACE(f, _args, ...) do { DBG("%s(%s);", #f, _args); f(__VA_ARGS__); GLERRV(#f); } while(0)
887 # define GL_ERROR_TRACE_RET(t, f, _args, ...) ({ t _r; DBG("%s(%s);", #f, _args); _r = f(__VA_ARGS__); GLERRV(#f); _r; })
888 # endif
889 # define glActiveTexture(...) GL_ERROR_TRACE(glActiveTexture, #__VA_ARGS__, __VA_ARGS__)
890 # define glBindAttribLocation(...) GL_ERROR_TRACE(glBindAttribLocation, #__VA_ARGS__, __VA_ARGS__)
891 # define glBindBuffer(...) GL_ERROR_TRACE(glBindBuffer, #__VA_ARGS__, __VA_ARGS__)
892 # define glBindTexture(...) GL_ERROR_TRACE(glBindTexture, #__VA_ARGS__, __VA_ARGS__)
893 # define glBlendFunc(...) GL_ERROR_TRACE(glBlendFunc, #__VA_ARGS__, __VA_ARGS__)
894 # define glBufferData(...) GL_ERROR_TRACE(glBufferData, #__VA_ARGS__, __VA_ARGS__)
895 # define glCompressedTexSubImage2D(...) GL_ERROR_TRACE(glCompressedTexSubImage2D, #__VA_ARGS__, __VA_ARGS__)
896 # define glDeleteBuffers(...) GL_ERROR_TRACE(glDeleteBuffers, #__VA_ARGS__, __VA_ARGS__)
897 # define glDepthMask(...) GL_ERROR_TRACE(glDepthMask, #__VA_ARGS__, __VA_ARGS__)
898 # define glDisable(...) GL_ERROR_TRACE(glDisable, #__VA_ARGS__, __VA_ARGS__)
899 # define glDisableVertexAttribArray(...) GL_ERROR_TRACE(glDisableVertexAttribArray, #__VA_ARGS__, __VA_ARGS__)
900 # define glDrawArrays(...) GL_ERROR_TRACE(glDrawArrays, #__VA_ARGS__, __VA_ARGS__)
901 # define glEnable(...) GL_ERROR_TRACE(glEnable, #__VA_ARGS__, __VA_ARGS__)
902 # define glEnableVertexAttribArray(...) GL_ERROR_TRACE(glEnableVertexAttribArray, #__VA_ARGS__, __VA_ARGS__)
903 # define glGenBuffers(...) GL_ERROR_TRACE(glGenBuffers, #__VA_ARGS__, __VA_ARGS__)
904 # define glGetFloatv(...) GL_ERROR_TRACE(glGetFloatv, #__VA_ARGS__, __VA_ARGS__)
905 # define glGetIntegerv(...) GL_ERROR_TRACE(glGetIntegerv, #__VA_ARGS__, __VA_ARGS__)
906 # define glGetUniformLocation(...) GL_ERROR_TRACE_RET(GLuint, glGetUniformLocation, #__VA_ARGS__, __VA_ARGS__)
907 # define glHint(...) GL_ERROR_TRACE(glHint, #__VA_ARGS__, __VA_ARGS__)
908 # define glReadPixels(...) GL_ERROR_TRACE(glReadPixels, #__VA_ARGS__, __VA_ARGS__)
909 # define glScissor(...) GL_ERROR_TRACE(glScissor, #__VA_ARGS__, __VA_ARGS__)
910 # define glGenFramebuffers(...) GL_ERROR_TRACE(glGenFramebuffers, #__VA_ARGS__, __VA_ARGS__)
911 # define glBindFramebuffer(...) GL_ERROR_TRACE(glBindFramebuffer, #__VA_ARGS__, __VA_ARGS__)
912 # define glEndTiling(...) GL_ERROR_TRACE(glEndTiling, #__VA_ARGS__, __VA_ARGS__)
913 # define glGetProgramBinary(...) GL_ERROR_TRACE(glGetProgramBinary, #__VA_ARGS__, __VA_ARGS__)
914 # define glMapBuffer(...) GL_ERROR_TRACE_RET(void *, glMapBuffer, #__VA_ARGS__, __VA_ARGS__)
915 # define glStartTiling(...) GL_ERROR_TRACE(glStartTiling, #__VA_ARGS__, __VA_ARGS__)
916 # define glUnmapBuffer(...) GL_ERROR_TRACE(glUnmapBuffer, #__VA_ARGS__, __VA_ARGS__)
917 # define glTexParameterf(...) GL_ERROR_TRACE(glTexParameterf, #__VA_ARGS__, __VA_ARGS__)
918 # define glTexParameteri(...) GL_ERROR_TRACE(glTexParameteri, #__VA_ARGS__, __VA_ARGS__)
919 # define glTexSubImage2D(...) GL_ERROR_TRACE(glTexSubImage2D, #__VA_ARGS__, __VA_ARGS__)
920 # define glTexImage2D(...) GL_ERROR_TRACE(glTexImage2D, #__VA_ARGS__, __VA_ARGS__)
921 # define glUniform1f(...) GL_ERROR_TRACE(glUniform1f, #__VA_ARGS__, __VA_ARGS__)
922 # define glUniform1i(...) GL_ERROR_TRACE(glUniform1i, #__VA_ARGS__, __VA_ARGS__)
923 # define glUniform2fv(...) GL_ERROR_TRACE(glUniform2fv, #__VA_ARGS__, __VA_ARGS__)
924 # define glUniform4fv(...) GL_ERROR_TRACE(glUniform4fv, #__VA_ARGS__, __VA_ARGS__)
925 # define glUniformMatrix4fv(...) GL_ERROR_TRACE(glUniformMatrix4fv, #__VA_ARGS__, __VA_ARGS__)
926 # define glUseProgram(...) GL_ERROR_TRACE(glUseProgram, #__VA_ARGS__, __VA_ARGS__)
927 # define glVertexAttribPointer(...) GL_ERROR_TRACE(glVertexAttribPointer, #__VA_ARGS__, __VA_ARGS__)
928 # define glViewport(...) GL_ERROR_TRACE(glViewport, #__VA_ARGS__, __VA_ARGS__)
929 # define glPixelStorei(...) GL_ERROR_TRACE(glPixelStorei, #__VA_ARGS__, __VA_ARGS__)
930 # define glCompressedTexImage2D(...) GL_ERROR_TRACE(glCompressedTexImage2D, #__VA_ARGS__, __VA_ARGS__)
931 # define glCreateShader(...) GL_ERROR_TRACE_RET(GLuint, glCreateShader, #__VA_ARGS__, __VA_ARGS__)
932 # define glCreateProgram(...) GL_ERROR_TRACE_RET(GLuint, glCreateProgram, #__VA_ARGS__, __VA_ARGS__)
933 # define glAttachShader(...) GL_ERROR_TRACE(glAttachShader, #__VA_ARGS__, __VA_ARGS__)
934 # define glLinkProgram(...) GL_ERROR_TRACE(glLinkProgram, #__VA_ARGS__, __VA_ARGS__)
935 # define glGetProgramiv(...) GL_ERROR_TRACE(glGetProgramiv, #__VA_ARGS__, __VA_ARGS__)
936 # define glGetProgramInfoLog(...) GL_ERROR_TRACE(glGetProgramInfoLog, #__VA_ARGS__, __VA_ARGS__)
937 # define glGetShaderiv(...) GL_ERROR_TRACE(glGetShaderiv, #__VA_ARGS__, __VA_ARGS__)
938 # define glShaderSource(...) GL_ERROR_TRACE(glShaderSource, #__VA_ARGS__, __VA_ARGS__)
939 # define glCompileShader(...) GL_ERROR_TRACE(glCompileShader, #__VA_ARGS__, __VA_ARGS__)
940 # define glsym_glGenFramebuffers(...) GL_ERROR_TRACE(glsym_glGenFramebuffers, #__VA_ARGS__, __VA_ARGS__)
941 # define glsym_glBindFramebuffer(...) GL_ERROR_TRACE(glsym_glBindFramebuffer, #__VA_ARGS__, __VA_ARGS__)
942 # define glsym_glFramebufferTexture2D(...) GL_ERROR_TRACE(glsym_glFramebufferTexture2D, #__VA_ARGS__, __VA_ARGS__)
943 # define glsym_glDeleteFramebuffers(...) GL_ERROR_TRACE(glsym_glDeleteFramebuffers, #__VA_ARGS__, __VA_ARGS__)
944 # define glsym_glGetProgramBinary(...) GL_ERROR_TRACE(glsym_glGetProgramBinary, #__VA_ARGS__, __VA_ARGS__)
945 # define glsym_glProgramBinary(...) GL_ERROR_TRACE(glsym_glProgramBinary, #__VA_ARGS__, __VA_ARGS__)
946 # define glsym_glProgramParameteri(...) GL_ERROR_TRACE(glsym_glProgramParameteri, #__VA_ARGS__, __VA_ARGS__)
947 # define glsym_glReleaseShaderCompiler(...) GL_ERROR_TRACE(glsym_glReleaseShaderCompiler, #__VA_ARGS__, __VA_ARGS__)
948 # define glsym_glMapBuffer(...) GL_ERROR_TRACE_RET(void *, glsym_glMapBuffer, #__VA_ARGS__, __VA_ARGS__)
949 # define glsym_glUnmapBuffer(...) GL_ERROR_TRACE_RET(unsigned int, glsym_glUnmapBuffer, #__VA_ARGS__, __VA_ARGS__)
950 # define eglsym_eglCreateImage(...) GL_ERROR_TRACE_RET(void *, eglsym_eglCreateImage, #__VA_ARGS__, __VA_ARGS__)
951 # define eglsym_eglCreateImageKHR(...) GL_ERROR_TRACE_RET(void *, eglsym_eglCreateImageKHR, #__VA_ARGS__, __VA_ARGS__)
952 # define eglsym_eglDestroyImage(...) GL_ERROR_TRACE_RET(unsigned int, eglsym_eglDestroyImage, #__VA_ARGS__, __VA_ARGS__)
953 # define secsym_glEGLImageTargetTexture2DOES(...) GL_ERROR_TRACE(secsym_glEGLImageTargetTexture2DOES, #__VA_ARGS__, __VA_ARGS__)
954 # define secsym_eglMapImageSEC(...) GL_ERROR_TRACE_RET(void *, secsym_eglMapImageSEC, #__VA_ARGS__, __VA_ARGS__)
955 # define secsym_eglUnmapImageSEC(...) GL_ERROR_TRACE_RET(unsigned int, secsym_eglUnmapImageSEC, #__VA_ARGS__, __VA_ARGS__)
956 # define secsym_eglGetImageAttribSEC(...) GL_ERROR_TRACE_RET(unsigned int, secsym_eglGetImageAttribSEC, #__VA_ARGS__, __VA_ARGS__)
957 # endif
958 #else
959 # define GLERRV(op)
960 #endif
961
962 Eina_Bool evas_gl_common_module_open(void);
963 void evas_gl_common_module_close(void);
964
965 #ifndef EVAS_GL_NO_HEADERS
966
967 static inline void
_tex_sub_2d(Evas_Engine_GL_Context * gc,int x,int y,int w,int h,int fmt,int type,const void * pix)968 _tex_sub_2d(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int fmt, int type, const void *pix)
969 {
970 if ((w > gc->shared->info.max_texture_size) ||
971 (h > gc->shared->info.max_texture_size)) return;
972 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, fmt, type, pix);
973 }
974
975 static inline void
_comp_tex_sub_2d(Evas_Engine_GL_Context * gc,int x,int y,int w,int h,int fmt,int imgsize,const void * pix)976 _comp_tex_sub_2d(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int fmt, int imgsize, const void *pix)
977 {
978 if ((w > gc->shared->info.max_texture_size) ||
979 (h > gc->shared->info.max_texture_size)) return;
980 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, fmt, imgsize, pix);
981 }
982
983 #endif
984
985 #undef EAPI
986 #define EAPI
987
988 extern Eina_Bool _need_context_restore;
989 extern void _context_restore(void);
990
991 #endif
992