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"));
49 std::string
extensions(GetPlatformExtensions());
51 ALLOW_UNUSED_LOCAL(extensions
);
53 if (g_debugBindingsInitialized
)
54 InitializeDebugBindings();
59 static void GL_BINDING_CALL
Debug_OSMesaColorClamp(GLboolean enable
) {
60 GL_SERVICE_LOG("OSMesaColorClamp"
61 << "(" << GLEnums::GetStringBool(enable
) << ")");
62 g_driver_osmesa
.debug_fn
.OSMesaColorClampFn(enable
);
65 static OSMesaContext GL_BINDING_CALL
66 Debug_OSMesaCreateContext(GLenum format
, OSMesaContext sharelist
) {
67 GL_SERVICE_LOG("OSMesaCreateContext"
68 << "(" << GLEnums::GetStringEnum(format
) << ", " << sharelist
70 OSMesaContext result
=
71 g_driver_osmesa
.debug_fn
.OSMesaCreateContextFn(format
, sharelist
);
72 GL_SERVICE_LOG("GL_RESULT: " << result
);
76 static OSMesaContext GL_BINDING_CALL
77 Debug_OSMesaCreateContextExt(GLenum format
,
81 OSMesaContext sharelist
) {
82 GL_SERVICE_LOG("OSMesaCreateContextExt"
83 << "(" << GLEnums::GetStringEnum(format
) << ", " << depthBits
84 << ", " << stencilBits
<< ", " << accumBits
<< ", "
86 OSMesaContext result
= g_driver_osmesa
.debug_fn
.OSMesaCreateContextExtFn(
87 format
, depthBits
, stencilBits
, accumBits
, sharelist
);
88 GL_SERVICE_LOG("GL_RESULT: " << result
);
92 static void GL_BINDING_CALL
Debug_OSMesaDestroyContext(OSMesaContext ctx
) {
93 GL_SERVICE_LOG("OSMesaDestroyContext"
94 << "(" << ctx
<< ")");
95 g_driver_osmesa
.debug_fn
.OSMesaDestroyContextFn(ctx
);
98 static GLboolean GL_BINDING_CALL
Debug_OSMesaGetColorBuffer(OSMesaContext c
,
103 GL_SERVICE_LOG("OSMesaGetColorBuffer"
104 << "(" << c
<< ", " << static_cast<const void*>(width
) << ", "
105 << static_cast<const void*>(height
) << ", "
106 << static_cast<const void*>(format
) << ", " << buffer
<< ")");
107 GLboolean result
= g_driver_osmesa
.debug_fn
.OSMesaGetColorBufferFn(
108 c
, width
, height
, format
, buffer
);
109 GL_SERVICE_LOG("GL_RESULT: " << result
);
113 static OSMesaContext GL_BINDING_CALL
Debug_OSMesaGetCurrentContext(void) {
114 GL_SERVICE_LOG("OSMesaGetCurrentContext"
117 OSMesaContext result
= g_driver_osmesa
.debug_fn
.OSMesaGetCurrentContextFn();
118 GL_SERVICE_LOG("GL_RESULT: " << result
);
122 static GLboolean GL_BINDING_CALL
123 Debug_OSMesaGetDepthBuffer(OSMesaContext c
,
126 GLint
* bytesPerValue
,
128 GL_SERVICE_LOG("OSMesaGetDepthBuffer"
129 << "(" << c
<< ", " << static_cast<const void*>(width
) << ", "
130 << static_cast<const void*>(height
) << ", "
131 << static_cast<const void*>(bytesPerValue
) << ", " << buffer
133 GLboolean result
= g_driver_osmesa
.debug_fn
.OSMesaGetDepthBufferFn(
134 c
, width
, height
, bytesPerValue
, buffer
);
135 GL_SERVICE_LOG("GL_RESULT: " << result
);
139 static void GL_BINDING_CALL
Debug_OSMesaGetIntegerv(GLint pname
, GLint
* value
) {
140 GL_SERVICE_LOG("OSMesaGetIntegerv"
141 << "(" << pname
<< ", " << static_cast<const void*>(value
)
143 g_driver_osmesa
.debug_fn
.OSMesaGetIntegervFn(pname
, value
);
146 static OSMESAproc GL_BINDING_CALL
147 Debug_OSMesaGetProcAddress(const char* funcName
) {
148 GL_SERVICE_LOG("OSMesaGetProcAddress"
149 << "(" << funcName
<< ")");
150 OSMESAproc result
= g_driver_osmesa
.debug_fn
.OSMesaGetProcAddressFn(funcName
);
151 GL_SERVICE_LOG("GL_RESULT: " << result
);
155 static GLboolean GL_BINDING_CALL
Debug_OSMesaMakeCurrent(OSMesaContext ctx
,
160 GL_SERVICE_LOG("OSMesaMakeCurrent"
161 << "(" << ctx
<< ", " << static_cast<const void*>(buffer
)
162 << ", " << GLEnums::GetStringEnum(type
) << ", " << width
163 << ", " << height
<< ")");
164 GLboolean result
= g_driver_osmesa
.debug_fn
.OSMesaMakeCurrentFn(
165 ctx
, buffer
, type
, width
, height
);
166 GL_SERVICE_LOG("GL_RESULT: " << result
);
170 static void GL_BINDING_CALL
Debug_OSMesaPixelStore(GLint pname
, GLint value
) {
171 GL_SERVICE_LOG("OSMesaPixelStore"
172 << "(" << pname
<< ", " << value
<< ")");
173 g_driver_osmesa
.debug_fn
.OSMesaPixelStoreFn(pname
, value
);
177 void DriverOSMESA::InitializeDebugBindings() {
178 if (!debug_fn
.OSMesaColorClampFn
) {
179 debug_fn
.OSMesaColorClampFn
= fn
.OSMesaColorClampFn
;
180 fn
.OSMesaColorClampFn
= Debug_OSMesaColorClamp
;
182 if (!debug_fn
.OSMesaCreateContextFn
) {
183 debug_fn
.OSMesaCreateContextFn
= fn
.OSMesaCreateContextFn
;
184 fn
.OSMesaCreateContextFn
= Debug_OSMesaCreateContext
;
186 if (!debug_fn
.OSMesaCreateContextExtFn
) {
187 debug_fn
.OSMesaCreateContextExtFn
= fn
.OSMesaCreateContextExtFn
;
188 fn
.OSMesaCreateContextExtFn
= Debug_OSMesaCreateContextExt
;
190 if (!debug_fn
.OSMesaDestroyContextFn
) {
191 debug_fn
.OSMesaDestroyContextFn
= fn
.OSMesaDestroyContextFn
;
192 fn
.OSMesaDestroyContextFn
= Debug_OSMesaDestroyContext
;
194 if (!debug_fn
.OSMesaGetColorBufferFn
) {
195 debug_fn
.OSMesaGetColorBufferFn
= fn
.OSMesaGetColorBufferFn
;
196 fn
.OSMesaGetColorBufferFn
= Debug_OSMesaGetColorBuffer
;
198 if (!debug_fn
.OSMesaGetCurrentContextFn
) {
199 debug_fn
.OSMesaGetCurrentContextFn
= fn
.OSMesaGetCurrentContextFn
;
200 fn
.OSMesaGetCurrentContextFn
= Debug_OSMesaGetCurrentContext
;
202 if (!debug_fn
.OSMesaGetDepthBufferFn
) {
203 debug_fn
.OSMesaGetDepthBufferFn
= fn
.OSMesaGetDepthBufferFn
;
204 fn
.OSMesaGetDepthBufferFn
= Debug_OSMesaGetDepthBuffer
;
206 if (!debug_fn
.OSMesaGetIntegervFn
) {
207 debug_fn
.OSMesaGetIntegervFn
= fn
.OSMesaGetIntegervFn
;
208 fn
.OSMesaGetIntegervFn
= Debug_OSMesaGetIntegerv
;
210 if (!debug_fn
.OSMesaGetProcAddressFn
) {
211 debug_fn
.OSMesaGetProcAddressFn
= fn
.OSMesaGetProcAddressFn
;
212 fn
.OSMesaGetProcAddressFn
= Debug_OSMesaGetProcAddress
;
214 if (!debug_fn
.OSMesaMakeCurrentFn
) {
215 debug_fn
.OSMesaMakeCurrentFn
= fn
.OSMesaMakeCurrentFn
;
216 fn
.OSMesaMakeCurrentFn
= Debug_OSMesaMakeCurrent
;
218 if (!debug_fn
.OSMesaPixelStoreFn
) {
219 debug_fn
.OSMesaPixelStoreFn
= fn
.OSMesaPixelStoreFn
;
220 fn
.OSMesaPixelStoreFn
= Debug_OSMesaPixelStore
;
222 g_debugBindingsInitialized
= true;
225 void DriverOSMESA::ClearBindings() {
226 memset(this, 0, sizeof(*this));
229 void OSMESAApiBase::OSMesaColorClampFn(GLboolean enable
) {
230 driver_
->fn
.OSMesaColorClampFn(enable
);
233 OSMesaContext
OSMESAApiBase::OSMesaCreateContextFn(GLenum format
,
234 OSMesaContext sharelist
) {
235 return driver_
->fn
.OSMesaCreateContextFn(format
, sharelist
);
238 OSMesaContext
OSMESAApiBase::OSMesaCreateContextExtFn(GLenum format
,
242 OSMesaContext sharelist
) {
243 return driver_
->fn
.OSMesaCreateContextExtFn(format
, depthBits
, stencilBits
,
244 accumBits
, sharelist
);
247 void OSMESAApiBase::OSMesaDestroyContextFn(OSMesaContext ctx
) {
248 driver_
->fn
.OSMesaDestroyContextFn(ctx
);
251 GLboolean
OSMESAApiBase::OSMesaGetColorBufferFn(OSMesaContext c
,
256 return driver_
->fn
.OSMesaGetColorBufferFn(c
, width
, height
, format
, buffer
);
259 OSMesaContext
OSMESAApiBase::OSMesaGetCurrentContextFn(void) {
260 return driver_
->fn
.OSMesaGetCurrentContextFn();
263 GLboolean
OSMESAApiBase::OSMesaGetDepthBufferFn(OSMesaContext c
,
266 GLint
* bytesPerValue
,
268 return driver_
->fn
.OSMesaGetDepthBufferFn(c
, width
, height
, bytesPerValue
,
272 void OSMESAApiBase::OSMesaGetIntegervFn(GLint pname
, GLint
* value
) {
273 driver_
->fn
.OSMesaGetIntegervFn(pname
, value
);
276 OSMESAproc
OSMESAApiBase::OSMesaGetProcAddressFn(const char* funcName
) {
277 return driver_
->fn
.OSMesaGetProcAddressFn(funcName
);
280 GLboolean
OSMESAApiBase::OSMesaMakeCurrentFn(OSMesaContext ctx
,
285 return driver_
->fn
.OSMesaMakeCurrentFn(ctx
, buffer
, type
, width
, height
);
288 void OSMESAApiBase::OSMesaPixelStoreFn(GLint pname
, GLint value
) {
289 driver_
->fn
.OSMesaPixelStoreFn(pname
, value
);
292 void TraceOSMESAApi::OSMesaColorClampFn(GLboolean enable
) {
293 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaColorClamp")
294 osmesa_api_
->OSMesaColorClampFn(enable
);
297 OSMesaContext
TraceOSMESAApi::OSMesaCreateContextFn(GLenum format
,
298 OSMesaContext sharelist
) {
299 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaCreateContext")
300 return osmesa_api_
->OSMesaCreateContextFn(format
, sharelist
);
303 OSMesaContext
TraceOSMESAApi::OSMesaCreateContextExtFn(
308 OSMesaContext sharelist
) {
309 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaCreateContextExt")
310 return osmesa_api_
->OSMesaCreateContextExtFn(format
, depthBits
, stencilBits
,
311 accumBits
, sharelist
);
314 void TraceOSMESAApi::OSMesaDestroyContextFn(OSMesaContext ctx
) {
315 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaDestroyContext")
316 osmesa_api_
->OSMesaDestroyContextFn(ctx
);
319 GLboolean
TraceOSMESAApi::OSMesaGetColorBufferFn(OSMesaContext c
,
324 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetColorBuffer")
325 return osmesa_api_
->OSMesaGetColorBufferFn(c
, width
, height
, format
, buffer
);
328 OSMesaContext
TraceOSMESAApi::OSMesaGetCurrentContextFn(void) {
329 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetCurrentContext")
330 return osmesa_api_
->OSMesaGetCurrentContextFn();
333 GLboolean
TraceOSMESAApi::OSMesaGetDepthBufferFn(OSMesaContext c
,
336 GLint
* bytesPerValue
,
338 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetDepthBuffer")
339 return osmesa_api_
->OSMesaGetDepthBufferFn(c
, width
, height
, bytesPerValue
,
343 void TraceOSMESAApi::OSMesaGetIntegervFn(GLint pname
, GLint
* value
) {
344 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetIntegerv")
345 osmesa_api_
->OSMesaGetIntegervFn(pname
, value
);
348 OSMESAproc
TraceOSMESAApi::OSMesaGetProcAddressFn(const char* funcName
) {
349 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetProcAddress")
350 return osmesa_api_
->OSMesaGetProcAddressFn(funcName
);
353 GLboolean
TraceOSMESAApi::OSMesaMakeCurrentFn(OSMesaContext ctx
,
358 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaMakeCurrent")
359 return osmesa_api_
->OSMesaMakeCurrentFn(ctx
, buffer
, type
, width
, height
);
362 void TraceOSMESAApi::OSMesaPixelStoreFn(GLint pname
, GLint value
) {
363 TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaPixelStore")
364 osmesa_api_
->OSMesaPixelStoreFn(pname
, value
);