Skip to content

Commit 36d6abf

Browse files
vmpstrCommit bot
authored and
Commit bot
committed
cc: Remove ScopedPtrDeque.
This patch removes ScopedPtrDeque and replaces it with a deque of scoped_ptrs. Note that this also adds a helper container_util file that contains TakeBack and TakeFront helpers. R=danakj CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1441613002 Cr-Commit-Position: refs/heads/master@{#359724}
1 parent 78bf53f commit 36d6abf

18 files changed

+141
-235
lines changed

cc/base/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source_set("base") {
77

88
sources = [
99
"completion_event.h",
10+
"container_util.h",
1011
"delayed_unique_notifier.cc",
1112
"delayed_unique_notifier.h",
1213
"histograms.cc",
@@ -27,7 +28,6 @@ source_set("base") {
2728
"rtree.cc",
2829
"rtree.h",
2930
"scoped_ptr_algorithm.h",
30-
"scoped_ptr_deque.h",
3131
"scoped_ptr_vector.h",
3232
"simple_enclosed_region.cc",
3333
"simple_enclosed_region.h",

cc/base/container_util.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2015 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef CC_BASE_CONTAINER_UTIL_H_
6+
#define CC_BASE_CONTAINER_UTIL_H_
7+
8+
#include "base/memory/scoped_ptr.h"
9+
10+
namespace cc {
11+
12+
// Removes the front element from the container and returns it. Note that this
13+
// currently only works with types that implement Pass().
14+
// TODO(vmpstr): Use std::move instead of Pass when allowed.
15+
template <typename Container>
16+
typename Container::value_type PopFront(Container* container) {
17+
typename Container::value_type element = container->front().Pass();
18+
container->pop_front();
19+
return element;
20+
}
21+
22+
// Removes the back element from the container and returns it. Note that this
23+
// currently only works with types that implement Pass().
24+
// TODO(vmpstr): Use std::move instead of Pass when allowed.
25+
template <typename Container>
26+
typename Container::value_type PopBack(Container* container) {
27+
typename Container::value_type element = container->back().Pass();
28+
container->pop_back();
29+
return element;
30+
}
31+
32+
} // namespace cc
33+
34+
#endif // CC_BASE_CONTAINER_UTIL_H_

cc/base/scoped_ptr_deque.h

-137
This file was deleted.

cc/cc.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
'animation/transform_operations.cc',
7777
'animation/transform_operations.h',
7878
'base/completion_event.h',
79+
'base/container_util.h',
7980
'base/delayed_unique_notifier.cc',
8081
'base/delayed_unique_notifier.h',
8182
'base/histograms.cc',
@@ -96,7 +97,6 @@
9697
'base/rtree.cc',
9798
'base/rtree.h',
9899
'base/scoped_ptr_algorithm.h',
99-
'base/scoped_ptr_deque.h',
100100
'base/scoped_ptr_vector.h',
101101
'base/simple_enclosed_region.cc',
102102
'base/simple_enclosed_region.h',

cc/output/bsp_tree.cc

+14-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <vector>
88

99
#include "base/memory/scoped_ptr.h"
10-
#include "cc/base/scoped_ptr_deque.h"
10+
#include "cc/base/container_util.h"
1111
#include "cc/base/scoped_ptr_vector.h"
1212
#include "cc/output/bsp_compare_result.h"
1313
#include "cc/quads/draw_polygon.h"
@@ -20,11 +20,11 @@ BspNode::BspNode(scoped_ptr<DrawPolygon> data) : node_data(data.Pass()) {
2020
BspNode::~BspNode() {
2121
}
2222

23-
BspTree::BspTree(ScopedPtrDeque<DrawPolygon>* list) {
23+
BspTree::BspTree(std::deque<scoped_ptr<DrawPolygon>>* list) {
2424
if (list->size() == 0)
2525
return;
2626

27-
root_ = make_scoped_ptr(new BspNode(list->take_front()));
27+
root_ = make_scoped_ptr(new BspNode(PopFront(list)));
2828
BuildTree(root_.get(), list);
2929
}
3030

@@ -35,14 +35,14 @@ BspTree::BspTree(ScopedPtrDeque<DrawPolygon>* list) {
3535
// can always simply just take from the front of the deque for our node's
3636
// data.
3737
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;
4141

4242
// We take in a list of polygons at this level of the tree, and have to
4343
// find a splitting plane, then classify polygons as either in front of
4444
// or behind that splitting plane.
45-
while (polygon_list->size() > 0) {
45+
while (!polygon_list->empty()) {
4646
// Is this particular polygon in front of or behind our splitting polygon.
4747
BspCompareResult comparer_result =
4848
GetNodePositionRelative(*polygon_list->front(), *(node->node_data));
@@ -52,18 +52,18 @@ void BspTree::BuildTree(BspNode* node,
5252
// or front of the list.
5353
switch (comparer_result) {
5454
case BSP_FRONT:
55-
front_list.push_back(polygon_list->take_front().Pass());
55+
front_list.push_back(PopFront(polygon_list));
5656
break;
5757
case BSP_BACK:
58-
back_list.push_back(polygon_list->take_front().Pass());
58+
back_list.push_back(PopFront(polygon_list));
5959
break;
6060
case BSP_SPLIT:
6161
{
6262
scoped_ptr<DrawPolygon> polygon;
6363
scoped_ptr<DrawPolygon> new_front;
6464
scoped_ptr<DrawPolygon> new_back;
6565
// Time to split this geometry, *it needs to be split by node_data.
66-
polygon = polygon_list->take_front();
66+
polygon = PopFront(polygon_list);
6767
bool split_result =
6868
polygon->Split(*(node->node_data), &new_front, &new_back);
6969
DCHECK(split_result);
@@ -75,10 +75,10 @@ void BspTree::BuildTree(BspNode* node,
7575
break;
7676
}
7777
case BSP_COPLANAR_FRONT:
78-
node->coplanars_front.push_back(polygon_list->take_front());
78+
node->coplanars_front.push_back(PopFront(polygon_list));
7979
break;
8080
case BSP_COPLANAR_BACK:
81-
node->coplanars_back.push_back(polygon_list->take_front());
81+
node->coplanars_back.push_back(PopFront(polygon_list));
8282
break;
8383
default:
8484
NOTREACHED();
@@ -88,14 +88,13 @@ void BspTree::BuildTree(BspNode* node,
8888

8989
// Build the back subtree using the front of the back_list as our splitter.
9090
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)));
9292
BuildTree(node->back_child.get(), &back_list);
9393
}
9494

9595
// Build the front subtree using the front of the front_list as our splitter.
9696
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)));
9998
BuildTree(node->front_child.get(), &front_list);
10099
}
101100
}

cc/output/bsp_tree.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#ifndef CC_OUTPUT_BSP_TREE_H_
66
#define CC_OUTPUT_BSP_TREE_H_
77

8+
#include <deque>
89
#include <vector>
910

1011
#include "base/memory/scoped_ptr.h"
11-
#include "cc/base/scoped_ptr_deque.h"
1212
#include "cc/base/scoped_ptr_vector.h"
1313
#include "cc/output/bsp_compare_result.h"
1414
#include "cc/quads/draw_polygon.h"
@@ -31,7 +31,7 @@ struct BspNode {
3131

3232
class CC_EXPORT BspTree {
3333
public:
34-
explicit BspTree(ScopedPtrDeque<DrawPolygon>* list);
34+
explicit BspTree(std::deque<scoped_ptr<DrawPolygon>>* list);
3535
scoped_ptr<BspNode>& root() { return root_; }
3636

3737
template <typename ActionHandlerType>
@@ -47,7 +47,7 @@ class CC_EXPORT BspTree {
4747
scoped_ptr<BspNode> root_;
4848

4949
void FromList(ScopedPtrVector<DrawPolygon>* list);
50-
void BuildTree(BspNode* node, ScopedPtrDeque<DrawPolygon>* data);
50+
void BuildTree(BspNode* node, std::deque<scoped_ptr<DrawPolygon>>* data);
5151

5252
template <typename ActionHandlerType>
5353
void WalkInOrderAction(ActionHandlerType* action_handler,

0 commit comments

Comments
 (0)