| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 active_layer_->AddTiling(2.3f); | 127 active_layer_->AddTiling(2.3f); |
| 128 active_layer_->AddTiling(1.0f); | 128 active_layer_->AddTiling(1.0f); |
| 129 active_layer_->AddTiling(0.5f); | 129 active_layer_->AddTiling(0.5f); |
| 130 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) | 130 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) |
| 131 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); | 131 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); |
| 132 pending_layer_->set_invalidation(invalidation); | 132 pending_layer_->set_invalidation(invalidation); |
| 133 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) | 133 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) |
| 134 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); | 134 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { | 137 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 138 host_impl_.CreatePendingTree(); | 138 host_impl_.CreatePendingTree(); |
| 139 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.f, 0.25f, 100.f); | 139 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.f, 0.25f, 100.f); |
| 140 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 140 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 141 | 141 |
| 142 // Steal from the recycled tree. | 142 // Steal from the recycled tree. |
| 143 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 143 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); |
| 144 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); | 144 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); |
| 145 | 145 |
| 146 scoped_ptr<FakePictureLayerImpl> pending_layer; | 146 scoped_ptr<FakePictureLayerImpl> pending_layer; |
| 147 if (old_pending_root) { | 147 if (old_pending_root) { |
| 148 pending_layer.reset( | 148 pending_layer.reset( |
| 149 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | 149 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); |
| 150 pending_layer->SetPile(pile); | 150 pending_layer->SetRasterSource(raster_source); |
| 151 } else { | 151 } else { |
| 152 pending_layer = | 152 pending_layer = FakePictureLayerImpl::CreateWithRasterSource( |
| 153 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 153 pending_tree, id_, raster_source); |
| 154 pending_layer->SetDrawsContent(true); | 154 pending_layer->SetDrawsContent(true); |
| 155 } | 155 } |
| 156 // The bounds() just mirror the pile size. | 156 // The bounds() just mirror the pile size. |
| 157 pending_layer->SetBounds(pending_layer->pile()->tiling_size()); | 157 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 158 pending_tree->SetRootLayer(pending_layer.Pass()); | 158 pending_tree->SetRootLayer(pending_layer.Pass()); |
| 159 | 159 |
| 160 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 160 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 161 host_impl_.pending_tree()->LayerById(id_)); | 161 host_impl_.pending_tree()->LayerById(id_)); |
| 162 pending_layer_->DoPostCommitInitializationIfNeeded(); | 162 pending_layer_->DoPostCommitInitializationIfNeeded(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, | 165 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, |
| 166 float ideal_contents_scale, | 166 float ideal_contents_scale, |
| 167 float device_scale_factor, | 167 float device_scale_factor, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 active_pile->add_draw_rect(rect); | 261 active_pile->add_draw_rect(rect); |
| 262 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); | 262 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); |
| 263 } | 263 } |
| 264 // Force re-record with newly injected content | 264 // Force re-record with newly injected content |
| 265 active_pile->RemoveRecordingAt(0, 0); | 265 active_pile->RemoveRecordingAt(0, 0); |
| 266 active_pile->AddRecordingAt(0, 0); | 266 active_pile->AddRecordingAt(0, 0); |
| 267 | 267 |
| 268 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); | 268 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); |
| 269 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 269 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 270 MockCanvas mock_canvas(1000, 1000); | 270 MockCanvas mock_canvas(1000, 1000); |
| 271 active_pile->RasterDirect(&mock_canvas, (*tile_iter)->content_rect(), | 271 active_pile->PlaybackToSharedCanvas(&mock_canvas, |
| 272 1.0f); | 272 (*tile_iter)->content_rect(), 1.0f); |
| 273 | 273 |
| 274 // This test verifies that when drawing the contents of a specific tile | 274 // This test verifies that when drawing the contents of a specific tile |
| 275 // at content scale 1.0, the playback canvas never receives content from | 275 // at content scale 1.0, the playback canvas never receives content from |
| 276 // neighboring tiles which indicates that the tile grid embedded in | 276 // neighboring tiles which indicates that the tile grid embedded in |
| 277 // SkPicture is perfectly aligned with the compositor's tiles. | 277 // SkPicture is perfectly aligned with the compositor's tiles. |
| 278 EXPECT_EQ(1u, mock_canvas.rects_.size()); | 278 EXPECT_EQ(1u, mock_canvas.rects_.size()); |
| 279 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); | 279 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); |
| 280 rect_iter++; | 280 rect_iter++; |
| 281 } | 281 } |
| 282 } | 282 } |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 651 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 652 | 652 |
| 653 for (PictureLayerTiling::CoverageIterator iter( | 653 for (PictureLayerTiling::CoverageIterator iter( |
| 654 tiling, | 654 tiling, |
| 655 tiling->contents_scale(), | 655 tiling->contents_scale(), |
| 656 gfx::Rect(tiling->tiling_size())); | 656 gfx::Rect(tiling->tiling_size())); |
| 657 iter; | 657 iter; |
| 658 ++iter) { | 658 ++iter) { |
| 659 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); | 659 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); |
| 660 // Ensure there is a recording for this tile. | 660 // Ensure there is a recording for this tile. |
| 661 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), | 661 bool in_pending = pending_pile->CoversRect(iter.full_tile_geometry_rect(), |
| 662 iter.full_tile_geometry_rect()); | 662 tiling->contents_scale()); |
| 663 bool in_active = active_pile->CanRaster(tiling->contents_scale(), | 663 bool in_active = active_pile->CoversRect(iter.full_tile_geometry_rect(), |
| 664 iter.full_tile_geometry_rect()); | 664 tiling->contents_scale()); |
| 665 | 665 |
| 666 if (in_pending && !in_active) | 666 if (in_pending && !in_active) |
| 667 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | 667 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
| 668 else if (in_active) | 668 else if (in_active) |
| 669 EXPECT_EQ(active_pile.get(), iter->raster_source()); | 669 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
| 670 else | 670 else |
| 671 EXPECT_FALSE(*iter); | 671 EXPECT_FALSE(*iter); |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 } | 674 } |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 device_scale, | 1125 device_scale, |
| 1126 page_scale, | 1126 page_scale, |
| 1127 maximum_animation_scale, | 1127 maximum_animation_scale, |
| 1128 animating_transform); | 1128 animating_transform); |
| 1129 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1129 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 1130 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); | 1130 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); |
| 1131 EXPECT_BOTH_EQ(num_tilings(), 4u); | 1131 EXPECT_BOTH_EQ(num_tilings(), 4u); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { | 1134 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
| 1135 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1135 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); |
| 1136 SetupDefaultTrees(tile_size); | 1136 gfx::Size tile_size(100, 100); |
| 1137 |
| 1138 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1139 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1140 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1141 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1142 |
| 1143 SetupTrees(pending_pile, active_pile); |
| 1137 | 1144 |
| 1138 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1145 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 1139 float device_scale = 1.f; | 1146 float device_scale = 1.f; |
| 1140 float page_scale = 1.f; | 1147 float page_scale = 1.f; |
| 1141 float maximum_animation_scale = 1.f; | 1148 float maximum_animation_scale = 1.f; |
| 1142 bool animating_transform = false; | 1149 bool animating_transform = false; |
| 1143 | 1150 |
| 1144 // Contents exactly fit on one tile at scale 1, no low res. | 1151 // Contents exactly fit on one tile at scale 1, no low res. |
| 1145 float contents_scale = 1.f; | 1152 float contents_scale = 1.f; |
| 1146 SetContentsScaleOnBothLayers(contents_scale, | 1153 SetContentsScaleOnBothLayers(contents_scale, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1174 maximum_animation_scale, | 1181 maximum_animation_scale, |
| 1175 animating_transform); | 1182 animating_transform); |
| 1176 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1183 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1177 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), | 1184 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), |
| 1178 contents_scale * low_res_factor); | 1185 contents_scale * low_res_factor); |
| 1179 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1186 EXPECT_BOTH_EQ(num_tilings(), 2u); |
| 1180 | 1187 |
| 1181 ResetTilingsAndRasterScales(); | 1188 ResetTilingsAndRasterScales(); |
| 1182 | 1189 |
| 1183 // 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. |
| 1184 pending_layer_->pile()->set_is_mask(true); | 1191 pending_pile->SetIsMask(true); |
| 1185 active_layer_->pile()->set_is_mask(true); | 1192 active_pile->SetIsMask(true); |
| 1186 SetContentsScaleOnBothLayers(contents_scale, | 1193 SetContentsScaleOnBothLayers(contents_scale, |
| 1187 device_scale, | 1194 device_scale, |
| 1188 page_scale, | 1195 page_scale, |
| 1189 maximum_animation_scale, | 1196 maximum_animation_scale, |
| 1190 animating_transform); | 1197 animating_transform); |
| 1191 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1198 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1192 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1199 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 1193 } | 1200 } |
| 1194 | 1201 |
| 1195 TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { | 1202 TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
| 1196 gfx::Size tile_size(100, 100); | 1203 gfx::Size tile_size(100, 100); |
| 1197 | 1204 |
| 1198 scoped_refptr<FakePicturePileImpl> valid_pile = | 1205 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 1199 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 1206 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); |
| 1200 valid_pile->set_is_mask(true); | 1207 valid_pile->SetIsMask(true); |
| 1201 SetupPendingTree(valid_pile); | 1208 SetupPendingTree(valid_pile); |
| 1202 | 1209 |
| 1203 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); |
| 1204 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1211 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 1205 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1212 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1206 | 1213 |
| 1207 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1214 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1208 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1215 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1209 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1216 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1210 | 1217 |
| 1211 ActivateTree(); | 1218 ActivateTree(); |
| 1212 | 1219 |
| 1213 // Mask layers have a tiling with a single tile in it. | 1220 // Mask layers have a tiling with a single tile in it. |
| 1214 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1221 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 1215 // The mask resource exists. | 1222 // The mask resource exists. |
| 1216 ResourceProvider::ResourceId mask_resource_id; | 1223 ResourceProvider::ResourceId mask_resource_id; |
| 1217 gfx::Size mask_texture_size; | 1224 gfx::Size mask_texture_size; |
| 1218 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1225 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1219 EXPECT_NE(0u, mask_resource_id); | 1226 EXPECT_NE(0u, mask_resource_id); |
| 1220 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); | 1227 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); |
| 1221 | 1228 |
| 1222 // Resize larger than the max texture size. | 1229 // Resize larger than the max texture size. |
| 1223 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; | 1230 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
| 1224 scoped_refptr<FakePicturePileImpl> huge_pile = | 1231 scoped_refptr<FakePicturePileImpl> huge_pile = |
| 1225 FakePicturePileImpl::CreateFilledPile( | 1232 FakePicturePileImpl::CreateFilledPile( |
| 1226 tile_size, gfx::Size(max_texture_size + 1, 10)); | 1233 tile_size, gfx::Size(max_texture_size + 1, 10)); |
| 1227 huge_pile->set_is_mask(true); | 1234 huge_pile->SetIsMask(true); |
| 1228 SetupPendingTree(huge_pile); | 1235 SetupPendingTree(huge_pile); |
| 1229 | 1236 |
| 1230 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); |
| 1231 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1238 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 1232 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1239 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1233 | 1240 |
| 1234 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1241 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| 1235 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1242 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1236 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1243 pending_layer_->HighResTiling()->AllTilesForTesting()); |
| 1237 | 1244 |
| 1238 ActivateTree(); | 1245 ActivateTree(); |
| 1239 | 1246 |
| 1240 // 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. |
| 1241 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1248 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 1242 // The mask resource is empty. | 1249 // The mask resource is empty. |
| 1243 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1250 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1244 EXPECT_EQ(0u, mask_resource_id); | 1251 EXPECT_EQ(0u, mask_resource_id); |
| 1245 } | 1252 } |
| 1246 | 1253 |
| 1247 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { | 1254 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { |
| 1248 gfx::Size tile_size(100, 100); | 1255 gfx::Size tile_size(100, 100); |
| 1249 | 1256 |
| 1250 scoped_refptr<FakePicturePileImpl> valid_pile = | 1257 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 1251 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 1258 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); |
| 1252 valid_pile->set_is_mask(true); | 1259 valid_pile->SetIsMask(true); |
| 1253 SetupPendingTree(valid_pile); | 1260 SetupPendingTree(valid_pile); |
| 1254 | 1261 |
| 1255 float ideal_contents_scale = 1.3f; | 1262 float ideal_contents_scale = 1.3f; |
| 1256 SetupDrawPropertiesAndUpdateTiles( | 1263 SetupDrawPropertiesAndUpdateTiles( |
| 1257 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); |
| 1258 EXPECT_EQ(ideal_contents_scale, | 1265 EXPECT_EQ(ideal_contents_scale, |
| 1259 pending_layer_->HighResTiling()->contents_scale()); | 1266 pending_layer_->HighResTiling()->contents_scale()); |
| 1260 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1267 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1261 | 1268 |
| 1262 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1269 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 // Solid color layer should not have tilings. | 1499 // Solid color layer should not have tilings. |
| 1493 ASSERT_FALSE(active_layer_->CanHaveTilings()); | 1500 ASSERT_FALSE(active_layer_->CanHaveTilings()); |
| 1494 | 1501 |
| 1495 // Update properties with solid color pile should not allow tilings at any | 1502 // Update properties with solid color pile should not allow tilings at any |
| 1496 // scale. | 1503 // scale. |
| 1497 host_impl_.active_tree()->UpdateDrawProperties(); | 1504 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1498 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1505 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
| 1499 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); | 1506 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); |
| 1500 | 1507 |
| 1501 // Push non-solid-color pending pile makes active layer can have tilings. | 1508 // Push non-solid-color pending pile makes active layer can have tilings. |
| 1502 active_layer_->UpdatePile(pending_pile); | 1509 active_layer_->UpdateRasterSource(pending_pile); |
| 1503 ASSERT_TRUE(active_layer_->CanHaveTilings()); | 1510 ASSERT_TRUE(active_layer_->CanHaveTilings()); |
| 1504 | 1511 |
| 1505 // Update properties with non-solid color pile should allow tilings. | 1512 // Update properties with non-solid color pile should allow tilings. |
| 1506 host_impl_.active_tree()->UpdateDrawProperties(); | 1513 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1507 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1514 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
| 1508 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); | 1515 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); |
| 1509 } | 1516 } |
| 1510 | 1517 |
| 1511 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1518 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
| 1512 gfx::Size tile_size(100, 100); | 1519 gfx::Size tile_size(100, 100); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 2044 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
| 2038 gfx::Size tile_size(100, 100); | 2045 gfx::Size tile_size(100, 100); |
| 2039 gfx::Size layer_bounds(400, 400); | 2046 gfx::Size layer_bounds(400, 400); |
| 2040 scoped_refptr<FakePicturePileImpl> pending_pile = | 2047 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2041 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2048 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2042 | 2049 |
| 2043 host_impl_.CreatePendingTree(); | 2050 host_impl_.CreatePendingTree(); |
| 2044 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 2051 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 2045 | 2052 |
| 2046 scoped_ptr<FakePictureLayerImpl> pending_layer = | 2053 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| 2047 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pending_pile); | 2054 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
| 2055 pending_pile); |
| 2048 pending_layer->SetDrawsContent(true); | 2056 pending_layer->SetDrawsContent(true); |
| 2049 pending_tree->SetRootLayer(pending_layer.Pass()); | 2057 pending_tree->SetRootLayer(pending_layer.Pass()); |
| 2050 | 2058 |
| 2051 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 2059 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 2052 host_impl_.pending_tree()->LayerById(id_)); | 2060 host_impl_.pending_tree()->LayerById(id_)); |
| 2053 | 2061 |
| 2054 // Set some state on the pending layer, make sure it is not clobbered | 2062 // Set some state on the pending layer, make sure it is not clobbered |
| 2055 // by a sync from the active layer. This could happen because if the | 2063 // by a sync from the active layer. This could happen because if the |
| 2056 // pending layer has not been post-commit initialized it will attempt | 2064 // pending layer has not been post-commit initialized it will attempt |
| 2057 // to sync from the active layer. | 2065 // to sync from the active layer. |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3701 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); | 3709 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); |
| 3702 | 3710 |
| 3703 scoped_ptr<FakePictureLayerImpl> layer_with_mask = | 3711 scoped_ptr<FakePictureLayerImpl> layer_with_mask = |
| 3704 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); | 3712 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); |
| 3705 | 3713 |
| 3706 layer_with_mask->SetBounds(bounds); | 3714 layer_with_mask->SetBounds(bounds); |
| 3707 layer_with_mask->SetContentBounds(bounds); | 3715 layer_with_mask->SetContentBounds(bounds); |
| 3708 | 3716 |
| 3709 scoped_refptr<FakePicturePileImpl> pending_pile = | 3717 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3710 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); | 3718 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); |
| 3711 pending_pile->set_is_mask(true); | 3719 pending_pile->SetIsMask(true); |
| 3712 scoped_ptr<FakePictureLayerImpl> mask = FakePictureLayerImpl::CreateWithPile( | 3720 scoped_ptr<FakePictureLayerImpl> mask = |
| 3713 host_impl_.pending_tree(), 3, pending_pile); | 3721 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 3, |
| 3722 pending_pile); |
| 3714 | 3723 |
| 3715 mask->SetBounds(bounds); | 3724 mask->SetBounds(bounds); |
| 3716 mask->SetContentBounds(bounds); | 3725 mask->SetContentBounds(bounds); |
| 3717 mask->SetDrawsContent(true); | 3726 mask->SetDrawsContent(true); |
| 3718 | 3727 |
| 3719 FakePictureLayerImpl* pending_mask_content = mask.get(); | 3728 FakePictureLayerImpl* pending_mask_content = mask.get(); |
| 3720 layer_with_mask->SetMaskLayer(mask.Pass()); | 3729 layer_with_mask->SetMaskLayer(mask.Pass()); |
| 3721 | 3730 |
| 3722 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = | 3731 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = |
| 3723 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); | 3732 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4478 | 4487 |
| 4479 gfx::Size tile_size(100, 100); | 4488 gfx::Size tile_size(100, 100); |
| 4480 gfx::Size layer_bounds(200, 200); | 4489 gfx::Size layer_bounds(200, 200); |
| 4481 gfx::Rect layer_rect(layer_bounds); | 4490 gfx::Rect layer_rect(layer_bounds); |
| 4482 | 4491 |
| 4483 FakeContentLayerClient client; | 4492 FakeContentLayerClient client; |
| 4484 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4493 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4485 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 4494 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 4486 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4495 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 4487 host->SetRootLayer(layer); | 4496 host->SetRootLayer(layer); |
| 4488 PicturePile* pile = layer->GetPicturePileForTesting(); | 4497 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4489 | 4498 |
| 4490 host_impl_.SetViewportSize(layer_bounds); | 4499 host_impl_.SetViewportSize(layer_bounds); |
| 4491 | 4500 |
| 4492 int frame_number = 0; | 4501 int frame_number = 0; |
| 4493 FakeRenderingStatsInstrumentation stats_instrumentation; | |
| 4494 | 4502 |
| 4495 client.set_fill_with_nonsolid_color(!test_for_solid); | 4503 client.set_fill_with_nonsolid_color(!test_for_solid); |
| 4496 | 4504 |
| 4497 Region invalidation(layer_rect); | 4505 Region invalidation(layer_rect); |
| 4498 pile->UpdateAndExpandInvalidation(&client, | 4506 recording_source->UpdateAndExpandInvalidation( |
| 4499 &invalidation, | 4507 &client, &invalidation, SK_ColorWHITE, false, false, layer_bounds, |
| 4500 SK_ColorWHITE, | 4508 layer_rect, frame_number++, Picture::RECORD_NORMALLY); |
| 4501 false, | |
| 4502 false, | |
| 4503 layer_bounds, | |
| 4504 layer_rect, | |
| 4505 frame_number++, | |
| 4506 Picture::RECORD_NORMALLY, | |
| 4507 &stats_instrumentation); | |
| 4508 | 4509 |
| 4509 scoped_refptr<PicturePileImpl> pending_pile = | 4510 scoped_refptr<RasterSource> pending_raster_source = |
| 4510 PicturePileImpl::CreateFromOther(pile); | 4511 recording_source->CreateRasterSource(); |
| 4511 | 4512 |
| 4512 SetupPendingTree(pending_pile); | 4513 SetupPendingTree(pending_raster_source); |
| 4513 ActivateTree(); | 4514 ActivateTree(); |
| 4514 | 4515 |
| 4515 active_layer_->set_fixed_tile_size(tile_size); | 4516 active_layer_->set_fixed_tile_size(tile_size); |
| 4516 host_impl_.active_tree()->UpdateDrawProperties(); | 4517 host_impl_.active_tree()->UpdateDrawProperties(); |
| 4517 if (test_for_solid) { | 4518 if (test_for_solid) { |
| 4518 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4519 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4519 } else { | 4520 } else { |
| 4520 ASSERT_TRUE(active_layer_->tilings()); | 4521 ASSERT_TRUE(active_layer_->tilings()); |
| 4521 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4522 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
| 4522 std::vector<Tile*> tiles = | 4523 std::vector<Tile*> tiles = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4553 | 4554 |
| 4554 gfx::Size tile_size(100, 100); | 4555 gfx::Size tile_size(100, 100); |
| 4555 gfx::Size layer_bounds(200, 200); | 4556 gfx::Size layer_bounds(200, 200); |
| 4556 gfx::Rect layer_rect(layer_bounds); | 4557 gfx::Rect layer_rect(layer_bounds); |
| 4557 | 4558 |
| 4558 FakeContentLayerClient client; | 4559 FakeContentLayerClient client; |
| 4559 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4560 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4560 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 4561 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 4561 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4562 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 4562 host->SetRootLayer(layer); | 4563 host->SetRootLayer(layer); |
| 4563 PicturePile* pile = layer->GetPicturePileForTesting(); | 4564 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4564 | 4565 |
| 4565 host_impl_.SetViewportSize(layer_bounds); | 4566 host_impl_.SetViewportSize(layer_bounds); |
| 4566 | 4567 |
| 4567 int frame_number = 0; | 4568 int frame_number = 0; |
| 4568 FakeRenderingStatsInstrumentation stats_instrumentation; | |
| 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 pile->UpdateAndExpandInvalidation(&client, | 4573 recording_source->UpdateAndExpandInvalidation( |
| 4574 &invalidation1, | 4574 &client, &invalidation1, SK_ColorWHITE, false, false, layer_bounds, |
| 4575 SK_ColorWHITE, | 4575 layer_rect, frame_number++, Picture::RECORD_NORMALLY); |
| 4576 false, | |
| 4577 false, | |
| 4578 layer_bounds, | |
| 4579 layer_rect, | |
| 4580 frame_number++, | |
| 4581 Picture::RECORD_NORMALLY, | |
| 4582 &stats_instrumentation); | |
| 4583 | 4576 |
| 4584 scoped_refptr<PicturePileImpl> pending_pile1 = | 4577 scoped_refptr<RasterSource> raster_source1 = |
| 4585 PicturePileImpl::CreateFromOther(pile); | 4578 recording_source->CreateRasterSource(); |
| 4586 | 4579 |
| 4587 SetupPendingTree(pending_pile1); | 4580 SetupPendingTree(raster_source1); |
| 4588 ActivateTree(); | 4581 ActivateTree(); |
| 4589 host_impl_.active_tree()->UpdateDrawProperties(); | 4582 host_impl_.active_tree()->UpdateDrawProperties(); |
| 4590 | 4583 |
| 4591 // We've started with a solid layer that contains some tilings. | 4584 // We've started with a solid layer that contains some tilings. |
| 4592 ASSERT_TRUE(active_layer_->tilings()); | 4585 ASSERT_TRUE(active_layer_->tilings()); |
| 4593 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); | 4586 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); |
| 4594 | 4587 |
| 4595 client.set_fill_with_nonsolid_color(false); | 4588 client.set_fill_with_nonsolid_color(false); |
| 4596 | 4589 |
| 4597 Region invalidation2(layer_rect); | 4590 Region invalidation2(layer_rect); |
| 4598 pile->UpdateAndExpandInvalidation(&client, | 4591 recording_source->UpdateAndExpandInvalidation( |
| 4599 &invalidation2, | 4592 &client, &invalidation2, SK_ColorWHITE, false, false, layer_bounds, |
| 4600 SK_ColorWHITE, | 4593 layer_rect, frame_number++, Picture::RECORD_NORMALLY); |
| 4601 false, | |
| 4602 false, | |
| 4603 layer_bounds, | |
| 4604 layer_rect, | |
| 4605 frame_number++, | |
| 4606 Picture::RECORD_NORMALLY, | |
| 4607 &stats_instrumentation); | |
| 4608 | 4594 |
| 4609 scoped_refptr<PicturePileImpl> pending_pile2 = | 4595 scoped_refptr<RasterSource> raster_source2 = |
| 4610 PicturePileImpl::CreateFromOther(pile); | 4596 recording_source->CreateRasterSource(); |
| 4611 | 4597 |
| 4612 SetupPendingTree(pending_pile2); | 4598 SetupPendingTree(raster_source2); |
| 4613 ActivateTree(); | 4599 ActivateTree(); |
| 4614 | 4600 |
| 4615 // 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. |
| 4616 ASSERT_TRUE(active_layer_->tilings()); | 4602 ASSERT_TRUE(active_layer_->tilings()); |
| 4617 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4603 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4618 } | 4604 } |
| 4619 | 4605 |
| 4620 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { | 4606 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { |
| 4621 base::TimeTicks time_ticks; | 4607 base::TimeTicks time_ticks; |
| 4622 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4608 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4736 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4722 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4737 EXPECT_EQ(result.width(), 448); | 4723 EXPECT_EQ(result.width(), 448); |
| 4738 EXPECT_EQ(result.height(), 448); | 4724 EXPECT_EQ(result.height(), 448); |
| 4739 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4725 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4740 EXPECT_EQ(result.width(), 512); | 4726 EXPECT_EQ(result.width(), 512); |
| 4741 EXPECT_EQ(result.height(), 500 + 2); | 4727 EXPECT_EQ(result.height(), 500 + 2); |
| 4742 } | 4728 } |
| 4743 | 4729 |
| 4744 } // namespace | 4730 } // namespace |
| 4745 } // namespace cc | 4731 } // namespace cc |
| OLD | NEW |