Chromium Code Reviews| Index: mojo/gles2/mgl_impl.cc |
| diff --git a/mojo/gles2/mgl_impl.cc b/mojo/gles2/mgl_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d35faea842a490d0dfa9eea15fad53076fda382f |
| --- /dev/null |
| +++ b/mojo/gles2/mgl_impl.cc |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2015 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. |
| + |
| +#include "mojo/public/c/gles2/gles2.h" |
| +#include "mojo/public/c/gpu/MGL/mgl.h" |
| +#include "mojo/public/c/gpu/MGL/mgl_onscreen.h" |
| +#include "mojo/public/cpp/system/message_pipe.h" |
| + |
| +// This file implements the MGL and MGL onscreen entry points exposed to the |
|
viettrungluu
2015/08/12 02:48:10
nit: I think you should put the file-level comment
|
| +// Mojo application by the shell. |
| +// |
| +// TODO(jamesr): These entry points are implemented on top of the MojoGLES2 |
| +// family, which for control functions is backwards. The MojoGLES2 control |
| +// entry points |
|
viettrungluu
2015/08/12 02:48:10
nit: rewrap this comment?
|
| +// should be implemented on top of these entry points while we deprecate them. |
| +extern "C" { |
|
viettrungluu
2015/08/12 02:48:10
nit: blank line after this one, and maybe also bef
|
| +MGLContext MGLCreateContext(MGLOpenGLAPIVersion version, |
| + MojoHandle command_buffer_handle, |
| + MGLContext share_group, |
| + MGLContextLostCallback lost_callback, |
| + void* lost_callback_closure, |
| + const struct MojoAsyncWaiter* async_waiter) { |
| + // TODO(jamesr): Support ES 3.0 / 3.1 where possible. |
| + if (version != MGL_API_VERSION_GLES2) { |
| + MojoClose(command_buffer_handle); |
| + return MGL_NO_CONTEXT; |
| + } |
| + // TODO(jamesr): Plumb through share groups. |
| + if (share_group != MGL_NO_CONTEXT) { |
| + MojoClose(command_buffer_handle); |
| + return MGL_NO_CONTEXT; |
| + } |
| + |
| + return reinterpret_cast<MGLContext>( |
| + MojoGLES2CreateContext(command_buffer_handle, lost_callback, |
| + lost_callback_closure, async_waiter)); |
| +} |
| + |
| +void MGLDestroyContext(MGLContext context) { |
| + MojoGLES2DestroyContext(reinterpret_cast<MojoGLES2Context>(context)); |
| +} |
| + |
| +int MGLMakeCurrent(MGLContext context) { |
| + MojoGLES2MakeCurrent(reinterpret_cast<MojoGLES2Context>(context)); |
| + // TODO(jamesr): Plumb through loss information through the return value. |
| + return 0; |
|
viettrungluu
2015/08/12 02:48:10
Aha, so your comment in the header about MGLMakeCu
|
| +} |
| + |
| +MGLContext MGLGetCurrentContext() { |
| + // TODO(jamesr): Implement. |
| + return MGL_NO_CONTEXT; |
| +} |
| + |
| +// TODO(jamesr): Hack - this symbol is defined in //mojo/gles2/gles2_impl.cc. |
| +// What should really happen here is this should call into the data structure |
| +// underlying MGLContext, but that can't happen until control is inverted. |
| +void MojoGLES2glResizeCHROMIUM(uint32_t width, |
| + uint32_t height, |
| + float scale_factor); |
| + |
| +void MGLResizeSurface(uint32_t width, uint32_t height) { |
| + // TODO(jamesr): Implement |
| + MojoGLES2glResizeCHROMIUM(width, height, 1.f); |
| +} |
| + |
| +void MGLSwapBuffers() { |
| + MojoGLES2SwapBuffers(); |
| +} |
| + |
| +} // extern "C" |