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 12378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, RasterTilePrioritizationForNonDrawingLayers) { |
| 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 |
| 12413 std::unique_ptr<FakePictureLayerImpl> scoped_hidden_layer = |
| 12414 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
| 12415 2, raster_source); |
| 12416 scoped_hidden_layer->SetBounds(layer_bounds); |
| 12417 scoped_hidden_layer->SetDrawsContent(true); |
| 12418 scoped_hidden_layer->set_contributes_to_drawn_render_surface(true); |
| 12419 FakePictureLayerImpl* hidden_layer = scoped_hidden_layer.get(); |
| 12420 root->test_properties()->AddChild(std::move(scoped_hidden_layer)); |
| 12421 |
| 12422 std::unique_ptr<FakePictureLayerImpl> scoped_drawing_layer = |
| 12423 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
| 12424 3, raster_source); |
| 12425 scoped_drawing_layer->SetBounds(layer_bounds); |
| 12426 scoped_drawing_layer->SetDrawsContent(true); |
| 12427 scoped_drawing_layer->set_contributes_to_drawn_render_surface(true); |
| 12428 FakePictureLayerImpl* drawing_layer = scoped_drawing_layer.get(); |
| 12429 root->test_properties()->AddChild(std::move(scoped_drawing_layer)); |
| 12430 |
| 12431 gfx::Rect layer_rect(0, 0, 500, 500); |
| 12432 gfx::Rect empty_rect(0, 0, 0, 0); |
| 12433 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 12434 |
| 12435 hidden_layer->tilings()->AddTiling(gfx::AxisTransform2d(), raster_source); |
| 12436 PictureLayerTiling* hidden_tiling = hidden_layer->tilings()->tiling_at(0); |
| 12437 hidden_tiling->set_resolution(TileResolution::LOW_RESOLUTION); |
| 12438 hidden_tiling->CreateAllTilesForTesting(); |
| 12439 hidden_tiling->SetTilePriorityRectsForTesting( |
| 12440 layer_rect, // Visible rect. |
| 12441 layer_rect, // Skewport rect. |
| 12442 layer_rect, // Soon rect. |
| 12443 layer_rect); // Eventually rect. |
| 12444 |
| 12445 drawing_layer->tilings()->AddTiling(gfx::AxisTransform2d(), raster_source); |
| 12446 PictureLayerTiling* drawing_tiling = drawing_layer->tilings()->tiling_at(0); |
| 12447 drawing_tiling->set_resolution(TileResolution::HIGH_RESOLUTION); |
| 12448 drawing_tiling->CreateAllTilesForTesting(); |
| 12449 drawing_tiling->SetTilePriorityRectsForTesting( |
| 12450 layer_rect, // Visible rect. |
| 12451 layer_rect, // Skewport rect. |
| 12452 layer_rect, // Soon rect. |
| 12453 layer_rect); // Eventually rect. |
| 12454 |
| 12455 // Both layers are drawn. Since the hidden layer has a low resolution tiling, |
| 12456 // in smoothness priority mode its tile is higher priority. |
| 12457 std::unique_ptr<RasterTilePriorityQueue> queue = |
| 12458 host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, |
| 12459 RasterTilePriorityQueue::Type::ALL); |
| 12460 EXPECT_EQ(queue->Top().tile()->layer_id(), 2); |
| 12461 |
| 12462 // Hide the hidden layer and set it to so it still rasters. Now the drawing |
| 12463 // layer should be prioritized over the hidden layer. |
| 12464 hidden_layer->set_contributes_to_drawn_render_surface(false); |
| 12465 hidden_layer->set_raster_even_if_not_in_rsll(true); |
| 12466 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, |
| 12467 RasterTilePriorityQueue::Type::ALL); |
| 12468 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); |
| 12469 } |
| 12470 |
12399 } // namespace | 12471 } // namespace |
12400 } // namespace cc | 12472 } // namespace cc |
OLD | NEW |