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_->GetContentsResourceId(&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_->GetContentsResourceId(&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 SetupDrawPropertiesAndUpdateTiles( |
| 1244 pending_layer_, ideal_contents_scale, 1.f, 1.f, 1.f, false); |
| 1245 EXPECT_EQ(ideal_contents_scale, |
| 1246 pending_layer_->HighResTiling()->contents_scale()); |
| 1247 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1248 |
| 1249 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1250 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1251 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1252 |
| 1253 ActivateTree(); |
| 1254 |
| 1255 // Mask layers have a tiling with a single tile in it. |
| 1256 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 1257 // The mask resource exists. |
| 1258 ResourceProvider::ResourceId mask_resource_id; |
| 1259 gfx::Size mask_texture_size; |
| 1260 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1261 EXPECT_NE(0u, mask_resource_id); |
| 1262 gfx::Size expected_mask_texture_size = gfx::ToCeiledSize( |
| 1263 gfx::ScaleSize(active_layer_->bounds(), ideal_contents_scale)); |
| 1264 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); |
1227 } | 1265 } |
1228 | 1266 |
1229 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1267 TEST_F(PictureLayerImplTest, ReleaseResources) { |
1230 gfx::Size tile_size(400, 400); | 1268 gfx::Size tile_size(400, 400); |
1231 gfx::Size layer_bounds(1300, 1900); | 1269 gfx::Size layer_bounds(1300, 1900); |
1232 | 1270 |
1233 scoped_refptr<FakePicturePileImpl> pending_pile = | 1271 scoped_refptr<FakePicturePileImpl> pending_pile = |
1234 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1272 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1235 scoped_refptr<FakePicturePileImpl> active_pile = | 1273 scoped_refptr<FakePicturePileImpl> active_pile = |
1236 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1274 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)); | 4548 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4511 EXPECT_EQ(result.width(), 448); | 4549 EXPECT_EQ(result.width(), 448); |
4512 EXPECT_EQ(result.height(), 448); | 4550 EXPECT_EQ(result.height(), 448); |
4513 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4551 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4514 EXPECT_EQ(result.width(), 512); | 4552 EXPECT_EQ(result.width(), 512); |
4515 EXPECT_EQ(result.height(), 500 + 2); | 4553 EXPECT_EQ(result.height(), 500 + 2); |
4516 } | 4554 } |
4517 | 4555 |
4518 } // namespace | 4556 } // namespace |
4519 } // namespace cc | 4557 } // namespace cc |
OLD | NEW |