| OLD | NEW |
| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 did_request_next_frame_(false), | 121 did_request_next_frame_(false), |
| 122 did_request_prepare_tiles_(false), | 122 did_request_prepare_tiles_(false), |
| 123 did_complete_page_scale_animation_(false), | 123 did_complete_page_scale_animation_(false), |
| 124 reduce_memory_result_(true), | 124 reduce_memory_result_(true), |
| 125 did_request_impl_side_invalidation_(false) { | 125 did_request_impl_side_invalidation_(false) { |
| 126 media::InitializeMediaLibrary(); | 126 media::InitializeMediaLibrary(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 LayerTreeSettings DefaultSettings() { | 129 LayerTreeSettings DefaultSettings() { |
| 130 LayerTreeSettings settings; | 130 LayerTreeSettings settings; |
| 131 settings.enable_surface_synchronization = true; |
| 131 settings.minimum_occlusion_tracking_size = gfx::Size(); | 132 settings.minimum_occlusion_tracking_size = gfx::Size(); |
| 132 settings.renderer_settings.texture_id_allocation_chunk_size = 1; | 133 settings.renderer_settings.texture_id_allocation_chunk_size = 1; |
| 133 settings.renderer_settings.buffer_to_texture_target_map = | 134 settings.renderer_settings.buffer_to_texture_target_map = |
| 134 DefaultBufferToTextureTargetMapForTesting(); | 135 DefaultBufferToTextureTargetMapForTesting(); |
| 135 return settings; | 136 return settings; |
| 136 } | 137 } |
| 137 | 138 |
| 138 void SetUp() override { | 139 void SetUp() override { |
| 139 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); | 140 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); |
| 140 } | 141 } |
| (...skipping 3305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3446 } | 3447 } |
| 3447 | 3448 |
| 3448 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { | 3449 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { |
| 3449 SetupMouseMoveAtWithDeviceScale(1.f); | 3450 SetupMouseMoveAtWithDeviceScale(1.f); |
| 3450 } | 3451 } |
| 3451 | 3452 |
| 3452 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { | 3453 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { |
| 3453 SetupMouseMoveAtWithDeviceScale(2.f); | 3454 SetupMouseMoveAtWithDeviceScale(2.f); |
| 3454 } | 3455 } |
| 3455 | 3456 |
| 3456 // This test verifies that only SurfaceLayers in the viewport are included | 3457 // This test verifies that only SurfaceLayers in the viewport and have fallbacks |
| 3457 // in CompositorFrameMetadata's |activation_dependencies|. | 3458 // that are different are included in CompositorFrameMetadata's |
| 3458 TEST_F(LayerTreeHostImplTest, EmbeddedSurfacesInMetadata) { | 3459 // |activation_dependencies|. |
| 3460 TEST_F(LayerTreeHostImplTest, ActivationDependenciesInMetadata) { |
| 3459 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 3461 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 3460 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 3462 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 3461 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 3463 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 3462 | 3464 |
| 3463 std::vector<SurfaceId> children = {MakeSurfaceId(FrameSinkId(1, 1), 1), | 3465 std::vector<SurfaceId> primary_surfaces = { |
| 3464 MakeSurfaceId(FrameSinkId(2, 2), 2), | 3466 MakeSurfaceId(FrameSinkId(1, 1), 1), MakeSurfaceId(FrameSinkId(2, 2), 2), |
| 3465 MakeSurfaceId(FrameSinkId(3, 3), 3)}; | 3467 MakeSurfaceId(FrameSinkId(3, 3), 3)}; |
| 3466 for (size_t i = 0; i < children.size(); ++i) { | 3468 |
| 3469 std::vector<SurfaceId> fallback_surfaces = { |
| 3470 MakeSurfaceId(FrameSinkId(4, 4), 1), MakeSurfaceId(FrameSinkId(4, 4), 2), |
| 3471 MakeSurfaceId(FrameSinkId(4, 4), 3)}; |
| 3472 |
| 3473 for (size_t i = 0; i < primary_surfaces.size(); ++i) { |
| 3467 std::unique_ptr<SurfaceLayerImpl> child = | 3474 std::unique_ptr<SurfaceLayerImpl> child = |
| 3468 SurfaceLayerImpl::Create(host_impl_->active_tree(), i + 6); | 3475 SurfaceLayerImpl::Create(host_impl_->active_tree(), i + 6); |
| 3469 child->SetPosition(gfx::PointF(25.f * i, 0.f)); | 3476 child->SetPosition(gfx::PointF(25.f * i, 0.f)); |
| 3470 child->SetBounds(gfx::Size(1, 1)); | 3477 child->SetBounds(gfx::Size(1, 1)); |
| 3471 child->SetDrawsContent(true); | 3478 child->SetDrawsContent(true); |
| 3472 child->SetPrimarySurfaceInfo( | 3479 child->SetPrimarySurfaceInfo( |
| 3473 SurfaceInfo(children[i], 1.f /* device_scale_factor */, | 3480 SurfaceInfo(primary_surfaces[i], 1.f /* device_scale_factor */, |
| 3481 gfx::Size(10, 10) /* size_in_pixels */)); |
| 3482 child->SetFallbackSurfaceInfo( |
| 3483 SurfaceInfo(fallback_surfaces[i], 1.f /* device_scale_factor */, |
| 3474 gfx::Size(10, 10) /* size_in_pixels */)); | 3484 gfx::Size(10, 10) /* size_in_pixels */)); |
| 3475 root->test_properties()->AddChild(std::move(child)); | 3485 root->test_properties()->AddChild(std::move(child)); |
| 3476 } | 3486 } |
| 3477 | 3487 |
| 3478 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3488 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3479 DrawFrame(); | 3489 DrawFrame(); |
| 3480 | 3490 |
| 3481 FakeCompositorFrameSink* fake_compositor_frame_sink = | 3491 FakeCompositorFrameSink* fake_compositor_frame_sink = |
| 3482 static_cast<FakeCompositorFrameSink*>( | 3492 static_cast<FakeCompositorFrameSink*>( |
| 3483 host_impl_->compositor_frame_sink()); | 3493 host_impl_->compositor_frame_sink()); |
| 3484 const CompositorFrameMetadata& metadata = | 3494 const CompositorFrameMetadata& metadata = |
| 3485 fake_compositor_frame_sink->last_sent_frame()->metadata; | 3495 fake_compositor_frame_sink->last_sent_frame()->metadata; |
| 3486 EXPECT_THAT(metadata.activation_dependencies, | 3496 EXPECT_THAT( |
| 3487 testing::UnorderedElementsAre(children[0], children[1])); | 3497 metadata.activation_dependencies, |
| 3498 testing::UnorderedElementsAre(primary_surfaces[0], primary_surfaces[1])); |
| 3488 EXPECT_THAT( | 3499 EXPECT_THAT( |
| 3489 metadata.referenced_surfaces, | 3500 metadata.referenced_surfaces, |
| 3490 testing::UnorderedElementsAre(children[0], children[1], children[2])); | 3501 testing::UnorderedElementsAre(fallback_surfaces[0], fallback_surfaces[1], |
| 3502 fallback_surfaces[2])); |
| 3491 } | 3503 } |
| 3492 | 3504 |
| 3493 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { | 3505 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { |
| 3494 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 3506 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 3495 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 3507 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 3496 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 3508 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 3497 DrawFrame(); | 3509 DrawFrame(); |
| 3498 { | 3510 { |
| 3499 CompositorFrameMetadata metadata = | 3511 CompositorFrameMetadata metadata = |
| 3500 host_impl_->MakeCompositorFrameMetadata(); | 3512 host_impl_->MakeCompositorFrameMetadata(); |
| (...skipping 8890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12391 | 12403 |
| 12392 TEST_F(LayerTreeHostImplTest, RasterColorSpace) { | 12404 TEST_F(LayerTreeHostImplTest, RasterColorSpace) { |
| 12393 LayerTreeSettings settings = DefaultSettings(); | 12405 LayerTreeSettings settings = DefaultSettings(); |
| 12394 settings.enable_color_correct_rasterization = true; | 12406 settings.enable_color_correct_rasterization = true; |
| 12395 CreateHostImpl(settings, CreateCompositorFrameSink()); | 12407 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 12396 EXPECT_EQ(host_impl_->GetRasterColorSpace(), gfx::ColorSpace::CreateSRGB()); | 12408 EXPECT_EQ(host_impl_->GetRasterColorSpace(), gfx::ColorSpace::CreateSRGB()); |
| 12397 } | 12409 } |
| 12398 | 12410 |
| 12399 } // namespace | 12411 } // namespace |
| 12400 } // namespace cc | 12412 } // namespace cc |
| OLD | NEW |