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" |
11 #include "native_client/src/public/imc_syscalls.h" | 11 #include "native_client/src/public/imc_syscalls.h" |
12 #include "native_client/src/public/imc_types.h" | 12 #include "native_client/src/public/imc_types.h" |
13 #include "native_client/src/untrusted/irt/irt.h" | 13 #include "native_client/src/untrusted/irt/irt.h" |
14 | 14 |
15 // The value for this FD must not conflict with uses inside Chromium. However, | 15 // The value for this FD must not conflict with uses inside Chromium. However, |
16 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define | 16 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define |
17 // from there. | 17 // from there. |
18 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3) | 18 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3) |
19 | 19 |
20 namespace { | |
21 | |
20 bool g_irt_mojo_valid = false; | 22 bool g_irt_mojo_valid = false; |
21 struct nacl_irt_mojo g_irt_mojo; | 23 struct nacl_irt_mojo g_irt_mojo; |
22 | 24 |
23 struct nacl_irt_mojo* get_irt_mojo() { | 25 struct nacl_irt_mojo* get_irt_mojo() { |
24 if (!g_irt_mojo_valid) { | 26 if (!g_irt_mojo_valid) { |
25 size_t rc = nacl_interface_query(NACL_IRT_MOJO_v0_1, &g_irt_mojo, | 27 size_t rc = nacl_interface_query(NACL_IRT_MOJO_v0_1, &g_irt_mojo, |
26 sizeof(g_irt_mojo)); | 28 sizeof(g_irt_mojo)); |
27 if (rc != sizeof(g_irt_mojo)) | 29 if (rc != sizeof(g_irt_mojo)) |
28 return NULL; | 30 return NULL; |
29 else | 31 g_irt_mojo_valid = true; |
30 g_irt_mojo_valid = true; | |
31 } | 32 } |
32 return &g_irt_mojo; | 33 return &g_irt_mojo; |
33 } | 34 } |
34 | 35 |
36 } | |
37 | |
35 MojoResult MojoCreateSharedBuffer( | 38 MojoResult MojoCreateSharedBuffer( |
36 const struct MojoCreateSharedBufferOptions* options, | 39 const struct MojoCreateSharedBufferOptions* options, |
37 uint64_t num_bytes, | 40 uint64_t num_bytes, |
38 MojoHandle* shared_buffer_handle) { | 41 MojoHandle* shared_buffer_handle) { |
39 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); | 42 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
40 if (irt_mojo == NULL) | 43 if (irt_mojo == NULL) |
41 return MOJO_RESULT_INTERNAL; | 44 return MOJO_RESULT_INTERNAL; |
42 return irt_mojo->MojoCreateSharedBuffer(options, num_bytes, | 45 return irt_mojo->MojoCreateSharedBuffer(options, num_bytes, |
43 shared_buffer_handle); | 46 shared_buffer_handle); |
44 } | 47 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 handles, num_handles, flags); | 221 handles, num_handles, flags); |
219 } | 222 } |
220 | 223 |
221 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { | 224 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { |
222 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); | 225 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
223 if (irt_mojo == NULL) | 226 if (irt_mojo == NULL) |
224 return MOJO_RESULT_INTERNAL; | 227 return MOJO_RESULT_INTERNAL; |
225 return irt_mojo->_MojoGetInitialHandle(handle); | 228 return irt_mojo->_MojoGetInitialHandle(handle); |
226 } | 229 } |
227 | 230 |
231 namespace { | |
232 | |
Sean Klein
2015/10/17 02:03:14
Is there a reason why you made a bunch of anonymou
Petr Hosek
2015/10/20 00:11:32
Done.
| |
233 bool g_irt_mgl_valid = false; | |
234 struct nacl_irt_mgl g_irt_mgl; | |
235 | |
236 struct nacl_irt_mgl* GetIrtMGL() { | |
237 if (!g_irt_mgl_valid) { | |
238 size_t rc = nacl_interface_query(NACL_IRT_MGL_v0_1, &g_irt_mgl, | |
239 sizeof(g_irt_mgl)); | |
240 if (rc != sizeof(g_irt_mgl)) | |
241 return NULL; | |
242 g_irt_mgl_valid = true; | |
243 } | |
244 return &g_irt_mgl; | |
245 } | |
246 | |
247 } | |
248 | |
249 MGLContext MGLCreateContext(MGLOpenGLAPIVersion version, | |
250 MojoHandle command_buffer_handle, | |
251 MGLContext share_group, | |
252 MGLContextLostCallback lost_callback, | |
253 void* lost_callback_closure, | |
254 const struct MojoAsyncWaiter* async_waiter) { | |
255 struct nacl_irt_mgl* irt_mgl = GetIrtMGL(); | |
256 if (irt_mgl == NULL) | |
257 return MGL_NO_CONTEXT; | |
258 return irt_mgl->MGLCreateContext(version, | |
259 command_buffer_handle, | |
260 share_group, | |
261 lost_callback, | |
262 lost_callback_closure, | |
263 async_waiter); | |
264 } | |
265 | |
266 void MGLDestroyContext(MGLContext context) { | |
267 struct nacl_irt_mgl* irt_mgl = GetIrtMGL(); | |
268 if (irt_mgl != NULL) | |
269 irt_mgl->MGLDestroyContext(context); | |
270 } | |
271 | |
272 void MGLMakeCurrent(MGLContext context) { | |
273 struct nacl_irt_mgl* irt_mgl = GetIrtMGL(); | |
274 if (irt_mgl != NULL) | |
275 irt_mgl->MGLMakeCurrent(context); | |
276 } | |
277 | |
278 MGLContext MGLGetCurrentContext(void) { | |
279 struct nacl_irt_mgl* irt_mgl = GetIrtMGL(); | |
280 if (irt_mgl == NULL) | |
281 return MGL_NO_CONTEXT; | |
282 return irt_mgl->MGLGetCurrentContext(); | |
283 } | |
284 | |
285 MGLMustCastToProperFunctionPointerType MGLGetProcAddress(const char* name) { | |
286 struct nacl_irt_mgl* irt_mgl = GetIrtMGL(); | |
287 if (irt_mgl == NULL) | |
288 return NULL; | |
289 return irt_mgl->MGLGetProcAddress(name); | |
290 } | |
291 | |
292 namespace { | |
293 | |
294 bool g_irt_mgl_onscreen_valid = false; | |
295 struct nacl_irt_mgl_onscreen g_irt_mgl_onscreen; | |
296 | |
297 struct nacl_irt_mgl_onscreen* GetIrtMGLOnScreen() { | |
298 if (!g_irt_mgl_onscreen_valid) { | |
299 size_t rc = nacl_interface_query(NACL_IRT_MGL_ONSCREEN_v0_1, | |
300 &g_irt_mgl_onscreen, | |
301 sizeof(g_irt_mgl_onscreen)); | |
302 if (rc != sizeof(g_irt_mgl_onscreen)) | |
303 return NULL; | |
304 g_irt_mgl_onscreen_valid = true; | |
305 } | |
306 return &g_irt_mgl_onscreen; | |
307 } | |
308 | |
309 } | |
310 | |
311 void MGLResizeSurface(uint32_t width, uint32_t height) { | |
312 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = GetIrtMGLOnScreen(); | |
313 if (irt_mgl_onscreen != NULL) | |
314 irt_mgl_onscreen->MGLResizeSurface(width, height); | |
315 } | |
316 | |
317 void MGLSwapBuffers(void) { | |
318 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = GetIrtMGLOnScreen(); | |
319 if (irt_mgl_onscreen != NULL) | |
320 irt_mgl_onscreen->MGLSwapBuffers(); | |
321 } | |
322 | |
323 namespace { | |
324 | |
325 bool g_irt_mgl_signal_sync_point_valid = false; | |
326 struct nacl_irt_mgl_signal_sync_point g_irt_mgl_signal_sync_point; | |
327 | |
328 struct nacl_irt_mgl_signal_sync_point* GetIrtMGLSignalSyncPoint() { | |
329 if (!g_irt_mgl_signal_sync_point_valid) { | |
330 size_t rc = nacl_interface_query(NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1, | |
331 &g_irt_mgl_signal_sync_point, | |
332 sizeof(g_irt_mgl_signal_sync_point)); | |
333 if (rc != sizeof(g_irt_mgl_signal_sync_point)) | |
334 return NULL; | |
335 g_irt_mgl_signal_sync_point_valid = true; | |
336 } | |
337 return &g_irt_mgl_signal_sync_point; | |
338 } | |
339 | |
340 } | |
341 | |
342 void MGLSignalSyncPoint(uint32_t sync_point, | |
343 MGLSignalSyncPointCallback callback, | |
344 void* closure) { | |
345 struct nacl_irt_mgl_signal_sync_point *irt_mgl_signal_sync_point = | |
346 GetIrtMGLSignalSyncPoint(); | |
347 if (irt_mgl_signal_sync_point != NULL) | |
348 irt_mgl_signal_sync_point->MGLSignalSyncPoint( | |
349 sync_point, callback, closure); | |
350 } | |
OLD | NEW |