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 4472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4483 PicturePileImpl::CreateFromOther(pile); | 4483 PicturePileImpl::CreateFromOther(pile); |
4484 | 4484 |
4485 SetupPendingTree(pending_pile2); | 4485 SetupPendingTree(pending_pile2); |
4486 ActivateTree(); | 4486 ActivateTree(); |
4487 | 4487 |
4488 // We've switched to a solid color, so we should end up with no tilings. | 4488 // We've switched to a solid color, so we should end up with no tilings. |
4489 ASSERT_TRUE(active_layer_->tilings()); | 4489 ASSERT_TRUE(active_layer_->tilings()); |
4490 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4490 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
4491 } | 4491 } |
4492 | 4492 |
| 4493 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { |
| 4494 base::TimeTicks time_ticks; |
| 4495 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4496 host_impl_.SetCurrentBeginFrameArgs( |
| 4497 CreateBeginFrameArgsForTesting(time_ticks)); |
| 4498 |
| 4499 gfx::Size tile_size(100, 100); |
| 4500 gfx::Size layer_bounds(400, 4000); |
| 4501 |
| 4502 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4503 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4504 scoped_refptr<FakePicturePileImpl> active_pile = |
| 4505 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4506 |
| 4507 SetupTrees(pending_pile, active_pile); |
| 4508 |
| 4509 Region invalidation; |
| 4510 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); |
| 4511 gfx::Transform transform; |
| 4512 |
| 4513 host_impl_.SetRequiresHighResToDraw(); |
| 4514 |
| 4515 // Update tiles. |
| 4516 pending_layer_->draw_properties().visible_content_rect = viewport; |
| 4517 pending_layer_->draw_properties().screen_space_transform = transform; |
| 4518 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 4519 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 4520 |
| 4521 // Ensure we can't activate. |
| 4522 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| 4523 |
| 4524 // Now in the same frame, move the viewport (this can happen during |
| 4525 // animation). |
| 4526 viewport = gfx::Rect(0, 2000, 100, 100); |
| 4527 |
| 4528 // Update tiles. |
| 4529 pending_layer_->draw_properties().visible_content_rect = viewport; |
| 4530 pending_layer_->draw_properties().screen_space_transform = transform; |
| 4531 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 4532 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 4533 |
| 4534 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. |
| 4535 std::vector<Tile*> tiles; |
| 4536 for (PictureLayerTiling::CoverageIterator iter( |
| 4537 pending_layer_->HighResTiling(), |
| 4538 1.f, |
| 4539 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4540 iter; |
| 4541 ++iter) { |
| 4542 if (*iter) |
| 4543 tiles.push_back(*iter); |
| 4544 } |
| 4545 |
| 4546 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4547 |
| 4548 // Ensure we can activate. |
| 4549 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| 4550 } |
| 4551 |
4493 class TileSizeSettings : public ImplSidePaintingSettings { | 4552 class TileSizeSettings : public ImplSidePaintingSettings { |
4494 public: | 4553 public: |
4495 TileSizeSettings() { | 4554 TileSizeSettings() { |
4496 default_tile_size = gfx::Size(100, 100); | 4555 default_tile_size = gfx::Size(100, 100); |
4497 max_untiled_layer_size = gfx::Size(200, 200); | 4556 max_untiled_layer_size = gfx::Size(200, 200); |
4498 } | 4557 } |
4499 }; | 4558 }; |
4500 | 4559 |
4501 class TileSizeTest : public PictureLayerImplTest { | 4560 class TileSizeTest : public PictureLayerImplTest { |
4502 public: | 4561 public: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4550 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4609 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4551 EXPECT_EQ(result.width(), 448); | 4610 EXPECT_EQ(result.width(), 448); |
4552 EXPECT_EQ(result.height(), 448); | 4611 EXPECT_EQ(result.height(), 448); |
4553 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4612 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4554 EXPECT_EQ(result.width(), 512); | 4613 EXPECT_EQ(result.width(), 512); |
4555 EXPECT_EQ(result.height(), 500 + 2); | 4614 EXPECT_EQ(result.height(), 500 + 2); |
4556 } | 4615 } |
4557 | 4616 |
4558 } // namespace | 4617 } // namespace |
4559 } // namespace cc | 4618 } // namespace cc |
OLD | NEW |