diff options
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/gles2/export.h | 29 | ||||
-rw-r--r-- | mojo/gles2/gles2_impl.cc (renamed from mojo/gles2/gles2.cc) | 35 | ||||
-rw-r--r-- | mojo/gles2/gles2_impl.h | 35 | ||||
-rw-r--r-- | mojo/mojo.gyp | 12 | ||||
-rw-r--r-- | mojo/mojo_public.gypi | 20 | ||||
-rw-r--r-- | mojo/public/gles2/gles2.h | 6 | ||||
-rw-r--r-- | mojo/public/gles2/gles2_private.cc | 42 | ||||
-rw-r--r-- | mojo/public/gles2/gles2_private.h | 29 | ||||
-rw-r--r-- | mojo/public/system/core_private.cc | 6 | ||||
-rw-r--r-- | mojo/public/system/core_private.h | 6 | ||||
-rw-r--r-- | mojo/shell/context.cc | 2 | ||||
-rw-r--r-- | mojo/system/core_impl.cc | 2 | ||||
-rw-r--r-- | mojo/system/core_impl.h | 2 |
13 files changed, 197 insertions, 29 deletions
diff --git a/mojo/gles2/export.h b/mojo/gles2/export.h new file mode 100644 index 0000000..bf58015 --- /dev/null +++ b/mojo/gles2/export.h @@ -0,0 +1,29 @@ +// 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_GLES2_EXPORT_H_ +#define MOJO_GLES2_EXPORT_H_ + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(MOJO_GLES2_IMPL_IMPLEMENTATION) +#define MOJO_GLES2_IMPL_EXPORT __declspec(dllexport) +#else +#define MOJO_GLES2_IMPL_EXPORT __declspec(dllimport) +#endif // defined(MOJO_GLES2_IMPL_IMPLEMENTATION) + +#else // defined(WIN32) +#if defined(MOJO_GLES2_IMPL_IMPLEMENTATION) +#define MOJO_GLES2_IMPL_EXPORT __attribute__((visibility("default"))) +#else +#define MOJO_GLES2_IMPL_EXPORT +#endif +#endif + +#else // defined(COMPONENT_BUILD) +#define MOJO_GLES2_IMPL_EXPORT +#endif + +#endif // MOJO_GLES2_EXPORT_H_ diff --git a/mojo/gles2/gles2.cc b/mojo/gles2/gles2_impl.cc index c90a331..53970ee 100644 --- a/mojo/gles2/gles2.cc +++ b/mojo/gles2/gles2_impl.cc @@ -2,21 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/public/gles2/gles2.h" +#include "mojo/gles2/gles2_impl.h" #include "gpu/command_buffer/client/gles2_lib.h" +#include "mojo/public/gles2/gles2_private.h" -extern "C" { +namespace mojo { +namespace gles2 { -void MojoGLES2Initialize() { - gles2::Initialize(); +GLES2Impl::GLES2Impl() { } -void MojoGLES2Terminate() { - gles2::Terminate(); +GLES2Impl::~GLES2Impl() { } -void MojoGLES2MakeCurrent(uint64_t encoded) { +void GLES2Impl::Init() { + GLES2Private::Init(new GLES2Impl()); +} + +void GLES2Impl::Initialize() { + ::gles2::Initialize(); +} + +void GLES2Impl::Terminate() { + ::gles2::Terminate(); +} + +void GLES2Impl::MakeCurrent(uint64_t encoded) { // 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 @@ -25,11 +37,12 @@ void MojoGLES2MakeCurrent(uint64_t encoded) { gpu::gles2::GLES2Interface* gl_interface = reinterpret_cast<gpu::gles2::GLES2Interface*>( static_cast<uintptr_t>(encoded)); - gles2::SetGLContext(gl_interface); + ::gles2::SetGLContext(gl_interface); } -void MojoGLES2SwapBuffers() { - gles2::GetGLContext()->SwapBuffers(); +void GLES2Impl::SwapBuffers() { + ::gles2::GetGLContext()->SwapBuffers(); } -} // extern "C" +} // namespace gles2 +} // namespace mojo diff --git a/mojo/gles2/gles2_impl.h b/mojo/gles2/gles2_impl.h new file mode 100644 index 0000000..8931df31 --- /dev/null +++ b/mojo/gles2/gles2_impl.h @@ -0,0 +1,35 @@ +// 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_GLES2_GLES2_IMPL_H_ +#define MOJO_GLES2_GLES2_IMPL_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "mojo/gles2/export.h" +#include "mojo/public/gles2/gles2_private.h" + +namespace mojo { +namespace gles2 { + +class MOJO_GLES2_IMPL_EXPORT GLES2Impl : public GLES2Private { + public: + GLES2Impl(); + virtual ~GLES2Impl(); + + static void Init(); + + virtual void Initialize() OVERRIDE; + virtual void Terminate() OVERRIDE; + virtual void MakeCurrent(uint64_t encoded) OVERRIDE; + virtual void SwapBuffers() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(GLES2Impl); +}; + +} // namespace gles2 +} // namespace mojo + +#endif // MOJO_GLES2_GLES2_IMPL_H_ diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index b5ea669..1de4f76 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -141,16 +141,19 @@ ], }, { - 'target_name': 'mojo_gles2', + 'target_name': 'mojo_gles2_impl', 'type': '<(component)', 'dependencies': [ '../gpu/gpu.gyp:gles2_c_lib', + 'mojo_gles2', ], 'defines': [ - 'MOJO_GLES2_IMPLEMENTATION', + 'MOJO_GLES2_IMPL_IMPLEMENTATION', ], 'sources': [ - 'gles2/gles2.cc', + 'gles2/export.h', + 'gles2/gles2_impl.cc', + 'gles2/gles2_impl.h', ], }, { @@ -221,9 +224,10 @@ '../net/net.gyp:net', '../url/url.gyp:url_lib', 'mojo_bindings', + 'mojo_gles2_impl', + 'mojo_native_viewport_service', 'mojo_system', 'mojo_system_impl', - 'mojo_native_viewport_service', ], 'sources': [ 'shell/app_container.cc', diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi index 2a106f6..f3b1cd8 100644 --- a/mojo/mojo_public.gypi +++ b/mojo/mojo_public.gypi @@ -24,6 +24,26 @@ ], }, { + 'target_name': 'mojo_gles2', + 'type': 'shared_library', + 'defines': [ + 'MOJO_GLES2_IMPLEMENTATION', + ], + 'include_dirs': [ + '..', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '..', + ], + }, + 'sources': [ + 'public/gles2/gles2.h', + 'public/gles2/gles2_private.cc', + 'public/gles2/gles2_private.h', + ], + }, + { 'target_name': 'mojo_public_test_support', 'type': 'static_library', 'dependencies': [ diff --git a/mojo/public/gles2/gles2.h b/mojo/public/gles2/gles2.h index fbcb2c7..7e89712 100644 --- a/mojo/public/gles2/gles2.h +++ b/mojo/public/gles2/gles2.h @@ -9,8 +9,6 @@ #include <stdint.h> -#if defined(COMPONENT_BUILD) - #if defined(WIN32) #if defined(MOJO_GLES2_IMPLEMENTATION) @@ -29,10 +27,6 @@ #endif // defined(WIN32) -#else // !defined(COMPONENT_BUILD) -#define MOJO_GLES2_EXPORT -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/mojo/public/gles2/gles2_private.cc b/mojo/public/gles2/gles2_private.cc new file mode 100644 index 0000000..8df1660 --- /dev/null +++ b/mojo/public/gles2/gles2_private.cc @@ -0,0 +1,42 @@ +// 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/gles2/gles2_private.h" + +#include <assert.h> +#include <stddef.h> + +static mojo::GLES2Private* g_private = NULL; + +extern "C" { + +void MojoGLES2Initialize() { + g_private->Initialize(); +} + +void MojoGLES2Terminate() { + g_private->Terminate(); +} + +void MojoGLES2MakeCurrent(uint64_t encoded) { + g_private->MakeCurrent(encoded); +} + +void MojoGLES2SwapBuffers() { + g_private->SwapBuffers(); +} + +} // extern "C" + +namespace mojo { + +GLES2Private::~GLES2Private() { +} + +void GLES2Private::Init(GLES2Private* priv) { + assert(!g_private); + g_private = priv; +} + +} // namespace mojo diff --git a/mojo/public/gles2/gles2_private.h b/mojo/public/gles2/gles2_private.h new file mode 100644 index 0000000..8fd0d0c --- /dev/null +++ b/mojo/public/gles2/gles2_private.h @@ -0,0 +1,29 @@ +// 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_SYSTEM_GLES2_PRIVATE_H_ +#define MOJO_PUBLIC_SYSTEM_GLES2_PRIVATE_H_ + +#include "mojo/public/gles2/gles2.h" + +namespace mojo { + +// Implementors of the gles2 APIs can use this interface to install their +// implementation into the mojo_gles2 dynamic library. Mojo clients should not +// call these functions directly. +class MOJO_GLES2_EXPORT GLES2Private { + public: + virtual ~GLES2Private(); + + static void Init(GLES2Private* priv); + + virtual void Initialize() = 0; + virtual void Terminate() = 0; + virtual void MakeCurrent(uint64_t encoded) = 0; + virtual void SwapBuffers() = 0; +}; + +} // namespace mojo + +#endif // MOJO_PUBLIC_SYSTEM_GLES2_PRIVATE_H_ diff --git a/mojo/public/system/core_private.cc b/mojo/public/system/core_private.cc index bc37ac0..3854c65 100644 --- a/mojo/public/system/core_private.cc +++ b/mojo/public/system/core_private.cc @@ -7,7 +7,7 @@ #include <assert.h> #include <stddef.h> -static mojo::Core* g_core = NULL; +static mojo::CorePrivate* g_core = NULL; extern "C" { @@ -67,10 +67,10 @@ MojoTimeTicks MojoGetTimeTicksNow() { namespace mojo { -Core::~Core() { +CorePrivate::~CorePrivate() { } -void Core::Init(Core* core) { +void CorePrivate::Init(CorePrivate* core) { assert(!g_core); g_core = core; } diff --git a/mojo/public/system/core_private.h b/mojo/public/system/core_private.h index adda16f..d72addd 100644 --- a/mojo/public/system/core_private.h +++ b/mojo/public/system/core_private.h @@ -12,11 +12,11 @@ namespace mojo { // Implementors of the core APIs can use this interface to install their // implementation into the mojo_system dynamic library. Mojo clients should not // call these functions directly. -class MOJO_SYSTEM_EXPORT Core { +class MOJO_SYSTEM_EXPORT CorePrivate { public: - virtual ~Core(); + virtual ~CorePrivate(); - static void Init(Core* core); + static void Init(CorePrivate* core); virtual MojoResult Close(MojoHandle handle) = 0; virtual MojoResult Wait(MojoHandle handle, diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc index 9088b3f..2eb130a 100644 --- a/mojo/shell/context.cc +++ b/mojo/shell/context.cc @@ -4,6 +4,7 @@ #include "mojo/shell/context.h" +#include "mojo/gles2/gles2_impl.h" #include "mojo/shell/network_delegate.h" #include "mojo/system/core_impl.h" @@ -19,6 +20,7 @@ Context::Context() scoped_ptr<net::NetworkDelegate>(new NetworkDelegate()), storage_.profile_path()) { system::CoreImpl::Init(); + gles2::GLES2Impl::Init(); BindingsSupport::Set(&bindings_support_impl_); } diff --git a/mojo/system/core_impl.cc b/mojo/system/core_impl.cc index 304e49e..a04750f 100644 --- a/mojo/system/core_impl.cc +++ b/mojo/system/core_impl.cc @@ -83,7 +83,7 @@ CoreImpl::HandleTableEntry::~HandleTableEntry() { // static void CoreImpl::Init() { - Core::Init(new CoreImpl()); + CorePrivate::Init(new CoreImpl()); } MojoResult CoreImpl::Close(MojoHandle handle) { diff --git a/mojo/system/core_impl.h b/mojo/system/core_impl.h index 6548f20..a6d5f0e 100644 --- a/mojo/system/core_impl.h +++ b/mojo/system/core_impl.h @@ -27,7 +27,7 @@ class CoreTestBase; // the (obvious) exception of |Init()|, which must be called first (and the call // completed) before making any other calls, all the public methods are // thread-safe. -class MOJO_SYSTEM_IMPL_EXPORT CoreImpl : public Core { +class MOJO_SYSTEM_IMPL_EXPORT CoreImpl : public CorePrivate { public: static void Init(); |