OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include "cc/debug/overdraw_metrics.h" | 7 #include "cc/debug/overdraw_metrics.h" |
8 #include "cc/resources/bitmap_content_layer_updater.h" | 8 #include "cc/resources/bitmap_content_layer_updater.h" |
9 #include "cc/resources/layer_painter.h" | 9 #include "cc/resources/layer_painter.h" |
10 #include "cc/resources/prioritized_resource_manager.h" | 10 #include "cc/resources/prioritized_resource_manager.h" |
11 #include "cc/resources/resource_update_controller.h" | 11 #include "cc/resources/resource_update_controller.h" |
12 #include "cc/test/animation_test_common.h" | 12 #include "cc/test/animation_test_common.h" |
13 #include "cc/test/fake_layer_tree_host_client.h" | 13 #include "cc/test/fake_layer_tree_host_client.h" |
14 #include "cc/test/fake_layer_tree_host_impl.h" | 14 #include "cc/test/fake_layer_tree_host_impl.h" |
15 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
16 #include "cc/test/fake_proxy.h" | 16 #include "cc/test/fake_proxy.h" |
17 #include "cc/test/fake_rendering_stats_instrumentation.h" | |
17 #include "cc/test/geometry_test_utils.h" | 18 #include "cc/test/geometry_test_utils.h" |
18 #include "cc/test/tiled_layer_test_common.h" | 19 #include "cc/test/tiled_layer_test_common.h" |
19 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread | 20 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/rect_conversions.h" | 22 #include "ui/gfx/rect_conversions.h" |
22 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
23 | 24 |
24 namespace cc { | 25 namespace cc { |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 m_queue = make_scoped_ptr(new ResourceUpdateQueue); | 101 m_queue = make_scoped_ptr(new ResourceUpdateQueue); |
101 } | 102 } |
102 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl) | 103 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl) |
103 { | 104 { |
104 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(proxy_); | 105 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(proxy_); |
105 layer->PushPropertiesTo(layerImpl); | 106 layer->PushPropertiesTo(layerImpl); |
106 } | 107 } |
107 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) | 108 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) |
108 { | 109 { |
109 DebugScopedSetMainThread mainThread(proxy_); | 110 DebugScopedSetMainThread mainThread(proxy_); |
110 layer->Update(m_queue.get(), occluded, NULL); | 111 layer->Update(m_queue.get(), occluded); |
111 } | 112 } |
112 | 113 |
113 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) | 114 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) |
114 { | 115 { |
115 scoped_refptr<FakeTiledLayer> layer2; | 116 scoped_refptr<FakeTiledLayer> layer2; |
116 calcDrawProps(layer1, layer2); | 117 calcDrawProps(layer1, layer2); |
117 } | 118 } |
118 | 119 |
119 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, | 120 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, |
120 const scoped_refptr<FakeTiledLayer>& layer2) | 121 const scoped_refptr<FakeTiledLayer>& layer2) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // Get textures | 154 // Get textures |
154 resource_manager_->ClearPriorities(); | 155 resource_manager_->ClearPriorities(); |
155 if (layer1) | 156 if (layer1) |
156 layer1->SetTexturePriorities(m_priorityCalculator); | 157 layer1->SetTexturePriorities(m_priorityCalculator); |
157 if (layer2) | 158 if (layer2) |
158 layer2->SetTexturePriorities(m_priorityCalculator); | 159 layer2->SetTexturePriorities(m_priorityCalculator); |
159 resource_manager_->PrioritizeTextures(); | 160 resource_manager_->PrioritizeTextures(); |
160 | 161 |
161 // Update content | 162 // Update content |
162 if (layer1) | 163 if (layer1) |
163 layer1->Update(m_queue.get(), m_occlusion, NULL); | 164 layer1->Update(m_queue.get(), m_occlusion); |
164 if (layer2) | 165 if (layer2) |
165 layer2->Update(m_queue.get(), m_occlusion, NULL); | 166 layer2->Update(m_queue.get(), m_occlusion); |
166 | 167 |
167 bool needsUpdate = false; | 168 bool needsUpdate = false; |
168 if (layer1) | 169 if (layer1) |
169 needsUpdate |= layer1->NeedsIdlePaint(); | 170 needsUpdate |= layer1->NeedsIdlePaint(); |
170 if (layer2) | 171 if (layer2) |
171 needsUpdate |= layer2->NeedsIdlePaint(); | 172 needsUpdate |= layer2->NeedsIdlePaint(); |
172 | 173 |
173 // Update textures and push. | 174 // Update textures and push. |
174 updateTextures(); | 175 updateTextures(); |
175 if (layer1) | 176 if (layer1) |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 | 568 |
568 // Pretend the layer is animating. | 569 // Pretend the layer is animating. |
569 layer->draw_properties().target_space_transform_is_animating = true; | 570 layer->draw_properties().target_space_transform_is_animating = true; |
570 layer->draw_properties().visible_content_rect = visibleRect; | 571 layer->draw_properties().visible_content_rect = visibleRect; |
571 layer->SetLayerTreeHost(layer_tree_host_.get()); | 572 layer->SetLayerTreeHost(layer_tree_host_.get()); |
572 | 573 |
573 // The layer should paint its entire contents on the first paint | 574 // The layer should paint its entire contents on the first paint |
574 // if it is close to the viewport size and has the available memory. | 575 // if it is close to the viewport size and has the available memory. |
575 layer->SetTexturePriorities(m_priorityCalculator); | 576 layer->SetTexturePriorities(m_priorityCalculator); |
576 resource_manager_->PrioritizeTextures(); | 577 resource_manager_->PrioritizeTextures(); |
577 layer->Update(m_queue.get(), 0, NULL); | 578 layer->Update(m_queue.get(), 0); |
578 updateTextures(); | 579 updateTextures(); |
579 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 580 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
580 | 581 |
581 // We should have all the tiles for the small animated layer. | 582 // We should have all the tiles for the small animated layer. |
582 // We should still have the visible tiles when we didn't | 583 // We should still have the visible tiles when we didn't |
583 // have enough memory for all the tiles. | 584 // have enough memory for all the tiles. |
584 if (!runOutOfMemory[i]) { | 585 if (!runOutOfMemory[i]) { |
585 for (int i = 0; i < 5; ++i) { | 586 for (int i = 0; i < 5; ++i) { |
586 for (int j = 0; j < 5; ++j) | 587 for (int j = 0; j < 5; ++j) |
587 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(i, j)); | 588 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(i, j)); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 layer->SetBounds(layerBounds.size()); | 725 layer->SetBounds(layerBounds.size()); |
725 layer->SetContentBounds(contentBounds.size()); | 726 layer->SetContentBounds(contentBounds.size()); |
726 layer->draw_properties().visible_content_rect = contentBounds; | 727 layer->draw_properties().visible_content_rect = contentBounds; |
727 | 728 |
728 // On first update, the updateRect includes all tiles, even beyond the bound aries of the layer. | 729 // On first update, the updateRect includes all tiles, even beyond the bound aries of the layer. |
729 // However, it should still be in layer space, not content space. | 730 // However, it should still be in layer space, not content space. |
730 layer->InvalidateContentRect(contentBounds); | 731 layer->InvalidateContentRect(contentBounds); |
731 | 732 |
732 layer->SetTexturePriorities(m_priorityCalculator); | 733 layer->SetTexturePriorities(m_priorityCalculator); |
733 resource_manager_->PrioritizeTextures(); | 734 resource_manager_->PrioritizeTextures(); |
734 layer->Update(m_queue.get(), 0, NULL); | 735 layer->Update(m_queue.get(), 0); |
735 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect()) ; | 736 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect()) ; |
736 updateTextures(); | 737 updateTextures(); |
737 | 738 |
738 // After the tiles are updated once, another invalidate only needs to update the bounds of the layer. | 739 // After the tiles are updated once, another invalidate only needs to update the bounds of the layer. |
739 layer->SetTexturePriorities(m_priorityCalculator); | 740 layer->SetTexturePriorities(m_priorityCalculator); |
740 resource_manager_->PrioritizeTextures(); | 741 resource_manager_->PrioritizeTextures(); |
741 layer->InvalidateContentRect(contentBounds); | 742 layer->InvalidateContentRect(contentBounds); |
742 layer->Update(m_queue.get(), 0, NULL); | 743 layer->Update(m_queue.get(), 0); |
743 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->update_rect()); | 744 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->update_rect()); |
744 updateTextures(); | 745 updateTextures(); |
745 | 746 |
746 // Partial re-paint should also be represented by the updateRect in layer sp ace, not content space. | 747 // Partial re-paint should also be represented by the updateRect in layer sp ace, not content space. |
747 gfx::Rect partialDamage(30, 100, 10, 10); | 748 gfx::Rect partialDamage(30, 100, 10, 10); |
748 layer->InvalidateContentRect(partialDamage); | 749 layer->InvalidateContentRect(partialDamage); |
749 layer->SetTexturePriorities(m_priorityCalculator); | 750 layer->SetTexturePriorities(m_priorityCalculator); |
750 resource_manager_->PrioritizeTextures(); | 751 resource_manager_->PrioritizeTextures(); |
751 layer->Update(m_queue.get(), 0, NULL); | 752 layer->Update(m_queue.get(), 0); |
752 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); | 753 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); |
753 } | 754 } |
754 | 755 |
755 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) | 756 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) |
756 { | 757 { |
757 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 758 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
758 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->active_tree(), 1)); | 759 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->active_tree(), 1)); |
759 | 760 |
760 // Create a layer with one tile. | 761 // Create a layer with one tile. |
761 layer->SetBounds(gfx::Size(100, 100)); | 762 layer->SetBounds(gfx::Size(100, 100)); |
762 calcDrawProps(layer); | 763 calcDrawProps(layer); |
763 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 764 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
764 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->last_needs_display_r ect()); | 765 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->last_needs_display_r ect()); |
765 | 766 |
766 // Push the tiles to the impl side and check that there is exactly one. | 767 // Push the tiles to the impl side and check that there is exactly one. |
767 layer->SetTexturePriorities(m_priorityCalculator); | 768 layer->SetTexturePriorities(m_priorityCalculator); |
768 resource_manager_->PrioritizeTextures(); | 769 resource_manager_->PrioritizeTextures(); |
769 layer->Update(m_queue.get(), 0, NULL); | 770 layer->Update(m_queue.get(), 0); |
770 updateTextures(); | 771 updateTextures(); |
771 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 772 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
772 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(0, 0)); | 773 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(0, 0)); |
773 EXPECT_FALSE(layerImpl->HasResourceIdForTileAt(0, 1)); | 774 EXPECT_FALSE(layerImpl->HasResourceIdForTileAt(0, 1)); |
774 EXPECT_FALSE(layerImpl->HasResourceIdForTileAt(1, 0)); | 775 EXPECT_FALSE(layerImpl->HasResourceIdForTileAt(1, 0)); |
775 EXPECT_FALSE(layerImpl->HasResourceIdForTileAt(1, 1)); | 776 EXPECT_FALSE(layerImpl->HasResourceIdForTileAt(1, 1)); |
776 | 777 |
777 layer->SetNeedsDisplayRect(gfx::Rect()); | 778 layer->SetNeedsDisplayRect(gfx::Rect()); |
778 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); | 779 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); |
779 | 780 |
780 // Change the contents scale. | 781 // Change the contents scale. |
781 layer->UpdateContentsScale(2); | 782 layer->UpdateContentsScale(2); |
782 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); | 783 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); |
783 | 784 |
784 // The impl side should get 2x2 tiles now. | 785 // The impl side should get 2x2 tiles now. |
785 layer->SetTexturePriorities(m_priorityCalculator); | 786 layer->SetTexturePriorities(m_priorityCalculator); |
786 resource_manager_->PrioritizeTextures(); | 787 resource_manager_->PrioritizeTextures(); |
787 layer->Update(m_queue.get(), 0, NULL); | 788 layer->Update(m_queue.get(), 0); |
788 updateTextures(); | 789 updateTextures(); |
789 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 790 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
790 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(0, 0)); | 791 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(0, 0)); |
791 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(0, 1)); | 792 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(0, 1)); |
792 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(1, 0)); | 793 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(1, 0)); |
793 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(1, 1)); | 794 EXPECT_TRUE(layerImpl->HasResourceIdForTileAt(1, 1)); |
794 | 795 |
795 // Verify that changing the contents scale caused invalidation, and | 796 // Verify that changing the contents scale caused invalidation, and |
796 // that the layer-space rectangle requiring painting is not scaled. | 797 // that the layer-space rectangle requiring painting is not scaled. |
797 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->last_needs_display_r ect()); | 798 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->last_needs_display_r ect()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 TEST_F(TiledLayerTest, resizeToSmaller) | 856 TEST_F(TiledLayerTest, resizeToSmaller) |
856 { | 857 { |
857 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 858 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
858 | 859 |
859 layer->SetBounds(gfx::Size(700, 700)); | 860 layer->SetBounds(gfx::Size(700, 700)); |
860 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); | 861 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
861 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); | 862 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); |
862 | 863 |
863 layer->SetTexturePriorities(m_priorityCalculator); | 864 layer->SetTexturePriorities(m_priorityCalculator); |
864 resource_manager_->PrioritizeTextures(); | 865 resource_manager_->PrioritizeTextures(); |
865 layer->Update(m_queue.get(), 0, NULL); | 866 layer->Update(m_queue.get(), 0); |
866 | 867 |
867 layer->SetBounds(gfx::Size(200, 200)); | 868 layer->SetBounds(gfx::Size(200, 200)); |
868 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); | 869 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); |
869 } | 870 } |
870 | 871 |
871 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) | 872 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) |
872 { | 873 { |
873 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 874 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
874 | 875 |
875 int size = 1 << 30; | 876 int size = 1 << 30; |
876 layer->SetBounds(gfx::Size(size, size)); | 877 layer->SetBounds(gfx::Size(size, size)); |
877 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); | 878 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
878 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); | 879 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); |
879 | 880 |
880 // Ensure no crash for bounds where size * size would overflow an int. | 881 // Ensure no crash for bounds where size * size would overflow an int. |
881 layer->SetTexturePriorities(m_priorityCalculator); | 882 layer->SetTexturePriorities(m_priorityCalculator); |
882 resource_manager_->PrioritizeTextures(); | 883 resource_manager_->PrioritizeTextures(); |
883 layer->Update(m_queue.get(), 0, NULL); | 884 layer->Update(m_queue.get(), 0); |
884 } | 885 } |
885 | 886 |
886 class TiledLayerPartialUpdateTest : public TiledLayerTest { | 887 class TiledLayerPartialUpdateTest : public TiledLayerTest { |
887 public: | 888 public: |
888 TiledLayerPartialUpdateTest() | 889 TiledLayerPartialUpdateTest() |
889 { | 890 { |
890 m_settings.max_partial_texture_updates = 4; | 891 m_settings.max_partial_texture_updates = 4; |
891 } | 892 } |
892 }; | 893 }; |
893 | 894 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
996 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) | 997 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) |
997 { | 998 { |
998 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 999 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
999 | 1000 |
1000 // The tile size is 100x100, so this invalidates and then paints two tiles. | 1001 // The tile size is 100x100, so this invalidates and then paints two tiles. |
1001 layer->SetBounds(gfx::Size(100, 200)); | 1002 layer->SetBounds(gfx::Size(100, 200)); |
1002 calcDrawProps(layer); | 1003 calcDrawProps(layer); |
1003 | 1004 |
1004 layer->SetTexturePriorities(m_priorityCalculator); | 1005 layer->SetTexturePriorities(m_priorityCalculator); |
1005 resource_manager_->PrioritizeTextures(); | 1006 resource_manager_->PrioritizeTextures(); |
1006 layer->Update(m_queue.get(), 0, NULL); | 1007 layer->Update(m_queue.get(), 0); |
1007 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); | 1008 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); |
1008 } | 1009 } |
1009 | 1010 |
1010 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) | 1011 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) |
1011 { | 1012 { |
1012 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 1013 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
1013 TestOcclusionTracker occluded; | 1014 TestOcclusionTracker occluded; |
1014 m_occlusion = &occluded; | 1015 m_occlusion = &occluded; |
1015 | 1016 |
1016 // The tile size is 100x100. | 1017 // The tile size is 100x100. |
1017 | 1018 |
1018 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1019 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); |
1019 layer->SetBounds(gfx::Size(600, 600)); | 1020 layer->SetBounds(gfx::Size(600, 600)); |
1020 calcDrawProps(layer); | 1021 calcDrawProps(layer); |
1021 | 1022 |
1022 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1023 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
1023 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->content_bounds()); | 1024 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->content_bounds()); |
1024 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); | 1025 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); |
1025 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1026 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1026 | 1027 |
1027 layer->SetTexturePriorities(m_priorityCalculator); | 1028 layer->SetTexturePriorities(m_priorityCalculator); |
1028 resource_manager_->PrioritizeTextures(); | 1029 resource_manager_->PrioritizeTextures(); |
1029 layer->Update(m_queue.get(), &occluded, NULL); | 1030 layer->Update(m_queue.get(), &occluded); |
1030 EXPECT_EQ(36-3, layer->fake_layer_updater()->update_count()); | 1031 EXPECT_EQ(36-3, layer->fake_layer_updater()->update_count()); |
1031 | 1032 |
1032 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1033 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1033 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); | 1034 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); |
1034 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1035 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1035 | 1036 |
1036 layer->fake_layer_updater()->ClearUpdateCount(); | 1037 layer->fake_layer_updater()->ClearUpdateCount(); |
1037 layer->SetTexturePriorities(m_priorityCalculator); | 1038 layer->SetTexturePriorities(m_priorityCalculator); |
1038 resource_manager_->PrioritizeTextures(); | 1039 resource_manager_->PrioritizeTextures(); |
1039 | 1040 |
1040 occluded.setOcclusion(gfx::Rect(250, 200, 300, 100)); | 1041 occluded.setOcclusion(gfx::Rect(250, 200, 300, 100)); |
1041 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1042 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1042 layer->Update(m_queue.get(), &occluded, NULL); | 1043 layer->Update(m_queue.get(), &occluded); |
1043 EXPECT_EQ(36-2, layer->fake_layer_updater()->update_count()); | 1044 EXPECT_EQ(36-2, layer->fake_layer_updater()->update_count()); |
1044 | 1045 |
1045 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1046 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1046 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00 + 340000, 1); | 1047 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00 + 340000, 1); |
1047 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1048 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1048 | 1049 |
1049 layer->fake_layer_updater()->ClearUpdateCount(); | 1050 layer->fake_layer_updater()->ClearUpdateCount(); |
1050 layer->SetTexturePriorities(m_priorityCalculator); | 1051 layer->SetTexturePriorities(m_priorityCalculator); |
1051 resource_manager_->PrioritizeTextures(); | 1052 resource_manager_->PrioritizeTextures(); |
1052 | 1053 |
1053 occluded.setOcclusion(gfx::Rect(250, 250, 300, 100)); | 1054 occluded.setOcclusion(gfx::Rect(250, 250, 300, 100)); |
1054 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1055 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1055 layer->Update(m_queue.get(), &occluded, NULL); | 1056 layer->Update(m_queue.get(), &occluded); |
1056 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); | 1057 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); |
1057 | 1058 |
1058 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1059 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1059 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00 + 340000 + 360000, 1); | 1060 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00 + 340000 + 360000, 1); |
1060 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1061 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1061 } | 1062 } |
1062 | 1063 |
1063 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) | 1064 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) |
1064 { | 1065 { |
1065 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 1066 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
1066 TestOcclusionTracker occluded; | 1067 TestOcclusionTracker occluded; |
1067 m_occlusion = &occluded; | 1068 m_occlusion = &occluded; |
1068 | 1069 |
1069 // The tile size is 100x100. | 1070 // The tile size is 100x100. |
1070 | 1071 |
1071 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1072 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); |
1072 layer->SetBounds(gfx::Size(600, 600)); | 1073 layer->SetBounds(gfx::Size(600, 600)); |
1073 calcDrawProps(layer); | 1074 calcDrawProps(layer); |
1074 | 1075 |
1075 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled. | 1076 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled. |
1076 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1077 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
1077 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); | 1078 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); |
1078 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); | 1079 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); |
1079 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1080 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1080 | 1081 |
1081 layer->SetTexturePriorities(m_priorityCalculator); | 1082 layer->SetTexturePriorities(m_priorityCalculator); |
1082 resource_manager_->PrioritizeTextures(); | 1083 resource_manager_->PrioritizeTextures(); |
1083 layer->Update(m_queue.get(), &occluded, NULL); | 1084 layer->Update(m_queue.get(), &occluded); |
1084 EXPECT_EQ(24-3, layer->fake_layer_updater()->update_count()); | 1085 EXPECT_EQ(24-3, layer->fake_layer_updater()->update_count()); |
1085 | 1086 |
1086 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1087 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1087 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2100 00, 1); | 1088 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2100 00, 1); |
1088 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1089 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1089 | 1090 |
1090 layer->fake_layer_updater()->ClearUpdateCount(); | 1091 layer->fake_layer_updater()->ClearUpdateCount(); |
1091 | 1092 |
1092 // Now the visible region stops at the edge of the occlusion so the partly v isible tiles become fully occluded. | 1093 // Now the visible region stops at the edge of the occlusion so the partly v isible tiles become fully occluded. |
1093 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1094 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
1094 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); | 1095 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); |
1095 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350); | 1096 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350); |
1096 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1097 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1097 layer->SetTexturePriorities(m_priorityCalculator); | 1098 layer->SetTexturePriorities(m_priorityCalculator); |
1098 resource_manager_->PrioritizeTextures(); | 1099 resource_manager_->PrioritizeTextures(); |
1099 layer->Update(m_queue.get(), &occluded, NULL); | 1100 layer->Update(m_queue.get(), &occluded); |
1100 EXPECT_EQ(24-6, layer->fake_layer_updater()->update_count()); | 1101 EXPECT_EQ(24-6, layer->fake_layer_updater()->update_count()); |
1101 | 1102 |
1102 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1103 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1103 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2100 00 + 180000, 1); | 1104 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2100 00 + 180000, 1); |
1104 EXPECT_EQ(3 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1105 EXPECT_EQ(3 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1105 | 1106 |
1106 layer->fake_layer_updater()->ClearUpdateCount(); | 1107 layer->fake_layer_updater()->ClearUpdateCount(); |
1107 | 1108 |
1108 // Now the visible region is even smaller than the occlusion, it should have the same result. | 1109 // Now the visible region is even smaller than the occlusion, it should have the same result. |
1109 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1110 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
1110 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); | 1111 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); |
1111 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); | 1112 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); |
1112 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1113 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1113 layer->SetTexturePriorities(m_priorityCalculator); | 1114 layer->SetTexturePriorities(m_priorityCalculator); |
1114 resource_manager_->PrioritizeTextures(); | 1115 resource_manager_->PrioritizeTextures(); |
1115 layer->Update(m_queue.get(), &occluded, NULL); | 1116 layer->Update(m_queue.get(), &occluded); |
1116 EXPECT_EQ(24-6, layer->fake_layer_updater()->update_count()); | 1117 EXPECT_EQ(24-6, layer->fake_layer_updater()->update_count()); |
1117 | 1118 |
1118 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1119 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1119 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2100 00 + 180000 + 180000, 1); | 1120 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2100 00 + 180000 + 180000, 1); |
1120 EXPECT_EQ(3 + 6 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()) ; | 1121 EXPECT_EQ(3 + 6 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()) ; |
1121 | 1122 |
1122 } | 1123 } |
1123 | 1124 |
1124 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) | 1125 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) |
1125 { | 1126 { |
1126 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 1127 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
1127 TestOcclusionTracker occluded; | 1128 TestOcclusionTracker occluded; |
1128 m_occlusion = &occluded; | 1129 m_occlusion = &occluded; |
1129 | 1130 |
1130 // The tile size is 100x100. | 1131 // The tile size is 100x100. |
1131 | 1132 |
1132 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1133 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); |
1133 layer->SetBounds(gfx::Size(600, 600)); | 1134 layer->SetBounds(gfx::Size(600, 600)); |
1134 calcDrawProps(layer); | 1135 calcDrawProps(layer); |
1135 | 1136 |
1136 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1137 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
1137 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); | 1138 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); |
1138 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); | 1139 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); |
1139 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1140 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1140 layer->SetTexturePriorities(m_priorityCalculator); | 1141 layer->SetTexturePriorities(m_priorityCalculator); |
1141 resource_manager_->PrioritizeTextures(); | 1142 resource_manager_->PrioritizeTextures(); |
1142 layer->Update(m_queue.get(), &occluded, NULL); | 1143 layer->Update(m_queue.get(), &occluded); |
1143 EXPECT_EQ(36-3, layer->fake_layer_updater()->update_count()); | 1144 EXPECT_EQ(36-3, layer->fake_layer_updater()->update_count()); |
1144 { | 1145 { |
1145 updateTextures(); | 1146 updateTextures(); |
1146 } | 1147 } |
1147 | 1148 |
1148 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1149 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1149 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); | 1150 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); |
1150 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1151 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1151 | 1152 |
1152 layer->fake_layer_updater()->ClearUpdateCount(); | 1153 layer->fake_layer_updater()->ClearUpdateCount(); |
1153 layer->SetTexturePriorities(m_priorityCalculator); | 1154 layer->SetTexturePriorities(m_priorityCalculator); |
1154 resource_manager_->PrioritizeTextures(); | 1155 resource_manager_->PrioritizeTextures(); |
1155 | 1156 |
1156 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. | 1157 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. |
1157 layer->Update(m_queue.get(), &occluded, NULL); | 1158 layer->Update(m_queue.get(), &occluded); |
1158 EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); | 1159 EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); |
1159 | 1160 |
1160 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1161 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1161 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); | 1162 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); |
1162 EXPECT_EQ(6, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1163 EXPECT_EQ(6, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1163 } | 1164 } |
1164 | 1165 |
1165 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) | 1166 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) |
1166 { | 1167 { |
1167 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 1168 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
(...skipping 11 matching lines...) Expand all Loading... | |
1179 screenTransform.Scale(0.5, 0.5); | 1180 screenTransform.Scale(0.5, 0.5); |
1180 layer->draw_properties().screen_space_transform = screenTransform; | 1181 layer->draw_properties().screen_space_transform = screenTransform; |
1181 layer->draw_properties().target_space_transform = screenTransform; | 1182 layer->draw_properties().target_space_transform = screenTransform; |
1182 | 1183 |
1183 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); | 1184 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); |
1184 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->content_bounds()); | 1185 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->content_bounds()); |
1185 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); | 1186 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); |
1186 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1187 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1187 layer->SetTexturePriorities(m_priorityCalculator); | 1188 layer->SetTexturePriorities(m_priorityCalculator); |
1188 resource_manager_->PrioritizeTextures(); | 1189 resource_manager_->PrioritizeTextures(); |
1189 layer->Update(m_queue.get(), &occluded, NULL); | 1190 layer->Update(m_queue.get(), &occluded); |
1190 EXPECT_EQ(36-3, layer->fake_layer_updater()->update_count()); | 1191 EXPECT_EQ(36-3, layer->fake_layer_updater()->update_count()); |
1191 | 1192 |
1192 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1193 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1193 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); | 1194 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3300 00, 1); |
1194 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1195 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1195 } | 1196 } |
1196 | 1197 |
1197 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) | 1198 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) |
1198 { | 1199 { |
1199 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 1200 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
(...skipping 15 matching lines...) Expand all Loading... | |
1215 drawTransform.Scale(invScaleFactor, invScaleFactor); | 1216 drawTransform.Scale(invScaleFactor, invScaleFactor); |
1216 layer->draw_properties().target_space_transform = drawTransform; | 1217 layer->draw_properties().target_space_transform = drawTransform; |
1217 layer->draw_properties().screen_space_transform = drawTransform; | 1218 layer->draw_properties().screen_space_transform = drawTransform; |
1218 | 1219 |
1219 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1220 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
1220 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->bounds()); | 1221 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->bounds()); |
1221 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); | 1222 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); |
1222 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1223 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1223 layer->SetTexturePriorities(m_priorityCalculator); | 1224 layer->SetTexturePriorities(m_priorityCalculator); |
1224 resource_manager_->PrioritizeTextures(); | 1225 resource_manager_->PrioritizeTextures(); |
1225 layer->Update(m_queue.get(), &occluded, NULL); | 1226 layer->Update(m_queue.get(), &occluded); |
1226 // The content is half the size of the layer (so the number of tiles is fewe r). | 1227 // The content is half the size of the layer (so the number of tiles is fewe r). |
1227 // In this case, the content is 300x300, and since the tile size is 100, the | 1228 // In this case, the content is 300x300, and since the tile size is 100, the |
1228 // number of tiles 3x3. | 1229 // number of tiles 3x3. |
1229 EXPECT_EQ(9, layer->fake_layer_updater()->update_count()); | 1230 EXPECT_EQ(9, layer->fake_layer_updater()->update_count()); |
1230 | 1231 |
1231 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1232 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1232 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 9000 0, 1); | 1233 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 9000 0, 1); |
1233 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1234 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1234 | 1235 |
1235 layer->fake_layer_updater()->ClearUpdateCount(); | 1236 layer->fake_layer_updater()->ClearUpdateCount(); |
1236 | 1237 |
1237 // This makes sure the painting works when the content space is scaled to | 1238 // This makes sure the painting works when the content space is scaled to |
1238 // a different layer space. In this case the occluded region catches the | 1239 // a different layer space. In this case the occluded region catches the |
1239 // blown up tiles. | 1240 // blown up tiles. |
1240 occluded.setOcclusion(gfx::Rect(200, 200, 300, 200)); | 1241 occluded.setOcclusion(gfx::Rect(200, 200, 300, 200)); |
1241 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->bounds()); | 1242 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->bounds()); |
1242 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); | 1243 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); |
1243 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1244 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1244 layer->SetTexturePriorities(m_priorityCalculator); | 1245 layer->SetTexturePriorities(m_priorityCalculator); |
1245 resource_manager_->PrioritizeTextures(); | 1246 resource_manager_->PrioritizeTextures(); |
1246 layer->Update(m_queue.get(), &occluded, NULL); | 1247 layer->Update(m_queue.get(), &occluded); |
1247 EXPECT_EQ(9-1, layer->fake_layer_updater()->update_count()); | 1248 EXPECT_EQ(9-1, layer->fake_layer_updater()->update_count()); |
1248 | 1249 |
1249 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1250 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1250 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 9000 0 + 80000, 1); | 1251 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 9000 0 + 80000, 1); |
1251 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1252 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1252 | 1253 |
1253 layer->fake_layer_updater()->ClearUpdateCount(); | 1254 layer->fake_layer_updater()->ClearUpdateCount(); |
1254 | 1255 |
1255 // This makes sure content scaling and transforms work together. | 1256 // This makes sure content scaling and transforms work together. |
1256 gfx::Transform screenTransform; | 1257 gfx::Transform screenTransform; |
1257 screenTransform.Scale(0.5, 0.5); | 1258 screenTransform.Scale(0.5, 0.5); |
1258 layer->draw_properties().screen_space_transform = screenTransform; | 1259 layer->draw_properties().screen_space_transform = screenTransform; |
1259 layer->draw_properties().target_space_transform = screenTransform; | 1260 layer->draw_properties().target_space_transform = screenTransform; |
1260 | 1261 |
1261 occluded.setOcclusion(gfx::Rect(100, 100, 150, 100)); | 1262 occluded.setOcclusion(gfx::Rect(100, 100, 150, 100)); |
1262 | 1263 |
1263 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds()); | 1264 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds()); |
1264 layer->draw_properties().drawable_content_rect = gfx::ToEnclosingRect(gfx::S caleRect(layerBoundsRect, 0.5)); | 1265 layer->draw_properties().drawable_content_rect = gfx::ToEnclosingRect(gfx::S caleRect(layerBoundsRect, 0.5)); |
1265 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); | 1266 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds()); |
1266 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1267 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1267 layer->SetTexturePriorities(m_priorityCalculator); | 1268 layer->SetTexturePriorities(m_priorityCalculator); |
1268 resource_manager_->PrioritizeTextures(); | 1269 resource_manager_->PrioritizeTextures(); |
1269 layer->Update(m_queue.get(), &occluded, NULL); | 1270 layer->Update(m_queue.get(), &occluded); |
1270 EXPECT_EQ(9-1, layer->fake_layer_updater()->update_count()); | 1271 EXPECT_EQ(9-1, layer->fake_layer_updater()->update_count()); |
1271 | 1272 |
1272 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1273 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1273 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 9000 0 + 80000 + 80000, 1); | 1274 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 9000 0 + 80000 + 80000, 1); |
1274 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1275 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1275 } | 1276 } |
1276 | 1277 |
1277 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) | 1278 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) |
1278 { | 1279 { |
1279 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); | 1280 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( resource_manager_.get())); |
(...skipping 12 matching lines...) Expand all Loading... | |
1292 layer->SetBounds(contentBounds.size()); | 1293 layer->SetBounds(contentBounds.size()); |
1293 calcDrawProps(layer); | 1294 calcDrawProps(layer); |
1294 layer->draw_properties().drawable_content_rect = visibleBounds; | 1295 layer->draw_properties().drawable_content_rect = visibleBounds; |
1295 layer->draw_properties().visible_content_rect = visibleBounds; | 1296 layer->draw_properties().visible_content_rect = visibleBounds; |
1296 | 1297 |
1297 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR egion should be empty. | 1298 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR egion should be empty. |
1298 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1299 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1299 layer->InvalidateContentRect(contentBounds); | 1300 layer->InvalidateContentRect(contentBounds); |
1300 layer->SetTexturePriorities(m_priorityCalculator); | 1301 layer->SetTexturePriorities(m_priorityCalculator); |
1301 resource_manager_->PrioritizeTextures(); | 1302 resource_manager_->PrioritizeTextures(); |
1302 layer->Update(m_queue.get(), &occluded, NULL); | 1303 layer->Update(m_queue.get(), &occluded); |
1303 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1304 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1304 EXPECT_TRUE(opaqueContents.IsEmpty()); | 1305 EXPECT_TRUE(opaqueContents.IsEmpty()); |
1305 | 1306 |
1306 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000, 1); | 1307 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000, 1); |
1307 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1308 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1308 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0, 1); | 1309 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0, 1); |
1309 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1310 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1310 | 1311 |
1311 // visibleContentOpaqueRegion should match the visible part of what is paint ed opaque. | 1312 // visibleContentOpaqueRegion should match the visible part of what is paint ed opaque. |
1312 opaquePaintRect = gfx::Rect(10, 10, 90, 190); | 1313 opaquePaintRect = gfx::Rect(10, 10, 90, 190); |
1313 layer->fake_layer_updater()->SetOpaquePaintRect(opaquePaintRect); | 1314 layer->fake_layer_updater()->SetOpaquePaintRect(opaquePaintRect); |
1314 layer->InvalidateContentRect(contentBounds); | 1315 layer->InvalidateContentRect(contentBounds); |
1315 layer->SetTexturePriorities(m_priorityCalculator); | 1316 layer->SetTexturePriorities(m_priorityCalculator); |
1316 resource_manager_->PrioritizeTextures(); | 1317 resource_manager_->PrioritizeTextures(); |
1317 layer->Update(m_queue.get(), &occluded, NULL); | 1318 layer->Update(m_queue.get(), &occluded); |
1318 updateTextures(); | 1319 updateTextures(); |
1319 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1320 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1320 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); | 1321 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); |
1321 | 1322 |
1322 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); | 1323 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); |
1323 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; | 1324 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; |
1324 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100, 1); | 1325 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100, 1); |
1325 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1326 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1326 | 1327 |
1327 // If we paint again without invalidating, the same stuff should be opaque. | 1328 // If we paint again without invalidating, the same stuff should be opaque. |
1328 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1329 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1329 layer->SetTexturePriorities(m_priorityCalculator); | 1330 layer->SetTexturePriorities(m_priorityCalculator); |
1330 resource_manager_->PrioritizeTextures(); | 1331 resource_manager_->PrioritizeTextures(); |
1331 layer->Update(m_queue.get(), &occluded, NULL); | 1332 layer->Update(m_queue.get(), &occluded); |
1332 updateTextures(); | 1333 updateTextures(); |
1333 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1334 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1334 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); | 1335 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); |
1335 | 1336 |
1336 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); | 1337 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); |
1337 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; | 1338 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; |
1338 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100, 1); | 1339 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100, 1); |
1339 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1340 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1340 | 1341 |
1341 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o paque-ness. And other tiles should | 1342 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o paque-ness. And other tiles should |
1342 // not be affected. | 1343 // not be affected. |
1343 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1344 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1344 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); | 1345 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); |
1345 layer->SetTexturePriorities(m_priorityCalculator); | 1346 layer->SetTexturePriorities(m_priorityCalculator); |
1346 resource_manager_->PrioritizeTextures(); | 1347 resource_manager_->PrioritizeTextures(); |
1347 layer->Update(m_queue.get(), &occluded, NULL); | 1348 layer->Update(m_queue.get(), &occluded); |
1348 updateTextures(); | 1349 updateTextures(); |
1349 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1350 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1350 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); | 1351 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); |
1351 | 1352 |
1352 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1, 1) ; | 1353 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1, 1) ; |
1353 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; | 1354 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; |
1354 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100 + 1, 1); | 1355 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100 + 1, 1); |
1355 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1356 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1356 | 1357 |
1357 // If we repaint an opaque part of the tile, then it should lose its opaque- ness. But other tiles should still | 1358 // If we repaint an opaque part of the tile, then it should lose its opaque- ness. But other tiles should still |
1358 // not be affected. | 1359 // not be affected. |
1359 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1360 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1360 layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1)); | 1361 layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1)); |
1361 layer->SetTexturePriorities(m_priorityCalculator); | 1362 layer->SetTexturePriorities(m_priorityCalculator); |
1362 resource_manager_->PrioritizeTextures(); | 1363 resource_manager_->PrioritizeTextures(); |
1363 layer->Update(m_queue.get(), &occluded, NULL); | 1364 layer->Update(m_queue.get(), &occluded); |
1364 updateTextures(); | 1365 updateTextures(); |
1365 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1366 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1366 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds).To String(), opaqueContents.ToString()); | 1367 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds).To String(), opaqueContents.ToString()); |
1367 | 1368 |
1368 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1 + 1, 1); | 1369 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1 + 1, 1); |
1369 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; | 1370 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1) ; |
1370 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100 + 1 + 1, 1); | 1371 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 2000 0 + 20000 - 17100 + 1 + 1, 1); |
1371 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1372 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1372 } | 1373 } |
1373 | 1374 |
(...skipping 11 matching lines...) Expand all Loading... | |
1385 | 1386 |
1386 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300); | 1387 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300); |
1387 layer->SetBounds(contentBounds.size()); | 1388 layer->SetBounds(contentBounds.size()); |
1388 calcDrawProps(layer); | 1389 calcDrawProps(layer); |
1389 | 1390 |
1390 // Invalidates and paints the whole layer. | 1391 // Invalidates and paints the whole layer. |
1391 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1392 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1392 layer->InvalidateContentRect(contentBounds); | 1393 layer->InvalidateContentRect(contentBounds); |
1393 layer->SetTexturePriorities(m_priorityCalculator); | 1394 layer->SetTexturePriorities(m_priorityCalculator); |
1394 resource_manager_->PrioritizeTextures(); | 1395 resource_manager_->PrioritizeTextures(); |
1395 layer->Update(m_queue.get(), &occluded, NULL); | 1396 layer->Update(m_queue.get(), &occluded); |
1396 updateTextures(); | 1397 updateTextures(); |
1397 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1398 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1398 EXPECT_TRUE(opaqueContents.IsEmpty()); | 1399 EXPECT_TRUE(opaqueContents.IsEmpty()); |
1399 | 1400 |
1400 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000, 1); | 1401 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000, 1); |
1401 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1402 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1402 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3000 0, 1); | 1403 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3000 0, 1); |
1403 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1404 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1404 | 1405 |
1405 // Invalidates an area on the top and bottom tile, which will cause us to pa int the tile in the middle, | 1406 // Invalidates an area on the top and bottom tile, which will cause us to pa int the tile in the middle, |
1406 // even though it is not dirty and will not be uploaded. | 1407 // even though it is not dirty and will not be uploaded. |
1407 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1408 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1408 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); | 1409 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); |
1409 layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10)); | 1410 layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10)); |
1410 layer->SetTexturePriorities(m_priorityCalculator); | 1411 layer->SetTexturePriorities(m_priorityCalculator); |
1411 resource_manager_->PrioritizeTextures(); | 1412 resource_manager_->PrioritizeTextures(); |
1412 layer->Update(m_queue.get(), &occluded, NULL); | 1413 layer->Update(m_queue.get(), &occluded); |
1413 updateTextures(); | 1414 updateTextures(); |
1414 opaqueContents = layer->VisibleContentOpaqueRegion(); | 1415 opaqueContents = layer->VisibleContentOpaqueRegion(); |
1415 EXPECT_TRUE(opaqueContents.IsEmpty()); | 1416 EXPECT_TRUE(opaqueContents.IsEmpty()); |
1416 | 1417 |
1417 // The middle tile was painted even though not invalidated. | 1418 // The middle tile was painted even though not invalidated. |
1418 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000 + 60 * 210, 1); | 1419 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000 + 60 * 210, 1); |
1419 // The pixels uploaded will not include the non-invalidated tile in the midd le. | 1420 // The pixels uploaded will not include the non-invalidated tile in the midd le. |
1420 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1421 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1421 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3000 0 + 1 + 100, 1); | 1422 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 3000 0 + 1 + 100, 1); |
1422 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1423 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1584 gfx::Rect m_paintedRect; | 1585 gfx::Rect m_paintedRect; |
1585 }; | 1586 }; |
1586 | 1587 |
1587 class UpdateTrackingTiledLayer : public FakeTiledLayer { | 1588 class UpdateTrackingTiledLayer : public FakeTiledLayer { |
1588 public: | 1589 public: |
1589 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) | 1590 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) |
1590 : FakeTiledLayer(manager) | 1591 : FakeTiledLayer(manager) |
1591 { | 1592 { |
1592 scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPaint er::Create()); | 1593 scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPaint er::Create()); |
1593 m_trackingLayerPainter = trackingLayerPainter.get(); | 1594 m_trackingLayerPainter = trackingLayerPainter.get(); |
1594 m_layerUpdater = BitmapContentLayerUpdater::Create(trackingLayerPainter. PassAs<LayerPainter>()); | 1595 m_layerUpdater = BitmapContentLayerUpdater::Create(trackingLayerPainter. PassAs<LayerPainter>(), &m_statsInstrumentation); |
1595 } | 1596 } |
1596 | 1597 |
1597 TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerP ainter; } | 1598 TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerP ainter; } |
1598 | 1599 |
1599 protected: | 1600 protected: |
1600 virtual ~UpdateTrackingTiledLayer() { } | 1601 virtual ~UpdateTrackingTiledLayer() { } |
1601 | 1602 |
1602 virtual LayerUpdater* Updater() const OVERRIDE { return m_layerUpdater.get() ; } | 1603 virtual LayerUpdater* Updater() const OVERRIDE { return m_layerUpdater.get() ; } |
1603 | 1604 |
1604 private: | 1605 private: |
1605 TrackingLayerPainter* m_trackingLayerPainter; | 1606 TrackingLayerPainter* m_trackingLayerPainter; |
1606 scoped_refptr<BitmapContentLayerUpdater> m_layerUpdater; | 1607 scoped_refptr<BitmapContentLayerUpdater> m_layerUpdater; |
1608 FakeRenderingStatsInstrumentation m_statsInstrumentation; | |
1607 }; | 1609 }; |
1608 | 1610 |
1609 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) | 1611 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) |
1610 { | 1612 { |
1611 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(resource_manager_.get())); | 1613 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(resource_manager_.get())); |
1612 | 1614 |
1613 gfx::Rect layerRect(0, 0, 30, 31); | 1615 gfx::Rect layerRect(0, 0, 30, 31); |
1614 layer->SetPosition(layerRect.origin()); | 1616 layer->SetPosition(layerRect.origin()); |
1615 layer->SetBounds(layerRect.size()); | 1617 layer->SetBounds(layerRect.size()); |
1616 layer->UpdateContentsScale(1.5); | 1618 layer->UpdateContentsScale(1.5); |
1617 | 1619 |
1618 gfx::Rect contentRect(0, 0, 45, 47); | 1620 gfx::Rect contentRect(0, 0, 45, 47); |
1619 EXPECT_EQ(contentRect.size(), layer->content_bounds()); | 1621 EXPECT_EQ(contentRect.size(), layer->content_bounds()); |
1620 layer->draw_properties().visible_content_rect = contentRect; | 1622 layer->draw_properties().visible_content_rect = contentRect; |
1621 layer->draw_properties().drawable_content_rect = contentRect; | 1623 layer->draw_properties().drawable_content_rect = contentRect; |
1622 | 1624 |
1623 layer->SetTexturePriorities(m_priorityCalculator); | 1625 layer->SetTexturePriorities(m_priorityCalculator); |
1624 resource_manager_->PrioritizeTextures(); | 1626 resource_manager_->PrioritizeTextures(); |
1625 | 1627 |
1626 // Update the whole tile. | 1628 // Update the whole tile. |
1627 layer->Update(m_queue.get(), 0, NULL); | 1629 layer->Update(m_queue.get(), 0); |
danakj
2013/03/23 01:56:32
can you make these 0's into NULL's while you're he
egraether
2013/03/25 21:07:44
Done.
| |
1628 layer->trackingLayerPainter()->resetPaintedRect(); | 1630 layer->trackingLayerPainter()->resetPaintedRect(); |
1629 | 1631 |
1630 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); | 1632 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); |
1631 updateTextures(); | 1633 updateTextures(); |
1632 | 1634 |
1633 // Invalidate the entire layer in content space. When painting, the rect giv en to webkit should match the layer's bounds. | 1635 // Invalidate the entire layer in content space. When painting, the rect giv en to webkit should match the layer's bounds. |
1634 layer->InvalidateContentRect(contentRect); | 1636 layer->InvalidateContentRect(contentRect); |
1635 layer->Update(m_queue.get(), 0, NULL); | 1637 layer->Update(m_queue.get(), 0); |
1636 | 1638 |
1637 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1639 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1638 } | 1640 } |
1639 | 1641 |
1640 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) | 1642 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) |
1641 { | 1643 { |
1642 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(resource_manager_.get())); | 1644 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(resource_manager_.get())); |
1643 | 1645 |
1644 gfx::Rect layerRect(0, 0, 30, 31); | 1646 gfx::Rect layerRect(0, 0, 30, 31); |
1645 layer->SetPosition(layerRect.origin()); | 1647 layer->SetPosition(layerRect.origin()); |
1646 layer->SetBounds(layerRect.size()); | 1648 layer->SetBounds(layerRect.size()); |
1647 layer->UpdateContentsScale(1.3f); | 1649 layer->UpdateContentsScale(1.3f); |
1648 | 1650 |
1649 gfx::Rect contentRect(gfx::Point(), layer->content_bounds()); | 1651 gfx::Rect contentRect(gfx::Point(), layer->content_bounds()); |
1650 layer->draw_properties().visible_content_rect = contentRect; | 1652 layer->draw_properties().visible_content_rect = contentRect; |
1651 layer->draw_properties().drawable_content_rect = contentRect; | 1653 layer->draw_properties().drawable_content_rect = contentRect; |
1652 | 1654 |
1653 layer->SetTexturePriorities(m_priorityCalculator); | 1655 layer->SetTexturePriorities(m_priorityCalculator); |
1654 resource_manager_->PrioritizeTextures(); | 1656 resource_manager_->PrioritizeTextures(); |
1655 | 1657 |
1656 // Update the whole tile. | 1658 // Update the whole tile. |
1657 layer->Update(m_queue.get(), 0, NULL); | 1659 layer->Update(m_queue.get(), 0); |
1658 layer->trackingLayerPainter()->resetPaintedRect(); | 1660 layer->trackingLayerPainter()->resetPaintedRect(); |
1659 | 1661 |
1660 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); | 1662 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); |
1661 updateTextures(); | 1663 updateTextures(); |
1662 | 1664 |
1663 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. | 1665 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. |
1664 layer->SetNeedsDisplayRect(layerRect); | 1666 layer->SetNeedsDisplayRect(layerRect); |
1665 layer->Update(m_queue.get(), 0, NULL); | 1667 layer->Update(m_queue.get(), 0); |
1666 | 1668 |
1667 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1669 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1668 } | 1670 } |
1669 | 1671 |
1670 } // namespace | 1672 } // namespace |
1671 } // namespace cc | 1673 } // namespace cc |
OLD | NEW |