Chromium Code Reviews| 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 MojoGLES2ControlThunks g_control_thunks = {0}; | |
| 12 static MojoGLES2ImplThunks g_impl_thunks = {0}; | |
| 13 | |
| 14 void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) { | |
| 15 assert(g_control_thunks.GLES2Initialize); | |
| 16 g_control_thunks.GLES2Initialize(async_waiter); | |
| 17 } | |
| 18 | |
| 19 void MojoGLES2Terminate() { | |
| 20 assert(g_control_thunks.GLES2Terminate); | |
| 21 g_control_thunks.GLES2Terminate(); | |
| 22 } | |
| 23 | |
| 24 MojoGLES2Context MojoGLES2CreateContext( | |
| 25 MojoHandle handle, | |
| 26 MojoGLES2ContextLost lost_callback, | |
| 27 void* closure) { | |
| 28 assert(g_control_thunks.GLES2CreateContext); | |
| 29 return g_control_thunks.GLES2CreateContext(handle, lost_callback, closure); | |
| 30 } | |
| 31 | |
| 32 void MojoGLES2DestroyContext(MojoGLES2Context context) { | |
| 33 assert(g_control_thunks.GLES2DestroyContext); | |
| 34 g_control_thunks.GLES2DestroyContext(context); | |
| 35 } | |
| 36 | |
| 37 void MojoGLES2MakeCurrent(MojoGLES2Context context) { | |
| 38 assert(g_control_thunks.GLES2MakeCurrent); | |
| 39 g_control_thunks.GLES2MakeCurrent(context); | |
| 40 } | |
| 41 | |
| 42 void MojoGLES2SwapBuffers() { | |
| 43 assert(g_control_thunks.GLES2SwapBuffers); | |
| 44 g_control_thunks.GLES2SwapBuffers(); | |
| 45 } | |
| 46 | |
| 47 void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { | |
| 48 assert(g_control_thunks.GLES2GetGLES2Interface); | |
| 49 return g_control_thunks.GLES2GetGLES2Interface(context); | |
| 50 } | |
| 51 | |
| 52 void* MojoGLES2GetContextSupport(MojoGLES2Context context) { | |
| 53 assert(g_control_thunks.GLES2GetContextSupport); | |
| 54 return g_control_thunks.GLES2GetContextSupport(context); | |
| 55 } | |
| 56 | |
| 57 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ | |
| 58 ReturnType gl##Function PARAMETERS { \ | |
| 59 assert(g_impl_thunks.Function); \ | |
| 60 return g_impl_thunks.Function ARGUMENTS; \ | |
| 61 } | |
| 62 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" | |
| 63 #undef VISIT_GL_CALL | |
| 64 | |
| 65 // Call this function by looking | |
|
viettrungluu
2014/07/29 00:27:06
If only I knew what this comment (which you copied
| |
| 66 // Always export this api. | |
| 67 #if defined(WIN32) | |
| 68 #define THUNK_EXPORT __declspec(dllexport) | |
|
viettrungluu
2014/07/29 00:27:06
Could you factor THUNK_EXPORT out into a header fi
| |
| 69 #else | |
| 70 #define THUNK_EXPORT __attribute__((visibility("default"))) | |
| 71 #endif | |
| 72 | |
| 73 extern "C" THUNK_EXPORT size_t MojoSetGLES2ControlThunks( | |
| 74 const MojoGLES2ControlThunks* gles2_control_thunks) { | |
| 75 if (gles2_control_thunks->size >= sizeof(g_control_thunks)) { | |
|
viettrungluu
2014/07/29 00:27:06
nit (here and below): Mostly, we omit the braces w
| |
| 76 g_control_thunks = *gles2_control_thunks; | |
| 77 } | |
| 78 return sizeof(g_control_thunks); | |
| 79 } | |
| 80 | |
| 81 extern "C" THUNK_EXPORT size_t MojoSetGLES2ImplThunks( | |
| 82 const MojoGLES2ImplThunks* gles2_impl_thunks) { | |
| 83 if (gles2_impl_thunks->size >= sizeof(g_impl_thunks)) { | |
| 84 g_impl_thunks = *gles2_impl_thunks; | |
| 85 } | |
| 86 return sizeof(g_impl_thunks); | |
| 87 } | |
| 88 | |
| 89 } // extern "C" | |
| OLD | NEW |