diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 01:15:09 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 01:15:09 +0000 |
commit | 99e508a465b28665fe32b8f01b1dacf24c925c66 (patch) | |
tree | f3883732637ec7a6b416efa3cc7008f3d2625f4d /mojo/public | |
parent | 6edd060869e0cc78544a947c768e48422d499375 (diff) | |
download | chromium_src-99e508a465b28665fe32b8f01b1dacf24c925c66.zip chromium_src-99e508a465b28665fe32b8f01b1dacf24c925c66.tar.gz chromium_src-99e508a465b28665fe32b8f01b1dacf24c925c66.tar.bz2 |
[Mojo] Remove dependency between mojo/public and gpu
This CL restructures how sample_app integrates with the GPU command buffer.
Instead of mojo/public containing code that depends directly on
gpu/command_buffer, this CL isolates that dependency into a dynamically linked
library modelled after mojo_system.
1) mojo/public/gles2 contains a simple C API to libmojo_gles2.so.
2) mojo/gles2 contains a "thin" implementation of this API in terms of
gpu/command_buffer.
3) Instead of subclassing GLES2ClientStub in mojo/public/bindings, we now
subclass the stub directly in sample_app and control the GLES2 C API via
mojo/public/gles2.
I've also added a couple of README.md files that describe the purposes of the
various directories and the reasons why the code is structured in this way.
R=darin@chromium.org
Review URL: https://codereview.chromium.org/101413002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/public')
-rw-r--r-- | mojo/public/README.md | 41 | ||||
-rw-r--r-- | mojo/public/bindings/gles2_client/DEPS | 3 | ||||
-rw-r--r-- | mojo/public/bindings/gles2_client/gles2_client_impl.cc | 75 | ||||
-rw-r--r-- | mojo/public/bindings/gles2_client/gles2_client_impl.h | 44 | ||||
-rw-r--r-- | mojo/public/gles2/gles2.h | 47 |
5 files changed, 88 insertions, 122 deletions
diff --git a/mojo/public/README.md b/mojo/public/README.md new file mode 100644 index 0000000..08f9881 --- /dev/null +++ b/mojo/public/README.md @@ -0,0 +1,41 @@ +Mojo Public API +=============== + +The Mojo Public API is a binary stable API to the Mojo system. There are +several components to the API: + +Bindings +-------- + +This directory contains a static library that clients can link into their +binary. The contents of this directory are not binary stable because each +client is free to use whichever version they prefer. + +This directory also contains a compiler that translates mojom interface +definition files into idiomatic bindings for various languages, including +C++ and JavaScript. Clients are expected to statically link with the generated +code, which reads and writes the binary stable IPC message format. + +GLES2 +----- + +The IPC protocol used to communicate between Mojo client and the GLES2 +service is not binary stable. To insulate themselves from changes in this +protocol, clients are expected to link dynamically against the standard GLES2 +headers from Khronos and the headers in this directory, which provide an +adaptor between the GLES2 C API and the underlying IPC protocol. + +System +------ + +This directory defines the interface between Mojo clients and the Mojo IPC +system. Although the Mojo IPC message format is binary stable, the mechanism +by which these messages are transported is not stable. To insulate themselves +from changes in the underlying transport, clients are expected to link against +these headers dynamically. + +Tests +----- + +This directory contains tests for code contained in the public API. Mojo +clients are expected to ignore this directory. diff --git a/mojo/public/bindings/gles2_client/DEPS b/mojo/public/bindings/gles2_client/DEPS deleted file mode 100644 index 08992c3..0000000 --- a/mojo/public/bindings/gles2_client/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+gpu/command_buffer/client", -] diff --git a/mojo/public/bindings/gles2_client/gles2_client_impl.cc b/mojo/public/bindings/gles2_client/gles2_client_impl.cc deleted file mode 100644 index 2fea93c..0000000 --- a/mojo/public/bindings/gles2_client/gles2_client_impl.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2013 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/bindings/gles2_client/gles2_client_impl.h" - -#include <assert.h> - -#include "gpu/command_buffer/client/gles2_lib.h" - -namespace mojo { -namespace { - -bool g_gles2_initialized = false; - -} // namespace - -GLES2Delegate::~GLES2Delegate() { -} - -void GLES2Delegate::DidCreateContext( - GLES2ClientImpl* gl, uint32_t width, uint32_t height) { -} - -void GLES2Delegate::ContextLost(GLES2ClientImpl* gl) { -} - -GLES2ClientImpl::GLES2ClientImpl(GLES2Delegate* delegate, - ScopedMessagePipeHandle gl) - : delegate_(delegate), - gl_(gl.Pass()) { - assert(g_gles2_initialized); - gl_.SetPeer(this); -} - -GLES2ClientImpl::~GLES2ClientImpl() { - gl_->Destroy(); -} - -void GLES2ClientImpl::Initialize() { - assert(!g_gles2_initialized); - gles2::Initialize(); - g_gles2_initialized = true; -} - -void GLES2ClientImpl::Terminate() { - assert(g_gles2_initialized); - gles2::Terminate(); - g_gles2_initialized = false; -} - -void GLES2ClientImpl::SwapBuffers() { - gles2::GetGLContext()->SwapBuffers(); -} - -void GLES2ClientImpl::DidCreateContext( - uint64_t encoded, uint32_t width, uint32_t height) { - // Ack, Hans! It's the giant hack. - // TODO(abarth): Replace this hack with something more disciplined. Most - // likley, we should receive a MojoHandle that we use to wire up the - // client side of an out-of-process command buffer. Given that we're - // still in-process, we just reinterpret_cast the value into a GL interface. - gpu::gles2::GLES2Interface* gl_interface = - reinterpret_cast<gpu::gles2::GLES2Interface*>( - static_cast<uintptr_t>(encoded)); - gles2::SetGLContext(gl_interface); - - delegate_->DidCreateContext(this, width, height); -} - -void GLES2ClientImpl::ContextLost() { - delegate_->ContextLost(this); -} - -} // mojo diff --git a/mojo/public/bindings/gles2_client/gles2_client_impl.h b/mojo/public/bindings/gles2_client/gles2_client_impl.h deleted file mode 100644 index 9213905..0000000 --- a/mojo/public/bindings/gles2_client/gles2_client_impl.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2013 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_PUBLIC_BINDINGS_GLES2_CLIENT_GLES2_CLIENT_IMPL_H_ -#define MOJO_PUBLIC_BINDINGS_GLES2_CLIENT_GLES2_CLIENT_IMPL_H_ - -#include "mojo/public/bindings/lib/remote_ptr.h" -#include "mojom/gles2.h" - -namespace mojo { -class GLES2ClientImpl; - -class GLES2Delegate { - public: - virtual ~GLES2Delegate(); - virtual void DidCreateContext( - GLES2ClientImpl* gl, uint32_t width, uint32_t height); - virtual void ContextLost(GLES2ClientImpl* gl); -}; - -class GLES2ClientImpl : public GLES2ClientStub { - public: - explicit GLES2ClientImpl(GLES2Delegate* delegate, - ScopedMessagePipeHandle gl); - virtual ~GLES2ClientImpl(); - - static void Initialize(); - static void Terminate(); - - void SwapBuffers(); - - private: - virtual void DidCreateContext( - uint64_t encoded, uint32_t width, uint32_t height) MOJO_OVERRIDE; - virtual void ContextLost() MOJO_OVERRIDE; - - GLES2Delegate* delegate_; - RemotePtr<GLES2> gl_; -}; - -} // mojo - -#endif // MOJO_PUBLIC_BINDINGS_GLES2_CLIENT_GLES2_CLIENT_IMPL_H_ diff --git a/mojo/public/gles2/gles2.h b/mojo/public/gles2/gles2.h new file mode 100644 index 0000000..0a32cdd --- /dev/null +++ b/mojo/public/gles2/gles2.h @@ -0,0 +1,47 @@ +// Copyright 2013 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_PUBLIC_GLES2_ADAPTOR_H_ +#define MOJO_PUBLIC_GLES2_ADAPTOR_H_ + +// Note: This header should be compilable as C. + +#include <stdint.h> + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(MOJO_GLES2_IMPLEMENTATION) +#define MOJO_GLES2_EXPORT __declspec(dllexport) +#else +#define MOJO_GLES2_EXPORT __declspec(dllimport) +#endif // defined(GFX_IMPLEMENTATION) + +#else // defined(WIN32) +#if defined(MOJO_GLES2_IMPLEMENTATION) +#define MOJO_GLES2_EXPORT __attribute__((visibility("default"))) +#else +#define MOJO_GLES2_EXPORT +#endif +#endif + +#else // defined(COMPONENT_BUILD) +#define MOJO_GLES2_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +MOJO_GLES2_EXPORT void MojoGLES2Initialize(); +MOJO_GLES2_EXPORT void MojoGLES2Terminate(); +// TODO(abarth): MojoGLES2MakeCurrent should take a MojoHandle. +MOJO_GLES2_EXPORT void MojoGLES2MakeCurrent(uint64_t encoded); +MOJO_GLES2_EXPORT void MojoGLES2SwapBuffers(); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // MOJO_PUBLIC_GLES2_ADAPTOR_H_ |