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

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: Reland of: [Ozone-GBM] Handle GPU crashes 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 fa0ad3de760d58d160e0a7a10dea1017538dde0f..c3ac47477a932db40d79a00bcab8275cb10a0461 100644
--- a/ui/ozone/platform/dri/screen_manager.cc
+++ b/ui/ozone/platform/dri/screen_manager.cc
@@ -24,6 +24,21 @@ ScreenManager::ScreenManager(DriWrapper* dri,
ScreenManager::~ScreenManager() {
}
+void ScreenManager::AddDisplayController(uint32_t crtc, uint32_t connector) {
+ HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
+ // TODO(dnicoara): Turn this into a DCHECK when async display configuration is
+ // properly supported. (When there can't be a race between forcing initial
+ // display configuration in ScreenManager and NativeDisplayDelegate creating
+ // the display controllers.)
+ if (it != controllers_.end()) {
+ LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present.";
+ 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()) {
@@ -41,48 +56,34 @@ bool ScreenManager::ConfigureDisplayController(uint32_t crtc,
gfx::Rect modeset_bounds(
origin.x(), origin.y(), mode.hdisplay, mode.vdisplay);
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);
}
@@ -160,6 +161,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