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

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

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « mojo/public/platform/nacl/mgl_irt.h ('k') | mojo/public/platform/nacl/mojo_initial_handle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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/nacl/mgl_irt.h"
6 #include "native_client/src/untrusted/irt/irt.h"
7
8 namespace {
9
10 bool g_irt_mgl_valid = false;
11 struct nacl_irt_mgl g_irt_mgl;
12
13 struct nacl_irt_mgl* GetIrtMGL() {
14 if (!g_irt_mgl_valid) {
15 size_t rc = nacl_interface_query(NACL_IRT_MGL_v0_1, &g_irt_mgl,
16 sizeof(g_irt_mgl));
17 if (rc != sizeof(g_irt_mgl))
18 return nullptr;
19 g_irt_mgl_valid = true;
20 }
21 return &g_irt_mgl;
22 }
23
24 bool g_irt_mgl_onscreen_valid = false;
25 struct nacl_irt_mgl_onscreen g_irt_mgl_onscreen;
26
27 struct nacl_irt_mgl_onscreen* GetIrtMGLOnScreen() {
28 if (!g_irt_mgl_onscreen_valid) {
29 size_t rc = nacl_interface_query(NACL_IRT_MGL_ONSCREEN_v0_1,
30 &g_irt_mgl_onscreen,
31 sizeof(g_irt_mgl_onscreen));
32 if (rc != sizeof(g_irt_mgl_onscreen))
33 return nullptr;
34 g_irt_mgl_onscreen_valid = true;
35 }
36 return &g_irt_mgl_onscreen;
37 }
38
39 bool g_irt_mgl_signal_sync_point_valid = false;
40 struct nacl_irt_mgl_signal_sync_point g_irt_mgl_signal_sync_point;
41
42 struct nacl_irt_mgl_signal_sync_point* GetIrtMGLSignalSyncPoint() {
43 if (!g_irt_mgl_signal_sync_point_valid) {
44 size_t rc = nacl_interface_query(NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1,
45 &g_irt_mgl_signal_sync_point,
46 sizeof(g_irt_mgl_signal_sync_point));
47 if (rc != sizeof(g_irt_mgl_signal_sync_point))
48 return nullptr;
49 g_irt_mgl_signal_sync_point_valid = true;
50 }
51 return &g_irt_mgl_signal_sync_point;
52 }
53
54 }
55
56 MGLContext MGLCreateContext(MGLOpenGLAPIVersion version,
57 MojoHandle command_buffer_handle,
58 MGLContext share_group,
59 MGLContextLostCallback lost_callback,
60 void* lost_callback_closure,
61 const struct MojoAsyncWaiter* async_waiter) {
62 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
63 if (!irt_mgl)
64 return MGL_NO_CONTEXT;
65 return irt_mgl->MGLCreateContext(version,
66 command_buffer_handle,
67 share_group,
68 lost_callback,
69 lost_callback_closure,
70 async_waiter);
71 }
72
73 void MGLDestroyContext(MGLContext context) {
74 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
75 if (irt_mgl)
76 irt_mgl->MGLDestroyContext(context);
77 }
78
79 void MGLMakeCurrent(MGLContext context) {
80 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
81 if (irt_mgl)
82 irt_mgl->MGLMakeCurrent(context);
83 }
84
85 MGLContext MGLGetCurrentContext(void) {
86 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
87 if (!irt_mgl)
88 return MGL_NO_CONTEXT;
89 return irt_mgl->MGLGetCurrentContext();
90 }
91
92 MGLMustCastToProperFunctionPointerType MGLGetProcAddress(const char* name) {
93 struct nacl_irt_mgl* irt_mgl = GetIrtMGL();
94 if (!irt_mgl)
95 return nullptr;
96 return irt_mgl->MGLGetProcAddress(name);
97 }
98
99 void MGLResizeSurface(uint32_t width, uint32_t height) {
100 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = GetIrtMGLOnScreen();
101 if (irt_mgl_onscreen)
102 irt_mgl_onscreen->MGLResizeSurface(width, height);
103 }
104
105 void MGLSwapBuffers(void) {
106 struct nacl_irt_mgl_onscreen* irt_mgl_onscreen = GetIrtMGLOnScreen();
107 if (irt_mgl_onscreen)
108 irt_mgl_onscreen->MGLSwapBuffers();
109 }
110
111 void MGLSignalSyncPoint(uint32_t sync_point,
112 MGLSignalSyncPointCallback callback,
113 void* closure) {
114 struct nacl_irt_mgl_signal_sync_point *irt_mgl_signal_sync_point =
115 GetIrtMGLSignalSyncPoint();
116 if (irt_mgl_signal_sync_point)
117 irt_mgl_signal_sync_point->MGLSignalSyncPoint(
118 sync_point, callback, closure);
119 }
OLDNEW
« no previous file with comments | « mojo/public/platform/nacl/mgl_irt.h ('k') | mojo/public/platform/nacl/mojo_initial_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698