OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // WARNING this file was generated by generate_nacl_bindings.py | 5 // WARNING this file was generated by generate_nacl_bindings.py |
6 // Do not edit by hand. | 6 // Do not edit by hand. |
7 | 7 |
8 #include "mojo/public/c/system/core.h" | 8 #include "mojo/public/c/system/core.h" |
9 #include "mojo/public/platform/nacl/mojo_irt.h" | 9 #include "mojo/public/platform/nacl/mojo_irt.h" |
10 #include "native_client/src/public/chrome_main.h" | 10 #include "native_client/src/public/chrome_main.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 handles, num_handles, flags); | 218 handles, num_handles, flags); |
219 } | 219 } |
220 | 220 |
221 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { | 221 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { |
222 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); | 222 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
223 if (irt_mojo == NULL) | 223 if (irt_mojo == NULL) |
224 return MOJO_RESULT_INTERNAL; | 224 return MOJO_RESULT_INTERNAL; |
225 return irt_mojo->_MojoGetInitialHandle(handle); | 225 return irt_mojo->_MojoGetInitialHandle(handle); |
226 } | 226 } |
227 | 227 |
228 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.
| |
229 struct nacl_irt_mgl g_irt_mgl; | |
230 | |
231 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.
| |
232 if (!g_irt_mgl_valid) { | |
233 size_t rc = nacl_interface_query(NACL_IRT_MGL_v0_1, &g_irt_mgl, | |
234 sizeof(g_irt_mgl)); | |
235 if (rc != sizeof(g_irt_mgl)) | |
236 return NULL; | |
237 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.
| |
238 g_irt_mgl_valid = true; | |
239 } | |
240 return &g_irt_mgl; | |
241 } | |
242 | |
243 MGLContext MGLCreateContext(MGLOpenGLAPIVersion version, | |
244 MojoHandle command_buffer_handle, | |
245 MGLContext share_group, | |
246 MGLContextLostCallback lost_callback, | |
247 void* lost_callback_closure, | |
248 const struct MojoAsyncWaiter* async_waiter) { | |
249 struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); | |
250 if (irt_mgl == NULL) | |
251 return MGL_NO_CONTEXT; | |
252 return irt_mgl->MGLCreateContext(version, | |
253 command_buffer_handle, | |
254 share_group, | |
255 lost_callback, | |
256 lost_callback_closure, | |
257 async_waiter); | |
258 } | |
259 | |
260 void MGLDestroyContext(MGLContext context) { | |
261 struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); | |
262 if (irt_mgl != NULL) | |
263 irt_mgl->MGLDestroyContext(context); | |
264 } | |
265 | |
266 void MGLMakeCurrent(MGLContext context) { | |
267 struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); | |
268 if (irt_mgl != NULL) | |
269 irt_mgl->MGLMakeCurrent(context); | |
270 } | |
271 | |
272 MGLContext MGLGetCurrentContext(void) { | |
273 struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); | |
274 if (irt_mgl == NULL) | |
275 return MGL_NO_CONTEXT; | |
276 return irt_mgl->MGLGetCurrentContext(); | |
277 } | |
278 | |
279 MGLMustCastToProperFunctionPointerType MGLGetProcAddress(const char* name) { | |
280 struct nacl_irt_mgl* irt_mgl = get_irt_mgl(); | |
281 if (irt_mgl == NULL) | |
282 return NULL; | |
283 return irt_mgl->MGLGetProcAddress(name); | |
284 } | |
285 | |
286 bool g_irt_mgl_onscreen_valid = false; | |
287 struct nacl_irt_mgl_onscreen g_irt_mgl_onscreen; | |
288 | |
289 struct nacl_irt_mgl_onscreen* get_irt_mgl_onscreen() { | |
290 if (!g_irt_mgl_onscreen_valid) { | |
291 size_t rc = nacl_interface_query(NACL_IRT_MGL_ONSCREEN_v0_1, | |
292 &g_irt_mgl_onscreen, | |
293 sizeof(g_irt_mgl_onscreen)); | |
294 if (rc != sizeof(g_irt_mgl_onscreen)) | |
295 return NULL; | |
296 else | |
297 g_irt_mgl_onscreen_valid = true; | |
298 } | |
299 return &g_irt_mgl_onscreen; | |
300 } | |
301 | |
302 void MGLResizeSurface(uint32_t width, uint32_t height) { | |
303 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = get_irt_mgl_onscreen(); | |
304 if (irt_mgl_onscreen != NULL) | |
305 irt_mgl_onscreen->MGLResizeSurface(width, height); | |
306 } | |
307 | |
308 void MGLSwapBuffers(void) { | |
309 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = get_irt_mgl_onscreen(); | |
310 if (irt_mgl_onscreen != NULL) | |
311 irt_mgl_onscreen->MGLSwapBuffers(); | |
312 } | |
OLD | NEW |