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

Side by Side Diff: ui/ozone/platform/drm/gpu/screen_manager.cc

Issue 2603863002: Remove base::ScopedPtrHashMap from ozone. (Closed)
Patch Set: fixes Created 3 years, 11 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
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/ozone/platform/drm/gpu/screen_manager.h" 5 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
6 6
7 #include <xf86drmMode.h> 7 #include <xf86drmMode.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 FindActiveDisplayControllerByLocation(bounds); 212 FindActiveDisplayControllerByLocation(bounds);
213 if (it != controllers_.end()) 213 if (it != controllers_.end())
214 return it->get(); 214 return it->get();
215 215
216 return nullptr; 216 return nullptr;
217 } 217 }
218 218
219 void ScreenManager::AddWindow(gfx::AcceleratedWidget widget, 219 void ScreenManager::AddWindow(gfx::AcceleratedWidget widget,
220 std::unique_ptr<DrmWindow> window) { 220 std::unique_ptr<DrmWindow> window) {
221 std::pair<WidgetToWindowMap::iterator, bool> result = 221 std::pair<WidgetToWindowMap::iterator, bool> result =
222 window_map_.add(widget, std::move(window)); 222 window_map_.insert(std::make_pair(widget, std::move(window)));
223 DCHECK(result.second) << "Window already added."; 223 DCHECK(result.second) << "Window already added.";
224 UpdateControllerToWindowMapping(); 224 UpdateControllerToWindowMapping();
225 } 225 }
226 226
227 std::unique_ptr<DrmWindow> ScreenManager::RemoveWindow( 227 std::unique_ptr<DrmWindow> ScreenManager::RemoveWindow(
228 gfx::AcceleratedWidget widget) { 228 gfx::AcceleratedWidget widget) {
229 std::unique_ptr<DrmWindow> window = window_map_.take_and_erase(widget); 229 std::unique_ptr<DrmWindow> window = std::move(window_map_[widget]);
230 window_map_.erase(widget);
230 DCHECK(window) << "Attempting to remove non-existing window for " << widget; 231 DCHECK(window) << "Attempting to remove non-existing window for " << widget;
231 UpdateControllerToWindowMapping(); 232 UpdateControllerToWindowMapping();
232 return window; 233 return window;
233 } 234 }
234 235
235 DrmWindow* ScreenManager::GetWindow(gfx::AcceleratedWidget widget) { 236 DrmWindow* ScreenManager::GetWindow(gfx::AcceleratedWidget widget) {
236 WidgetToWindowMap::iterator it = window_map_.find(widget); 237 WidgetToWindowMap::iterator it = window_map_.find(widget);
237 if (it != window_map_.end()) 238 if (it != window_map_.end())
238 return it->second; 239 return it->second.get();
239 240
240 return nullptr; 241 return nullptr;
241 } 242 }
242 243
243 ScreenManager::HardwareDisplayControllers::iterator 244 ScreenManager::HardwareDisplayControllers::iterator
244 ScreenManager::FindDisplayController(const scoped_refptr<DrmDevice>& drm, 245 ScreenManager::FindDisplayController(const scoped_refptr<DrmDevice>& drm,
245 uint32_t crtc) { 246 uint32_t crtc) {
246 for (auto it = controllers_.begin(); it != controllers_.end(); ++it) { 247 for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
247 if ((*it)->HasCrtc(drm, crtc)) 248 if ((*it)->HasCrtc(drm, crtc))
248 return it; 249 return it;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 305
305 DrmWindow* window = FindWindowAt( 306 DrmWindow* window = FindWindowAt(
306 gfx::Rect(controller->origin(), controller->GetModeSize())); 307 gfx::Rect(controller->origin(), controller->GetModeSize()));
307 if (!window) 308 if (!window)
308 continue; 309 continue;
309 310
310 window_to_controller_map[window] = controller.get(); 311 window_to_controller_map[window] = controller.get();
311 } 312 }
312 313
313 // Apply the new mapping to all windows. 314 // Apply the new mapping to all windows.
314 for (auto pair : window_map_) { 315 for (auto& pair : window_map_) {
315 auto it = window_to_controller_map.find(pair.second); 316 auto it = window_to_controller_map.find(pair.second.get());
316 HardwareDisplayController* controller = nullptr; 317 HardwareDisplayController* controller = nullptr;
317 if (it != window_to_controller_map.end()) 318 if (it != window_to_controller_map.end())
318 controller = it->second; 319 controller = it->second;
319 320
320 bool should_enable = 321 bool should_enable =
321 controller && pair.second->GetController() != controller; 322 controller && pair.second->GetController() != controller;
322 pair.second->SetController(controller); 323 pair.second->SetController(controller);
323 324
324 // If we're moving windows between controllers modeset the controller 325 // If we're moving windows between controllers modeset the controller
325 // otherwise the controller may be waiting for a page flip while the window 326 // otherwise the controller may be waiting for a page flip while the window
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 OverlayPlane plane = GetModesetBuffer(controller, rect); 380 OverlayPlane plane = GetModesetBuffer(controller, rect);
380 if (!plane.buffer || !controller->Modeset(plane, mode)) { 381 if (!plane.buffer || !controller->Modeset(plane, mode)) {
381 LOG(ERROR) << "Failed to modeset controller"; 382 LOG(ERROR) << "Failed to modeset controller";
382 return false; 383 return false;
383 } 384 }
384 385
385 return true; 386 return true;
386 } 387 }
387 388
388 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { 389 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const {
389 for (auto pair : window_map_) { 390 for (auto& pair : window_map_) {
390 if (pair.second->bounds() == bounds) 391 if (pair.second->bounds() == bounds)
391 return pair.second; 392 return pair.second.get();
392 } 393 }
393 394
394 return nullptr; 395 return nullptr;
395 } 396 }
396 397
397 } // namespace ui 398 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698