diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-09 06:13:33 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-09 06:14:33 +0000 |
commit | e074c2c4c2d7f1e44e06ada75037dc365aaf8596 (patch) | |
tree | f920618de40fd2631edc805231446293e219de4e /mojo/gles2 | |
parent | 050e782f12deeb35d1fc7dec41dc8357bb95078e (diff) | |
download | chromium_src-e074c2c4c2d7f1e44e06ada75037dc365aaf8596.zip chromium_src-e074c2c4c2d7f1e44e06ada75037dc365aaf8596.tar.gz chromium_src-e074c2c4c2d7f1e44e06ada75037dc365aaf8596.tar.bz2 |
mojo: Reland "Convert gles2 to the new thunking system."
This apparently fixes the tests. There was a merge conflict with the new
mojo_base.gyp file, and now we should be properly integrated, and
everything needed for the implementation of GLES2 should live in
mojo_base (mirroring mojo_system_impl), while everything about the
thunking goes in mojo_public (mirroring mojo_system).
BUG=386799
First Review URL: https://codereview.chromium.org/413303002
Review URL: https://codereview.chromium.org/448873002
Cr-Commit-Position: refs/heads/master@{#288527}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/gles2')
-rw-r--r-- | mojo/gles2/BUILD.gn | 3 | ||||
-rw-r--r-- | mojo/gles2/gles2_impl.cc | 82 | ||||
-rw-r--r-- | mojo/gles2/gles2_support_impl.cc | 106 | ||||
-rw-r--r-- | mojo/gles2/gles2_support_impl.h | 43 |
4 files changed, 83 insertions, 151 deletions
diff --git a/mojo/gles2/BUILD.gn b/mojo/gles2/BUILD.gn index 0893116..9b4ffb9 100644 --- a/mojo/gles2/BUILD.gn +++ b/mojo/gles2/BUILD.gn @@ -29,8 +29,7 @@ component("gles2") { "command_buffer_client_impl.cc", "command_buffer_client_impl.h", "gles2_impl_export.h", - "gles2_support_impl.cc", - "gles2_support_impl.h", + "gles2_impl.cc", "gles2_context.cc", "gles2_context.h", ] diff --git a/mojo/gles2/gles2_impl.cc b/mojo/gles2/gles2_impl.cc new file mode 100644 index 0000000..59b4278 --- /dev/null +++ b/mojo/gles2/gles2_impl.cc @@ -0,0 +1,82 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/public/c/gles2/gles2.h" + +#include "gpu/command_buffer/client/gles2_interface.h" +#include "mojo/gles2/gles2_context.h" + +using mojo::gles2::GLES2Context; + +namespace { + +const MojoAsyncWaiter* g_async_waiter = NULL; +gpu::gles2::GLES2Interface* g_gpu_interface = NULL; + +} // namespace + +extern "C" { + +void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) { + DCHECK(!g_async_waiter); + DCHECK(async_waiter); + g_async_waiter = async_waiter; +} + +void MojoGLES2Terminate() { + DCHECK(g_async_waiter); + g_async_waiter = NULL; +} + +MojoGLES2Context MojoGLES2CreateContext( + MojoHandle handle, + MojoGLES2ContextLost lost_callback, + void* closure) { + mojo::MessagePipeHandle mph(handle); + mojo::ScopedMessagePipeHandle scoped_handle(mph); + scoped_ptr<GLES2Context> client(new GLES2Context(g_async_waiter, + scoped_handle.Pass(), + lost_callback, + closure)); + if (!client->Initialize()) + client.reset(); + return client.release(); +} + +void MojoGLES2DestroyContext(MojoGLES2Context context) { + delete static_cast<GLES2Context*>(context); +} + +void MojoGLES2MakeCurrent(MojoGLES2Context context) { + gpu::gles2::GLES2Interface* interface = NULL; + if (context) { + GLES2Context* client = static_cast<GLES2Context*>(context); + interface = client->interface(); + DCHECK(interface); + } + g_gpu_interface = interface; +} + +void MojoGLES2SwapBuffers() { + assert(g_gpu_interface); + g_gpu_interface->SwapBuffers(); +} + +void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) { + return static_cast<GLES2Context*>(context)->interface(); +} + +void* MojoGLES2GetContextSupport(MojoGLES2Context context) { + return static_cast<GLES2Context*>(context)->context_support(); +} + +#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ + ReturnType gl##Function PARAMETERS { \ + assert(g_gpu_interface); \ + return g_gpu_interface->Function ARGUMENTS; \ + } +#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" +#undef VISIT_GL_CALL + +} // extern "C" diff --git a/mojo/gles2/gles2_support_impl.cc b/mojo/gles2/gles2_support_impl.cc deleted file mode 100644 index 99e8bb4..0000000 --- a/mojo/gles2/gles2_support_impl.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/gles2/gles2_support_impl.h" - -#include "base/lazy_instance.h" -#include "gpu/command_buffer/client/gles2_interface.h" -#include "mojo/gles2/gles2_context.h" -#include "mojo/public/gles2/gles2_interface.h" -#include "mojo/public/gles2/gles2_private.h" - -namespace mojo { -namespace gles2 { - -namespace { - -class GLES2ImplForCommandBuffer : public GLES2Interface { - public: - GLES2ImplForCommandBuffer() : gpu_interface_(NULL) {} - - void set_gpu_interface(gpu::gles2::GLES2Interface* gpu_interface) { - gpu_interface_ = gpu_interface; - } - gpu::gles2::GLES2Interface* gpu_interface() const { return gpu_interface_; } - -#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \ - virtual ReturnType Function PARAMETERS OVERRIDE { \ - return gpu_interface_->Function ARGUMENTS; \ - } -#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h" -#undef VISIT_GL_CALL - - private: - gpu::gles2::GLES2Interface* gpu_interface_; - DISALLOW_COPY_AND_ASSIGN(GLES2ImplForCommandBuffer); -}; - -base::LazyInstance<GLES2ImplForCommandBuffer> g_gles2_interface = - LAZY_INSTANCE_INITIALIZER; - -} // anonymous namespace - -GLES2SupportImpl::GLES2SupportImpl() : async_waiter_(NULL) {} -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) { - ScopedMessagePipeHandle scoped_handle(handle); - scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter_, - scoped_handle.Pass(), - lost_callback, - closure)); - if (!client->Initialize()) - client.reset(); - return client.release(); -} - -void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) { - delete static_cast<GLES2Context*>(context); -} - -void GLES2SupportImpl::MakeCurrent(MojoGLES2Context context) { - gpu::gles2::GLES2Interface* interface = NULL; - if (context) { - GLES2Context* client = static_cast<GLES2Context*>(context); - interface = client->interface(); - DCHECK(interface); - } - g_gles2_interface.Get().set_gpu_interface(interface); -} - -void GLES2SupportImpl::SwapBuffers() { - g_gles2_interface.Get().gpu_interface()->SwapBuffers(); -} - -void* GLES2SupportImpl::GetGLES2Interface(MojoGLES2Context context) { - return static_cast<GLES2Context*>(context)->interface(); -} - -void* GLES2SupportImpl::GetContextSupport(MojoGLES2Context context) { - return static_cast<GLES2Context*>(context)->context_support(); -} - -GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() { - return &g_gles2_interface.Get(); -} - -} // namespace gles2 -} // namespace mojo diff --git a/mojo/gles2/gles2_support_impl.h b/mojo/gles2/gles2_support_impl.h deleted file mode 100644 index 5598a09..0000000 --- a/mojo/gles2/gles2_support_impl.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_GLES2_GLES2_SUPPORT_IMPL_H_ -#define MOJO_GLES2_GLES2_SUPPORT_IMPL_H_ - -#include "base/compiler_specific.h" -#include "mojo/gles2/gles2_impl_export.h" -#include "mojo/public/gles2/gles2_private.h" - -namespace mojo { -namespace gles2 { - -class MOJO_GLES2_IMPL_EXPORT GLES2SupportImpl : public GLES2Support { - public: - virtual ~GLES2SupportImpl(); - - static void Init(); - - virtual void Initialize(const MojoAsyncWaiter* async_waiter) OVERRIDE; - virtual void Terminate() OVERRIDE; - virtual MojoGLES2Context CreateContext( - MessagePipeHandle handle, - MojoGLES2ContextLost lost_callback, - void* closure) OVERRIDE; - virtual void DestroyContext(MojoGLES2Context context) OVERRIDE; - virtual void MakeCurrent(MojoGLES2Context context) OVERRIDE; - virtual void SwapBuffers() OVERRIDE; - virtual void* GetGLES2Interface(MojoGLES2Context context) OVERRIDE; - virtual void* GetContextSupport(MojoGLES2Context context) OVERRIDE; - virtual GLES2Interface* GetGLES2InterfaceForCurrentContext() OVERRIDE; - - private: - GLES2SupportImpl(); - - const MojoAsyncWaiter* async_waiter_; -}; - -} // namespace gles2 -} // namespace mojo - -#endif // MOJO_GLES2_GLES2_SUPPORT_IMPL_H_ |