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

Side by Side Diff: ui/gfx/display_layout_builder.cc

Issue 1813493002: COMPLETED PREVIEW Migrate to Display Placement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gfxmove
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 | « ui/gfx/display_layout_builder.h ('k') | ui/gfx/gfx.gyp » ('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 "ui/gfx/display_layout_builder.h" 5 #include "ui/gfx/display_layout_builder.h"
6 6
7 namespace gfx { 7 namespace gfx {
8 8
9 DisplayLayoutBuilder::DisplayLayoutBuilder(const DisplayLayout& layout) 9 DisplayLayoutBuilder::DisplayLayoutBuilder(const DisplayLayout& layout)
10 : layout_(layout.Copy()) {} 10 : layout_(layout.Copy()) {}
(...skipping 19 matching lines...) Expand all
30 DisplayLayoutBuilder& DisplayLayoutBuilder::ClearPlacements() { 30 DisplayLayoutBuilder& DisplayLayoutBuilder::ClearPlacements() {
31 layout_->placement_list.clear(); 31 layout_->placement_list.clear();
32 return *this; 32 return *this;
33 } 33 }
34 34
35 DisplayLayoutBuilder& DisplayLayoutBuilder::AddDisplayPlacement( 35 DisplayLayoutBuilder& DisplayLayoutBuilder::AddDisplayPlacement(
36 int64_t display_id, 36 int64_t display_id,
37 int64_t parent_display_id, 37 int64_t parent_display_id,
38 DisplayPlacement::Position position, 38 DisplayPlacement::Position position,
39 int offset) { 39 int offset) {
40 scoped_ptr<DisplayPlacement> placement(new DisplayPlacement); 40 DisplayPlacement placement;
41 placement->position = position; 41 placement.position = position;
42 placement->offset = offset; 42 placement.offset = offset;
43 placement->display_id = display_id; 43 placement.display_id = display_id;
44 placement->parent_display_id = parent_display_id; 44 placement.parent_display_id = parent_display_id;
45 layout_->placement_list.push_back(std::move(placement)); 45 AddDisplayPlacement(placement);
46 return *this; 46 return *this;
47 } 47 }
48 48
49 DisplayLayoutBuilder& DisplayLayoutBuilder::AddDisplayPlacement(
50 const DisplayPlacement& placement) {
51 layout_->placement_list.push_back(
52 make_scoped_ptr(new DisplayPlacement(placement)));
53 return *this;
54 }
55
49 DisplayLayoutBuilder& DisplayLayoutBuilder::SetSecondaryPlacement( 56 DisplayLayoutBuilder& DisplayLayoutBuilder::SetSecondaryPlacement(
50 int64_t secondary_id, 57 int64_t secondary_id,
51 DisplayPlacement::Position position, 58 DisplayPlacement::Position position,
52 int offset) { 59 int offset) {
53 layout_->placement_list.clear(); 60 layout_->placement_list.clear();
54 AddDisplayPlacement(secondary_id, layout_->primary_id, position, offset); 61 AddDisplayPlacement(secondary_id, layout_->primary_id, position, offset);
55 return *this; 62 return *this;
56 } 63 }
57 64
58 scoped_ptr<DisplayLayout> DisplayLayoutBuilder::Build() { 65 scoped_ptr<DisplayLayout> DisplayLayoutBuilder::Build() {
59 std::sort(layout_->placement_list.begin(), layout_->placement_list.end(), 66 std::sort(layout_->placement_list.begin(), layout_->placement_list.end(),
60 [](const DisplayPlacement* a, const DisplayPlacement* b) { 67 [](const DisplayPlacement* a, const DisplayPlacement* b) {
61 return a->display_id < b->display_id; 68 return a->display_id < b->display_id;
62 }); 69 });
63 return std::move(layout_); 70 return std::move(layout_);
64 } 71 }
65 72
66 } // namespace gfx 73 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/display_layout_builder.h ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698