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

Side by Side Diff: ash/display/display_util.cc

Issue 1361763003: Ignore UI scaling when internal display isn't active (in docked mode, for example) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « ash/display/display_manager_unittest.cc ('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 "ash/display/display_util.h" 5 #include "ash/display/display_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 << resolution.ToString(); 166 << resolution.ToString();
167 return false; 167 return false;
168 } 168 }
169 *out = *iter; 169 *out = *iter;
170 return true; 170 return true;
171 } 171 }
172 172
173 bool GetDisplayModeForNextUIScale(const DisplayInfo& info, 173 bool GetDisplayModeForNextUIScale(const DisplayInfo& info,
174 bool up, 174 bool up,
175 DisplayMode* out) { 175 DisplayMode* out) {
176 if (!gfx::Display::IsInternalDisplayId(info.id())) 176 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
177 if (!display_manager->IsActiveDisplayId(info.id()) ||
178 !gfx::Display::IsInternalDisplayId(info.id())) {
177 return false; 179 return false;
180 }
178 const std::vector<DisplayMode>& modes = info.display_modes(); 181 const std::vector<DisplayMode>& modes = info.display_modes();
179 ScaleComparator comparator(info.configured_ui_scale()); 182 ScaleComparator comparator(info.configured_ui_scale());
180 auto iter = std::find_if(modes.begin(), modes.end(), comparator); 183 auto iter = std::find_if(modes.begin(), modes.end(), comparator);
181 FindNextMode(iter, modes, up, out); 184 FindNextMode(iter, modes, up, out);
182 return true; 185 return true;
183 } 186 }
184 187
185 bool GetDisplayModeForNextResolution(const DisplayInfo& info, 188 bool GetDisplayModeForNextResolution(const DisplayInfo& info,
186 bool up, 189 bool up,
187 DisplayMode* out) { 190 DisplayMode* out) {
188 if (gfx::Display::IsInternalDisplayId(info.id())) 191 if (gfx::Display::IsInternalDisplayId(info.id()))
189 return false; 192 return false;
190 const std::vector<DisplayMode>& modes = info.display_modes(); 193 const std::vector<DisplayMode>& modes = info.display_modes();
191 DisplayMode tmp(info.size_in_pixel(), 0.0f, false, false); 194 DisplayMode tmp(info.size_in_pixel(), 0.0f, false, false);
192 tmp.device_scale_factor = info.device_scale_factor(); 195 tmp.device_scale_factor = info.device_scale_factor();
193 gfx::Size resolution = tmp.GetSizeInDIP(false); 196 gfx::Size resolution = tmp.GetSizeInDIP(false);
194 auto iter = std::find_if(modes.begin(), modes.end(), 197 auto iter = std::find_if(modes.begin(), modes.end(),
195 [resolution](const DisplayMode& mode) { 198 [resolution](const DisplayMode& mode) {
196 return mode.GetSizeInDIP(false) == resolution; 199 return mode.GetSizeInDIP(false) == resolution;
197 }); 200 });
198 FindNextMode(iter, modes, up, out); 201 FindNextMode(iter, modes, up, out);
199 return true; 202 return true;
200 } 203 }
201 204
202 bool SetDisplayUIScale(int64 id, float ui_scale) { 205 bool SetDisplayUIScale(int64 id, float ui_scale) {
203 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 206 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
207 if (!display_manager->IsActiveDisplayId(id) ||
208 !gfx::Display::IsInternalDisplayId(id)) {
209 return false;
210 }
204 const DisplayInfo& info = display_manager->GetDisplayInfo(id); 211 const DisplayInfo& info = display_manager->GetDisplayInfo(id);
205 DisplayMode mode; 212 DisplayMode mode;
206 if (!GetDisplayModeForUIScale(info, ui_scale, &mode)) 213 if (!GetDisplayModeForUIScale(info, ui_scale, &mode))
207 return false; 214 return false;
208 return display_manager->SetDisplayMode(id, mode); 215 return display_manager->SetDisplayMode(id, mode);
209 } 216 }
210 217
211 bool HasDisplayModeForUIScale(const DisplayInfo& info, float ui_scale) { 218 bool HasDisplayModeForUIScale(const DisplayInfo& info, float ui_scale) {
212 ScaleComparator comparator(ui_scale); 219 ScaleComparator comparator(ui_scale);
213 const std::vector<DisplayMode>& modes = info.display_modes(); 220 const std::vector<DisplayMode>& modes = info.display_modes();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID 358 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID
352 // in edid_parser.cc. 359 // in edid_parser.cc.
353 int index_1 = id1 & 0xFF; 360 int index_1 = id1 & 0xFF;
354 int index_2 = id2 & 0xFF; 361 int index_2 = id2 & 0xFF;
355 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; 362 DCHECK_NE(index_1, index_2) << id1 << " and " << id2;
356 return gfx::Display::IsInternalDisplayId(id1) || 363 return gfx::Display::IsInternalDisplayId(id1) ||
357 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2)); 364 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2));
358 } 365 }
359 366
360 } // namespace ash 367 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698