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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: rebase Created 4 years, 3 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
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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "cc/animation/mutable_properties.h" 7 #include "cc/animation/mutable_properties.h"
8 #include "cc/layers/painted_scrollbar_layer_impl.h" 8 #include "cc/layers/painted_scrollbar_layer_impl.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
10 #include "cc/output/filter_operation.h" 10 #include "cc/output/filter_operation.h"
11 #include "cc/output/filter_operations.h" 11 #include "cc/output/filter_operations.h"
12 #include "cc/test/animation_test_common.h" 12 #include "cc/test/animation_test_common.h"
13 #include "cc/test/fake_compositor_frame_sink.h"
13 #include "cc/test/fake_impl_task_runner_provider.h" 14 #include "cc/test/fake_impl_task_runner_provider.h"
14 #include "cc/test/fake_layer_tree_host_impl.h" 15 #include "cc/test/fake_layer_tree_host_impl.h"
15 #include "cc/test/fake_output_surface.h"
16 #include "cc/test/geometry_test_utils.h" 16 #include "cc/test/geometry_test_utils.h"
17 #include "cc/test/test_shared_bitmap_manager.h" 17 #include "cc/test/test_shared_bitmap_manager.h"
18 #include "cc/test/test_task_graph_runner.h" 18 #include "cc/test/test_task_graph_runner.h"
19 #include "cc/trees/layer_tree_impl.h" 19 #include "cc/trees/layer_tree_impl.h"
20 #include "cc/trees/single_thread_proxy.h" 20 #include "cc/trees/single_thread_proxy.h"
21 #include "cc/trees/tree_synchronizer.h" 21 #include "cc/trees/tree_synchronizer.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 24 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
25 25
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { 119 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
120 // 120 //
121 // This test checks that layerPropertyChanged() has the correct behavior. 121 // This test checks that layerPropertyChanged() has the correct behavior.
122 // 122 //
123 123
124 // The constructor on this will fake that we are on the correct thread. 124 // The constructor on this will fake that we are on the correct thread.
125 // Create a simple LayerImpl tree: 125 // Create a simple LayerImpl tree:
126 FakeImplTaskRunnerProvider task_runner_provider; 126 FakeImplTaskRunnerProvider task_runner_provider;
127 TestSharedBitmapManager shared_bitmap_manager; 127 TestSharedBitmapManager shared_bitmap_manager;
128 TestTaskGraphRunner task_graph_runner; 128 TestTaskGraphRunner task_graph_runner;
129 std::unique_ptr<OutputSurface> output_surface = 129 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
130 FakeOutputSurface::CreateDelegating3d(); 130 FakeCompositorFrameSink::Create3d();
131 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 131 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
132 &task_graph_runner); 132 &task_graph_runner);
133 host_impl.SetVisible(true); 133 host_impl.SetVisible(true);
134 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 134 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
135 std::unique_ptr<LayerImpl> root_clip_ptr = 135 std::unique_ptr<LayerImpl> root_clip_ptr =
136 LayerImpl::Create(host_impl.active_tree(), 1); 136 LayerImpl::Create(host_impl.active_tree(), 1);
137 LayerImpl* root_clip = root_clip_ptr.get(); 137 LayerImpl* root_clip = root_clip_ptr.get();
138 std::unique_ptr<LayerImpl> root_ptr = 138 std::unique_ptr<LayerImpl> root_ptr =
139 LayerImpl::Create(host_impl.active_tree(), 2); 139 LayerImpl::Create(host_impl.active_tree(), 2);
140 LayerImpl* root = root_ptr.get(); 140 LayerImpl* root = root_ptr.get();
141 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr)); 141 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr));
142 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_clip_ptr)); 142 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_clip_ptr));
143 143
144 root->test_properties()->force_render_surface = true; 144 root->test_properties()->force_render_surface = true;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); 239 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1));
240 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); 240 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true));
241 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); 241 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true));
242 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); 242 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size));
243 } 243 }
244 244
245 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { 245 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
246 FakeImplTaskRunnerProvider task_runner_provider; 246 FakeImplTaskRunnerProvider task_runner_provider;
247 TestSharedBitmapManager shared_bitmap_manager; 247 TestSharedBitmapManager shared_bitmap_manager;
248 TestTaskGraphRunner task_graph_runner; 248 TestTaskGraphRunner task_graph_runner;
249 std::unique_ptr<OutputSurface> output_surface = 249 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
250 FakeOutputSurface::CreateDelegating3d(); 250 FakeCompositorFrameSink::Create3d();
251 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 251 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
252 &task_graph_runner); 252 &task_graph_runner);
253 host_impl.SetVisible(true); 253 host_impl.SetVisible(true);
254 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 254 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
255 host_impl.active_tree()->SetRootLayerForTesting( 255 host_impl.active_tree()->SetRootLayerForTesting(
256 LayerImpl::Create(host_impl.active_tree(), 1)); 256 LayerImpl::Create(host_impl.active_tree(), 1));
257 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing(); 257 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing();
258 root->SetHasRenderSurface(true); 258 root->SetHasRenderSurface(true);
259 std::unique_ptr<LayerImpl> layer_ptr = 259 std::unique_ptr<LayerImpl> layer_ptr =
260 LayerImpl::Create(host_impl.active_tree(), 2); 260 LayerImpl::Create(host_impl.active_tree(), 2);
261 LayerImpl* layer = layer_ptr.get(); 261 LayerImpl* layer = layer_ptr.get();
262 root->test_properties()->AddChild(std::move(layer_ptr)); 262 root->test_properties()->AddChild(std::move(layer_ptr));
263 layer->SetScrollClipLayer(root->id()); 263 layer->SetScrollClipLayer(root->id());
264 std::unique_ptr<LayerImpl> layer2_ptr = 264 std::unique_ptr<LayerImpl> layer2_ptr =
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 370 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
371 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0))); 371 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0)));
372 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 372 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
373 layer->SetMutableProperties(MutableProperty::kTransform)); 373 layer->SetMutableProperties(MutableProperty::kTransform));
374 } 374 }
375 375
376 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { 376 TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
377 FakeImplTaskRunnerProvider task_runner_provider; 377 FakeImplTaskRunnerProvider task_runner_provider;
378 TestSharedBitmapManager shared_bitmap_manager; 378 TestSharedBitmapManager shared_bitmap_manager;
379 TestTaskGraphRunner task_graph_runner; 379 TestTaskGraphRunner task_graph_runner;
380 std::unique_ptr<OutputSurface> output_surface = 380 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
381 FakeOutputSurface::CreateDelegating3d(); 381 FakeCompositorFrameSink::Create3d();
382 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 382 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
383 &task_graph_runner); 383 &task_graph_runner);
384 host_impl.SetVisible(true); 384 host_impl.SetVisible(true);
385 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 385 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
386 host_impl.active_tree()->SetRootLayerForTesting( 386 host_impl.active_tree()->SetRootLayerForTesting(
387 LayerImpl::Create(host_impl.active_tree(), 1)); 387 LayerImpl::Create(host_impl.active_tree(), 1));
388 LayerImpl* layer = host_impl.active_tree()->root_layer_for_testing(); 388 LayerImpl* layer = host_impl.active_tree()->root_layer_for_testing();
389 389
390 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { 390 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) {
391 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { 391 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) {
392 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { 392 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) {
393 layer->SetContentsOpaque(!!contents_opaque); 393 layer->SetContentsOpaque(!!contents_opaque);
394 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED 394 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED
395 : SK_ColorTRANSPARENT); 395 : SK_ColorTRANSPARENT);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 pending_layer->PushPropertiesTo(layer()); 595 pending_layer->PushPropertiesTo(layer());
596 596
597 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 597 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
598 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 598 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
599 pending_layer->CurrentScrollOffset()); 599 pending_layer->CurrentScrollOffset());
600 } 600 }
601 601
602 } // namespace 602 } // namespace
603 } // namespace cc 603 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698