4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
8 * Vitaliy Cherepanov <v.cherepanov@samsung.com>
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)
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.
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
30 #include "da_gles20.h"
32 #include "common_probe_init.h"
36 void probe_terminate_with_err(const char *msg, const char *func_name,
40 const char *lib_name = "unknown";
42 if (id < NUM_ORIGINAL_LIBRARY)
43 lib_name = lib_string[id];
44 sprintf(error_msg, "%s : [%s], %s", msg, func_name, lib_name);
53 ////////////////////////////////////////////////////////////////////////////
54 //egl init probe function
56 // func_name - original function name for dlsym search
57 // func_pointer - original function pointer (return)
60 // search original function by name
61 // function have no return becouse on error it terminates main application
69 void init_probe_egl(__attribute__ ((unused))const char *func_name, void **func_pointer,
70 __attribute__ ((unused))ORIGINAL_LIBRARY id)
73 *func_pointer = (void *)dummy;
76 void init_probe_egl(const char *func_name, void **func_pointer,
82 if (lib_handle[id] == ((void *)0)) {
83 lib_handle[id] = dlopen(lib_string[id],
84 RTLD_LAZY | RTLD_GLOBAL);
86 if (lib_handle[id] == ((void *)0))
87 probe_terminate_with_err("dlopen failed", func_name, id);
89 faddr = dlsym(lib_handle[id], func_name);
90 if (faddr == NULL || dlerror() != NULL)
91 probe_terminate_with_err("dlsym failed", func_name, id);
92 memcpy(func_pointer, &faddr, sizeof(faddr));
98 void init_probe_gl(const char *func_name, void **func_pointer,
99 ORIGINAL_LIBRARY id, int blockresult, int32_t vAPI_ID)
102 probeInfo_t tempProbeInfo;
105 if (lib_handle[id] == ((void *)0)) {
106 lib_handle[id] = dlopen(lib_string[id], RTLD_LAZY);
107 if (lib_handle[id] == ((void *)0))
108 probe_terminate_with_err("dlopen failed", func_name, id);
110 setProbePoint(&tempProbeInfo);
111 if (blockresult != 0) {
113 char maxValString[64];
115 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVal[0]);
116 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxVal[1]);
117 sprintf(maxValString, "%d,%d", maxVal[0], maxVal[1]);
119 PACK_COMMON_BEGIN(MSG_PROBE_GL, vAPI_ID, "", 0);
120 PACK_COMMON_END('p', 1, 0, 0);
121 PACK_GL_ADD(APITYPE_INIT, 0, maxValString);
126 faddr = dlsym(lib_handle[id], func_name);
127 if (faddr == NULL || dlerror() != NULL)
128 probe_terminate_with_err("function not found in lib", func_name,
131 memcpy(func_pointer, &faddr, sizeof(faddr));