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

Side by Side Diff: cc/output/bsp_tree.cc

Issue 2258833002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 | « cc/layers/texture_layer.cc ('k') | cc/output/gl_renderer.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/output/bsp_tree.h" 5 #include "cc/output/bsp_tree.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "cc/base/container_util.h" 11 #include "cc/base/container_util.h"
12 #include "cc/output/bsp_compare_result.h" 12 #include "cc/output/bsp_compare_result.h"
13 #include "cc/quads/draw_polygon.h" 13 #include "cc/quads/draw_polygon.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 BspNode::BspNode(std::unique_ptr<DrawPolygon> data) 17 BspNode::BspNode(std::unique_ptr<DrawPolygon> data)
18 : node_data(std::move(data)) {} 18 : node_data(std::move(data)) {}
19 19
20 BspNode::~BspNode() { 20 BspNode::~BspNode() {
21 } 21 }
22 22
23 BspTree::BspTree(std::deque<std::unique_ptr<DrawPolygon>>* list) { 23 BspTree::BspTree(std::deque<std::unique_ptr<DrawPolygon>>* list) {
24 if (list->size() == 0) 24 if (list->size() == 0)
25 return; 25 return;
26 26
27 root_ = base::WrapUnique(new BspNode(PopFront(list))); 27 root_ = base::MakeUnique<BspNode>(PopFront(list));
28 BuildTree(root_.get(), list); 28 BuildTree(root_.get(), list);
29 } 29 }
30 30
31 // The idea behind using a deque for BuildTree's input is that we want to be 31 // The idea behind using a deque for BuildTree's input is that we want to be
32 // able to place polygons that we've decided aren't splitting plane candidates 32 // able to place polygons that we've decided aren't splitting plane candidates
33 // at the back of the queue while moving the candidate splitting planes to the 33 // at the back of the queue while moving the candidate splitting planes to the
34 // front when the heuristic decides that they're a better choice. This way we 34 // front when the heuristic decides that they're a better choice. This way we
35 // can always simply just take from the front of the deque for our node's 35 // can always simply just take from the front of the deque for our node's
36 // data. 36 // data.
37 void BspTree::BuildTree( 37 void BspTree::BuildTree(
(...skipping 22 matching lines...) Expand all
60 } else { 60 } else {
61 if (new_front) 61 if (new_front)
62 front_list.push_back(std::move(new_front)); 62 front_list.push_back(std::move(new_front));
63 if (new_back) 63 if (new_back)
64 back_list.push_back(std::move(new_back)); 64 back_list.push_back(std::move(new_back));
65 } 65 }
66 } 66 }
67 67
68 // Build the back subtree using the front of the back_list as our splitter. 68 // Build the back subtree using the front of the back_list as our splitter.
69 if (back_list.size() > 0) { 69 if (back_list.size() > 0) {
70 node->back_child = base::WrapUnique(new BspNode(PopFront(&back_list))); 70 node->back_child = base::MakeUnique<BspNode>(PopFront(&back_list));
71 BuildTree(node->back_child.get(), &back_list); 71 BuildTree(node->back_child.get(), &back_list);
72 } 72 }
73 73
74 // Build the front subtree using the front of the front_list as our splitter. 74 // Build the front subtree using the front of the front_list as our splitter.
75 if (front_list.size() > 0) { 75 if (front_list.size() > 0) {
76 node->front_child = base::WrapUnique(new BspNode(PopFront(&front_list))); 76 node->front_child = base::MakeUnique<BspNode>(PopFront(&front_list));
77 BuildTree(node->front_child.get(), &front_list); 77 BuildTree(node->front_child.get(), &front_list);
78 } 78 }
79 } 79 }
80 80
81 // The base comparer with 0,0,0 as camera position facing forward 81 // The base comparer with 0,0,0 as camera position facing forward
82 BspCompareResult BspTree::GetCameraPositionRelative(const DrawPolygon& node) { 82 BspCompareResult BspTree::GetCameraPositionRelative(const DrawPolygon& node) {
83 if (node.normal().z() > 0.0f) { 83 if (node.normal().z() > 0.0f) {
84 return BSP_FRONT; 84 return BSP_FRONT;
85 } 85 }
86 return BSP_BACK; 86 return BSP_BACK;
87 } 87 }
88 88
89 BspTree::~BspTree() { 89 BspTree::~BspTree() {
90 } 90 }
91 91
92 } // namespace cc 92 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698