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 "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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 tmp.device_scale_factor = info.device_scale_factor(); | 195 tmp.device_scale_factor = info.device_scale_factor(); |
196 gfx::Size resolution = tmp.GetSizeInDIP(false); | 196 gfx::Size resolution = tmp.GetSizeInDIP(false); |
197 auto iter = std::find_if(modes.begin(), modes.end(), | 197 auto iter = std::find_if(modes.begin(), modes.end(), |
198 [resolution](const DisplayMode& mode) { | 198 [resolution](const DisplayMode& mode) { |
199 return mode.GetSizeInDIP(false) == resolution; | 199 return mode.GetSizeInDIP(false) == resolution; |
200 }); | 200 }); |
201 FindNextMode(iter, modes, up, out); | 201 FindNextMode(iter, modes, up, out); |
202 return true; | 202 return true; |
203 } | 203 } |
204 | 204 |
205 bool SetDisplayUIScale(int64 id, float ui_scale) { | 205 bool SetDisplayUIScale(int64_t id, float ui_scale) { |
206 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 206 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
207 if (!display_manager->IsActiveDisplayId(id) || | 207 if (!display_manager->IsActiveDisplayId(id) || |
208 !gfx::Display::IsInternalDisplayId(id)) { | 208 !gfx::Display::IsInternalDisplayId(id)) { |
209 return false; | 209 return false; |
210 } | 210 } |
211 const DisplayInfo& info = display_manager->GetDisplayInfo(id); | 211 const DisplayInfo& info = display_manager->GetDisplayInfo(id); |
212 DisplayMode mode; | 212 DisplayMode mode; |
213 if (!GetDisplayModeForUIScale(info, ui_scale, &mode)) | 213 if (!GetDisplayModeForUIScale(info, ui_scale, &mode)) |
214 return false; | 214 return false; |
215 return display_manager->SetDisplayMode(id, mode); | 215 return display_manager->SetDisplayMode(id, mode); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, | 342 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, |
343 const gfx::Point& point_in_screen) { | 343 const gfx::Point& point_in_screen) { |
344 auto iter = std::find_if(displays.begin(), displays.end(), | 344 auto iter = std::find_if(displays.begin(), displays.end(), |
345 [point_in_screen](const gfx::Display& display) { | 345 [point_in_screen](const gfx::Display& display) { |
346 return display.bounds().Contains(point_in_screen); | 346 return display.bounds().Contains(point_in_screen); |
347 }); | 347 }); |
348 return iter == displays.end() ? -1 : (iter - displays.begin()); | 348 return iter == displays.end() ? -1 : (iter - displays.begin()); |
349 } | 349 } |
350 | 350 |
351 DisplayIdPair CreateDisplayIdPair(int64 id1, int64 id2) { | 351 DisplayIdPair CreateDisplayIdPair(int64_t id1, int64_t id2) { |
352 return CompareDisplayIds(id1, id2) ? std::make_pair(id1, id2) | 352 return CompareDisplayIds(id1, id2) ? std::make_pair(id1, id2) |
353 : std::make_pair(id2, id1); | 353 : std::make_pair(id2, id1); |
354 } | 354 } |
355 | 355 |
356 bool CompareDisplayIds(int64 id1, int64 id2) { | 356 bool CompareDisplayIds(int64_t id1, int64_t id2) { |
357 DCHECK_NE(id1, id2); | 357 DCHECK_NE(id1, id2); |
358 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID | 358 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID |
359 // in edid_parser.cc. | 359 // in edid_parser.cc. |
360 int index_1 = id1 & 0xFF; | 360 int index_1 = id1 & 0xFF; |
361 int index_2 = id2 & 0xFF; | 361 int index_2 = id2 & 0xFF; |
362 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; | 362 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; |
363 return gfx::Display::IsInternalDisplayId(id1) || | 363 return gfx::Display::IsInternalDisplayId(id1) || |
364 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2)); | 364 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2)); |
365 } | 365 } |
366 | 366 |
367 } // namespace ash | 367 } // namespace ash |
OLD | NEW |