summaryrefslogtreecommitdiffstats
path: root/mojo/gles2
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 17:06:40 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 17:07:37 +0000
commitf723adfa62d5a3f0fd7773aec0dcca30006834b8 (patch)
treee4747ee136b7decd373ef2dd502dd01ac02d87a8 /mojo/gles2
parent426e3ae7de80643893a6d8dc5e47180270244669 (diff)
downloadchromium_src-f723adfa62d5a3f0fd7773aec0dcca30006834b8.zip
chromium_src-f723adfa62d5a3f0fd7773aec0dcca30006834b8.tar.gz
chromium_src-f723adfa62d5a3f0fd7773aec0dcca30006834b8.tar.bz2
mojo: Reland "Convert gles2 to the new thunking system."
This maintains the fixes for the mac isolate files, and switches around the targets used in the gyp files to fix the unit tests in component builds. BUG=386799 First Review URL: https://codereview.chromium.org/413303002 Second Review URL: https://codereview.chromium.org/448873002 Review URL: https://codereview.chromium.org/460743002 Cr-Commit-Position: refs/heads/master@{#289006} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/gles2')
-rw-r--r--mojo/gles2/BUILD.gn3
-rw-r--r--mojo/gles2/gles2_impl.cc82
-rw-r--r--mojo/gles2/gles2_support_impl.cc106
-rw-r--r--mojo/gles2/gles2_support_impl.h43
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_