Index: cc/layers/picture_layer_impl_unittest.cc |
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc |
index 1e649263682debfd3bde050bed89e076fa32ba9e..65de537442dc20af92f43954aa09c2e0f724d109 100644 |
--- a/cc/layers/picture_layer_impl_unittest.cc |
+++ b/cc/layers/picture_layer_impl_unittest.cc |
@@ -1189,7 +1189,7 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
EXPECT_EQ(mask->num_tilings(), 1u); |
} |
-TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
+TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
base::TimeTicks time_ticks; |
time_ticks += base::TimeDelta::FromMilliseconds(1); |
host_impl_.SetCurrentBeginFrameArgs( |
@@ -1236,7 +1236,7 @@ TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
gfx::Size mask_texture_size; |
active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
EXPECT_NE(0u, mask_resource_id); |
- EXPECT_EQ(mask_texture_size, active_mask->bounds()); |
+ EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
// Drop resources and recreate them, still the same. |
pending_mask->ReleaseResources(); |
@@ -1245,16 +1245,7 @@ TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
active_mask->HighResTiling()->CreateAllTilesForTesting(); |
EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
EXPECT_NE(0u, mask_resource_id); |
- EXPECT_EQ(mask_texture_size, active_layer_->bounds()); |
- |
- // Drop resources and recreate them, still the same. |
- pending_mask->ReleaseResources(); |
- active_mask->ReleaseResources(); |
- SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
- active_mask->HighResTiling()->CreateAllTilesForTesting(); |
- EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
- EXPECT_NE(0u, mask_resource_id); |
- EXPECT_EQ(mask_texture_size, active_mask->bounds()); |
+ EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
// Resize larger than the max texture size. |
int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
@@ -1272,7 +1263,8 @@ TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
host_impl_.pending_tree()->UpdateDrawProperties(); |
- EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); |
+ // The mask tiling gets scaled down. |
+ EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); |
EXPECT_EQ(1u, pending_mask->num_tilings()); |
host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
@@ -1280,27 +1272,52 @@ TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
ActivateTree(); |
- // Mask layers have a tiling, but there should be no tiles in it. |
- EXPECT_EQ(0u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
- // The mask resource is empty. |
- active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
- EXPECT_EQ(0u, mask_resource_id); |
+ // Mask layers have a tiling with a single tile in it. |
+ EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
+ // The mask resource exists. |
+ active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
+ EXPECT_NE(0u, mask_resource_id); |
+ gfx::Size expected_size = active_mask->bounds(); |
+ expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); |
+ EXPECT_EQ(expected_size, mask_texture_size); |
// Drop resources and recreate them, still the same. |
pending_mask->ReleaseResources(); |
active_mask->ReleaseResources(); |
SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
active_mask->HighResTiling()->CreateAllTilesForTesting(); |
- EXPECT_EQ(0u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
- active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
- EXPECT_EQ(0u, mask_resource_id); |
+ EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
+ EXPECT_NE(0u, mask_resource_id); |
+ EXPECT_EQ(expected_size, mask_texture_size); |
// Do another activate, the same holds. |
SetupPendingTree(huge_pile); |
ActivateTree(); |
- EXPECT_EQ(0u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
+ EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
+ EXPECT_EQ(expected_size, mask_texture_size); |
EXPECT_EQ(0u, mask_resource_id); |
+ |
+ // Resize even larger, so that the scale would be smaller than the minimum |
+ // contents scale. Then the layer should no longer have any tiling. |
+ float min_contents_scale = host_impl_.settings().minimum_contents_scale; |
+ gfx::Size extra_huge_bounds(max_texture_size / min_contents_scale + 1, 10); |
+ scoped_refptr<FakePicturePileImpl> extra_huge_pile = |
+ FakePicturePileImpl::CreateFilledPile(tile_size, extra_huge_bounds); |
+ |
+ SetupPendingTree(extra_huge_pile); |
+ pending_mask->SetBounds(extra_huge_bounds); |
+ pending_mask->SetContentBounds(extra_huge_bounds); |
+ pending_mask->SetRasterSourceOnPending(extra_huge_pile, Region()); |
+ |
+ EXPECT_FALSE(pending_mask->CanHaveTilings()); |
+ |
+ time_ticks += base::TimeDelta::FromMilliseconds(1); |
+ host_impl_.SetCurrentBeginFrameArgs( |
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
+ host_impl_.pending_tree()->UpdateDrawProperties(); |
+ |
+ EXPECT_EQ(0u, pending_mask->num_tilings()); |
} |
TEST_F(PictureLayerImplTest, ScaledMaskLayer) { |
@@ -1674,7 +1691,7 @@ TEST_F(NoLowResPictureLayerImplTest, |
if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { |
num_inside++; |
// Mark everything in viewport for tile priority as ready to draw. |
- ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
+ TileDrawInfo& draw_info = tile->draw_info(); |
draw_info.SetSolidColorForTesting(SK_ColorRED); |
} else { |
num_outside++; |
@@ -2819,7 +2836,7 @@ TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { |
tile_it != high_res_tiles.end(); |
++tile_it) { |
Tile* tile = *tile_it; |
- ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
+ TileDrawInfo& draw_info = tile->draw_info(); |
draw_info.SetSolidColorForTesting(SK_ColorRED); |
} |
@@ -3606,51 +3623,6 @@ TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { |
->visible_content_rect.ToString()); |
} |
-TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { |
- gfx::Size tile_size(400, 400); |
- gfx::Size bounds(100000, 100); |
- |
- host_impl_.CreatePendingTree(); |
- |
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); |
- |
- scoped_refptr<FakePicturePileImpl> pending_pile = |
- FakePicturePileImpl::CreateFilledPile(tile_size, bounds); |
- scoped_ptr<FakePictureLayerImpl> layer_with_mask = |
- FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
- pending_pile); |
- layer_with_mask->SetBounds(bounds); |
- layer_with_mask->SetContentBounds(bounds); |
- |
- scoped_refptr<FakePicturePileImpl> mask_pile = |
- FakePicturePileImpl::CreateFilledPile(tile_size, bounds); |
- scoped_ptr<FakePictureLayerImpl> mask = |
- FakePictureLayerImpl::CreateMaskWithRasterSource( |
- host_impl_.pending_tree(), 3, mask_pile); |
- mask->SetBounds(bounds); |
- mask->SetContentBounds(bounds); |
- mask->SetDrawsContent(true); |
- layer_with_mask->SetMaskLayer(mask.Pass()); |
- |
- FakePictureLayerImpl* pending_mask = |
- static_cast<FakePictureLayerImpl*>(layer_with_mask->mask_layer()); |
- |
- scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = |
- FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 4, |
- pending_pile); |
- child_of_layer_with_mask->SetBounds(bounds); |
- child_of_layer_with_mask->SetContentBounds(bounds); |
- child_of_layer_with_mask->SetDrawsContent(true); |
- layer_with_mask->AddChild(child_of_layer_with_mask.Pass()); |
- root->AddChild(layer_with_mask.Pass()); |
- |
- host_impl_.pending_tree()->SetRootLayer(root.Pass()); |
- |
- EXPECT_EQ(0u, pending_mask->num_tilings()); |
- host_impl_.pending_tree()->UpdateDrawProperties(); |
- EXPECT_NE(0u, pending_mask->num_tilings()); |
-} |
- |
class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
public: |
PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} |