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

Side by Side Diff: ui/ozone/platform/dri/screen_manager.cc

Issue 548613002: Revert of [Ozone-GBM] Handle GPU crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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/dri/screen_manager.h" 5 #include "ui/ozone/platform/dri/screen_manager.h"
6 6
7 #include <xf86drmMode.h> 7 #include <xf86drmMode.h>
8 8
9 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 #include "ui/ozone/platform/dri/crtc_state.h" 12 #include "ui/ozone/platform/dri/crtc_state.h"
13 #include "ui/ozone/platform/dri/dri_util.h" 13 #include "ui/ozone/platform/dri/dri_util.h"
14 #include "ui/ozone/platform/dri/hardware_display_controller.h" 14 #include "ui/ozone/platform/dri/hardware_display_controller.h"
15 #include "ui/ozone/platform/dri/scanout_buffer.h" 15 #include "ui/ozone/platform/dri/scanout_buffer.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 ScreenManager::ScreenManager(DriWrapper* dri, 19 ScreenManager::ScreenManager(DriWrapper* dri,
20 ScanoutBufferGenerator* buffer_generator) 20 ScanoutBufferGenerator* buffer_generator)
21 : dri_(dri), buffer_generator_(buffer_generator) { 21 : dri_(dri), buffer_generator_(buffer_generator) {
22 } 22 }
23 23
24 ScreenManager::~ScreenManager() { 24 ScreenManager::~ScreenManager() {
25 } 25 }
26 26
27 void ScreenManager::AddDisplayController(uint32_t crtc, uint32_t connector) {
28 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
29 // TODO(dnicoara): Turn this into a DCHECK when async display configuration is
30 // properly supported. (When there can't be a race between forcing initial
31 // display configuration in ScreenManager and NativeDisplayDelegate creating
32 // the display controllers.)
33 if (it != controllers_.end()) {
34 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present.";
35 return;
36 }
37
38 controllers_.push_back(new HardwareDisplayController(
39 dri_, scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector))));
40 }
41
42 void ScreenManager::RemoveDisplayController(uint32_t crtc) { 27 void ScreenManager::RemoveDisplayController(uint32_t crtc) {
43 HardwareDisplayControllers::iterator it = FindDisplayController(crtc); 28 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
44 if (it != controllers_.end()) { 29 if (it != controllers_.end()) {
45 bool is_mirrored = (*it)->IsMirrored(); 30 bool is_mirrored = (*it)->IsMirrored();
46 (*it)->RemoveCrtc(crtc); 31 (*it)->RemoveCrtc(crtc);
47 if (!is_mirrored) 32 if (!is_mirrored)
48 controllers_.erase(it); 33 controllers_.erase(it);
49 } 34 }
50 } 35 }
51 36
52 bool ScreenManager::ConfigureDisplayController(uint32_t crtc, 37 bool ScreenManager::ConfigureDisplayController(uint32_t crtc,
53 uint32_t connector, 38 uint32_t connector,
54 const gfx::Point& origin, 39 const gfx::Point& origin,
55 const drmModeModeInfo& mode) { 40 const drmModeModeInfo& mode) {
56 gfx::Rect modeset_bounds( 41 gfx::Rect modeset_bounds(
57 origin.x(), origin.y(), mode.hdisplay, mode.vdisplay); 42 origin.x(), origin.y(), mode.hdisplay, mode.vdisplay);
58 HardwareDisplayControllers::iterator it = FindDisplayController(crtc); 43 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
59 DCHECK(controllers_.end() != it) << "Display controller (crtc=" << crtc 44 HardwareDisplayController* controller = NULL;
60 << ") doesn't exist."; 45 if (it != controllers_.end()) {
46 controller = *it;
47 // If nothing changed just enable the controller. Note, we perform an exact
48 // comparison on the mode since the refresh rate may have changed.
49 if (SameMode(mode, controller->get_mode()) &&
50 origin == controller->origin() && !controller->IsDisabled())
51 return controller->Enable();
61 52
62 HardwareDisplayController* controller = *it; 53 // Either the mode or the location of the display changed, so exit mirror
63 controller = *it; 54 // mode and configure the display independently. If the caller still wants
64 // If nothing changed just enable the controller. Note, we perform an exact 55 // mirror mode, subsequent calls configuring the other controllers will
65 // comparison on the mode since the refresh rate may have changed. 56 // restore mirror mode.
66 if (SameMode(mode, controller->get_mode()) && 57 if (controller->IsMirrored()) {
67 origin == controller->origin() && !controller->IsDisabled()) 58 controller =
68 return controller->Enable(); 59 new HardwareDisplayController(dri_, controller->RemoveCrtc(crtc));
60 controllers_.push_back(controller);
61 it = --controllers_.end();
62 }
69 63
70 // Either the mode or the location of the display changed, so exit mirror 64 HardwareDisplayControllers::iterator mirror =
71 // mode and configure the display independently. If the caller still wants 65 FindActiveDisplayControllerByLocation(modeset_bounds);
72 // mirror mode, subsequent calls configuring the other controllers will 66 // Handle mirror mode.
73 // restore mirror mode. 67 if (mirror != controllers_.end() && it != mirror)
74 if (controller->IsMirrored()) { 68 return HandleMirrorMode(it, mirror, crtc, connector);
75 controller = 69 } else {
76 new HardwareDisplayController(dri_, controller->RemoveCrtc(crtc)); 70 HardwareDisplayControllers::iterator mirror =
77 controllers_.push_back(controller); 71 FindActiveDisplayControllerByLocation(modeset_bounds);
78 it = --controllers_.end(); 72 if (mirror != controllers_.end()) {
73 (*mirror)->AddCrtc(
74 scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector)));
75 return (*mirror)->Enable();
76 }
79 } 77 }
80 78
81 HardwareDisplayControllers::iterator mirror = 79 if (!controller) {
82 FindActiveDisplayControllerByLocation(modeset_bounds); 80 controller = new HardwareDisplayController(
83 // Handle mirror mode. 81 dri_,
84 if (mirror != controllers_.end() && it != mirror) 82 scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector)));
85 return HandleMirrorMode(it, mirror, crtc, connector); 83 controllers_.push_back(controller);
84 }
86 85
87 return ModesetDisplayController(controller, origin, mode); 86 return ModesetDisplayController(controller, origin, mode);
88 } 87 }
89 88
90 bool ScreenManager::DisableDisplayController(uint32_t crtc) { 89 bool ScreenManager::DisableDisplayController(uint32_t crtc) {
91 HardwareDisplayControllers::iterator it = FindDisplayController(crtc); 90 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
92 if (it != controllers_.end()) { 91 if (it != controllers_.end()) {
93 if ((*it)->IsMirrored()) { 92 if ((*it)->IsMirrored()) {
94 HardwareDisplayController* controller = 93 HardwareDisplayController* controller =
95 new HardwareDisplayController(dri_, (*it)->RemoveCrtc(crtc)); 94 new HardwareDisplayController(dri_, (*it)->RemoveCrtc(crtc));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 153
155 DCHECK_NE(0u, displays.size()); 154 DCHECK_NE(0u, displays.size());
156 155
157 ScopedDrmPropertyPtr dpms( 156 ScopedDrmPropertyPtr dpms(
158 dri_->GetProperty(displays[0]->connector(), "DPMS")); 157 dri_->GetProperty(displays[0]->connector(), "DPMS"));
159 if (dpms) 158 if (dpms)
160 dri_->SetProperty(displays[0]->connector()->connector_id, 159 dri_->SetProperty(displays[0]->connector()->connector_id,
161 dpms->prop_id, 160 dpms->prop_id,
162 DRM_MODE_DPMS_ON); 161 DRM_MODE_DPMS_ON);
163 162
164 AddDisplayController(displays[0]->crtc()->crtc_id,
165 displays[0]->connector()->connector_id);
166 ConfigureDisplayController(displays[0]->crtc()->crtc_id, 163 ConfigureDisplayController(displays[0]->crtc()->crtc_id,
167 displays[0]->connector()->connector_id, 164 displays[0]->connector()->connector_id,
168 gfx::Point(), 165 gfx::Point(),
169 displays[0]->connector()->modes[0]); 166 displays[0]->connector()->modes[0]);
170 } 167 }
171 168
172 bool ScreenManager::ModesetDisplayController( 169 bool ScreenManager::ModesetDisplayController(
173 HardwareDisplayController* controller, 170 HardwareDisplayController* controller,
174 const gfx::Point& origin, 171 const gfx::Point& origin,
175 const drmModeModeInfo& mode) { 172 const drmModeModeInfo& mode) {
(...skipping 30 matching lines...) Expand all
206 203
207 // When things go wrong revert back to the previous configuration since 204 // When things go wrong revert back to the previous configuration since
208 // it is expected that the configuration would not have changed if 205 // it is expected that the configuration would not have changed if
209 // things fail. 206 // things fail.
210 (*original)->AddCrtc((*mirror)->RemoveCrtc(crtc)); 207 (*original)->AddCrtc((*mirror)->RemoveCrtc(crtc));
211 (*original)->Enable(); 208 (*original)->Enable();
212 return false; 209 return false;
213 } 210 }
214 211
215 } // namespace ui 212 } // namespace ui
OLDNEW
« 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