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

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

Issue 606883002: Add a headless configuration to Mojo's native viewport service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address jamesr's questions Created 6 years, 2 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 "mojo/services/native_viewport/native_viewport_impl.h" 5 #include "mojo/services/native_viewport/native_viewport_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 11 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/application_impl.h" 12 #include "mojo/public/cpp/application/application_impl.h"
13 #include "mojo/public/cpp/application/interface_factory.h" 13 #include "mojo/public/cpp/application/interface_factory.h"
14 #include "mojo/services/native_viewport/platform_viewport_headless.h"
14 #include "mojo/services/native_viewport/viewport_surface.h" 15 #include "mojo/services/native_viewport/viewport_surface.h"
15 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 16 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
16 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 17 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
17 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" 18 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h"
18 #include "ui/events/event.h" 19 #include "ui/events/event.h"
19 20
20 namespace mojo { 21 namespace mojo {
21 namespace { 22 namespace {
22 23
23 bool IsRateLimitedEventType(ui::Event* event) { 24 bool IsRateLimitedEventType(ui::Event* event) {
24 return event->type() == ui::ET_MOUSE_MOVED || 25 return event->type() == ui::ET_MOUSE_MOVED ||
25 event->type() == ui::ET_MOUSE_DRAGGED || 26 event->type() == ui::ET_MOUSE_DRAGGED ||
26 event->type() == ui::ET_TOUCH_MOVED; 27 event->type() == ui::ET_TOUCH_MOVED;
27 } 28 }
28 29
29 } // namespace 30 } // namespace
30 31
31 NativeViewportImpl::NativeViewportImpl(ApplicationImpl* app) 32 NativeViewportImpl::NativeViewportImpl(ApplicationImpl* app, bool is_headless)
32 : widget_id_(0u), waiting_for_event_ack_(false), weak_factory_(this) { 33 : is_headless_(is_headless),
34 widget_id_(0u),
35 waiting_for_event_ack_(false),
36 weak_factory_(this) {
33 app->ConnectToService("mojo:mojo_surfaces_service", &surfaces_service_); 37 app->ConnectToService("mojo:mojo_surfaces_service", &surfaces_service_);
34 // TODO(jamesr): Should be mojo_gpu_service 38 // TODO(jamesr): Should be mojo_gpu_service
35 app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); 39 app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_);
36 } 40 }
37 41
38 NativeViewportImpl::~NativeViewportImpl() { 42 NativeViewportImpl::~NativeViewportImpl() {
39 // Destroy the NativeViewport early on as it may call us back during 43 // Destroy the NativeViewport early on as it may call us back during
40 // destruction and we want to be in a known state. 44 // destruction and we want to be in a known state.
41 platform_viewport_.reset(); 45 platform_viewport_.reset();
42 } 46 }
43 47
44 void NativeViewportImpl::Create(SizePtr bounds) { 48 void NativeViewportImpl::Create(SizePtr bounds) {
45 platform_viewport_ = PlatformViewport::Create(this); 49 if (is_headless_)
50 platform_viewport_ = PlatformViewportHeadless::Create(this);
51 else
52 platform_viewport_ = PlatformViewport::Create(this);
46 gfx::Rect rect = gfx::Rect(bounds.To<gfx::Size>()); 53 gfx::Rect rect = gfx::Rect(bounds.To<gfx::Size>());
47 platform_viewport_->Init(rect); 54 platform_viewport_->Init(rect);
48 OnBoundsChanged(rect); 55 OnBoundsChanged(rect);
49 } 56 }
50 57
51 void NativeViewportImpl::Show() { 58 void NativeViewportImpl::Show() {
52 platform_viewport_->Show(); 59 platform_viewport_->Show();
53 } 60 }
54 61
55 void NativeViewportImpl::Hide() { 62 void NativeViewportImpl::Hide() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void NativeViewportImpl::OnDestroyed() { 135 void NativeViewportImpl::OnDestroyed() {
129 client()->OnDestroyed(); 136 client()->OnDestroyed();
130 } 137 }
131 138
132 void NativeViewportImpl::AckEvent() { 139 void NativeViewportImpl::AckEvent() {
133 waiting_for_event_ack_ = false; 140 waiting_for_event_ack_ = false;
134 } 141 }
135 142
136 } // namespace mojo 143 } // namespace mojo
137 144
OLDNEW
« no previous file with comments | « mojo/services/native_viewport/native_viewport_impl.h ('k') | mojo/services/native_viewport/platform_viewport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698