| 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 | 16 |
| 16 namespace display { | 17 namespace display { |
| 17 | 18 |
| 18 namespace { | |
| 19 | |
| 20 // TODO(kylechar): Move these to ui/display/chromeos/display_util.cc/h. | |
| 21 bool CompareDisplayIds(int64_t id1, int64_t id2) { | |
| 22 DCHECK_NE(id1, id2); | |
| 23 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID | |
| 24 // in edid_parser.cc. | |
| 25 int index_1 = id1 & 0xFF; | |
| 26 int index_2 = id2 & 0xFF; | |
| 27 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; | |
| 28 return Display::IsInternalDisplayId(id1) || | |
| 29 (index_1 < index_2 && !Display::IsInternalDisplayId(id2)); | |
| 30 } | |
| 31 | |
| 32 std::string DisplayIdListToString(const DisplayIdList& list) { | |
| 33 std::stringstream s; | |
| 34 const char* sep = ""; | |
| 35 for (int64_t id : list) { | |
| 36 s << sep << id; | |
| 37 sep = ","; | |
| 38 } | |
| 39 return s.str(); | |
| 40 } | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 DisplayLayoutStore::DisplayLayoutStore() | 19 DisplayLayoutStore::DisplayLayoutStore() |
| 45 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { | 20 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { |
| 46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 21 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 47 if (command_line->HasSwitch(switches::kSecondaryDisplayLayout)) { | 22 if (command_line->HasSwitch(switches::kSecondaryDisplayLayout)) { |
| 48 std::string value = | 23 std::string value = |
| 49 command_line->GetSwitchValueASCII(switches::kSecondaryDisplayLayout); | 24 command_line->GetSwitchValueASCII(switches::kSecondaryDisplayLayout); |
| 50 char layout; | 25 char layout; |
| 51 int offset = 0; | 26 int offset = 0; |
| 52 if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { | 27 if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { |
| 53 if (layout == 't') | 28 if (layout == 't') |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 placement.display_id = list[i + 1]; | 113 placement.display_id = list[i + 1]; |
| 139 placement.parent_display_id = list[i]; | 114 placement.parent_display_id = list[i]; |
| 140 layout->placement_list.push_back(placement); | 115 layout->placement_list.push_back(placement); |
| 141 } | 116 } |
| 142 layouts_[list] = std::move(layout); | 117 layouts_[list] = std::move(layout); |
| 143 auto iter = layouts_.find(list); | 118 auto iter = layouts_.find(list); |
| 144 return iter->second.get(); | 119 return iter->second.get(); |
| 145 } | 120 } |
| 146 | 121 |
| 147 } // namespace display | 122 } // namespace display |
| OLD | NEW |