| 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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_impl.h" | 7 #include "cc/layer_tree_impl.h" |
| 8 #include "cc/test/fake_content_layer_client.h" | 8 #include "cc/test/fake_content_layer_client.h" |
| 9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 TestablePictureLayerImpl::create(pending_tree, id_, pile); | 167 TestablePictureLayerImpl::create(pending_tree, id_, pile); |
| 168 pending_layer->setDrawsContent(true); | 168 pending_layer->setDrawsContent(true); |
| 169 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 169 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 static void VerifyAllTilesExistAndHavePile( | 172 static void VerifyAllTilesExistAndHavePile( |
| 173 const PictureLayerTiling* tiling, | 173 const PictureLayerTiling* tiling, |
| 174 PicturePileImpl* pile) { | 174 PicturePileImpl* pile) { |
| 175 for (PictureLayerTiling::Iterator iter(tiling, | 175 for (PictureLayerTiling::Iterator iter(tiling, |
| 176 tiling->contents_scale(), | 176 tiling->contents_scale(), |
| 177 tiling->ContentRect()); | 177 tiling->ContentRect(), |
| 178 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
| 178 iter; ++iter) { | 179 iter; ++iter) { |
| 179 EXPECT_TRUE(*iter); | 180 EXPECT_TRUE(*iter); |
| 180 EXPECT_EQ(pile, iter->picture_pile()); | 181 EXPECT_EQ(pile, iter->picture_pile()); |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| 184 void SetContentsScaleOnBothLayers(float scale, bool animating_transform) { | 185 void SetContentsScaleOnBothLayers(float scale, bool animating_transform) { |
| 185 float result_scale_x, result_scale_y; | 186 float result_scale_x, result_scale_y; |
| 186 gfx::Size result_bounds; | 187 gfx::Size result_bounds; |
| 187 pending_layer_->calculateContentsScale( | 188 pending_layer_->calculateContentsScale( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 243 |
| 243 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); | 244 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); |
| 244 EXPECT_GT(tilings.num_tilings(), 0u); | 245 EXPECT_GT(tilings.num_tilings(), 0u); |
| 245 for (size_t i = 0; i < tilings.num_tilings(); ++i) { | 246 for (size_t i = 0; i < tilings.num_tilings(); ++i) { |
| 246 const PictureLayerTiling* tiling = tilings.tiling_at(i); | 247 const PictureLayerTiling* tiling = tilings.tiling_at(i); |
| 247 gfx::Rect content_invalidation = gfx::ToEnclosingRect(gfx::ScaleRect( | 248 gfx::Rect content_invalidation = gfx::ToEnclosingRect(gfx::ScaleRect( |
| 248 layer_invalidation, | 249 layer_invalidation, |
| 249 tiling->contents_scale())); | 250 tiling->contents_scale())); |
| 250 for (PictureLayerTiling::Iterator iter(tiling, | 251 for (PictureLayerTiling::Iterator iter(tiling, |
| 251 tiling->contents_scale(), | 252 tiling->contents_scale(), |
| 252 tiling->ContentRect()); | 253 tiling->ContentRect(), |
| 254 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
| 253 iter; ++iter) { | 255 iter; ++iter) { |
| 254 EXPECT_TRUE(*iter); | 256 EXPECT_TRUE(*iter); |
| 255 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 257 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 256 if (iter.geometry_rect().Intersects(content_invalidation)) | 258 if (iter.geometry_rect().Intersects(content_invalidation)) |
| 257 EXPECT_EQ(pending_pile, iter->picture_pile()); | 259 EXPECT_EQ(pending_pile, iter->picture_pile()); |
| 258 else | 260 else |
| 259 EXPECT_EQ(active_pile, iter->picture_pile()); | 261 EXPECT_EQ(active_pile, iter->picture_pile()); |
| 260 } | 262 } |
| 261 } | 263 } |
| 262 } | 264 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 304 |
| 303 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); | 305 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); |
| 304 EXPECT_GT(tilings.num_tilings(), 0u); | 306 EXPECT_GT(tilings.num_tilings(), 0u); |
| 305 for (size_t i = 0; i < tilings.num_tilings(); ++i) { | 307 for (size_t i = 0; i < tilings.num_tilings(); ++i) { |
| 306 const PictureLayerTiling* tiling = tilings.tiling_at(i); | 308 const PictureLayerTiling* tiling = tilings.tiling_at(i); |
| 307 gfx::Rect active_content_bounds = gfx::ToEnclosingRect(gfx::ScaleRect( | 309 gfx::Rect active_content_bounds = gfx::ToEnclosingRect(gfx::ScaleRect( |
| 308 gfx::Rect(active_layer_bounds), | 310 gfx::Rect(active_layer_bounds), |
| 309 tiling->contents_scale())); | 311 tiling->contents_scale())); |
| 310 for (PictureLayerTiling::Iterator iter(tiling, | 312 for (PictureLayerTiling::Iterator iter(tiling, |
| 311 tiling->contents_scale(), | 313 tiling->contents_scale(), |
| 312 tiling->ContentRect()); | 314 tiling->ContentRect(), |
| 315 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
| 313 iter; ++iter) { | 316 iter; ++iter) { |
| 314 EXPECT_TRUE(*iter); | 317 EXPECT_TRUE(*iter); |
| 315 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 318 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 316 if (iter.geometry_rect().right() >= active_content_bounds.width() || | 319 if (iter.geometry_rect().right() >= active_content_bounds.width() || |
| 317 iter.geometry_rect().bottom() >= active_content_bounds.height()) { | 320 iter.geometry_rect().bottom() >= active_content_bounds.height()) { |
| 318 EXPECT_EQ(pending_pile, iter->picture_pile()); | 321 EXPECT_EQ(pending_pile, iter->picture_pile()); |
| 319 } else { | 322 } else { |
| 320 EXPECT_EQ(active_pile, iter->picture_pile()); | 323 EXPECT_EQ(active_pile, iter->picture_pile()); |
| 321 } | 324 } |
| 322 } | 325 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 351 Region invalidation; | 354 Region invalidation; |
| 352 AddDefaultTilingsWithInvalidation(invalidation); | 355 AddDefaultTilingsWithInvalidation(invalidation); |
| 353 | 356 |
| 354 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); | 357 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); |
| 355 EXPECT_GT(tilings.num_tilings(), 0u); | 358 EXPECT_GT(tilings.num_tilings(), 0u); |
| 356 for (size_t i = 0; i < tilings.num_tilings(); ++i) { | 359 for (size_t i = 0; i < tilings.num_tilings(); ++i) { |
| 357 const PictureLayerTiling* tiling = tilings.tiling_at(i); | 360 const PictureLayerTiling* tiling = tilings.tiling_at(i); |
| 358 | 361 |
| 359 for (PictureLayerTiling::Iterator iter(tiling, | 362 for (PictureLayerTiling::Iterator iter(tiling, |
| 360 tiling->contents_scale(), | 363 tiling->contents_scale(), |
| 361 tiling->ContentRect()); | 364 tiling->ContentRect(), |
| 365 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
| 362 iter; ++iter) { | 366 iter; ++iter) { |
| 363 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); | 367 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); |
| 364 // Ensure there is a recording for this tile. | 368 // Ensure there is a recording for this tile. |
| 365 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 369 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
| 366 gfx::ScaleRect( | 370 gfx::ScaleRect( |
| 367 iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale())); | 371 iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale())); |
| 368 layer_rect.Intersect(gfx::Rect(layer_bounds)); | 372 layer_rect.Intersect(gfx::Rect(layer_bounds)); |
| 369 | 373 |
| 370 bool in_pending = pending_pile->recorded_region().Contains(layer_rect); | 374 bool in_pending = pending_pile->recorded_region().Contains(layer_rect); |
| 371 bool in_active = active_pile->recorded_region().Contains(layer_rect); | 375 bool in_active = active_pile->recorded_region().Contains(layer_rect); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 603 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 600 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); | 604 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); |
| 601 used_tilings.clear(); | 605 used_tilings.clear(); |
| 602 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 606 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 603 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 607 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
| 604 | 608 |
| 605 } | 609 } |
| 606 | 610 |
| 607 } // namespace | 611 } // namespace |
| 608 } // namespace cc | 612 } // namespace cc |
| OLD | NEW |