OLD | NEW |
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/dri_gpu_platform_support.h" | 5 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" |
6 | 6 |
7 #include "ipc/ipc_message_macros.h" | 7 #include "ipc/ipc_message_macros.h" |
8 #include "ui/display/types/display_mode.h" | 8 #include "ui/display/types/display_mode.h" |
9 #include "ui/display/types/display_snapshot.h" | 9 #include "ui/display/types/display_snapshot.h" |
10 #include "ui/ozone/common/display_util.h" | 10 #include "ui/ozone/common/display_util.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 void DriGpuPlatformSupport::OnRefreshNativeDisplays( | 133 void DriGpuPlatformSupport::OnRefreshNativeDisplays( |
134 const std::vector<DisplaySnapshot_Params>& cached_displays) { | 134 const std::vector<DisplaySnapshot_Params>& cached_displays) { |
135 std::vector<DisplaySnapshot_Params> displays; | 135 std::vector<DisplaySnapshot_Params> displays; |
136 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); | 136 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); |
137 | 137 |
138 // If any of the cached displays are in the list of new displays then apply | 138 // If any of the cached displays are in the list of new displays then apply |
139 // their configuration immediately. | 139 // their configuration immediately. |
140 for (size_t i = 0; i < native_displays.size(); ++i) { | 140 for (size_t i = 0; i < native_displays.size(); ++i) { |
141 std::vector<DisplaySnapshot_Params>::const_iterator it = | 141 std::vector<DisplaySnapshot_Params>::const_iterator it = |
142 std::find_if(cached_displays.begin(), | 142 std::find_if(cached_displays.begin(), cached_displays.end(), |
143 cached_displays.end(), | |
144 FindDisplayById(native_displays[i]->display_id())); | 143 FindDisplayById(native_displays[i]->display_id())); |
145 | 144 |
146 if (it == cached_displays.end()) | 145 if (it == cached_displays.end()) |
147 continue; | 146 continue; |
148 | 147 |
149 if (it->has_current_mode) | 148 if (it->has_current_mode) |
150 OnConfigureNativeDisplay(it->display_id, it->current_mode, it->origin); | 149 OnConfigureNativeDisplay(it->display_id, it->current_mode, it->origin); |
151 else | 150 else |
152 OnDisableNativeDisplay(it->display_id); | 151 OnDisableNativeDisplay(it->display_id); |
153 } | 152 } |
(...skipping 22 matching lines...) Expand all Loading... |
176 mode = display->modes()[i]; | 175 mode = display->modes()[i]; |
177 break; | 176 break; |
178 } | 177 } |
179 } | 178 } |
180 | 179 |
181 // If the display doesn't have the mode natively, then lookup the mode from | 180 // If the display doesn't have the mode natively, then lookup the mode from |
182 // other displays and try using it on the current display (some displays | 181 // other displays and try using it on the current display (some displays |
183 // support panel fitting and they can use different modes even if the mode | 182 // support panel fitting and they can use different modes even if the mode |
184 // isn't explicitly declared). | 183 // isn't explicitly declared). |
185 if (!mode) | 184 if (!mode) |
186 mode = ndd_->FindDisplayMode( | 185 mode = ndd_->FindDisplayMode(mode_param.size, mode_param.is_interlaced, |
187 mode_param.size, mode_param.is_interlaced, mode_param.refresh_rate); | 186 mode_param.refresh_rate); |
188 | 187 |
189 if (!mode) { | 188 if (!mode) { |
190 LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString() | 189 LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString() |
191 << " is_interlaced=" << mode_param.is_interlaced | 190 << " is_interlaced=" << mode_param.is_interlaced |
192 << " refresh_rate=" << mode_param.refresh_rate; | 191 << " refresh_rate=" << mode_param.refresh_rate; |
193 return; | 192 return; |
194 } | 193 } |
195 | 194 |
196 ndd_->Configure(*display, mode, origin); | 195 ndd_->Configure(*display, mode, origin); |
197 } | 196 } |
198 | 197 |
199 void DriGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) { | 198 void DriGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) { |
200 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); | 199 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); |
201 if (display) | 200 if (display) |
202 ndd_->Configure(*display, NULL, gfx::Point()); | 201 ndd_->Configure(*display, NULL, gfx::Point()); |
203 else | 202 else |
204 LOG(ERROR) << "There is no display with ID " << id; | 203 LOG(ERROR) << "There is no display with ID " << id; |
205 } | 204 } |
206 | 205 |
207 } // namespace ui | 206 } // namespace ui |
OLD | NEW |