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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 "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 #include <utility> 9 #include <utility>
9 10
11 #include "base/memory/ptr_util.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "ui/gfx/geometry/point.h" 13 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
14 #include "ui/ozone/platform/drm/common/drm_util.h" 16 #include "ui/ozone/platform/drm/common/drm_util.h"
15 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" 17 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
16 #include "ui/ozone/platform/drm/gpu/drm_console_buffer.h" 18 #include "ui/ozone/platform/drm/gpu/drm_console_buffer.h"
17 #include "ui/ozone/platform/drm/gpu/drm_device.h" 19 #include "ui/ozone/platform/drm/gpu/drm_device.h"
18 #include "ui/ozone/platform/drm/gpu/drm_window.h" 20 #include "ui/ozone/platform/drm/gpu/drm_window.h"
19 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 21 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); 95 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc);
94 // TODO(dnicoara): Turn this into a DCHECK when async display configuration is 96 // TODO(dnicoara): Turn this into a DCHECK when async display configuration is
95 // properly supported. (When there can't be a race between forcing initial 97 // properly supported. (When there can't be a race between forcing initial
96 // display configuration in ScreenManager and NativeDisplayDelegate creating 98 // display configuration in ScreenManager and NativeDisplayDelegate creating
97 // the display controllers.) 99 // the display controllers.)
98 if (it != controllers_.end()) { 100 if (it != controllers_.end()) {
99 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present."; 101 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present.";
100 return; 102 return;
101 } 103 }
102 104
103 controllers_.push_back(make_scoped_ptr(new HardwareDisplayController( 105 controllers_.push_back(base::WrapUnique(new HardwareDisplayController(
104 scoped_ptr<CrtcController>(new CrtcController(drm, crtc, connector)), 106 std::unique_ptr<CrtcController>(new CrtcController(drm, crtc, connector)),
105 gfx::Point()))); 107 gfx::Point())));
106 } 108 }
107 109
108 void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm, 110 void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm,
109 uint32_t crtc) { 111 uint32_t crtc) {
110 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); 112 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc);
111 if (it != controllers_.end()) { 113 if (it != controllers_.end()) {
112 bool is_mirrored = (*it)->IsMirrored(); 114 bool is_mirrored = (*it)->IsMirrored();
113 (*it)->RemoveCrtc(drm, crtc); 115 (*it)->RemoveCrtc(drm, crtc);
114 if (!is_mirrored) { 116 if (!is_mirrored) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 163
162 // Just re-enable the controller to re-use the current state. 164 // Just re-enable the controller to re-use the current state.
163 return EnableController(controller); 165 return EnableController(controller);
164 } 166 }
165 167
166 // Either the mode or the location of the display changed, so exit mirror 168 // Either the mode or the location of the display changed, so exit mirror
167 // mode and configure the display independently. If the caller still wants 169 // mode and configure the display independently. If the caller still wants
168 // mirror mode, subsequent calls configuring the other controllers will 170 // mirror mode, subsequent calls configuring the other controllers will
169 // restore mirror mode. 171 // restore mirror mode.
170 if (controller->IsMirrored()) { 172 if (controller->IsMirrored()) {
171 controllers_.push_back(make_scoped_ptr(new HardwareDisplayController( 173 controllers_.push_back(base::WrapUnique(new HardwareDisplayController(
172 controller->RemoveCrtc(drm, crtc), controller->origin()))); 174 controller->RemoveCrtc(drm, crtc), controller->origin())));
173 it = controllers_.end() - 1; 175 it = controllers_.end() - 1;
174 controller = it->get(); 176 controller = it->get();
175 } 177 }
176 178
177 HardwareDisplayControllers::iterator mirror = 179 HardwareDisplayControllers::iterator mirror =
178 FindActiveDisplayControllerByLocation(modeset_bounds); 180 FindActiveDisplayControllerByLocation(modeset_bounds);
179 // Handle mirror mode. 181 // Handle mirror mode.
180 if (mirror != controllers_.end() && it != mirror) 182 if (mirror != controllers_.end() && it != mirror)
181 return HandleMirrorMode(it, mirror, drm, crtc, connector, mode); 183 return HandleMirrorMode(it, mirror, drm, crtc, connector, mode);
182 184
183 return ModesetController(controller, origin, mode); 185 return ModesetController(controller, origin, mode);
184 } 186 }
185 187
186 bool ScreenManager::DisableDisplayController( 188 bool ScreenManager::DisableDisplayController(
187 const scoped_refptr<DrmDevice>& drm, 189 const scoped_refptr<DrmDevice>& drm,
188 uint32_t crtc) { 190 uint32_t crtc) {
189 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); 191 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc);
190 if (it != controllers_.end()) { 192 if (it != controllers_.end()) {
191 HardwareDisplayController* controller = it->get(); 193 HardwareDisplayController* controller = it->get();
192 if (controller->IsMirrored()) { 194 if (controller->IsMirrored()) {
193 controllers_.push_back(make_scoped_ptr(new HardwareDisplayController( 195 controllers_.push_back(base::WrapUnique(new HardwareDisplayController(
194 controller->RemoveCrtc(drm, crtc), controller->origin()))); 196 controller->RemoveCrtc(drm, crtc), controller->origin())));
195 controller = controllers_.back().get(); 197 controller = controllers_.back().get();
196 } 198 }
197 199
198 controller->Disable(); 200 controller->Disable();
199 UpdateControllerToWindowMapping(); 201 UpdateControllerToWindowMapping();
200 return true; 202 return true;
201 } 203 }
202 204
203 LOG(ERROR) << "Failed to find display controller crtc=" << crtc; 205 LOG(ERROR) << "Failed to find display controller crtc=" << crtc;
204 return false; 206 return false;
205 } 207 }
206 208
207 HardwareDisplayController* ScreenManager::GetDisplayController( 209 HardwareDisplayController* ScreenManager::GetDisplayController(
208 const gfx::Rect& bounds) { 210 const gfx::Rect& bounds) {
209 HardwareDisplayControllers::iterator it = 211 HardwareDisplayControllers::iterator it =
210 FindActiveDisplayControllerByLocation(bounds); 212 FindActiveDisplayControllerByLocation(bounds);
211 if (it != controllers_.end()) 213 if (it != controllers_.end())
212 return it->get(); 214 return it->get();
213 215
214 return nullptr; 216 return nullptr;
215 } 217 }
216 218
217 void ScreenManager::AddWindow(gfx::AcceleratedWidget widget, 219 void ScreenManager::AddWindow(gfx::AcceleratedWidget widget,
218 scoped_ptr<DrmWindow> window) { 220 std::unique_ptr<DrmWindow> window) {
219 std::pair<WidgetToWindowMap::iterator, bool> result = 221 std::pair<WidgetToWindowMap::iterator, bool> result =
220 window_map_.add(widget, std::move(window)); 222 window_map_.add(widget, std::move(window));
221 DCHECK(result.second) << "Window already added."; 223 DCHECK(result.second) << "Window already added.";
222 UpdateControllerToWindowMapping(); 224 UpdateControllerToWindowMapping();
223 } 225 }
224 226
225 scoped_ptr<DrmWindow> ScreenManager::RemoveWindow( 227 std::unique_ptr<DrmWindow> ScreenManager::RemoveWindow(
226 gfx::AcceleratedWidget widget) { 228 gfx::AcceleratedWidget widget) {
227 scoped_ptr<DrmWindow> window = window_map_.take_and_erase(widget); 229 std::unique_ptr<DrmWindow> window = window_map_.take_and_erase(widget);
228 DCHECK(window) << "Attempting to remove non-existing window for " << widget; 230 DCHECK(window) << "Attempting to remove non-existing window for " << widget;
229 UpdateControllerToWindowMapping(); 231 UpdateControllerToWindowMapping();
230 return window; 232 return window;
231 } 233 }
232 234
233 DrmWindow* ScreenManager::GetWindow(gfx::AcceleratedWidget widget) { 235 DrmWindow* ScreenManager::GetWindow(gfx::AcceleratedWidget widget) {
234 WidgetToWindowMap::iterator it = window_map_.find(widget); 236 WidgetToWindowMap::iterator it = window_map_.find(widget);
235 if (it != window_map_.end()) 237 if (it != window_map_.end())
236 return it->second; 238 return it->second;
237 239
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { 384 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const {
383 for (auto pair : window_map_) { 385 for (auto pair : window_map_) {
384 if (pair.second->bounds() == bounds) 386 if (pair.second->bounds() == bounds)
385 return pair.second; 387 return pair.second;
386 } 388 }
387 389
388 return nullptr; 390 return nullptr;
389 } 391 }
390 392
391 } // namespace ui 393 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager.h ('k') | ui/ozone/platform/drm/gpu/screen_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698