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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 946813003: Check context id when deciding if a layer is in existing sorting context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Whoops. Not allowed to include tuple after all. Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 AddAnimatedTransformToLayer( 2968 AddAnimatedTransformToLayer(
2969 root.get(), 10.0, start_transform_operations, end_transform_operations); 2969 root.get(), 10.0, start_transform_operations, end_transform_operations);
2970 2970
2971 EXPECT_TRUE(root->TransformIsAnimating()); 2971 EXPECT_TRUE(root->TransformIsAnimating());
2972 2972
2973 ExecuteCalculateDrawProperties(root.get()); 2973 ExecuteCalculateDrawProperties(root.get());
2974 2974
2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion); 2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion);
2976 } 2976 }
2977 2977
2978 TEST_F(LayerTreeHostCommonTest, WillSortAtContextBoundary) {
2979 // Creates a layer tree that looks as follows:
2980 // * root (sorting-context-id1)
2981 // * parent (sorting-context-id2)
2982 // * child1 (sorting-context-id2)
2983 // * child2 (sorting-context-id2)
2984 //
2985 // This test ensures that we sort at |parent| even though both it and root are
2986 // set to be 3d sorted.
2987 FakeImplProxy proxy;
2988 TestSharedBitmapManager shared_bitmap_manager;
2989 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
2990
2991 scoped_ptr<LayerImpl> root_ptr(LayerImpl::Create(host_impl.active_tree(), 1));
2992 LayerImpl* root = root_ptr.get();
2993 scoped_ptr<LayerImpl> parent_ptr(
2994 LayerImpl::Create(host_impl.active_tree(), 2));
2995 LayerImpl* parent = parent_ptr.get();
2996 scoped_ptr<LayerImpl> child1_ptr(
2997 LayerImpl::Create(host_impl.active_tree(), 3));
2998 LayerImpl* child1 = child1_ptr.get();
2999 scoped_ptr<LayerImpl> child2_ptr(
3000 LayerImpl::Create(host_impl.active_tree(), 4));
3001 LayerImpl* child2 = child2_ptr.get();
3002
3003 gfx::Transform identity_matrix;
3004 gfx::Transform below_matrix;
3005 below_matrix.Translate3d(0.f, 0.f, -10.f);
3006 gfx::Transform above_matrix;
3007 above_matrix.Translate3d(0.f, 0.f, 10.f);
3008
3009 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3010 gfx::PointF(), gfx::Size(100, 100), true, true,
3011 true);
3012 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
3013 gfx::PointF(), gfx::Size(50, 50), true, true,
3014 true);
3015 SetLayerPropertiesForTesting(child1, above_matrix, gfx::Point3F(),
3016 gfx::PointF(), gfx::Size(50, 50), true, true,
3017 false);
3018 SetLayerPropertiesForTesting(child2, below_matrix, gfx::Point3F(),
3019 gfx::PointF(), gfx::Size(50, 50), true, true,
3020 false);
3021
3022 root->Set3dSortingContextId(3);
3023 root->SetDrawsContent(true);
3024 parent->Set3dSortingContextId(7);
3025 parent->SetDrawsContent(true);
3026 child1->Set3dSortingContextId(7);
3027 child1->SetDrawsContent(true);
3028 child2->Set3dSortingContextId(7);
3029 child2->SetDrawsContent(true);
3030
3031 parent->AddChild(child1_ptr.Pass());
3032 parent->AddChild(child2_ptr.Pass());
3033 root->AddChild(parent_ptr.Pass());
3034
3035 LayerImplList render_surface_layer_list;
3036 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
3037 root_ptr.get(), root->bounds(), &render_surface_layer_list);
3038 inputs.can_adjust_raster_scales = true;
3039 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
3040
3041 EXPECT_TRUE(root->render_surface());
3042 EXPECT_EQ(2u, render_surface_layer_list.size());
3043
3044 EXPECT_EQ(3u, parent->render_surface()->layer_list().size());
3045 EXPECT_EQ(child2->id(), parent->render_surface()->layer_list().at(0)->id());
3046 EXPECT_EQ(parent->id(), parent->render_surface()->layer_list().at(1)->id());
3047 EXPECT_EQ(child1->id(), parent->render_surface()->layer_list().at(2)->id());
3048 }
3049
2978 TEST_F(LayerTreeHostCommonTest, 3050 TEST_F(LayerTreeHostCommonTest,
2979 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { 3051 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) {
2980 scoped_refptr<Layer> root = Layer::Create(); 3052 scoped_refptr<Layer> root = Layer::Create();
2981 3053
2982 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3054 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2983 host->SetRootLayer(root); 3055 host->SetRootLayer(root);
2984 3056
2985 gfx::Transform identity_matrix; 3057 gfx::Transform identity_matrix;
2986 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3058 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
2987 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3059 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
(...skipping 5678 matching lines...) Expand 10 before | Expand all | Expand 10 after
8666 8738
8667 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8739 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
8668 8740
8669 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8741 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8670 root_size.height() + 50); 8742 root_size.height() + 50);
8671 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); 8743 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect());
8672 } 8744 }
8673 8745
8674 } // namespace 8746 } // namespace
8675 } // namespace cc 8747 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698