1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file is auto-generated from
6 // ui/gl/generate_bindings.py
7 // It's formatted by clang-format using chromium coding style:
8 // clang-format -i -style=chromium filename
13 #include "base/trace_event/trace_event.h"
14 #include "ui/gl/gl_bindings.h"
15 #include "ui/gl/gl_context.h"
16 #include "ui/gl/gl_enums.h"
17 #include "ui/gl/gl_implementation.h"
18 #include "ui/gl/gl_osmesa_api_implementation.h"
19 #include "ui/gl/gl_version_info.h"
23 static bool g_debugBindingsInitialized
;
24 DriverOSMESA g_driver_osmesa
;
26 void DriverOSMESA::InitializeStaticBindings() {
27 fn
.OSMesaColorClampFn
= reinterpret_cast<OSMesaColorClampProc
>(
28 GetGLProcAddress("OSMesaColorClamp"));
29 fn
.OSMesaCreateContextFn
= reinterpret_cast<OSMesaCreateContextProc
>(
30 GetGLProcAddress("OSMesaCreateContext"));
31 fn
.OSMesaCreateContextExtFn
= reinterpret_cast<OSMesaCreateContextExtProc
>(
32 GetGLProcAddress("OSMesaCreateContextExt"));
33 fn
.OSMesaDestroyContextFn
= reinterpret_cast<OSMesaDestroyContextProc
>(
34 GetGLProcAddress("OSMesaDestroyContext"));
35 fn
.OSMesaGetColorBufferFn
= reinterpret_cast<OSMesaGetColorBufferProc
>(
36 GetGLProcAddress("OSMesaGetColorBuffer"));
37 fn
.OSMesaGetCurrentContextFn
= reinterpret_cast<OSMesaGetCurrentContextProc
>(
38 GetGLProcAddress("OSMesaGetCurrentContext"));
39 fn
.OSMesaGetDepthBufferFn
= reinterpret_cast<OSMesaGetDepthBufferProc
>(
40 GetGLProcAddress("OSMesaGetDepthBuffer"));
41 fn
.OSMesaGetIntegervFn
= reinterpret_cast<OSMesaGetIntegervProc
>(
42 GetGLProcAddress("OSMesaGetIntegerv"));
43 fn
.OSMesaGetProcAddressFn
= reinterpret_cast<OSMesaGetProcAddressProc
>(
44 GetGLProcAddress("OSMesaGetProcAddress"));
45 fn
.OSMesaMakeCurrentFn
= reinterpret_cast<OSMesaMakeCurrentProc
>(
46 GetGLProcAddress("OSMesaMakeCurrent"));
47 fn
.OSMesaPixelStoreFn
= reinterpret_cast<OSMesaPixelStoreProc
>(
48 GetGLProcAddress("OSMesaPixelStore"));
51 void DriverOSMESA::InitializeExtensionBindings() {
52 std::string
extensions(GetPlatformExtensions());
54 ALLOW_UNUSED_LOCAL(extensions
);
56 if (g_debugBindingsInitialized
)
57 InitializeDebugBindings();
62 static void GL_BINDING_CALL
Debug_OSMesaColorClamp(GLboolean enable
) {
63 GL_SERVICE_LOG("OSMesaColorClamp"
64 << "(" << GLEnums::GetStringBool(enable
) << ")");
65 g_driver_osmesa
.debug_fn
.OSMesaColorClampFn(enable
);
68 static OSMesaContext GL_BINDING_CALL
69 Debug_OSMesaCreateContext(GLenum format
, OSMesaContext sharelist
) {
70 GL_SERVICE_LOG("OSMesaCreateContext"
71 << "(" << GLEnums::GetStringEnum(format
) << ", " << sharelist
73 OSMesaContext result
=
74 g_driver_osmesa
.debug_fn
.OSMesaCreateContextFn(format
, sharelist
);
75 GL_SERVICE_LOG("GL_RESULT: " << result
);
79 static OSMesaContext GL_BINDING_CALL
80 Debug_OSMesaCreateContextExt(GLenum format
,
84 OSMesaContext sharelist
) {
85 GL_SERVICE_LOG("OSMesaCreateContextExt"
86 << "(" << GLEnums::GetStringEnum(format
) << ", " << depthBits
87 << ", " << stencilBits
<< ", " << accumBits
<< ", "
89 OSMesaContext result
= g_driver_osmesa
.debug_fn
.OSMesaCreateContextExtFn(
90 format
, depthBits
, stencilBits
, accumBits
, sharelist
);
91 GL_SERVICE_LOG("GL_RESULT: " << result
);
95 static void GL_BINDING_CALL
Debug_OSMesaDestroyContext(OSMesaContext ctx
) {
96 GL_SERVICE_LOG("OSMesaDestroyContext"
97 << "(" << ctx
<< ")");
98 g_driver_osmesa
.debug_fn
.OSMesaDestroyContextFn(ctx
);
101 static GLboolean GL_BINDING_CALL
Debug_OSMesaGetColorBuffer(OSMesaContext c
,
106 GL_SERVICE_LOG("OSMesaGetColorBuffer"
107 << "(" << c
<< ", " << static_cast<const void*>(width
) << ", "
108 << static_cast<const void*>(height
) << ", "
109 << static_cast<const void*>(format
) << ", " << buffer
<< ")");
110 GLboolean result
= g_driver_osmesa
.debug_fn
.OSMesaGetColorBufferFn(
111 c
, width
, height
, format
, buffer
);
112 GL_SERVICE_LOG("GL_RESULT: " << result
);
116 static OSMesaContext GL_BINDING_CALL
Debug_OSMesaGetCurrentContext(void) {
117 GL_SERVICE_LOG("OSMesaGetCurrentContext"
120 OSMesaContext result
= g_driver_osmesa
.debug_fn
.OSMesaGetCurrentContextFn();
121 GL_SERVICE_LOG("GL_RESULT: " << result
);
125 static GLboolean GL_BINDING_CALL
126 Debug_OSMesaGetDepthBuffer(OSMesaContext c
,
129 GLint
* bytesPerValue
,
131 GL_SERVICE_LOG("OSMesaGetDepthBuffer"
132 << "(" << c
<< ", " << static_cast<const void*>(width
) << ", "
133 << static_cast<const void*>(height
) << ", "
134 << static_cast<const void*>(bytesPerValue
) << ", " << buffer
136 GLboolean result
= g_driver_osmesa
.debug_fn
.OSMesaGetDepthBufferFn(
137 c
, width
, height
, bytesPerValue
, buffer
);
138 GL_SERVICE_LOG("GL_RESULT: " << result
);
142 static void GL_BINDING_CALL
Debug_OSMesaGetIntegerv(GLint pname
, GLint
* value
) {
143 GL_SERVICE_LOG("OSMesaGetIntegerv"
144 << "(" << pname
<< ", " << static_cast<const void*>(value
)
146 g_driver_osmesa
.debug_fn
.OSMesaGetIntegervFn(pname
, value
);
149 static OSMESAproc GL_BINDING_CALL
150 Debug_OSMesaGetProcAddress(const char* funcName
) {
151 GL_SERVICE_LOG("OSMesaGetProcAddress"
152 << "(" << funcName
<< ")");
153 OSMESAproc result
= g_driver_osmesa
.debug_fn
.OSMesaGetProcAddressFn(funcName
);
154 GL_SERVICE_LOG("GL_RESULT: " << result
);
158 static GLboolean GL_BINDING_CALL
Debug_OSMesaMakeCurrent(OSMesaContext ctx
,
163 GL_SERVICE_LOG("OSMesaMakeCurrent"
164 << "(" << ctx
<< ", " << static_cast<const void*>(buffer
)
165 << ", " << GLEnums::GetStringEnum(type
) << ", " << width
166 << ", " << height
<< ")");
167 GLboolean result
= g_driver_osmesa
.debug_fn
.OSMesaMakeCurrentFn(
168 ctx
, buffer
, type
, width
, height
);
169 GL_SERVICE_LOG("GL_RESULT: " << result
);
173 static void GL_BINDING_CALL
Debug_OSMesaPixelStore(GLint pname
, GLint value
) {
174 GL_SERVICE_LOG("OSMesaPixelStore"
175 << "(" << pname
<< ", " << value
<< ")");
176 g_driver_osmesa
.debug_fn
.OSMesaPixelStoreFn(pname
, value
);
180 void DriverOSMESA::InitializeDebugBindings() {
181 if (!debug_fn
.OSMesaColorClampFn
) {
182 debug_fn
.OSMesaColorClampFn
= fn
.OSMesaColorClampFn
;
183 fn
.OSMesaColorClampFn
= Debug_OSMesaColorClamp
;
185 if (!debug_fn
.OSMesaCreateContextFn
) {
186 debug_fn
.OSMesaCreateContextFn
= fn
.OSMesaCreateContextFn
;
187 fn
.OSMesaCreateContextFn
= Debug_OSMesaCreateContext
;
189 if (!debug_fn
.OSMesaCreateContextExtFn
) {
190 debug_fn
.OSMesaCreateContextExtFn
= fn
.OSMesaCreateContextExtFn
;
191 fn
.OSMesaCreateContextExtFn
= Debug_OSMesaCreateContextExt
;
193 if (!debug_fn
.OSMesaDestroyContextFn
) {
194 debug_fn
.OSMesaDestroyContextFn
= fn
.OSMesaDestroyContextFn
;
195 fn
.OSMesaDestroyContextFn
= Debug_OSMesaDestroyContext
;
197 if (!debug_fn
.OSMesaGetColorBufferFn
) {
198 debug_fn
.OSMesaGetColorBufferFn
= fn
.OSMesaGetColorBufferFn
;
199 fn
.OSMesaGetColorBufferFn
= Debug_OSMesaGetColorBuffer
;
201 if (!debug_fn
.OSMesaGetCurrentContextFn
) {
202 debug_fn
.OSMesaGetCurrentContextFn
= fn
.OSMesaGetCurrentContextFn
;
203 fn
.OSMesaGetCurrentContextFn
= Debug_OSMesaGetCurrentContext
;
205 if (!debug_fn
.OSMesaGetDepthBufferFn
) {
206 debug_fn
.OSMesaGetDepthBufferFn
= fn
.OSMesaGetDepthBufferFn
;
207 fn
.OSMesaGetDepthBufferFn
= Debug_OSMesaGetDepthBuffer
;
209 if (!debug_fn
.OSMesaGetIntegervFn
) {
210 debug_fn
.OSMesaGetIntegervFn
= fn
.OSMesaGetIntegervFn
;
211 fn
.OSMesaGetIntegervFn
= Debug_OSMesaGetIntegerv
;
213 if (!debug_fn
.OSMesaGetProcAddressFn
) {
214 debug_fn
.OSMesaGetProcAddressFn
= fn
.OSMesaGetProcAddressFn
;
215 fn
.OSMesaGetProcAddressFn
= Debug_OSMesaGetProcAddress
;
217 if (!debug_fn
.OSMesaMakeCurrentFn
) {
218 debug_fn
.OSMesaMakeCurrentFn
= fn
.OSMesaMakeCurrentFn
;
219 fn
.OSMesaMakeCurrentFn
= Debug_OSMesaMakeCurrent
;
221 if (!debug_fn
.OSMesaPixelStoreFn
) {
222 debug_fn
.OSMesaPixelStoreFn
= fn
.OSMesaPixelStoreFn
;
223 fn
.OSMesaPixelStoreFn
= Debug_OSMesaPixelStore
;
225 g_debugBindingsInitialized
= true;
228 void DriverOSMESA::ClearBindings() {
229 memset(this, 0, sizeof(*this));
232 void OSMESAApiBase::OSMesaColorClampFn(GLboolean enable
) {
233 driver_
->fn
.OSMesaColorClampFn(enable
);
236 OSMesaContext
OSMESAApiBase::OSMesaCreateContextFn(GLenum format
,
237 OSMesaContext sharelist
) {
238 return driver_
->fn
.OSMesaCreateContextFn(format
, sharelist
);
241 OSMesaContext
OSMESAApiBase::OSMesaCreateContextExtFn(GLenum format
,
245 OSMesaContext sharelist
) {
246 return driver_
->fn
.OSMesaCreateContextExtFn(format
, depthBits
, stencilBits
,
247 accumBits
, sharelist
);
250 void OSMESAApiBase::OSMesaDestroyContextFn(OSMesaContext ctx
) {
251 driver_
->fn
.OSMesaDestroyContextFn(ctx
);
254 GLboolean
OSMESAApiBase::OSMesaGetColorBufferFn(OSMesaContext c
,
259 return driver_
->fn
.OSMesaGetColorBufferFn(c
, width
, height
, format
, buffer
);
262 OSMesaContext
OSMESAApiBase::OSMesaGetCurrentContextFn(void) {
263 return driver_
->fn
.OSMesaGetCurrentContextFn();
266 GLboolean
OSMESAApiBase::OSMesaGetDepthBufferFn(OSMesaContext c
,
269 GLint
* bytesPerValue
,
271 return driver_
->fn
.OSMesaGetDepthBufferFn(c
, width
, height
, bytesPerValue
,
275 void OSMESAApiBase::OSMesaGetIntegervFn(GLint pname
, GLint
* value
) {
276 driver_
->fn
.OSMesaGetIntegervFn(pname
, value
);
279 OSMESAproc
OSMESAApiBase::OSMesaGetProcAddressFn(const char* funcName
) {
280 return driver_
->fn
.OSMesaGetProcAddressFn(funcName
);
283 GLboolean
OSMESAApiBase::OSMesaMakeCurrentFn(OSMesaContext ctx
,
288 return driver_
->fn
.OSMesaMakeCurrentFn(ctx
, buffer
, type
, width
, height
);
291 void OSMESAApiBase::OSMesaPixelStoreFn(GLint pname
, GLint value
) {
292 driver_
->fn
.OSMesaPixelStoreFn(pname
, value
);
295 void TraceOSMESAApi::OSMesaColorClampFn(GLboolean enable
) {
296 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaColorClamp")
297 osmesa_api_
->OSMesaColorClampFn(enable
);
300 OSMesaContext
TraceOSMESAApi::OSMesaCreateContextFn(GLenum format
,
301 OSMesaContext sharelist
) {
302 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaCreateContext")
303 return osmesa_api_
->OSMesaCreateContextFn(format
, sharelist
);
306 OSMesaContext
TraceOSMESAApi::OSMesaCreateContextExtFn(
311 OSMesaContext sharelist
) {
312 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaCreateContextExt")
313 return osmesa_api_
->OSMesaCreateContextExtFn(format
, depthBits
, stencilBits
,
314 accumBits
, sharelist
);
317 void TraceOSMESAApi::OSMesaDestroyContextFn(OSMesaContext ctx
) {
318 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaDestroyContext")
319 osmesa_api_
->OSMesaDestroyContextFn(ctx
);
322 GLboolean
TraceOSMESAApi::OSMesaGetColorBufferFn(OSMesaContext c
,
327 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetColorBuffer")
328 return osmesa_api_
->OSMesaGetColorBufferFn(c
, width
, height
, format
, buffer
);
331 OSMesaContext
TraceOSMESAApi::OSMesaGetCurrentContextFn(void) {
332 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetCurrentContext")
333 return osmesa_api_
->OSMesaGetCurrentContextFn();
336 GLboolean
TraceOSMESAApi::OSMesaGetDepthBufferFn(OSMesaContext c
,
339 GLint
* bytesPerValue
,
341 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetDepthBuffer")
342 return osmesa_api_
->OSMesaGetDepthBufferFn(c
, width
, height
, bytesPerValue
,
346 void TraceOSMESAApi::OSMesaGetIntegervFn(GLint pname
, GLint
* value
) {
347 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetIntegerv")
348 osmesa_api_
->OSMesaGetIntegervFn(pname
, value
);
351 OSMESAproc
TraceOSMESAApi::OSMesaGetProcAddressFn(const char* funcName
) {
352 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetProcAddress")
353 return osmesa_api_
->OSMesaGetProcAddressFn(funcName
);
356 GLboolean
TraceOSMESAApi::OSMesaMakeCurrentFn(OSMesaContext ctx
,
361 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaMakeCurrent")
362 return osmesa_api_
->OSMesaMakeCurrentFn(ctx
, buffer
, type
, width
, height
);
365 void TraceOSMESAApi::OSMesaPixelStoreFn(GLint pname
, GLint value
) {
366 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaPixelStore")
367 osmesa_api_
->OSMesaPixelStoreFn(pname
, value
);