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

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

Issue 2118993002: Detemplatize cc property nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | 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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "cc/test/fake_raster_source.h" 55 #include "cc/test/fake_raster_source.h"
56 #include "cc/test/fake_video_frame_provider.h" 56 #include "cc/test/fake_video_frame_provider.h"
57 #include "cc/test/geometry_test_utils.h" 57 #include "cc/test/geometry_test_utils.h"
58 #include "cc/test/gpu_rasterization_enabled_settings.h" 58 #include "cc/test/gpu_rasterization_enabled_settings.h"
59 #include "cc/test/layer_test_common.h" 59 #include "cc/test/layer_test_common.h"
60 #include "cc/test/layer_tree_test.h" 60 #include "cc/test/layer_tree_test.h"
61 #include "cc/test/test_gpu_memory_buffer_manager.h" 61 #include "cc/test/test_gpu_memory_buffer_manager.h"
62 #include "cc/test/test_shared_bitmap_manager.h" 62 #include "cc/test/test_shared_bitmap_manager.h"
63 #include "cc/test/test_task_graph_runner.h" 63 #include "cc/test/test_task_graph_runner.h"
64 #include "cc/test/test_web_graphics_context_3d.h" 64 #include "cc/test/test_web_graphics_context_3d.h"
65 #include "cc/trees/effect_node.h"
65 #include "cc/trees/layer_tree_impl.h" 66 #include "cc/trees/layer_tree_impl.h"
66 #include "cc/trees/single_thread_proxy.h" 67 #include "cc/trees/single_thread_proxy.h"
68 #include "cc/trees/transform_node.h"
67 #include "media/base/media.h" 69 #include "media/base/media.h"
68 #include "testing/gmock/include/gmock/gmock.h" 70 #include "testing/gmock/include/gmock/gmock.h"
69 #include "testing/gtest/include/gtest/gtest.h" 71 #include "testing/gtest/include/gtest/gtest.h"
70 #include "third_party/skia/include/core/SkMallocPixelRef.h" 72 #include "third_party/skia/include/core/SkMallocPixelRef.h"
71 #include "ui/gfx/geometry/rect_conversions.h" 73 #include "ui/gfx/geometry/rect_conversions.h"
72 #include "ui/gfx/geometry/size_conversions.h" 74 #include "ui/gfx/geometry/size_conversions.h"
73 #include "ui/gfx/geometry/vector2d_conversions.h" 75 #include "ui/gfx/geometry/vector2d_conversions.h"
74 76
75 #define EXPECT_SCOPED(statements) \ 77 #define EXPECT_SCOPED(statements) \
76 { \ 78 { \
(...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 2935 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2934 host_impl_->ActivateSyncTree(); 2936 host_impl_->ActivateSyncTree();
2935 2937
2936 LayerImpl* active_scrollbar_layer = 2938 LayerImpl* active_scrollbar_layer =
2937 host_impl_->active_tree()->LayerById(400); 2939 host_impl_->active_tree()->LayerById(400);
2938 2940
2939 EffectNode* active_tree_node = 2941 EffectNode* active_tree_node =
2940 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2942 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2941 active_scrollbar_layer->effect_tree_index()); 2943 active_scrollbar_layer->effect_tree_index());
2942 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2944 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
2943 active_tree_node->data.opacity); 2945 active_tree_node->opacity);
2944 2946
2945 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) 2947 host_impl_->ScrollbarAnimationControllerForId(scroll->id())
2946 ->DidMouseMoveNear(0); 2948 ->DidMouseMoveNear(0);
2947 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2949 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2948 InputHandler::WHEEL); 2950 InputHandler::WHEEL);
2949 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 2951 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
2950 host_impl_->ScrollEnd(EndState().get()); 2952 host_impl_->ScrollEnd(EndState().get());
2951 host_impl_->CreatePendingTree(); 2953 host_impl_->CreatePendingTree();
2952 // To test the case where the effect tree index of scrollbar layer changes, 2954 // To test the case where the effect tree index of scrollbar layer changes,
2953 // we force the container layer to create a render surface. 2955 // we force the container layer to create a render surface.
2954 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); 2956 container = host_impl_->pending_tree()->InnerViewportContainerLayer();
2955 container->test_properties()->force_render_surface = true; 2957 container->test_properties()->force_render_surface = true;
2956 container->SetBounds(gfx::Size(10, 10)); 2958 container->SetBounds(gfx::Size(10, 10));
2957 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 2959 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2958 2960
2959 LayerImpl* pending_scrollbar_layer = 2961 LayerImpl* pending_scrollbar_layer =
2960 host_impl_->pending_tree()->LayerById(400); 2962 host_impl_->pending_tree()->LayerById(400);
2961 EffectNode* pending_tree_node = 2963 EffectNode* pending_tree_node =
2962 host_impl_->pending_tree()->property_trees()->effect_tree.Node( 2964 host_impl_->pending_tree()->property_trees()->effect_tree.Node(
2963 pending_scrollbar_layer->effect_tree_index()); 2965 pending_scrollbar_layer->effect_tree_index());
2964 host_impl_->pending_tree() 2966 host_impl_->pending_tree()
2965 ->property_trees() 2967 ->property_trees()
2966 ->always_use_active_tree_opacity_effect_ids.push_back(400); 2968 ->always_use_active_tree_opacity_effect_ids.push_back(400);
2967 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); 2969 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
2968 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 2970 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity());
2969 EXPECT_FLOAT_EQ(0.f, pending_tree_node->data.opacity); 2971 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity);
2970 host_impl_->ActivateSyncTree(); 2972 host_impl_->ActivateSyncTree();
2971 active_tree_node = 2973 active_tree_node =
2972 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2974 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2973 active_scrollbar_layer->effect_tree_index()); 2975 active_scrollbar_layer->effect_tree_index());
2974 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); 2976 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
2975 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 2977 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity());
2976 } 2978 }
2977 }; 2979 };
2978 2980
2979 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) { 2981 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) {
2980 RunTest(LayerTreeSettings::LINEAR_FADE); 2982 RunTest(LayerTreeSettings::LINEAR_FADE);
2981 } 2983 }
2982 2984
2983 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { 2985 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) {
2984 RunTest(LayerTreeSettings::THINNING); 2986 RunTest(LayerTreeSettings::THINNING);
(...skipping 6862 matching lines...) Expand 10 before | Expand all | Expand 10 after
9847 test_layer->SetTransform(perspective_transform); 9849 test_layer->SetTransform(perspective_transform);
9848 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 9850 host_impl_->active_tree()->BuildPropertyTreesForTesting();
9849 9851
9850 bool update_lcd_text = false; 9852 bool update_lcd_text = false;
9851 9853
9852 host_impl_->SetViewportSize(gfx::Size(50, 50)); 9854 host_impl_->SetViewportSize(gfx::Size(50, 50));
9853 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 9855 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
9854 TransformNode* node = 9856 TransformNode* node =
9855 host_impl_->active_tree()->property_trees()->transform_tree.Node( 9857 host_impl_->active_tree()->property_trees()->transform_tree.Node(
9856 test_layer->transform_tree_index()); 9858 test_layer->transform_tree_index());
9857 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); 9859 EXPECT_EQ(node->sublayer_scale, gfx::Vector2dF(1.f, 1.f));
9858 9860
9859 gfx::Transform external_transform; 9861 gfx::Transform external_transform;
9860 external_transform.Translate(10, 10); 9862 external_transform.Translate(10, 10);
9861 external_transform.Scale(2, 2); 9863 external_transform.Scale(2, 2);
9862 gfx::Rect external_viewport; 9864 gfx::Rect external_viewport;
9863 gfx::Rect external_clip(layer_size); 9865 gfx::Rect external_clip(layer_size);
9864 bool resourceless_software_draw = false; 9866 bool resourceless_software_draw = false;
9865 host_impl_->SetExternalTilePriorityConstraints(external_viewport, 9867 host_impl_->SetExternalTilePriorityConstraints(external_viewport,
9866 external_transform); 9868 external_transform);
9867 9869
9868 // Transform node's sublayer scale should include the device transform scale. 9870 // Transform node's sublayer scale should include the device transform scale.
9869 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 9871 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
9870 resourceless_software_draw); 9872 resourceless_software_draw);
9871 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( 9873 node = host_impl_->active_tree()->property_trees()->transform_tree.Node(
9872 test_layer->transform_tree_index()); 9874 test_layer->transform_tree_index());
9873 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); 9875 EXPECT_EQ(node->sublayer_scale, gfx::Vector2dF(2.f, 2.f));
9874 9876
9875 // Clear the external transform. 9877 // Clear the external transform.
9876 external_transform = gfx::Transform(); 9878 external_transform = gfx::Transform();
9877 host_impl_->SetExternalTilePriorityConstraints(external_viewport, 9879 host_impl_->SetExternalTilePriorityConstraints(external_viewport,
9878 external_transform); 9880 external_transform);
9879 9881
9880 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 9882 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
9881 resourceless_software_draw); 9883 resourceless_software_draw);
9882 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( 9884 node = host_impl_->active_tree()->property_trees()->transform_tree.Node(
9883 test_layer->transform_tree_index()); 9885 test_layer->transform_tree_index());
9884 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); 9886 EXPECT_EQ(node->sublayer_scale, gfx::Vector2dF(1.f, 1.f));
9885 } 9887 }
9886 9888
9887 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { 9889 TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
9888 const gfx::Size content_size(1000, 1000); 9890 const gfx::Size content_size(1000, 1000);
9889 const gfx::Size viewport_size(50, 100); 9891 const gfx::Size viewport_size(50, 100);
9890 CreateBasicVirtualViewportLayers(viewport_size, content_size); 9892 CreateBasicVirtualViewportLayers(viewport_size, content_size);
9891 9893
9892 DrawFrame(); 9894 DrawFrame();
9893 9895
9894 base::TimeTicks start_time = 9896 base::TimeTicks start_time =
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
10890 DrawFrame(); 10892 DrawFrame();
10891 10893
10892 host_impl_->CreatePendingTree(); 10894 host_impl_->CreatePendingTree();
10893 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); 10895 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f);
10894 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); 10896 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer();
10895 10897
10896 TransformNode* active_tree_node = 10898 TransformNode* active_tree_node =
10897 host_impl_->active_tree()->property_trees()->transform_tree.Node( 10899 host_impl_->active_tree()->property_trees()->transform_tree.Node(
10898 page_scale_layer->transform_tree_index()); 10900 page_scale_layer->transform_tree_index());
10899 // SetPageScaleOnActiveTree also updates the factors in property trees. 10901 // SetPageScaleOnActiveTree also updates the factors in property trees.
10900 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f); 10902 EXPECT_EQ(active_tree_node->post_local_scale_factor, 2.f);
10901 EXPECT_EQ(host_impl_->active_tree()->current_page_scale_factor(), 2.f); 10903 EXPECT_EQ(host_impl_->active_tree()->current_page_scale_factor(), 2.f);
10902 10904
10903 TransformNode* pending_tree_node = 10905 TransformNode* pending_tree_node =
10904 host_impl_->pending_tree()->property_trees()->transform_tree.Node( 10906 host_impl_->pending_tree()->property_trees()->transform_tree.Node(
10905 page_scale_layer->transform_tree_index()); 10907 page_scale_layer->transform_tree_index());
10906 EXPECT_EQ(pending_tree_node->data.post_local_scale_factor, 1.f); 10908 EXPECT_EQ(pending_tree_node->post_local_scale_factor, 1.f);
10907 EXPECT_EQ(host_impl_->pending_tree()->current_page_scale_factor(), 2.f); 10909 EXPECT_EQ(host_impl_->pending_tree()->current_page_scale_factor(), 2.f);
10908 10910
10909 host_impl_->pending_tree()->UpdateDrawProperties(false); 10911 host_impl_->pending_tree()->UpdateDrawProperties(false);
10910 pending_tree_node = 10912 pending_tree_node =
10911 host_impl_->pending_tree()->property_trees()->transform_tree.Node( 10913 host_impl_->pending_tree()->property_trees()->transform_tree.Node(
10912 page_scale_layer->transform_tree_index()); 10914 page_scale_layer->transform_tree_index());
10913 EXPECT_EQ(pending_tree_node->data.post_local_scale_factor, 2.f); 10915 EXPECT_EQ(pending_tree_node->post_local_scale_factor, 2.f);
10914 10916
10915 host_impl_->ActivateSyncTree(); 10917 host_impl_->ActivateSyncTree();
10916 host_impl_->active_tree()->UpdateDrawProperties(false); 10918 host_impl_->active_tree()->UpdateDrawProperties(false);
10917 active_tree_node = 10919 active_tree_node =
10918 host_impl_->active_tree()->property_trees()->transform_tree.Node( 10920 host_impl_->active_tree()->property_trees()->transform_tree.Node(
10919 page_scale_layer->transform_tree_index()); 10921 page_scale_layer->transform_tree_index());
10920 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f); 10922 EXPECT_EQ(active_tree_node->post_local_scale_factor, 2.f);
10921 } 10923 }
10922 10924
10923 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { 10925 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) {
10924 // Checks that the sublayer scale of a transform node in the subtree of the 10926 // Checks that the sublayer scale of a transform node in the subtree of the
10925 // page scale layer is updated without a property tree rebuild. 10927 // page scale layer is updated without a property tree rebuild.
10926 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); 10928 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f);
10927 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); 10929 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100));
10928 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); 10930 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer();
10929 page_scale_layer->test_properties()->AddChild( 10931 page_scale_layer->test_properties()->AddChild(
10930 LayerImpl::Create(host_impl_->active_tree(), 100)); 10932 LayerImpl::Create(host_impl_->active_tree(), 100));
10931 10933
10932 LayerImpl* in_subtree_of_page_scale_layer = 10934 LayerImpl* in_subtree_of_page_scale_layer =
10933 host_impl_->active_tree()->LayerById(100); 10935 host_impl_->active_tree()->LayerById(100);
10934 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = 10936 in_subtree_of_page_scale_layer->test_properties()->force_render_surface =
10935 true; 10937 true;
10936 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 10938 host_impl_->active_tree()->BuildPropertyTreesForTesting();
10937 10939
10938 DrawFrame(); 10940 DrawFrame();
10939 10941
10940 TransformNode* node = 10942 TransformNode* node =
10941 host_impl_->active_tree()->property_trees()->transform_tree.Node( 10943 host_impl_->active_tree()->property_trees()->transform_tree.Node(
10942 in_subtree_of_page_scale_layer->transform_tree_index()); 10944 in_subtree_of_page_scale_layer->transform_tree_index());
10943 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); 10945 EXPECT_EQ(node->sublayer_scale, gfx::Vector2dF(1.f, 1.f));
10944 10946
10945 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); 10947 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f);
10946 10948
10947 DrawFrame(); 10949 DrawFrame();
10948 10950
10949 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); 10951 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100);
10950 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( 10952 node = host_impl_->active_tree()->property_trees()->transform_tree.Node(
10951 in_subtree_of_page_scale_layer->transform_tree_index()); 10953 in_subtree_of_page_scale_layer->transform_tree_index());
10952 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); 10954 EXPECT_EQ(node->sublayer_scale, gfx::Vector2dF(2.f, 2.f));
10953 } 10955 }
10954 10956
10955 TEST_F(LayerTreeHostImplTest, JitterTest) { 10957 TEST_F(LayerTreeHostImplTest, JitterTest) {
10956 host_impl_->SetViewportSize(gfx::Size(100, 100)); 10958 host_impl_->SetViewportSize(gfx::Size(100, 100));
10957 10959
10958 host_impl_->CreatePendingTree(); 10960 host_impl_->CreatePendingTree();
10959 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 10961 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
10960 gfx::Size(100, 100)); 10962 gfx::Size(100, 100));
10961 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 10963 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
10962 10964
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
11044 11046
11045 // Re-initialize with a software output surface. 11047 // Re-initialize with a software output surface.
11046 output_surface_ = FakeOutputSurface::CreateSoftware( 11048 output_surface_ = FakeOutputSurface::CreateSoftware(
11047 base::WrapUnique(new SoftwareOutputDevice)); 11049 base::WrapUnique(new SoftwareOutputDevice));
11048 host_impl_->InitializeRenderer(output_surface_.get()); 11050 host_impl_->InitializeRenderer(output_surface_.get());
11049 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11051 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11050 } 11052 }
11051 11053
11052 } // namespace 11054 } // namespace
11053 } // namespace cc 11055 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698