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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc

Issue 2894523007: Use display::DisplayMode in ozone/drm/gpu (Closed)
Patch Set: review nits Created 3 years, 7 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/drm/gpu/drm_gpu_display_manager.h" 5 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "ui/display/types/display_mode.h"
10 #include "ui/display/types/gamma_ramp_rgb_entry.h" 11 #include "ui/display/types/gamma_ramp_rgb_entry.h"
11 #include "ui/ozone/platform/drm/common/drm_util.h" 12 #include "ui/ozone/platform/drm/common/drm_util.h"
12 #include "ui/ozone/platform/drm/gpu/drm_device.h" 13 #include "ui/ozone/platform/drm/gpu/drm_device.h"
13 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 14 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
14 #include "ui/ozone/platform/drm/gpu/drm_display.h" 15 #include "ui/ozone/platform/drm/gpu/drm_display.h"
15 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 16 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 namespace { 20 namespace {
(...skipping 14 matching lines...) Expand all
34 return drm_ == other->drm() && connector_ == other->connector() && 35 return drm_ == other->drm() && connector_ == other->connector() &&
35 crtc_ == other->crtc(); 36 crtc_ == other->crtc();
36 } 37 }
37 38
38 private: 39 private:
39 scoped_refptr<DrmDevice> drm_; 40 scoped_refptr<DrmDevice> drm_;
40 uint32_t crtc_; 41 uint32_t crtc_;
41 uint32_t connector_; 42 uint32_t connector_;
42 }; 43 };
43 44
45 bool MatchMode(const display::DisplayMode& display_mode,
46 const drmModeModeInfo& m) {
47 return display_mode.size() == ModeSize(m) &&
48 display_mode.refresh_rate() == ModeRefreshRate(m) &&
49 display_mode.is_interlaced() == ModeIsInterlaced(m);
50 }
51
44 bool FindMatchingMode(const std::vector<drmModeModeInfo> modes, 52 bool FindMatchingMode(const std::vector<drmModeModeInfo> modes,
45 const DisplayMode_Params& mode_params, 53 const display::DisplayMode& display_mode,
46 drmModeModeInfo* mode) { 54 drmModeModeInfo* mode) {
47 for (const drmModeModeInfo& m : modes) { 55 for (const drmModeModeInfo& m : modes) {
48 DisplayMode_Params params = CreateDisplayModeParams(m); 56 if (MatchMode(display_mode, m)) {
49 if (mode_params.size == params.size &&
50 mode_params.refresh_rate == params.refresh_rate &&
51 mode_params.is_interlaced == params.is_interlaced) {
52 *mode = m; 57 *mode = m;
53 return true; 58 return true;
54 } 59 }
55 } 60 }
56
57 return false; 61 return false;
58 } 62 }
59 63
60 } // namespace 64 } // namespace
61 65
62 DrmGpuDisplayManager::DrmGpuDisplayManager(ScreenManager* screen_manager, 66 DrmGpuDisplayManager::DrmGpuDisplayManager(ScreenManager* screen_manager,
63 DrmDeviceManager* drm_device_manager) 67 DrmDeviceManager* drm_device_manager)
64 : screen_manager_(screen_manager), drm_device_manager_(drm_device_manager) { 68 : screen_manager_(screen_manager), drm_device_manager_(drm_device_manager) {
65 } 69 }
66 70
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 128 }
125 129
126 void DrmGpuDisplayManager::RelinquishDisplayControl() { 130 void DrmGpuDisplayManager::RelinquishDisplayControl() {
127 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); 131 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices();
128 for (const auto& drm : devices) 132 for (const auto& drm : devices)
129 drm->DropMaster(); 133 drm->DropMaster();
130 } 134 }
131 135
132 bool DrmGpuDisplayManager::ConfigureDisplay( 136 bool DrmGpuDisplayManager::ConfigureDisplay(
133 int64_t display_id, 137 int64_t display_id,
134 const DisplayMode_Params& mode_param, 138 const display::DisplayMode& display_mode,
135 const gfx::Point& origin) { 139 const gfx::Point& origin) {
136 DrmDisplay* display = FindDisplay(display_id); 140 DrmDisplay* display = FindDisplay(display_id);
137 if (!display) { 141 if (!display) {
138 LOG(ERROR) << "There is no display with ID " << display_id; 142 LOG(ERROR) << "There is no display with ID " << display_id;
139 return false; 143 return false;
140 } 144 }
141 145
142 drmModeModeInfo mode; 146 drmModeModeInfo mode;
143 bool mode_found = FindMatchingMode(display->modes(), mode_param, &mode); 147 bool mode_found = FindMatchingMode(display->modes(), display_mode, &mode);
144 if (!mode_found) { 148 if (!mode_found) {
145 // If the display doesn't have the mode natively, then lookup the mode from 149 // If the display doesn't have the mode natively, then lookup the mode from
146 // other displays and try using it on the current display (some displays 150 // other displays and try using it on the current display (some displays
147 // support panel fitting and they can use different modes even if the mode 151 // support panel fitting and they can use different modes even if the mode
148 // isn't explicitly declared). 152 // isn't explicitly declared).
149 for (const auto& other_display : displays_) { 153 for (const auto& other_display : displays_) {
150 mode_found = FindMatchingMode(other_display->modes(), mode_param, &mode); 154 mode_found =
155 FindMatchingMode(other_display->modes(), display_mode, &mode);
151 if (mode_found) 156 if (mode_found)
152 break; 157 break;
153 } 158 }
154 } 159 }
155 160
156 if (!mode_found) { 161 if (!mode_found) {
157 LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString() 162 LOG(ERROR) << "Failed to find mode: size=" << display_mode.size().ToString()
158 << " is_interlaced=" << mode_param.is_interlaced 163 << " is_interlaced=" << display_mode.is_interlaced()
159 << " refresh_rate=" << mode_param.refresh_rate; 164 << " refresh_rate=" << display_mode.refresh_rate();
160 return false; 165 return false;
161 } 166 }
162 167
163 return display->Configure(&mode, origin); 168 return display->Configure(&mode, origin);
164 } 169 }
165 170
166 bool DrmGpuDisplayManager::DisableDisplay(int64_t display_id) { 171 bool DrmGpuDisplayManager::DisableDisplay(int64_t display_id) {
167 DrmDisplay* display = FindDisplay(display_id); 172 DrmDisplay* display = FindDisplay(display_id);
168 if (!display) { 173 if (!display) {
169 LOG(ERROR) << "There is no display with ID " << display_id; 174 LOG(ERROR) << "There is no display with ID " << display_id;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DisplayComparator(new_display.get())); 241 DisplayComparator(new_display.get()));
237 242
238 if (it == old_displays.end()) { 243 if (it == old_displays.end()) {
239 screen_manager_->AddDisplayController( 244 screen_manager_->AddDisplayController(
240 new_display->drm(), new_display->crtc(), new_display->connector()); 245 new_display->drm(), new_display->crtc(), new_display->connector());
241 } 246 }
242 } 247 }
243 } 248 }
244 249
245 } // namespace ui 250 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h ('k') | ui/ozone/platform/drm/gpu/drm_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698