tizen 2.3 release
[framework/system/swap-probe.git] / probe_graphics / da_evas_gl.c
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Vitaliy Cherepanov <v.cherepanov@samsung.com>
9  *
10  * This library is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU Lesser General Public License as published by the
12  * Free Software Foundation; either version 2.1 of the License, or (at your option)
13  * any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
16  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this library; if not, write to the Free Software Foundation, Inc., 51
22  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  * Contributors:
25  * - Samsung RnD Institute Russia
26  *
27  */
28
29 #include "da_gles20.h"
30 #include "daprobe.h"
31 #include "binproto.h"
32 #include "common_probe_init.h"
33 #include "real_functions.h"
34
35 static enum DaOptions _sopt = OPT_GLES;
36
37 /* Evas open gl API functions */
38
39 void evas_gl_free(Evas_GL *evas_gl)
40 {
41         typedef void (*methodType)(Evas_GL *evas_gl);
42         BEFORE_EVAS_GL(evas_gl_free);
43         evas_gl_freep(evas_gl);
44         AFTER('v', NO_RETURN_VALUE, APITYPE_CONTEXT, "", "p",
45               voidp_to_uint64(evas_gl));
46 }
47
48 void evas_gl_config_free(Evas_GL_Config *cfg)
49 {
50         typedef void (*methodType)(Evas_GL_Config *cfg);
51         BEFORE_EVAS_GL(evas_gl_config_free);
52         evas_gl_config_freep(cfg);
53         AFTER('v', NO_RETURN_VALUE, APITYPE_CONTEXT, "", "p",
54               voidp_to_uint64(cfg));
55 }
56
57 void evas_gl_surface_destroy(Evas_GL *evas_gl, Evas_GL_Surface *surf)
58 {
59         typedef void (*methodType)(Evas_GL *evas_gl, Evas_GL_Surface *surf);
60         BEFORE_EVAS_GL(evas_gl_surface_destroy);
61         evas_gl_surface_destroyp(evas_gl, surf);
62         AFTER('v', NO_RETURN_VALUE, APITYPE_CONTEXT, "", "pp",
63               voidp_to_uint64(evas_gl), voidp_to_uint64(surf));
64 }
65
66 void evas_gl_context_destroy(Evas_GL *evas_gl, Evas_GL_Context *ctx)
67 {
68         typedef void (*methodType)(Evas_GL *evas_gl, Evas_GL_Context *ctx);
69         BEFORE_EVAS_GL(evas_gl_context_destroy);
70         evas_gl_context_destroyp(evas_gl, ctx);
71         AFTER('v', NO_RETURN_VALUE, APITYPE_CONTEXT, "", "pp",
72               voidp_to_uint64(evas_gl), voidp_to_uint64(ctx));
73 }
74
75 Evas_GL *evas_gl_new(Evas *e)
76 {
77         typedef Evas_GL *(*methodType)(Evas *e);
78         BEFORE_EVAS_GL(evas_gl_new);
79         Evas_GL *res = evas_gl_newp(e);
80         AFTER('p', voidp_to_uint64(res), APITYPE_CONTEXT, "", "p",
81               voidp_to_uint64(e));
82         return res;
83 }
84
85 Evas_GL_Config *evas_gl_config_new(void)
86 {
87         typedef Evas_GL_Config *(*methodType)(void);
88         BEFORE_EVAS_GL(evas_gl_config_new);
89         Evas_GL_Config *res = evas_gl_config_newp();
90         AFTER_NO_PARAM('p', voidp_to_uint64(res), APITYPE_CONTEXT, "");
91         return res;
92 }
93
94 Evas_GL_Surface *evas_gl_surface_create(Evas_GL *evas_gl, Evas_GL_Config *cfg,
95                                         int w, int h)
96 {
97         typedef Evas_GL_Surface *(*methodType)(Evas_GL *evas_gl,
98                                                Evas_GL_Config *cfg,
99                                                int w, int h);
100         BEFORE_EVAS_GL(evas_gl_surface_create);
101         Evas_GL_Surface *res = evas_gl_surface_createp(evas_gl, cfg, w, h);
102         AFTER('p', voidp_to_uint64(res), APITYPE_CONTEXT, "", "ppdd",
103               voidp_to_uint64(evas_gl), voidp_to_uint64(cfg), w, h);
104         return res;
105 }
106
107 Evas_GL_Context *evas_gl_context_create(Evas_GL *evas_gl,
108                                         Evas_GL_Context *share_ctx)
109 {
110         typedef Evas_GL_Context *(*methodType)(Evas_GL *evas_gl,
111                                                Evas_GL_Context *share_ctx);
112         BEFORE_EVAS_GL(evas_gl_context_create);
113         Evas_GL_Context *res = evas_gl_context_createp(evas_gl, share_ctx);
114         AFTER('p', voidp_to_uint64(res), APITYPE_CONTEXT, "", "pp",
115               voidp_to_uint64(evas_gl), voidp_to_uint64(share_ctx));
116         return res;
117 }
118
119 Eina_Bool evas_gl_make_current(Evas_GL *evas_gl, Evas_GL_Surface *surf,
120                                Evas_GL_Context *ctx)
121 {
122         typedef Eina_Bool (*methodType)(Evas_GL *evas_gl, Evas_GL_Surface *surf,
123                                         Evas_GL_Context *ctx);
124         BEFORE_EVAS_GL(evas_gl_make_current);
125         Eina_Bool res = evas_gl_make_currentp(evas_gl, surf, ctx);
126         AFTER('b', res, APITYPE_CONTEXT, "", "ppp",
127               voidp_to_uint64(evas_gl), voidp_to_uint64(surf), voidp_to_uint64(ctx));
128         return res;
129 }
130
131 const char *evas_gl_string_query(Evas_GL *evas_gl, int name)
132 {
133         typedef const char *(*methodType)(Evas_GL *evas_gl, int name);
134         BEFORE_EVAS_GL(evas_gl_string_query);
135         const char *res = evas_gl_string_queryp(evas_gl, name);
136         AFTER('s', res, APITYPE_CONTEXT, "", "pd",
137               voidp_to_uint64(evas_gl), name);
138         return res;
139 }
140
141 Evas_GL_Func evas_gl_proc_address_get(Evas_GL *evas_gl, const char *name)
142 {
143         typedef Evas_GL_Func(*methodType)(Evas_GL *evas_gl, const char *name);
144         BEFORE_EVAS_GL(evas_gl_proc_address_get);
145         Evas_GL_Func res = evas_gl_proc_address_getp(evas_gl, name);
146         AFTER('p', voidp_to_uint64(res), APITYPE_CONTEXT, "", "ps",
147               voidp_to_uint64(evas_gl), name);
148         return res;
149 }
150
151 Eina_Bool evas_gl_native_surface_get(Evas_GL *evas_gl, Evas_GL_Surface *surf,
152                                      Evas_Native_Surface *ns)
153 {
154         typedef Eina_Bool(*methodType)(Evas_GL *evas_gl, Evas_GL_Surface *surf,
155                                    Evas_Native_Surface *ns);
156         BEFORE_EVAS_GL(evas_gl_native_surface_get);
157         Eina_Bool res = evas_gl_native_surface_getp(evas_gl, surf, ns);
158         AFTER('b', res, APITYPE_CONTEXT, "", "ppp",
159               voidp_to_uint64(evas_gl), voidp_to_uint64(surf), voidp_to_uint64(ns));
160         return res;
161 }
162
163 /* ----------------- api get functions -------------- */
164
165 Evas_GL_API *evas_gl_api_get(Evas_GL *evas_gl)
166 {
167         typedef Evas_GL_API *(*methodType)(Evas_GL *evas_gl);
168         BEFORE_EVAS_GL(evas_gl_api_get);
169         Evas_GL_API *res = evas_gl_api_getp(evas_gl);
170
171         /* save original api functions and rewrite it by probes */
172         if (res != NULL) {
173                 save_orig_gl_api_list(res);
174                 change_gl_api_list(res);
175         }
176
177         AFTER('p', res, APITYPE_CONTEXT, "", "p",
178               voidp_to_uint64(evas_gl));
179
180         return res;
181 }
182
183 Evas_GL_API* elm_glview_gl_api_get(const Evas_Object *obj)
184 {
185         typedef Evas_GL_API *(*methodType)(const Evas_Object *obj);
186         BEFORE_EVAS_GL(elm_glview_gl_api_get);
187         Evas_GL_API *res = elm_glview_gl_api_getp(obj);
188
189         /* save original api functions and rewrite it by probes */
190         if (res != NULL) {
191                 save_orig_gl_api_list(res);
192                 change_gl_api_list(res);
193         }
194
195         /*clean error code*/
196         __gl_api->glGetError();
197
198         AFTER('p', res, APITYPE_CONTEXT, "", "p",
199               voidp_to_uint64(obj));
200
201         return res;
202 }
203
204 Evas_GL_API *evas_gl_context_api_get(Evas_GL *evas_gl, Evas_GL_Context *ctx)
205 {
206         typedef Evas_GL_API *(*methodType)(Evas_GL *evas_gl, Evas_GL_Context *ctx);
207         static methodType evas_gl_context_api_getp = 0;
208
209         GET_REAL_FUNC_RTLD_NEXT(evas_gl_context_api_get);
210
211         Evas_GL_API *res = evas_gl_context_api_getp(evas_gl, ctx);
212
213         /* save original api functions and rewrite it by probes */
214         if (res != NULL) {
215                 save_orig_gl_api_list(res);
216                 change_gl_api_list(res);
217         }
218
219         return res;
220 }