Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1193 | 1193 |
| 1194 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1194 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1195 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1195 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1196 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1196 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1197 | 1197 |
| 1198 ActivateTree(); | 1198 ActivateTree(); |
| 1199 | 1199 |
| 1200 // Mask layers have a tiling with a single tile in it. | 1200 // Mask layers have a tiling with a single tile in it. |
| 1201 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1201 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 1202 // The mask resource exists. | 1202 // The mask resource exists. |
| 1203 EXPECT_NE(0u, active_layer_->ContentsResourceId()); | 1203 ResourceProvider::ResourceId mask_resource_id; |
| 1204 gfx::Size mask_texture_size; | |
| 1205 active_layer_->ContentsResourceId(&mask_resource_id, &mask_texture_size); | |
| 1206 EXPECT_NE(0u, mask_resource_id); | |
| 1207 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); | |
| 1204 | 1208 |
| 1205 // Resize larger than the max texture size. | 1209 // Resize larger than the max texture size. |
| 1206 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; | 1210 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
| 1207 scoped_refptr<FakePicturePileImpl> huge_pile = | 1211 scoped_refptr<FakePicturePileImpl> huge_pile = |
| 1208 FakePicturePileImpl::CreateFilledPile( | 1212 FakePicturePileImpl::CreateFilledPile( |
| 1209 tile_size, gfx::Size(max_texture_size + 1, 10)); | 1213 tile_size, gfx::Size(max_texture_size + 1, 10)); |
| 1210 huge_pile->set_is_mask(true); | 1214 huge_pile->set_is_mask(true); |
| 1211 SetupPendingTree(huge_pile); | 1215 SetupPendingTree(huge_pile); |
| 1212 | 1216 |
| 1213 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1217 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1214 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1218 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 1215 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1219 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1216 | 1220 |
| 1217 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1221 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1218 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1222 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1219 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1223 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1220 | 1224 |
| 1221 ActivateTree(); | 1225 ActivateTree(); |
| 1222 | 1226 |
| 1223 // Mask layers have a tiling, but there should be no tiles in it. | 1227 // Mask layers have a tiling, but there should be no tiles in it. |
| 1224 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1228 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 1225 // The mask resource is empty. | 1229 // The mask resource is empty. |
| 1226 EXPECT_EQ(0u, active_layer_->ContentsResourceId()); | 1230 active_layer_->ContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1231 EXPECT_EQ(0u, mask_resource_id); | |
| 1232 } | |
| 1233 | |
| 1234 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { | |
| 1235 gfx::Size tile_size(100, 100); | |
| 1236 | |
| 1237 scoped_refptr<FakePicturePileImpl> valid_pile = | |
| 1238 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | |
| 1239 valid_pile->set_is_mask(true); | |
| 1240 SetupPendingTree(valid_pile); | |
| 1241 | |
| 1242 float ideal_contents_scale = 1.3f; | |
| 1243 float device_scale = 2.7f; | |
|
danakj
2014/10/15 19:37:26
these look fun but you might as well set dsf and p
enne (OOO)
2014/10/15 19:49:03
Done.
| |
| 1244 float page_scale = 3.2f; | |
| 1245 float maximum_animation_scale = 1.f; | |
| 1246 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
| 1247 ideal_contents_scale, | |
| 1248 device_scale, | |
| 1249 page_scale, | |
| 1250 maximum_animation_scale, | |
| 1251 false); | |
| 1252 EXPECT_EQ(ideal_contents_scale, | |
| 1253 pending_layer_->HighResTiling()->contents_scale()); | |
| 1254 EXPECT_EQ(1u, pending_layer_->num_tilings()); | |
| 1255 | |
| 1256 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | |
| 1257 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | |
| 1258 pending_layer_->HighResTiling()->AllTilesForTesting()); | |
| 1259 | |
| 1260 ActivateTree(); | |
| 1261 | |
| 1262 // Mask layers have a tiling with a single tile in it. | |
| 1263 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | |
| 1264 // The mask resource exists. | |
| 1265 ResourceProvider::ResourceId mask_resource_id; | |
| 1266 gfx::Size mask_texture_size; | |
| 1267 active_layer_->ContentsResourceId(&mask_resource_id, &mask_texture_size); | |
| 1268 EXPECT_NE(0u, mask_resource_id); | |
| 1269 gfx::Size expected_mask_texture_size = gfx::ToCeiledSize( | |
| 1270 gfx::ScaleSize(active_layer_->bounds(), ideal_contents_scale)); | |
| 1271 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); | |
| 1227 } | 1272 } |
| 1228 | 1273 |
| 1229 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1274 TEST_F(PictureLayerImplTest, ReleaseResources) { |
| 1230 gfx::Size tile_size(400, 400); | 1275 gfx::Size tile_size(400, 400); |
| 1231 gfx::Size layer_bounds(1300, 1900); | 1276 gfx::Size layer_bounds(1300, 1900); |
| 1232 | 1277 |
| 1233 scoped_refptr<FakePicturePileImpl> pending_pile = | 1278 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1234 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1279 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1235 scoped_refptr<FakePicturePileImpl> active_pile = | 1280 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1236 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1281 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4510 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4555 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4511 EXPECT_EQ(result.width(), 448); | 4556 EXPECT_EQ(result.width(), 448); |
| 4512 EXPECT_EQ(result.height(), 448); | 4557 EXPECT_EQ(result.height(), 448); |
| 4513 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4558 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4514 EXPECT_EQ(result.width(), 512); | 4559 EXPECT_EQ(result.width(), 512); |
| 4515 EXPECT_EQ(result.height(), 500 + 2); | 4560 EXPECT_EQ(result.height(), 500 + 2); |
| 4516 } | 4561 } |
| 4517 | 4562 |
| 4518 } // namespace | 4563 } // namespace |
| 4519 } // namespace cc | 4564 } // namespace cc |
| OLD | NEW |