| Index: ui/ozone/platform/drm/gpu/screen_manager.cc
|
| diff --git a/ui/ozone/platform/drm/gpu/screen_manager.cc b/ui/ozone/platform/drm/gpu/screen_manager.cc
|
| index 0fefd4b8b5cc5db41c1195fd0a91c3ca3e13a80a..52959847af076e46e0e00e51e1caa6542b419935 100644
|
| --- a/ui/ozone/platform/drm/gpu/screen_manager.cc
|
| +++ b/ui/ozone/platform/drm/gpu/screen_manager.cc
|
| @@ -33,10 +33,9 @@ void FillModesetBuffer(const scoped_refptr<DrmDevice>& drm,
|
| return;
|
| }
|
|
|
| - auto crtcs = controller->crtc_controllers();
|
| - DCHECK(!crtcs.empty());
|
| -
|
| - ScopedDrmCrtcPtr saved_crtc(drm->GetCrtc(crtcs[0]->crtc()));
|
| + DCHECK(!controller->crtc_controllers().empty());
|
| + CrtcController* first_crtc = controller->crtc_controllers()[0].get();
|
| + ScopedDrmCrtcPtr saved_crtc(drm->GetCrtc(first_crtc->crtc()));
|
| if (!saved_crtc || !saved_crtc->buffer_id) {
|
| VLOG(2) << "Crtc has no saved state or wasn't modeset";
|
| return;
|
| @@ -68,9 +67,9 @@ void FillModesetBuffer(const scoped_refptr<DrmDevice>& drm,
|
| CrtcController* GetCrtcController(HardwareDisplayController* controller,
|
| const scoped_refptr<DrmDevice>& drm,
|
| uint32_t crtc) {
|
| - for (CrtcController* crtc_controller : controller->crtc_controllers()) {
|
| + for (const auto& crtc_controller : controller->crtc_controllers()) {
|
| if (crtc_controller->crtc() == crtc)
|
| - return crtc_controller;
|
| + return crtc_controller.get();
|
| }
|
|
|
| NOTREACHED();
|
| @@ -100,9 +99,9 @@ void ScreenManager::AddDisplayController(const scoped_refptr<DrmDevice>& drm,
|
| return;
|
| }
|
|
|
| - controllers_.push_back(new HardwareDisplayController(
|
| + controllers_.push_back(make_scoped_ptr(new HardwareDisplayController(
|
| scoped_ptr<CrtcController>(new CrtcController(drm, crtc, connector)),
|
| - gfx::Point()));
|
| + gfx::Point())));
|
| }
|
|
|
| void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm,
|
| @@ -144,7 +143,7 @@ bool ScreenManager::ActualConfigureDisplayController(
|
| DCHECK(controllers_.end() != it) << "Display controller (crtc=" << crtc
|
| << ") doesn't exist.";
|
|
|
| - HardwareDisplayController* controller = *it;
|
| + HardwareDisplayController* controller = it->get();
|
| CrtcController* crtc_controller = GetCrtcController(controller, drm, crtc);
|
| // If nothing changed just enable the controller. Note, we perform an exact
|
| // comparison on the mode since the refresh rate may have changed.
|
| @@ -168,10 +167,10 @@ bool ScreenManager::ActualConfigureDisplayController(
|
| // mirror mode, subsequent calls configuring the other controllers will
|
| // restore mirror mode.
|
| if (controller->IsMirrored()) {
|
| - controller = new HardwareDisplayController(
|
| - controller->RemoveCrtc(drm, crtc), controller->origin());
|
| - controllers_.push_back(controller);
|
| + controllers_.push_back(make_scoped_ptr(new HardwareDisplayController(
|
| + controller->RemoveCrtc(drm, crtc), controller->origin())));
|
| it = controllers_.end() - 1;
|
| + controller = it->get();
|
| }
|
|
|
| HardwareDisplayControllers::iterator mirror =
|
| @@ -188,11 +187,11 @@ bool ScreenManager::DisableDisplayController(
|
| uint32_t crtc) {
|
| HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc);
|
| if (it != controllers_.end()) {
|
| - HardwareDisplayController* controller = *it;
|
| + HardwareDisplayController* controller = it->get();
|
| if (controller->IsMirrored()) {
|
| - controller = new HardwareDisplayController(
|
| - controller->RemoveCrtc(drm, crtc), controller->origin());
|
| - controllers_.push_back(controller);
|
| + controllers_.push_back(make_scoped_ptr(new HardwareDisplayController(
|
| + controller->RemoveCrtc(drm, crtc), controller->origin())));
|
| + controller = controllers_.back().get();
|
| }
|
|
|
| controller->Disable();
|
| @@ -209,7 +208,7 @@ HardwareDisplayController* ScreenManager::GetDisplayController(
|
| HardwareDisplayControllers::iterator it =
|
| FindActiveDisplayControllerByLocation(bounds);
|
| if (it != controllers_.end())
|
| - return *it;
|
| + return it->get();
|
|
|
| return nullptr;
|
| }
|
| @@ -241,8 +240,7 @@ DrmWindow* ScreenManager::GetWindow(gfx::AcceleratedWidget widget) {
|
| ScreenManager::HardwareDisplayControllers::iterator
|
| ScreenManager::FindDisplayController(const scoped_refptr<DrmDevice>& drm,
|
| uint32_t crtc) {
|
| - for (HardwareDisplayControllers::iterator it = controllers_.begin();
|
| - it != controllers_.end(); ++it) {
|
| + for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
|
| if ((*it)->HasCrtc(drm, crtc))
|
| return it;
|
| }
|
| @@ -252,8 +250,7 @@ ScreenManager::FindDisplayController(const scoped_refptr<DrmDevice>& drm,
|
|
|
| ScreenManager::HardwareDisplayControllers::iterator
|
| ScreenManager::FindActiveDisplayControllerByLocation(const gfx::Rect& bounds) {
|
| - for (HardwareDisplayControllers::iterator it = controllers_.begin();
|
| - it != controllers_.end(); ++it) {
|
| + for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
|
| gfx::Rect controller_bounds((*it)->origin(), (*it)->GetModeSize());
|
| if (controller_bounds == bounds && !(*it)->IsDisabled())
|
| return it;
|
| @@ -279,7 +276,7 @@ bool ScreenManager::HandleMirrorMode(
|
| // TODO(dnicoara): This is hacky, instead the DrmDisplay and CrtcController
|
| // should be merged and picking the mode should be done properly within
|
| // HardwareDisplayController.
|
| - if (ModesetController(*original, (*mirror)->origin(), mode)) {
|
| + if (ModesetController(original->get(), (*mirror)->origin(), mode)) {
|
| (*mirror)->AddCrtc((*original)->RemoveCrtc(drm, crtc));
|
| controllers_.erase(original);
|
| return true;
|
| @@ -290,7 +287,7 @@ bool ScreenManager::HandleMirrorMode(
|
| // When things go wrong revert back to the previous configuration since
|
| // it is expected that the configuration would not have changed if
|
| // things fail.
|
| - ModesetController(*original, last_origin, last_mode);
|
| + ModesetController(original->get(), last_origin, last_mode);
|
| return false;
|
| }
|
|
|
| @@ -298,7 +295,7 @@ void ScreenManager::UpdateControllerToWindowMapping() {
|
| std::map<DrmWindow*, HardwareDisplayController*> window_to_controller_map;
|
| // First create a unique mapping between a window and a controller. Note, a
|
| // controller may be associated with at most 1 window.
|
| - for (HardwareDisplayController* controller : controllers_) {
|
| + for (const auto& controller : controllers_) {
|
| if (controller->IsDisabled())
|
| continue;
|
|
|
| @@ -307,7 +304,7 @@ void ScreenManager::UpdateControllerToWindowMapping() {
|
| if (!window)
|
| continue;
|
|
|
| - window_to_controller_map[window] = controller;
|
| + window_to_controller_map[window] = controller.get();
|
| }
|
|
|
| // Apply the new mapping to all windows.
|
|
|