[IMPROVE] open GL native probes added
[platform/core/system/swap-probe.git] / probe_graphics / da_gles20_native.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2013 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 //disable tizen redefines
30 #define _GL2_MACRO_H_
31 #define _GL_MACRO_H_
32
33 extern "C" {
34 /*
35  * this include to make C native open gl functions
36  * probe prototypes
37  *
38  */
39
40 #include "da_gles20_tizen.cpp"
41
42 } /* extern C */
43
44 #undef eglSwapBuffers
45 extern "C" EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
46 {
47         typedef EGLBoolean (*methodType)(EGLDisplay, EGLSurface);
48         BEFORE_EGL(eglSwapBuffers);
49         EGLBoolean ret = eglSwapBuffersp(dpy, surface);
50         error = eglGetError();
51         AFTER_NO_PARAM('d', ret, APITYPE_CONTEXT, "");
52
53         return ret;
54 }
55 #define eglSwapBuffers _SglSwapBuffers
56
57 EGLBoolean _SglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
58 {
59         typedef EGLBoolean (*methodType)(EGLDisplay, EGLSurface);
60         BEFORE_OSP_UIFW(_SglSwapBuffers);
61         EGLBoolean ret = _SglSwapBuffersp(dpy, surface);
62         error = eglGetError();
63         AFTER_NO_PARAM('d', ret, APITYPE_CONTEXT, "");
64
65         return ret;
66 }
67
68 #undef eglGetProcAddress
69 extern "C" EGLAPI __eglMustCastToProperFunctionPointerType
70 eglGetProcAddress(const char* procname)
71 {
72         typedef EGLAPI __eglMustCastToProperFunctionPointerType
73                 (*methodType)(const char* procname);
74         __eglMustCastToProperFunctionPointerType ret = NULL;
75
76         BEFORE_EGL(eglGetProcAddress);
77
78         probeBlockStart();
79         INIT_LIB(LIBSELF, RTLD_LAZY | RTLD_GLOBAL);
80         ret = (typeof(ret)) dlsym(lib_handle[LIBSELF], procname);
81         if (dlerror() != NULL)
82                 ret = NULL;
83         probeBlockEnd();
84
85         if (ret == NULL) {
86                 // we don't have <procname> function in our lib
87                 // so we need find original function
88                 ret = eglGetProcAddressp(procname);
89                 error = eglGetError();
90         }
91
92         AFTER_NO_PARAM('p', ret, APITYPE_CONTEXT, "");
93         return ret;
94
95 }
96 #define eglGetProcAddress _eglGetProcAddress
97
98 #undef _GL2_MACRO_H_
99 #undef _GL_MACRO_H_