OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 gfx::Size recording_source_viewport_; | 125 gfx::Size recording_source_viewport_; |
126 | 126 |
127 DISALLOW_COPY_AND_ASSIGN(TestSerializationPictureLayer); | 127 DISALLOW_COPY_AND_ASSIGN(TestSerializationPictureLayer); |
128 }; | 128 }; |
129 | 129 |
130 namespace { | 130 namespace { |
131 | 131 |
132 TEST(PictureLayerTest, TestSetAllPropsSerializationDeserialization) { | 132 TEST(PictureLayerTest, TestSetAllPropsSerializationDeserialization) { |
133 FakeLayerTreeHostClient host_client; | 133 FakeLayerTreeHostClient host_client; |
134 TestTaskGraphRunner task_graph_runner; | 134 TestTaskGraphRunner task_graph_runner; |
135 LayerTreeSettings settings; | 135 LayerTreeSettings settings = LayerTreeSettingsForTesting(); |
136 std::unique_ptr<FakeImageSerializationProcessor> | 136 std::unique_ptr<FakeImageSerializationProcessor> |
137 fake_image_serialization_processor = | 137 fake_image_serialization_processor = |
138 base::WrapUnique(new FakeImageSerializationProcessor); | 138 base::WrapUnique(new FakeImageSerializationProcessor); |
139 std::unique_ptr<FakeLayerTreeHost> host = | 139 std::unique_ptr<FakeLayerTreeHost> host = |
140 FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings, | 140 FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings, |
141 CompositorMode::SINGLE_THREADED, | 141 CompositorMode::SINGLE_THREADED, |
142 fake_image_serialization_processor.get()); | 142 fake_image_serialization_processor.get()); |
143 host->InitializePictureCacheForTesting(); | 143 host->InitializePictureCacheForTesting(); |
144 | 144 |
145 gfx::Size recording_source_viewport(256, 256); | 145 gfx::Size recording_source_viewport(256, 256); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 // The important two lines are the following: | 275 // The important two lines are the following: |
276 layer->SetNeedsDisplayRect(invalidation_bounds); | 276 layer->SetNeedsDisplayRect(invalidation_bounds); |
277 layer->Update(); | 277 layer->Update(); |
278 | 278 |
279 host->CommitComplete(); | 279 host->CommitComplete(); |
280 FakeImplTaskRunnerProvider impl_task_runner_provider; | 280 FakeImplTaskRunnerProvider impl_task_runner_provider; |
281 TestSharedBitmapManager shared_bitmap_manager; | 281 TestSharedBitmapManager shared_bitmap_manager; |
282 std::unique_ptr<OutputSurface> output_surface( | 282 std::unique_ptr<OutputSurface> output_surface( |
283 FakeOutputSurface::CreateDelegating3d()); | 283 FakeOutputSurface::CreateDelegating3d()); |
284 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); | 284 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); |
285 layer_tree_settings.image_decode_tasks_enabled = true; | 285 layer_tree_settings.image_decode_tasks_enabled = true; |
286 FakeLayerTreeHostImpl host_impl(layer_tree_settings, | 286 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
287 &impl_task_runner_provider, | 287 &impl_task_runner_provider, |
288 &shared_bitmap_manager, &task_graph_runner); | 288 &shared_bitmap_manager, &task_graph_runner); |
289 host_impl.SetVisible(true); | 289 host_impl.SetVisible(true); |
290 host_impl.InitializeRenderer(output_surface.get()); | 290 host_impl.InitializeRenderer(output_surface.get()); |
291 host_impl.CreatePendingTree(); | 291 host_impl.CreatePendingTree(); |
292 host_impl.pending_tree()->SetRootLayerForTesting( | 292 host_impl.pending_tree()->SetRootLayerForTesting( |
293 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 293 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
294 host_impl.pending_tree()->BuildLayerListForTesting(); | 294 host_impl.pending_tree()->BuildLayerListForTesting(); |
(...skipping 23 matching lines...) Expand all Loading... |
318 gfx::Rect invalidation_bounds(layer_size); | 318 gfx::Rect invalidation_bounds(layer_size); |
319 | 319 |
320 // The important line is the following (note that we do not call Update): | 320 // The important line is the following (note that we do not call Update): |
321 layer->SetNeedsDisplayRect(invalidation_bounds); | 321 layer->SetNeedsDisplayRect(invalidation_bounds); |
322 | 322 |
323 host->CommitComplete(); | 323 host->CommitComplete(); |
324 FakeImplTaskRunnerProvider impl_task_runner_provider; | 324 FakeImplTaskRunnerProvider impl_task_runner_provider; |
325 TestSharedBitmapManager shared_bitmap_manager; | 325 TestSharedBitmapManager shared_bitmap_manager; |
326 std::unique_ptr<OutputSurface> output_surface( | 326 std::unique_ptr<OutputSurface> output_surface( |
327 FakeOutputSurface::CreateDelegating3d()); | 327 FakeOutputSurface::CreateDelegating3d()); |
328 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); | 328 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); |
329 layer_tree_settings.image_decode_tasks_enabled = true; | 329 layer_tree_settings.image_decode_tasks_enabled = true; |
330 FakeLayerTreeHostImpl host_impl(layer_tree_settings, | 330 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
331 &impl_task_runner_provider, | 331 &impl_task_runner_provider, |
332 &shared_bitmap_manager, &task_graph_runner); | 332 &shared_bitmap_manager, &task_graph_runner); |
333 host_impl.SetVisible(true); | 333 host_impl.SetVisible(true); |
334 host_impl.InitializeRenderer(output_surface.get()); | 334 host_impl.InitializeRenderer(output_surface.get()); |
335 host_impl.CreatePendingTree(); | 335 host_impl.CreatePendingTree(); |
336 host_impl.pending_tree()->SetRootLayerForTesting( | 336 host_impl.pending_tree()->SetRootLayerForTesting( |
337 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 337 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
338 host_impl.pending_tree()->BuildLayerListForTesting(); | 338 host_impl.pending_tree()->BuildLayerListForTesting(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 recording_source->SetForceUnsuitableForGpuRasterization(true); | 455 recording_source->SetForceUnsuitableForGpuRasterization(true); |
456 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 456 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
457 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 457 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
458 } | 458 } |
459 | 459 |
460 // PicturePile uses the source frame number as a unit for measuring invalidation | 460 // PicturePile uses the source frame number as a unit for measuring invalidation |
461 // frequency. When a pile moves between compositors, the frame number increases | 461 // frequency. When a pile moves between compositors, the frame number increases |
462 // non-monotonically. This executes that code path under this scenario allowing | 462 // non-monotonically. This executes that code path under this scenario allowing |
463 // for the code to verify correctness with DCHECKs. | 463 // for the code to verify correctness with DCHECKs. |
464 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 464 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { |
465 LayerTreeSettings settings; | 465 LayerTreeSettings settings = LayerTreeSettingsForTesting(); |
466 settings.single_thread_proxy_scheduler = false; | 466 settings.single_thread_proxy_scheduler = false; |
467 settings.use_zero_copy = true; | 467 settings.use_zero_copy = true; |
468 settings.verify_clip_tree_calculations = true; | |
469 settings.verify_transform_tree_calculations = true; | |
470 | 468 |
471 StubLayerTreeHostSingleThreadClient single_thread_client; | 469 StubLayerTreeHostSingleThreadClient single_thread_client; |
472 FakeLayerTreeHostClient host_client1; | 470 FakeLayerTreeHostClient host_client1; |
473 FakeLayerTreeHostClient host_client2; | 471 FakeLayerTreeHostClient host_client2; |
474 TestSharedBitmapManager shared_bitmap_manager; | 472 TestSharedBitmapManager shared_bitmap_manager; |
475 TestTaskGraphRunner task_graph_runner; | 473 TestTaskGraphRunner task_graph_runner; |
476 | 474 |
477 ContentLayerClient* client = EmptyContentLayerClient::GetInstance(); | 475 ContentLayerClient* client = EmptyContentLayerClient::GetInstance(); |
478 scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(client); | 476 scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(client); |
479 | 477 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // Do a main frame, record the picture layers. The frame number has changed | 524 // Do a main frame, record the picture layers. The frame number has changed |
527 // non-monotonically. | 525 // non-monotonically. |
528 layer->SetNeedsDisplay(); | 526 layer->SetNeedsDisplay(); |
529 host2->Composite(base::TimeTicks::Now()); | 527 host2->Composite(base::TimeTicks::Now()); |
530 EXPECT_EQ(3, layer->update_count()); | 528 EXPECT_EQ(3, layer->update_count()); |
531 EXPECT_EQ(1, host2->source_frame_number()); | 529 EXPECT_EQ(1, host2->source_frame_number()); |
532 } | 530 } |
533 | 531 |
534 } // namespace | 532 } // namespace |
535 } // namespace cc | 533 } // namespace cc |
OLD | NEW |