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

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

Issue 556263005: [Ozone-DRI] Fix blank screen on init (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
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // configuration reader and ScreenManager is called from there to create the 110 // configuration reader and ScreenManager is called from there to create the
111 // one display needed by the content_shell target. 111 // one display needed by the content_shell target.
112 if (controllers_.empty()) 112 if (controllers_.empty())
113 ForceInitializationOfPrimaryDisplay(); 113 ForceInitializationOfPrimaryDisplay();
114 114
115 HardwareDisplayControllers::iterator it = 115 HardwareDisplayControllers::iterator it =
116 FindActiveDisplayControllerByLocation(bounds); 116 FindActiveDisplayControllerByLocation(bounds);
117 if (it != controllers_.end()) 117 if (it != controllers_.end())
118 return (*it)->AsWeakPtr(); 118 return (*it)->AsWeakPtr();
119 119
120 // If no active controllers then pick the first controller at the location.
121 // TODO(dnicoara): Remove once async display configuration is fully supported.
122 it = FindDisplayControllerByLocation(bounds);
123 if (it != controllers_.end())
124 return (*it)->AsWeakPtr();
125
126 return base::WeakPtr<HardwareDisplayController>(); 120 return base::WeakPtr<HardwareDisplayController>();
127 } 121 }
128 122
129 ScreenManager::HardwareDisplayControllers::iterator 123 ScreenManager::HardwareDisplayControllers::iterator
130 ScreenManager::FindDisplayController(uint32_t crtc) { 124 ScreenManager::FindDisplayController(uint32_t crtc) {
131 for (HardwareDisplayControllers::iterator it = controllers_.begin(); 125 for (HardwareDisplayControllers::iterator it = controllers_.begin();
132 it != controllers_.end(); 126 it != controllers_.end();
133 ++it) { 127 ++it) {
134 if ((*it)->HasCrtc(crtc)) 128 if ((*it)->HasCrtc(crtc))
135 return it; 129 return it;
(...skipping 10 matching lines...) Expand all
146 gfx::Rect controller_bounds((*it)->origin(), (*it)->GetModeSize()); 140 gfx::Rect controller_bounds((*it)->origin(), (*it)->GetModeSize());
147 // We don't perform a strict check since content_shell will have windows 141 // We don't perform a strict check since content_shell will have windows
148 // smaller than the display size. 142 // smaller than the display size.
149 if (controller_bounds.Contains(bounds) && !(*it)->IsDisabled()) 143 if (controller_bounds.Contains(bounds) && !(*it)->IsDisabled())
150 return it; 144 return it;
151 } 145 }
152 146
153 return controllers_.end(); 147 return controllers_.end();
154 } 148 }
155 149
156 ScreenManager::HardwareDisplayControllers::iterator
157 ScreenManager::FindDisplayControllerByLocation(const gfx::Rect& bounds) {
158 for (HardwareDisplayControllers::iterator it = controllers_.begin();
159 it != controllers_.end();
160 ++it) {
161 gfx::Rect controller_bounds((*it)->origin(), (*it)->GetModeSize());
162 // We don't perform a strict check since content_shell will have windows
163 // smaller than the display size.
164 if (controller_bounds.Contains(bounds))
165 return it;
166 }
167
168 return controllers_.end();
169 }
170
171 void ScreenManager::ForceInitializationOfPrimaryDisplay() { 150 void ScreenManager::ForceInitializationOfPrimaryDisplay() {
172 LOG(WARNING) << "Forcing initialization of primary display."; 151 LOG(WARNING) << "Forcing initialization of primary display.";
173 ScopedVector<HardwareDisplayControllerInfo> displays = 152 ScopedVector<HardwareDisplayControllerInfo> displays =
174 GetAvailableDisplayControllerInfos(dri_->get_fd()); 153 GetAvailableDisplayControllerInfos(dri_->get_fd());
175 154
176 DCHECK_NE(0u, displays.size()); 155 DCHECK_NE(0u, displays.size());
177 156
178 ScopedDrmPropertyPtr dpms( 157 ScopedDrmPropertyPtr dpms(
179 dri_->GetProperty(displays[0]->connector(), "DPMS")); 158 dri_->GetProperty(displays[0]->connector(), "DPMS"));
180 if (dpms) 159 if (dpms)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 206
228 // When things go wrong revert back to the previous configuration since 207 // When things go wrong revert back to the previous configuration since
229 // it is expected that the configuration would not have changed if 208 // it is expected that the configuration would not have changed if
230 // things fail. 209 // things fail.
231 (*original)->AddCrtc((*mirror)->RemoveCrtc(crtc)); 210 (*original)->AddCrtc((*mirror)->RemoveCrtc(crtc));
232 (*original)->Enable(); 211 (*original)->Enable();
233 return false; 212 return false;
234 } 213 }
235 214
236 } // namespace ui 215 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698