OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 if (multi_display_mode_ != MIRRORING) | 680 if (multi_display_mode_ != MIRRORING) |
681 multi_display_mode_ = current_default_multi_display_mode_; | 681 multi_display_mode_ = current_default_multi_display_mode_; |
682 | 682 |
683 CreateSoftwareMirroringDisplayInfo(&new_display_info_list); | 683 CreateSoftwareMirroringDisplayInfo(&new_display_info_list); |
684 | 684 |
685 // Close the mirroring window if any here to avoid creating two compositor on | 685 // Close the mirroring window if any here to avoid creating two compositor on |
686 // one display. | 686 // one display. |
687 if (delegate_) | 687 if (delegate_) |
688 delegate_->CloseMirroringDisplayIfNotNecessary(); | 688 delegate_->CloseMirroringDisplayIfNotNecessary(); |
689 | 689 |
690 display::DisplayList new_displays; | 690 display::Displays new_displays; |
691 display::DisplayList removed_displays; | 691 display::Displays removed_displays; |
692 std::map<size_t, uint32_t> display_changes; | 692 std::map<size_t, uint32_t> display_changes; |
693 std::vector<size_t> added_display_indices; | 693 std::vector<size_t> added_display_indices; |
694 | 694 |
695 display::DisplayList::iterator curr_iter = active_display_list_.begin(); | 695 display::Displays::iterator curr_iter = active_display_list_.begin(); |
696 DisplayInfoList::const_iterator new_info_iter = new_display_info_list.begin(); | 696 DisplayInfoList::const_iterator new_info_iter = new_display_info_list.begin(); |
697 | 697 |
698 while (curr_iter != active_display_list_.end() || | 698 while (curr_iter != active_display_list_.end() || |
699 new_info_iter != new_display_info_list.end()) { | 699 new_info_iter != new_display_info_list.end()) { |
700 if (curr_iter == active_display_list_.end()) { | 700 if (curr_iter == active_display_list_.end()) { |
701 // more displays in new list. | 701 // more displays in new list. |
702 added_display_indices.push_back(new_displays.size()); | 702 added_display_indices.push_back(new_displays.size()); |
703 InsertAndUpdateDisplayInfo(*new_info_iter); | 703 InsertAndUpdateDisplayInfo(*new_info_iter); |
704 new_displays.push_back( | 704 new_displays.push_back( |
705 CreateDisplayFromDisplayInfoById(new_info_iter->id())); | 705 CreateDisplayFromDisplayInfoById(new_info_iter->id())); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 } | 983 } |
984 num_connected_displays_ = new_display_info_list.size(); | 984 num_connected_displays_ = new_display_info_list.size(); |
985 mirroring_display_id_ = display::Display::kInvalidDisplayID; | 985 mirroring_display_id_ = display::Display::kInvalidDisplayID; |
986 software_mirroring_display_list_.clear(); | 986 software_mirroring_display_list_.clear(); |
987 UpdateDisplaysWith(new_display_info_list); | 987 UpdateDisplaysWith(new_display_info_list); |
988 } | 988 } |
989 | 989 |
990 void DisplayManager::ToggleDisplayScaleFactor() { | 990 void DisplayManager::ToggleDisplayScaleFactor() { |
991 DCHECK(!active_display_list_.empty()); | 991 DCHECK(!active_display_list_.empty()); |
992 DisplayInfoList new_display_info_list; | 992 DisplayInfoList new_display_info_list; |
993 for (display::DisplayList::const_iterator iter = active_display_list_.begin(); | 993 for (display::Displays::const_iterator iter = active_display_list_.begin(); |
994 iter != active_display_list_.end(); ++iter) { | 994 iter != active_display_list_.end(); ++iter) { |
995 display::ManagedDisplayInfo display_info = GetDisplayInfo(iter->id()); | 995 display::ManagedDisplayInfo display_info = GetDisplayInfo(iter->id()); |
996 display_info.set_device_scale_factor( | 996 display_info.set_device_scale_factor( |
997 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); | 997 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); |
998 new_display_info_list.push_back(display_info); | 998 new_display_info_list.push_back(display_info); |
999 } | 999 } |
1000 AddMirrorDisplayInfoIfAny(&new_display_info_list); | 1000 AddMirrorDisplayInfoIfAny(&new_display_info_list); |
1001 UpdateDisplaysWith(new_display_info_list); | 1001 UpdateDisplaysWith(new_display_info_list); |
1002 } | 1002 } |
1003 | 1003 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 display::Display new_display(display_info.id()); | 1344 display::Display new_display(display_info.id()); |
1345 new_display.SetScaleAndBounds( | 1345 new_display.SetScaleAndBounds( |
1346 1.0f, gfx::Rect(origin, gfx::ScaleToFlooredSize( | 1346 1.0f, gfx::Rect(origin, gfx::ScaleToFlooredSize( |
1347 display_info.size_in_pixel(), scale))); | 1347 display_info.size_in_pixel(), scale))); |
1348 new_display.set_touch_support(display_info.touch_support()); | 1348 new_display.set_touch_support(display_info.touch_support()); |
1349 new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); | 1349 new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); |
1350 return new_display; | 1350 return new_display; |
1351 } | 1351 } |
1352 | 1352 |
1353 void DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout( | 1353 void DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout( |
1354 display::DisplayList* display_list, | 1354 display::Displays* display_list, |
1355 std::vector<size_t>* updated_indices) { | 1355 std::vector<size_t>* updated_indices) { |
1356 if (display_list->size() == 1u) | 1356 if (display_list->size() == 1u) |
1357 return; | 1357 return; |
1358 | 1358 |
1359 const display::DisplayLayout& layout = | 1359 const display::DisplayLayout& layout = |
1360 layout_store_->GetRegisteredDisplayLayout( | 1360 layout_store_->GetRegisteredDisplayLayout( |
1361 display::CreateDisplayIdList(*display_list)); | 1361 display::CreateDisplayIdList(*display_list)); |
1362 | 1362 |
1363 // Ignore if a user has a old format (should be extremely rare) | 1363 // Ignore if a user has a old format (should be extremely rare) |
1364 // and this will be replaced with DCHECK. | 1364 // and this will be replaced with DCHECK. |
(...skipping 16 matching lines...) Expand all Loading... |
1381 void DisplayManager::CreateMirrorWindowIfAny() { | 1381 void DisplayManager::CreateMirrorWindowIfAny() { |
1382 if (software_mirroring_display_list_.empty() || !delegate_) | 1382 if (software_mirroring_display_list_.empty() || !delegate_) |
1383 return; | 1383 return; |
1384 DisplayInfoList list; | 1384 DisplayInfoList list; |
1385 for (auto& display : software_mirroring_display_list_) | 1385 for (auto& display : software_mirroring_display_list_) |
1386 list.push_back(GetDisplayInfo(display.id())); | 1386 list.push_back(GetDisplayInfo(display.id())); |
1387 delegate_->CreateOrUpdateMirroringDisplay(list); | 1387 delegate_->CreateOrUpdateMirroringDisplay(list); |
1388 } | 1388 } |
1389 | 1389 |
1390 void DisplayManager::ApplyDisplayLayout(const display::DisplayLayout& layout, | 1390 void DisplayManager::ApplyDisplayLayout(const display::DisplayLayout& layout, |
1391 display::DisplayList* display_list, | 1391 display::Displays* display_list, |
1392 std::vector<int64_t>* updated_ids) { | 1392 std::vector<int64_t>* updated_ids) { |
1393 layout.ApplyToDisplayList(display_list, updated_ids, | 1393 layout.ApplyToDisplayList(display_list, updated_ids, |
1394 kMinimumOverlapForInvalidOffset); | 1394 kMinimumOverlapForInvalidOffset); |
1395 } | 1395 } |
1396 | 1396 |
1397 void DisplayManager::RunPendingTasksForTest() { | 1397 void DisplayManager::RunPendingTasksForTest() { |
1398 if (!software_mirroring_display_list_.empty()) | 1398 if (!software_mirroring_display_list_.empty()) |
1399 base::RunLoop().RunUntilIdle(); | 1399 base::RunLoop().RunUntilIdle(); |
1400 } | 1400 } |
1401 | 1401 |
1402 } // namespace ash | 1402 } // namespace ash |
OLD | NEW |