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

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: add unit test 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 #include <tuple>
Ian Vollick 2015/02/21 23:00:49 Although not needed for my changes, the presubmit
enne (OOO) 2015/02/23 19:01:50 This doesn't build on Android, unfortunately. I r
9 10
10 #include "cc/animation/layer_animation_controller.h" 11 #include "cc/animation/layer_animation_controller.h"
11 #include "cc/animation/transform_operations.h" 12 #include "cc/animation/transform_operations.h"
12 #include "cc/base/math_util.h" 13 #include "cc/base/math_util.h"
13 #include "cc/layers/content_layer.h" 14 #include "cc/layers/content_layer.h"
14 #include "cc/layers/content_layer_client.h" 15 #include "cc/layers/content_layer_client.h"
15 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
16 #include "cc/layers/layer_client.h" 17 #include "cc/layers/layer_client.h"
17 #include "cc/layers/layer_impl.h" 18 #include "cc/layers/layer_impl.h"
18 #include "cc/layers/layer_iterator.h" 19 #include "cc/layers/layer_iterator.h"
(...skipping 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 AddAnimatedTransformToLayer( 2969 AddAnimatedTransformToLayer(
2969 root.get(), 10.0, start_transform_operations, end_transform_operations); 2970 root.get(), 10.0, start_transform_operations, end_transform_operations);
2970 2971
2971 EXPECT_TRUE(root->TransformIsAnimating()); 2972 EXPECT_TRUE(root->TransformIsAnimating());
2972 2973
2973 ExecuteCalculateDrawProperties(root.get()); 2974 ExecuteCalculateDrawProperties(root.get());
2974 2975
2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion); 2976 EXPECT_FALSE(child->draw_properties().sorted_for_recursion);
2976 } 2977 }
2977 2978
2979 TEST_F(LayerTreeHostCommonTest, WillSortAtContextBoundary) {
2980 // Creates a layer tree that looks as follows:
2981 // * root (sorting-context-id1)
2982 // * parent (sorting-context-id2)
2983 // * child1 (sorting-context-id2)
2984 // * child2 (sorting-context-id2)
2985 //
2986 // This test ensures that we sort at |parent| even though both it and root are
2987 // set to be 3d sorted.
2988 FakeImplProxy proxy;
2989 TestSharedBitmapManager shared_bitmap_manager;
2990 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
2991
2992 scoped_ptr<LayerImpl> root_ptr(LayerImpl::Create(host_impl.active_tree(), 1));
2993 LayerImpl* root = root_ptr.get();
2994 scoped_ptr<LayerImpl> parent_ptr(
2995 LayerImpl::Create(host_impl.active_tree(), 2));
2996 LayerImpl* parent = parent_ptr.get();
2997 scoped_ptr<LayerImpl> child1_ptr(
2998 LayerImpl::Create(host_impl.active_tree(), 3));
2999 LayerImpl* child1 = child1_ptr.get();
3000 scoped_ptr<LayerImpl> child2_ptr(
3001 LayerImpl::Create(host_impl.active_tree(), 4));
3002 LayerImpl* child2 = child2_ptr.get();
3003
3004 gfx::Transform identity_matrix;
3005 gfx::Transform below_matrix;
3006 below_matrix.Translate3d(0.f, 0.f, -10.f);
3007 gfx::Transform above_matrix;
3008 above_matrix.Translate3d(0.f, 0.f, 10.f);
3009
3010 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3011 gfx::PointF(), gfx::Size(100, 100), true, true,
3012 true);
3013 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
3014 gfx::PointF(), gfx::Size(50, 50), true, true,
3015 true);
3016 SetLayerPropertiesForTesting(child1, above_matrix, gfx::Point3F(),
3017 gfx::PointF(), gfx::Size(50, 50), true, true,
3018 false);
3019 SetLayerPropertiesForTesting(child2, below_matrix, gfx::Point3F(),
3020 gfx::PointF(), gfx::Size(50, 50), true, true,
3021 false);
3022
3023 root->Set3dSortingContextId(3);
3024 root->SetDrawsContent(true);
3025 parent->Set3dSortingContextId(7);
3026 parent->SetDrawsContent(true);
3027 child1->Set3dSortingContextId(7);
3028 child1->SetDrawsContent(true);
3029 child2->Set3dSortingContextId(7);
3030 child2->SetDrawsContent(true);
3031
3032 parent->AddChild(child1_ptr.Pass());
3033 parent->AddChild(child2_ptr.Pass());
3034 root->AddChild(parent_ptr.Pass());
3035
3036 LayerImplList render_surface_layer_list;
3037 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
3038 root_ptr.get(), root->bounds(), &render_surface_layer_list);
3039 inputs.can_adjust_raster_scales = true;
3040 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
3041
3042 EXPECT_TRUE(root->render_surface());
3043 EXPECT_EQ(2u, render_surface_layer_list.size());
3044
3045 EXPECT_EQ(3u, parent->render_surface()->layer_list().size());
3046 EXPECT_EQ(child2->id(), parent->render_surface()->layer_list().at(0)->id());
3047 EXPECT_EQ(parent->id(), parent->render_surface()->layer_list().at(1)->id());
3048 EXPECT_EQ(child1->id(), parent->render_surface()->layer_list().at(2)->id());
3049 }
3050
2978 TEST_F(LayerTreeHostCommonTest, 3051 TEST_F(LayerTreeHostCommonTest,
2979 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { 3052 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) {
2980 scoped_refptr<Layer> root = Layer::Create(); 3053 scoped_refptr<Layer> root = Layer::Create();
2981 3054
2982 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3055 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2983 host->SetRootLayer(root); 3056 host->SetRootLayer(root);
2984 3057
2985 gfx::Transform identity_matrix; 3058 gfx::Transform identity_matrix;
2986 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3059 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
2987 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3060 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
(...skipping 5678 matching lines...) Expand 10 before | Expand all | Expand 10 after
8666 8739
8667 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8740 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
8668 8741
8669 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8742 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8670 root_size.height() + 50); 8743 root_size.height() + 50);
8671 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); 8744 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect());
8672 } 8745 }
8673 8746
8674 } // namespace 8747 } // namespace
8675 } // namespace cc 8748 } // 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