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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, | 332 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, |
333 const gfx::Point& point_in_screen) { | 333 const gfx::Point& point_in_screen) { |
334 auto iter = std::find_if(displays.begin(), displays.end(), | 334 auto iter = std::find_if(displays.begin(), displays.end(), |
335 [point_in_screen](const gfx::Display& display) { | 335 [point_in_screen](const gfx::Display& display) { |
336 return display.bounds().Contains(point_in_screen); | 336 return display.bounds().Contains(point_in_screen); |
337 }); | 337 }); |
338 return iter == displays.end() ? -1 : (iter - displays.begin()); | 338 return iter == displays.end() ? -1 : (iter - displays.begin()); |
339 } | 339 } |
340 | 340 |
341 DisplayIdPair CreateDisplayIdPair(int64 id1, int64 id2) { | 341 DisplayIdPair CreateDisplayIdPair(int64 id1, int64 id2) { |
| 342 return CompareDisplayIds(id1, id2) ? std::make_pair(id1, id2) |
| 343 : std::make_pair(id2, id1); |
| 344 } |
| 345 |
| 346 bool CompareDisplayIds(int64 id1, int64 id2) { |
342 DCHECK_NE(id1, id2); | 347 DCHECK_NE(id1, id2); |
343 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID | 348 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID |
344 // in edid_parser.cc. | 349 // in edid_parser.cc. |
345 int index_1 = id1 & 0xFF; | 350 int index_1 = id1 & 0xFF; |
346 int index_2 = id2 & 0xFF; | 351 int index_2 = id2 & 0xFF; |
347 if (gfx::Display::IsInternalDisplayId(id2) || index_2 < index_1) | 352 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; |
348 return std::make_pair(id2, id1); | 353 return gfx::Display::IsInternalDisplayId(id1) || |
349 else | 354 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2)); |
350 return std::make_pair(id1, id2); | |
351 } | 355 } |
352 | 356 |
353 } // namespace ash | 357 } // namespace ash |
OLD | NEW |