| 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_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 host_impl()->CommitComplete(); | 2332 host_impl()->CommitComplete(); |
| 2333 EXPECT_EQ(1u, pending_layer()->release_tile_resources_count()); | 2333 EXPECT_EQ(1u, pending_layer()->release_tile_resources_count()); |
| 2334 EXPECT_EQ(1u, active_layer()->release_tile_resources_count()); | 2334 EXPECT_EQ(1u, active_layer()->release_tile_resources_count()); |
| 2335 EXPECT_EQ(1u, pending_layer()->release_resources_count()); | 2335 EXPECT_EQ(1u, pending_layer()->release_resources_count()); |
| 2336 EXPECT_EQ(1u, active_layer()->release_resources_count()); | 2336 EXPECT_EQ(1u, active_layer()->release_resources_count()); |
| 2337 | 2337 |
| 2338 // But the pending layer gets a tiling back, and can activate it. | 2338 // But the pending layer gets a tiling back, and can activate it. |
| 2339 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScaleKey(1.f)); | 2339 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScaleKey(1.f)); |
| 2340 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 2340 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 2341 | 2341 |
| 2342 host_impl()->NotifyReadyToActivate(); |
| 2342 ActivateTree(); | 2343 ActivateTree(); |
| 2343 EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScaleKey(1.f)); | 2344 EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScaleKey(1.f)); |
| 2344 | 2345 |
| 2345 SetupPendingTree(pending_raster_source); | 2346 SetupPendingTree(pending_raster_source); |
| 2346 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScaleKey(1.f)); | 2347 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScaleKey(1.f)); |
| 2347 | 2348 |
| 2348 // Toggling the gpu rasterization clears all tilings on both trees. | 2349 // Toggling the gpu rasterization clears all tilings on both trees. |
| 2349 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); | 2350 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); |
| 2350 host_impl()->SetHasGpuRasterizationTrigger(false); | 2351 host_impl()->SetHasGpuRasterizationTrigger(false); |
| 2351 host_impl()->CommitComplete(); | 2352 host_impl()->CommitComplete(); |
| 2352 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, | 2353 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, |
| 2353 host_impl()->gpu_rasterization_status()); | 2354 host_impl()->gpu_rasterization_status()); |
| 2354 EXPECT_EQ(2u, pending_layer()->release_tile_resources_count()); | 2355 EXPECT_EQ(2u, pending_layer()->release_tile_resources_count()); |
| 2355 EXPECT_EQ(2u, active_layer()->release_tile_resources_count()); | 2356 EXPECT_EQ(2u, active_layer()->release_tile_resources_count()); |
| 2356 EXPECT_EQ(2u, pending_layer()->release_resources_count()); | 2357 EXPECT_EQ(2u, pending_layer()->release_resources_count()); |
| 2357 EXPECT_EQ(2u, active_layer()->release_resources_count()); | 2358 EXPECT_EQ(2u, active_layer()->release_resources_count()); |
| 2359 host_impl()->NotifyReadyToActivate(); |
| 2358 | 2360 |
| 2359 host_impl()->SetHasGpuRasterizationTrigger(true); | 2361 host_impl()->SetHasGpuRasterizationTrigger(true); |
| 2360 host_impl()->SetContentIsSuitableForGpuRasterization(false); | 2362 host_impl()->SetContentIsSuitableForGpuRasterization(false); |
| 2361 host_impl()->CommitComplete(); | 2363 host_impl()->CommitComplete(); |
| 2362 EXPECT_EQ(GpuRasterizationStatus::ON, | 2364 EXPECT_EQ(GpuRasterizationStatus::ON, |
| 2363 host_impl()->gpu_rasterization_status()); | 2365 host_impl()->gpu_rasterization_status()); |
| 2364 } | 2366 } |
| 2365 | 2367 |
| 2366 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { | 2368 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { |
| 2367 // Put 0.5 as high res. | 2369 // Put 0.5 as high res. |
| (...skipping 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4731 FakePictureLayerImpl::Create(pending_tree, layer_id()); | 4733 FakePictureLayerImpl::Create(pending_tree, layer_id()); |
| 4732 | 4734 |
| 4733 host_impl()->SetViewportSize(gfx::Size(1000, 1000)); | 4735 host_impl()->SetViewportSize(gfx::Size(1000, 1000)); |
| 4734 gfx::Size result; | 4736 gfx::Size result; |
| 4735 | 4737 |
| 4736 host_impl()->SetContentIsSuitableForGpuRasterization(true); | 4738 host_impl()->SetContentIsSuitableForGpuRasterization(true); |
| 4737 host_impl()->SetHasGpuRasterizationTrigger(false); | 4739 host_impl()->SetHasGpuRasterizationTrigger(false); |
| 4738 host_impl()->CommitComplete(); | 4740 host_impl()->CommitComplete(); |
| 4739 EXPECT_EQ(host_impl()->gpu_rasterization_status(), | 4741 EXPECT_EQ(host_impl()->gpu_rasterization_status(), |
| 4740 GpuRasterizationStatus::OFF_VIEWPORT); | 4742 GpuRasterizationStatus::OFF_VIEWPORT); |
| 4743 host_impl()->NotifyReadyToActivate(); |
| 4741 | 4744 |
| 4742 // Default tile-size for large layers. | 4745 // Default tile-size for large layers. |
| 4743 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4746 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
| 4744 EXPECT_EQ(result.width(), 100); | 4747 EXPECT_EQ(result.width(), 100); |
| 4745 EXPECT_EQ(result.height(), 100); | 4748 EXPECT_EQ(result.height(), 100); |
| 4746 // Don't tile and round-up, when under max_untiled_layer_size. | 4749 // Don't tile and round-up, when under max_untiled_layer_size. |
| 4747 result = layer->CalculateTileSize(gfx::Size(42, 42)); | 4750 result = layer->CalculateTileSize(gfx::Size(42, 42)); |
| 4748 EXPECT_EQ(result.width(), 64); | 4751 EXPECT_EQ(result.width(), 64); |
| 4749 EXPECT_EQ(result.height(), 64); | 4752 EXPECT_EQ(result.height(), 64); |
| 4750 result = layer->CalculateTileSize(gfx::Size(191, 191)); | 4753 result = layer->CalculateTileSize(gfx::Size(191, 191)); |
| 4751 EXPECT_EQ(result.width(), 192); | 4754 EXPECT_EQ(result.width(), 192); |
| 4752 EXPECT_EQ(result.height(), 192); | 4755 EXPECT_EQ(result.height(), 192); |
| 4753 result = layer->CalculateTileSize(gfx::Size(199, 199)); | 4756 result = layer->CalculateTileSize(gfx::Size(199, 199)); |
| 4754 EXPECT_EQ(result.width(), 200); | 4757 EXPECT_EQ(result.width(), 200); |
| 4755 EXPECT_EQ(result.height(), 200); | 4758 EXPECT_EQ(result.height(), 200); |
| 4756 | 4759 |
| 4757 // Gpu-rasterization uses 25% viewport-height tiles. | 4760 // Gpu-rasterization uses 25% viewport-height tiles. |
| 4758 // The +2's below are for border texels. | 4761 // The +2's below are for border texels. |
| 4759 host_impl()->SetHasGpuRasterizationTrigger(true); | 4762 host_impl()->SetHasGpuRasterizationTrigger(true); |
| 4760 host_impl()->CommitComplete(); | 4763 host_impl()->CommitComplete(); |
| 4761 EXPECT_EQ(host_impl()->gpu_rasterization_status(), | 4764 EXPECT_EQ(host_impl()->gpu_rasterization_status(), |
| 4762 GpuRasterizationStatus::ON); | 4765 GpuRasterizationStatus::ON); |
| 4763 host_impl()->SetViewportSize(gfx::Size(2000, 2000)); | 4766 host_impl()->SetViewportSize(gfx::Size(2000, 2000)); |
| 4767 host_impl()->NotifyReadyToActivate(); |
| 4764 | 4768 |
| 4765 layer->set_gpu_raster_max_texture_size(host_impl()->device_viewport_size()); | 4769 layer->set_gpu_raster_max_texture_size(host_impl()->device_viewport_size()); |
| 4766 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4770 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
| 4767 EXPECT_EQ(result.width(), | 4771 EXPECT_EQ(result.width(), |
| 4768 MathUtil::UncheckedRoundUp( | 4772 MathUtil::UncheckedRoundUp( |
| 4769 2000 + 2 * PictureLayerTiling::kBorderTexels, 32)); | 4773 2000 + 2 * PictureLayerTiling::kBorderTexels, 32)); |
| 4770 EXPECT_EQ(result.height(), 512); // 500 + 2, 32-byte aligned. | 4774 EXPECT_EQ(result.height(), 512); // 500 + 2, 32-byte aligned. |
| 4771 | 4775 |
| 4772 // Clamp and round-up, when smaller than viewport. | 4776 // Clamp and round-up, when smaller than viewport. |
| 4773 // Tile-height doubles to 50% when width shrinks to <= 50%. | 4777 // Tile-height doubles to 50% when width shrinks to <= 50%. |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5145 EXPECT_EQ(gfx::AxisTransform2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), | 5149 EXPECT_EQ(gfx::AxisTransform2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), |
| 5146 tiling->raster_transform()); | 5150 tiling->raster_transform()); |
| 5147 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | 5151 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| 5148 for (auto* tile : tiling->AllTilesForTesting()) | 5152 for (auto* tile : tiling->AllTilesForTesting()) |
| 5149 EXPECT_EQ(tile->raster_transform(), tiling->raster_transform()); | 5153 EXPECT_EQ(tile->raster_transform(), tiling->raster_transform()); |
| 5150 } | 5154 } |
| 5151 } | 5155 } |
| 5152 | 5156 |
| 5153 } // namespace | 5157 } // namespace |
| 5154 } // namespace cc | 5158 } // namespace cc |
| OLD | NEW |