| 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" |
| 11 #include "cc/animation/animation_host.h" | 11 #include "cc/animation/animation_host.h" |
| 12 #include "cc/layers/append_quads_data.h" | 12 #include "cc/layers/append_quads_data.h" |
| 13 #include "cc/layers/content_layer_client.h" | 13 #include "cc/layers/content_layer_client.h" |
| 14 #include "cc/layers/picture_layer_impl.h" | 14 #include "cc/layers/picture_layer_impl.h" |
| 15 #include "cc/paint/paint_flags.h" | 15 #include "cc/paint/paint_flags.h" |
| 16 #include "cc/test/fake_compositor_frame_sink.h" | 16 #include "cc/test/fake_compositor_frame_sink.h" |
| 17 #include "cc/test/fake_content_layer_client.h" | 17 #include "cc/test/fake_content_layer_client.h" |
| 18 #include "cc/test/fake_layer_tree_host.h" | 18 #include "cc/test/fake_layer_tree_host.h" |
| 19 #include "cc/test/fake_picture_layer.h" | 19 #include "cc/test/fake_picture_layer.h" |
| 20 #include "cc/test/fake_picture_layer_impl.h" | 20 #include "cc/test/fake_picture_layer_impl.h" |
| 21 #include "cc/test/fake_proxy.h" | 21 #include "cc/test/fake_proxy.h" |
| 22 #include "cc/test/fake_recording_source.h" | 22 #include "cc/test/fake_recording_source.h" |
| 23 #include "cc/test/layer_tree_settings_for_testing.h" | |
| 24 #include "cc/test/skia_common.h" | 23 #include "cc/test/skia_common.h" |
| 25 #include "cc/test/stub_layer_tree_host_single_thread_client.h" | 24 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
| 26 #include "cc/test/test_task_graph_runner.h" | 25 #include "cc/test/test_task_graph_runner.h" |
| 27 #include "cc/trees/single_thread_proxy.h" | 26 #include "cc/trees/single_thread_proxy.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "third_party/skia/include/core/SkRefCnt.h" | 29 #include "third_party/skia/include/core/SkRefCnt.h" |
| 31 | 30 |
| 32 namespace cc { | 31 namespace cc { |
| 33 | 32 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 gfx::Rect invalidation_bounds(layer_size); | 94 gfx::Rect invalidation_bounds(layer_size); |
| 96 | 95 |
| 97 // The important two lines are the following: | 96 // The important two lines are the following: |
| 98 layer->SetNeedsDisplayRect(invalidation_bounds); | 97 layer->SetNeedsDisplayRect(invalidation_bounds); |
| 99 layer->Update(); | 98 layer->Update(); |
| 100 | 99 |
| 101 host->CommitComplete(); | 100 host->CommitComplete(); |
| 102 FakeImplTaskRunnerProvider impl_task_runner_provider; | 101 FakeImplTaskRunnerProvider impl_task_runner_provider; |
| 103 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 102 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 104 FakeCompositorFrameSink::Create3d()); | 103 FakeCompositorFrameSink::Create3d()); |
| 105 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); | 104 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 106 layer_tree_settings.image_decode_tasks_enabled = true; | 105 layer_tree_settings.image_decode_tasks_enabled = true; |
| 107 FakeLayerTreeHostImpl host_impl( | 106 FakeLayerTreeHostImpl host_impl( |
| 108 layer_tree_settings, &impl_task_runner_provider, &task_graph_runner); | 107 layer_tree_settings, &impl_task_runner_provider, &task_graph_runner); |
| 109 host_impl.SetVisible(true); | 108 host_impl.SetVisible(true); |
| 110 host_impl.InitializeRenderer(compositor_frame_sink.get()); | 109 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 111 host_impl.CreatePendingTree(); | 110 host_impl.CreatePendingTree(); |
| 112 host_impl.pending_tree()->SetRootLayerForTesting( | 111 host_impl.pending_tree()->SetRootLayerForTesting( |
| 113 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 112 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 114 host_impl.pending_tree()->BuildLayerListForTesting(); | 113 host_impl.pending_tree()->BuildLayerListForTesting(); |
| 115 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( | 114 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 138 | 137 |
| 139 gfx::Rect invalidation_bounds(layer_size); | 138 gfx::Rect invalidation_bounds(layer_size); |
| 140 | 139 |
| 141 // The important line is the following (note that we do not call Update): | 140 // The important line is the following (note that we do not call Update): |
| 142 layer->SetNeedsDisplayRect(invalidation_bounds); | 141 layer->SetNeedsDisplayRect(invalidation_bounds); |
| 143 | 142 |
| 144 host->CommitComplete(); | 143 host->CommitComplete(); |
| 145 FakeImplTaskRunnerProvider impl_task_runner_provider; | 144 FakeImplTaskRunnerProvider impl_task_runner_provider; |
| 146 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 145 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 147 FakeCompositorFrameSink::Create3d()); | 146 FakeCompositorFrameSink::Create3d()); |
| 148 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); | 147 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 149 layer_tree_settings.image_decode_tasks_enabled = true; | 148 layer_tree_settings.image_decode_tasks_enabled = true; |
| 150 FakeLayerTreeHostImpl host_impl( | 149 FakeLayerTreeHostImpl host_impl( |
| 151 layer_tree_settings, &impl_task_runner_provider, &task_graph_runner); | 150 layer_tree_settings, &impl_task_runner_provider, &task_graph_runner); |
| 152 host_impl.SetVisible(true); | 151 host_impl.SetVisible(true); |
| 153 host_impl.InitializeRenderer(compositor_frame_sink.get()); | 152 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 154 host_impl.CreatePendingTree(); | 153 host_impl.CreatePendingTree(); |
| 155 host_impl.pending_tree()->SetRootLayerForTesting( | 154 host_impl.pending_tree()->SetRootLayerForTesting( |
| 156 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 155 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 157 host_impl.pending_tree()->BuildLayerListForTesting(); | 156 host_impl.pending_tree()->BuildLayerListForTesting(); |
| 158 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( | 157 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 185 host->CommitComplete(); | 184 host->CommitComplete(); |
| 186 EXPECT_EQ(1, host->SourceFrameNumber()); | 185 EXPECT_EQ(1, host->SourceFrameNumber()); |
| 187 | 186 |
| 188 layer->SavePaintProperties(); | 187 layer->SavePaintProperties(); |
| 189 layer->Update(); | 188 layer->Update(); |
| 190 | 189 |
| 191 FakeImplTaskRunnerProvider impl_task_runner_provider; | 190 FakeImplTaskRunnerProvider impl_task_runner_provider; |
| 192 | 191 |
| 193 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 192 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 194 FakeCompositorFrameSink::Create3d()); | 193 FakeCompositorFrameSink::Create3d()); |
| 195 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); | 194 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 196 layer_tree_settings.image_decode_tasks_enabled = true; | 195 layer_tree_settings.image_decode_tasks_enabled = true; |
| 197 FakeLayerTreeHostImpl host_impl( | 196 FakeLayerTreeHostImpl host_impl( |
| 198 layer_tree_settings, &impl_task_runner_provider, &task_graph_runner); | 197 layer_tree_settings, &impl_task_runner_provider, &task_graph_runner); |
| 199 host_impl.SetVisible(true); | 198 host_impl.SetVisible(true); |
| 200 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); | 199 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); |
| 201 | 200 |
| 202 host_impl.CreatePendingTree(); | 201 host_impl.CreatePendingTree(); |
| 203 host_impl.pending_tree()->SetRootLayerForTesting( | 202 host_impl.pending_tree()->SetRootLayerForTesting( |
| 204 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); | 203 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 205 host_impl.pending_tree()->BuildLayerListForTesting(); | 204 host_impl.pending_tree()->BuildLayerListForTesting(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Veto gpu rasterization. | 282 // Veto gpu rasterization. |
| 284 layer->set_force_unsuitable_for_gpu_rasterization(true); | 283 layer->set_force_unsuitable_for_gpu_rasterization(true); |
| 285 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 284 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
| 286 } | 285 } |
| 287 | 286 |
| 288 // PicturePile uses the source frame number as a unit for measuring invalidation | 287 // PicturePile uses the source frame number as a unit for measuring invalidation |
| 289 // frequency. When a pile moves between compositors, the frame number increases | 288 // frequency. When a pile moves between compositors, the frame number increases |
| 290 // non-monotonically. This executes that code path under this scenario allowing | 289 // non-monotonically. This executes that code path under this scenario allowing |
| 291 // for the code to verify correctness with DCHECKs. | 290 // for the code to verify correctness with DCHECKs. |
| 292 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 291 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { |
| 293 LayerTreeSettings settings = LayerTreeSettingsForTesting(); | 292 LayerTreeSettings settings = LayerTreeSettings(); |
| 294 settings.single_thread_proxy_scheduler = false; | 293 settings.single_thread_proxy_scheduler = false; |
| 295 settings.use_zero_copy = true; | 294 settings.use_zero_copy = true; |
| 296 | 295 |
| 297 StubLayerTreeHostSingleThreadClient single_thread_client; | 296 StubLayerTreeHostSingleThreadClient single_thread_client; |
| 298 FakeLayerTreeHostClient host_client1; | 297 FakeLayerTreeHostClient host_client1; |
| 299 FakeLayerTreeHostClient host_client2; | 298 FakeLayerTreeHostClient host_client2; |
| 300 TestTaskGraphRunner task_graph_runner; | 299 TestTaskGraphRunner task_graph_runner; |
| 301 | 300 |
| 302 FakeContentLayerClient client; | 301 FakeContentLayerClient client; |
| 303 client.set_bounds(gfx::Size()); | 302 client.set_bounds(gfx::Size()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 host2->Composite(base::TimeTicks::Now()); | 355 host2->Composite(base::TimeTicks::Now()); |
| 357 EXPECT_EQ(3, layer->update_count()); | 356 EXPECT_EQ(3, layer->update_count()); |
| 358 EXPECT_EQ(1, host2->SourceFrameNumber()); | 357 EXPECT_EQ(1, host2->SourceFrameNumber()); |
| 359 | 358 |
| 360 animation_host->SetMutatorHostClient(nullptr); | 359 animation_host->SetMutatorHostClient(nullptr); |
| 361 animation_host2->SetMutatorHostClient(nullptr); | 360 animation_host2->SetMutatorHostClient(nullptr); |
| 362 } | 361 } |
| 363 | 362 |
| 364 } // namespace | 363 } // namespace |
| 365 } // namespace cc | 364 } // namespace cc |
| OLD | NEW |