7
7
#include < vector>
8
8
9
9
#include " base/memory/scoped_ptr.h"
10
- #include " cc/base/scoped_ptr_deque .h"
10
+ #include " cc/base/container_util .h"
11
11
#include " cc/base/scoped_ptr_vector.h"
12
12
#include " cc/output/bsp_compare_result.h"
13
13
#include " cc/quads/draw_polygon.h"
@@ -20,11 +20,11 @@ BspNode::BspNode(scoped_ptr<DrawPolygon> data) : node_data(data.Pass()) {
20
20
BspNode::~BspNode () {
21
21
}
22
22
23
- BspTree::BspTree (ScopedPtrDeque< DrawPolygon>* list) {
23
+ BspTree::BspTree (std::deque<scoped_ptr< DrawPolygon> >* list) {
24
24
if (list->size () == 0 )
25
25
return ;
26
26
27
- root_ = make_scoped_ptr (new BspNode (list-> take_front ( )));
27
+ root_ = make_scoped_ptr (new BspNode (PopFront (list )));
28
28
BuildTree (root_.get (), list);
29
29
}
30
30
@@ -35,14 +35,14 @@ BspTree::BspTree(ScopedPtrDeque<DrawPolygon>* list) {
35
35
// can always simply just take from the front of the deque for our node's
36
36
// data.
37
37
void BspTree::BuildTree (BspNode* node,
38
- ScopedPtrDeque< DrawPolygon>* polygon_list) {
39
- ScopedPtrDeque< DrawPolygon> front_list;
40
- ScopedPtrDeque< DrawPolygon> back_list;
38
+ std::deque<scoped_ptr< DrawPolygon> >* polygon_list) {
39
+ std::deque<scoped_ptr< DrawPolygon> > front_list;
40
+ std::deque<scoped_ptr< DrawPolygon> > back_list;
41
41
42
42
// We take in a list of polygons at this level of the tree, and have to
43
43
// find a splitting plane, then classify polygons as either in front of
44
44
// or behind that splitting plane.
45
- while (polygon_list->size () > 0 ) {
45
+ while (! polygon_list->empty () ) {
46
46
// Is this particular polygon in front of or behind our splitting polygon.
47
47
BspCompareResult comparer_result =
48
48
GetNodePositionRelative (*polygon_list->front (), *(node->node_data ));
@@ -52,18 +52,18 @@ void BspTree::BuildTree(BspNode* node,
52
52
// or front of the list.
53
53
switch (comparer_result) {
54
54
case BSP_FRONT:
55
- front_list.push_back (polygon_list-> take_front (). Pass ( ));
55
+ front_list.push_back (PopFront (polygon_list ));
56
56
break ;
57
57
case BSP_BACK:
58
- back_list.push_back (polygon_list-> take_front (). Pass ( ));
58
+ back_list.push_back (PopFront (polygon_list ));
59
59
break ;
60
60
case BSP_SPLIT:
61
61
{
62
62
scoped_ptr<DrawPolygon> polygon;
63
63
scoped_ptr<DrawPolygon> new_front;
64
64
scoped_ptr<DrawPolygon> new_back;
65
65
// Time to split this geometry, *it needs to be split by node_data.
66
- polygon = polygon_list-> take_front ( );
66
+ polygon = PopFront (polygon_list );
67
67
bool split_result =
68
68
polygon->Split (*(node->node_data ), &new_front, &new_back);
69
69
DCHECK (split_result);
@@ -75,10 +75,10 @@ void BspTree::BuildTree(BspNode* node,
75
75
break ;
76
76
}
77
77
case BSP_COPLANAR_FRONT:
78
- node->coplanars_front .push_back (polygon_list-> take_front ( ));
78
+ node->coplanars_front .push_back (PopFront (polygon_list ));
79
79
break ;
80
80
case BSP_COPLANAR_BACK:
81
- node->coplanars_back .push_back (polygon_list-> take_front ( ));
81
+ node->coplanars_back .push_back (PopFront (polygon_list ));
82
82
break ;
83
83
default :
84
84
NOTREACHED ();
@@ -88,14 +88,13 @@ void BspTree::BuildTree(BspNode* node,
88
88
89
89
// Build the back subtree using the front of the back_list as our splitter.
90
90
if (back_list.size () > 0 ) {
91
- node->back_child = make_scoped_ptr (new BspNode (back_list. take_front ( )));
91
+ node->back_child = make_scoped_ptr (new BspNode (PopFront (&back_list )));
92
92
BuildTree (node->back_child .get (), &back_list);
93
93
}
94
94
95
95
// Build the front subtree using the front of the front_list as our splitter.
96
96
if (front_list.size () > 0 ) {
97
- node->front_child =
98
- scoped_ptr<BspNode>(new BspNode (front_list.take_front ()));
97
+ node->front_child = make_scoped_ptr (new BspNode (PopFront (&front_list)));
99
98
BuildTree (node->front_child .get (), &front_list);
100
99
}
101
100
}
0 commit comments