Index: mojo/public/platform/nacl/libmojo.cc |
diff --git a/mojo/public/platform/nacl/libmojo.cc b/mojo/public/platform/nacl/libmojo.cc |
index 391f6fb3665dbbaff380acf8593b8606d8d28b34..2355c033fd2342dd29749203bc133d3dab7bda4d 100644 |
--- a/mojo/public/platform/nacl/libmojo.cc |
+++ b/mojo/public/platform/nacl/libmojo.cc |
@@ -225,3 +225,88 @@ MojoResult _MojoGetInitialHandle(MojoHandle* handle) { |
return irt_mojo->_MojoGetInitialHandle(handle); |
} |
+bool g_irt_mgl_valid = false; |
Mark Seaborn
2015/10/17 01:08:08
I realise you are copying the existing pattern for
Petr Hosek
2015/10/17 01:51:13
Done.
|
+struct nacl_irt_mgl g_irt_mgl; |
+ |
+struct nacl_irt_mgl* get_irt_mgl() { |
Mark Seaborn
2015/10/17 01:08:08
Chromium naming style would be GetIrtMgl()
Petr Hosek
2015/10/17 01:51:13
Done.
|
+ if (!g_irt_mgl_valid) { |
+ size_t rc = nacl_interface_query(NACL_IRT_MGL_v0_1, &g_irt_mgl, |
+ sizeof(g_irt_mgl)); |
+ if (rc != sizeof(g_irt_mgl)) |
+ return NULL; |
+ else |
Mark Seaborn
2015/10/17 01:08:08
Nit: You could drop the 'else' since this is after
Petr Hosek
2015/10/17 01:51:13
Done.
|
+ g_irt_mgl_valid = true; |
+ } |
+ return &g_irt_mgl; |
+} |
+ |
+MGLContext MGLCreateContext(MGLOpenGLAPIVersion version, |
+ MojoHandle command_buffer_handle, |
+ MGLContext share_group, |
+ MGLContextLostCallback lost_callback, |
+ void* lost_callback_closure, |
+ const struct MojoAsyncWaiter* async_waiter) { |
+ struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); |
+ if (irt_mgl == NULL) |
+ return MGL_NO_CONTEXT; |
+ return irt_mgl->MGLCreateContext(version, |
+ command_buffer_handle, |
+ share_group, |
+ lost_callback, |
+ lost_callback_closure, |
+ async_waiter); |
+} |
+ |
+void MGLDestroyContext(MGLContext context) { |
+ struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); |
+ if (irt_mgl != NULL) |
+ irt_mgl->MGLDestroyContext(context); |
+} |
+ |
+void MGLMakeCurrent(MGLContext context) { |
+ struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); |
+ if (irt_mgl != NULL) |
+ irt_mgl->MGLMakeCurrent(context); |
+} |
+ |
+MGLContext MGLGetCurrentContext(void) { |
+ struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); |
+ if (irt_mgl == NULL) |
+ return MGL_NO_CONTEXT; |
+ return irt_mgl->MGLGetCurrentContext(); |
+} |
+ |
+MGLMustCastToProperFunctionPointerType MGLGetProcAddress(const char* name) { |
+ struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); |
+ if (irt_mgl == NULL) |
+ return NULL; |
+ return irt_mgl->MGLGetProcAddress(name); |
+} |
+ |
+bool g_irt_mgl_onscreen_valid = false; |
+struct nacl_irt_mgl_onscreen g_irt_mgl_onscreen; |
+ |
+struct nacl_irt_mgl_onscreen* get_irt_mgl_onscreen() { |
+ if (!g_irt_mgl_onscreen_valid) { |
+ size_t rc = nacl_interface_query(NACL_IRT_MGL_ONSCREEN_v0_1, |
+ &g_irt_mgl_onscreen, |
+ sizeof(g_irt_mgl_onscreen)); |
+ if (rc != sizeof(g_irt_mgl_onscreen)) |
+ return NULL; |
+ else |
+ g_irt_mgl_onscreen_valid = true; |
+ } |
+ return &g_irt_mgl_onscreen; |
+} |
+ |
+void MGLResizeSurface(uint32_t width, uint32_t height) { |
+ struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = get_irt_mgl_onscreen(); |
+ if (irt_mgl_onscreen != NULL) |
+ irt_mgl_onscreen->MGLResizeSurface(width, height); |
+} |
+ |
+void MGLSwapBuffers(void) { |
+ struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = get_irt_mgl_onscreen(); |
+ if (irt_mgl_onscreen != NULL) |
+ irt_mgl_onscreen->MGLSwapBuffers(); |
+} |