| 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 #include "mojo/public/c/gles2/gles2.h" | |
| 6 | |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | |
| 8 #include "mojo/gles2/gles2_context.h" | |
| 9 | |
| 10 using mojo::gles2::GLES2Context; | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 const MojoAsyncWaiter* g_async_waiter = NULL; | |
| 15 gpu::gles2::GLES2Interface* g_gpu_interface = NULL; | |
| 16 | |
| 17 } // namespace | |
| 18 | |
| 19 extern "C" { | |
| 20 | |
| 21 void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) { | |
| 22 DCHECK(!g_async_waiter); | |
| 23 DCHECK(async_waiter); | |
| 24 g_async_waiter = async_waiter; | |
| 25 } | |
| 26 | |
| 27 void MojoGLES2Terminate() { | |
| 28 DCHECK(g_async_waiter); | |
| 29 g_async_waiter = NULL; | |
| 30 } | |
| 31 | |
| 32 MojoGLES2Context MojoGLES2CreateContext( | |
| 33 MojoHandle handle, | |
| 34 MojoGLES2ContextLost lost_callback, | |
| 35 void* closure) { | |
| 36 mojo::MessagePipeHandle mph(handle); | |
| 37 mojo::ScopedMessagePipeHandle scoped_handle(mph); | |
| 38 scoped_ptr<GLES2Context> client(new GLES2Context(g_async_waiter, | |
| 39 scoped_handle.Pass(), | |
| 40 lost_callback, | |
| 41 closure)); | |
| 42 if (!client->Initialize()) | |
| 43 client.reset(); | |
| 44 return client.release(); | |
| 45 } | |
| 46 | |
| 47 void MojoGLES2DestroyContext(MojoGLES2Context context) { | |
| 48 delete static_cast<GLES2Context*>(context); | |
| 49 } | |
| 50 | |
| 51 void MojoGLES2MakeCurrent(MojoGLES2Context context) { | |
| 52 gpu::gles2::GLES2Interface* interface = NULL; | |
| 53 if (context) { | |
| 54 GLES2Context* client = static_cast<GLES2Context*>(context); | |
| 55 interface = client->interface(); | |
| 56 DCHECK(interface); | |
| 57 } | |
| 58 g_gpu_interface = interface; | |
| 59 } | |
| 60 | |
| 61 void MojoGLES2SwapBuffers() { | |
| 62 assert(g_gpu_interface); | |
| 63 g_gpu_interface->SwapBuffers(); | |
| 64 } | |
| 65 | |
| 66 void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { | |
| 67 return static_cast<GLES2Context*>(context)->interface(); | |
| 68 } | |
| 69 | |
| 70 void* MojoGLES2GetContextSupport(MojoGLES2Context context) { | |
| 71 return static_cast<GLES2Context*>(context)->context_support(); | |
| 72 } | |
| 73 | |
| 74 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ | |
| 75 ReturnType gl##Function PARAMETERS { \ | |
| 76 assert(g_gpu_interface); \ | |
| 77 return g_gpu_interface->Function ARGUMENTS; \ | |
| 78 } | |
| 79 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" | |
| 80 #undef VISIT_GL_CALL | |
| 81 | |
| 82 } // extern "C" | |
| OLD | NEW |