OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/message_loop/message_loop.h" | |
6 #include "gpu/command_buffer/service/mailbox_manager.h" | |
7 #include "mojo/public/c/system/main.h" | |
8 #include "mojo/public/cpp/application/application_connection.h" | |
9 #include "mojo/public/cpp/application/application_delegate.h" | |
10 #include "mojo/public/cpp/application/application_runner_chromium.h" | |
11 #include "mojo/public/cpp/application/interface_factory_impl.h" | |
12 #include "mojo/services/native_viewport/gpu_impl.h" | |
13 #include "mojo/services/native_viewport/native_viewport_impl.h" | |
14 #include "ui/gl/gl_share_group.h" | |
15 #include "ui/gl/gl_surface.h" | |
16 | |
17 namespace mojo { | |
18 | |
19 class NativeViewportAppDelegate : public ApplicationDelegate, | |
20 public InterfaceFactory<NativeViewport>, | |
21 public InterfaceFactory<Gpu> { | |
22 public: | |
23 NativeViewportAppDelegate() | |
24 : share_group_(new gfx::GLShareGroup), | |
25 mailbox_manager_(new gpu::gles2::MailboxManager) {} | |
26 virtual ~NativeViewportAppDelegate() {} | |
27 | |
28 private: | |
29 // ApplicationDelegate implementation. | |
30 virtual void Initialize(ApplicationImpl* application) OVERRIDE { | |
31 app_ = application; | |
32 #if !defined(COMPONENT_BUILD) | |
33 gfx::GLSurface::InitializeOneOff(); | |
34 #endif | |
35 } | |
36 | |
37 virtual bool ConfigureIncomingConnection( | |
38 mojo::ApplicationConnection* connection) OVERRIDE { | |
39 connection->AddService<NativeViewport>(this); | |
40 connection->AddService<Gpu>(this); | |
41 return true; | |
42 } | |
43 | |
44 // InterfaceFactory<NativeViewport> implementation. | |
45 virtual void Create(ApplicationConnection* connection, | |
46 InterfaceRequest<NativeViewport> request) OVERRIDE { | |
47 BindToRequest(new NativeViewportImpl(app_), &request); | |
48 } | |
49 | |
50 // InterfaceFactory<Gpu> implementation. | |
51 virtual void Create(ApplicationConnection* connection, | |
52 InterfaceRequest<Gpu> request) OVERRIDE { | |
53 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), | |
54 &request); | |
55 } | |
56 | |
57 ApplicationImpl* app_; | |
58 scoped_refptr<gfx::GLShareGroup> share_group_; | |
59 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | |
60 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); | |
61 }; | |
62 } | |
Ben Goodger (Google)
2014/09/02 22:24:16
nit: NL after
DaveMoore
2014/09/02 22:39:06
Done.
| |
63 class NativeViewportAppDelegate : public mojo::ApplicationDelegate { | |
64 public: | |
65 virtual bool ConfigureIncomingConnection( | |
66 mojo::ApplicationConnection* connection) OVERRIDE { | |
67 connection->AddService(&native_viewport_factory_); | |
68 return true; | |
69 } | |
70 | |
71 private: | |
72 mojo::InterfaceFactoryImpl<mojo::NativeViewportImpl> native_viewport_factory_; | |
73 }; | |
74 | |
75 MojoResult MojoMain(MojoHandle shell_handle) { | |
76 mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate); | |
77 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); | |
78 return runner.Run(shell_handle); | |
79 } | |
OLD | NEW |