OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/gles2/control_thunks_impl.h" | 5 #include "mojo/gles2/control_thunks_impl.h" |
6 | 6 |
7 #include "mojo/gles2/gles2_context.h" | 7 #include "mojo/gles2/gles2_context.h" |
8 #include "mojo/public/cpp/system/message_pipe.h" | 8 #include "mojo/public/cpp/system/message_pipe.h" |
9 | 9 |
| 10 extern "C" { |
| 11 |
| 12 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ |
| 13 ReturnType MojoGLES2gl##Function PARAMETERS; |
| 14 #include "mojo/public/platform/native/gles2/call_visitor.h" |
| 15 #undef VISIT_GL_CALL |
| 16 |
| 17 } |
| 18 |
10 namespace gles2 { | 19 namespace gles2 { |
11 | 20 |
12 // static | 21 // static |
13 ControlThunksImpl* ControlThunksImpl::Get() { | 22 ControlThunksImpl* ControlThunksImpl::Get() { |
14 static base::LazyInstance<ControlThunksImpl>::Leaky thunks; | 23 static base::LazyInstance<ControlThunksImpl>::Leaky thunks; |
15 return thunks.Pointer(); | 24 return thunks.Pointer(); |
16 } | 25 } |
17 | 26 |
18 MGLContext ControlThunksImpl::CreateContext( | 27 MGLContext ControlThunksImpl::CreateContext( |
19 MGLOpenGLAPIVersion version, | 28 MGLOpenGLAPIVersion version, |
(...skipping 25 matching lines...) Expand all Loading... |
45 } | 54 } |
46 | 55 |
47 void ControlThunksImpl::ResizeSurface(uint32_t width, uint32_t height) { | 56 void ControlThunksImpl::ResizeSurface(uint32_t width, uint32_t height) { |
48 current_context_tls_.Get()->interface()->ResizeCHROMIUM(width, height, 1.f); | 57 current_context_tls_.Get()->interface()->ResizeCHROMIUM(width, height, 1.f); |
49 } | 58 } |
50 | 59 |
51 void ControlThunksImpl::SwapBuffers() { | 60 void ControlThunksImpl::SwapBuffers() { |
52 current_context_tls_.Get()->interface()->SwapBuffers(); | 61 current_context_tls_.Get()->interface()->SwapBuffers(); |
53 } | 62 } |
54 | 63 |
| 64 |
| 65 MGLMustCastToProperFunctionPointerType ControlThunksImpl::GetProcAddress( |
| 66 const char* name) { |
| 67 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ |
| 68 if (!strcmp(name, "gl"#Function)) \ |
| 69 return reinterpret_cast<MGLMustCastToProperFunctionPointerType>( \ |
| 70 MojoGLES2gl##Function); |
| 71 #include "mojo/public/platform/native/gles2/call_visitor.h" |
| 72 #undef VISIT_GL_CALL |
| 73 return nullptr; |
| 74 } |
| 75 |
55 void* ControlThunksImpl::GetGLES2Interface(MGLContext context) { | 76 void* ControlThunksImpl::GetGLES2Interface(MGLContext context) { |
56 GLES2Context* client = reinterpret_cast<GLES2Context*>(context); | 77 GLES2Context* client = reinterpret_cast<GLES2Context*>(context); |
57 DCHECK(client); | 78 DCHECK(client); |
58 return client->interface(); | 79 return client->interface(); |
59 } | 80 } |
60 | 81 |
61 void ControlThunksImpl::SignalSyncPoint( | 82 void ControlThunksImpl::SignalSyncPoint( |
62 uint32_t sync_point, | 83 uint32_t sync_point, |
63 MGLSignalSyncPointCallback callback, | 84 MGLSignalSyncPointCallback callback, |
64 void* closure) { | 85 void* closure) { |
65 current_context_tls_.Get()->context_support()->SignalSyncPoint( | 86 current_context_tls_.Get()->context_support()->SignalSyncPoint( |
66 sync_point, base::Bind(callback, closure)); | 87 sync_point, base::Bind(callback, closure)); |
67 } | 88 } |
68 | 89 |
69 gpu::gles2::GLES2Interface* ControlThunksImpl::CurrentGLES2Interface() { | 90 gpu::gles2::GLES2Interface* ControlThunksImpl::CurrentGLES2Interface() { |
70 if (!current_context_tls_.Get()) | 91 if (!current_context_tls_.Get()) |
71 return nullptr; | 92 return nullptr; |
72 return current_context_tls_.Get()->interface(); | 93 return current_context_tls_.Get()->interface(); |
73 } | 94 } |
74 | 95 |
75 ControlThunksImpl::ControlThunksImpl() { | 96 ControlThunksImpl::ControlThunksImpl() { |
76 } | 97 } |
77 | 98 |
78 ControlThunksImpl::~ControlThunksImpl() { | 99 ControlThunksImpl::~ControlThunksImpl() { |
79 } | 100 } |
80 | 101 |
81 } // namespace gles2 | 102 } // namespace gles2 |
OLD | NEW |