| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |