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

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

Issue 428413002: Make async waiter explicit MojoGLES2CreateContext param (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/gles2/gles2_support_impl.h ('k') | mojo/public/c/gles2/gles2.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gles2/gles2_support_impl.h" 5 #include "mojo/gles2/gles2_support_impl.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/threading/thread_local.h"
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "mojo/gles2/gles2_context.h" 9 #include "mojo/gles2/gles2_context.h"
10 #include "mojo/public/gles2/gles2_interface.h" 10 #include "mojo/public/gles2/gles2_interface.h"
11 #include "mojo/public/gles2/gles2_private.h" 11 #include "mojo/public/gles2/gles2_private.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 namespace { 16 namespace {
17 17
(...skipping 11 matching lines...) Expand all
29 return gpu_interface_->Function ARGUMENTS; \ 29 return gpu_interface_->Function ARGUMENTS; \
30 } 30 }
31 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" 31 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
32 #undef VISIT_GL_CALL 32 #undef VISIT_GL_CALL
33 33
34 private: 34 private:
35 gpu::gles2::GLES2Interface* gpu_interface_; 35 gpu::gles2::GLES2Interface* gpu_interface_;
36 DISALLOW_COPY_AND_ASSIGN(GLES2ImplForCommandBuffer); 36 DISALLOW_COPY_AND_ASSIGN(GLES2ImplForCommandBuffer);
37 }; 37 };
38 38
39 base::LazyInstance<GLES2ImplForCommandBuffer> g_gles2_interface = 39 base::ThreadLocalPointer<GLES2ImplForCommandBuffer> g_gles2_interface;
jamesr 2014/07/31 01:36:00 this change isn't strictly speaking part of the sa
piman 2014/07/31 01:53:46 base::LazyInstance<base::ThreadLocalPointer> to av
40 LAZY_INSTANCE_INITIALIZER;
41 40
42 } // anonymous namespace 41 } // anonymous namespace
43 42
44 GLES2SupportImpl::GLES2SupportImpl() : async_waiter_(NULL) {} 43 GLES2SupportImpl::GLES2SupportImpl() {}
45 GLES2SupportImpl::~GLES2SupportImpl() {} 44 GLES2SupportImpl::~GLES2SupportImpl() {}
46 45
47 // static 46 // static
48 void GLES2SupportImpl::Init() { GLES2Support::Init(new GLES2SupportImpl()); } 47 void GLES2SupportImpl::Init() { GLES2Support::Init(new GLES2SupportImpl()); }
49 48
50 void GLES2SupportImpl::Initialize(const MojoAsyncWaiter* async_waiter) {
51 DCHECK(!async_waiter_);
52 DCHECK(async_waiter);
53 async_waiter_ = async_waiter;
54 }
55
56 void GLES2SupportImpl::Terminate() {
57 DCHECK(async_waiter_);
58 async_waiter_ = NULL;
59 }
60
61 MojoGLES2Context GLES2SupportImpl::CreateContext( 49 MojoGLES2Context GLES2SupportImpl::CreateContext(
62 MessagePipeHandle handle, 50 MessagePipeHandle handle,
63 MojoGLES2ContextLost lost_callback, 51 MojoGLES2ContextLost lost_callback,
64 void* closure) { 52 void* closure,
53 const MojoAsyncWaiter* async_waiter) {
65 ScopedMessagePipeHandle scoped_handle(handle); 54 ScopedMessagePipeHandle scoped_handle(handle);
66 scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter_, 55 scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter,
67 scoped_handle.Pass(), 56 scoped_handle.Pass(),
68 lost_callback, 57 lost_callback,
69 closure)); 58 closure));
70 if (!client->Initialize()) 59 if (!client->Initialize())
71 client.reset(); 60 client.reset();
72 return client.release(); 61 return client.release();
73 } 62 }
74 63
75 void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) { 64 void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) {
65 delete g_gles2_interface.Get();
jamesr 2014/07/31 01:36:00 this is maybe not quite right - I'm assuming that
piman 2014/07/31 01:53:46 mmh, I don't think we should impose that restricti
76 delete static_cast<GLES2Context*>(context); 66 delete static_cast<GLES2Context*>(context);
77 } 67 }
78 68
79 void GLES2SupportImpl::MakeCurrent(MojoGLES2Context context) { 69 void GLES2SupportImpl::MakeCurrent(MojoGLES2Context context) {
80 gpu::gles2::GLES2Interface* interface = NULL; 70 gpu::gles2::GLES2Interface* interface = NULL;
81 if (context) { 71 if (context) {
82 GLES2Context* client = static_cast<GLES2Context*>(context); 72 GLES2Context* client = static_cast<GLES2Context*>(context);
83 interface = client->interface(); 73 interface = client->interface();
84 DCHECK(interface); 74 DCHECK(interface);
85 } 75 }
86 g_gles2_interface.Get().set_gpu_interface(interface); 76 if (!g_gles2_interface.Get())
77 g_gles2_interface.Set(new GLES2ImplForCommandBuffer);
78 g_gles2_interface.Get()->set_gpu_interface(interface);
87 } 79 }
88 80
89 void GLES2SupportImpl::SwapBuffers() { 81 void GLES2SupportImpl::SwapBuffers() {
90 g_gles2_interface.Get().gpu_interface()->SwapBuffers(); 82 g_gles2_interface.Get()->gpu_interface()->SwapBuffers();
91 } 83 }
92 84
93 void* GLES2SupportImpl::GetGLES2Interface(MojoGLES2Context context) { 85 void* GLES2SupportImpl::GetGLES2Interface(MojoGLES2Context context) {
94 return static_cast<GLES2Context*>(context)->interface(); 86 return static_cast<GLES2Context*>(context)->interface();
95 } 87 }
96 88
97 void* GLES2SupportImpl::GetContextSupport(MojoGLES2Context context) { 89 void* GLES2SupportImpl::GetContextSupport(MojoGLES2Context context) {
98 return static_cast<GLES2Context*>(context)->context_support(); 90 return static_cast<GLES2Context*>(context)->context_support();
99 } 91 }
100 92
101 GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() { 93 GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() {
102 return &g_gles2_interface.Get(); 94 return g_gles2_interface.Get();
103 } 95 }
104 96
105 } // namespace gles2 97 } // namespace gles2
106 } // namespace mojo 98 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/gles2/gles2_support_impl.h ('k') | mojo/public/c/gles2/gles2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698