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