Chromium Code Reviews| Index: mojo/gles2/gles2_support_impl.cc |
| diff --git a/mojo/gles2/gles2_support_impl.cc b/mojo/gles2/gles2_support_impl.cc |
| index 99e8bb44dadebc0759dd37261f361e9465ec16cd..c0aee43a7c01d60607b911aaf5756083526c7538 100644 |
| --- a/mojo/gles2/gles2_support_impl.cc |
| +++ b/mojo/gles2/gles2_support_impl.cc |
| @@ -4,7 +4,7 @@ |
| #include "mojo/gles2/gles2_support_impl.h" |
| -#include "base/lazy_instance.h" |
| +#include "base/threading/thread_local.h" |
| #include "gpu/command_buffer/client/gles2_interface.h" |
| #include "mojo/gles2/gles2_context.h" |
| #include "mojo/public/gles2/gles2_interface.h" |
| @@ -36,34 +36,23 @@ class GLES2ImplForCommandBuffer : public GLES2Interface { |
| DISALLOW_COPY_AND_ASSIGN(GLES2ImplForCommandBuffer); |
| }; |
| -base::LazyInstance<GLES2ImplForCommandBuffer> g_gles2_interface = |
| - LAZY_INSTANCE_INITIALIZER; |
| +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
|
| } // anonymous namespace |
| -GLES2SupportImpl::GLES2SupportImpl() : async_waiter_(NULL) {} |
| +GLES2SupportImpl::GLES2SupportImpl() {} |
| GLES2SupportImpl::~GLES2SupportImpl() {} |
| // static |
| void GLES2SupportImpl::Init() { GLES2Support::Init(new GLES2SupportImpl()); } |
| -void GLES2SupportImpl::Initialize(const MojoAsyncWaiter* async_waiter) { |
| - DCHECK(!async_waiter_); |
| - DCHECK(async_waiter); |
| - async_waiter_ = async_waiter; |
| -} |
| - |
| -void GLES2SupportImpl::Terminate() { |
| - DCHECK(async_waiter_); |
| - async_waiter_ = NULL; |
| -} |
| - |
| MojoGLES2Context GLES2SupportImpl::CreateContext( |
| MessagePipeHandle handle, |
| MojoGLES2ContextLost lost_callback, |
| - void* closure) { |
| + void* closure, |
| + const MojoAsyncWaiter* async_waiter) { |
| ScopedMessagePipeHandle scoped_handle(handle); |
| - scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter_, |
| + scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter, |
| scoped_handle.Pass(), |
| lost_callback, |
| closure)); |
| @@ -73,6 +62,7 @@ MojoGLES2Context GLES2SupportImpl::CreateContext( |
| } |
| void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) { |
| + 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
|
| delete static_cast<GLES2Context*>(context); |
| } |
| @@ -83,11 +73,13 @@ void GLES2SupportImpl::MakeCurrent(MojoGLES2Context context) { |
| interface = client->interface(); |
| DCHECK(interface); |
| } |
| - g_gles2_interface.Get().set_gpu_interface(interface); |
| + if (!g_gles2_interface.Get()) |
| + g_gles2_interface.Set(new GLES2ImplForCommandBuffer); |
| + g_gles2_interface.Get()->set_gpu_interface(interface); |
| } |
| void GLES2SupportImpl::SwapBuffers() { |
| - g_gles2_interface.Get().gpu_interface()->SwapBuffers(); |
| + g_gles2_interface.Get()->gpu_interface()->SwapBuffers(); |
| } |
| void* GLES2SupportImpl::GetGLES2Interface(MojoGLES2Context context) { |
| @@ -99,7 +91,7 @@ void* GLES2SupportImpl::GetContextSupport(MojoGLES2Context context) { |
| } |
| GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() { |
| - return &g_gles2_interface.Get(); |
| + return g_gles2_interface.Get(); |
| } |
| } // namespace gles2 |