Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: services/native_viewport/app_delegate.cc

Issue 1309273005: native_viewport support for ozone (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/native_viewport/app_delegate.h ('k') | services/native_viewport/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <vector>
6 #include "services/native_viewport/app_delegate.h"
7
8 namespace native_viewport {
9
10 NativeViewportAppDelegate::NativeViewportAppDelegate() : is_headless_(false) {}
11
12 NativeViewportAppDelegate::~NativeViewportAppDelegate() {}
13
14 void NativeViewportAppDelegate::InitLogging(
15 mojo::ApplicationImpl* application) {
16 std::vector<const char*> args;
17 for (auto& a : application->args()) {
18 args.push_back(a.c_str());
19 }
20
21 base::CommandLine::Reset();
22 base::CommandLine::Init(args.size(), args.data());
23
24 logging::LoggingSettings settings;
25 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
26 logging::InitLogging(settings);
27 }
28
29 void NativeViewportAppDelegate::Initialize(mojo::ApplicationImpl* application) {
30 application_ = application;
31
32 InitLogging(application);
33 tracing_.Initialize(application);
34
35 // Apply the switch for kTouchEvents to CommandLine (if set). This allows
36 // redirecting the mouse to a touch device on X for testing.
37 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
38 const std::string touch_event_string("--" +
39 std::string(switches::kTouchDevices));
40 auto touch_iter = std::find(application->args().begin(),
41 application->args().end(), touch_event_string);
42 if (touch_iter != application->args().end() &&
43 ++touch_iter != application->args().end()) {
44 command_line->AppendSwitchASCII(touch_event_string, *touch_iter);
45 }
46
47 if (application->HasArg(mojo::kUseTestConfig))
48 gfx::GLSurface::InitializeOneOffForTests();
49 else if (application->HasArg(mojo::kUseOSMesa))
50 gfx::GLSurface::InitializeOneOff(gfx::kGLImplementationOSMesaGL);
51 else
52 gfx::GLSurface::InitializeOneOff();
53
54 is_headless_ = application->HasArg(mojo::kUseHeadlessConfig);
55 }
56
57 bool NativeViewportAppDelegate::ConfigureIncomingConnection(
58 ApplicationConnection* connection) {
59 connection->AddService<NativeViewport>(this);
60 connection->AddService<Gpu>(this);
61 return true;
62 }
63
64 void NativeViewportAppDelegate::Create(
65 ApplicationConnection* connection,
66 mojo::InterfaceRequest<NativeViewport> request) {
67 if (!gpu_state_.get())
68 gpu_state_ = new gles2::GpuState;
69 new NativeViewportImpl(application_, is_headless_, gpu_state_,
70 request.Pass());
71 }
72
73 void NativeViewportAppDelegate::Create(ApplicationConnection* connection,
74 mojo::InterfaceRequest<Gpu> request) {
75 if (!gpu_state_.get())
76 gpu_state_ = new gles2::GpuState;
77 new gles2::GpuImpl(request.Pass(), gpu_state_);
78 }
79
80 } // namespace native_viewport
OLDNEW
« no previous file with comments | « services/native_viewport/app_delegate.h ('k') | services/native_viewport/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698