OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "gpu/command_buffer/service/mailbox_manager.h" | 7 #include "gpu/command_buffer/service/mailbox_manager.h" |
8 #include "mojo/application/application_runner_chromium.h" | 8 #include "mojo/application/application_runner_chromium.h" |
9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class NativeViewportAppDelegate | 22 class NativeViewportAppDelegate |
23 : public ApplicationDelegate, | 23 : public ApplicationDelegate, |
24 public InterfaceFactory<NativeViewport>, | 24 public InterfaceFactory<NativeViewport>, |
25 public InterfaceFactory<Gpu> { | 25 public InterfaceFactory<Gpu> { |
26 public: | 26 public: |
27 NativeViewportAppDelegate() | 27 NativeViewportAppDelegate() |
28 : share_group_(new gfx::GLShareGroup), | 28 : share_group_(new gfx::GLShareGroup), |
29 mailbox_manager_(new gpu::gles2::MailboxManager), | 29 mailbox_manager_(new gpu::gles2::MailboxManager), |
30 is_headless_(false) {} | 30 is_headless_(false) {} |
31 virtual ~NativeViewportAppDelegate() {} | 31 ~NativeViewportAppDelegate() override {} |
32 | 32 |
33 private: | 33 private: |
34 bool HasArg(const std::string& arg) { | 34 bool HasArg(const std::string& arg) { |
35 const auto& args = app_->args(); | 35 const auto& args = app_->args(); |
36 return std::find(args.begin(), args.end(), arg) != args.end(); | 36 return std::find(args.begin(), args.end(), arg) != args.end(); |
37 } | 37 } |
38 | 38 |
39 // ApplicationDelegate implementation. | 39 // ApplicationDelegate implementation. |
40 virtual void Initialize(ApplicationImpl* application) override { | 40 void Initialize(ApplicationImpl* application) override { |
41 app_ = application; | 41 app_ = application; |
42 | 42 |
43 #if !defined(COMPONENT_BUILD) | 43 #if !defined(COMPONENT_BUILD) |
44 if (HasArg(kUseTestConfig)) | 44 if (HasArg(kUseTestConfig)) |
45 gfx::GLSurface::InitializeOneOffForTests(); | 45 gfx::GLSurface::InitializeOneOffForTests(); |
46 else | 46 else |
47 gfx::GLSurface::InitializeOneOff(); | 47 gfx::GLSurface::InitializeOneOff(); |
48 #endif | 48 #endif |
49 is_headless_ = HasArg(kUseHeadlessConfig); | 49 is_headless_ = HasArg(kUseHeadlessConfig); |
50 } | 50 } |
51 | 51 |
52 virtual bool ConfigureIncomingConnection( | 52 bool ConfigureIncomingConnection( |
53 mojo::ApplicationConnection* connection) override { | 53 mojo::ApplicationConnection* connection) override { |
54 connection->AddService<NativeViewport>(this); | 54 connection->AddService<NativeViewport>(this); |
55 connection->AddService<Gpu>(this); | 55 connection->AddService<Gpu>(this); |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 // InterfaceFactory<NativeViewport> implementation. | 59 // InterfaceFactory<NativeViewport> implementation. |
60 virtual void Create(ApplicationConnection* connection, | 60 void Create(ApplicationConnection* connection, |
61 InterfaceRequest<NativeViewport> request) override { | 61 InterfaceRequest<NativeViewport> request) override { |
62 BindToRequest(new NativeViewportImpl(app_, is_headless_), &request); | 62 BindToRequest(new NativeViewportImpl(app_, is_headless_), &request); |
63 } | 63 } |
64 | 64 |
65 // InterfaceFactory<Gpu> implementation. | 65 // InterfaceFactory<Gpu> implementation. |
66 virtual void Create(ApplicationConnection* connection, | 66 void Create(ApplicationConnection* connection, |
67 InterfaceRequest<Gpu> request) override { | 67 InterfaceRequest<Gpu> request) override { |
68 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), | 68 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), |
69 &request); | 69 &request); |
70 } | 70 } |
71 | 71 |
72 ApplicationImpl* app_; | 72 ApplicationImpl* app_; |
73 scoped_refptr<gfx::GLShareGroup> share_group_; | 73 scoped_refptr<gfx::GLShareGroup> share_group_; |
74 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 74 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
75 bool is_headless_; | 75 bool is_headless_; |
76 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
77 }; | 77 }; |
78 } | 78 } |
79 | 79 |
80 MojoResult MojoMain(MojoHandle shell_handle) { | 80 MojoResult MojoMain(MojoHandle shell_handle) { |
81 mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate); | 81 mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate); |
82 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); | 82 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
83 return runner.Run(shell_handle); | 83 return runner.Run(shell_handle); |
84 } | 84 } |
OLD | NEW |