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

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/picture_layer_impl.cc ('k') | cc/layers/ui_resource_layer.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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 1219
1220 // Mask layers have a tiling with a single tile in it. 1220 // Mask layers have a tiling with a single tile in it.
1221 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); 1221 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size());
1222 // The mask resource exists. 1222 // The mask resource exists.
1223 ResourceProvider::ResourceId mask_resource_id; 1223 ResourceProvider::ResourceId mask_resource_id;
1224 gfx::Size mask_texture_size; 1224 gfx::Size mask_texture_size;
1225 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1225 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1226 EXPECT_NE(0u, mask_resource_id); 1226 EXPECT_NE(0u, mask_resource_id);
1227 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); 1227 EXPECT_EQ(mask_texture_size, active_layer_->bounds());
1228 1228
1229 // Drop resources and recreate them, still the same.
1230 old_pending_layer_->ReleaseResources();
1231 active_layer_->ReleaseResources();
1232 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
1233 active_layer_->HighResTiling()->CreateAllTilesForTesting();
1234 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size());
1235 EXPECT_NE(0u, mask_resource_id);
1236 EXPECT_EQ(mask_texture_size, active_layer_->bounds());
1237
1229 // Resize larger than the max texture size. 1238 // Resize larger than the max texture size.
1230 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; 1239 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size;
1231 scoped_refptr<FakePicturePileImpl> huge_pile = 1240 scoped_refptr<FakePicturePileImpl> huge_pile =
1232 FakePicturePileImpl::CreateFilledPile( 1241 FakePicturePileImpl::CreateFilledPile(
1233 tile_size, gfx::Size(max_texture_size + 1, 10)); 1242 tile_size, gfx::Size(max_texture_size + 1, 10));
1234 SetupPendingTree(huge_pile); 1243 SetupPendingTree(huge_pile);
1235 pending_layer_->set_is_mask(true); 1244 pending_layer_->set_is_mask(true);
1236 1245
1237 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); 1246 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
1238 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); 1247 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale());
1239 EXPECT_EQ(1u, pending_layer_->num_tilings()); 1248 EXPECT_EQ(1u, pending_layer_->num_tilings());
1240 1249
1241 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); 1250 pending_layer_->HighResTiling()->CreateAllTilesForTesting();
1242 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 1251 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
1243 pending_layer_->HighResTiling()->AllTilesForTesting()); 1252 pending_layer_->HighResTiling()->AllTilesForTesting());
1244 1253
1245 ActivateTree(); 1254 ActivateTree();
1246 1255
1247 // Mask layers have a tiling, but there should be no tiles in it. 1256 // Mask layers have a tiling, but there should be no tiles in it.
1248 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); 1257 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size());
1249 // The mask resource is empty. 1258 // The mask resource is empty.
1250 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1259 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1251 EXPECT_EQ(0u, mask_resource_id); 1260 EXPECT_EQ(0u, mask_resource_id);
1261
1262 // Drop resources and recreate them, still the same.
1263 old_pending_layer_->ReleaseResources();
1264 active_layer_->ReleaseResources();
1265 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
1266 active_layer_->HighResTiling()->CreateAllTilesForTesting();
1267 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size());
1268 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1269 EXPECT_EQ(0u, mask_resource_id);
1252 } 1270 }
1253 1271
1254 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { 1272 TEST_F(PictureLayerImplTest, ScaledMaskLayer) {
1255 gfx::Size tile_size(100, 100); 1273 gfx::Size tile_size(100, 100);
1256 1274
1257 scoped_refptr<FakePicturePileImpl> valid_pile = 1275 scoped_refptr<FakePicturePileImpl> valid_pile =
1258 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); 1276 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000));
1259 SetupPendingTree(valid_pile); 1277 SetupPendingTree(valid_pile);
1260 pending_layer_->set_is_mask(true); 1278 pending_layer_->set_is_mask(true);
1261 1279
(...skipping 3460 matching lines...) Expand 10 before | Expand all | Expand 10 after
4722 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4740 result = layer->CalculateTileSize(gfx::Size(447, 400));
4723 EXPECT_EQ(result.width(), 448); 4741 EXPECT_EQ(result.width(), 448);
4724 EXPECT_EQ(result.height(), 448); 4742 EXPECT_EQ(result.height(), 448);
4725 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4743 result = layer->CalculateTileSize(gfx::Size(500, 499));
4726 EXPECT_EQ(result.width(), 512); 4744 EXPECT_EQ(result.width(), 512);
4727 EXPECT_EQ(result.height(), 500 + 2); 4745 EXPECT_EQ(result.height(), 500 + 2);
4728 } 4746 }
4729 4747
4730 } // namespace 4748 } // namespace
4731 } // namespace cc 4749 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/ui_resource_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698