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

Unified Diff: ui/ozone/platform/dri/screen_manager.cc

Issue 522463005: [Ozone-GBM] Handle GPU crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated to allow proper restore of secondary displays Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | ui/ozone/platform/dri/screen_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/screen_manager.cc
diff --git a/ui/ozone/platform/dri/screen_manager.cc b/ui/ozone/platform/dri/screen_manager.cc
index 0a8af0fc662a8efa3388aa14ea1941228f2cf838..5e96759398b77c0a448754cdc9d982c7c04f5eb4 100644
--- a/ui/ozone/platform/dri/screen_manager.cc
+++ b/ui/ozone/platform/dri/screen_manager.cc
@@ -32,6 +32,17 @@ ScreenManager::ScreenManager(DriWrapper* dri,
ScreenManager::~ScreenManager() {
}
+void ScreenManager::AddDisplayController(uint32_t crtc, uint32_t connector) {
+ HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
+ if (it != controllers_.end()) {
+ LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present.";
alexst (slow to review) 2014/09/04 14:44:45 Do you expect this to be a regular frequent occurr
dnicoara 2014/09/04 15:12:07 This is a by-product of having to support a forced
+ return;
+ }
+
+ controllers_.push_back(new HardwareDisplayController(
+ dri_, scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector))));
+}
+
void ScreenManager::RemoveDisplayController(uint32_t crtc) {
HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
if (it != controllers_.end()) {
@@ -48,48 +59,34 @@ bool ScreenManager::ConfigureDisplayController(uint32_t crtc,
const drmModeModeInfo& mode) {
gfx::Rect modeset_bounds(origin, GetModeSize(mode));
HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
- HardwareDisplayController* controller = NULL;
- if (it != controllers_.end()) {
- controller = *it;
- // If nothing changed just enable the controller. Note, we perform an exact
- // comparison on the mode since the refresh rate may have changed.
- if (SameMode(mode, controller->get_mode()) &&
- origin == controller->origin() && !controller->IsDisabled())
- return controller->Enable();
-
- // Either the mode or the location of the display changed, so exit mirror
- // mode and configure the display independently. If the caller still wants
- // mirror mode, subsequent calls configuring the other controllers will
- // restore mirror mode.
- if (controller->IsMirrored()) {
- controller =
- new HardwareDisplayController(dri_, controller->RemoveCrtc(crtc));
- controllers_.push_back(controller);
- it = --controllers_.end();
- }
-
- HardwareDisplayControllers::iterator mirror =
- FindActiveDisplayControllerByLocation(modeset_bounds);
- // Handle mirror mode.
- if (mirror != controllers_.end() && it != mirror)
- return HandleMirrorMode(it, mirror, crtc, connector);
- } else {
- HardwareDisplayControllers::iterator mirror =
- FindActiveDisplayControllerByLocation(modeset_bounds);
- if (mirror != controllers_.end()) {
- (*mirror)->AddCrtc(
- scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector)));
- return (*mirror)->Enable();
- }
- }
-
- if (!controller) {
- controller = new HardwareDisplayController(
- dri_,
- scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector)));
+ DCHECK(controllers_.end() != it) << "Display controller (crtc=" << crtc
+ << ") doesn't exist.";
+
+ HardwareDisplayController* controller = *it;
+ controller = *it;
+ // If nothing changed just enable the controller. Note, we perform an exact
+ // comparison on the mode since the refresh rate may have changed.
+ if (SameMode(mode, controller->get_mode()) &&
+ origin == controller->origin() && !controller->IsDisabled())
+ return controller->Enable();
+
+ // Either the mode or the location of the display changed, so exit mirror
+ // mode and configure the display independently. If the caller still wants
+ // mirror mode, subsequent calls configuring the other controllers will
+ // restore mirror mode.
+ if (controller->IsMirrored()) {
+ controller =
+ new HardwareDisplayController(dri_, controller->RemoveCrtc(crtc));
controllers_.push_back(controller);
+ it = --controllers_.end();
}
+ HardwareDisplayControllers::iterator mirror =
+ FindActiveDisplayControllerByLocation(modeset_bounds);
+ // Handle mirror mode.
+ if (mirror != controllers_.end() && it != mirror)
+ return HandleMirrorMode(it, mirror, crtc, connector);
+
return ModesetDisplayController(controller, origin, mode);
}
@@ -168,6 +165,8 @@ void ScreenManager::ForceInitializationOfPrimaryDisplay() {
dpms->prop_id,
DRM_MODE_DPMS_ON);
+ AddDisplayController(displays[0]->crtc()->crtc_id,
+ displays[0]->connector()->connector_id);
ConfigureDisplayController(displays[0]->crtc()->crtc_id,
displays[0]->connector()->connector_id,
gfx::Point(),
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | ui/ozone/platform/dri/screen_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698