| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 active_layer_(nullptr) {} | 64 active_layer_(nullptr) {} |
| 65 | 65 |
| 66 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 66 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
| 67 : proxy_(base::MessageLoopProxy::current()), | 67 : proxy_(base::MessageLoopProxy::current()), |
| 68 host_impl_(settings, &proxy_, &shared_bitmap_manager_), | 68 host_impl_(settings, &proxy_, &shared_bitmap_manager_), |
| 69 id_(7) {} | 69 id_(7) {} |
| 70 | 70 |
| 71 virtual ~PictureLayerImplTest() { | 71 virtual ~PictureLayerImplTest() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void SetUp() override { | 74 void SetUp() override { InitializeRenderer(); } |
| 75 InitializeRenderer(); | |
| 76 } | |
| 77 | 75 |
| 78 virtual void InitializeRenderer() { | 76 virtual void InitializeRenderer() { |
| 79 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 77 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
| 80 } | 78 } |
| 81 | 79 |
| 82 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 80 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 83 gfx::Size tile_size(100, 100); | 81 gfx::Size tile_size(100, 100); |
| 84 | 82 |
| 85 scoped_refptr<FakePicturePileImpl> pending_pile = | 83 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 86 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 84 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 874 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 877 EXPECT_FLOAT_EQ(2.0f, | 875 EXPECT_FLOAT_EQ(2.0f, |
| 878 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 876 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 879 EXPECT_FLOAT_EQ(1.0f, | 877 EXPECT_FLOAT_EQ(1.0f, |
| 880 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 878 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 881 EXPECT_FLOAT_EQ(2.0f * low_res_factor, | 879 EXPECT_FLOAT_EQ(2.0f * low_res_factor, |
| 882 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 880 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 883 | 881 |
| 884 // Zoom out further, close to our low-res scale factor. We should | 882 // Zoom out further, close to our low-res scale factor. We should |
| 885 // use that tiling as high-res, and not create a new tiling. | 883 // use that tiling as high-res, and not create a new tiling. |
| 886 SetContentsScaleOnBothLayers( | 884 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, |
| 887 low_res_factor, 1.0f, low_res_factor / 2.0f, 1.0f, false); | 885 low_res_factor * 2.1f, 1.0f, false); |
| 888 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 886 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 889 | 887 |
| 890 // Zoom in a lot now. Since we increase by increments of | 888 // Zoom in a lot now. Since we increase by increments of |
| 891 // kMaxScaleRatioDuringPinch, this will first use 1.0, then 2.0 | 889 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. |
| 892 // and then finally create a new tiling at 4.0. | 890 SetContentsScaleOnBothLayers(3.8f, 1.0f, 2.1f, 1.f, false); |
| 893 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); | |
| 894 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | |
| 895 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); | |
| 896 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | |
| 897 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); | |
| 898 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 891 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
| 899 EXPECT_FLOAT_EQ(4.0f, | 892 EXPECT_FLOAT_EQ(4.0f, |
| 900 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 893 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 901 } | 894 } |
| 902 | 895 |
| 903 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { | 896 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |
| 904 gfx::Size tile_size(300, 300); | 897 gfx::Size tile_size(300, 300); |
| 905 gfx::Size layer_bounds(2600, 3800); | 898 gfx::Size layer_bounds(2600, 3800); |
| 906 | 899 |
| 907 scoped_refptr<FakePicturePileImpl> pending_pile = | 900 scoped_refptr<FakePicturePileImpl> pending_pile = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 931 EXPECT_FLOAT_EQ(0.12f, | 924 EXPECT_FLOAT_EQ(0.12f, |
| 932 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 925 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 933 EXPECT_FLOAT_EQ(0.0625, | 926 EXPECT_FLOAT_EQ(0.0625, |
| 934 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 927 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 935 | 928 |
| 936 // Zoom out further, close to our low-res scale factor. We should | 929 // Zoom out further, close to our low-res scale factor. We should |
| 937 // use that tiling as high-res, and not create a new tiling. | 930 // use that tiling as high-res, and not create a new tiling. |
| 938 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); | 931 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); |
| 939 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 932 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 940 | 933 |
| 941 // Zoom in. 0.125(desired_scale) should be snapped to 0.12 during zoom-in | 934 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in |
| 942 // because 0.125(desired_scale) is within the ratio(1.2) | 935 // because 0.25(desired_scale) is within the ratio(1.2). |
| 943 SetContentsScaleOnBothLayers(0.5f, 1.0f, 0.5f, 1.0f, false); | 936 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, false); |
| 944 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 937 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 938 |
| 939 // Zoom in a lot. Since we move in factors of two, we should get a scale that |
| 940 // is a power of 2 times 0.24. |
| 941 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, false); |
| 942 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
| 943 EXPECT_FLOAT_EQ(1.92f, |
| 944 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 945 } | 945 } |
| 946 | 946 |
| 947 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 947 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
| 948 gfx::Size tile_size(400, 400); | 948 gfx::Size tile_size(400, 400); |
| 949 gfx::Size layer_bounds(1300, 1900); | 949 gfx::Size layer_bounds(1300, 1900); |
| 950 | 950 |
| 951 scoped_refptr<FakePicturePileImpl> pending_pile = | 951 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 952 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 952 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 953 scoped_refptr<FakePicturePileImpl> active_pile = | 953 scoped_refptr<FakePicturePileImpl> active_pile = |
| 954 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 954 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 maximum_animation_scale, | 1181 maximum_animation_scale, |
| 1182 animating_transform); | 1182 animating_transform); |
| 1183 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1183 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1184 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), | 1184 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), |
| 1185 contents_scale * low_res_factor); | 1185 contents_scale * low_res_factor); |
| 1186 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1186 EXPECT_BOTH_EQ(num_tilings(), 2u); |
| 1187 | 1187 |
| 1188 ResetTilingsAndRasterScales(); | 1188 ResetTilingsAndRasterScales(); |
| 1189 | 1189 |
| 1190 // Mask layers dont create low res since they always fit on one tile. | 1190 // Mask layers dont create low res since they always fit on one tile. |
| 1191 pending_pile->SetIsMask(true); | 1191 pending_layer_->set_is_mask(true); |
| 1192 active_pile->SetIsMask(true); | 1192 active_layer_->set_is_mask(true); |
| 1193 SetContentsScaleOnBothLayers(contents_scale, | 1193 SetContentsScaleOnBothLayers(contents_scale, |
| 1194 device_scale, | 1194 device_scale, |
| 1195 page_scale, | 1195 page_scale, |
| 1196 maximum_animation_scale, | 1196 maximum_animation_scale, |
| 1197 animating_transform); | 1197 animating_transform); |
| 1198 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1198 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1199 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1199 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { | 1202 TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
| 1203 gfx::Size tile_size(100, 100); | 1203 gfx::Size tile_size(100, 100); |
| 1204 | 1204 |
| 1205 scoped_refptr<FakePicturePileImpl> valid_pile = | 1205 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 1206 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 1206 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); |
| 1207 valid_pile->SetIsMask(true); | |
| 1208 SetupPendingTree(valid_pile); | 1207 SetupPendingTree(valid_pile); |
| 1208 pending_layer_->set_is_mask(true); |
| 1209 | 1209 |
| 1210 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1210 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1211 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1211 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 1212 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1212 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1213 | 1213 |
| 1214 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1214 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1215 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1215 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1216 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1216 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1217 | 1217 |
| 1218 ActivateTree(); | 1218 ActivateTree(); |
| 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 // Resize larger than the max texture size. | 1229 // Resize larger than the max texture size. |
| 1230 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; | 1230 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
| 1231 scoped_refptr<FakePicturePileImpl> huge_pile = | 1231 scoped_refptr<FakePicturePileImpl> huge_pile = |
| 1232 FakePicturePileImpl::CreateFilledPile( | 1232 FakePicturePileImpl::CreateFilledPile( |
| 1233 tile_size, gfx::Size(max_texture_size + 1, 10)); | 1233 tile_size, gfx::Size(max_texture_size + 1, 10)); |
| 1234 huge_pile->SetIsMask(true); | |
| 1235 SetupPendingTree(huge_pile); | 1234 SetupPendingTree(huge_pile); |
| 1235 pending_layer_->set_is_mask(true); |
| 1236 | 1236 |
| 1237 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1237 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1238 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1238 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 1239 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1239 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1240 | 1240 |
| 1241 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1241 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1242 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1242 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1243 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1243 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1244 | 1244 |
| 1245 ActivateTree(); | 1245 ActivateTree(); |
| 1246 | 1246 |
| 1247 // Mask layers have a tiling, but there should be no tiles in it. | 1247 // Mask layers have a tiling, but there should be no tiles in it. |
| 1248 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1248 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 1249 // The mask resource is empty. | 1249 // The mask resource is empty. |
| 1250 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1250 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1251 EXPECT_EQ(0u, mask_resource_id); | 1251 EXPECT_EQ(0u, mask_resource_id); |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { | 1254 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { |
| 1255 gfx::Size tile_size(100, 100); | 1255 gfx::Size tile_size(100, 100); |
| 1256 | 1256 |
| 1257 scoped_refptr<FakePicturePileImpl> valid_pile = | 1257 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 1258 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 1258 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); |
| 1259 valid_pile->SetIsMask(true); | |
| 1260 SetupPendingTree(valid_pile); | 1259 SetupPendingTree(valid_pile); |
| 1260 pending_layer_->set_is_mask(true); |
| 1261 | 1261 |
| 1262 float ideal_contents_scale = 1.3f; | 1262 float ideal_contents_scale = 1.3f; |
| 1263 SetupDrawPropertiesAndUpdateTiles( | 1263 SetupDrawPropertiesAndUpdateTiles( |
| 1264 pending_layer_, ideal_contents_scale, 1.f, 1.f, 1.f, false); | 1264 pending_layer_, ideal_contents_scale, 1.f, 1.f, 1.f, false); |
| 1265 EXPECT_EQ(ideal_contents_scale, | 1265 EXPECT_EQ(ideal_contents_scale, |
| 1266 pending_layer_->HighResTiling()->contents_scale()); | 1266 pending_layer_->HighResTiling()->contents_scale()); |
| 1267 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1267 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1268 | 1268 |
| 1269 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1269 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1270 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1270 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 gfx::Size tile_size(100, 100); | 2020 gfx::Size tile_size(100, 100); |
| 2021 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2021 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
| 2022 | 2022 |
| 2023 gfx::Size pending_layer_bounds(400, 400); | 2023 gfx::Size pending_layer_bounds(400, 400); |
| 2024 pending_layer_->SetBounds(pending_layer_bounds); | 2024 pending_layer_->SetBounds(pending_layer_bounds); |
| 2025 | 2025 |
| 2026 CreateHighLowResAndSetAllTilesVisible(); | 2026 CreateHighLowResAndSetAllTilesVisible(); |
| 2027 // TODO(vmpstr): This is confusing. Rework the test to create different bounds | 2027 // TODO(vmpstr): This is confusing. Rework the test to create different bounds |
| 2028 // on different trees instead of fudging tilings. | 2028 // on different trees instead of fudging tilings. |
| 2029 pending_layer_->HighResTiling()->ComputeTilePriorityRects( | 2029 pending_layer_->HighResTiling()->ComputeTilePriorityRects( |
| 2030 PENDING_TREE, gfx::Rect(pending_layer_bounds), 1.f, 1.f, Occlusion()); | 2030 gfx::Rect(pending_layer_bounds), 1.f, 1.f, Occlusion()); |
| 2031 | 2031 |
| 2032 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2032 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2033 active_layer_->SetAllTilesReady(); | 2033 active_layer_->SetAllTilesReady(); |
| 2034 | 2034 |
| 2035 // Since the active layer has different bounds, the pending layer needs all | 2035 // Since the active layer has different bounds, the pending layer needs all |
| 2036 // high res tiles in order to activate. | 2036 // high res tiles in order to activate. |
| 2037 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2037 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2038 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2038 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2039 | 2039 |
| 2040 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2040 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2110 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
| 2111 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2111 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
| 2112 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2112 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2113 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2113 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); |
| 2114 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2114 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); |
| 2115 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | 2115 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); |
| 2116 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | 2116 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); |
| 2117 | 2117 |
| 2118 // Drop the tiles on the active tree and recreate them. The same tiles | 2118 // Drop the tiles on the active tree and recreate them. The same tiles |
| 2119 // should be shared or not. | 2119 // should be shared or not. |
| 2120 active_tiling->ComputeTilePriorityRects( | 2120 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); |
| 2121 ACTIVE_TREE, gfx::Rect(), 1.f, 1.0, Occlusion()); | |
| 2122 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); | 2121 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); |
| 2123 active_tiling->CreateAllTilesForTesting(); | 2122 active_tiling->CreateAllTilesForTesting(); |
| 2124 | 2123 |
| 2125 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2124 // Tile 0,0 should be shared, but tile 1,1 should not be. |
| 2126 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2125 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
| 2127 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2126 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
| 2128 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2127 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
| 2129 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2128 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2130 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2129 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); |
| 2131 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2130 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 2451 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
| 2453 EXPECT_FLOAT_EQ(contents_scale, | 2452 EXPECT_FLOAT_EQ(contents_scale, |
| 2454 pending_layer_->HighResTiling()->contents_scale()); | 2453 pending_layer_->HighResTiling()->contents_scale()); |
| 2455 | 2454 |
| 2456 host_impl_.PinchGestureBegin(); | 2455 host_impl_.PinchGestureBegin(); |
| 2457 | 2456 |
| 2458 float page_scale = 0.0001f; | 2457 float page_scale = 0.0001f; |
| 2459 EXPECT_LT(page_scale * contents_scale, | 2458 EXPECT_LT(page_scale * contents_scale, |
| 2460 pending_layer_->MinimumContentsScale()); | 2459 pending_layer_->MinimumContentsScale()); |
| 2461 | 2460 |
| 2462 SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, 1.f, false); | 2461 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, |
| 2462 1.f, false); |
| 2463 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 2463 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
| 2464 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | 2464 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
| 2465 pending_layer_->HighResTiling()->contents_scale()); | 2465 pending_layer_->HighResTiling()->contents_scale()); |
| 2466 } | 2466 } |
| 2467 | 2467 |
| 2468 class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { | 2468 class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { |
| 2469 public: | 2469 public: |
| 2470 void InitializeRenderer() override { | 2470 void InitializeRenderer() override { |
| 2471 bool delegated_rendering = false; | 2471 bool delegated_rendering = false; |
| 2472 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDeferredGL( | 2472 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDeferredGL( |
| 2473 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), | 2473 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), |
| 2474 delegated_rendering)); | 2474 delegated_rendering)); |
| 2475 } | 2475 } |
| 2476 | 2476 |
| 2477 virtual void SetUp() override { | 2477 void SetUp() override { |
| 2478 PictureLayerImplTest::SetUp(); | 2478 PictureLayerImplTest::SetUp(); |
| 2479 | 2479 |
| 2480 // Create some default active and pending trees. | 2480 // Create some default active and pending trees. |
| 2481 gfx::Size tile_size(100, 100); | 2481 gfx::Size tile_size(100, 100); |
| 2482 gfx::Size layer_bounds(400, 400); | 2482 gfx::Size layer_bounds(400, 400); |
| 2483 | 2483 |
| 2484 scoped_refptr<FakePicturePileImpl> pending_pile = | 2484 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2485 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2485 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2486 scoped_refptr<FakePicturePileImpl> active_pile = | 2486 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2487 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2487 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3709 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); | 3709 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); |
| 3710 | 3710 |
| 3711 scoped_ptr<FakePictureLayerImpl> layer_with_mask = | 3711 scoped_ptr<FakePictureLayerImpl> layer_with_mask = |
| 3712 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); | 3712 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); |
| 3713 | 3713 |
| 3714 layer_with_mask->SetBounds(bounds); | 3714 layer_with_mask->SetBounds(bounds); |
| 3715 layer_with_mask->SetContentBounds(bounds); | 3715 layer_with_mask->SetContentBounds(bounds); |
| 3716 | 3716 |
| 3717 scoped_refptr<FakePicturePileImpl> pending_pile = | 3717 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3718 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); | 3718 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); |
| 3719 pending_pile->SetIsMask(true); | |
| 3720 scoped_ptr<FakePictureLayerImpl> mask = | 3719 scoped_ptr<FakePictureLayerImpl> mask = |
| 3721 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 3, | 3720 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 3, |
| 3722 pending_pile); | 3721 pending_pile); |
| 3722 mask->set_is_mask(true); |
| 3723 | 3723 |
| 3724 mask->SetBounds(bounds); | 3724 mask->SetBounds(bounds); |
| 3725 mask->SetContentBounds(bounds); | 3725 mask->SetContentBounds(bounds); |
| 3726 mask->SetDrawsContent(true); | 3726 mask->SetDrawsContent(true); |
| 3727 | 3727 |
| 3728 FakePictureLayerImpl* pending_mask_content = mask.get(); | 3728 FakePictureLayerImpl* pending_mask_content = mask.get(); |
| 3729 layer_with_mask->SetMaskLayer(mask.Pass()); | 3729 layer_with_mask->SetMaskLayer(mask.Pass()); |
| 3730 | 3730 |
| 3731 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = | 3731 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = |
| 3732 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); | 3732 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4497 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4497 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4498 | 4498 |
| 4499 host_impl_.SetViewportSize(layer_bounds); | 4499 host_impl_.SetViewportSize(layer_bounds); |
| 4500 | 4500 |
| 4501 int frame_number = 0; | 4501 int frame_number = 0; |
| 4502 | 4502 |
| 4503 client.set_fill_with_nonsolid_color(!test_for_solid); | 4503 client.set_fill_with_nonsolid_color(!test_for_solid); |
| 4504 | 4504 |
| 4505 Region invalidation(layer_rect); | 4505 Region invalidation(layer_rect); |
| 4506 recording_source->UpdateAndExpandInvalidation( | 4506 recording_source->UpdateAndExpandInvalidation( |
| 4507 &client, &invalidation, SK_ColorWHITE, false, false, layer_bounds, | 4507 &client, &invalidation, layer_bounds, layer_rect, frame_number++, |
| 4508 layer_rect, frame_number++, Picture::RECORD_NORMALLY); | 4508 Picture::RECORD_NORMALLY); |
| 4509 | 4509 |
| 4510 scoped_refptr<RasterSource> pending_raster_source = | 4510 scoped_refptr<RasterSource> pending_raster_source = |
| 4511 recording_source->CreateRasterSource(); | 4511 recording_source->CreateRasterSource(); |
| 4512 | 4512 |
| 4513 SetupPendingTree(pending_raster_source); | 4513 SetupPendingTree(pending_raster_source); |
| 4514 ActivateTree(); | 4514 ActivateTree(); |
| 4515 | 4515 |
| 4516 active_layer_->set_fixed_tile_size(tile_size); | 4516 active_layer_->set_fixed_tile_size(tile_size); |
| 4517 host_impl_.active_tree()->UpdateDrawProperties(); | 4517 host_impl_.active_tree()->UpdateDrawProperties(); |
| 4518 if (test_for_solid) { | 4518 if (test_for_solid) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4564 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4564 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4565 | 4565 |
| 4566 host_impl_.SetViewportSize(layer_bounds); | 4566 host_impl_.SetViewportSize(layer_bounds); |
| 4567 | 4567 |
| 4568 int frame_number = 0; | 4568 int frame_number = 0; |
| 4569 | 4569 |
| 4570 client.set_fill_with_nonsolid_color(true); | 4570 client.set_fill_with_nonsolid_color(true); |
| 4571 | 4571 |
| 4572 Region invalidation1(layer_rect); | 4572 Region invalidation1(layer_rect); |
| 4573 recording_source->UpdateAndExpandInvalidation( | 4573 recording_source->UpdateAndExpandInvalidation( |
| 4574 &client, &invalidation1, SK_ColorWHITE, false, false, layer_bounds, | 4574 &client, &invalidation1, layer_bounds, layer_rect, frame_number++, |
| 4575 layer_rect, frame_number++, Picture::RECORD_NORMALLY); | 4575 Picture::RECORD_NORMALLY); |
| 4576 | 4576 |
| 4577 scoped_refptr<RasterSource> raster_source1 = | 4577 scoped_refptr<RasterSource> raster_source1 = |
| 4578 recording_source->CreateRasterSource(); | 4578 recording_source->CreateRasterSource(); |
| 4579 | 4579 |
| 4580 SetupPendingTree(raster_source1); | 4580 SetupPendingTree(raster_source1); |
| 4581 ActivateTree(); | 4581 ActivateTree(); |
| 4582 host_impl_.active_tree()->UpdateDrawProperties(); | 4582 host_impl_.active_tree()->UpdateDrawProperties(); |
| 4583 | 4583 |
| 4584 // We've started with a solid layer that contains some tilings. | 4584 // We've started with a solid layer that contains some tilings. |
| 4585 ASSERT_TRUE(active_layer_->tilings()); | 4585 ASSERT_TRUE(active_layer_->tilings()); |
| 4586 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); | 4586 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); |
| 4587 | 4587 |
| 4588 client.set_fill_with_nonsolid_color(false); | 4588 client.set_fill_with_nonsolid_color(false); |
| 4589 | 4589 |
| 4590 Region invalidation2(layer_rect); | 4590 Region invalidation2(layer_rect); |
| 4591 recording_source->UpdateAndExpandInvalidation( | 4591 recording_source->UpdateAndExpandInvalidation( |
| 4592 &client, &invalidation2, SK_ColorWHITE, false, false, layer_bounds, | 4592 &client, &invalidation2, layer_bounds, layer_rect, frame_number++, |
| 4593 layer_rect, frame_number++, Picture::RECORD_NORMALLY); | 4593 Picture::RECORD_NORMALLY); |
| 4594 | 4594 |
| 4595 scoped_refptr<RasterSource> raster_source2 = | 4595 scoped_refptr<RasterSource> raster_source2 = |
| 4596 recording_source->CreateRasterSource(); | 4596 recording_source->CreateRasterSource(); |
| 4597 | 4597 |
| 4598 SetupPendingTree(raster_source2); | 4598 SetupPendingTree(raster_source2); |
| 4599 ActivateTree(); | 4599 ActivateTree(); |
| 4600 | 4600 |
| 4601 // We've switched to a solid color, so we should end up with no tilings. | 4601 // We've switched to a solid color, so we should end up with no tilings. |
| 4602 ASSERT_TRUE(active_layer_->tilings()); | 4602 ASSERT_TRUE(active_layer_->tilings()); |
| 4603 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4603 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4722 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4722 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4723 EXPECT_EQ(result.width(), 448); | 4723 EXPECT_EQ(result.width(), 448); |
| 4724 EXPECT_EQ(result.height(), 448); | 4724 EXPECT_EQ(result.height(), 448); |
| 4725 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4725 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4726 EXPECT_EQ(result.width(), 512); | 4726 EXPECT_EQ(result.width(), 512); |
| 4727 EXPECT_EQ(result.height(), 500 + 2); | 4727 EXPECT_EQ(result.height(), 500 + 2); |
| 4728 } | 4728 } |
| 4729 | 4729 |
| 4730 } // namespace | 4730 } // namespace |
| 4731 } // namespace cc | 4731 } // namespace cc |
| OLD | NEW |