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

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

Issue 2035863003: cc: Add mask and replica layer ids to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 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/layers/layer_impl_unittest.cc ('k') | cc/layers/render_surface_impl.h » ('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 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 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 EXPECT_FALSE(pending_layer()->LowResTiling()); 1137 EXPECT_FALSE(pending_layer()->LowResTiling());
1138 EXPECT_EQ(active_layer()->num_tilings(), 2u); 1138 EXPECT_EQ(active_layer()->num_tilings(), 2u);
1139 EXPECT_EQ(pending_layer()->num_tilings(), 1u); 1139 EXPECT_EQ(pending_layer()->num_tilings(), 1u);
1140 1140
1141 // Mask layers dont create low res since they always fit on one tile. 1141 // Mask layers dont create low res since they always fit on one tile.
1142 std::unique_ptr<FakePictureLayerImpl> mask = 1142 std::unique_ptr<FakePictureLayerImpl> mask =
1143 FakePictureLayerImpl::CreateMaskWithRasterSource( 1143 FakePictureLayerImpl::CreateMaskWithRasterSource(
1144 host_impl()->pending_tree(), 3, pending_raster_source); 1144 host_impl()->pending_tree(), 3, pending_raster_source);
1145 mask->SetBounds(layer_bounds); 1145 mask->SetBounds(layer_bounds);
1146 mask->SetDrawsContent(true); 1146 mask->SetDrawsContent(true);
1147 pending_layer()->SetMaskLayer(std::move(mask)); 1147 pending_layer()->test_properties()->SetMaskLayer(std::move(mask));
1148 pending_layer()->SetHasRenderSurface(true); 1148 pending_layer()->SetHasRenderSurface(true);
1149 RebuildPropertyTreesOnPendingTree(); 1149 RebuildPropertyTreesOnPendingTree();
1150 host_impl()->pending_tree()->UpdateDrawProperties(false); 1150 host_impl()->pending_tree()->UpdateDrawProperties(false);
1151 1151
1152 FakePictureLayerImpl* mask_raw = 1152 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>(
1153 static_cast<FakePictureLayerImpl*>(pending_layer()->mask_layer()); 1153 pending_layer()->test_properties()->mask_layer);
1154 // We did an UpdateDrawProperties above, which will set a contents scale on 1154 // We did an UpdateDrawProperties above, which will set a contents scale on
1155 // the mask layer, so allow us to reset the contents scale. 1155 // the mask layer, so allow us to reset the contents scale.
1156 mask_raw->ReleaseResources(); 1156 mask_raw->ReleaseResources();
1157 mask_raw->RecreateResources(); 1157 mask_raw->RecreateResources();
1158 1158
1159 SetupDrawPropertiesAndUpdateTiles( 1159 SetupDrawPropertiesAndUpdateTiles(
1160 mask_raw, contents_scale, device_scale, page_scale, 1160 mask_raw, contents_scale, device_scale, page_scale,
1161 maximum_animation_scale, starting_animation_scale, animating_transform); 1161 maximum_animation_scale, starting_animation_scale, animating_transform);
1162 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); 1162 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale);
1163 EXPECT_EQ(mask_raw->num_tilings(), 1u); 1163 EXPECT_EQ(mask_raw->num_tilings(), 1u);
1164 } 1164 }
1165 1165
1166 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { 1166 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) {
1167 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1167 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1168 1168
1169 gfx::Size layer_bounds(1000, 1000); 1169 gfx::Size layer_bounds(1000, 1000);
1170 1170
1171 scoped_refptr<FakeRasterSource> valid_raster_source = 1171 scoped_refptr<FakeRasterSource> valid_raster_source =
1172 FakeRasterSource::CreateFilled(layer_bounds); 1172 FakeRasterSource::CreateFilled(layer_bounds);
1173 SetupPendingTree(valid_raster_source); 1173 SetupPendingTree(valid_raster_source);
1174 1174
1175 std::unique_ptr<FakePictureLayerImpl> mask_ptr = 1175 std::unique_ptr<FakePictureLayerImpl> mask_ptr =
1176 FakePictureLayerImpl::CreateMaskWithRasterSource( 1176 FakePictureLayerImpl::CreateMaskWithRasterSource(
1177 host_impl()->pending_tree(), 3, valid_raster_source); 1177 host_impl()->pending_tree(), 3, valid_raster_source);
1178 mask_ptr->SetBounds(layer_bounds); 1178 mask_ptr->SetBounds(layer_bounds);
1179 mask_ptr->SetDrawsContent(true); 1179 mask_ptr->SetDrawsContent(true);
1180 pending_layer()->SetMaskLayer(std::move(mask_ptr)); 1180 pending_layer()->test_properties()->SetMaskLayer(std::move(mask_ptr));
1181 pending_layer()->test_properties()->force_render_surface = true; 1181 pending_layer()->test_properties()->force_render_surface = true;
1182 1182
1183 RebuildPropertyTreesOnPendingTree(); 1183 RebuildPropertyTreesOnPendingTree();
1184 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1184 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1185 bool update_lcd_text = false; 1185 bool update_lcd_text = false;
1186 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); 1186 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text);
1187 1187
1188 FakePictureLayerImpl* pending_mask = 1188 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>(
1189 static_cast<FakePictureLayerImpl*>(pending_layer()->mask_layer()); 1189 pending_layer()->test_properties()->mask_layer);
1190 1190
1191 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); 1191 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale());
1192 EXPECT_EQ(1u, pending_mask->num_tilings()); 1192 EXPECT_EQ(1u, pending_mask->num_tilings());
1193 1193
1194 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( 1194 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(
1195 pending_mask->HighResTiling()->AllTilesForTesting()); 1195 pending_mask->HighResTiling()->AllTilesForTesting());
1196 1196
1197 ActivateTree(); 1197 ActivateTree();
1198 1198
1199 FakePictureLayerImpl* active_mask = 1199 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>(
1200 static_cast<FakePictureLayerImpl*>(active_layer()->mask_layer()); 1200 host_impl()->active_tree()->LayerById(pending_mask->id()));
1201 1201
1202 // Mask layers have a tiling with a single tile in it. 1202 // Mask layers have a tiling with a single tile in it.
1203 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1203 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1204 // The mask resource exists. 1204 // The mask resource exists.
1205 ResourceId mask_resource_id; 1205 ResourceId mask_resource_id;
1206 gfx::Size mask_texture_size; 1206 gfx::Size mask_texture_size;
1207 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1207 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1208 EXPECT_NE(0u, mask_resource_id); 1208 EXPECT_NE(0u, mask_resource_id);
1209 EXPECT_EQ(active_mask->bounds(), mask_texture_size); 1209 EXPECT_EQ(active_mask->bounds(), mask_texture_size);
1210 1210
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 1300
1301 scoped_refptr<FakeRasterSource> valid_raster_source = 1301 scoped_refptr<FakeRasterSource> valid_raster_source =
1302 FakeRasterSource::CreateFilled(layer_bounds); 1302 FakeRasterSource::CreateFilled(layer_bounds);
1303 SetupPendingTree(valid_raster_source); 1303 SetupPendingTree(valid_raster_source);
1304 1304
1305 std::unique_ptr<FakePictureLayerImpl> mask_ptr = 1305 std::unique_ptr<FakePictureLayerImpl> mask_ptr =
1306 FakePictureLayerImpl::CreateMaskWithRasterSource( 1306 FakePictureLayerImpl::CreateMaskWithRasterSource(
1307 host_impl()->pending_tree(), 3, valid_raster_source); 1307 host_impl()->pending_tree(), 3, valid_raster_source);
1308 mask_ptr->SetBounds(layer_bounds); 1308 mask_ptr->SetBounds(layer_bounds);
1309 mask_ptr->SetDrawsContent(true); 1309 mask_ptr->SetDrawsContent(true);
1310 pending_layer()->SetMaskLayer(std::move(mask_ptr)); 1310 pending_layer()->test_properties()->SetMaskLayer(std::move(mask_ptr));
1311 pending_layer()->test_properties()->force_render_surface = true; 1311 pending_layer()->test_properties()->force_render_surface = true;
1312 1312
1313 RebuildPropertyTreesOnPendingTree(); 1313 RebuildPropertyTreesOnPendingTree();
1314 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1314 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1315 bool update_lcd_text = false; 1315 bool update_lcd_text = false;
1316 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); 1316 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text);
1317 1317
1318 FakePictureLayerImpl* pending_mask = 1318 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>(
1319 static_cast<FakePictureLayerImpl*>(pending_layer()->mask_layer()); 1319 pending_layer()->test_properties()->mask_layer);
1320 1320
1321 // Masks are scaled, and do not have a low res tiling. 1321 // Masks are scaled, and do not have a low res tiling.
1322 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); 1322 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale());
1323 EXPECT_EQ(1u, pending_mask->num_tilings()); 1323 EXPECT_EQ(1u, pending_mask->num_tilings());
1324 1324
1325 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( 1325 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(
1326 pending_mask->HighResTiling()->AllTilesForTesting()); 1326 pending_mask->HighResTiling()->AllTilesForTesting());
1327 1327
1328 ActivateTree(); 1328 ActivateTree();
1329 1329
1330 FakePictureLayerImpl* active_mask = 1330 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>(
1331 static_cast<FakePictureLayerImpl*>(active_layer()->mask_layer()); 1331 host_impl()->active_tree()->LayerById(pending_mask->id()));
1332 1332
1333 // Mask layers have a tiling with a single tile in it. 1333 // Mask layers have a tiling with a single tile in it.
1334 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1334 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1335 // The mask resource exists. 1335 // The mask resource exists.
1336 ResourceId mask_resource_id; 1336 ResourceId mask_resource_id;
1337 gfx::Size mask_texture_size; 1337 gfx::Size mask_texture_size;
1338 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1338 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1339 EXPECT_NE(0u, mask_resource_id); 1339 EXPECT_NE(0u, mask_resource_id);
1340 gfx::Size expected_mask_texture_size = 1340 gfx::Size expected_mask_texture_size =
1341 gfx::ScaleToCeiledSize(active_mask->bounds(), 1.3f); 1341 gfx::ScaleToCeiledSize(active_mask->bounds(), 1.3f);
(...skipping 3420 matching lines...) Expand 10 before | Expand all | Expand 10 after
4762 // New low res tiling. 4762 // New low res tiling.
4763 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); 4763 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles());
4764 4764
4765 // This tiling will be high res now, it won't contain low res content since it 4765 // This tiling will be high res now, it won't contain low res content since it
4766 // was all destroyed. 4766 // was all destroyed.
4767 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); 4767 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles());
4768 } 4768 }
4769 4769
4770 } // namespace 4770 } // namespace
4771 } // namespace cc 4771 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl_unittest.cc ('k') | cc/layers/render_surface_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698