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

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

Issue 1134123005: cc: split UpdateGpuRasterizationStatus() into two parts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes per review comments Created 5 years, 7 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
« no previous file with comments | « no previous file | cc/trees/layer_tree_host.cc » ('j') | cc/trees/layer_tree_host_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2429 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2430 2430
2431 SetupTrees(pending_pile, active_pile); 2431 SetupTrees(pending_pile, active_pile);
2432 2432
2433 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2433 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2434 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); 2434 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f));
2435 2435
2436 // Gpu rasterization is disabled by default. 2436 // Gpu rasterization is disabled by default.
2437 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); 2437 EXPECT_FALSE(host_impl_.use_gpu_rasterization());
2438 // Toggling the gpu rasterization clears all tilings on both trees. 2438 // Toggling the gpu rasterization clears all tilings on both trees.
2439 host_impl_.set_has_gpu_rasterization_trigger(true); 2439 host_impl_.SetHasGpuRasterizationTrigger(true);
2440 host_impl_.set_content_is_suitable_for_gpu_rasterization(true); 2440 host_impl_.SetContentIsSuitableForGpuRasterization(true);
2441 host_impl_.UpdateGpuRasterizationStatus(); 2441 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded();
2442 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 2442 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2443 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 2443 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
2444 2444
2445 // Make sure that we can still add tiling to the pending layer, 2445 // Make sure that we can still add tiling to the pending layer,
2446 // that gets synced to the active layer. 2446 // that gets synced to the active layer.
2447 time_ticks += base::TimeDelta::FromMilliseconds(1); 2447 time_ticks += base::TimeDelta::FromMilliseconds(1);
2448 host_impl_.SetCurrentBeginFrameArgs( 2448 host_impl_.SetCurrentBeginFrameArgs(
2449 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 2449 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2450 bool update_lcd_text = false; 2450 bool update_lcd_text = false;
2451 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 2451 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
2452 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2452 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2453 2453
2454 ActivateTree(); 2454 ActivateTree();
2455 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); 2455 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f));
2456 2456
2457 SetupPendingTree(pending_pile); 2457 SetupPendingTree(pending_pile);
2458 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2458 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2459 2459
2460 // Toggling the gpu rasterization clears all tilings on both trees. 2460 // Toggling the gpu rasterization clears all tilings on both trees.
2461 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); 2461 EXPECT_TRUE(host_impl_.use_gpu_rasterization());
2462 host_impl_.set_has_gpu_rasterization_trigger(false); 2462 host_impl_.SetHasGpuRasterizationTrigger(false);
2463 host_impl_.UpdateGpuRasterizationStatus(); 2463 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded();
2464 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, 2464 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT,
2465 host_impl_.gpu_rasterization_status()); 2465 host_impl_.gpu_rasterization_status());
2466 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 2466 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2467 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 2467 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
2468 2468
2469 host_impl_.set_has_gpu_rasterization_trigger(true); 2469 host_impl_.SetHasGpuRasterizationTrigger(true);
2470 host_impl_.set_content_is_suitable_for_gpu_rasterization(false); 2470 host_impl_.SetContentIsSuitableForGpuRasterization(false);
2471 host_impl_.UpdateGpuRasterizationStatus();
2472 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 2471 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT,
2473 host_impl_.gpu_rasterization_status()); 2472 host_impl_.gpu_rasterization_status());
2474 } 2473 }
2475 2474
2476 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { 2475 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) {
2477 gfx::Size tile_size(100, 100); 2476 gfx::Size tile_size(100, 100);
2478 2477
2479 // Put 0.5 as high res. 2478 // Put 0.5 as high res.
2480 host_impl_.SetDeviceScaleFactor(0.5f); 2479 host_impl_.SetDeviceScaleFactor(0.5f);
2481 2480
(...skipping 25 matching lines...) Expand all
2507 pending_layer_->tilings()->FindTilingWithScale(1.0f); 2506 pending_layer_->tilings()->FindTilingWithScale(1.0f);
2508 ASSERT_TRUE(tiling); 2507 ASSERT_TRUE(tiling);
2509 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); 2508 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution());
2510 } 2509 }
2511 2510
2512 TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) { 2511 TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) {
2513 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); 2512 gfx::Size default_tile_size(host_impl_.settings().default_tile_size);
2514 gfx::Size layer_bounds(default_tile_size.width() * 4, 2513 gfx::Size layer_bounds(default_tile_size.width() * 4,
2515 default_tile_size.height() * 4); 2514 default_tile_size.height() * 4);
2516 2515
2517 host_impl_.set_has_gpu_rasterization_trigger(false); 2516 host_impl_.SetHasGpuRasterizationTrigger(false);
2518 host_impl_.UpdateGpuRasterizationStatus();
2519 2517
2520 SetupDefaultTrees(layer_bounds); 2518 SetupDefaultTrees(layer_bounds);
2521 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); 2519 EXPECT_FALSE(host_impl_.use_gpu_rasterization());
2522 // Should have a low-res and a high-res tiling. 2520 // Should have a low-res and a high-res tiling.
2523 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); 2521 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
2524 } 2522 }
2525 2523
2526 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { 2524 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) {
2527 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); 2525 gfx::Size default_tile_size(host_impl_.settings().default_tile_size);
2528 gfx::Size layer_bounds(default_tile_size.width() * 4, 2526 gfx::Size layer_bounds(default_tile_size.width() * 4,
2529 default_tile_size.height() * 4); 2527 default_tile_size.height() * 4);
2530 2528
2531 host_impl_.set_has_gpu_rasterization_trigger(true); 2529 host_impl_.SetHasGpuRasterizationTrigger(true);
2532 host_impl_.set_content_is_suitable_for_gpu_rasterization(true); 2530 host_impl_.SetContentIsSuitableForGpuRasterization(true);
2533 host_impl_.UpdateGpuRasterizationStatus();
2534 2531
2535 SetupDefaultTrees(layer_bounds); 2532 SetupDefaultTrees(layer_bounds);
2536 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); 2533 EXPECT_TRUE(host_impl_.use_gpu_rasterization());
2537 // Should only have the high-res tiling. 2534 // Should only have the high-res tiling.
2538 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 2535 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2539 } 2536 }
2540 2537
2541 TEST_F(PictureLayerImplTest, RequiredTilesWithGpuRasterization) { 2538 TEST_F(PictureLayerImplTest, RequiredTilesWithGpuRasterization) {
2542 host_impl_.set_has_gpu_rasterization_trigger(true); 2539 host_impl_.SetHasGpuRasterizationTrigger(true);
2543 host_impl_.set_content_is_suitable_for_gpu_rasterization(true); 2540 host_impl_.SetContentIsSuitableForGpuRasterization(true);
2544 host_impl_.UpdateGpuRasterizationStatus();
2545 2541
2546 gfx::Size viewport_size(1000, 1000); 2542 gfx::Size viewport_size(1000, 1000);
2547 host_impl_.SetViewportSize(viewport_size); 2543 host_impl_.SetViewportSize(viewport_size);
2548 2544
2549 gfx::Size layer_bounds(4000, 4000); 2545 gfx::Size layer_bounds(4000, 4000);
2550 SetupDefaultTrees(layer_bounds); 2546 SetupDefaultTrees(layer_bounds);
2551 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); 2547 EXPECT_TRUE(host_impl_.use_gpu_rasterization());
2552 2548
2553 // Should only have the high-res tiling. 2549 // Should only have the high-res tiling.
2554 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); 2550 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings());
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 maximum_animation_scale, 2830 maximum_animation_scale,
2835 starting_animation_scale, animating_transform); 2831 starting_animation_scale, animating_transform);
2836 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); 2832 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f);
2837 } 2833 }
2838 2834
2839 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForGpuRasterization) { 2835 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForGpuRasterization) {
2840 gfx::Size layer_bounds(100, 100); 2836 gfx::Size layer_bounds(100, 100);
2841 gfx::Size viewport_size(1000, 1000); 2837 gfx::Size viewport_size(1000, 1000);
2842 SetupDefaultTrees(layer_bounds); 2838 SetupDefaultTrees(layer_bounds);
2843 host_impl_.SetViewportSize(viewport_size); 2839 host_impl_.SetViewportSize(viewport_size);
2844 host_impl_.set_has_gpu_rasterization_trigger(true); 2840 host_impl_.SetHasGpuRasterizationTrigger(true);
2845 host_impl_.set_content_is_suitable_for_gpu_rasterization(true); 2841 host_impl_.SetContentIsSuitableForGpuRasterization(true);
2846 host_impl_.UpdateGpuRasterizationStatus(); 2842 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded();
danakj 2015/05/13 20:21:57 is this needed?
Stephen White 2015/05/13 20:38:35 Yes. The EXPECT_BOTH_EQ(HighResTiling()->contents_
2847 2843
2848 float contents_scale = 1.f; 2844 float contents_scale = 1.f;
2849 float device_scale = 1.3f; 2845 float device_scale = 1.3f;
2850 float page_scale = 1.4f; 2846 float page_scale = 1.4f;
2851 float maximum_animation_scale = 1.f; 2847 float maximum_animation_scale = 1.f;
2852 float starting_animation_scale = 0.f; 2848 float starting_animation_scale = 0.f;
2853 bool animating_transform = false; 2849 bool animating_transform = false;
2854 2850
2855 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, 2851 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2856 maximum_animation_scale, 2852 maximum_animation_scale,
(...skipping 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 TEST_F(TileSizeTest, TileSizes) { 5017 TEST_F(TileSizeTest, TileSizes) {
5022 host_impl_.CreatePendingTree(); 5018 host_impl_.CreatePendingTree();
5023 5019
5024 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 5020 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
5025 scoped_ptr<FakePictureLayerImpl> layer = 5021 scoped_ptr<FakePictureLayerImpl> layer =
5026 FakePictureLayerImpl::Create(pending_tree, id_); 5022 FakePictureLayerImpl::Create(pending_tree, id_);
5027 5023
5028 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); 5024 host_impl_.SetViewportSize(gfx::Size(1000, 1000));
5029 gfx::Size result; 5025 gfx::Size result;
5030 5026
5031 host_impl_.set_content_is_suitable_for_gpu_rasterization(true); 5027 host_impl_.SetContentIsSuitableForGpuRasterization(true);
5032 host_impl_.set_has_gpu_rasterization_trigger(false); 5028 host_impl_.SetHasGpuRasterizationTrigger(false);
5033 host_impl_.UpdateGpuRasterizationStatus();
5034 EXPECT_EQ(host_impl_.gpu_rasterization_status(), 5029 EXPECT_EQ(host_impl_.gpu_rasterization_status(),
5035 GpuRasterizationStatus::OFF_VIEWPORT); 5030 GpuRasterizationStatus::OFF_VIEWPORT);
5036 5031
5037 // Default tile-size for large layers. 5032 // Default tile-size for large layers.
5038 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); 5033 result = layer->CalculateTileSize(gfx::Size(10000, 10000));
5039 EXPECT_EQ(result.width(), 100); 5034 EXPECT_EQ(result.width(), 100);
5040 EXPECT_EQ(result.height(), 100); 5035 EXPECT_EQ(result.height(), 100);
5041 // Don't tile and round-up, when under max_untiled_layer_size. 5036 // Don't tile and round-up, when under max_untiled_layer_size.
5042 result = layer->CalculateTileSize(gfx::Size(42, 42)); 5037 result = layer->CalculateTileSize(gfx::Size(42, 42));
5043 EXPECT_EQ(result.width(), 64); 5038 EXPECT_EQ(result.width(), 64);
5044 EXPECT_EQ(result.height(), 64); 5039 EXPECT_EQ(result.height(), 64);
5045 result = layer->CalculateTileSize(gfx::Size(191, 191)); 5040 result = layer->CalculateTileSize(gfx::Size(191, 191));
5046 EXPECT_EQ(result.width(), 192); 5041 EXPECT_EQ(result.width(), 192);
5047 EXPECT_EQ(result.height(), 192); 5042 EXPECT_EQ(result.height(), 192);
5048 result = layer->CalculateTileSize(gfx::Size(199, 199)); 5043 result = layer->CalculateTileSize(gfx::Size(199, 199));
5049 EXPECT_EQ(result.width(), 200); 5044 EXPECT_EQ(result.width(), 200);
5050 EXPECT_EQ(result.height(), 200); 5045 EXPECT_EQ(result.height(), 200);
5051 5046
5052 // Gpu-rasterization uses 25% viewport-height tiles. 5047 // Gpu-rasterization uses 25% viewport-height tiles.
5053 // The +2's below are for border texels. 5048 // The +2's below are for border texels.
5054 host_impl_.set_has_gpu_rasterization_trigger(true); 5049 host_impl_.SetHasGpuRasterizationTrigger(true);
5055 host_impl_.UpdateGpuRasterizationStatus();
5056 EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON); 5050 EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON);
5057 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); 5051 host_impl_.SetViewportSize(gfx::Size(2000, 2000));
5058 5052
5059 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); 5053 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size());
5060 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); 5054 result = layer->CalculateTileSize(gfx::Size(10000, 10000));
5061 EXPECT_EQ(result.width(), 2000 + 2 * PictureLayerTiling::kBorderTexels); 5055 EXPECT_EQ(result.width(), 2000 + 2 * PictureLayerTiling::kBorderTexels);
5062 EXPECT_EQ(result.height(), 500 + 2); 5056 EXPECT_EQ(result.height(), 500 + 2);
5063 5057
5064 // Clamp and round-up, when smaller than viewport. 5058 // Clamp and round-up, when smaller than viewport.
5065 // Tile-height doubles to 50% when width shrinks to <= 50%. 5059 // Tile-height doubles to 50% when width shrinks to <= 50%.
5066 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); 5060 host_impl_.SetViewportSize(gfx::Size(1000, 1000));
5067 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); 5061 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size());
5068 result = layer->CalculateTileSize(gfx::Size(447, 10000)); 5062 result = layer->CalculateTileSize(gfx::Size(447, 10000));
5069 EXPECT_EQ(result.width(), 448); 5063 EXPECT_EQ(result.width(), 448);
5070 EXPECT_EQ(result.height(), 500 + 2); 5064 EXPECT_EQ(result.height(), 500 + 2);
5071 5065
5072 // Largest layer is 50% of viewport width (rounded up), and 5066 // Largest layer is 50% of viewport width (rounded up), and
5073 // 50% of viewport in height. 5067 // 50% of viewport in height.
5074 result = layer->CalculateTileSize(gfx::Size(447, 400)); 5068 result = layer->CalculateTileSize(gfx::Size(447, 400));
5075 EXPECT_EQ(result.width(), 448); 5069 EXPECT_EQ(result.width(), 448);
5076 EXPECT_EQ(result.height(), 448); 5070 EXPECT_EQ(result.height(), 448);
5077 result = layer->CalculateTileSize(gfx::Size(500, 499)); 5071 result = layer->CalculateTileSize(gfx::Size(500, 499));
5078 EXPECT_EQ(result.width(), 512); 5072 EXPECT_EQ(result.width(), 512);
5079 EXPECT_EQ(result.height(), 500 + 2); 5073 EXPECT_EQ(result.height(), 500 + 2);
5080 } 5074 }
5081 5075
5082 } // namespace 5076 } // namespace
5083 } // namespace cc 5077 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host.cc » ('j') | cc/trees/layer_tree_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698