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

Side by Side Diff: ash/display/display_layout_builder.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.cc ('k') | ash/display/display_layout_builder_unittest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_layout_builder.h" 5 #include "ash/display/display_layout_builder.h"
6 6
7 #include <algorithm>
8
7 namespace ash { 9 namespace ash {
8 10
9 DisplayLayoutBuilder::DisplayLayoutBuilder(const DisplayLayout& layout) 11 DisplayLayoutBuilder::DisplayLayoutBuilder(const DisplayLayout& layout)
10 : layout_(layout.Copy()) {} 12 : layout_(layout.Copy()) {}
11 13
12 DisplayLayoutBuilder::DisplayLayoutBuilder(int64_t primary_id) 14 DisplayLayoutBuilder::DisplayLayoutBuilder(int64_t primary_id)
13 : layout_(new DisplayLayout) { 15 : layout_(new DisplayLayout) {
14 layout_->primary_id = primary_id; 16 layout_->primary_id = primary_id;
15 } 17 }
16 18
(...skipping 13 matching lines...) Expand all
30 DisplayLayoutBuilder& DisplayLayoutBuilder::ClearPlacements() { 32 DisplayLayoutBuilder& DisplayLayoutBuilder::ClearPlacements() {
31 layout_->placement_list.clear(); 33 layout_->placement_list.clear();
32 return *this; 34 return *this;
33 } 35 }
34 36
35 DisplayLayoutBuilder& DisplayLayoutBuilder::AddDisplayPlacement( 37 DisplayLayoutBuilder& DisplayLayoutBuilder::AddDisplayPlacement(
36 int64_t display_id, 38 int64_t display_id,
37 int64_t parent_display_id, 39 int64_t parent_display_id,
38 DisplayPlacement::Position position, 40 DisplayPlacement::Position position,
39 int offset) { 41 int offset) {
40 scoped_ptr<DisplayPlacement> placement(new DisplayPlacement); 42 DisplayPlacement placement;
41 placement->position = position; 43 placement.position = position;
42 placement->offset = offset; 44 placement.offset = offset;
43 placement->display_id = display_id; 45 placement.display_id = display_id;
44 placement->parent_display_id = parent_display_id; 46 placement.parent_display_id = parent_display_id;
45 layout_->placement_list.push_back(std::move(placement)); 47 layout_->placement_list.push_back(placement);
46 return *this; 48 return *this;
47 } 49 }
48 50
49 DisplayLayoutBuilder& DisplayLayoutBuilder::SetSecondaryPlacement( 51 DisplayLayoutBuilder& DisplayLayoutBuilder::SetSecondaryPlacement(
50 int64_t secondary_id, 52 int64_t secondary_id,
51 DisplayPlacement::Position position, 53 DisplayPlacement::Position position,
52 int offset) { 54 int offset) {
53 layout_->placement_list.clear(); 55 layout_->placement_list.clear();
54 AddDisplayPlacement(secondary_id, layout_->primary_id, position, offset); 56 AddDisplayPlacement(secondary_id, layout_->primary_id, position, offset);
55 return *this; 57 return *this;
56 } 58 }
57 59
58 scoped_ptr<DisplayLayout> DisplayLayoutBuilder::Build() { 60 scoped_ptr<DisplayLayout> DisplayLayoutBuilder::Build() {
59 std::sort(layout_->placement_list.begin(), layout_->placement_list.end(), 61 std::sort(layout_->placement_list.begin(), layout_->placement_list.end(),
60 [](const DisplayPlacement* a, const DisplayPlacement* b) { 62 [](const DisplayPlacement& a, const DisplayPlacement& b) {
61 return a->display_id < b->display_id; 63 return a.display_id < b.display_id;
62 }); 64 });
63 return std::move(layout_); 65 return std::move(layout_);
64 } 66 }
65 67
66 } // namespace ash 68 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_layout.cc ('k') | ash/display/display_layout_builder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698