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 <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.h" |
11 #include "cc/resources/bitmap_content_layer_updater.h" | 11 #include "cc/resources/bitmap_content_layer_updater.h" |
12 #include "cc/resources/layer_painter.h" | 12 #include "cc/resources/layer_painter.h" |
13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
15 #include "cc/test/animation_test_common.h" | 15 #include "cc/test/animation_test_common.h" |
16 #include "cc/test/fake_layer_tree_host_client.h" | 16 #include "cc/test/fake_layer_tree_host_client.h" |
17 #include "cc/test/fake_layer_tree_host_impl.h" | 17 #include "cc/test/fake_layer_tree_host_impl.h" |
18 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
19 #include "cc/test/fake_proxy.h" | 19 #include "cc/test/fake_proxy.h" |
| 20 #include "cc/test/fake_rendering_stats_instrumentation.h" |
20 #include "cc/test/geometry_test_utils.h" | 21 #include "cc/test/geometry_test_utils.h" |
21 #include "cc/test/tiled_layer_test_common.h" | 22 #include "cc/test/tiled_layer_test_common.h" |
22 #include "cc/trees/single_thread_proxy.h" | 23 #include "cc/trees/single_thread_proxy.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "ui/gfx/rect_conversions.h" | 25 #include "ui/gfx/rect_conversions.h" |
25 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
26 | 27 |
27 namespace cc { | 28 namespace cc { |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 106 |
106 void LayerPushPropertiesTo(FakeTiledLayer* layer, | 107 void LayerPushPropertiesTo(FakeTiledLayer* layer, |
107 FakeTiledLayerImpl* layer_impl) { | 108 FakeTiledLayerImpl* layer_impl) { |
108 DebugScopedSetImplThreadAndMainThreadBlocked | 109 DebugScopedSetImplThreadAndMainThreadBlocked |
109 impl_thread_and_main_thread_blocked(proxy_); | 110 impl_thread_and_main_thread_blocked(proxy_); |
110 layer->PushPropertiesTo(layer_impl); | 111 layer->PushPropertiesTo(layer_impl); |
111 } | 112 } |
112 | 113 |
113 void LayerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) { | 114 void LayerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) { |
114 DebugScopedSetMainThread main_thread(proxy_); | 115 DebugScopedSetMainThread main_thread(proxy_); |
115 layer->Update(queue_.get(), occluded, NULL); | 116 layer->Update(queue_.get(), occluded); |
116 } | 117 } |
117 | 118 |
118 void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) { | 119 void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) { |
119 scoped_refptr<FakeTiledLayer> layer2; | 120 scoped_refptr<FakeTiledLayer> layer2; |
120 CalcDrawProps(layer1, layer2); | 121 CalcDrawProps(layer1, layer2); |
121 } | 122 } |
122 | 123 |
123 void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, | 124 void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, |
124 const scoped_refptr<FakeTiledLayer>& layer2) { | 125 const scoped_refptr<FakeTiledLayer>& layer2) { |
125 if (layer1 && !layer1->parent()) | 126 if (layer1 && !layer1->parent()) |
(...skipping 28 matching lines...) Expand all Loading... |
154 // Get textures | 155 // Get textures |
155 resource_manager_->ClearPriorities(); | 156 resource_manager_->ClearPriorities(); |
156 if (layer1) | 157 if (layer1) |
157 layer1->SetTexturePriorities(priority_calculator_); | 158 layer1->SetTexturePriorities(priority_calculator_); |
158 if (layer2) | 159 if (layer2) |
159 layer2->SetTexturePriorities(priority_calculator_); | 160 layer2->SetTexturePriorities(priority_calculator_); |
160 resource_manager_->PrioritizeTextures(); | 161 resource_manager_->PrioritizeTextures(); |
161 | 162 |
162 // Update content | 163 // Update content |
163 if (layer1) | 164 if (layer1) |
164 layer1->Update(queue_.get(), occlusion_, NULL); | 165 layer1->Update(queue_.get(), occlusion_); |
165 if (layer2) | 166 if (layer2) |
166 layer2->Update(queue_.get(), occlusion_, NULL); | 167 layer2->Update(queue_.get(), occlusion_); |
167 | 168 |
168 bool needs_update = false; | 169 bool needs_update = false; |
169 if (layer1) | 170 if (layer1) |
170 needs_update |= layer1->NeedsIdlePaint(); | 171 needs_update |= layer1->NeedsIdlePaint(); |
171 if (layer2) | 172 if (layer2) |
172 needs_update |= layer2->NeedsIdlePaint(); | 173 needs_update |= layer2->NeedsIdlePaint(); |
173 | 174 |
174 // Update textures and push. | 175 // Update textures and push. |
175 UpdateTextures(); | 176 UpdateTextures(); |
176 if (layer1) | 177 if (layer1) |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 | 599 |
599 // Pretend the layer is animating. | 600 // Pretend the layer is animating. |
600 layer->draw_properties().target_space_transform_is_animating = true; | 601 layer->draw_properties().target_space_transform_is_animating = true; |
601 layer->draw_properties().visible_content_rect = visible_rect; | 602 layer->draw_properties().visible_content_rect = visible_rect; |
602 layer->SetLayerTreeHost(layer_tree_host_.get()); | 603 layer->SetLayerTreeHost(layer_tree_host_.get()); |
603 | 604 |
604 // The layer should paint its entire contents on the first paint | 605 // The layer should paint its entire contents on the first paint |
605 // if it is close to the viewport size and has the available memory. | 606 // if it is close to the viewport size and has the available memory. |
606 layer->SetTexturePriorities(priority_calculator_); | 607 layer->SetTexturePriorities(priority_calculator_); |
607 resource_manager_->PrioritizeTextures(); | 608 resource_manager_->PrioritizeTextures(); |
608 layer->Update(queue_.get(), 0, NULL); | 609 layer->Update(queue_.get(), NULL); |
609 UpdateTextures(); | 610 UpdateTextures(); |
610 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 611 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
611 | 612 |
612 // We should have all the tiles for the small animated layer. | 613 // We should have all the tiles for the small animated layer. |
613 // We should still have the visible tiles when we didn't | 614 // We should still have the visible tiles when we didn't |
614 // have enough memory for all the tiles. | 615 // have enough memory for all the tiles. |
615 if (!run_out_of_memory[i]) { | 616 if (!run_out_of_memory[i]) { |
616 for (int i = 0; i < 5; ++i) { | 617 for (int i = 0; i < 5; ++i) { |
617 for (int j = 0; j < 5; ++j) | 618 for (int j = 0; j < 5; ++j) |
618 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(i, j)); | 619 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(i, j)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 layer->SetContentBounds(content_bounds.size()); | 766 layer->SetContentBounds(content_bounds.size()); |
766 layer->draw_properties().visible_content_rect = content_bounds; | 767 layer->draw_properties().visible_content_rect = content_bounds; |
767 | 768 |
768 // On first update, the update_rect includes all tiles, even beyond the | 769 // On first update, the update_rect includes all tiles, even beyond the |
769 // boundaries of the layer. | 770 // boundaries of the layer. |
770 // However, it should still be in layer space, not content space. | 771 // However, it should still be in layer space, not content space. |
771 layer->InvalidateContentRect(content_bounds); | 772 layer->InvalidateContentRect(content_bounds); |
772 | 773 |
773 layer->SetTexturePriorities(priority_calculator_); | 774 layer->SetTexturePriorities(priority_calculator_); |
774 resource_manager_->PrioritizeTextures(); | 775 resource_manager_->PrioritizeTextures(); |
775 layer->Update(queue_.get(), 0, NULL); | 776 layer->Update(queue_.get(), NULL); |
776 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect()); | 777 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect()); |
777 UpdateTextures(); | 778 UpdateTextures(); |
778 | 779 |
779 // After the tiles are updated once, another invalidate only needs to update | 780 // After the tiles are updated once, another invalidate only needs to update |
780 // the bounds of the layer. | 781 // the bounds of the layer. |
781 layer->SetTexturePriorities(priority_calculator_); | 782 layer->SetTexturePriorities(priority_calculator_); |
782 resource_manager_->PrioritizeTextures(); | 783 resource_manager_->PrioritizeTextures(); |
783 layer->InvalidateContentRect(content_bounds); | 784 layer->InvalidateContentRect(content_bounds); |
784 layer->Update(queue_.get(), 0, NULL); | 785 layer->Update(queue_.get(), NULL); |
785 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); | 786 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); |
786 UpdateTextures(); | 787 UpdateTextures(); |
787 | 788 |
788 // Partial re-paint should also be represented by the update rect in layer | 789 // Partial re-paint should also be represented by the update rect in layer |
789 // space, not content space. | 790 // space, not content space. |
790 gfx::Rect partial_damage(30, 100, 10, 10); | 791 gfx::Rect partial_damage(30, 100, 10, 10); |
791 layer->InvalidateContentRect(partial_damage); | 792 layer->InvalidateContentRect(partial_damage); |
792 layer->SetTexturePriorities(priority_calculator_); | 793 layer->SetTexturePriorities(priority_calculator_); |
793 resource_manager_->PrioritizeTextures(); | 794 resource_manager_->PrioritizeTextures(); |
794 layer->Update(queue_.get(), 0, NULL); | 795 layer->Update(queue_.get(), NULL); |
795 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); | 796 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); |
796 } | 797 } |
797 | 798 |
798 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { | 799 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { |
799 scoped_refptr<FakeTiledLayer> layer = | 800 scoped_refptr<FakeTiledLayer> layer = |
800 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 801 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
801 scoped_ptr<FakeTiledLayerImpl> layer_impl = | 802 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
802 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); | 803 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
803 | 804 |
804 // Create a layer with one tile. | 805 // Create a layer with one tile. |
805 layer->SetBounds(gfx::Size(100, 100)); | 806 layer->SetBounds(gfx::Size(100, 100)); |
806 CalcDrawProps(layer); | 807 CalcDrawProps(layer); |
807 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 808 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
808 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), | 809 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), |
809 layer->last_needs_display_rect()); | 810 layer->last_needs_display_rect()); |
810 | 811 |
811 // Push the tiles to the impl side and check that there is exactly one. | 812 // Push the tiles to the impl side and check that there is exactly one. |
812 layer->SetTexturePriorities(priority_calculator_); | 813 layer->SetTexturePriorities(priority_calculator_); |
813 resource_manager_->PrioritizeTextures(); | 814 resource_manager_->PrioritizeTextures(); |
814 layer->Update(queue_.get(), 0, NULL); | 815 layer->Update(queue_.get(), NULL); |
815 UpdateTextures(); | 816 UpdateTextures(); |
816 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 817 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
817 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 818 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
818 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); | 819 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); |
819 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 0)); | 820 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 0)); |
820 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 1)); | 821 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 1)); |
821 | 822 |
822 layer->SetNeedsDisplayRect(gfx::Rect()); | 823 layer->SetNeedsDisplayRect(gfx::Rect()); |
823 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); | 824 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); |
824 | 825 |
825 // Change the contents scale. | 826 // Change the contents scale. |
826 layer->UpdateContentsScale(2.f); | 827 layer->UpdateContentsScale(2.f); |
827 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); | 828 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); |
828 | 829 |
829 // The impl side should get 2x2 tiles now. | 830 // The impl side should get 2x2 tiles now. |
830 layer->SetTexturePriorities(priority_calculator_); | 831 layer->SetTexturePriorities(priority_calculator_); |
831 resource_manager_->PrioritizeTextures(); | 832 resource_manager_->PrioritizeTextures(); |
832 layer->Update(queue_.get(), 0, NULL); | 833 layer->Update(queue_.get(), NULL); |
833 UpdateTextures(); | 834 UpdateTextures(); |
834 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 835 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
835 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 836 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
836 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); | 837 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); |
837 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 0)); | 838 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 0)); |
838 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1)); | 839 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1)); |
839 | 840 |
840 // Verify that changing the contents scale caused invalidation, and | 841 // Verify that changing the contents scale caused invalidation, and |
841 // that the layer-space rectangle requiring painting is not scaled. | 842 // that the layer-space rectangle requiring painting is not scaled. |
842 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), | 843 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 TEST_F(TiledLayerTest, ResizeToSmaller) { | 904 TEST_F(TiledLayerTest, ResizeToSmaller) { |
904 scoped_refptr<FakeTiledLayer> layer = | 905 scoped_refptr<FakeTiledLayer> layer = |
905 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 906 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
906 | 907 |
907 layer->SetBounds(gfx::Size(700, 700)); | 908 layer->SetBounds(gfx::Size(700, 700)); |
908 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); | 909 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
909 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); | 910 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); |
910 | 911 |
911 layer->SetTexturePriorities(priority_calculator_); | 912 layer->SetTexturePriorities(priority_calculator_); |
912 resource_manager_->PrioritizeTextures(); | 913 resource_manager_->PrioritizeTextures(); |
913 layer->Update(queue_.get(), 0, NULL); | 914 layer->Update(queue_.get(), NULL); |
914 | 915 |
915 layer->SetBounds(gfx::Size(200, 200)); | 916 layer->SetBounds(gfx::Size(200, 200)); |
916 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); | 917 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); |
917 } | 918 } |
918 | 919 |
919 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { | 920 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { |
920 scoped_refptr<FakeTiledLayer> layer = | 921 scoped_refptr<FakeTiledLayer> layer = |
921 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 922 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
922 | 923 |
923 int size = 1 << 30; | 924 int size = 1 << 30; |
924 layer->SetBounds(gfx::Size(size, size)); | 925 layer->SetBounds(gfx::Size(size, size)); |
925 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); | 926 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
926 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); | 927 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); |
927 | 928 |
928 // Ensure no crash for bounds where size * size would overflow an int. | 929 // Ensure no crash for bounds where size * size would overflow an int. |
929 layer->SetTexturePriorities(priority_calculator_); | 930 layer->SetTexturePriorities(priority_calculator_); |
930 resource_manager_->PrioritizeTextures(); | 931 resource_manager_->PrioritizeTextures(); |
931 layer->Update(queue_.get(), 0, NULL); | 932 layer->Update(queue_.get(), NULL); |
932 } | 933 } |
933 | 934 |
934 class TiledLayerPartialUpdateTest : public TiledLayerTest { | 935 class TiledLayerPartialUpdateTest : public TiledLayerTest { |
935 public: | 936 public: |
936 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; } | 937 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; } |
937 }; | 938 }; |
938 | 939 |
939 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { | 940 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { |
940 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | 941 // Create one 300 x 200 tiled layer with 3 x 2 tiles. |
941 gfx::Size content_bounds(300, 200); | 942 gfx::Size content_bounds(300, 200); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { | 1053 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { |
1053 scoped_refptr<FakeTiledLayer> layer = | 1054 scoped_refptr<FakeTiledLayer> layer = |
1054 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1055 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1055 | 1056 |
1056 // The tile size is 100x100, so this invalidates and then paints two tiles. | 1057 // The tile size is 100x100, so this invalidates and then paints two tiles. |
1057 layer->SetBounds(gfx::Size(100, 200)); | 1058 layer->SetBounds(gfx::Size(100, 200)); |
1058 CalcDrawProps(layer); | 1059 CalcDrawProps(layer); |
1059 | 1060 |
1060 layer->SetTexturePriorities(priority_calculator_); | 1061 layer->SetTexturePriorities(priority_calculator_); |
1061 resource_manager_->PrioritizeTextures(); | 1062 resource_manager_->PrioritizeTextures(); |
1062 layer->Update(queue_.get(), 0, NULL); | 1063 layer->Update(queue_.get(), NULL); |
1063 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); | 1064 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); |
1064 } | 1065 } |
1065 | 1066 |
1066 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { | 1067 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { |
1067 scoped_refptr<FakeTiledLayer> layer = | 1068 scoped_refptr<FakeTiledLayer> layer = |
1068 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1069 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1069 TestOcclusionTracker occluded; | 1070 TestOcclusionTracker occluded; |
1070 occlusion_ = &occluded; | 1071 occlusion_ = &occluded; |
1071 | 1072 |
1072 // The tile size is 100x100. | 1073 // The tile size is 100x100. |
1073 | 1074 |
1074 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1075 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); |
1075 layer->SetBounds(gfx::Size(600, 600)); | 1076 layer->SetBounds(gfx::Size(600, 600)); |
1076 CalcDrawProps(layer); | 1077 CalcDrawProps(layer); |
1077 | 1078 |
1078 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1079 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); |
1079 layer->draw_properties().drawable_content_rect = | 1080 layer->draw_properties().drawable_content_rect = |
1080 gfx::Rect(layer->content_bounds()); | 1081 gfx::Rect(layer->content_bounds()); |
1081 layer->draw_properties().visible_content_rect = | 1082 layer->draw_properties().visible_content_rect = |
1082 gfx::Rect(layer->content_bounds()); | 1083 gfx::Rect(layer->content_bounds()); |
1083 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1084 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1084 | 1085 |
1085 layer->SetTexturePriorities(priority_calculator_); | 1086 layer->SetTexturePriorities(priority_calculator_); |
1086 resource_manager_->PrioritizeTextures(); | 1087 resource_manager_->PrioritizeTextures(); |
1087 layer->Update(queue_.get(), &occluded, NULL); | 1088 layer->Update(queue_.get(), &occluded); |
1088 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); | 1089 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); |
1089 | 1090 |
1090 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1091 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1091 EXPECT_NEAR( | 1092 EXPECT_NEAR( |
1092 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); | 1093 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); |
1093 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1094 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1094 | 1095 |
1095 layer->fake_layer_updater()->ClearUpdateCount(); | 1096 layer->fake_layer_updater()->ClearUpdateCount(); |
1096 layer->SetTexturePriorities(priority_calculator_); | 1097 layer->SetTexturePriorities(priority_calculator_); |
1097 resource_manager_->PrioritizeTextures(); | 1098 resource_manager_->PrioritizeTextures(); |
1098 | 1099 |
1099 occluded.SetOcclusion(gfx::Rect(250, 200, 300, 100)); | 1100 occluded.SetOcclusion(gfx::Rect(250, 200, 300, 100)); |
1100 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1101 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1101 layer->Update(queue_.get(), &occluded, NULL); | 1102 layer->Update(queue_.get(), &occluded); |
1102 EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count()); | 1103 EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count()); |
1103 | 1104 |
1104 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1105 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1105 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1106 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1106 330000 + 340000, | 1107 330000 + 340000, |
1107 1); | 1108 1); |
1108 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1109 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1109 | 1110 |
1110 layer->fake_layer_updater()->ClearUpdateCount(); | 1111 layer->fake_layer_updater()->ClearUpdateCount(); |
1111 layer->SetTexturePriorities(priority_calculator_); | 1112 layer->SetTexturePriorities(priority_calculator_); |
1112 resource_manager_->PrioritizeTextures(); | 1113 resource_manager_->PrioritizeTextures(); |
1113 | 1114 |
1114 occluded.SetOcclusion(gfx::Rect(250, 250, 300, 100)); | 1115 occluded.SetOcclusion(gfx::Rect(250, 250, 300, 100)); |
1115 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1116 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1116 layer->Update(queue_.get(), &occluded, NULL); | 1117 layer->Update(queue_.get(), &occluded); |
1117 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); | 1118 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); |
1118 | 1119 |
1119 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1120 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1120 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1121 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1121 330000 + 340000 + 360000, | 1122 330000 + 340000 + 360000, |
1122 1); | 1123 1); |
1123 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1124 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1124 } | 1125 } |
1125 | 1126 |
1126 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { | 1127 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { |
(...skipping 10 matching lines...) Expand all Loading... |
1137 | 1138 |
1138 // The partially occluded tiles (by the 150 occlusion height) are visible | 1139 // The partially occluded tiles (by the 150 occlusion height) are visible |
1139 // beyond the occlusion, so not culled. | 1140 // beyond the occlusion, so not culled. |
1140 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1141 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); |
1141 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); | 1142 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); |
1142 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); | 1143 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); |
1143 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1144 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1144 | 1145 |
1145 layer->SetTexturePriorities(priority_calculator_); | 1146 layer->SetTexturePriorities(priority_calculator_); |
1146 resource_manager_->PrioritizeTextures(); | 1147 resource_manager_->PrioritizeTextures(); |
1147 layer->Update(queue_.get(), &occluded, NULL); | 1148 layer->Update(queue_.get(), &occluded); |
1148 EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count()); | 1149 EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count()); |
1149 | 1150 |
1150 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1151 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1151 EXPECT_NEAR( | 1152 EXPECT_NEAR( |
1152 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 210000, 1); | 1153 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 210000, 1); |
1153 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1154 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1154 | 1155 |
1155 layer->fake_layer_updater()->ClearUpdateCount(); | 1156 layer->fake_layer_updater()->ClearUpdateCount(); |
1156 | 1157 |
1157 // Now the visible region stops at the edge of the occlusion so the partly | 1158 // Now the visible region stops at the edge of the occlusion so the partly |
1158 // visible tiles become fully occluded. | 1159 // visible tiles become fully occluded. |
1159 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1160 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); |
1160 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); | 1161 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); |
1161 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350); | 1162 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350); |
1162 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1163 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1163 layer->SetTexturePriorities(priority_calculator_); | 1164 layer->SetTexturePriorities(priority_calculator_); |
1164 resource_manager_->PrioritizeTextures(); | 1165 resource_manager_->PrioritizeTextures(); |
1165 layer->Update(queue_.get(), &occluded, NULL); | 1166 layer->Update(queue_.get(), &occluded); |
1166 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); | 1167 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); |
1167 | 1168 |
1168 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1169 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1169 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1170 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1170 210000 + 180000, | 1171 210000 + 180000, |
1171 1); | 1172 1); |
1172 EXPECT_EQ(3 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1173 EXPECT_EQ(3 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1173 | 1174 |
1174 layer->fake_layer_updater()->ClearUpdateCount(); | 1175 layer->fake_layer_updater()->ClearUpdateCount(); |
1175 | 1176 |
1176 // Now the visible region is even smaller than the occlusion, it should have | 1177 // Now the visible region is even smaller than the occlusion, it should have |
1177 // the same result. | 1178 // the same result. |
1178 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1179 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); |
1179 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); | 1180 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); |
1180 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); | 1181 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); |
1181 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1182 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1182 layer->SetTexturePriorities(priority_calculator_); | 1183 layer->SetTexturePriorities(priority_calculator_); |
1183 resource_manager_->PrioritizeTextures(); | 1184 resource_manager_->PrioritizeTextures(); |
1184 layer->Update(queue_.get(), &occluded, NULL); | 1185 layer->Update(queue_.get(), &occluded); |
1185 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); | 1186 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); |
1186 | 1187 |
1187 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1188 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1188 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1189 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1189 210000 + 180000 + 180000, | 1190 210000 + 180000 + 180000, |
1190 1); | 1191 1); |
1191 EXPECT_EQ(3 + 6 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1192 EXPECT_EQ(3 + 6 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1192 } | 1193 } |
1193 | 1194 |
1194 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { | 1195 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { |
1195 scoped_refptr<FakeTiledLayer> layer = | 1196 scoped_refptr<FakeTiledLayer> layer = |
1196 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1197 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1197 TestOcclusionTracker occluded; | 1198 TestOcclusionTracker occluded; |
1198 occlusion_ = &occluded; | 1199 occlusion_ = &occluded; |
1199 | 1200 |
1200 // The tile size is 100x100. | 1201 // The tile size is 100x100. |
1201 | 1202 |
1202 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1203 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); |
1203 layer->SetBounds(gfx::Size(600, 600)); | 1204 layer->SetBounds(gfx::Size(600, 600)); |
1204 CalcDrawProps(layer); | 1205 CalcDrawProps(layer); |
1205 | 1206 |
1206 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1207 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); |
1207 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); | 1208 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); |
1208 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); | 1209 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); |
1209 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1210 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1210 layer->SetTexturePriorities(priority_calculator_); | 1211 layer->SetTexturePriorities(priority_calculator_); |
1211 resource_manager_->PrioritizeTextures(); | 1212 resource_manager_->PrioritizeTextures(); |
1212 layer->Update(queue_.get(), &occluded, NULL); | 1213 layer->Update(queue_.get(), &occluded); |
1213 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); | 1214 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); |
1214 { UpdateTextures(); } | 1215 { UpdateTextures(); } |
1215 | 1216 |
1216 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1217 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1217 EXPECT_NEAR( | 1218 EXPECT_NEAR( |
1218 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); | 1219 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); |
1219 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1220 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1220 | 1221 |
1221 layer->fake_layer_updater()->ClearUpdateCount(); | 1222 layer->fake_layer_updater()->ClearUpdateCount(); |
1222 layer->SetTexturePriorities(priority_calculator_); | 1223 layer->SetTexturePriorities(priority_calculator_); |
1223 resource_manager_->PrioritizeTextures(); | 1224 resource_manager_->PrioritizeTextures(); |
1224 | 1225 |
1225 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted | 1226 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted |
1226 // now. | 1227 // now. |
1227 layer->Update(queue_.get(), &occluded, NULL); | 1228 layer->Update(queue_.get(), &occluded); |
1228 EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); | 1229 EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); |
1229 | 1230 |
1230 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1231 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1231 EXPECT_NEAR( | 1232 EXPECT_NEAR( |
1232 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); | 1233 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); |
1233 EXPECT_EQ(6, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1234 EXPECT_EQ(6, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1234 } | 1235 } |
1235 | 1236 |
1236 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { | 1237 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { |
1237 scoped_refptr<FakeTiledLayer> layer = | 1238 scoped_refptr<FakeTiledLayer> layer = |
(...skipping 14 matching lines...) Expand all Loading... |
1252 layer->draw_properties().target_space_transform = screen_transform; | 1253 layer->draw_properties().target_space_transform = screen_transform; |
1253 | 1254 |
1254 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50)); | 1255 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50)); |
1255 layer->draw_properties().drawable_content_rect = | 1256 layer->draw_properties().drawable_content_rect = |
1256 gfx::Rect(layer->content_bounds()); | 1257 gfx::Rect(layer->content_bounds()); |
1257 layer->draw_properties().visible_content_rect = | 1258 layer->draw_properties().visible_content_rect = |
1258 gfx::Rect(layer->content_bounds()); | 1259 gfx::Rect(layer->content_bounds()); |
1259 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1260 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1260 layer->SetTexturePriorities(priority_calculator_); | 1261 layer->SetTexturePriorities(priority_calculator_); |
1261 resource_manager_->PrioritizeTextures(); | 1262 resource_manager_->PrioritizeTextures(); |
1262 layer->Update(queue_.get(), &occluded, NULL); | 1263 layer->Update(queue_.get(), &occluded); |
1263 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); | 1264 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); |
1264 | 1265 |
1265 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1266 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1266 EXPECT_NEAR( | 1267 EXPECT_NEAR( |
1267 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); | 1268 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); |
1268 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1269 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1269 } | 1270 } |
1270 | 1271 |
1271 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { | 1272 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { |
1272 scoped_refptr<FakeTiledLayer> layer = | 1273 scoped_refptr<FakeTiledLayer> layer = |
(...skipping 18 matching lines...) Expand all Loading... |
1291 layer->draw_properties().screen_space_transform = draw_transform; | 1292 layer->draw_properties().screen_space_transform = draw_transform; |
1292 | 1293 |
1293 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1294 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); |
1294 layer->draw_properties().drawable_content_rect = | 1295 layer->draw_properties().drawable_content_rect = |
1295 gfx::Rect(layer->bounds()); | 1296 gfx::Rect(layer->bounds()); |
1296 layer->draw_properties().visible_content_rect = | 1297 layer->draw_properties().visible_content_rect = |
1297 gfx::Rect(layer->content_bounds()); | 1298 gfx::Rect(layer->content_bounds()); |
1298 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1299 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1299 layer->SetTexturePriorities(priority_calculator_); | 1300 layer->SetTexturePriorities(priority_calculator_); |
1300 resource_manager_->PrioritizeTextures(); | 1301 resource_manager_->PrioritizeTextures(); |
1301 layer->Update(queue_.get(), &occluded, NULL); | 1302 layer->Update(queue_.get(), &occluded); |
1302 // The content is half the size of the layer (so the number of tiles is | 1303 // The content is half the size of the layer (so the number of tiles is |
1303 // fewer). In this case, the content is 300x300, and since the tile size is | 1304 // fewer). In this case, the content is 300x300, and since the tile size is |
1304 // 100, the number of tiles 3x3. | 1305 // 100, the number of tiles 3x3. |
1305 EXPECT_EQ(9, layer->fake_layer_updater()->update_count()); | 1306 EXPECT_EQ(9, layer->fake_layer_updater()->update_count()); |
1306 | 1307 |
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( | 1309 EXPECT_NEAR( |
1309 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 90000, 1); | 1310 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 90000, 1); |
1310 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1311 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1311 | 1312 |
1312 layer->fake_layer_updater()->ClearUpdateCount(); | 1313 layer->fake_layer_updater()->ClearUpdateCount(); |
1313 | 1314 |
1314 // This makes sure the painting works when the content space is scaled to | 1315 // This makes sure the painting works when the content space is scaled to |
1315 // a different layer space. In this case the occluded region catches the | 1316 // a different layer space. In this case the occluded region catches the |
1316 // blown up tiles. | 1317 // blown up tiles. |
1317 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 200)); | 1318 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 200)); |
1318 layer->draw_properties().drawable_content_rect = | 1319 layer->draw_properties().drawable_content_rect = |
1319 gfx::Rect(layer->bounds()); | 1320 gfx::Rect(layer->bounds()); |
1320 layer->draw_properties().visible_content_rect = | 1321 layer->draw_properties().visible_content_rect = |
1321 gfx::Rect(layer->content_bounds()); | 1322 gfx::Rect(layer->content_bounds()); |
1322 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1323 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1323 layer->SetTexturePriorities(priority_calculator_); | 1324 layer->SetTexturePriorities(priority_calculator_); |
1324 resource_manager_->PrioritizeTextures(); | 1325 resource_manager_->PrioritizeTextures(); |
1325 layer->Update(queue_.get(), &occluded, NULL); | 1326 layer->Update(queue_.get(), &occluded); |
1326 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); | 1327 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); |
1327 | 1328 |
1328 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1329 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1329 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1330 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1330 90000 + 80000, | 1331 90000 + 80000, |
1331 1); | 1332 1); |
1332 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1333 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1333 | 1334 |
1334 layer->fake_layer_updater()->ClearUpdateCount(); | 1335 layer->fake_layer_updater()->ClearUpdateCount(); |
1335 | 1336 |
1336 // This makes sure content scaling and transforms work together. | 1337 // This makes sure content scaling and transforms work together. |
1337 gfx::Transform screen_transform; | 1338 gfx::Transform screen_transform; |
1338 screen_transform.Scale(0.5, 0.5); | 1339 screen_transform.Scale(0.5, 0.5); |
1339 layer->draw_properties().screen_space_transform = screen_transform; | 1340 layer->draw_properties().screen_space_transform = screen_transform; |
1340 layer->draw_properties().target_space_transform = screen_transform; | 1341 layer->draw_properties().target_space_transform = screen_transform; |
1341 | 1342 |
1342 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 100)); | 1343 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 100)); |
1343 | 1344 |
1344 gfx::Rect layer_bounds_rect(layer->bounds()); | 1345 gfx::Rect layer_bounds_rect(layer->bounds()); |
1345 layer->draw_properties().drawable_content_rect = | 1346 layer->draw_properties().drawable_content_rect = |
1346 gfx::ToEnclosingRect(gfx::ScaleRect(layer_bounds_rect, 0.5)); | 1347 gfx::ToEnclosingRect(gfx::ScaleRect(layer_bounds_rect, 0.5)); |
1347 layer->draw_properties().visible_content_rect = | 1348 layer->draw_properties().visible_content_rect = |
1348 gfx::Rect(layer->content_bounds()); | 1349 gfx::Rect(layer->content_bounds()); |
1349 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1350 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1350 layer->SetTexturePriorities(priority_calculator_); | 1351 layer->SetTexturePriorities(priority_calculator_); |
1351 resource_manager_->PrioritizeTextures(); | 1352 resource_manager_->PrioritizeTextures(); |
1352 layer->Update(queue_.get(), &occluded, NULL); | 1353 layer->Update(queue_.get(), &occluded); |
1353 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); | 1354 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); |
1354 | 1355 |
1355 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1356 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1356 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1357 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1357 90000 + 80000 + 80000, | 1358 90000 + 80000 + 80000, |
1358 1); | 1359 1); |
1359 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1360 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1360 } | 1361 } |
1361 | 1362 |
1362 TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { | 1363 TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { |
(...skipping 17 matching lines...) Expand all Loading... |
1380 CalcDrawProps(layer); | 1381 CalcDrawProps(layer); |
1381 layer->draw_properties().drawable_content_rect = visible_bounds; | 1382 layer->draw_properties().drawable_content_rect = visible_bounds; |
1382 layer->draw_properties().visible_content_rect = visible_bounds; | 1383 layer->draw_properties().visible_content_rect = visible_bounds; |
1383 | 1384 |
1384 // If the layer doesn't paint opaque content, then the | 1385 // If the layer doesn't paint opaque content, then the |
1385 // VisibleContentOpaqueRegion should be empty. | 1386 // VisibleContentOpaqueRegion should be empty. |
1386 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1387 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1387 layer->InvalidateContentRect(content_bounds); | 1388 layer->InvalidateContentRect(content_bounds); |
1388 layer->SetTexturePriorities(priority_calculator_); | 1389 layer->SetTexturePriorities(priority_calculator_); |
1389 resource_manager_->PrioritizeTextures(); | 1390 resource_manager_->PrioritizeTextures(); |
1390 layer->Update(queue_.get(), &occluded, NULL); | 1391 layer->Update(queue_.get(), &occluded); |
1391 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1392 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1392 EXPECT_TRUE(opaque_contents.IsEmpty()); | 1393 EXPECT_TRUE(opaque_contents.IsEmpty()); |
1393 | 1394 |
1394 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000, 1); | 1395 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000, 1); |
1395 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1396 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1396 EXPECT_NEAR( | 1397 EXPECT_NEAR( |
1397 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); | 1398 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); |
1398 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1399 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1399 | 1400 |
1400 // VisibleContentOpaqueRegion should match the visible part of what is painted | 1401 // VisibleContentOpaqueRegion should match the visible part of what is painted |
1401 // opaque. | 1402 // opaque. |
1402 opaque_paint_rect = gfx::Rect(10, 10, 90, 190); | 1403 opaque_paint_rect = gfx::Rect(10, 10, 90, 190); |
1403 layer->fake_layer_updater()->SetOpaquePaintRect(opaque_paint_rect); | 1404 layer->fake_layer_updater()->SetOpaquePaintRect(opaque_paint_rect); |
1404 layer->InvalidateContentRect(content_bounds); | 1405 layer->InvalidateContentRect(content_bounds); |
1405 layer->SetTexturePriorities(priority_calculator_); | 1406 layer->SetTexturePriorities(priority_calculator_); |
1406 resource_manager_->PrioritizeTextures(); | 1407 resource_manager_->PrioritizeTextures(); |
1407 layer->Update(queue_.get(), &occluded, NULL); | 1408 layer->Update(queue_.get(), &occluded); |
1408 UpdateTextures(); | 1409 UpdateTextures(); |
1409 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1410 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1410 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), | 1411 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), |
1411 opaque_contents.ToString()); | 1412 opaque_contents.ToString()); |
1412 | 1413 |
1413 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); | 1414 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); |
1414 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); | 1415 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); |
1415 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1416 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1416 20000 + 20000 - 17100, | 1417 20000 + 20000 - 17100, |
1417 1); | 1418 1); |
1418 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1419 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1419 | 1420 |
1420 // If we paint again without invalidating, the same stuff should be opaque. | 1421 // If we paint again without invalidating, the same stuff should be opaque. |
1421 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1422 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1422 layer->SetTexturePriorities(priority_calculator_); | 1423 layer->SetTexturePriorities(priority_calculator_); |
1423 resource_manager_->PrioritizeTextures(); | 1424 resource_manager_->PrioritizeTextures(); |
1424 layer->Update(queue_.get(), &occluded, NULL); | 1425 layer->Update(queue_.get(), &occluded); |
1425 UpdateTextures(); | 1426 UpdateTextures(); |
1426 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1427 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1427 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), | 1428 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), |
1428 opaque_contents.ToString()); | 1429 opaque_contents.ToString()); |
1429 | 1430 |
1430 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); | 1431 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); |
1431 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); | 1432 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); |
1432 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1433 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1433 20000 + 20000 - 17100, | 1434 20000 + 20000 - 17100, |
1434 1); | 1435 1); |
1435 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1436 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1436 | 1437 |
1437 // If we repaint a non-opaque part of the tile, then it shouldn't lose its | 1438 // If we repaint a non-opaque part of the tile, then it shouldn't lose its |
1438 // opaque-ness. And other tiles should not be affected. | 1439 // opaque-ness. And other tiles should not be affected. |
1439 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1440 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1440 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); | 1441 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); |
1441 layer->SetTexturePriorities(priority_calculator_); | 1442 layer->SetTexturePriorities(priority_calculator_); |
1442 resource_manager_->PrioritizeTextures(); | 1443 resource_manager_->PrioritizeTextures(); |
1443 layer->Update(queue_.get(), &occluded, NULL); | 1444 layer->Update(queue_.get(), &occluded); |
1444 UpdateTextures(); | 1445 UpdateTextures(); |
1445 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1446 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1446 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), | 1447 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), |
1447 opaque_contents.ToString()); | 1448 opaque_contents.ToString()); |
1448 | 1449 |
1449 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1, 1); | 1450 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1, 1); |
1450 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); | 1451 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); |
1451 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1452 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
1452 20000 + 20000 - 17100 + 1, | 1453 20000 + 20000 - 17100 + 1, |
1453 1); | 1454 1); |
1454 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1455 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1455 | 1456 |
1456 // If we repaint an opaque part of the tile, then it should lose its | 1457 // If we repaint an opaque part of the tile, then it should lose its |
1457 // opaque-ness. But other tiles should still not be affected. | 1458 // opaque-ness. But other tiles should still not be affected. |
1458 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1459 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1459 layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1)); | 1460 layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1)); |
1460 layer->SetTexturePriorities(priority_calculator_); | 1461 layer->SetTexturePriorities(priority_calculator_); |
1461 resource_manager_->PrioritizeTextures(); | 1462 resource_manager_->PrioritizeTextures(); |
1462 layer->Update(queue_.get(), &occluded, NULL); | 1463 layer->Update(queue_.get(), &occluded); |
1463 UpdateTextures(); | 1464 UpdateTextures(); |
1464 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1465 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1465 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), | 1466 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), |
1466 visible_bounds).ToString(), | 1467 visible_bounds).ToString(), |
1467 opaque_contents.ToString()); | 1468 opaque_contents.ToString()); |
1468 | 1469 |
1469 EXPECT_NEAR( | 1470 EXPECT_NEAR( |
1470 occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1 + 1, 1); | 1471 occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1 + 1, 1); |
1471 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); | 1472 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); |
1472 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), | 1473 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), |
(...skipping 18 matching lines...) Expand all Loading... |
1491 | 1492 |
1492 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300); | 1493 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300); |
1493 layer->SetBounds(content_bounds.size()); | 1494 layer->SetBounds(content_bounds.size()); |
1494 CalcDrawProps(layer); | 1495 CalcDrawProps(layer); |
1495 | 1496 |
1496 // Invalidates and paints the whole layer. | 1497 // Invalidates and paints the whole layer. |
1497 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1498 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1498 layer->InvalidateContentRect(content_bounds); | 1499 layer->InvalidateContentRect(content_bounds); |
1499 layer->SetTexturePriorities(priority_calculator_); | 1500 layer->SetTexturePriorities(priority_calculator_); |
1500 resource_manager_->PrioritizeTextures(); | 1501 resource_manager_->PrioritizeTextures(); |
1501 layer->Update(queue_.get(), &occluded, NULL); | 1502 layer->Update(queue_.get(), &occluded); |
1502 UpdateTextures(); | 1503 UpdateTextures(); |
1503 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1504 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1504 EXPECT_TRUE(opaque_contents.IsEmpty()); | 1505 EXPECT_TRUE(opaque_contents.IsEmpty()); |
1505 | 1506 |
1506 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000, 1); | 1507 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000, 1); |
1507 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1508 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
1508 EXPECT_NEAR( | 1509 EXPECT_NEAR( |
1509 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 30000, 1); | 1510 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 30000, 1); |
1510 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1511 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1511 | 1512 |
1512 // Invalidates an area on the top and bottom tile, which will cause us to | 1513 // Invalidates an area on the top and bottom tile, which will cause us to |
1513 // paint the tile in the middle, even though it is not dirty and will not be | 1514 // paint the tile in the middle, even though it is not dirty and will not be |
1514 // uploaded. | 1515 // uploaded. |
1515 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); | 1516 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); |
1516 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); | 1517 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); |
1517 layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10)); | 1518 layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10)); |
1518 layer->SetTexturePriorities(priority_calculator_); | 1519 layer->SetTexturePriorities(priority_calculator_); |
1519 resource_manager_->PrioritizeTextures(); | 1520 resource_manager_->PrioritizeTextures(); |
1520 layer->Update(queue_.get(), &occluded, NULL); | 1521 layer->Update(queue_.get(), &occluded); |
1521 UpdateTextures(); | 1522 UpdateTextures(); |
1522 opaque_contents = layer->VisibleContentOpaqueRegion(); | 1523 opaque_contents = layer->VisibleContentOpaqueRegion(); |
1523 EXPECT_TRUE(opaque_contents.IsEmpty()); | 1524 EXPECT_TRUE(opaque_contents.IsEmpty()); |
1524 | 1525 |
1525 // The middle tile was painted even though not invalidated. | 1526 // The middle tile was painted even though not invalidated. |
1526 EXPECT_NEAR( | 1527 EXPECT_NEAR( |
1527 occluded.overdraw_metrics()->pixels_painted(), 30000 + 60 * 210, 1); | 1528 occluded.overdraw_metrics()->pixels_painted(), 30000 + 60 * 210, 1); |
1528 // The pixels uploaded will not include the non-invalidated tile in the | 1529 // The pixels uploaded will not include the non-invalidated tile in the |
1529 // middle. | 1530 // middle. |
1530 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 1531 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 gfx::Rect painted_rect_; | 1713 gfx::Rect painted_rect_; |
1713 }; | 1714 }; |
1714 | 1715 |
1715 class UpdateTrackingTiledLayer : public FakeTiledLayer { | 1716 class UpdateTrackingTiledLayer : public FakeTiledLayer { |
1716 public: | 1717 public: |
1717 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) | 1718 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) |
1718 : FakeTiledLayer(manager) { | 1719 : FakeTiledLayer(manager) { |
1719 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); | 1720 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); |
1720 tracking_layer_painter_ = painter.get(); | 1721 tracking_layer_painter_ = painter.get(); |
1721 layer_updater_ = | 1722 layer_updater_ = |
1722 BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>()); | 1723 BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>(), |
| 1724 &stats_instrumentation_); |
1723 } | 1725 } |
1724 | 1726 |
1725 TrackingLayerPainter* tracking_layer_painter() const { | 1727 TrackingLayerPainter* tracking_layer_painter() const { |
1726 return tracking_layer_painter_; | 1728 return tracking_layer_painter_; |
1727 } | 1729 } |
1728 | 1730 |
1729 private: | 1731 private: |
1730 virtual LayerUpdater* Updater() const OVERRIDE { | 1732 virtual LayerUpdater* Updater() const OVERRIDE { |
1731 return layer_updater_.get(); | 1733 return layer_updater_.get(); |
1732 } | 1734 } |
1733 virtual ~UpdateTrackingTiledLayer() {} | 1735 virtual ~UpdateTrackingTiledLayer() {} |
1734 | 1736 |
1735 TrackingLayerPainter* tracking_layer_painter_; | 1737 TrackingLayerPainter* tracking_layer_painter_; |
1736 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; | 1738 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; |
| 1739 FakeRenderingStatsInstrumentation stats_instrumentation_; |
1737 }; | 1740 }; |
1738 | 1741 |
1739 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { | 1742 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { |
1740 scoped_refptr<UpdateTrackingTiledLayer> layer = | 1743 scoped_refptr<UpdateTrackingTiledLayer> layer = |
1741 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); | 1744 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); |
1742 | 1745 |
1743 gfx::Rect layer_rect(0, 0, 30, 31); | 1746 gfx::Rect layer_rect(0, 0, 30, 31); |
1744 layer->SetPosition(layer_rect.origin()); | 1747 layer->SetPosition(layer_rect.origin()); |
1745 layer->SetBounds(layer_rect.size()); | 1748 layer->SetBounds(layer_rect.size()); |
1746 layer->UpdateContentsScale(1.5f); | 1749 layer->UpdateContentsScale(1.5f); |
1747 | 1750 |
1748 gfx::Rect content_rect(0, 0, 45, 47); | 1751 gfx::Rect content_rect(0, 0, 45, 47); |
1749 EXPECT_EQ(content_rect.size(), layer->content_bounds()); | 1752 EXPECT_EQ(content_rect.size(), layer->content_bounds()); |
1750 layer->draw_properties().visible_content_rect = content_rect; | 1753 layer->draw_properties().visible_content_rect = content_rect; |
1751 layer->draw_properties().drawable_content_rect = content_rect; | 1754 layer->draw_properties().drawable_content_rect = content_rect; |
1752 | 1755 |
1753 layer->SetTexturePriorities(priority_calculator_); | 1756 layer->SetTexturePriorities(priority_calculator_); |
1754 resource_manager_->PrioritizeTextures(); | 1757 resource_manager_->PrioritizeTextures(); |
1755 | 1758 |
1756 // Update the whole tile. | 1759 // Update the whole tile. |
1757 layer->Update(queue_.get(), 0, NULL); | 1760 layer->Update(queue_.get(), NULL); |
1758 layer->tracking_layer_painter()->ResetPaintedRect(); | 1761 layer->tracking_layer_painter()->ResetPaintedRect(); |
1759 | 1762 |
1760 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); | 1763 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); |
1761 UpdateTextures(); | 1764 UpdateTextures(); |
1762 | 1765 |
1763 // Invalidate the entire layer in content space. When painting, the rect given | 1766 // Invalidate the entire layer in content space. When painting, the rect given |
1764 // to webkit should match the layer's bounds. | 1767 // to webkit should match the layer's bounds. |
1765 layer->InvalidateContentRect(content_rect); | 1768 layer->InvalidateContentRect(content_rect); |
1766 layer->Update(queue_.get(), 0, NULL); | 1769 layer->Update(queue_.get(), NULL); |
1767 | 1770 |
1768 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1771 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1769 } | 1772 } |
1770 | 1773 |
1771 TEST_F(TiledLayerTest, | 1774 TEST_F(TiledLayerTest, |
1772 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { | 1775 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { |
1773 scoped_refptr<UpdateTrackingTiledLayer> layer = | 1776 scoped_refptr<UpdateTrackingTiledLayer> layer = |
1774 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); | 1777 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); |
1775 | 1778 |
1776 gfx::Rect layer_rect(0, 0, 30, 31); | 1779 gfx::Rect layer_rect(0, 0, 30, 31); |
1777 layer->SetPosition(layer_rect.origin()); | 1780 layer->SetPosition(layer_rect.origin()); |
1778 layer->SetBounds(layer_rect.size()); | 1781 layer->SetBounds(layer_rect.size()); |
1779 layer->UpdateContentsScale(1.3f); | 1782 layer->UpdateContentsScale(1.3f); |
1780 | 1783 |
1781 gfx::Rect content_rect(layer->content_bounds()); | 1784 gfx::Rect content_rect(layer->content_bounds()); |
1782 layer->draw_properties().visible_content_rect = content_rect; | 1785 layer->draw_properties().visible_content_rect = content_rect; |
1783 layer->draw_properties().drawable_content_rect = content_rect; | 1786 layer->draw_properties().drawable_content_rect = content_rect; |
1784 | 1787 |
1785 layer->SetTexturePriorities(priority_calculator_); | 1788 layer->SetTexturePriorities(priority_calculator_); |
1786 resource_manager_->PrioritizeTextures(); | 1789 resource_manager_->PrioritizeTextures(); |
1787 | 1790 |
1788 // Update the whole tile. | 1791 // Update the whole tile. |
1789 layer->Update(queue_.get(), 0, NULL); | 1792 layer->Update(queue_.get(), NULL); |
1790 layer->tracking_layer_painter()->ResetPaintedRect(); | 1793 layer->tracking_layer_painter()->ResetPaintedRect(); |
1791 | 1794 |
1792 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); | 1795 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); |
1793 UpdateTextures(); | 1796 UpdateTextures(); |
1794 | 1797 |
1795 // Invalidate the entire layer in layer space. When painting, the rect given | 1798 // Invalidate the entire layer in layer space. When painting, the rect given |
1796 // to webkit should match the layer's bounds. | 1799 // to webkit should match the layer's bounds. |
1797 layer->SetNeedsDisplayRect(layer_rect); | 1800 layer->SetNeedsDisplayRect(layer_rect); |
1798 layer->Update(queue_.get(), 0, NULL); | 1801 layer->Update(queue_.get(), NULL); |
1799 | 1802 |
1800 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1803 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1801 } | 1804 } |
1802 | 1805 |
1803 } // namespace | 1806 } // namespace |
1804 } // namespace cc | 1807 } // namespace cc |
OLD | NEW |