| 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_impl.h" | |
| 8 #include "mojo/application/application_runner_chromium.h" | 7 #include "mojo/application/application_runner_chromium.h" |
| 9 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
| 11 #include "mojo/public/cpp/application/application_delegate.h" | 10 #include "mojo/public/cpp/application/application_delegate.h" |
| 12 #include "mojo/public/cpp/application/application_impl.h" | 11 #include "mojo/public/cpp/application/application_impl.h" |
| 13 #include "mojo/public/cpp/application/interface_factory_impl.h" | 12 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 14 #include "mojo/services/gles2/gpu_impl.h" | 13 #include "mojo/services/gles2/gpu_impl.h" |
| 15 #include "mojo/services/native_viewport/native_viewport_impl.h" | 14 #include "mojo/services/native_viewport/native_viewport_impl.h" |
| 16 #include "mojo/services/public/cpp/native_viewport/args.h" | 15 #include "mojo/services/public/cpp/native_viewport/args.h" |
| 17 #include "ui/gl/gl_share_group.h" | |
| 18 #include "ui/gl/gl_surface.h" | 16 #include "ui/gl/gl_surface.h" |
| 19 | 17 |
| 20 namespace mojo { | 18 namespace mojo { |
| 21 | 19 |
| 22 class NativeViewportAppDelegate | 20 class NativeViewportAppDelegate |
| 23 : public ApplicationDelegate, | 21 : public ApplicationDelegate, |
| 24 public InterfaceFactory<NativeViewport>, | 22 public InterfaceFactory<NativeViewport>, |
| 25 public InterfaceFactory<Gpu> { | 23 public InterfaceFactory<Gpu> { |
| 26 public: | 24 public: |
| 27 NativeViewportAppDelegate() | 25 NativeViewportAppDelegate() : is_headless_(false) {} |
| 28 : share_group_(new gfx::GLShareGroup), | |
| 29 mailbox_manager_(new gpu::gles2::MailboxManagerImpl), | |
| 30 is_headless_(false) {} | |
| 31 ~NativeViewportAppDelegate() override {} | 26 ~NativeViewportAppDelegate() override {} |
| 32 | 27 |
| 33 private: | 28 private: |
| 34 // ApplicationDelegate implementation. | 29 // ApplicationDelegate implementation. |
| 35 void Initialize(ApplicationImpl* application) override { | 30 void Initialize(ApplicationImpl* application) override { |
| 36 app_ = application; | 31 app_ = application; |
| 37 | 32 |
| 38 if (app_->HasArg(kUseTestConfig)) | 33 if (app_->HasArg(kUseTestConfig)) |
| 39 gfx::GLSurface::InitializeOneOffForTests(); | 34 gfx::GLSurface::InitializeOneOffForTests(); |
| 40 else if (app_->HasArg(kUseOSMesa)) | 35 else if (app_->HasArg(kUseOSMesa)) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 54 | 49 |
| 55 // InterfaceFactory<NativeViewport> implementation. | 50 // InterfaceFactory<NativeViewport> implementation. |
| 56 void Create(ApplicationConnection* connection, | 51 void Create(ApplicationConnection* connection, |
| 57 InterfaceRequest<NativeViewport> request) override { | 52 InterfaceRequest<NativeViewport> request) override { |
| 58 BindToRequest(new NativeViewportImpl(app_, is_headless_), &request); | 53 BindToRequest(new NativeViewportImpl(app_, is_headless_), &request); |
| 59 } | 54 } |
| 60 | 55 |
| 61 // InterfaceFactory<Gpu> implementation. | 56 // InterfaceFactory<Gpu> implementation. |
| 62 void Create(ApplicationConnection* connection, | 57 void Create(ApplicationConnection* connection, |
| 63 InterfaceRequest<Gpu> request) override { | 58 InterfaceRequest<Gpu> request) override { |
| 64 new GpuImpl(request.Pass(), share_group_.get(), mailbox_manager_.get()); | 59 if (!gpu_state_.get()) |
| 60 gpu_state_ = new GpuImpl::State; |
| 61 new GpuImpl(request.Pass(), gpu_state_); |
| 65 } | 62 } |
| 66 | 63 |
| 67 ApplicationImpl* app_; | 64 ApplicationImpl* app_; |
| 68 scoped_refptr<gfx::GLShareGroup> share_group_; | 65 scoped_refptr<GpuImpl::State> gpu_state_; |
| 69 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | |
| 70 bool is_headless_; | 66 bool is_headless_; |
| 71 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
| 72 }; | 68 }; |
| 73 } | 69 } |
| 74 | 70 |
| 75 MojoResult MojoMain(MojoHandle shell_handle) { | 71 MojoResult MojoMain(MojoHandle shell_handle) { |
| 76 mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate); | 72 mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate); |
| 77 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); | 73 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
| 78 return runner.Run(shell_handle); | 74 return runner.Run(shell_handle); |
| 79 } | 75 } |
| OLD | NEW |