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

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

Issue 695183003: Bring skydebugger closer to clean-shutdown (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 app_connection->ConnectToService("mojo:surfaces_service", &surfaces_service_); 89 app_connection->ConnectToService("mojo:surfaces_service", &surfaces_service_);
90 surfaces_service_->CreateSurfaceConnection(base::Bind( 90 surfaces_service_->CreateSurfaceConnection(base::Bind(
91 &DisplayManager::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr())); 91 &DisplayManager::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr()));
92 92
93 NativeViewportEventDispatcherPtr event_dispatcher; 93 NativeViewportEventDispatcherPtr event_dispatcher;
94 app_connection->ConnectToService(&event_dispatcher); 94 app_connection->ConnectToService(&event_dispatcher);
95 native_viewport_->SetEventDispatcher(event_dispatcher.Pass()); 95 native_viewport_->SetEventDispatcher(event_dispatcher.Pass());
96 } 96 }
97 97
98 DisplayManager::~DisplayManager() { 98 DisplayManager::~DisplayManager() {
99 if (!surface_id_.is_null())
sky 2014/11/05 18:30:52 Since we're shutting down is this strictly necessa
100 surface_->DestroySurface(SurfaceId::From(surface_id_));
99 } 101 }
100 102
101 void DisplayManager::SchedulePaint(const ServerView* view, 103 void DisplayManager::SchedulePaint(const ServerView* view,
102 const gfx::Rect& bounds) { 104 const gfx::Rect& bounds) {
103 if (!view->visible()) 105 if (!view->visible())
104 return; 106 return;
105 gfx::Rect root_relative_rect = ConvertRectToRoot(view, bounds); 107 gfx::Rect root_relative_rect = ConvertRectToRoot(view, bounds);
106 if (root_relative_rect.IsEmpty()) 108 if (root_relative_rect.IsEmpty())
107 return; 109 return;
108 dirty_rect_.Union(root_relative_rect); 110 dirty_rect_.Union(root_relative_rect);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 frame->passes.push_back(pass.Pass()); 151 frame->passes.push_back(pass.Pass());
150 frame->resources.resize(0u); 152 frame->resources.resize(0u);
151 surface_->SubmitFrame(SurfaceId::From(surface_id_), frame.Pass()); 153 surface_->SubmitFrame(SurfaceId::From(surface_id_), frame.Pass());
152 154
153 native_viewport_->SubmittedFrame(SurfaceId::From(surface_id_)); 155 native_viewport_->SubmittedFrame(SurfaceId::From(surface_id_));
154 156
155 dirty_rect_ = gfx::Rect(); 157 dirty_rect_ = gfx::Rect();
156 } 158 }
157 159
158 void DisplayManager::OnDestroyed() { 160 void DisplayManager::OnDestroyed() {
161 // This is called when the native_viewport is torn down before
162 // ~DisplayManager may be called.
159 native_viewport_closed_callback_.Run(); 163 native_viewport_closed_callback_.Run();
160 } 164 }
161 165
162 void DisplayManager::OnSizeChanged(SizePtr size) { 166 void DisplayManager::OnSizeChanged(SizePtr size) {
163 size_ = size.To<gfx::Size>(); 167 size_ = size.To<gfx::Size>();
164 connection_manager_->root()->SetBounds(gfx::Rect(size_)); 168 connection_manager_->root()->SetBounds(gfx::Rect(size_));
165 if (surface_id_.is_null()) 169 if (surface_id_.is_null())
166 return; 170 return;
167 surface_->DestroySurface(SurfaceId::From(surface_id_)); 171 surface_->DestroySurface(SurfaceId::From(surface_id_));
168 surface_id_ = cc::SurfaceId(); 172 surface_id_ = cc::SurfaceId();
169 SchedulePaint(connection_manager_->root(), gfx::Rect(size_)); 173 SchedulePaint(connection_manager_->root(), gfx::Rect(size_));
170 } 174 }
171 175
172 void DisplayManager::ReturnResources(Array<ReturnedResourcePtr> resources) { 176 void DisplayManager::ReturnResources(Array<ReturnedResourcePtr> resources) {
173 DCHECK_EQ(0u, resources.size()); 177 DCHECK_EQ(0u, resources.size());
174 } 178 }
175 179
176 } // namespace service 180 } // namespace service
177 } // namespace mojo 181 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698