| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "ui/display/display.h" | 12 #include "ui/display/display.h" |
| 13 #include "ui/display/display_switches.h" | 13 #include "ui/display/display_switches.h" |
| 14 #include "ui/display/manager/display_layout_store.h" | 14 #include "ui/display/manager/display_layout_store.h" |
| 15 #include "ui/display/manager/display_manager_utilities.h" | 15 #include "ui/display/manager/display_manager_utilities.h" |
| 16 #include "ui/display/types/display_constants.h" |
| 16 | 17 |
| 17 namespace display { | 18 namespace display { |
| 18 | 19 |
| 19 DisplayLayoutStore::DisplayLayoutStore() | 20 DisplayLayoutStore::DisplayLayoutStore() |
| 20 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { | 21 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { |
| 21 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 22 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 22 if (command_line->HasSwitch(switches::kSecondaryDisplayLayout)) { | 23 if (command_line->HasSwitch(switches::kSecondaryDisplayLayout)) { |
| 23 std::string value = | 24 std::string value = |
| 24 command_line->GetSwitchValueASCII(switches::kSecondaryDisplayLayout); | 25 command_line->GetSwitchValueASCII(switches::kSecondaryDisplayLayout); |
| 25 char layout; | 26 char layout; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 55 if (list.size() == 2 && layout->placement_list.size() > 1) | 56 if (list.size() == 2 && layout->placement_list.size() > 1) |
| 56 return; | 57 return; |
| 57 | 58 |
| 58 // Do not overwrite the valid data with old invalid date. | 59 // Do not overwrite the valid data with old invalid date. |
| 59 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) | 60 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) |
| 60 return; | 61 return; |
| 61 | 62 |
| 62 // Old data may not have the display_id/parent_display_id. | 63 // Old data may not have the display_id/parent_display_id. |
| 63 // Guess these values based on the saved primary_id. | 64 // Guess these values based on the saved primary_id. |
| 64 if (layout->placement_list.size() >= 1 && | 65 if (layout->placement_list.size() >= 1 && |
| 65 layout->placement_list[0].display_id == | 66 layout->placement_list[0].display_id == display::kInvalidDisplayId) { |
| 66 display::Display::kInvalidDisplayID) { | |
| 67 if (layout->primary_id == list[1]) { | 67 if (layout->primary_id == list[1]) { |
| 68 layout->placement_list[0].display_id = list[0]; | 68 layout->placement_list[0].display_id = list[0]; |
| 69 layout->placement_list[0].parent_display_id = list[1]; | 69 layout->placement_list[0].parent_display_id = list[1]; |
| 70 } else { | 70 } else { |
| 71 layout->placement_list[0].display_id = list[1]; | 71 layout->placement_list[0].display_id = list[1]; |
| 72 layout->placement_list[0].parent_display_id = list[0]; | 72 layout->placement_list[0].parent_display_id = list[0]; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 DCHECK(display::DisplayLayout::Validate(list, *layout.get())) | 75 DCHECK(display::DisplayLayout::Validate(list, *layout.get())) |
| 76 << "ids=" << DisplayIdListToString(list) | 76 << "ids=" << DisplayIdListToString(list) |
| 77 << ", layout=" << layout->ToString(); | 77 << ", layout=" << layout->ToString(); |
| 78 layouts_[list] = std::move(layout); | 78 layouts_[list] = std::move(layout); |
| 79 } | 79 } |
| 80 | 80 |
| 81 const display::DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout( | 81 const display::DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout( |
| 82 const display::DisplayIdList& list) { | 82 const display::DisplayIdList& list) { |
| 83 DCHECK_NE(1u, list.size()); | 83 DCHECK_NE(1u, list.size()); |
| 84 const auto iter = layouts_.find(list); | 84 const auto iter = layouts_.find(list); |
| 85 const display::DisplayLayout* layout = iter != layouts_.end() | 85 const display::DisplayLayout* layout = iter != layouts_.end() |
| 86 ? iter->second.get() | 86 ? iter->second.get() |
| 87 : CreateDefaultDisplayLayout(list); | 87 : CreateDefaultDisplayLayout(list); |
| 88 DCHECK(display::DisplayLayout::Validate(list, *layout)) << layout->ToString(); | 88 DCHECK(display::DisplayLayout::Validate(list, *layout)) << layout->ToString(); |
| 89 DCHECK_NE(layout->primary_id, display::Display::kInvalidDisplayID); | 89 DCHECK_NE(layout->primary_id, display::kInvalidDisplayId); |
| 90 return *layout; | 90 return *layout; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void DisplayLayoutStore::UpdateMultiDisplayState( | 93 void DisplayLayoutStore::UpdateMultiDisplayState( |
| 94 const display::DisplayIdList& list, | 94 const display::DisplayIdList& list, |
| 95 bool mirrored, | 95 bool mirrored, |
| 96 bool default_unified) { | 96 bool default_unified) { |
| 97 DCHECK(layouts_.find(list) != layouts_.end()); | 97 DCHECK(layouts_.find(list) != layouts_.end()); |
| 98 if (layouts_.find(list) == layouts_.end()) | 98 if (layouts_.find(list) == layouts_.end()) |
| 99 CreateDefaultDisplayLayout(list); | 99 CreateDefaultDisplayLayout(list); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 113 placement.display_id = list[i + 1]; | 113 placement.display_id = list[i + 1]; |
| 114 placement.parent_display_id = list[i]; | 114 placement.parent_display_id = list[i]; |
| 115 layout->placement_list.push_back(placement); | 115 layout->placement_list.push_back(placement); |
| 116 } | 116 } |
| 117 layouts_[list] = std::move(layout); | 117 layouts_[list] = std::move(layout); |
| 118 auto iter = layouts_.find(list); | 118 auto iter = layouts_.find(list); |
| 119 return iter->second.get(); | 119 return iter->second.get(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace display | 122 } // namespace display |
| OLD | NEW |