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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2612093002: Build mapping from element id to transform/effect nodes. (Closed)
Patch Set: Check tree size in test. Created 3 years, 11 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
« no previous file with comments | « no previous file | cc/trees/property_tree.h » ('j') | cc/trees/property_tree.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 5e58148f9db03b81fc5af4b916472398a081e627..68813d7c95ee1d05d6d70062cf84492916f1c336 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -30,7 +30,6 @@
#include "cc/output/copy_output_result.h"
#include "cc/output/output_surface.h"
#include "cc/output/swap_promise.h"
-#include "cc/playback/display_item_list_settings.h"
#include "cc/quads/draw_quad.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/tile_draw_quad.h"
@@ -918,6 +917,87 @@ class LayerTreeHostTestPushNodeOwnerToNodeIdMap : public LayerTreeHostTest {
// engine will never build PropertyTrees in LTH remote. See crbug.com/655795.
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushNodeOwnerToNodeIdMap);
+class LayerTreeHostTestPushElementIdToNodeIdMap : public LayerTreeHostTest {
+ protected:
+ void SetupTree() override {
+ root_ = Layer::Create();
+ child_ = Layer::Create();
+ child_->SetElementId(kTestElementId);
+ root_->AddChild(child_);
+ layer_tree()->SetRootLayer(root_);
+ LayerTreeHostTest::SetupTree();
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DidCommit() override {
+ switch (layer_tree_host()->SourceFrameNumber()) {
+ case 1:
+ child_->SetForceRenderSurfaceForTesting(true);
+ break;
+ case 2:
+ child_->SetForceRenderSurfaceForTesting(false);
+ break;
+ }
+ }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
+ PropertyTrees* property_trees = impl->sync_tree()->property_trees();
+ auto root_element_id_to_transform_node_index =
ajuma 2017/01/10 00:02:36 int child_transform_node_index
wkorman 2017/01/10 00:13:09 Moved inline to the one case statement where it's
+ property_trees->element_id_to_transform_node_index[kTestElementId];
+ auto root_element_id_to_effect_node_index =
ajuma 2017/01/10 00:02:36 int child_effect_node_index
wkorman 2017/01/10 00:13:09 Moved inline to the one case statement where it's
+ property_trees->element_id_to_effect_node_index[kTestElementId];
+
+ LayerImpl* child_impl_ = impl->active_tree()->LayerById(child_->id());
+ switch (impl->sync_tree()->source_frame_number()) {
+ case 0:
+ EXPECT_EQ(2U, child_impl_->layer_tree_impl()
+ ->property_trees()
+ ->transform_tree.size());
+ EXPECT_EQ(2U, child_impl_->layer_tree_impl()
+ ->property_trees()
+ ->effect_tree.size());
+ EXPECT_EQ(0, root_element_id_to_transform_node_index);
+ EXPECT_EQ(0, root_element_id_to_effect_node_index);
ajuma 2017/01/10 00:02:36 These 0s are because kTestElementId isn't present
wkorman 2017/01/10 00:13:09 Good point, revised here and below to find() == en
+ break;
+ case 1:
+ EXPECT_EQ(3U, child_impl_->layer_tree_impl()
wkorman 2017/01/09 21:41:55 We don't currently set the element id on the trans
+ ->property_trees()
+ ->transform_tree.size());
+ EXPECT_EQ(3U, child_impl_->layer_tree_impl()
+ ->property_trees()
+ ->effect_tree.size());
+ EXPECT_EQ(2, root_element_id_to_transform_node_index);
+ EXPECT_EQ(2, root_element_id_to_effect_node_index);
+ break;
+ case 2:
+ EXPECT_EQ(2U, child_impl_->layer_tree_impl()
+ ->property_trees()
+ ->transform_tree.size());
+ EXPECT_EQ(2U, child_impl_->layer_tree_impl()
+ ->property_trees()
+ ->effect_tree.size());
+ EXPECT_EQ(0, root_element_id_to_transform_node_index);
+ EXPECT_EQ(0, root_element_id_to_effect_node_index);
ajuma 2017/01/10 00:02:36 Same comment about checking that kTestElementId is
wkorman 2017/01/10 00:13:09 Done.
+ break;
+ }
+ EndTest();
+ }
+
+ void AfterTest() override {}
+
+ private:
+ const ElementId kTestElementId = ElementId(42, 8118);
+
+ scoped_refptr<Layer> root_;
+ scoped_refptr<Layer> child_;
+};
+
+// Validates that, for a layer with a compositor element id set on it, mappings
+// from compositor element id to transform/effect node indexes are created as
+// part of building a layer's property tree and are present on the impl thread.
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushElementIdToNodeIdMap);
+
class LayerTreeHostTestSurfaceDamage : public LayerTreeHostTest {
protected:
void SetupTree() override {
« no previous file with comments | « no previous file | cc/trees/property_tree.h » ('j') | cc/trees/property_tree.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698