Chromium Code Reviews| Index: mojo/public/platform/native/gles2_thunks.h |
| diff --git a/mojo/public/platform/native/gles2_thunks.h b/mojo/public/platform/native/gles2_thunks.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c78ad7d27215341c025c9cd7de3e34df25cf4f2b |
| --- /dev/null |
| +++ b/mojo/public/platform/native/gles2_thunks.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ |
| +#define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ |
| + |
| +#include <stddef.h> |
| + |
| +#include "mojo/public/c/gles2/gles2.h" |
| + |
| +// Structure used to bind the GLES2 functions of a DSO to theose of the |
| +// embedder. |
| +// This is the ABI between the embedder and the DSO. It can only have new |
| +// functions added to the end. No other changes are supported. |
| +#pragma pack(push, 8) |
| +struct MojoGLES2Thunks { |
| + size_t size; // Should be set to sizeof(MojoGLES2Thunks). |
| + |
| + void (*GLES2Initialize)(const MojoAsyncWaiter* async_waiter); |
| + void (*GLES2Terminate)(void); |
| + MojoGLES2Context (*GLES2CreateContext)( |
| + MojoHandle handle, |
| + MojoGLES2ContextLost lost_callback, |
| + void* closure); |
| + void (*GLES2DestroyContext)(MojoGLES2Context context); |
| + void (*GLES2MakeCurrent)(MojoGLES2Context context); |
| + void (*GLES2SwapBuffers)(void); |
| + |
| + // TODO(piman): We shouldn't have to leak those 2 interfaces, especially in a |
| + // type-unsafe way. |
| + void* (*GLES2GetGLES2Interface)(MojoGLES2Context context); |
| + void* (*GLES2GetContextSupport)(MojoGLES2Context context); |
| + |
| +#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ |
| + ReturnType (*Function) PARAMETERS; |
| +#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" |
|
viettrungluu
2014/07/28 22:11:05
Is this resilient to changes? Is autogen going to
Elliot Glaysher
2014/07/28 22:21:27
The functions added from gles2_call_visitor_autoge
|
| +#undef VISIT_GL_CALL |
| +}; |
| +#pragma pack(pop) |
| + |
| +// Intended to be called from the embedder. Returns a |MojoCore| initialized |
| +// to contain pointers to each of the embedder's MojoCore functions. |
| +inline MojoGLES2Thunks MojoMakeGLES2Thunks() { |
| + MojoGLES2Thunks gles2_thunks = { |
| + sizeof(MojoGLES2Thunks), |
| + MojoGLES2Initialize, |
| + MojoGLES2Terminate, |
| + MojoGLES2CreateContext, |
| + MojoGLES2DestroyContext, |
| + MojoGLES2MakeCurrent, |
| + MojoGLES2SwapBuffers, |
| + MojoGLES2GetGLES2Interface, |
| + MojoGLES2GetContextSupport, |
| +#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ |
| + gl##Function, |
| +#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" |
| +#undef VISIT_GL_CALL |
| + }; |
| + |
| + return gles2_thunks; |
| +} |
| + |
| +// Use this type for the function found by dynamically discovering it in |
| +// a DSO linked with mojo_system. For example: |
| +// MojoSetGLES2ThunksFn mojo_set_gles2_thunks_fn = |
| +// reinterpret_cast<MojoSetGLES2ThunksFn>(app_library.GetFunctionPointer( |
| +// "MojoSetGLES2Thunks")); |
| +// The expected size of |gles2_thunks} is returned. |
| +// The contents of |gles2_thunks| are copied. |
| +typedef size_t (*MojoSetGLES2ThunksFn)(const MojoGLES2Thunks* gles2_thunks); |
| + |
| +#endif // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_THUNKS_H_ |