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

Side by Side Diff: mojo/services/native_viewport/main.cc

Issue 769173002: Move native_viewport and gles2 service impls to //services (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
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 "base/macros.h"
6 #include "base/message_loop/message_loop.h"
7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/common/tracing_impl.h"
9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_connection.h"
11 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/application_impl.h"
13 #include "mojo/public/cpp/application/interface_factory_impl.h"
14 #include "mojo/services/gles2/gpu_impl.h"
15 #include "mojo/services/native_viewport/native_viewport_impl.h"
16 #include "mojo/services/public/cpp/native_viewport/args.h"
17 #include "ui/gl/gl_surface.h"
18
19 namespace mojo {
20
21 class NativeViewportAppDelegate
22 : public ApplicationDelegate,
23 public InterfaceFactory<NativeViewport>,
24 public InterfaceFactory<Gpu> {
25 public:
26 NativeViewportAppDelegate() : is_headless_(false) {}
27 ~NativeViewportAppDelegate() override {}
28
29 private:
30 // ApplicationDelegate implementation.
31 void Initialize(ApplicationImpl* application) override {
32 app_ = application;
33
34 TracingImpl::Create(application);
35
36 if (app_->HasArg(kUseTestConfig))
37 gfx::GLSurface::InitializeOneOffForTests();
38 else if (app_->HasArg(kUseOSMesa))
39 gfx::GLSurface::InitializeOneOff(gfx::kGLImplementationOSMesaGL);
40 else
41 gfx::GLSurface::InitializeOneOff();
42
43 is_headless_ = app_->HasArg(kUseHeadlessConfig);
44 }
45
46 bool ConfigureIncomingConnection(
47 mojo::ApplicationConnection* connection) override {
48 connection->AddService<NativeViewport>(this);
49 connection->AddService<Gpu>(this);
50 return true;
51 }
52
53 // InterfaceFactory<NativeViewport> implementation.
54 void Create(ApplicationConnection* connection,
55 InterfaceRequest<NativeViewport> request) override {
56 BindToRequest(new NativeViewportImpl(app_, is_headless_), &request);
57 }
58
59 // InterfaceFactory<Gpu> implementation.
60 void Create(ApplicationConnection* connection,
61 InterfaceRequest<Gpu> request) override {
62 if (!gpu_state_.get())
63 gpu_state_ = new GpuImpl::State;
64 new GpuImpl(request.Pass(), gpu_state_);
65 }
66
67 ApplicationImpl* app_;
68 scoped_refptr<GpuImpl::State> gpu_state_;
69 bool is_headless_;
70 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate);
71 };
72 }
73
74 MojoResult MojoMain(MojoHandle shell_handle) {
75 mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate);
76 runner.set_message_loop_type(base::MessageLoop::TYPE_UI);
77 return runner.Run(shell_handle);
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698