OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ | |
6 #define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include "mojo/public/c/gles2/gles2.h" | |
11 | |
12 // Structure used to bind the interface which manipulates GLES2 surfaces to a | |
13 // DSO to theose of the embedder. | |
14 // | |
15 // This is the ABI between the embedder and the DSO. It can only have new | |
16 // functions added to the end. No other changes are supported. | |
17 #pragma pack(push, 8) | |
18 struct MojoGLES2ControlThunks { | |
19 size_t size; // Should be set to sizeof(MojoGLES2ControlThunks). | |
20 | |
21 MojoGLES2Context (*GLES2CreateContext)(MojoHandle handle, | |
22 MojoGLES2ContextLost lost_callback, | |
23 void* closure, | |
24 const MojoAsyncWaiter* async_waiter); | |
25 void (*GLES2DestroyContext)(MojoGLES2Context context); | |
26 void (*GLES2MakeCurrent)(MojoGLES2Context context); | |
27 void (*GLES2SwapBuffers)(); | |
28 | |
29 // TODO(piman): We shouldn't have to leak these 2 interfaces, especially in a | |
30 // type-unsafe way. | |
31 void* (*GLES2GetGLES2Interface)(MojoGLES2Context context); | |
32 void* (*GLES2GetContextSupport)(MojoGLES2Context context); | |
33 }; | |
34 #pragma pack(pop) | |
35 | |
36 // Intended to be called from the embedder. Returns an object initialized to | |
37 // contain pointers to each of the embedder's MojoGLES2ControlThunks functions. | |
38 inline MojoGLES2ControlThunks MojoMakeGLES2ControlThunks() { | |
39 MojoGLES2ControlThunks gles2_control_thunks = { | |
40 sizeof(MojoGLES2ControlThunks), | |
41 MojoGLES2CreateContext, | |
42 MojoGLES2DestroyContext, | |
43 MojoGLES2MakeCurrent, | |
44 MojoGLES2SwapBuffers, | |
45 MojoGLES2GetGLES2Interface, | |
46 MojoGLES2GetContextSupport | |
47 }; | |
48 | |
49 return gles2_control_thunks; | |
50 } | |
51 | |
52 // Use this type for the function found by dynamically discovering it in | |
53 // a DSO linked with mojo_system. For example: | |
54 // MojoSetGLES2ControlThunksFn mojo_set_gles2_control_thunks_fn = | |
55 // reinterpret_cast<MojoSetGLES2ControlThunksFn>( | |
56 // app_library.GetFunctionPointer("MojoSetGLES2ControlThunks")); | |
57 // The expected size of |gles2_control_thunks| is returned. | |
58 // The contents of |gles2_control_thunks| are copied. | |
59 typedef size_t (*MojoSetGLES2ControlThunksFn)( | |
60 const MojoGLES2ControlThunks* gles2_control_thunks); | |
61 | |
62 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ | |
OLD | NEW |