OLD | NEW |
| (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 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_MGL_THUNKS_H_ | |
6 #define MOJO_PUBLIC_PLATFORM_NATIVE_MGL_THUNKS_H_ | |
7 | |
8 #include <MGL/mgl.h> | |
9 #include <stddef.h> | |
10 | |
11 // Structure used to bind the interface which manipulates MGL contexts to a | |
12 // DSO to theose of the embedder. | |
13 // | |
14 // This is the ABI between the embedder and the DSO. It can only have new | |
15 // functions added to the end. No other changes are supported. | |
16 #pragma pack(push, 8) | |
17 struct MGLThunks { | |
18 size_t size; // Should be set to sizeof(MGLThunks). | |
19 | |
20 MGLContext (*MGLCreateContext)(MGLOpenGLAPIVersion version, | |
21 MojoHandle command_buffer_handle, | |
22 MGLContext share_group, | |
23 MGLContextLostCallback lost_callback, | |
24 void* lost_callback_closure, | |
25 const struct MojoAsyncWaiter* async_waiter); | |
26 void (*MGLDestroyContext)(MGLContext context); | |
27 void (*MGLMakeCurrent)(MGLContext context); | |
28 MGLContext (*MGLGetCurrentContext)(void); | |
29 MGLMustCastToProperFunctionPointerType (*MGLGetProcAddress)(const char* name); | |
30 }; | |
31 #pragma pack(pop) | |
32 | |
33 // Intended to be called from the embedder. Returns an object initialized to | |
34 // contain pointers to each of the embedder's MGLThunks functions. | |
35 inline struct MGLThunks MojoMakeMGLThunks() { | |
36 struct MGLThunks mgl_thunks = { | |
37 sizeof(struct MGLThunks), | |
38 MGLCreateContext, | |
39 MGLDestroyContext, | |
40 MGLMakeCurrent, | |
41 MGLGetCurrentContext, | |
42 MGLGetProcAddress, | |
43 }; | |
44 | |
45 return mgl_thunks; | |
46 } | |
47 | |
48 // Use this type for the function found by dynamically discovering it in | |
49 // a DSO linked with mojo_system. For example: | |
50 // MojoSetMGLThunksFn mojo_set_gles2_thunks_fn = | |
51 // reinterpret_cast<MojoSetMGLThunksFn>( | |
52 // app_library.GetFunctionPointer("MojoSetMGLThunks")); | |
53 // The expected size of |mgl_thunks| is returned. | |
54 // The contents of |mgl_thunks| are copied. | |
55 typedef size_t (*MojoSetMGLThunksFn)(const struct MGLThunks* mgl_thunks); | |
56 | |
57 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_MGL_THUNKS_H_ | |
OLD | NEW |