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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2751783002: cc: Replace LayerIterator with iterator that walks layer list and effect tree (Closed)
Patch Set: Clean up #includes Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index e43a988097021b8298e141632795dc6187f7a5db..ffad7292bbff4da951c5c4bfb305bd0dc44a9da5 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -20,10 +20,10 @@
#include "cc/base/math_util.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/layers/content_layer_client.h"
+#include "cc/layers/effect_tree_layer_list_iterator.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_client.h"
#include "cc/layers/layer_impl.h"
-#include "cc/layers/layer_iterator.h"
#include "cc/layers/render_surface_impl.h"
#include "cc/layers/texture_layer_impl.h"
#include "cc/output/copy_output_request.h"
@@ -6159,15 +6159,16 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
int count_represents_target_render_surface = 0;
int count_represents_contributing_render_surface = 0;
int count_represents_itself = 0;
- LayerIterator end = LayerIterator::End(&render_surface_layer_list);
- for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
- it != end; ++it) {
- if (it.represents_target_render_surface())
+ for (EffectTreeLayerListIterator it(host_impl.active_tree());
+ it.state() != EffectTreeLayerListIterator::State::END; ++it) {
+ if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
count_represents_target_render_surface++;
- if (it.represents_contributing_render_surface())
+ } else if (it.state() ==
+ EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
count_represents_contributing_render_surface++;
- if (it.represents_itself())
+ } else {
count_represents_itself++;
+ }
}
// Two render surfaces.
@@ -6190,15 +6191,16 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
int count_represents_target_render_surface = 0;
int count_represents_contributing_render_surface = 0;
int count_represents_itself = 0;
- LayerIterator end = LayerIterator::End(&render_surface_layer_list);
- for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
- it != end; ++it) {
- if (it.represents_target_render_surface())
+ for (EffectTreeLayerListIterator it(host_impl.active_tree());
+ it.state() != EffectTreeLayerListIterator::State::END; ++it) {
+ if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
count_represents_target_render_surface++;
- if (it.represents_contributing_render_surface())
+ } else if (it.state() ==
+ EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
count_represents_contributing_render_surface++;
- if (it.represents_itself())
+ } else {
count_represents_itself++;
+ }
}
// Only root layer has a render surface.
@@ -8249,20 +8251,18 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
}
-static void GatherDrawnLayers(const LayerImplList* rsll,
+static void GatherDrawnLayers(LayerTreeImpl* tree_impl,
std::set<LayerImpl*>* drawn_layers) {
- for (LayerIterator it = LayerIterator::Begin(rsll),
- end = LayerIterator::End(rsll);
- it != end; ++it) {
- LayerImpl* layer = *it;
- if (it.represents_itself())
- drawn_layers->insert(layer);
-
- if (!it.represents_contributing_render_surface())
+ for (EffectTreeLayerListIterator it(tree_impl);
+ it.state() != EffectTreeLayerListIterator::State::END; ++it) {
+ if (it.state() == EffectTreeLayerListIterator::State::LAYER)
+ drawn_layers->insert(it.current_layer());
+
+ if (it.state() != EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE)
continue;
- if (layer->GetRenderSurface()->MaskLayer())
- drawn_layers->insert(layer->GetRenderSurface()->MaskLayer());
+ if (it.current_render_surface()->MaskLayer())
+ drawn_layers->insert(it.current_render_surface()->MaskLayer());
}
}
@@ -8311,7 +8311,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
std::set<LayerImpl*> expected;
std::set<LayerImpl*> actual;
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
// If we force render surface, but none of the layers are in the layer list,
@@ -8329,7 +8329,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.clear();
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
// However, if we say that this layer also draws content, it will appear in
@@ -8348,7 +8348,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.insert(grand_child1_raw);
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
// Now child is forced to have a render surface, and one if its children draws
@@ -8371,7 +8371,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.insert(grand_child2_raw);
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
// Add a mask layer to child.
@@ -8398,7 +8398,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.insert(child_raw->test_properties()->mask_layer);
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
ExecuteCalculateDrawProperties(grand_parent_raw);
@@ -8416,7 +8416,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.insert(child_raw->test_properties()->mask_layer);
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
@@ -8436,7 +8436,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.clear();
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
// Child itself draws means that we should have the child and the mask in the
@@ -8457,7 +8457,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.insert(child_raw);
expected.insert(child_raw->test_properties()->mask_layer);
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
child_raw->test_properties()->SetMaskLayer(nullptr);
@@ -8486,7 +8486,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
expected.insert(grand_child2_raw);
actual.clear();
- GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
+ GatherDrawnLayers(host_impl.active_tree(), &actual);
EXPECT_EQ(expected, actual);
}

Powered by Google App Engine
This is Rietveld 408576698