Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: ui/display/manager/display_layout_store.cc

Issue 2223063003: Move DisplayLayoutStore from ash to ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase/add TODO. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/display/manager/display_layout_store.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/common/ash_switches.h" 7 #include <string>
8 #include "ash/display/display_layout_store.h" 8 #include <utility>
9 #include "ash/display/display_manager.h" 9
10 #include "ash/display/display_util.h"
11 #include "ash/shell.h"
12 #include "base/command_line.h" 10 #include "base/command_line.h"
13 #include "base/logging.h" 11 #include "base/logging.h"
14 #include "ui/display/display.h" 12 #include "ui/display/display.h"
13 #include "ui/display/display_switches.h"
14 #include "ui/display/manager/display_layout_store.h"
15 15
16 namespace ash { 16 namespace display {
17
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
17 43
18 DisplayLayoutStore::DisplayLayoutStore() 44 DisplayLayoutStore::DisplayLayoutStore()
19 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { 45 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) {
20 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
21 if (command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) { 47 if (command_line->HasSwitch(switches::kSecondaryDisplayLayout)) {
22 std::string value = 48 std::string value =
23 command_line->GetSwitchValueASCII(switches::kAshSecondaryDisplayLayout); 49 command_line->GetSwitchValueASCII(switches::kSecondaryDisplayLayout);
24 char layout; 50 char layout;
25 int offset = 0; 51 int offset = 0;
26 if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { 52 if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) {
27 if (layout == 't') 53 if (layout == 't')
28 default_display_placement_.position = display::DisplayPlacement::TOP; 54 default_display_placement_.position = display::DisplayPlacement::TOP;
29 else if (layout == 'b') 55 else if (layout == 'b')
30 default_display_placement_.position = display::DisplayPlacement::BOTTOM; 56 default_display_placement_.position = display::DisplayPlacement::BOTTOM;
31 else if (layout == 'r') 57 else if (layout == 'r')
32 default_display_placement_.position = display::DisplayPlacement::RIGHT; 58 default_display_placement_.position = display::DisplayPlacement::RIGHT;
33 else if (layout == 'l') 59 else if (layout == 'l')
34 default_display_placement_.position = display::DisplayPlacement::LEFT; 60 default_display_placement_.position = display::DisplayPlacement::LEFT;
35 default_display_placement_.offset = offset; 61 default_display_placement_.offset = offset;
36 } 62 }
37 } 63 }
38 } 64 }
39 65
40 DisplayLayoutStore::~DisplayLayoutStore() {} 66 DisplayLayoutStore::~DisplayLayoutStore() {}
41 67
42 void DisplayLayoutStore::SetDefaultDisplayPlacement( 68 void DisplayLayoutStore::SetDefaultDisplayPlacement(
43 const display::DisplayPlacement& placement) { 69 const display::DisplayPlacement& placement) {
44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 70 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
45 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) 71 if (!command_line->HasSwitch(switches::kSecondaryDisplayLayout))
46 default_display_placement_ = placement; 72 default_display_placement_ = placement;
47 } 73 }
48 74
49 void DisplayLayoutStore::RegisterLayoutForDisplayIdList( 75 void DisplayLayoutStore::RegisterLayoutForDisplayIdList(
50 const display::DisplayIdList& list, 76 const display::DisplayIdList& list,
51 std::unique_ptr<display::DisplayLayout> layout) { 77 std::unique_ptr<display::DisplayLayout> layout) {
52 // m50/51 dev/beta channel may have bad layout data saved in local state. 78 // m50/51 dev/beta channel may have bad layout data saved in local state.
53 // TODO(oshima): Consider removing this after m53. 79 // TODO(oshima): Consider removing this after m53.
54 if (list.size() == 2 && layout->placement_list.size() > 1) 80 if (list.size() == 2 && layout->placement_list.size() > 1)
55 return; 81 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 display::DisplayPlacement placement(default_display_placement_); 137 display::DisplayPlacement placement(default_display_placement_);
112 placement.display_id = list[i + 1]; 138 placement.display_id = list[i + 1];
113 placement.parent_display_id = list[i]; 139 placement.parent_display_id = list[i];
114 layout->placement_list.push_back(placement); 140 layout->placement_list.push_back(placement);
115 } 141 }
116 layouts_[list] = std::move(layout); 142 layouts_[list] = std::move(layout);
117 auto iter = layouts_.find(list); 143 auto iter = layouts_.find(list);
118 return iter->second.get(); 144 return iter->second.get();
119 } 145 }
120 146
121 } // namespace ash 147 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/manager/display_layout_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698