OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "components/native_viewport/native_viewport_application_delegate.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "components/native_viewport/native_viewport_impl.h" |
| 9 #include "components/native_viewport/public/cpp/args.h" |
| 10 #include "mojo/application/public/cpp/application_connection.h" |
| 11 #include "mojo/application/public/cpp/application_impl.h" |
| 12 #include "ui/events/event_switches.h" |
| 13 #include "ui/gl/gl_surface.h" |
| 14 |
| 15 namespace native_viewport { |
| 16 |
| 17 NativeViewportApplicationDelegate::NativeViewportApplicationDelegate() |
| 18 : is_headless_(false) { |
| 19 } |
| 20 |
| 21 NativeViewportApplicationDelegate::~NativeViewportApplicationDelegate() { |
| 22 } |
| 23 |
| 24 void NativeViewportApplicationDelegate::Initialize( |
| 25 mojo::ApplicationImpl* application) { |
| 26 tracing_.Initialize(application); |
| 27 |
| 28 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 29 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); |
| 30 if (!is_headless_) { |
| 31 if (command_line->HasSwitch(mojo::kUseTestConfig)) |
| 32 gfx::GLSurface::InitializeOneOffForTests(); |
| 33 else |
| 34 gfx::GLSurface::InitializeOneOff(); |
| 35 } |
| 36 } |
| 37 |
| 38 bool NativeViewportApplicationDelegate::ConfigureIncomingConnection( |
| 39 mojo::ApplicationConnection* connection) { |
| 40 connection->AddService<mojo::NativeViewport>(this); |
| 41 connection->AddService<mojo::Gpu>(this); |
| 42 return true; |
| 43 } |
| 44 |
| 45 void NativeViewportApplicationDelegate::Create( |
| 46 mojo::ApplicationConnection* connection, |
| 47 mojo::InterfaceRequest<mojo::NativeViewport> request) { |
| 48 if (!gpu_state_.get()) |
| 49 gpu_state_ = new gles2::GpuState; |
| 50 new NativeViewportImpl(is_headless_, gpu_state_, request.Pass()); |
| 51 } |
| 52 |
| 53 void NativeViewportApplicationDelegate::Create( |
| 54 mojo::ApplicationConnection* connection, |
| 55 mojo::InterfaceRequest<mojo::Gpu> request) { |
| 56 if (!gpu_state_.get()) |
| 57 gpu_state_ = new gles2::GpuState; |
| 58 new gles2::GpuImpl(request.Pass(), gpu_state_); |
| 59 } |
| 60 |
| 61 } // namespace native_viewport |
OLD | NEW |