| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/public/c/gles2/gles2.h" | 5 #include "mojo/public/c/gles2/gles2.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "gpu/GLES2/gl2extchromium.h" | 9 #include "gpu/GLES2/gl2extchromium.h" |
| 10 #include "gpu/command_buffer/client/gles2_interface.h" | 10 #include "gpu/command_buffer/client/gles2_interface.h" |
| 11 #include "mojo/gles2/gles2_context.h" | 11 #include "mojo/gles2/gles2_context.h" |
| 12 | 12 |
| 13 using gles2::GLES2Context; | 13 using gles2::GLES2Context; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int32_t kNone = 0x3038; // EGL_NONE |
| 18 |
| 17 base::LazyInstance<base::ThreadLocalPointer<gpu::gles2::GLES2Interface> >::Leaky | 19 base::LazyInstance<base::ThreadLocalPointer<gpu::gles2::GLES2Interface> >::Leaky |
| 18 g_gpu_interface; | 20 g_gpu_interface; |
| 19 | 21 |
| 20 void RunSignalSyncCallback(MojoGLES2SignalSyncPointCallback callback, | 22 void RunSignalSyncCallback(MojoGLES2SignalSyncPointCallback callback, |
| 21 void* closure) { | 23 void* closure) { |
| 22 callback(closure); | 24 callback(closure); |
| 23 } | 25 } |
| 24 | 26 |
| 25 } // namespace | 27 } // namespace |
| 26 | 28 |
| 27 extern "C" { | 29 extern "C" { |
| 28 MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle, | 30 MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle, |
| 31 const int32_t* attrib_list, |
| 29 MojoGLES2ContextLost lost_callback, | 32 MojoGLES2ContextLost lost_callback, |
| 30 void* closure, | 33 void* closure, |
| 31 const MojoAsyncWaiter* async_waiter) { | 34 const MojoAsyncWaiter* async_waiter) { |
| 32 mojo::MessagePipeHandle mph(handle); | 35 mojo::MessagePipeHandle mph(handle); |
| 33 mojo::ScopedMessagePipeHandle scoped_handle(mph); | 36 mojo::ScopedMessagePipeHandle scoped_handle(mph); |
| 37 std::vector<int32_t> attribs; |
| 38 if (attrib_list) { |
| 39 for (int32_t const* p = attrib_list; *p != kNone;) { |
| 40 attribs.push_back(*p++); |
| 41 attribs.push_back(*p++); |
| 42 } |
| 43 } |
| 44 attribs.push_back(kNone); |
| 34 scoped_ptr<GLES2Context> client(new GLES2Context( | 45 scoped_ptr<GLES2Context> client(new GLES2Context( |
| 35 async_waiter, scoped_handle.Pass(), lost_callback, closure)); | 46 attribs, async_waiter, scoped_handle.Pass(), lost_callback, closure)); |
| 36 if (!client->Initialize()) | 47 if (!client->Initialize()) |
| 37 client.reset(); | 48 client.reset(); |
| 38 return client.release(); | 49 return client.release(); |
| 39 } | 50 } |
| 40 | 51 |
| 41 void MojoGLES2DestroyContext(MojoGLES2Context context) { | 52 void MojoGLES2DestroyContext(MojoGLES2Context context) { |
| 42 delete static_cast<GLES2Context*>(context); | 53 delete static_cast<GLES2Context*>(context); |
| 43 } | 54 } |
| 44 | 55 |
| 45 void MojoGLES2MakeCurrent(MojoGLES2Context context) { | 56 void MojoGLES2MakeCurrent(MojoGLES2Context context) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_image_autogen.h" | 97 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_image_autogen.h" |
| 87 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_miscellaneous_autogen.
h" | 98 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_miscellaneous_autogen.
h" |
| 88 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_pixel_transfer_buffer_
object_autogen.h" | 99 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_pixel_transfer_buffer_
object_autogen.h" |
| 89 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_sub_image_autogen.h" | 100 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_sub_image_autogen.h" |
| 90 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h" | 101 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_sync_point_autogen.h" |
| 91 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autoge
n.h" | 102 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_texture_mailbox_autoge
n.h" |
| 92 #include "mojo/public/c/gles2/gles2_call_visitor_occlusion_query_ext_autogen.h" | 103 #include "mojo/public/c/gles2/gles2_call_visitor_occlusion_query_ext_autogen.h" |
| 93 #undef VISIT_GL_CALL | 104 #undef VISIT_GL_CALL |
| 94 | 105 |
| 95 } // extern "C" | 106 } // extern "C" |
| OLD | NEW |