| OLD | NEW |
| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); | 95 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); |
| 96 // 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 |
| 97 // 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 |
| 98 // display configuration in ScreenManager and NativeDisplayDelegate creating | 98 // display configuration in ScreenManager and NativeDisplayDelegate creating |
| 99 // the display controllers.) | 99 // the display controllers.) |
| 100 if (it != controllers_.end()) { | 100 if (it != controllers_.end()) { |
| 101 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present."; | 101 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present."; |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 | 104 |
| 105 controllers_.push_back(base::WrapUnique(new HardwareDisplayController( | 105 controllers_.push_back(base::MakeUnique<HardwareDisplayController>( |
| 106 std::unique_ptr<CrtcController>(new CrtcController(drm, crtc, connector)), | 106 std::unique_ptr<CrtcController>(new CrtcController(drm, crtc, connector)), |
| 107 gfx::Point()))); | 107 gfx::Point())); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm, | 110 void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm, |
| 111 uint32_t crtc) { | 111 uint32_t crtc) { |
| 112 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); | 112 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); |
| 113 if (it != controllers_.end()) { | 113 if (it != controllers_.end()) { |
| 114 bool is_mirrored = (*it)->IsMirrored(); | 114 bool is_mirrored = (*it)->IsMirrored(); |
| 115 (*it)->RemoveCrtc(drm, crtc); | 115 (*it)->RemoveCrtc(drm, crtc); |
| 116 if (!is_mirrored) { | 116 if (!is_mirrored) { |
| 117 controllers_.erase(it); | 117 controllers_.erase(it); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 // Just re-enable the controller to re-use the current state. | 164 // Just re-enable the controller to re-use the current state. |
| 165 return EnableController(controller); | 165 return EnableController(controller); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // 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 |
| 169 // mode and configure the display independently. If the caller still wants | 169 // mode and configure the display independently. If the caller still wants |
| 170 // mirror mode, subsequent calls configuring the other controllers will | 170 // mirror mode, subsequent calls configuring the other controllers will |
| 171 // restore mirror mode. | 171 // restore mirror mode. |
| 172 if (controller->IsMirrored()) { | 172 if (controller->IsMirrored()) { |
| 173 controllers_.push_back(base::WrapUnique(new HardwareDisplayController( | 173 controllers_.push_back(base::MakeUnique<HardwareDisplayController>( |
| 174 controller->RemoveCrtc(drm, crtc), controller->origin()))); | 174 controller->RemoveCrtc(drm, crtc), controller->origin())); |
| 175 it = controllers_.end() - 1; | 175 it = controllers_.end() - 1; |
| 176 controller = it->get(); | 176 controller = it->get(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 HardwareDisplayControllers::iterator mirror = | 179 HardwareDisplayControllers::iterator mirror = |
| 180 FindActiveDisplayControllerByLocation(modeset_bounds); | 180 FindActiveDisplayControllerByLocation(modeset_bounds); |
| 181 // Handle mirror mode. | 181 // Handle mirror mode. |
| 182 if (mirror != controllers_.end() && it != mirror) | 182 if (mirror != controllers_.end() && it != mirror) |
| 183 return HandleMirrorMode(it, mirror, drm, crtc, connector, mode); | 183 return HandleMirrorMode(it, mirror, drm, crtc, connector, mode); |
| 184 | 184 |
| 185 return ModesetController(controller, origin, mode); | 185 return ModesetController(controller, origin, mode); |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool ScreenManager::DisableDisplayController( | 188 bool ScreenManager::DisableDisplayController( |
| 189 const scoped_refptr<DrmDevice>& drm, | 189 const scoped_refptr<DrmDevice>& drm, |
| 190 uint32_t crtc) { | 190 uint32_t crtc) { |
| 191 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); | 191 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); |
| 192 if (it != controllers_.end()) { | 192 if (it != controllers_.end()) { |
| 193 HardwareDisplayController* controller = it->get(); | 193 HardwareDisplayController* controller = it->get(); |
| 194 if (controller->IsMirrored()) { | 194 if (controller->IsMirrored()) { |
| 195 controllers_.push_back(base::WrapUnique(new HardwareDisplayController( | 195 controllers_.push_back(base::MakeUnique<HardwareDisplayController>( |
| 196 controller->RemoveCrtc(drm, crtc), controller->origin()))); | 196 controller->RemoveCrtc(drm, crtc), controller->origin())); |
| 197 controller = controllers_.back().get(); | 197 controller = controllers_.back().get(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 controller->Disable(); | 200 controller->Disable(); |
| 201 UpdateControllerToWindowMapping(); | 201 UpdateControllerToWindowMapping(); |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 LOG(ERROR) << "Failed to find display controller crtc=" << crtc; | 205 LOG(ERROR) << "Failed to find display controller crtc=" << crtc; |
| 206 return false; | 206 return false; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { | 387 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { |
| 388 for (auto pair : window_map_) { | 388 for (auto pair : window_map_) { |
| 389 if (pair.second->bounds() == bounds) | 389 if (pair.second->bounds() == bounds) |
| 390 return pair.second; | 390 return pair.second; |
| 391 } | 391 } |
| 392 | 392 |
| 393 return nullptr; | 393 return nullptr; |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace ui | 396 } // namespace ui |
| OLD | NEW |