diff options
-rw-r--r-- | cc/base/BUILD.gn | 2 | ||||
-rw-r--r-- | cc/base/container_util.h | 34 | ||||
-rw-r--r-- | cc/base/scoped_ptr_deque.h | 137 | ||||
-rw-r--r-- | cc/cc.gyp | 2 | ||||
-rw-r--r-- | cc/output/bsp_tree.cc | 29 | ||||
-rw-r--r-- | cc/output/bsp_tree.h | 6 | ||||
-rw-r--r-- | cc/output/bsp_tree_unittest.cc | 21 | ||||
-rw-r--r-- | cc/output/direct_renderer.cc | 11 | ||||
-rw-r--r-- | cc/output/direct_renderer.h | 3 | ||||
-rw-r--r-- | cc/output/gl_renderer.cc | 5 | ||||
-rw-r--r-- | cc/output/gl_renderer.h | 7 | ||||
-rw-r--r-- | cc/raster/one_copy_tile_task_worker_pool.cc | 47 | ||||
-rw-r--r-- | cc/raster/one_copy_tile_task_worker_pool.h | 4 | ||||
-rw-r--r-- | cc/raster/task_graph_runner_unittest.cc | 9 | ||||
-rw-r--r-- | cc/resources/resource_pool.cc | 36 | ||||
-rw-r--r-- | cc/resources/resource_pool.h | 3 | ||||
-rw-r--r-- | cc/resources/resource_provider_unittest.cc | 16 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_perftest.cc | 4 |
18 files changed, 141 insertions, 235 deletions
diff --git a/cc/base/BUILD.gn b/cc/base/BUILD.gn index c6dc603..6898aa1 100644 --- a/cc/base/BUILD.gn +++ b/cc/base/BUILD.gn @@ -7,6 +7,7 @@ source_set("base") { sources = [ "completion_event.h", + "container_util.h", "delayed_unique_notifier.cc", "delayed_unique_notifier.h", "histograms.cc", @@ -27,7 +28,6 @@ source_set("base") { "rtree.cc", "rtree.h", "scoped_ptr_algorithm.h", - "scoped_ptr_deque.h", "scoped_ptr_vector.h", "simple_enclosed_region.cc", "simple_enclosed_region.h", diff --git a/cc/base/container_util.h b/cc/base/container_util.h new file mode 100644 index 0000000..2f0da6c --- /dev/null +++ b/cc/base/container_util.h @@ -0,0 +1,34 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_BASE_CONTAINER_UTIL_H_ +#define CC_BASE_CONTAINER_UTIL_H_ + +#include "base/memory/scoped_ptr.h" + +namespace cc { + +// Removes the front element from the container and returns it. Note that this +// currently only works with types that implement Pass(). +// TODO(vmpstr): Use std::move instead of Pass when allowed. +template <typename Container> +typename Container::value_type PopFront(Container* container) { + typename Container::value_type element = container->front().Pass(); + container->pop_front(); + return element; +} + +// Removes the back element from the container and returns it. Note that this +// currently only works with types that implement Pass(). +// TODO(vmpstr): Use std::move instead of Pass when allowed. +template <typename Container> +typename Container::value_type PopBack(Container* container) { + typename Container::value_type element = container->back().Pass(); + container->pop_back(); + return element; +} + +} // namespace cc + +#endif // CC_BASE_CONTAINER_UTIL_H_ diff --git a/cc/base/scoped_ptr_deque.h b/cc/base/scoped_ptr_deque.h deleted file mode 100644 index cb4adfc..0000000 --- a/cc/base/scoped_ptr_deque.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CC_BASE_SCOPED_PTR_DEQUE_H_ -#define CC_BASE_SCOPED_PTR_DEQUE_H_ - -#include <algorithm> -#include <deque> - -#include "base/basictypes.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/stl_util.h" - -namespace cc { - -// This type acts like a deque<scoped_ptr> based on top of std::deque. The -// ScopedPtrDeque has ownership of all elements in the deque. -template <typename T> -class ScopedPtrDeque { - public: - typedef typename std::deque<T*>::const_iterator const_iterator; - typedef typename std::deque<T*>::reverse_iterator reverse_iterator; - typedef typename std::deque<T*>::const_reverse_iterator - const_reverse_iterator; - -#if defined(OS_ANDROID) - // On Android the iterator is not a class, so we can't block assignment. - typedef typename std::deque<T*>::iterator iterator; -#else - // Ban setting values on the iterator directly. New pointers must be passed - // to methods on the ScopedPtrDeque class to appear in the deque. - class iterator : public std::deque<T*>::iterator { - public: - explicit iterator(const typename std::deque<T*>::iterator& other) - : std::deque<T*>::iterator(other) {} - T* const& operator*() { return std::deque<T*>::iterator::operator*(); } - }; -#endif - - ScopedPtrDeque() {} - - ~ScopedPtrDeque() { clear(); } - - size_t size() const { - return data_.size(); - } - - T* at(size_t index) const { - DCHECK(index < size()); - return data_[index]; - } - - T* operator[](size_t index) const { - return at(index); - } - - T* front() const { - DCHECK(!empty()); - return at(0); - } - - T* back() const { - DCHECK(!empty()); - return at(size() - 1); - } - - bool empty() const { - return data_.empty(); - } - - scoped_ptr<T> take_front() { - scoped_ptr<T> ret(front()); - data_.pop_front(); - return ret.Pass(); - } - - scoped_ptr<T> take_back() { - scoped_ptr<T> ret(back()); - data_.pop_back(); - return ret.Pass(); - } - - void clear() { - STLDeleteElements(&data_); - } - - void push_front(scoped_ptr<T> item) { - data_.push_front(item.release()); - } - - void push_back(scoped_ptr<T> item) { - data_.push_back(item.release()); - } - - void insert(iterator position, scoped_ptr<T> item) { - DCHECK(position <= end()); - data_.insert(position, item.release()); - } - - scoped_ptr<T> take(iterator position) { - DCHECK(position < end()); - scoped_ptr<T> ret(*position); - data_.erase(position); - return ret.Pass(); - } - - void swap(iterator a, iterator b) { - DCHECK(a < end()); - DCHECK(b < end()); - if (a == end() || b == end() || a == b) - return; - typename std::deque<T*>::iterator writable_a = a; - typename std::deque<T*>::iterator writable_b = b; - std::swap(*writable_a, *writable_b); - } - - iterator begin() { return static_cast<iterator>(data_.begin()); } - const_iterator begin() const { return data_.begin(); } - iterator end() { return static_cast<iterator>(data_.end()); } - const_iterator end() const { return data_.end(); } - - reverse_iterator rbegin() { return data_.rbegin(); } - const_reverse_iterator rbegin() const { return data_.rbegin(); } - reverse_iterator rend() { return data_.rend(); } - const_reverse_iterator rend() const { return data_.rend(); } - - private: - std::deque<T*> data_; - - DISALLOW_COPY_AND_ASSIGN(ScopedPtrDeque); -}; - -} // namespace cc - -#endif // CC_BASE_SCOPED_PTR_DEQUE_H_ @@ -76,6 +76,7 @@ 'animation/transform_operations.cc', 'animation/transform_operations.h', 'base/completion_event.h', + 'base/container_util.h', 'base/delayed_unique_notifier.cc', 'base/delayed_unique_notifier.h', 'base/histograms.cc', @@ -96,7 +97,6 @@ 'base/rtree.cc', 'base/rtree.h', 'base/scoped_ptr_algorithm.h', - 'base/scoped_ptr_deque.h', 'base/scoped_ptr_vector.h', 'base/simple_enclosed_region.cc', 'base/simple_enclosed_region.h', diff --git a/cc/output/bsp_tree.cc b/cc/output/bsp_tree.cc index 4eb87cb..a32c3f4 100644 --- a/cc/output/bsp_tree.cc +++ b/cc/output/bsp_tree.cc @@ -7,7 +7,7 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "cc/base/scoped_ptr_deque.h" +#include "cc/base/container_util.h" #include "cc/base/scoped_ptr_vector.h" #include "cc/output/bsp_compare_result.h" #include "cc/quads/draw_polygon.h" @@ -20,11 +20,11 @@ BspNode::BspNode(scoped_ptr<DrawPolygon> data) : node_data(data.Pass()) { BspNode::~BspNode() { } -BspTree::BspTree(ScopedPtrDeque<DrawPolygon>* list) { +BspTree::BspTree(std::deque<scoped_ptr<DrawPolygon>>* list) { if (list->size() == 0) return; - root_ = make_scoped_ptr(new BspNode(list->take_front())); + root_ = make_scoped_ptr(new BspNode(PopFront(list))); BuildTree(root_.get(), list); } @@ -35,14 +35,14 @@ BspTree::BspTree(ScopedPtrDeque<DrawPolygon>* list) { // can always simply just take from the front of the deque for our node's // data. void BspTree::BuildTree(BspNode* node, - ScopedPtrDeque<DrawPolygon>* polygon_list) { - ScopedPtrDeque<DrawPolygon> front_list; - ScopedPtrDeque<DrawPolygon> back_list; + std::deque<scoped_ptr<DrawPolygon>>* polygon_list) { + std::deque<scoped_ptr<DrawPolygon>> front_list; + std::deque<scoped_ptr<DrawPolygon>> back_list; // We take in a list of polygons at this level of the tree, and have to // find a splitting plane, then classify polygons as either in front of // or behind that splitting plane. - while (polygon_list->size() > 0) { + while (!polygon_list->empty()) { // Is this particular polygon in front of or behind our splitting polygon. BspCompareResult comparer_result = GetNodePositionRelative(*polygon_list->front(), *(node->node_data)); @@ -52,10 +52,10 @@ void BspTree::BuildTree(BspNode* node, // or front of the list. switch (comparer_result) { case BSP_FRONT: - front_list.push_back(polygon_list->take_front().Pass()); + front_list.push_back(PopFront(polygon_list)); break; case BSP_BACK: - back_list.push_back(polygon_list->take_front().Pass()); + back_list.push_back(PopFront(polygon_list)); break; case BSP_SPLIT: { @@ -63,7 +63,7 @@ void BspTree::BuildTree(BspNode* node, scoped_ptr<DrawPolygon> new_front; scoped_ptr<DrawPolygon> new_back; // Time to split this geometry, *it needs to be split by node_data. - polygon = polygon_list->take_front(); + polygon = PopFront(polygon_list); bool split_result = polygon->Split(*(node->node_data), &new_front, &new_back); DCHECK(split_result); @@ -75,10 +75,10 @@ void BspTree::BuildTree(BspNode* node, break; } case BSP_COPLANAR_FRONT: - node->coplanars_front.push_back(polygon_list->take_front()); + node->coplanars_front.push_back(PopFront(polygon_list)); break; case BSP_COPLANAR_BACK: - node->coplanars_back.push_back(polygon_list->take_front()); + node->coplanars_back.push_back(PopFront(polygon_list)); break; default: NOTREACHED(); @@ -88,14 +88,13 @@ void BspTree::BuildTree(BspNode* node, // Build the back subtree using the front of the back_list as our splitter. if (back_list.size() > 0) { - node->back_child = make_scoped_ptr(new BspNode(back_list.take_front())); + node->back_child = make_scoped_ptr(new BspNode(PopFront(&back_list))); BuildTree(node->back_child.get(), &back_list); } // Build the front subtree using the front of the front_list as our splitter. if (front_list.size() > 0) { - node->front_child = - scoped_ptr<BspNode>(new BspNode(front_list.take_front())); + node->front_child = make_scoped_ptr(new BspNode(PopFront(&front_list))); BuildTree(node->front_child.get(), &front_list); } } diff --git a/cc/output/bsp_tree.h b/cc/output/bsp_tree.h index 29c8605..0a0b948 100644 --- a/cc/output/bsp_tree.h +++ b/cc/output/bsp_tree.h @@ -5,10 +5,10 @@ #ifndef CC_OUTPUT_BSP_TREE_H_ #define CC_OUTPUT_BSP_TREE_H_ +#include <deque> #include <vector> #include "base/memory/scoped_ptr.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/base/scoped_ptr_vector.h" #include "cc/output/bsp_compare_result.h" #include "cc/quads/draw_polygon.h" @@ -31,7 +31,7 @@ struct BspNode { class CC_EXPORT BspTree { public: - explicit BspTree(ScopedPtrDeque<DrawPolygon>* list); + explicit BspTree(std::deque<scoped_ptr<DrawPolygon>>* list); scoped_ptr<BspNode>& root() { return root_; } template <typename ActionHandlerType> @@ -47,7 +47,7 @@ class CC_EXPORT BspTree { scoped_ptr<BspNode> root_; void FromList(ScopedPtrVector<DrawPolygon>* list); - void BuildTree(BspNode* node, ScopedPtrDeque<DrawPolygon>* data); + void BuildTree(BspNode* node, std::deque<scoped_ptr<DrawPolygon>>* data); template <typename ActionHandlerType> void WalkInOrderAction(ActionHandlerType* action_handler, diff --git a/cc/output/bsp_tree_unittest.cc b/cc/output/bsp_tree_unittest.cc index 100bc91..18e65a5 100644 --- a/cc/output/bsp_tree_unittest.cc +++ b/cc/output/bsp_tree_unittest.cc @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <deque> + #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/base/scoped_ptr_vector.h" #include "cc/output/bsp_tree.h" #include "cc/output/bsp_walk_action.h" @@ -30,7 +31,7 @@ namespace { class BspTreeTest { public: - static void RunTest(ScopedPtrDeque<DrawPolygon>* test_polygons, + static void RunTest(std::deque<scoped_ptr<DrawPolygon>>* test_polygons, const std::vector<int>& compare_list) { BspTree bsp_tree(test_polygons); @@ -113,7 +114,7 @@ TEST(BspTreeTest, NoSplit) { scoped_ptr<DrawPolygon> polygon_c( CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2)); - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_a.Pass()); polygon_list.push_back(polygon_b.Pass()); polygon_list.push_back(polygon_c.Pass()); @@ -141,7 +142,7 @@ TEST(BspTreeTest, BasicSplit) { scoped_ptr<DrawPolygon> polygon_b( CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_a.Pass()); polygon_list.push_back(polygon_b.Pass()); @@ -170,7 +171,7 @@ TEST(BspTreeTest, QuadOffset) { scoped_ptr<DrawPolygon> polygon_b( CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_a.Pass()); polygon_list.push_back(polygon_b.Pass()); @@ -199,7 +200,7 @@ TEST(BspTreeTest, QuadOffsetSplit) { scoped_ptr<DrawPolygon> polygon_b( CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_b.Pass()); polygon_list.push_back(polygon_a.Pass()); @@ -235,7 +236,7 @@ TEST(BspTreeTest, ThreeWaySplit) { scoped_ptr<DrawPolygon> polygon_c( CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 1.0f, 0.0f), 2)); - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_a.Pass()); polygon_list.push_back(polygon_b.Pass()); polygon_list.push_back(polygon_c.Pass()); @@ -276,7 +277,7 @@ TEST(BspTreeTest, Coplanar) { scoped_ptr<DrawPolygon> polygon_f = polygon_c->CreateCopy(); { - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_a.Pass()); polygon_list.push_back(polygon_b.Pass()); polygon_list.push_back(polygon_c.Pass()); @@ -288,7 +289,7 @@ TEST(BspTreeTest, Coplanar) { // Now check a different order and ensure we get that back as well { - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_f.Pass()); polygon_list.push_back(polygon_d.Pass()); polygon_list.push_back(polygon_e.Pass()); @@ -333,7 +334,7 @@ TEST(BspTreeTest, CoplanarSplit) { scoped_ptr<DrawPolygon> polygon_d( CREATE_DRAW_POLYGON(vertices_d, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 3)); - ScopedPtrDeque<DrawPolygon> polygon_list; + std::deque<scoped_ptr<DrawPolygon>> polygon_list; polygon_list.push_back(polygon_a.Pass()); polygon_list.push_back(polygon_b.Pass()); polygon_list.push_back(polygon_c.Pass()); diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 43e19c3..16dcd5a 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -404,10 +404,11 @@ void DirectRenderer::DoDrawPolygon(const DrawPolygon& poly, } } -void DirectRenderer::FlushPolygons(ScopedPtrDeque<DrawPolygon>* poly_list, - DrawingFrame* frame, - const gfx::Rect& render_pass_scissor, - bool use_render_pass_scissor) { +void DirectRenderer::FlushPolygons( + std::deque<scoped_ptr<DrawPolygon>>* poly_list, + DrawingFrame* frame, + const gfx::Rect& render_pass_scissor, + bool use_render_pass_scissor) { if (poly_list->empty()) { return; } @@ -473,7 +474,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame, MoveFromDrawToWindowSpace(frame, render_pass_scissor_in_draw_space)); const QuadList& quad_list = render_pass->quad_list; - ScopedPtrDeque<DrawPolygon> poly_list; + std::deque<scoped_ptr<DrawPolygon>> poly_list; int next_polygon_id = 0; int last_sorting_context_id = 0; diff --git a/cc/output/direct_renderer.h b/cc/output/direct_renderer.h index 87e64d6..be72632 100644 --- a/cc/output/direct_renderer.h +++ b/cc/output/direct_renderer.h @@ -9,7 +9,6 @@ #include "base/callback.h" #include "base/containers/scoped_ptr_hash_map.h" #include "cc/base/cc_export.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/output/overlay_processor.h" #include "cc/output/renderer.h" #include "cc/raster/task_graph_runner.h" @@ -104,7 +103,7 @@ class CC_EXPORT DirectRenderer : public Renderer { static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); - void FlushPolygons(ScopedPtrDeque<DrawPolygon>* poly_list, + void FlushPolygons(std::deque<scoped_ptr<DrawPolygon>>* poly_list, DrawingFrame* frame, const gfx::Rect& render_pass_scissor, bool use_render_pass_scissor); diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 22fea9e..22e2cb8 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -17,6 +17,7 @@ #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "base/trace_event/trace_event.h" +#include "cc/base/container_util.h" #include "cc/base/math_util.h" #include "cc/output/compositor_frame.h" #include "cc/output/compositor_frame_metadata.h" @@ -474,12 +475,12 @@ void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { if (pending_sync_queries_.front()->IsPending()) break; - available_sync_queries_.push_back(pending_sync_queries_.take_front()); + available_sync_queries_.push_back(PopFront(&pending_sync_queries_)); } current_sync_query_ = available_sync_queries_.empty() ? make_scoped_ptr(new SyncQuery(gl_)) - : available_sync_queries_.take_front(); + : PopFront(&available_sync_queries_); read_lock_fence = current_sync_query_->Begin(); } else { diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h index a090324..0aa4e8f 100644 --- a/cc/output/gl_renderer.h +++ b/cc/output/gl_renderer.h @@ -5,9 +5,10 @@ #ifndef CC_OUTPUT_GL_RENDERER_H_ #define CC_OUTPUT_GL_RENDERER_H_ +#include <deque> + #include "base/cancelable_callback.h" #include "cc/base/cc_export.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/base/scoped_ptr_vector.h" #include "cc/output/direct_renderer.h" #include "cc/output/gl_renderer_draw_cache.h" @@ -504,8 +505,8 @@ class CC_EXPORT GLRenderer : public DirectRenderer { scoped_ptr<ResourceProvider::ScopedWriteLockGL> current_framebuffer_lock_; class SyncQuery; - ScopedPtrDeque<SyncQuery> pending_sync_queries_; - ScopedPtrDeque<SyncQuery> available_sync_queries_; + std::deque<scoped_ptr<SyncQuery>> pending_sync_queries_; + std::deque<scoped_ptr<SyncQuery>> available_sync_queries_; scoped_ptr<SyncQuery> current_sync_query_; bool use_sync_query_; bool use_blend_equation_advanced_; diff --git a/cc/raster/one_copy_tile_task_worker_pool.cc b/cc/raster/one_copy_tile_task_worker_pool.cc index 5e31746..5aa1aaa 100644 --- a/cc/raster/one_copy_tile_task_worker_pool.cc +++ b/cc/raster/one_copy_tile_task_worker_pool.cc @@ -12,6 +12,7 @@ #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event_argument.h" +#include "cc/base/container_util.h" #include "cc/base/math_util.h" #include "cc/debug/traced_value.h" #include "cc/raster/raster_buffer.h" @@ -613,8 +614,8 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource, if (!CheckForQueryResult(gl, busy_buffers_.front()->query_id)) break; - MarkStagingBufferAsFree(busy_buffers_.front()); - free_buffers_.push_back(busy_buffers_.take_front()); + MarkStagingBufferAsFree(busy_buffers_.front().get()); + free_buffers_.push_back(PopFront(&busy_buffers_)); } } @@ -628,14 +629,14 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource, if (resource_provider_->use_sync_query()) { WaitForQueryResult(gl, busy_buffers_.front()->query_id); - MarkStagingBufferAsFree(busy_buffers_.front()); - free_buffers_.push_back(busy_buffers_.take_front()); + MarkStagingBufferAsFree(busy_buffers_.front().get()); + free_buffers_.push_back(PopFront(&busy_buffers_)); } else { // Fall-back to glFinish if CHROMIUM_sync_query is not available. gl->Finish(); while (!busy_buffers_.empty()) { - MarkStagingBufferAsFree(busy_buffers_.front()); - free_buffers_.push_back(busy_buffers_.take_front()); + MarkStagingBufferAsFree(busy_buffers_.front().get()); + free_buffers_.push_back(PopFront(&busy_buffers_)); } } } @@ -643,13 +644,14 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource, // Find a staging buffer that allows us to perform partial raster when // using persistent GpuMemoryBuffers. if (use_partial_raster_ && previous_content_id) { - StagingBufferDeque::iterator it = - std::find_if(free_buffers_.begin(), free_buffers_.end(), - [previous_content_id](const StagingBuffer* buffer) { - return buffer->content_id == previous_content_id; - }); + StagingBufferDeque::iterator it = std::find_if( + free_buffers_.begin(), free_buffers_.end(), + [previous_content_id](const scoped_ptr<StagingBuffer>& buffer) { + return buffer->content_id == previous_content_id; + }); if (it != free_buffers_.end()) { - staging_buffer = free_buffers_.take(it); + staging_buffer = it->Pass(); + free_buffers_.erase(it); MarkStagingBufferAsBusy(staging_buffer.get()); } } @@ -658,12 +660,13 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource, if (!staging_buffer) { StagingBufferDeque::iterator it = std::find_if(free_buffers_.begin(), free_buffers_.end(), - [resource](const StagingBuffer* buffer) { + [resource](const scoped_ptr<StagingBuffer>& buffer) { return buffer->size == resource->size() && buffer->format == resource->format(); }); if (it != free_buffers_.end()) { - staging_buffer = free_buffers_.take(it); + staging_buffer = it->Pass(); + free_buffers_.erase(it); MarkStagingBufferAsBusy(staging_buffer.get()); } } @@ -681,9 +684,9 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource, break; free_buffers_.front()->DestroyGLResources(gl); - MarkStagingBufferAsBusy(free_buffers_.front()); - RemoveStagingBuffer(free_buffers_.front()); - free_buffers_.take_front(); + MarkStagingBufferAsBusy(free_buffers_.front().get()); + RemoveStagingBuffer(free_buffers_.front().get()); + free_buffers_.pop_front(); } return staging_buffer.Pass(); @@ -763,9 +766,9 @@ void OneCopyTileTaskWorkerPool::ReleaseBuffersNotUsedSince( return; free_buffers_.front()->DestroyGLResources(gl); - MarkStagingBufferAsBusy(free_buffers_.front()); - RemoveStagingBuffer(free_buffers_.front()); - free_buffers_.take_front(); + MarkStagingBufferAsBusy(free_buffers_.front().get()); + RemoveStagingBuffer(free_buffers_.front().get()); + free_buffers_.pop_front(); } while (!busy_buffers_.empty()) { @@ -773,8 +776,8 @@ void OneCopyTileTaskWorkerPool::ReleaseBuffersNotUsedSince( return; busy_buffers_.front()->DestroyGLResources(gl); - RemoveStagingBuffer(busy_buffers_.front()); - busy_buffers_.take_front(); + RemoveStagingBuffer(busy_buffers_.front().get()); + busy_buffers_.pop_front(); } } } diff --git a/cc/raster/one_copy_tile_task_worker_pool.h b/cc/raster/one_copy_tile_task_worker_pool.h index a582c4e..08445b0 100644 --- a/cc/raster/one_copy_tile_task_worker_pool.h +++ b/cc/raster/one_copy_tile_task_worker_pool.h @@ -5,6 +5,7 @@ #ifndef CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ #define CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ +#include <deque> #include <set> #include "base/memory/weak_ptr.h" @@ -12,7 +13,6 @@ #include "base/time/time.h" #include "base/trace_event/memory_dump_provider.h" #include "base/values.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/output/context_provider.h" #include "cc/raster/tile_task_runner.h" #include "cc/raster/tile_task_worker_pool.h" @@ -152,7 +152,7 @@ class CC_EXPORT OneCopyTileTaskWorkerPool // |lock_| must be acquired when accessing the following members. using StagingBufferSet = std::set<const StagingBuffer*>; StagingBufferSet buffers_; - using StagingBufferDeque = ScopedPtrDeque<StagingBuffer>; + using StagingBufferDeque = std::deque<scoped_ptr<StagingBuffer>>; StagingBufferDeque free_buffers_; StagingBufferDeque busy_buffers_; int bytes_scheduled_since_last_flush_; diff --git a/cc/raster/task_graph_runner_unittest.cc b/cc/raster/task_graph_runner_unittest.cc index eb9b6d9..31144e7 100644 --- a/cc/raster/task_graph_runner_unittest.cc +++ b/cc/raster/task_graph_runner_unittest.cc @@ -4,12 +4,13 @@ #include "cc/raster/task_graph_runner.h" +#include <deque> #include <vector> #include "base/bind.h" #include "base/synchronization/lock.h" #include "base/threading/simple_thread.h" -#include "cc/base/scoped_ptr_deque.h" +#include "cc/base/container_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace cc { @@ -181,8 +182,8 @@ class TaskGraphRunnerTest : public TaskGraphRunnerTestBase, } void TearDown() override { task_graph_runner_->Shutdown(); - while (workers_.size()) { - scoped_ptr<base::DelegateSimpleThread> worker = workers_.take_front(); + while (!workers_.empty()) { + scoped_ptr<base::DelegateSimpleThread> worker = PopFront(&workers_); worker->Join(); } } @@ -191,7 +192,7 @@ class TaskGraphRunnerTest : public TaskGraphRunnerTestBase, // Overridden from base::DelegateSimpleThread::Delegate: void Run() override { task_graph_runner_->Run(); } - ScopedPtrDeque<base::DelegateSimpleThread> workers_; + std::deque<scoped_ptr<base::DelegateSimpleThread>> workers_; }; TEST_P(TaskGraphRunnerTest, Basic) { diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index 28ab249..c6f9cbb 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -10,6 +10,7 @@ #include "base/strings/stringprintf.h" #include "base/thread_task_runner_handle.h" #include "base/trace_event/memory_dump_manager.h" +#include "cc/base/container_util.h" #include "cc/resources/resource_provider.h" #include "cc/resources/resource_util.h" #include "cc/resources/scoped_resource.h" @@ -79,7 +80,7 @@ ResourcePool::~ResourcePool() { DCHECK_EQ(0u, in_use_resources_.size()); while (!busy_resources_.empty()) { - DidFinishUsingResource(busy_resources_.take_back()); + DidFinishUsingResource(PopBack(&busy_resources_)); } SetResourceUsageLimits(0, 0); @@ -96,7 +97,7 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, // LRU resources within kResourceExpirationDelayMs. for (ResourceDeque::iterator it = unused_resources_.begin(); it != unused_resources_.end(); ++it) { - ScopedResource* resource = *it; + ScopedResource* resource = it->get(); DCHECK(resource_provider_->CanLockForWrite(resource->id())); if (resource->format() != format) @@ -105,7 +106,8 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, continue; // Transfer resource to |in_use_resources_|. - in_use_resources_.set(resource->id(), unused_resources_.take(it)); + in_use_resources_.set(resource->id(), it->Pass()); + unused_resources_.erase(it); in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( resource->size(), resource->format()); return resource; @@ -137,18 +139,20 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, Resource* ResourcePool::TryAcquireResourceWithContentId(uint64_t content_id) { DCHECK(content_id); - auto it = std::find_if(unused_resources_.begin(), unused_resources_.end(), - [content_id](const PoolResource* pool_resource) { - return pool_resource->content_id() == content_id; - }); + auto it = + std::find_if(unused_resources_.begin(), unused_resources_.end(), + [content_id](const scoped_ptr<PoolResource>& pool_resource) { + return pool_resource->content_id() == content_id; + }); if (it == unused_resources_.end()) return nullptr; - Resource* resource = *it; + Resource* resource = it->get(); DCHECK(resource_provider_->CanLockForWrite(resource->id())); // Transfer resource to |in_use_resources_|. - in_use_resources_.set(resource->id(), unused_resources_.take(it)); + in_use_resources_.set(resource->id(), it->Pass()); + unused_resources_.erase(it); in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( resource->size(), resource->format()); return resource; @@ -192,7 +196,7 @@ void ResourcePool::ReduceResourceUsage() { // can't be locked for write might also not be truly free-able. // We can free the resource here but it doesn't mean that the // memory is necessarily returned to the OS. - DeleteResource(unused_resources_.take_back()); + DeleteResource(PopBack(&unused_resources_)); } } @@ -214,13 +218,15 @@ void ResourcePool::DeleteResource(scoped_ptr<PoolResource> resource) { void ResourcePool::CheckBusyResources() { for (size_t i = 0; i < busy_resources_.size();) { ResourceDeque::iterator it(busy_resources_.begin() + i); - PoolResource* resource = *it; + PoolResource* resource = it->get(); if (resource_provider_->CanLockForWrite(resource->id())) { - DidFinishUsingResource(busy_resources_.take(it)); + DidFinishUsingResource(it->Pass()); + busy_resources_.erase(it); } else if (resource_provider_->IsLost(resource->id())) { // Remove lost resources from pool. - DeleteResource(busy_resources_.take(it)); + DeleteResource(it->Pass()); + busy_resources_.erase(it); } else { ++i; } @@ -270,7 +276,7 @@ void ResourcePool::EvictResourcesNotUsedSince(base::TimeTicks time_limit) { if (unused_resources_.back()->last_usage() > time_limit) return; - DeleteResource(unused_resources_.take_back()); + DeleteResource(PopBack(&unused_resources_)); } // Also free busy resources older than the delay. With a sufficiently large @@ -281,7 +287,7 @@ void ResourcePool::EvictResourcesNotUsedSince(base::TimeTicks time_limit) { if (busy_resources_.back()->last_usage() > time_limit) return; - DeleteResource(busy_resources_.take_back()); + DeleteResource(PopBack(&busy_resources_)); } } diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h index ef99d26..31653c4 100644 --- a/cc/resources/resource_pool.h +++ b/cc/resources/resource_pool.h @@ -11,7 +11,6 @@ #include "base/memory/scoped_ptr.h" #include "base/trace_event/memory_dump_provider.h" #include "cc/base/cc_export.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/output/renderer.h" #include "cc/resources/resource.h" #include "cc/resources/resource_format.h" @@ -117,7 +116,7 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider { size_t total_resource_count_; // Holds most recently used resources at the front of the queue. - using ResourceDeque = ScopedPtrDeque<PoolResource>; + using ResourceDeque = std::deque<scoped_ptr<PoolResource>>; ResourceDeque unused_resources_; ResourceDeque busy_resources_; diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 2c567f7..86b6025 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -5,6 +5,7 @@ #include "cc/resources/resource_provider.h" #include <algorithm> +#include <deque> #include <map> #include <set> #include <vector> @@ -13,7 +14,6 @@ #include "base/containers/hash_tables.h" #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/output/output_surface.h" #include "cc/resources/returned_resource.h" #include "cc/resources/shared_bitmap_manager.h" @@ -182,12 +182,11 @@ class ResourceProviderContext : public TestWebGraphicsContext3D { uint32 sync_point = shared_data_->InsertSyncPoint(); // Commit the produceTextureCHROMIUM calls at this point, so that // they're associated with the sync point. - for (PendingProduceTextureList::iterator it = - pending_produce_textures_.begin(); - it != pending_produce_textures_.end(); - ++it) { - shared_data_->ProduceTexture((*it)->mailbox, gpu::SyncToken(sync_point), - (*it)->texture); + for (const scoped_ptr<PendingProduceTexture>& pending_texture : + pending_produce_textures_) { + shared_data_->ProduceTexture(pending_texture->mailbox, + gpu::SyncToken(sync_point), + pending_texture->texture); } pending_produce_textures_.clear(); return sync_point; @@ -357,10 +356,9 @@ class ResourceProviderContext : public TestWebGraphicsContext3D { GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; scoped_refptr<TestTexture> texture; }; - typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; ContextSharedData* shared_data_; gpu::SyncToken last_waited_sync_token_; - PendingProduceTextureList pending_produce_textures_; + std::deque<scoped_ptr<PendingProduceTexture>> pending_produce_textures_; }; void GetResourcePixels(ResourceProvider* resource_provider, diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc index 357db7c..968224f 100644 --- a/cc/trees/layer_tree_host_common_perftest.cc +++ b/cc/trees/layer_tree_host_common_perftest.cc @@ -4,6 +4,7 @@ #include "cc/trees/layer_tree_host_common.h" +#include <deque> #include <sstream> #include "base/files/file_path.h" @@ -13,7 +14,6 @@ #include "base/strings/string_piece.h" #include "base/threading/thread.h" #include "base/time/time.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/base/scoped_ptr_vector.h" #include "cc/debug/lap_timer.h" #include "cc/layers/layer.h" @@ -165,7 +165,7 @@ class BspTreePerfTest : public CalcDrawPropsTest { timer_.Reset(); do { - ScopedPtrDeque<DrawPolygon> test_list; + std::deque<scoped_ptr<DrawPolygon>> test_list; for (int i = 0; i < num_duplicates_; i++) { for (size_t i = 0; i < polygon_list.size(); i++) { test_list.push_back(polygon_list[i]->CreateCopy()); |