| 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 4652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4663 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4663 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 4664 host->SetRootLayer(layer); | 4664 host->SetRootLayer(layer); |
| 4665 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4665 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4666 | 4666 |
| 4667 int frame_number = 0; | 4667 int frame_number = 0; |
| 4668 | 4668 |
| 4669 client.set_fill_with_nonsolid_color(!test_for_solid); | 4669 client.set_fill_with_nonsolid_color(!test_for_solid); |
| 4670 | 4670 |
| 4671 Region invalidation(layer_rect); | 4671 Region invalidation(layer_rect); |
| 4672 recording_source->UpdateAndExpandInvalidation( | 4672 recording_source->UpdateAndExpandInvalidation( |
| 4673 &client, &invalidation, false, layer_bounds, layer_rect, frame_number++, | 4673 &client, &invalidation, layer_bounds, layer_rect, frame_number++, |
| 4674 RecordingSource::RECORD_NORMALLY); | 4674 RecordingSource::RECORD_NORMALLY); |
| 4675 | 4675 |
| 4676 scoped_refptr<RasterSource> pending_raster_source = | 4676 scoped_refptr<RasterSource> pending_raster_source = |
| 4677 recording_source->CreateRasterSource(); | 4677 recording_source->CreateRasterSource(true); |
| 4678 | 4678 |
| 4679 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 4679 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 4680 ActivateTree(); | 4680 ActivateTree(); |
| 4681 | 4681 |
| 4682 if (test_for_solid) { | 4682 if (test_for_solid) { |
| 4683 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4683 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4684 } else { | 4684 } else { |
| 4685 ASSERT_TRUE(active_layer_->tilings()); | 4685 ASSERT_TRUE(active_layer_->tilings()); |
| 4686 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4686 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
| 4687 std::vector<Tile*> tiles = | 4687 std::vector<Tile*> tiles = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4726 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4726 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 4727 host->SetRootLayer(layer); | 4727 host->SetRootLayer(layer); |
| 4728 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4728 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4729 | 4729 |
| 4730 int frame_number = 0; | 4730 int frame_number = 0; |
| 4731 | 4731 |
| 4732 client.set_fill_with_nonsolid_color(true); | 4732 client.set_fill_with_nonsolid_color(true); |
| 4733 | 4733 |
| 4734 Region invalidation1(layer_rect); | 4734 Region invalidation1(layer_rect); |
| 4735 recording_source->UpdateAndExpandInvalidation( | 4735 recording_source->UpdateAndExpandInvalidation( |
| 4736 &client, &invalidation1, false, layer_bounds, layer_rect, frame_number++, | 4736 &client, &invalidation1, layer_bounds, layer_rect, frame_number++, |
| 4737 RecordingSource::RECORD_NORMALLY); | 4737 RecordingSource::RECORD_NORMALLY); |
| 4738 | 4738 |
| 4739 scoped_refptr<RasterSource> raster_source1 = | 4739 scoped_refptr<RasterSource> raster_source1 = |
| 4740 recording_source->CreateRasterSource(); | 4740 recording_source->CreateRasterSource(true); |
| 4741 | 4741 |
| 4742 SetupPendingTree(raster_source1); | 4742 SetupPendingTree(raster_source1); |
| 4743 ActivateTree(); | 4743 ActivateTree(); |
| 4744 host_impl_.active_tree()->UpdateDrawProperties(); | 4744 host_impl_.active_tree()->UpdateDrawProperties(); |
| 4745 | 4745 |
| 4746 // We've started with a solid layer that contains some tilings. | 4746 // We've started with a solid layer that contains some tilings. |
| 4747 ASSERT_TRUE(active_layer_->tilings()); | 4747 ASSERT_TRUE(active_layer_->tilings()); |
| 4748 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); | 4748 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); |
| 4749 | 4749 |
| 4750 client.set_fill_with_nonsolid_color(false); | 4750 client.set_fill_with_nonsolid_color(false); |
| 4751 | 4751 |
| 4752 Region invalidation2(layer_rect); | 4752 Region invalidation2(layer_rect); |
| 4753 recording_source->UpdateAndExpandInvalidation( | 4753 recording_source->UpdateAndExpandInvalidation( |
| 4754 &client, &invalidation2, false, layer_bounds, layer_rect, frame_number++, | 4754 &client, &invalidation2, layer_bounds, layer_rect, frame_number++, |
| 4755 RecordingSource::RECORD_NORMALLY); | 4755 RecordingSource::RECORD_NORMALLY); |
| 4756 | 4756 |
| 4757 scoped_refptr<RasterSource> raster_source2 = | 4757 scoped_refptr<RasterSource> raster_source2 = |
| 4758 recording_source->CreateRasterSource(); | 4758 recording_source->CreateRasterSource(true); |
| 4759 | 4759 |
| 4760 SetupPendingTree(raster_source2); | 4760 SetupPendingTree(raster_source2); |
| 4761 ActivateTree(); | 4761 ActivateTree(); |
| 4762 | 4762 |
| 4763 // We've switched to a solid color, so we should end up with no tilings. | 4763 // We've switched to a solid color, so we should end up with no tilings. |
| 4764 ASSERT_TRUE(active_layer_->tilings()); | 4764 ASSERT_TRUE(active_layer_->tilings()); |
| 4765 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4765 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4766 } | 4766 } |
| 4767 | 4767 |
| 4768 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { | 4768 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4947 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4947 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4948 EXPECT_EQ(result.width(), 448); | 4948 EXPECT_EQ(result.width(), 448); |
| 4949 EXPECT_EQ(result.height(), 448); | 4949 EXPECT_EQ(result.height(), 448); |
| 4950 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4950 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4951 EXPECT_EQ(result.width(), 512); | 4951 EXPECT_EQ(result.width(), 512); |
| 4952 EXPECT_EQ(result.height(), 500 + 2); | 4952 EXPECT_EQ(result.height(), 500 + 2); |
| 4953 } | 4953 } |
| 4954 | 4954 |
| 4955 } // namespace | 4955 } // namespace |
| 4956 } // namespace cc | 4956 } // namespace cc |
| OLD | NEW |