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

Side by Side Diff: services/surfaces/surfaces_service_application.cc

Issue 940293003: Add a Display and ContextProvider concept to mojom, use to recreate (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
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 "services/surfaces/surfaces_service_application.h" 5 #include "services/surfaces/surfaces_service_application.h"
6 6
7 #include "cc/surfaces/display.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"
9 #include "services/surfaces/display_factory_impl.h"
10 #include "services/surfaces/surfaces_impl.h" 10 #include "services/surfaces/surfaces_impl.h"
11 #include "services/surfaces/surfaces_scheduler.h"
11 12
12 namespace surfaces { 13 namespace surfaces {
13 14
14 SurfacesServiceApplication::SurfacesServiceApplication() 15 SurfacesServiceApplication::SurfacesServiceApplication()
15 : next_id_namespace_(1u), display_(nullptr) { 16 : next_id_namespace_(1u) {
16 } 17 }
17 18
18 SurfacesServiceApplication::~SurfacesServiceApplication() { 19 SurfacesServiceApplication::~SurfacesServiceApplication() {
19 } 20 }
20 21
21 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { 22 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
22 tracing_.Initialize(app); 23 tracing_.Initialize(app);
23 scheduler_.reset(new SurfacesScheduler(this)); 24 scheduler_.reset(new SurfacesScheduler);
24 } 25 }
25 26
26 bool SurfacesServiceApplication::ConfigureIncomingConnection( 27 bool SurfacesServiceApplication::ConfigureIncomingConnection(
27 mojo::ApplicationConnection* connection) { 28 mojo::ApplicationConnection* connection) {
28 connection->AddService(this); 29 connection->AddService<mojo::DisplayFactory>(this);
30 connection->AddService<mojo::Surface>(this);
29 return true; 31 return true;
30 } 32 }
31 33
32 void SurfacesServiceApplication::Create( 34 void SurfacesServiceApplication::Create(
33 mojo::ApplicationConnection* connection, 35 mojo::ApplicationConnection* connection,
34 mojo::InterfaceRequest<mojo::Surface> request) { 36 mojo::InterfaceRequest<mojo::DisplayFactory> request) {
35 new SurfacesImpl(&manager_, next_id_namespace_++, this, request.Pass()); 37 new DisplayFactoryImpl(&manager_, next_id_namespace_++, scheduler_.get(),
38 request.Pass());
36 } 39 }
37 40
38 void SurfacesServiceApplication::OnVSyncParametersUpdated( 41 void SurfacesServiceApplication::Create(
39 base::TimeTicks timebase, 42 mojo::ApplicationConnection* connection,
40 base::TimeDelta interval) { 43 mojo::InterfaceRequest<mojo::Surface> request) {
41 scheduler_->OnVSyncParametersUpdated(timebase, interval); 44 new SurfacesImpl(&manager_, next_id_namespace_++, scheduler_.get(),
42 } 45 request.Pass());
43
44 void SurfacesServiceApplication::FrameSubmitted() {
45 scheduler_->SetNeedsDraw();
46 }
47
48 void SurfacesServiceApplication::SetDisplay(cc::Display* display) {
49 display_ = display;
50 }
51
52 void SurfacesServiceApplication::OnDisplayBeingDestroyed(cc::Display* display) {
53 if (display_ == display)
54 SetDisplay(nullptr);
55 }
56
57 void SurfacesServiceApplication::Draw() {
58 if (display_)
59 display_->Draw();
60 } 46 }
61 47
62 } // namespace surfaces 48 } // namespace surfaces
63 49
64 MojoResult MojoMain(MojoHandle shell_handle) { 50 MojoResult MojoMain(MojoHandle shell_handle) {
65 mojo::ApplicationRunnerChromium runner( 51 mojo::ApplicationRunnerChromium runner(
66 new surfaces::SurfacesServiceApplication); 52 new surfaces::SurfacesServiceApplication);
67 return runner.Run(shell_handle); 53 return runner.Run(shell_handle);
68 } 54 }
OLDNEW
« no previous file with comments | « services/surfaces/surfaces_service_application.h ('k') | services/view_manager/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698