| 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 "mojo/application/application_runner_chromium.h" | 7 #include "mojo/application/application_runner_chromium.h" |
| 8 #include "mojo/common/tracing_impl.h" | 8 #include "mojo/common/tracing_impl.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 49 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
| 50 connection->AddService<NativeViewport>(this); | 50 connection->AddService<NativeViewport>(this); |
| 51 connection->AddService<Gpu>(this); | 51 connection->AddService<Gpu>(this); |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // mojo::InterfaceFactory<NativeViewport> implementation. | 55 // mojo::InterfaceFactory<NativeViewport> implementation. |
| 56 void Create(ApplicationConnection* connection, | 56 void Create(ApplicationConnection* connection, |
| 57 mojo::InterfaceRequest<NativeViewport> request) override { | 57 mojo::InterfaceRequest<NativeViewport> request) override { |
| 58 new NativeViewportImpl(app_, is_headless_, request.Pass()); | 58 if (!gpu_state_.get()) |
| 59 gpu_state_ = new gles2::GpuState; |
| 60 new NativeViewportImpl(app_, is_headless_, gpu_state_, request.Pass()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 // mojo::InterfaceFactory<Gpu> implementation. | 63 // mojo::InterfaceFactory<Gpu> implementation. |
| 62 void Create(ApplicationConnection* connection, | 64 void Create(ApplicationConnection* connection, |
| 63 mojo::InterfaceRequest<Gpu> request) override { | 65 mojo::InterfaceRequest<Gpu> request) override { |
| 64 if (!gpu_state_.get()) | 66 if (!gpu_state_.get()) |
| 65 gpu_state_ = new gles2::GpuImpl::State; | 67 gpu_state_ = new gles2::GpuState; |
| 66 new gles2::GpuImpl(request.Pass(), gpu_state_); | 68 new gles2::GpuImpl(request.Pass(), gpu_state_); |
| 67 } | 69 } |
| 68 | 70 |
| 69 mojo::ApplicationImpl* app_; | 71 mojo::ApplicationImpl* app_; |
| 70 scoped_refptr<gles2::GpuImpl::State> gpu_state_; | 72 scoped_refptr<gles2::GpuState> gpu_state_; |
| 71 bool is_headless_; | 73 bool is_headless_; |
| 72 mojo::TracingImpl tracing_; | 74 mojo::TracingImpl tracing_; |
| 73 | 75 |
| 74 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
| 75 }; | 77 }; |
| 76 } | 78 } |
| 77 | 79 |
| 78 MojoResult MojoMain(MojoHandle shell_handle) { | 80 MojoResult MojoMain(MojoHandle shell_handle) { |
| 79 mojo::ApplicationRunnerChromium runner( | 81 mojo::ApplicationRunnerChromium runner( |
| 80 new native_viewport::NativeViewportAppDelegate); | 82 new native_viewport::NativeViewportAppDelegate); |
| 81 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); | 83 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
| 82 return runner.Run(shell_handle); | 84 return runner.Run(shell_handle); |
| 83 } | 85 } |
| OLD | NEW |