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

Side by Side Diff: ash/display/display_layout_store.cc

Issue 1819533002: Convert ScopedVector<DisplayPlacement> to std::vector<DisplayPlacement> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@jsonrefactor
Patch Set: Created 4 years, 9 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 | « ash/display/display_layout_builder_unittest.cc ('k') | ash/display/display_manager.cc » ('j') | 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/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_layout_store.h" 8 #include "ash/display/display_layout_store.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/display/display_util.h" 10 #include "ash/display/display_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const DisplayIdList& list, 51 const DisplayIdList& list,
52 scoped_ptr<DisplayLayout> layout) { 52 scoped_ptr<DisplayLayout> layout) {
53 53
54 // Do not overwrite the valid data with old invalid date. 54 // Do not overwrite the valid data with old invalid date.
55 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) 55 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1]))
56 return; 56 return;
57 57
58 // Old data may not have the display_id/parent_display_id. 58 // Old data may not have the display_id/parent_display_id.
59 // Guess these values based on the saved primary_id. 59 // Guess these values based on the saved primary_id.
60 if (layout->placement_list.size() >= 1 && 60 if (layout->placement_list.size() >= 1 &&
61 layout->placement_list[0]->display_id == 61 layout->placement_list[0].display_id == gfx::Display::kInvalidDisplayID) {
62 gfx::Display::kInvalidDisplayID) {
63 if (layout->primary_id == list[1]) { 62 if (layout->primary_id == list[1]) {
64 layout->placement_list[0]->display_id = list[0]; 63 layout->placement_list[0].display_id = list[0];
65 layout->placement_list[0]->parent_display_id = list[1]; 64 layout->placement_list[0].parent_display_id = list[1];
66 } else { 65 } else {
67 layout->placement_list[0]->display_id = list[1]; 66 layout->placement_list[0].display_id = list[1];
68 layout->placement_list[0]->parent_display_id = list[0]; 67 layout->placement_list[0].parent_display_id = list[0];
69 } 68 }
70 } 69 }
71 DCHECK(DisplayLayout::Validate(list, *layout.get())) << layout->ToString(); 70 DCHECK(DisplayLayout::Validate(list, *layout.get())) << layout->ToString();
72 layouts_[list] = std::move(layout); 71 layouts_[list] = std::move(layout);
73 } 72 }
74 73
75 const DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout( 74 const DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout(
76 const DisplayIdList& list) { 75 const DisplayIdList& list) {
77 DCHECK_NE(1u, list.size()); 76 DCHECK_NE(1u, list.size());
78 const auto iter = layouts_.find(list); 77 const auto iter = layouts_.find(list);
(...skipping 16 matching lines...) Expand all
95 layouts_[list]->default_unified = default_unified; 94 layouts_[list]->default_unified = default_unified;
96 } 95 }
97 96
98 DisplayLayout* DisplayLayoutStore::CreateDefaultDisplayLayout( 97 DisplayLayout* DisplayLayoutStore::CreateDefaultDisplayLayout(
99 const DisplayIdList& list) { 98 const DisplayIdList& list) {
100 scoped_ptr<DisplayLayout> layout(new DisplayLayout); 99 scoped_ptr<DisplayLayout> layout(new DisplayLayout);
101 // The first display is the primary by default. 100 // The first display is the primary by default.
102 layout->primary_id = list[0]; 101 layout->primary_id = list[0];
103 layout->placement_list.clear(); 102 layout->placement_list.clear();
104 for (size_t i = 0; i < list.size() - 1; i++) { 103 for (size_t i = 0; i < list.size() - 1; i++) {
105 scoped_ptr<DisplayPlacement> placement( 104 DisplayPlacement placement(default_display_placement_);
106 new DisplayPlacement(default_display_placement_)); 105 placement.display_id = list[i + 1];
107 placement->display_id = list[i + 1]; 106 placement.parent_display_id = list[i];
108 placement->parent_display_id = list[i]; 107 layout->placement_list.push_back(placement);
109 layout->placement_list.push_back(std::move(placement));
110 } 108 }
111 layouts_[list] = std::move(layout); 109 layouts_[list] = std::move(layout);
112 auto iter = layouts_.find(list); 110 auto iter = layouts_.find(list);
113 return iter->second.get(); 111 return iter->second.get();
114 } 112 }
115 113
116 } // namespace ash 114 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_layout_builder_unittest.cc ('k') | ash/display/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698