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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2899403003: cc: Give non-drawing layers that are rasterized a lower priority. (Closed)
Patch Set: perftest Created 3 years, 6 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 | « cc/tiles/tiling_set_raster_queue_all.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12378 matching lines...) Expand 10 before | Expand all | Expand 10 after
12389 EXPECT_FALSE(host_impl_->GetRasterColorSpace().IsValid()); 12389 EXPECT_FALSE(host_impl_->GetRasterColorSpace().IsValid());
12390 } 12390 }
12391 12391
12392 TEST_F(LayerTreeHostImplTest, RasterColorSpace) { 12392 TEST_F(LayerTreeHostImplTest, RasterColorSpace) {
12393 LayerTreeSettings settings = DefaultSettings(); 12393 LayerTreeSettings settings = DefaultSettings();
12394 settings.enable_color_correct_rasterization = true; 12394 settings.enable_color_correct_rasterization = true;
12395 CreateHostImpl(settings, CreateCompositorFrameSink()); 12395 CreateHostImpl(settings, CreateCompositorFrameSink());
12396 EXPECT_EQ(host_impl_->GetRasterColorSpace(), gfx::ColorSpace::CreateSRGB()); 12396 EXPECT_EQ(host_impl_->GetRasterColorSpace(), gfx::ColorSpace::CreateSRGB());
12397 } 12397 }
12398 12398
12399 TEST_F(LayerTreeHostImplTest, UpdatedTilingsForNonDrawingLayers) {
12400 gfx::Size layer_bounds(500, 500);
12401
12402 host_impl_->SetViewportSize(layer_bounds);
12403 host_impl_->CreatePendingTree();
12404 std::unique_ptr<LayerImpl> scoped_root =
12405 LayerImpl::Create(host_impl_->pending_tree(), 1);
12406 scoped_root->SetBounds(layer_bounds);
12407 LayerImpl* root = scoped_root.get();
12408 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(scoped_root));
12409
12410 scoped_refptr<FakeRasterSource> raster_source(
12411 FakeRasterSource::CreateFilled(layer_bounds));
12412 std::unique_ptr<FakePictureLayerImpl> scoped_animated_transform_layer =
12413 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(),
12414 2, raster_source);
12415 scoped_animated_transform_layer->SetBounds(layer_bounds);
12416 scoped_animated_transform_layer->SetDrawsContent(true);
12417 gfx::Transform singular;
12418 singular.Scale3d(6.f, 6.f, 0.f);
12419 scoped_animated_transform_layer->test_properties()->transform = singular;
12420 FakePictureLayerImpl* animated_transform_layer =
12421 scoped_animated_transform_layer.get();
12422 root->test_properties()->AddChild(std::move(scoped_animated_transform_layer));
12423
12424 host_impl_->pending_tree()->SetElementIdsForTesting();
12425 TransformOperations start_transform_operations;
12426 start_transform_operations.AppendMatrix(singular);
12427 TransformOperations end_transform_operations;
12428 AddAnimatedTransformToElementWithPlayer(
12429 animated_transform_layer->element_id(), timeline(), 10.0,
12430 start_transform_operations, end_transform_operations);
12431
12432 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
12433 EXPECT_EQ(animated_transform_layer->tilings()->num_tilings(), 0u);
danakj 2017/05/26 15:46:20 Can you add some comments explaining what these ex
Khushal 2017/05/26 18:09:21 Done.
12434 host_impl_->pending_tree()->UpdateDrawProperties(false);
12435 EXPECT_TRUE(animated_transform_layer->HasValidTilePriorities());
12436 EXPECT_EQ(animated_transform_layer->tilings()->num_tilings(), 1u);
12437 EXPECT_FALSE(animated_transform_layer->tilings()
12438 ->tiling_at(0)
12439 ->can_require_tiles_for_activation());
12440 }
12441
12442 TEST_F(LayerTreeHostImplTest, RasterTilePrioritizationForNonDrawingLayers) {
12443 gfx::Size layer_bounds(500, 500);
12444
12445 host_impl_->SetViewportSize(layer_bounds);
12446 host_impl_->CreatePendingTree();
12447 std::unique_ptr<LayerImpl> scoped_root =
12448 LayerImpl::Create(host_impl_->pending_tree(), 1);
12449 scoped_root->SetBounds(layer_bounds);
12450 LayerImpl* root = scoped_root.get();
12451 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(scoped_root));
12452
12453 scoped_refptr<FakeRasterSource> raster_source(
12454 FakeRasterSource::CreateFilled(layer_bounds));
12455
12456 std::unique_ptr<FakePictureLayerImpl> scoped_hidden_layer =
12457 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(),
12458 2, raster_source);
12459 scoped_hidden_layer->SetBounds(layer_bounds);
12460 scoped_hidden_layer->SetDrawsContent(true);
12461 scoped_hidden_layer->set_contributes_to_drawn_render_surface(true);
12462 FakePictureLayerImpl* hidden_layer = scoped_hidden_layer.get();
12463 root->test_properties()->AddChild(std::move(scoped_hidden_layer));
12464
12465 std::unique_ptr<FakePictureLayerImpl> scoped_drawing_layer =
12466 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(),
12467 3, raster_source);
12468 scoped_drawing_layer->SetBounds(layer_bounds);
12469 scoped_drawing_layer->SetDrawsContent(true);
12470 scoped_drawing_layer->set_contributes_to_drawn_render_surface(true);
12471 FakePictureLayerImpl* drawing_layer = scoped_drawing_layer.get();
12472 root->test_properties()->AddChild(std::move(scoped_drawing_layer));
12473
12474 gfx::Rect layer_rect(0, 0, 500, 500);
12475 gfx::Rect empty_rect(0, 0, 0, 0);
12476 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
12477
12478 hidden_layer->tilings()->AddTiling(gfx::AxisTransform2d(), raster_source);
12479 PictureLayerTiling* hidden_tiling = hidden_layer->tilings()->tiling_at(0);
12480 hidden_tiling->set_resolution(TileResolution::LOW_RESOLUTION);
12481 hidden_tiling->CreateAllTilesForTesting();
12482 hidden_tiling->SetTilePriorityRectsForTesting(
12483 layer_rect, // Visible rect.
12484 layer_rect, // Skewport rect.
12485 layer_rect, // Soon rect.
12486 layer_rect); // Eventually rect.
12487
12488 drawing_layer->tilings()->AddTiling(gfx::AxisTransform2d(), raster_source);
12489 PictureLayerTiling* drawing_tiling = drawing_layer->tilings()->tiling_at(0);
12490 drawing_tiling->set_resolution(TileResolution::HIGH_RESOLUTION);
12491 drawing_tiling->CreateAllTilesForTesting();
12492 drawing_tiling->SetTilePriorityRectsForTesting(
12493 layer_rect, // Visible rect.
12494 layer_rect, // Skewport rect.
12495 layer_rect, // Soon rect.
12496 layer_rect); // Eventually rect.
12497
12498 // Both layers are drawn. Since the hidden layer has a low resolution tiling,
12499 // in smoothness priority mode its tile is higher priority.
12500 std::unique_ptr<RasterTilePriorityQueue> queue =
12501 host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY,
12502 RasterTilePriorityQueue::Type::ALL);
12503 EXPECT_EQ(queue->Top().tile()->layer_id(), 2);
12504
12505 // Hide the hidden layer and set it to so it still rasters. Now the drawing
12506 // layer should be prioritized over the hidden layer.
12507 hidden_layer->set_contributes_to_drawn_render_surface(false);
12508 hidden_layer->set_raster_even_if_not_in_rsll(true);
12509 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY,
12510 RasterTilePriorityQueue::Type::ALL);
12511 EXPECT_EQ(queue->Top().tile()->layer_id(), 3);
12512 }
12513
12399 } // namespace 12514 } // namespace
12400 } // namespace cc 12515 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tiling_set_raster_queue_all.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698