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

Side by Side Diff: mojo/services/view_manager/display_manager.cc

Issue 685013002: Refactors event dispatching of NativeViewport into its own interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 6 years, 1 month 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/view_manager/display_manager.h" 5 #include "mojo/services/view_manager/display_manager.h"
6 6
7 #include "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "cc/surfaces/surface_id_allocator.h" 8 #include "cc/surfaces/surface_id_allocator.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/surfaces/surfaces_type_converters.h" 10 #include "mojo/converters/surfaces/surfaces_type_converters.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 &native_viewport_); 81 &native_viewport_);
82 native_viewport_.set_client(this); 82 native_viewport_.set_client(this);
83 native_viewport_->Create( 83 native_viewport_->Create(
84 Size::From(size_), 84 Size::From(size_),
85 base::Bind(&DisplayManager::OnCreatedNativeViewport, 85 base::Bind(&DisplayManager::OnCreatedNativeViewport,
86 weak_factory_.GetWeakPtr())); 86 weak_factory_.GetWeakPtr()));
87 native_viewport_->Show(); 87 native_viewport_->Show();
88 app_connection->ConnectToService("mojo:surfaces_service", &surfaces_service_); 88 app_connection->ConnectToService("mojo:surfaces_service", &surfaces_service_);
89 surfaces_service_->CreateSurfaceConnection(base::Bind( 89 surfaces_service_->CreateSurfaceConnection(base::Bind(
90 &DisplayManager::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr())); 90 &DisplayManager::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr()));
91
92 NativeViewportEventDispatcherPtr event_dispatcher;
93 app_connection->ConnectToService(&event_dispatcher);
94 native_viewport_->SetEventDispatcher(event_dispatcher.Pass());
91 } 95 }
92 96
93 DisplayManager::~DisplayManager() { 97 DisplayManager::~DisplayManager() {
94 } 98 }
95 99
96 void DisplayManager::SchedulePaint(const ServerView* view, 100 void DisplayManager::SchedulePaint(const ServerView* view,
97 const gfx::Rect& bounds) { 101 const gfx::Rect& bounds) {
98 if (!view->visible()) 102 if (!view->visible())
99 return; 103 return;
100 gfx::Rect root_relative_rect = ConvertRectToRoot(view, bounds); 104 gfx::Rect root_relative_rect = ConvertRectToRoot(view, bounds);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void DisplayManager::OnSizeChanged(SizePtr size) { 154 void DisplayManager::OnSizeChanged(SizePtr size) {
151 size_ = size.To<gfx::Size>(); 155 size_ = size.To<gfx::Size>();
152 connection_manager_->root()->SetBounds(gfx::Rect(size_)); 156 connection_manager_->root()->SetBounds(gfx::Rect(size_));
153 if (surface_id_.is_null()) 157 if (surface_id_.is_null())
154 return; 158 return;
155 surface_->DestroySurface(SurfaceId::From(surface_id_)); 159 surface_->DestroySurface(SurfaceId::From(surface_id_));
156 surface_id_ = cc::SurfaceId(); 160 surface_id_ = cc::SurfaceId();
157 SchedulePaint(connection_manager_->root(), gfx::Rect(size_)); 161 SchedulePaint(connection_manager_->root(), gfx::Rect(size_));
158 } 162 }
159 163
160 void DisplayManager::OnEvent(EventPtr event,
161 const mojo::Callback<void()>& callback) {
162 connection_manager_->DispatchViewInputEventToDelegate(event.Pass());
163 callback.Run();
164 }
165
166 void DisplayManager::ReturnResources(Array<ReturnedResourcePtr> resources) { 164 void DisplayManager::ReturnResources(Array<ReturnedResourcePtr> resources) {
167 DCHECK_EQ(0u, resources.size()); 165 DCHECK_EQ(0u, resources.size());
168 } 166 }
169 167
170 } // namespace service 168 } // namespace service
171 } // namespace mojo 169 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/display_manager.h ('k') | mojo/services/view_manager/view_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698