| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| 11 #include "gpu/GLES2/gl2extchromium.h" | 11 #include "gpu/GLES2/gl2extchromium.h" |
| 12 #include "gpu/command_buffer/client/gles2_interface.h" | 12 #include "gpu/command_buffer/client/gles2_interface.h" |
| 13 #include "mojo/gles2/gles2_context.h" | 13 #include "mojo/gles2/gles2_context.h" |
| 14 // Even though this isn't used here, we need to include it to get the symbols to | 14 // Even though this isn't used here, we need to include it to get the symbols to |
| 15 // be exported in component build. | 15 // be exported in component build. |
| 16 #include "mojo/public/c/gles2/chromium_extension.h" | 16 #include "mojo/public/c/gles2/chromium_extension.h" |
| 17 #include "mojo/public/c/gles2/gles2.h" | 17 #include "mojo/public/c/gles2/gles2.h" |
| 18 | 18 |
| 19 using gles2::GLES2Context; | 19 using gles2::GLES2Context; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const int32_t kNone = 0x3038; // EGL_NONE | 23 const int32_t kNone = 0x3038; // EGL_NONE |
| 24 | 24 |
| 25 base::LazyInstance<base::ThreadLocalPointer<gpu::gles2::GLES2Interface> >::Leaky | 25 base::LazyInstance<base::ThreadLocalPointer<gpu::gles2::GLES2Interface> >::Leaky |
| 26 g_gpu_interface; | 26 g_gpu_interface; |
| 27 | 27 |
| 28 void RunSignalSyncCallback(MojoGLES2SignalSyncPointCallback callback, | |
| 29 void* closure) { | |
| 30 callback(closure); | |
| 31 } | |
| 32 | |
| 33 } // namespace | 28 } // namespace |
| 34 | 29 |
| 35 extern "C" { | 30 extern "C" { |
| 36 MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle, | 31 MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle, |
| 37 const int32_t* attrib_list, | 32 const int32_t* attrib_list, |
| 38 MojoGLES2ContextLost lost_callback, | 33 MojoGLES2ContextLost lost_callback, |
| 39 void* closure, | 34 void* closure, |
| 40 const MojoAsyncWaiter* async_waiter) { | 35 const MojoAsyncWaiter* async_waiter) { |
| 41 mojo::MessagePipeHandle mph(handle); | 36 mojo::MessagePipeHandle mph(handle); |
| 42 mojo::ScopedMessagePipeHandle scoped_handle(mph); | 37 mojo::ScopedMessagePipeHandle scoped_handle(mph); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 67 DCHECK(interface); | 62 DCHECK(interface); |
| 68 } | 63 } |
| 69 g_gpu_interface.Get().Set(interface); | 64 g_gpu_interface.Get().Set(interface); |
| 70 } | 65 } |
| 71 | 66 |
| 72 void MojoGLES2SwapBuffers() { | 67 void MojoGLES2SwapBuffers() { |
| 73 DCHECK(g_gpu_interface.Get().Get()); | 68 DCHECK(g_gpu_interface.Get().Get()); |
| 74 g_gpu_interface.Get().Get()->SwapBuffers(); | 69 g_gpu_interface.Get().Get()->SwapBuffers(); |
| 75 } | 70 } |
| 76 | 71 |
| 77 void MojoGLES2SignalSyncPoint( | |
| 78 MojoGLES2Context context, | |
| 79 uint32_t sync_point, | |
| 80 MojoGLES2SignalSyncPointCallback callback, | |
| 81 void* closure) { | |
| 82 DCHECK(context); | |
| 83 static_cast<GLES2Context*>(context)->context_support()->SignalSyncPoint( | |
| 84 sync_point, base::Bind(&RunSignalSyncCallback, callback, closure)); | |
| 85 } | |
| 86 | |
| 87 void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { | 72 void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { |
| 88 return static_cast<GLES2Context*>(context)->interface(); | 73 return static_cast<GLES2Context*>(context)->interface(); |
| 89 } | 74 } |
| 90 | 75 |
| 91 void* MojoGLES2GetContextSupport(MojoGLES2Context context) { | 76 void* MojoGLES2GetContextSupport(MojoGLES2Context context) { |
| 92 return static_cast<GLES2Context*>(context)->context_support(); | 77 return static_cast<GLES2Context*>(context)->context_support(); |
| 93 } | 78 } |
| 94 | 79 |
| 95 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ | 80 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ |
| 96 ReturnType GL_APIENTRY gl##Function PARAMETERS { \ | 81 ReturnType GL_APIENTRY gl##Function PARAMETERS { \ |
| 97 DCHECK(g_gpu_interface.Get().Get()); \ | 82 DCHECK(g_gpu_interface.Get().Get()); \ |
| 98 return g_gpu_interface.Get().Get()->Function ARGUMENTS; \ | 83 return g_gpu_interface.Get().Get()->Function ARGUMENTS; \ |
| 99 } | 84 } |
| 100 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" | 85 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" |
| 101 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_extension_autogen.h" | 86 #include "mojo/public/c/gles2/gles2_call_visitor_chromium_extension_autogen.h" |
| 102 #undef VISIT_GL_CALL | 87 #undef VISIT_GL_CALL |
| 103 | 88 |
| 104 } // extern "C" | 89 } // extern "C" |
| OLD | NEW |