Chromium Code Reviews| Index: mojo/services/native_viewport/main.cc |
| diff --git a/mojo/services/native_viewport/main.cc b/mojo/services/native_viewport/main.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cbff350bbf08b128750bfa1209b9e5e16625468f |
| --- /dev/null |
| +++ b/mojo/services/native_viewport/main.cc |
| @@ -0,0 +1,79 @@ |
| +// 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 "base/message_loop/message_loop.h" |
| +#include "gpu/command_buffer/service/mailbox_manager.h" |
| +#include "mojo/public/c/system/main.h" |
| +#include "mojo/public/cpp/application/application_connection.h" |
| +#include "mojo/public/cpp/application/application_delegate.h" |
| +#include "mojo/public/cpp/application/application_runner_chromium.h" |
| +#include "mojo/public/cpp/application/interface_factory_impl.h" |
| +#include "mojo/services/native_viewport/gpu_impl.h" |
| +#include "mojo/services/native_viewport/native_viewport_impl.h" |
| +#include "ui/gl/gl_share_group.h" |
| +#include "ui/gl/gl_surface.h" |
| + |
| +namespace mojo { |
| + |
| +class NativeViewportAppDelegate : public ApplicationDelegate, |
| + public InterfaceFactory<NativeViewport>, |
| + public InterfaceFactory<Gpu> { |
| + public: |
| + NativeViewportAppDelegate() |
| + : share_group_(new gfx::GLShareGroup), |
| + mailbox_manager_(new gpu::gles2::MailboxManager) {} |
| + virtual ~NativeViewportAppDelegate() {} |
| + |
| + private: |
| + // ApplicationDelegate implementation. |
| + virtual void Initialize(ApplicationImpl* application) OVERRIDE { |
| + app_ = application; |
| +#if !defined(COMPONENT_BUILD) |
| + gfx::GLSurface::InitializeOneOff(); |
| +#endif |
| + } |
| + |
| + virtual bool ConfigureIncomingConnection( |
| + mojo::ApplicationConnection* connection) OVERRIDE { |
| + connection->AddService<NativeViewport>(this); |
| + connection->AddService<Gpu>(this); |
| + return true; |
| + } |
| + |
| + // InterfaceFactory<NativeViewport> implementation. |
| + virtual void Create(ApplicationConnection* connection, |
| + InterfaceRequest<NativeViewport> request) OVERRIDE { |
| + BindToRequest(new NativeViewportImpl(app_), &request); |
| + } |
| + |
| + // InterfaceFactory<Gpu> implementation. |
| + virtual void Create(ApplicationConnection* connection, |
| + InterfaceRequest<Gpu> request) OVERRIDE { |
| + BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), |
| + &request); |
| + } |
| + |
| + ApplicationImpl* app_; |
| + scoped_refptr<gfx::GLShareGroup> share_group_; |
| + scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
| + DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
| +}; |
| +} |
|
Ben Goodger (Google)
2014/09/02 22:24:16
nit: NL after
DaveMoore
2014/09/02 22:39:06
Done.
|
| +class NativeViewportAppDelegate : public mojo::ApplicationDelegate { |
| + public: |
| + virtual bool ConfigureIncomingConnection( |
| + mojo::ApplicationConnection* connection) OVERRIDE { |
| + connection->AddService(&native_viewport_factory_); |
| + return true; |
| + } |
| + |
| + private: |
| + mojo::InterfaceFactoryImpl<mojo::NativeViewportImpl> native_viewport_factory_; |
| +}; |
| + |
| +MojoResult MojoMain(MojoHandle shell_handle) { |
| + mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate); |
| + runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
| + return runner.Run(shell_handle); |
| +} |