diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 21:37:23 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 21:37:23 +0000 |
commit | 989386c3e4c2e35fa4cf0d41febd1751e9afa3b3 (patch) | |
tree | 4869c1c6d2c4233ba654faf7b311c6698d6f1692 /cc/layers | |
parent | 909f5c42b086a8388abbee04049e0f44091fef6d (diff) | |
download | chromium_src-989386c3e4c2e35fa4cf0d41febd1751e9afa3b3.zip chromium_src-989386c3e4c2e35fa4cf0d41febd1751e9afa3b3.tar.gz chromium_src-989386c3e4c2e35fa4cf0d41febd1751e9afa3b3.tar.bz2 |
cc: Clean up the RenderSurface objects in the RenderSurfaceLayerList
When the RenderSurfaceLayerList is cleared, we need to also destroy
the RenderSurface objects.
Create a RenderSurfaceLayerList subclass of LayerList which
does this cleanup in a safe/scoped way, and use that in the
public API for LayerTreeHostCommon.
R=earthdok, enne
BUG=259902
Review URL: https://chromiumcodereview.appspot.com/19236002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/contents_scaling_layer_unittest.cc | 2 | ||||
-rw-r--r-- | cc/layers/layer_iterator.cc | 21 | ||||
-rw-r--r-- | cc/layers/layer_iterator.h | 17 | ||||
-rw-r--r-- | cc/layers/layer_iterator_unittest.cc | 66 | ||||
-rw-r--r-- | cc/layers/layer_lists.cc | 60 | ||||
-rw-r--r-- | cc/layers/layer_lists.h | 24 | ||||
-rw-r--r-- | cc/layers/render_surface.cc | 11 | ||||
-rw-r--r-- | cc/layers/render_surface.h | 5 | ||||
-rw-r--r-- | cc/layers/scrollbar_layer_unittest.cc | 4 | ||||
-rw-r--r-- | cc/layers/solid_color_layer_impl_unittest.cc | 2 | ||||
-rw-r--r-- | cc/layers/tiled_layer_unittest.cc | 145 |
11 files changed, 240 insertions, 117 deletions
diff --git a/cc/layers/contents_scaling_layer_unittest.cc b/cc/layers/contents_scaling_layer_unittest.cc index 23f1376..08d3c32 100644 --- a/cc/layers/contents_scaling_layer_unittest.cc +++ b/cc/layers/contents_scaling_layer_unittest.cc @@ -37,7 +37,7 @@ class MockContentsScalingLayer : public ContentsScalingLayer { }; void CalcDrawProps(Layer* root, float device_scale) { - LayerList render_surface_layer_list; + RenderSurfaceLayerList render_surface_layer_list; LayerTreeHostCommon::CalculateDrawProperties( root, gfx::Size(500, 500), diff --git a/cc/layers/layer_iterator.cc b/cc/layers/layer_iterator.cc index 6fc9ec1..c33e753 100644 --- a/cc/layers/layer_iterator.cc +++ b/cc/layers/layer_iterator.cc @@ -177,11 +177,14 @@ void LayerIteratorActions::FrontToBack::GoToHighestInSubtree( // Declare each of the above functions for Layer and LayerImpl classes // so that they are linked. template CC_EXPORT void LayerIteratorActions::BackToFront::Begin( - LayerIterator<Layer, LayerList, RenderSurface, BackToFront>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, BackToFront>* + it); template CC_EXPORT void LayerIteratorActions::BackToFront::End( - LayerIterator<Layer, LayerList, RenderSurface, BackToFront>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, BackToFront>* + it); template CC_EXPORT void LayerIteratorActions::BackToFront::Next( - LayerIterator<Layer, LayerList, RenderSurface, BackToFront>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, BackToFront>* + it); template CC_EXPORT void LayerIteratorActions::BackToFront::Begin( LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, BackToFront>* @@ -194,13 +197,17 @@ template CC_EXPORT void LayerIteratorActions::BackToFront::Next( it); template CC_EXPORT void LayerIteratorActions::FrontToBack::Next( - LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, FrontToBack>* + it); template CC_EXPORT void LayerIteratorActions::FrontToBack::End( - LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, FrontToBack>* + it); template CC_EXPORT void LayerIteratorActions::FrontToBack::Begin( - LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, FrontToBack>* + it); template CC_EXPORT void LayerIteratorActions::FrontToBack::GoToHighestInSubtree( - LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>* it); + LayerIterator<Layer, RenderSurfaceLayerList, RenderSurface, FrontToBack>* + it); template CC_EXPORT void LayerIteratorActions::FrontToBack::Next( LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, FrontToBack>* diff --git a/cc/layers/layer_iterator.h b/cc/layers/layer_iterator.h index d7b85d4..b8a02c3 100644 --- a/cc/layers/layer_iterator.h +++ b/cc/layers/layer_iterator.h @@ -18,9 +18,9 @@ namespace cc { // See below for details. // // void DoStuffOnLayers( -// const LayerList& render_surface_layer_list) { +// const RenderSurfaceLayerList& render_surface_layer_list) { // typedef LayerIterator<Layer, -// LayerList, +// RenderSurfaceLayerList, // RenderSurface, // LayerIteratorActions::FrontToBack> // LayerIteratorType; @@ -157,8 +157,7 @@ class LayerIterator { } LayerType* target_render_surface_layer() const { - return get_raw_ptr( - (*render_surface_layer_list_)[target_render_surface_layer_index_]); + return render_surface_layer_list_->at(target_render_surface_layer_index_); } operator const LayerIteratorPosition<LayerType>() const { @@ -178,7 +177,7 @@ class LayerIterator { : render_surface_layer_list_(render_surface_layer_list), target_render_surface_layer_index_(0) { for (size_t i = 0; i < render_surface_layer_list->size(); ++i) { - if (!(*render_surface_layer_list)[i]->render_surface()) { + if (!render_surface_layer_list->at(i)->render_surface()) { NOTREACHED(); actions_.End(this); return; @@ -191,16 +190,10 @@ class LayerIterator { actions_.End(this); } - inline static Layer* get_raw_ptr(const scoped_refptr<Layer>& ptr) { - return ptr.get(); - } - inline static LayerImpl* get_raw_ptr(LayerImpl* ptr) { return ptr; } - inline LayerType* current_layer() const { return current_layer_represents_target_render_surface() ? target_render_surface_layer() - : get_raw_ptr( - target_render_surface_children()[current_layer_index_]); + : target_render_surface_children().at(current_layer_index_); } inline bool current_layer_represents_contributing_render_surface() const { diff --git a/cc/layers/layer_iterator_unittest.cc b/cc/layers/layer_iterator_unittest.cc index 10526ba..ea8ec3b 100644 --- a/cc/layers/layer_iterator_unittest.cc +++ b/cc/layers/layer_iterator_unittest.cc @@ -50,20 +50,20 @@ class TestLayer : public Layer { EXPECT_EQ(itself, layer->count_representing_itself_); typedef LayerIterator<Layer, - LayerList, + RenderSurfaceLayerList, RenderSurface, LayerIteratorActions::FrontToBack> FrontToBack; typedef LayerIterator<Layer, - LayerList, + RenderSurfaceLayerList, RenderSurface, LayerIteratorActions::BackToFront> BackToFront; -void ResetCounts(LayerList* render_surface_layerList) { +void ResetCounts(RenderSurfaceLayerList* render_surface_layer_list) { for (unsigned surface_index = 0; - surface_index < render_surface_layerList->size(); + surface_index < render_surface_layer_list->size(); ++surface_index) { TestLayer* render_surface_layer = static_cast<TestLayer*>( - (*render_surface_layerList)[surface_index].get()); + render_surface_layer_list->at(surface_index)); RenderSurface* render_surface = render_surface_layer->render_surface(); render_surface_layer->count_representing_target_surface_ = -1; @@ -74,7 +74,7 @@ void ResetCounts(LayerList* render_surface_layerList) { layer_index < render_surface->layer_list().size(); ++layer_index) { TestLayer* layer = static_cast<TestLayer*>( - render_surface->layer_list()[layer_index].get()); + render_surface->layer_list().at(layer_index)); layer->count_representing_target_surface_ = -1; layer->count_representing_contributing_surface_ = -1; @@ -84,11 +84,11 @@ void ResetCounts(LayerList* render_surface_layerList) { } void IterateFrontToBack( - LayerList* render_surface_layerList) { - ResetCounts(render_surface_layerList); + RenderSurfaceLayerList* render_surface_layer_list) { + ResetCounts(render_surface_layer_list); int count = 0; - for (FrontToBack it = FrontToBack::Begin(render_surface_layerList); - it != FrontToBack::End(render_surface_layerList); + for (FrontToBack it = FrontToBack::Begin(render_surface_layer_list); + it != FrontToBack::End(render_surface_layer_list); ++it, ++count) { TestLayer* layer = static_cast<TestLayer*>(*it); if (it.represents_target_render_surface()) @@ -101,11 +101,11 @@ void IterateFrontToBack( } void IterateBackToFront( - LayerList* render_surface_layerList) { - ResetCounts(render_surface_layerList); + RenderSurfaceLayerList* render_surface_layer_list) { + ResetCounts(render_surface_layer_list); int count = 0; - for (BackToFront it = BackToFront::Begin(render_surface_layerList); - it != BackToFront::End(render_surface_layerList); + for (BackToFront it = BackToFront::Begin(render_surface_layer_list); + it != BackToFront::End(render_surface_layer_list); ++it, ++count) { TestLayer* layer = static_cast<TestLayer*>(*it); if (it.represents_target_render_surface()) @@ -118,10 +118,10 @@ void IterateBackToFront( } TEST(LayerIteratorTest, EmptyTree) { - LayerList render_surface_layerList; + RenderSurfaceLayerList render_surface_layer_list; - IterateBackToFront(&render_surface_layerList); - IterateFrontToBack(&render_surface_layerList); + IterateBackToFront(&render_surface_layer_list); + IterateFrontToBack(&render_surface_layer_list); } TEST(LayerIteratorTest, SimpleTree) { @@ -131,14 +131,12 @@ TEST(LayerIteratorTest, SimpleTree) { scoped_refptr<TestLayer> third = TestLayer::Create(); scoped_refptr<TestLayer> fourth = TestLayer::Create(); - root_layer->CreateRenderSurface(); - root_layer->AddChild(first); root_layer->AddChild(second); root_layer->AddChild(third); root_layer->AddChild(fourth); - LayerList render_surface_layerList; + RenderSurfaceLayerList render_surface_layer_list; LayerTreeHostCommon::CalculateDrawProperties(root_layer.get(), root_layer->bounds(), gfx::Transform(), @@ -148,16 +146,16 @@ TEST(LayerIteratorTest, SimpleTree) { 256, false, false, - &render_surface_layerList); + &render_surface_layer_list); - IterateBackToFront(&render_surface_layerList); + IterateBackToFront(&render_surface_layer_list); EXPECT_COUNT(root_layer, 0, -1, 1); EXPECT_COUNT(first, -1, -1, 2); EXPECT_COUNT(second, -1, -1, 3); EXPECT_COUNT(third, -1, -1, 4); EXPECT_COUNT(fourth, -1, -1, 5); - IterateFrontToBack(&render_surface_layerList); + IterateFrontToBack(&render_surface_layer_list); EXPECT_COUNT(root_layer, 5, -1, 4); EXPECT_COUNT(first, -1, -1, 3); EXPECT_COUNT(second, -1, -1, 2); @@ -176,8 +174,6 @@ TEST(LayerIteratorTest, ComplexTree) { scoped_refptr<TestLayer> root221 = TestLayer::Create(); scoped_refptr<TestLayer> root231 = TestLayer::Create(); - root_layer->CreateRenderSurface(); - root_layer->AddChild(root1); root_layer->AddChild(root2); root_layer->AddChild(root3); @@ -187,7 +183,7 @@ TEST(LayerIteratorTest, ComplexTree) { root22->AddChild(root221); root23->AddChild(root231); - LayerList render_surface_layerList; + RenderSurfaceLayerList render_surface_layer_list; LayerTreeHostCommon::CalculateDrawProperties(root_layer.get(), root_layer->bounds(), gfx::Transform(), @@ -197,9 +193,9 @@ TEST(LayerIteratorTest, ComplexTree) { 256, false, false, - &render_surface_layerList); + &render_surface_layer_list); - IterateBackToFront(&render_surface_layerList); + IterateBackToFront(&render_surface_layer_list); EXPECT_COUNT(root_layer, 0, -1, 1); EXPECT_COUNT(root1, -1, -1, 2); EXPECT_COUNT(root2, -1, -1, 3); @@ -210,7 +206,7 @@ TEST(LayerIteratorTest, ComplexTree) { EXPECT_COUNT(root231, -1, -1, 8); EXPECT_COUNT(root3, -1, -1, 9); - IterateFrontToBack(&render_surface_layerList); + IterateFrontToBack(&render_surface_layer_list); EXPECT_COUNT(root_layer, 9, -1, 8); EXPECT_COUNT(root1, -1, -1, 7); EXPECT_COUNT(root2, -1, -1, 6); @@ -233,10 +229,6 @@ TEST(LayerIteratorTest, ComplexTreeMultiSurface) { scoped_refptr<TestLayer> root221 = TestLayer::Create(); scoped_refptr<TestLayer> root231 = TestLayer::Create(); - root_layer->CreateRenderSurface(); - root_layer->render_surface()-> - SetContentRect(gfx::Rect(root_layer->bounds())); - root_layer->AddChild(root1); root_layer->AddChild(root2); root_layer->AddChild(root3); @@ -251,7 +243,7 @@ TEST(LayerIteratorTest, ComplexTreeMultiSurface) { root23->SetOpacity(0.5f); root23->AddChild(root231); - LayerList render_surface_layerList; + RenderSurfaceLayerList render_surface_layer_list; LayerTreeHostCommon::CalculateDrawProperties(root_layer.get(), root_layer->bounds(), gfx::Transform(), @@ -261,9 +253,9 @@ TEST(LayerIteratorTest, ComplexTreeMultiSurface) { 256, false, false, - &render_surface_layerList); + &render_surface_layer_list); - IterateBackToFront(&render_surface_layerList); + IterateBackToFront(&render_surface_layer_list); EXPECT_COUNT(root_layer, 0, -1, 1); EXPECT_COUNT(root1, -1, -1, 2); EXPECT_COUNT(root2, 4, 3, -1); @@ -274,7 +266,7 @@ TEST(LayerIteratorTest, ComplexTreeMultiSurface) { EXPECT_COUNT(root231, -1, -1, 13); EXPECT_COUNT(root3, -1, -1, 14); - IterateFrontToBack(&render_surface_layerList); + IterateFrontToBack(&render_surface_layer_list); EXPECT_COUNT(root_layer, 14, -1, 13); EXPECT_COUNT(root1, -1, -1, 12); EXPECT_COUNT(root2, 10, 11, -1); diff --git a/cc/layers/layer_lists.cc b/cc/layers/layer_lists.cc new file mode 100644 index 0000000..89cd498 --- /dev/null +++ b/cc/layers/layer_lists.cc @@ -0,0 +1,60 @@ +// Copyright 2013 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. + +#include "cc/layers/layer_lists.h" + +#include "cc/layers/layer.h" + +namespace cc { + +RenderSurfaceLayerList::RenderSurfaceLayerList() {} + +RenderSurfaceLayerList::~RenderSurfaceLayerList() { + for (size_t i = 0; i < size(); ++i) + at(size() - 1 - i)->ClearRenderSurface(); +} + +Layer* RenderSurfaceLayerList::at(size_t i) const { + return list_.at(i); +} + +void RenderSurfaceLayerList::pop_back() { + list_.pop_back(); +} + +void RenderSurfaceLayerList::push_back(const scoped_refptr<Layer>& layer) { + list_.push_back(layer); +} + +Layer* RenderSurfaceLayerList::back() { + return list_.back(); +} + +size_t RenderSurfaceLayerList::size() const { + return list_.size(); +} + +LayerList::iterator RenderSurfaceLayerList::begin() { + return list_.begin(); +} + +LayerList::iterator RenderSurfaceLayerList::end() { + return list_.end(); +} + +LayerList::const_iterator RenderSurfaceLayerList::begin() const { + return list_.begin(); +} + +LayerList::const_iterator RenderSurfaceLayerList::end() const { + return list_.end(); +} + +void RenderSurfaceLayerList::clear() { + for (size_t i = 0; i < list_.size(); ++i) + DCHECK(!list_[i]->render_surface()); + list_.clear(); +} + +} // namespace cc diff --git a/cc/layers/layer_lists.h b/cc/layers/layer_lists.h index 83ef5fd..24a9c3c 100644 --- a/cc/layers/layer_lists.h +++ b/cc/layers/layer_lists.h @@ -8,6 +8,7 @@ #include <vector> #include "base/memory/ref_counted.h" +#include "cc/base/cc_export.h" #include "cc/base/scoped_ptr_vector.h" namespace cc { @@ -19,6 +20,29 @@ typedef std::vector<scoped_refptr<Layer> > LayerList; typedef ScopedPtrVector<LayerImpl> OwnedLayerImplList; typedef std::vector<LayerImpl*> LayerImplList; +class CC_EXPORT RenderSurfaceLayerList { + public: + RenderSurfaceLayerList(); + ~RenderSurfaceLayerList(); + + Layer* at(size_t i) const; + void pop_back(); + void push_back(const scoped_refptr<Layer>& layer); + Layer* back(); + size_t size() const; + bool empty() const { return size() == 0u; } + LayerList::iterator begin(); + LayerList::iterator end(); + LayerList::const_iterator begin() const; + LayerList::const_iterator end() const; + void clear(); + + private: + LayerList list_; + + DISALLOW_COPY_AND_ASSIGN(RenderSurfaceLayerList); +}; + } // namespace cc #endif // CC_LAYERS_LAYER_LISTS_H_ diff --git a/cc/layers/render_surface.cc b/cc/layers/render_surface.cc index 60d9cb2..a17beab 100644 --- a/cc/layers/render_surface.cc +++ b/cc/layers/render_surface.cc @@ -20,7 +20,16 @@ RenderSurface::RenderSurface(Layer* owning_layer) contributes_to_drawn_surface_(false), nearest_ancestor_that_moves_pixels_(NULL) {} -RenderSurface::~RenderSurface() {} +RenderSurface::~RenderSurface() { + for (size_t i = 0; i < layer_list_.size(); ++i) { + DCHECK(!layer_list_.at(i)->render_surface()) << + "RenderSurfaces should be cleared from the contributing layers " << + "before destroying this surface to avoid leaking a circular " << + "reference on the contributing layer. Probably the " << + "RenderSurfaceLayerList should just be destroyed before destroying " << + "any RenderSurfaces on layers."; + } +} gfx::RectF RenderSurface::DrawableContentRect() const { gfx::RectF drawable_content_rect = diff --git a/cc/layers/render_surface.h b/cc/layers/render_surface.h index 369d8c9..adce0a8 100644 --- a/cc/layers/render_surface.h +++ b/cc/layers/render_surface.h @@ -97,11 +97,10 @@ class CC_EXPORT RenderSurface { contributes_to_drawn_surface_ = contributes_to_drawn_surface; } - LayerList& layer_list() { return layer_list_; } + RenderSurfaceLayerList& layer_list() { return layer_list_; } // A no-op since DelegatedRendererLayers on the main thread don't have any // RenderPasses so they can't contribute to a surface. void AddContributingDelegatedRenderPassLayer(Layer* layer) {} - void ClearLayerLists() { layer_list_.clear(); } void SetNearestAncestorThatMovesPixels(RenderSurface* surface) { nearest_ancestor_that_moves_pixels_ = surface; @@ -133,7 +132,7 @@ class CC_EXPORT RenderSurface { // Uses the space of the surface's target surface. gfx::Rect clip_rect_; - LayerList layer_list_; + RenderSurfaceLayerList layer_list_; // The nearest ancestor target surface that will contain the contents of this // surface, and that is going to move pixels within the surface (such as with diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index c71731d8..eff52d2 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -455,6 +455,8 @@ class ScrollbarLayerTestResourceCreation : public testing::Test { EXPECT_EQ(expected_resources, queue.PartialUploadSize()); testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); + + scrollbar_layer->ClearRenderSurface(); } protected: @@ -548,6 +550,8 @@ class ScaledScrollbarLayerTestResourceCreation : public testing::Test { } testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); + + scrollbar_layer->ClearRenderSurface(); } protected: diff --git a/cc/layers/solid_color_layer_impl_unittest.cc b/cc/layers/solid_color_layer_impl_unittest.cc index 0ec7040..62729ed 100644 --- a/cc/layers/solid_color_layer_impl_unittest.cc +++ b/cc/layers/solid_color_layer_impl_unittest.cc @@ -109,7 +109,7 @@ TEST(SolidColorLayerImplTest, VerifyOpaqueRect) { scoped_refptr<Layer> root = Layer::Create(); root->AddChild(layer); - LayerList render_surface_layer_list; + RenderSurfaceLayerList render_surface_layer_list; LayerTreeHostCommon::CalculateDrawProperties(root.get(), gfx::Size(500, 500), gfx::Transform(), diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index 601c59d..7eb1c8d 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -118,13 +118,15 @@ class TiledLayerTest : public testing::Test { layer->Update(queue_.get(), occluded); } - void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) { + void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, + RenderSurfaceLayerList* render_surface_layer_list) { scoped_refptr<FakeTiledLayer> layer2; - CalcDrawProps(layer1, layer2); + CalcDrawProps(layer1, layer2, render_surface_layer_list); } void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, - const scoped_refptr<FakeTiledLayer>& layer2) { + const scoped_refptr<FakeTiledLayer>& layer2, + RenderSurfaceLayerList* render_surface_layer_list) { if (layer1.get() && !layer1->parent()) layer_tree_host_->root_layer()->AddChild(layer1); if (layer2.get() && !layer2->parent()) @@ -132,7 +134,6 @@ class TiledLayerTest : public testing::Test { if (occlusion_) occlusion_->SetRenderTarget(layer_tree_host_->root_layer()); - LayerList render_surface_layer_list; LayerTreeHostCommon::CalculateDrawProperties( layer_tree_host_->root_layer(), layer_tree_host_->device_viewport_size(), @@ -143,7 +144,7 @@ class TiledLayerTest : public testing::Test { layer_tree_host_->GetRendererCapabilities().max_texture_size, false, // can_use_lcd_text true, // can_adjust_raster_scale - &render_surface_layer_list); + render_surface_layer_list); } bool UpdateAndPush(const scoped_refptr<FakeTiledLayer>& layer1, @@ -212,10 +213,11 @@ TEST_F(TiledLayerTest, PushDirtyTiles) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // The tile size is 100x100, so this invalidates and then paints two tiles. layer->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); UpdateAndPush(layer, layer_impl); // We should have both tiles on the impl side. @@ -242,37 +244,45 @@ TEST_F(TiledLayerTest, PushOccludedDirtyTiles) { occlusion_ = &occluded; layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); - // The tile size is 100x100, so this invalidates and then paints two tiles. - layer->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer); - UpdateAndPush(layer, layer_impl); - - EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); - EXPECT_NEAR( - occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); - EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); + { + RenderSurfaceLayerList render_surface_layer_list; - // We should have both tiles on the impl side. - EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); - EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); + // The tile size is 100x100, so this invalidates and then paints two tiles. + layer->SetBounds(gfx::Size(100, 200)); + CalcDrawProps(layer, &render_surface_layer_list); + UpdateAndPush(layer, layer_impl); - // Invalidates part of the top tile... - layer->InvalidateContentRect(gfx::Rect(0, 0, 50, 50)); - // ....but the area is occluded. - occluded.SetOcclusion(gfx::Rect(0, 0, 50, 50)); - CalcDrawProps(layer); - UpdateAndPush(layer, layer_impl); + EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); + EXPECT_NEAR( + occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); + EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); - EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); - EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), - 20000 + 2500, - 1); - EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); + // We should have both tiles on the impl side. + EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); + EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); + } - // We should still have both tiles, as part of the top tile is still - // unoccluded. - EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); - EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); + { + RenderSurfaceLayerList render_surface_layer_list; + + // Invalidates part of the top tile... + layer->InvalidateContentRect(gfx::Rect(0, 0, 50, 50)); + // ....but the area is occluded. + occluded.SetOcclusion(gfx::Rect(0, 0, 50, 50)); + CalcDrawProps(layer, &render_surface_layer_list); + UpdateAndPush(layer, layer_impl); + + EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); + EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), + 20000 + 2500, + 1); + EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); + + // We should still have both tiles, as part of the top tile is still + // unoccluded. + EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); + EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); + } } TEST_F(TiledLayerTest, PushDeletedTiles) { @@ -280,10 +290,11 @@ TEST_F(TiledLayerTest, PushDeletedTiles) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // The tile size is 100x100, so this invalidates and then paints two tiles. layer->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); UpdateAndPush(layer, layer_impl); // We should have both tiles on the impl side. @@ -316,11 +327,12 @@ TEST_F(TiledLayerTest, PushIdlePaintTiles) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the // center. This paints 1 visible of the 25 invalid tiles. layer->SetBounds(gfx::Size(500, 500)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(200, 200, 100, 100); bool needs_update = UpdateAndPush(layer, layer_impl); // We should need idle-painting for surrounding tiles. @@ -384,7 +396,9 @@ TEST_F(TiledLayerTest, PredictivePainting) { // Setup. Use the previous_visible_rect to setup the prediction for next // frame. layer->SetBounds(bounds); - CalcDrawProps(layer); + + RenderSurfaceLayerList render_surface_layer_list; + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = previous_visible_rect; bool needs_update = UpdateAndPush(layer, layer_impl); @@ -432,6 +446,7 @@ TEST_F(TiledLayerTest, PushTilesAfterIdlePaintFailed) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl2 = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2)); + RenderSurfaceLayerList render_surface_layer_list; // For this test we have two layers. layer1 exhausts most texture memory, // leaving room for 2 more tiles from layer2, but not all three tiles. First @@ -449,7 +464,7 @@ TEST_F(TiledLayerTest, PushTilesAfterIdlePaintFailed) { // Paint a single tile in layer2 so that it will idle paint. layer1->SetBounds(layer1_rect.size()); layer2->SetBounds(layer2_rect.size()); - CalcDrawProps(layer1, layer2); + CalcDrawProps(layer1, layer2, &render_surface_layer_list); layer1->draw_properties().visible_content_rect = layer1_rect; layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); bool needs_update = UpdateAndPush(layer1, layer_impl1, layer2, layer_impl2); @@ -485,6 +500,7 @@ TEST_F(TiledLayerTest, PushIdlePaintedOccludedTiles) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; @@ -493,7 +509,7 @@ TEST_F(TiledLayerTest, PushIdlePaintedOccludedTiles) { occluded.SetOcclusion(gfx::Rect(0, 0, 100, 100)); layer->SetBounds(gfx::Size(100, 100)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); UpdateAndPush(layer, layer_impl); @@ -508,6 +524,7 @@ TEST_F(TiledLayerTest, PushTilesMarkedDirtyDuringPaint) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // The tile size is 100x100, so this invalidates and then paints two tiles. // However, during the paint, we invalidate one of the tiles. This should @@ -515,7 +532,7 @@ TEST_F(TiledLayerTest, PushTilesMarkedDirtyDuringPaint) { layer->fake_layer_updater()->SetRectToInvalidate( gfx::Rect(0, 50, 100, 50), layer.get()); layer->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); UpdateAndPush(layer, layer_impl); @@ -533,13 +550,14 @@ TEST_F(TiledLayerTest, PushTilesLayerMarkedDirtyDuringPaintOnNextLayer) { make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); scoped_ptr<FakeTiledLayerImpl> layer2_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2)); + RenderSurfaceLayerList render_surface_layer_list; // Invalidate a tile on layer1, during update of layer 2. layer2->fake_layer_updater()->SetRectToInvalidate( gfx::Rect(0, 50, 100, 50), layer1.get()); layer1->SetBounds(gfx::Size(100, 200)); layer2->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer1, layer2); + CalcDrawProps(layer1, layer2, &render_surface_layer_list); layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); UpdateAndPush(layer1, layer1_impl, layer2, layer2_impl); @@ -560,12 +578,13 @@ TEST_F(TiledLayerTest, PushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) { make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); scoped_ptr<FakeTiledLayerImpl> layer2_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2)); + RenderSurfaceLayerList render_surface_layer_list; layer1->fake_layer_updater()->SetRectToInvalidate( gfx::Rect(0, 50, 100, 50), layer2.get()); layer1->SetBounds(gfx::Size(100, 200)); layer2->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer1, layer2); + CalcDrawProps(layer1, layer2, &render_surface_layer_list); layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); UpdateAndPush(layer1, layer1_impl, layer2, layer2_impl); @@ -601,11 +620,12 @@ TEST_F(TiledLayerTest, PaintSmallAnimatedLayersImmediately) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // Full size layer with half being visible. layer->SetBounds(gfx::Size(layer_width, layer_height)); gfx::Rect visible_rect(0, 0, layer_width / 2, layer_height); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); // Pretend the layer is animating. layer->draw_properties().target_space_transform_is_animating = true; @@ -643,6 +663,7 @@ TEST_F(TiledLayerTest, IdlePaintOutOfMemory) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // We have enough memory for only the visible rect, so we will run out of // memory in first idle paint. @@ -652,7 +673,7 @@ TEST_F(TiledLayerTest, IdlePaintOutOfMemory) { // The tile size is 100x100, so this invalidates and then paints two tiles. bool needs_update = false; layer->SetBounds(gfx::Size(300, 300)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(100, 100, 100, 100); for (int i = 0; i < 2; i++) needs_update = UpdateAndPush(layer, layer_impl); @@ -678,7 +699,9 @@ TEST_F(TiledLayerTest, IdlePaintZeroSizedLayer) { // The layer's bounds are empty. // Empty layers don't paint or idle-paint. layer->SetBounds(gfx::Size()); - CalcDrawProps(layer); + + RenderSurfaceLayerList render_surface_layer_list; + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(); bool needs_update = UpdateAndPush(layer, layer_impl); @@ -713,7 +736,9 @@ TEST_F(TiledLayerTest, IdlePaintNonVisibleLayers) { for (int i = 0; i < 10; i++) { layer->SetBounds(gfx::Size(100, 100)); - CalcDrawProps(layer); + + RenderSurfaceLayerList render_surface_layer_list; + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = visible_rect[i]; if (invalidate[i]) @@ -732,10 +757,11 @@ TEST_F(TiledLayerTest, InvalidateFromPrepare) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // The tile size is 100x100, so this invalidates and then paints two tiles. layer->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); UpdateAndPush(layer, layer_impl); @@ -815,10 +841,11 @@ TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); scoped_ptr<FakeTiledLayerImpl> layer_impl = make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); + RenderSurfaceLayerList render_surface_layer_list; // Create a layer with one tile. layer->SetBounds(gfx::Size(100, 100)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); layer->Update(queue_.get(), NULL); UpdateTextures(); @@ -1073,10 +1100,11 @@ TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; // The tile size is 100x100, so this invalidates and then paints two tiles. layer->SetBounds(gfx::Size(100, 200)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); @@ -1088,6 +1116,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; @@ -1095,7 +1124,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); layer->SetBounds(gfx::Size(600, 600)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); layer->draw_properties().drawable_content_rect = @@ -1151,6 +1180,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; @@ -1158,7 +1188,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); layer->SetBounds(gfx::Size(600, 600)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); // The partially occluded tiles (by the 150 occlusion height) are visible // beyond the occlusion, so not culled. @@ -1222,6 +1252,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; @@ -1229,7 +1260,7 @@ TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); layer->SetBounds(gfx::Size(600, 600)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); @@ -1266,6 +1297,7 @@ TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; @@ -1275,7 +1307,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { // space) is transformed differently than the layer. layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); layer->SetBounds(gfx::Size(600, 600)); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); gfx::Transform screen_transform; screen_transform.Scale(0.5, 0.5); layer->draw_properties().screen_space_transform = screen_transform; @@ -1302,6 +1334,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { scoped_refptr<FakeTiledLayer> layer = new FakeTiledLayer(resource_manager_.get()); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; @@ -1319,7 +1352,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { layer->SetAnchorPoint(gfx::PointF()); layer->SetBounds(gfx::Size(300, 300)); scale_layer->AddChild(layer); - CalcDrawProps(scale_layer); + CalcDrawProps(scale_layer, &render_surface_layer_list); EXPECT_FLOAT_EQ(2.f, layer->contents_scale_x()); EXPECT_FLOAT_EQ(2.f, layer->contents_scale_y()); EXPECT_EQ(gfx::Size(600, 600).ToString(), @@ -1406,6 +1439,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); @@ -1420,7 +1454,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { gfx::Rect visible_bounds = gfx::Rect(0, 0, 100, 150); layer->SetBounds(content_bounds.size()); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); layer->draw_properties().drawable_content_rect = visible_bounds; layer->draw_properties().visible_content_rect = visible_bounds; @@ -1526,6 +1560,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { TEST_F(TiledLayerTest, Pixels_paintedMetrics) { scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); + RenderSurfaceLayerList render_surface_layer_list; TestOcclusionTracker occluded; occlusion_ = &occluded; layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); @@ -1538,7 +1573,7 @@ TEST_F(TiledLayerTest, Pixels_paintedMetrics) { gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300); layer->SetBounds(content_bounds.size()); - CalcDrawProps(layer); + CalcDrawProps(layer, &render_surface_layer_list); // Invalidates and paints the whole layer. layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |