Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: mojo/gles2/control_thunks_impl.cc

Issue 1354353002: Add GetProcAddress to OpenGL control interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Review feedback addressed Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 void* ControlThunksImpl::GetProcAddress(const char* name) {
65 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
66 if (!strcmp(name, "gl##Function")) \
67 return reinterpret_cast<void*>(MojoGLES2gl##Function);
68 #include "mojo/public/platform/native/gles2/call_visitor.h"
69 #undef VISIT_GL_CALL
70 return nullptr;
71 }
72
55 void* ControlThunksImpl::GetGLES2Interface(MGLContext context) { 73 void* ControlThunksImpl::GetGLES2Interface(MGLContext context) {
56 GLES2Context* client = reinterpret_cast<GLES2Context*>(context); 74 GLES2Context* client = reinterpret_cast<GLES2Context*>(context);
57 DCHECK(client); 75 DCHECK(client);
58 return client->interface(); 76 return client->interface();
59 } 77 }
60 78
61 void ControlThunksImpl::SignalSyncPoint( 79 void ControlThunksImpl::SignalSyncPoint(
62 uint32_t sync_point, 80 uint32_t sync_point,
63 MGLSignalSyncPointCallback callback, 81 MGLSignalSyncPointCallback callback,
64 void* closure) { 82 void* closure) {
65 current_context_tls_.Get()->context_support()->SignalSyncPoint( 83 current_context_tls_.Get()->context_support()->SignalSyncPoint(
66 sync_point, base::Bind(callback, closure)); 84 sync_point, base::Bind(callback, closure));
67 } 85 }
68 86
69 gpu::gles2::GLES2Interface* ControlThunksImpl::CurrentGLES2Interface() { 87 gpu::gles2::GLES2Interface* ControlThunksImpl::CurrentGLES2Interface() {
70 if (!current_context_tls_.Get()) 88 if (!current_context_tls_.Get())
71 return nullptr; 89 return nullptr;
72 return current_context_tls_.Get()->interface(); 90 return current_context_tls_.Get()->interface();
73 } 91 }
74 92
75 ControlThunksImpl::ControlThunksImpl() { 93 ControlThunksImpl::ControlThunksImpl() {
76 } 94 }
77 95
78 ControlThunksImpl::~ControlThunksImpl() { 96 ControlThunksImpl::~ControlThunksImpl() {
79 } 97 }
80 98
81 } // namespace gles2 99 } // namespace gles2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698