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 "mojo/services/surfaces/surfaces_service_application.h" | 5 #include "mojo/services/surfaces/surfaces_service_application.h" |
6 | 6 |
7 #include "cc/surfaces/display.h" | 7 #include "cc/surfaces/display.h" |
8 | 8 |
9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
10 #include "mojo/public/cpp/application/application_runner_chromium.h" | 10 #include "mojo/public/cpp/application/application_runner_chromium.h" |
11 #include "mojo/services/surfaces/surfaces_service_impl.h" | 11 #include "mojo/services/surfaces/surfaces_service_impl.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 | 14 |
15 SurfacesServiceApplication::SurfacesServiceApplication() | 15 SurfacesServiceApplication::SurfacesServiceApplication() |
16 : next_id_namespace_(1u), display_(NULL) { | 16 : next_id_namespace_(1u), display_(NULL), draw_timer_(false, false) { |
17 } | 17 } |
18 | 18 |
19 SurfacesServiceApplication::~SurfacesServiceApplication() { | 19 SurfacesServiceApplication::~SurfacesServiceApplication() { |
20 } | 20 } |
21 | 21 |
22 bool SurfacesServiceApplication::ConfigureIncomingConnection( | 22 bool SurfacesServiceApplication::ConfigureIncomingConnection( |
23 ApplicationConnection* connection) { | 23 ApplicationConnection* connection) { |
24 connection->AddService(this); | 24 connection->AddService(this); |
25 return true; | 25 return true; |
26 } | 26 } |
27 | 27 |
28 void SurfacesServiceApplication::Create( | 28 void SurfacesServiceApplication::Create( |
29 ApplicationConnection* connection, | 29 ApplicationConnection* connection, |
30 InterfaceRequest<SurfacesService> request) { | 30 InterfaceRequest<SurfacesService> request) { |
31 BindToRequest(new SurfacesServiceImpl(&manager_, &next_id_namespace_, this), | 31 BindToRequest(new SurfacesServiceImpl(&manager_, &next_id_namespace_, this), |
32 &request); | 32 &request); |
33 } | 33 } |
34 | 34 |
35 void SurfacesServiceApplication::FrameSubmitted() { | 35 void SurfacesServiceApplication::FrameSubmitted() { |
36 if (display_) | 36 if (!draw_timer_.IsRunning() && display_) { |
37 display_->Draw(); | 37 draw_timer_.Start(FROM_HERE, |
| 38 base::TimeDelta::FromMilliseconds(17), |
| 39 base::Bind(base::IgnoreResult(&cc::Display::Draw), |
| 40 base::Unretained(display_))); |
| 41 } |
38 } | 42 } |
39 | 43 |
40 void SurfacesServiceApplication::SetDisplay(cc::Display* display) { | 44 void SurfacesServiceApplication::SetDisplay(cc::Display* display) { |
41 display_ = display; | 45 display_ = display; |
42 } | 46 } |
43 | 47 |
44 } // namespace mojo | 48 } // namespace mojo |
45 | 49 |
46 MojoResult MojoMain(MojoHandle shell_handle) { | 50 MojoResult MojoMain(MojoHandle shell_handle) { |
47 mojo::ApplicationRunnerChromium runner(new mojo::SurfacesServiceApplication); | 51 mojo::ApplicationRunnerChromium runner(new mojo::SurfacesServiceApplication); |
48 return runner.Run(shell_handle); | 52 return runner.Run(shell_handle); |
49 } | 53 } |
OLD | NEW |