Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: mojo/public/platform/nacl/libmojo.cc

Issue 1413683003: Expose MGL interface through NaCl IRT (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Combine anonymous namespaces into one Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
Mark Seaborn 2015/10/20 16:26:07 Oh, I just noticed this comment: "Do not edit by h
Petr Hosek 2015/10/20 21:38:31 Done.
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 bool g_irt_mgl_valid = false;
37 struct nacl_irt_mgl g_irt_mgl;
38
39 struct nacl_irt_mgl* GetIrtMGL() {
40 if (!g_irt_mgl_valid) {
41 size_t rc = nacl_interface_query(NACL_IRT_MGL_v0_1, &g_irt_mgl,
42 sizeof(g_irt_mgl));
43 if (rc != sizeof(g_irt_mgl))
44 return NULL;
45 g_irt_mgl_valid = true;
46 }
47 return &g_irt_mgl;
48 }
49
50 bool g_irt_mgl_onscreen_valid = false;
51 struct nacl_irt_mgl_onscreen g_irt_mgl_onscreen;
52
53 struct nacl_irt_mgl_onscreen* GetIrtMGLOnScreen() {
54 if (!g_irt_mgl_onscreen_valid) {
55 size_t rc = nacl_interface_query(NACL_IRT_MGL_ONSCREEN_v0_1,
56 &g_irt_mgl_onscreen,
57 sizeof(g_irt_mgl_onscreen));
58 if (rc != sizeof(g_irt_mgl_onscreen))
59 return NULL;
60 g_irt_mgl_onscreen_valid = true;
61 }
62 return &g_irt_mgl_onscreen;
63 }
64
65 bool g_irt_mgl_signal_sync_point_valid = false;
66 struct nacl_irt_mgl_signal_sync_point g_irt_mgl_signal_sync_point;
67
68 struct nacl_irt_mgl_signal_sync_point* GetIrtMGLSignalSyncPoint() {
69 if (!g_irt_mgl_signal_sync_point_valid) {
70 size_t rc = nacl_interface_query(NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1,
71 &g_irt_mgl_signal_sync_point,
72 sizeof(g_irt_mgl_signal_sync_point));
73 if (rc != sizeof(g_irt_mgl_signal_sync_point))
74 return NULL;
75 g_irt_mgl_signal_sync_point_valid = true;
76 }
77 return &g_irt_mgl_signal_sync_point;
78 }
79
80 }
81
35 MojoResult MojoCreateSharedBuffer( 82 MojoResult MojoCreateSharedBuffer(
36 const struct MojoCreateSharedBufferOptions* options, 83 const struct MojoCreateSharedBufferOptions* options,
37 uint64_t num_bytes, 84 uint64_t num_bytes,
38 MojoHandle* shared_buffer_handle) { 85 MojoHandle* shared_buffer_handle) {
39 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); 86 struct nacl_irt_mojo* irt_mojo = get_irt_mojo();
40 if (irt_mojo == NULL) 87 if (irt_mojo == NULL)
41 return MOJO_RESULT_INTERNAL; 88 return MOJO_RESULT_INTERNAL;
42 return irt_mojo->MojoCreateSharedBuffer(options, num_bytes, 89 return irt_mojo->MojoCreateSharedBuffer(options, num_bytes,
43 shared_buffer_handle); 90 shared_buffer_handle);
44 } 91 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 handles, num_handles, flags); 265 handles, num_handles, flags);
219 } 266 }
220 267
221 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { 268 MojoResult _MojoGetInitialHandle(MojoHandle* handle) {
222 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); 269 struct nacl_irt_mojo* irt_mojo = get_irt_mojo();
223 if (irt_mojo == NULL) 270 if (irt_mojo == NULL)
224 return MOJO_RESULT_INTERNAL; 271 return MOJO_RESULT_INTERNAL;
225 return irt_mojo->_MojoGetInitialHandle(handle); 272 return irt_mojo->_MojoGetInitialHandle(handle);
226 } 273 }
227 274
275 MGLContext MGLCreateContext(MGLOpenGLAPIVersion version,
276 MojoHandle command_buffer_handle,
277 MGLContext share_group,
278 MGLContextLostCallback lost_callback,
279 void* lost_callback_closure,
280 const struct MojoAsyncWaiter* async_waiter) {
281 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
282 if (irt_mgl == NULL)
283 return MGL_NO_CONTEXT;
284 return irt_mgl->MGLCreateContext(version,
285 command_buffer_handle,
286 share_group,
287 lost_callback,
288 lost_callback_closure,
289 async_waiter);
290 }
291
292 void MGLDestroyContext(MGLContext context) {
293 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
294 if (irt_mgl != NULL)
295 irt_mgl->MGLDestroyContext(context);
296 }
297
298 void MGLMakeCurrent(MGLContext context) {
299 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
300 if (irt_mgl != NULL)
301 irt_mgl->MGLMakeCurrent(context);
302 }
303
304 MGLContext MGLGetCurrentContext(void) {
305 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
306 if (irt_mgl == NULL)
307 return MGL_NO_CONTEXT;
308 return irt_mgl->MGLGetCurrentContext();
309 }
310
311 MGLMustCastToProperFunctionPointerType MGLGetProcAddress(const char* name) {
312 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
313 if (irt_mgl == NULL)
314 return NULL;
315 return irt_mgl->MGLGetProcAddress(name);
316 }
317
318 void MGLResizeSurface(uint32_t width, uint32_t height) {
319 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = GetIrtMGLOnScreen();
320 if (irt_mgl_onscreen != NULL)
321 irt_mgl_onscreen->MGLResizeSurface(width, height);
322 }
323
324 void MGLSwapBuffers(void) {
325 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = GetIrtMGLOnScreen();
326 if (irt_mgl_onscreen != NULL)
327 irt_mgl_onscreen->MGLSwapBuffers();
328 }
329
330 void MGLSignalSyncPoint(uint32_t sync_point,
331 MGLSignalSyncPointCallback callback,
332 void* closure) {
333 struct nacl_irt_mgl_signal_sync_point *irt_mgl_signal_sync_point =
334 GetIrtMGLSignalSyncPoint();
335 if (irt_mgl_signal_sync_point != NULL)
336 irt_mgl_signal_sync_point->MGLSignalSyncPoint(
337 sync_point, callback, closure);
338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698