OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "mojo/public/platform/native/gles2_thunks.h" |
| 6 |
| 7 #include <assert.h> |
| 8 |
| 9 extern "C" { |
| 10 |
| 11 static MojoGLES2Thunks g_thunks = {0}; |
| 12 |
| 13 void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) { |
| 14 assert(g_thunks.GLES2Initialize); |
| 15 g_thunks.GLES2Initialize(async_waiter); |
| 16 } |
| 17 |
| 18 void MojoGLES2Terminate() { |
| 19 assert(g_thunks.GLES2Terminate); |
| 20 g_thunks.GLES2Terminate(); |
| 21 } |
| 22 |
| 23 MojoGLES2Context MojoGLES2CreateContext( |
| 24 MojoHandle handle, |
| 25 MojoGLES2ContextLost lost_callback, |
| 26 void* closure) { |
| 27 assert(g_thunks.GLES2CreateContext); |
| 28 return g_thunks.GLES2CreateContext(handle, lost_callback, closure); |
| 29 } |
| 30 |
| 31 void MojoGLES2DestroyContext(MojoGLES2Context context) { |
| 32 assert(g_thunks.GLES2DestroyContext); |
| 33 g_thunks.GLES2DestroyContext(context); |
| 34 } |
| 35 |
| 36 void MojoGLES2MakeCurrent(MojoGLES2Context context) { |
| 37 assert(g_thunks.GLES2MakeCurrent); |
| 38 g_thunks.GLES2MakeCurrent(context); |
| 39 } |
| 40 |
| 41 void MojoGLES2SwapBuffers() { |
| 42 assert(g_thunks.GLES2SwapBuffers); |
| 43 g_thunks.GLES2SwapBuffers(); |
| 44 } |
| 45 |
| 46 void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { |
| 47 assert(g_thunks.GLES2GetGLES2Interface); |
| 48 return g_thunks.GLES2GetGLES2Interface(context); |
| 49 } |
| 50 |
| 51 void* MojoGLES2GetContextSupport(MojoGLES2Context context) { |
| 52 assert(g_thunks.GLES2GetContextSupport); |
| 53 return g_thunks.GLES2GetContextSupport(context); |
| 54 } |
| 55 |
| 56 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ |
| 57 ReturnType gl##Function PARAMETERS { \ |
| 58 assert(g_thunks.Function); \ |
| 59 return g_thunks.Function ARGUMENTS; \ |
| 60 } |
| 61 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" |
| 62 #undef VISIT_GL_CALL |
| 63 |
| 64 // Call this function by looking |
| 65 // Always export this api. |
| 66 #if defined(WIN32) |
| 67 #define THUNK_EXPORT __declspec(dllexport) |
| 68 #else |
| 69 #define THUNK_EXPORT __attribute__((visibility("default"))) |
| 70 #endif |
| 71 |
| 72 extern "C" THUNK_EXPORT size_t MojoSetGLES2Thunks( |
| 73 const MojoGLES2Thunks* gles2_thunks) { |
| 74 if (gles2_thunks->size >= sizeof(g_thunks)) { |
| 75 g_thunks = *gles2_thunks; |
| 76 } |
| 77 return sizeof(g_thunks); |
| 78 } |
| 79 |
| 80 } // extern "C" |
OLD | NEW |