Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: cc/layers/tiled_layer_unittest.cc

Issue 13939005: cc: Add strict layer property change checking and handle bounds changes during paint. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/CHECK/DCHECK/ Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/tiled_layer.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const scoped_refptr<FakeTiledLayer>& layer2, 153 const scoped_refptr<FakeTiledLayer>& layer2,
154 const scoped_ptr<FakeTiledLayerImpl>& layer_impl2) { 154 const scoped_ptr<FakeTiledLayerImpl>& layer_impl2) {
155 // Get textures 155 // Get textures
156 resource_manager_->ClearPriorities(); 156 resource_manager_->ClearPriorities();
157 if (layer1) 157 if (layer1)
158 layer1->SetTexturePriorities(priority_calculator_); 158 layer1->SetTexturePriorities(priority_calculator_);
159 if (layer2) 159 if (layer2)
160 layer2->SetTexturePriorities(priority_calculator_); 160 layer2->SetTexturePriorities(priority_calculator_);
161 resource_manager_->PrioritizeTextures(); 161 resource_manager_->PrioritizeTextures();
162 162
163 // Save paint properties
164 if (layer1)
165 layer1->SavePaintProperties();
166 if (layer2)
167 layer2->SavePaintProperties();
168
163 // Update content 169 // Update content
164 if (layer1) 170 if (layer1)
165 layer1->Update(queue_.get(), occlusion_, NULL); 171 layer1->Update(queue_.get(), occlusion_, NULL);
166 if (layer2) 172 if (layer2)
167 layer2->Update(queue_.get(), occlusion_, NULL); 173 layer2->Update(queue_.get(), occlusion_, NULL);
168 174
169 bool needs_update = false; 175 bool needs_update = false;
170 if (layer1) 176 if (layer1)
171 needs_update |= layer1->NeedsIdlePaint(); 177 needs_update |= layer1->NeedsIdlePaint();
172 if (layer2) 178 if (layer2)
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 604
599 // Pretend the layer is animating. 605 // Pretend the layer is animating.
600 layer->draw_properties().target_space_transform_is_animating = true; 606 layer->draw_properties().target_space_transform_is_animating = true;
601 layer->draw_properties().visible_content_rect = visible_rect; 607 layer->draw_properties().visible_content_rect = visible_rect;
602 layer->SetLayerTreeHost(layer_tree_host_.get()); 608 layer->SetLayerTreeHost(layer_tree_host_.get());
603 609
604 // The layer should paint its entire contents on the first paint 610 // 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. 611 // if it is close to the viewport size and has the available memory.
606 layer->SetTexturePriorities(priority_calculator_); 612 layer->SetTexturePriorities(priority_calculator_);
607 resource_manager_->PrioritizeTextures(); 613 resource_manager_->PrioritizeTextures();
614 layer->SavePaintProperties();
608 layer->Update(queue_.get(), 0, NULL); 615 layer->Update(queue_.get(), 0, NULL);
609 UpdateTextures(); 616 UpdateTextures();
610 LayerPushPropertiesTo(layer.get(), layer_impl.get()); 617 LayerPushPropertiesTo(layer.get(), layer_impl.get());
611 618
612 // We should have all the tiles for the small animated layer. 619 // We should have all the tiles for the small animated layer.
613 // We should still have the visible tiles when we didn't 620 // We should still have the visible tiles when we didn't
614 // have enough memory for all the tiles. 621 // have enough memory for all the tiles.
615 if (!run_out_of_memory[i]) { 622 if (!run_out_of_memory[i]) {
616 for (int i = 0; i < 5; ++i) { 623 for (int i = 0; i < 5; ++i) {
617 for (int j = 0; j < 5; ++j) 624 for (int j = 0; j < 5; ++j)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 layer->SetContentBounds(content_bounds.size()); 772 layer->SetContentBounds(content_bounds.size());
766 layer->draw_properties().visible_content_rect = content_bounds; 773 layer->draw_properties().visible_content_rect = content_bounds;
767 774
768 // On first update, the update_rect includes all tiles, even beyond the 775 // On first update, the update_rect includes all tiles, even beyond the
769 // boundaries of the layer. 776 // boundaries of the layer.
770 // However, it should still be in layer space, not content space. 777 // However, it should still be in layer space, not content space.
771 layer->InvalidateContentRect(content_bounds); 778 layer->InvalidateContentRect(content_bounds);
772 779
773 layer->SetTexturePriorities(priority_calculator_); 780 layer->SetTexturePriorities(priority_calculator_);
774 resource_manager_->PrioritizeTextures(); 781 resource_manager_->PrioritizeTextures();
782 layer->SavePaintProperties();
775 layer->Update(queue_.get(), 0, NULL); 783 layer->Update(queue_.get(), 0, NULL);
776 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect()); 784 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect());
777 UpdateTextures(); 785 UpdateTextures();
778 786
779 // After the tiles are updated once, another invalidate only needs to update 787 // After the tiles are updated once, another invalidate only needs to update
780 // the bounds of the layer. 788 // the bounds of the layer.
781 layer->SetTexturePriorities(priority_calculator_); 789 layer->SetTexturePriorities(priority_calculator_);
782 resource_manager_->PrioritizeTextures(); 790 resource_manager_->PrioritizeTextures();
783 layer->InvalidateContentRect(content_bounds); 791 layer->InvalidateContentRect(content_bounds);
792 layer->SavePaintProperties();
784 layer->Update(queue_.get(), 0, NULL); 793 layer->Update(queue_.get(), 0, NULL);
785 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); 794 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect());
786 UpdateTextures(); 795 UpdateTextures();
787 796
788 // Partial re-paint should also be represented by the update rect in layer 797 // Partial re-paint should also be represented by the update rect in layer
789 // space, not content space. 798 // space, not content space.
790 gfx::Rect partial_damage(30, 100, 10, 10); 799 gfx::Rect partial_damage(30, 100, 10, 10);
791 layer->InvalidateContentRect(partial_damage); 800 layer->InvalidateContentRect(partial_damage);
792 layer->SetTexturePriorities(priority_calculator_); 801 layer->SetTexturePriorities(priority_calculator_);
793 resource_manager_->PrioritizeTextures(); 802 resource_manager_->PrioritizeTextures();
803 layer->SavePaintProperties();
794 layer->Update(queue_.get(), 0, NULL); 804 layer->Update(queue_.get(), 0, NULL);
795 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); 805 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect());
796 } 806 }
797 807
798 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { 808 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) {
799 scoped_refptr<FakeTiledLayer> layer = 809 scoped_refptr<FakeTiledLayer> layer =
800 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 810 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
801 scoped_ptr<FakeTiledLayerImpl> layer_impl = 811 scoped_ptr<FakeTiledLayerImpl> layer_impl =
802 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 812 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
803 813
804 // Create a layer with one tile. 814 // Create a layer with one tile.
805 layer->SetBounds(gfx::Size(100, 100)); 815 layer->SetBounds(gfx::Size(100, 100));
806 CalcDrawProps(layer); 816 CalcDrawProps(layer);
807 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 817 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
808 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), 818 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100),
809 layer->last_needs_display_rect()); 819 layer->last_needs_display_rect());
810 820
811 // Push the tiles to the impl side and check that there is exactly one. 821 // Push the tiles to the impl side and check that there is exactly one.
812 layer->SetTexturePriorities(priority_calculator_); 822 layer->SetTexturePriorities(priority_calculator_);
813 resource_manager_->PrioritizeTextures(); 823 resource_manager_->PrioritizeTextures();
824 layer->SavePaintProperties();
814 layer->Update(queue_.get(), 0, NULL); 825 layer->Update(queue_.get(), 0, NULL);
815 UpdateTextures(); 826 UpdateTextures();
816 LayerPushPropertiesTo(layer.get(), layer_impl.get()); 827 LayerPushPropertiesTo(layer.get(), layer_impl.get());
817 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 828 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
818 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); 829 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1));
819 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 0)); 830 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 0));
820 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 1)); 831 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 1));
821 832
822 layer->SetNeedsDisplayRect(gfx::Rect()); 833 layer->SetNeedsDisplayRect(gfx::Rect());
823 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); 834 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect());
824 835
825 // Change the contents scale. 836 // Change the contents scale.
826 layer->UpdateContentsScale(2.f); 837 layer->UpdateContentsScale(2.f);
827 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); 838 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200);
828 839
829 // The impl side should get 2x2 tiles now. 840 // The impl side should get 2x2 tiles now.
830 layer->SetTexturePriorities(priority_calculator_); 841 layer->SetTexturePriorities(priority_calculator_);
831 resource_manager_->PrioritizeTextures(); 842 resource_manager_->PrioritizeTextures();
843 layer->SavePaintProperties();
832 layer->Update(queue_.get(), 0, NULL); 844 layer->Update(queue_.get(), 0, NULL);
833 UpdateTextures(); 845 UpdateTextures();
834 LayerPushPropertiesTo(layer.get(), layer_impl.get()); 846 LayerPushPropertiesTo(layer.get(), layer_impl.get());
835 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 847 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
836 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); 848 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1));
837 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 0)); 849 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 0));
838 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1)); 850 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1));
839 851
840 // Verify that changing the contents scale caused invalidation, and 852 // Verify that changing the contents scale caused invalidation, and
841 // that the layer-space rectangle requiring painting is not scaled. 853 // that the layer-space rectangle requiring painting is not scaled.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 TEST_F(TiledLayerTest, ResizeToSmaller) { 915 TEST_F(TiledLayerTest, ResizeToSmaller) {
904 scoped_refptr<FakeTiledLayer> layer = 916 scoped_refptr<FakeTiledLayer> layer =
905 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 917 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
906 918
907 layer->SetBounds(gfx::Size(700, 700)); 919 layer->SetBounds(gfx::Size(700, 700));
908 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); 920 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700);
909 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); 921 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700));
910 922
911 layer->SetTexturePriorities(priority_calculator_); 923 layer->SetTexturePriorities(priority_calculator_);
912 resource_manager_->PrioritizeTextures(); 924 resource_manager_->PrioritizeTextures();
925 layer->SavePaintProperties();
913 layer->Update(queue_.get(), 0, NULL); 926 layer->Update(queue_.get(), 0, NULL);
914 927
915 layer->SetBounds(gfx::Size(200, 200)); 928 layer->SetBounds(gfx::Size(200, 200));
916 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); 929 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200));
917 } 930 }
918 931
919 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { 932 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) {
920 scoped_refptr<FakeTiledLayer> layer = 933 scoped_refptr<FakeTiledLayer> layer =
921 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 934 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
922 935
923 int size = 1 << 30; 936 int size = 1 << 30;
924 layer->SetBounds(gfx::Size(size, size)); 937 layer->SetBounds(gfx::Size(size, size));
925 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); 938 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700);
926 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); 939 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size));
927 940
928 // Ensure no crash for bounds where size * size would overflow an int. 941 // Ensure no crash for bounds where size * size would overflow an int.
929 layer->SetTexturePriorities(priority_calculator_); 942 layer->SetTexturePriorities(priority_calculator_);
930 resource_manager_->PrioritizeTextures(); 943 resource_manager_->PrioritizeTextures();
944 layer->SavePaintProperties();
931 layer->Update(queue_.get(), 0, NULL); 945 layer->Update(queue_.get(), 0, NULL);
932 } 946 }
933 947
934 class TiledLayerPartialUpdateTest : public TiledLayerTest { 948 class TiledLayerPartialUpdateTest : public TiledLayerTest {
935 public: 949 public:
936 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; } 950 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; }
937 }; 951 };
938 952
939 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { 953 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) {
940 // Create one 300 x 200 tiled layer with 3 x 2 tiles. 954 // Create one 300 x 200 tiled layer with 3 x 2 tiles.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { 1066 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) {
1053 scoped_refptr<FakeTiledLayer> layer = 1067 scoped_refptr<FakeTiledLayer> layer =
1054 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1068 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
1055 1069
1056 // The tile size is 100x100, so this invalidates and then paints two tiles. 1070 // The tile size is 100x100, so this invalidates and then paints two tiles.
1057 layer->SetBounds(gfx::Size(100, 200)); 1071 layer->SetBounds(gfx::Size(100, 200));
1058 CalcDrawProps(layer); 1072 CalcDrawProps(layer);
1059 1073
1060 layer->SetTexturePriorities(priority_calculator_); 1074 layer->SetTexturePriorities(priority_calculator_);
1061 resource_manager_->PrioritizeTextures(); 1075 resource_manager_->PrioritizeTextures();
1076 layer->SavePaintProperties();
1062 layer->Update(queue_.get(), 0, NULL); 1077 layer->Update(queue_.get(), 0, NULL);
1063 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); 1078 EXPECT_EQ(2, layer->fake_layer_updater()->update_count());
1064 } 1079 }
1065 1080
1066 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { 1081 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) {
1067 scoped_refptr<FakeTiledLayer> layer = 1082 scoped_refptr<FakeTiledLayer> layer =
1068 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1083 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
1069 TestOcclusionTracker occluded; 1084 TestOcclusionTracker occluded;
1070 occlusion_ = &occluded; 1085 occlusion_ = &occluded;
1071 1086
1072 // The tile size is 100x100. 1087 // The tile size is 100x100.
1073 1088
1074 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); 1089 layer_tree_host_->SetViewportSize(gfx::Size(600, 600));
1075 layer->SetBounds(gfx::Size(600, 600)); 1090 layer->SetBounds(gfx::Size(600, 600));
1076 CalcDrawProps(layer); 1091 CalcDrawProps(layer);
1077 1092
1078 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); 1093 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100));
1079 layer->draw_properties().drawable_content_rect = 1094 layer->draw_properties().drawable_content_rect =
1080 gfx::Rect(layer->content_bounds()); 1095 gfx::Rect(layer->content_bounds());
1081 layer->draw_properties().visible_content_rect = 1096 layer->draw_properties().visible_content_rect =
1082 gfx::Rect(layer->content_bounds()); 1097 gfx::Rect(layer->content_bounds());
1083 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1098 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1084 1099
1085 layer->SetTexturePriorities(priority_calculator_); 1100 layer->SetTexturePriorities(priority_calculator_);
1086 resource_manager_->PrioritizeTextures(); 1101 resource_manager_->PrioritizeTextures();
1102 layer->SavePaintProperties();
1087 layer->Update(queue_.get(), &occluded, NULL); 1103 layer->Update(queue_.get(), &occluded, NULL);
1088 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); 1104 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count());
1089 1105
1090 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1106 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1091 EXPECT_NEAR( 1107 EXPECT_NEAR(
1092 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); 1108 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1);
1093 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1109 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload());
1094 1110
1095 layer->fake_layer_updater()->ClearUpdateCount(); 1111 layer->fake_layer_updater()->ClearUpdateCount();
1096 layer->SetTexturePriorities(priority_calculator_); 1112 layer->SetTexturePriorities(priority_calculator_);
1097 resource_manager_->PrioritizeTextures(); 1113 resource_manager_->PrioritizeTextures();
1098 1114
1099 occluded.SetOcclusion(gfx::Rect(250, 200, 300, 100)); 1115 occluded.SetOcclusion(gfx::Rect(250, 200, 300, 100));
1100 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1116 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1117 layer->SavePaintProperties();
1101 layer->Update(queue_.get(), &occluded, NULL); 1118 layer->Update(queue_.get(), &occluded, NULL);
1102 EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count()); 1119 EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count());
1103 1120
1104 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1121 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1105 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1122 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1106 330000 + 340000, 1123 330000 + 340000,
1107 1); 1124 1);
1108 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1125 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload());
1109 1126
1110 layer->fake_layer_updater()->ClearUpdateCount(); 1127 layer->fake_layer_updater()->ClearUpdateCount();
1111 layer->SetTexturePriorities(priority_calculator_); 1128 layer->SetTexturePriorities(priority_calculator_);
1112 resource_manager_->PrioritizeTextures(); 1129 resource_manager_->PrioritizeTextures();
1113 1130
1114 occluded.SetOcclusion(gfx::Rect(250, 250, 300, 100)); 1131 occluded.SetOcclusion(gfx::Rect(250, 250, 300, 100));
1115 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1132 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1133 layer->SavePaintProperties();
1116 layer->Update(queue_.get(), &occluded, NULL); 1134 layer->Update(queue_.get(), &occluded, NULL);
1117 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); 1135 EXPECT_EQ(36, layer->fake_layer_updater()->update_count());
1118 1136
1119 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1137 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1120 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1138 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1121 330000 + 340000 + 360000, 1139 330000 + 340000 + 360000,
1122 1); 1140 1);
1123 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1141 EXPECT_EQ(3 + 2, occluded.overdraw_metrics()->tiles_culled_for_upload());
1124 } 1142 }
1125 1143
(...skipping 11 matching lines...) Expand all
1137 1155
1138 // The partially occluded tiles (by the 150 occlusion height) are visible 1156 // The partially occluded tiles (by the 150 occlusion height) are visible
1139 // beyond the occlusion, so not culled. 1157 // beyond the occlusion, so not culled.
1140 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); 1158 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150));
1141 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); 1159 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); 1160 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360);
1143 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1161 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1144 1162
1145 layer->SetTexturePriorities(priority_calculator_); 1163 layer->SetTexturePriorities(priority_calculator_);
1146 resource_manager_->PrioritizeTextures(); 1164 resource_manager_->PrioritizeTextures();
1165 layer->SavePaintProperties();
1147 layer->Update(queue_.get(), &occluded, NULL); 1166 layer->Update(queue_.get(), &occluded, NULL);
1148 EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count()); 1167 EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count());
1149 1168
1150 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1169 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1151 EXPECT_NEAR( 1170 EXPECT_NEAR(
1152 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 210000, 1); 1171 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 210000, 1);
1153 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1172 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload());
1154 1173
1155 layer->fake_layer_updater()->ClearUpdateCount(); 1174 layer->fake_layer_updater()->ClearUpdateCount();
1156 1175
1157 // Now the visible region stops at the edge of the occlusion so the partly 1176 // Now the visible region stops at the edge of the occlusion so the partly
1158 // visible tiles become fully occluded. 1177 // visible tiles become fully occluded.
1159 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); 1178 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150));
1160 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); 1179 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); 1180 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350);
1162 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1181 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1163 layer->SetTexturePriorities(priority_calculator_); 1182 layer->SetTexturePriorities(priority_calculator_);
1164 resource_manager_->PrioritizeTextures(); 1183 resource_manager_->PrioritizeTextures();
1184 layer->SavePaintProperties();
1165 layer->Update(queue_.get(), &occluded, NULL); 1185 layer->Update(queue_.get(), &occluded, NULL);
1166 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); 1186 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count());
1167 1187
1168 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1188 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1169 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1189 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1170 210000 + 180000, 1190 210000 + 180000,
1171 1); 1191 1);
1172 EXPECT_EQ(3 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1192 EXPECT_EQ(3 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload());
1173 1193
1174 layer->fake_layer_updater()->ClearUpdateCount(); 1194 layer->fake_layer_updater()->ClearUpdateCount();
1175 1195
1176 // Now the visible region is even smaller than the occlusion, it should have 1196 // Now the visible region is even smaller than the occlusion, it should have
1177 // the same result. 1197 // the same result.
1178 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); 1198 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150));
1179 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); 1199 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); 1200 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340);
1181 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1201 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1182 layer->SetTexturePriorities(priority_calculator_); 1202 layer->SetTexturePriorities(priority_calculator_);
1183 resource_manager_->PrioritizeTextures(); 1203 resource_manager_->PrioritizeTextures();
1204 layer->SavePaintProperties();
1184 layer->Update(queue_.get(), &occluded, NULL); 1205 layer->Update(queue_.get(), &occluded, NULL);
1185 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); 1206 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count());
1186 1207
1187 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1208 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1188 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1209 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1189 210000 + 180000 + 180000, 1210 210000 + 180000 + 180000,
1190 1); 1211 1);
1191 EXPECT_EQ(3 + 6 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1212 EXPECT_EQ(3 + 6 + 6, occluded.overdraw_metrics()->tiles_culled_for_upload());
1192 } 1213 }
1193 1214
1194 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { 1215 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) {
1195 scoped_refptr<FakeTiledLayer> layer = 1216 scoped_refptr<FakeTiledLayer> layer =
1196 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1217 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
1197 TestOcclusionTracker occluded; 1218 TestOcclusionTracker occluded;
1198 occlusion_ = &occluded; 1219 occlusion_ = &occluded;
1199 1220
1200 // The tile size is 100x100. 1221 // The tile size is 100x100.
1201 1222
1202 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); 1223 layer_tree_host_->SetViewportSize(gfx::Size(600, 600));
1203 layer->SetBounds(gfx::Size(600, 600)); 1224 layer->SetBounds(gfx::Size(600, 600));
1204 CalcDrawProps(layer); 1225 CalcDrawProps(layer);
1205 1226
1206 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); 1227 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100));
1207 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); 1228 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); 1229 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600);
1209 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1230 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1210 layer->SetTexturePriorities(priority_calculator_); 1231 layer->SetTexturePriorities(priority_calculator_);
1211 resource_manager_->PrioritizeTextures(); 1232 resource_manager_->PrioritizeTextures();
1233 layer->SavePaintProperties();
1212 layer->Update(queue_.get(), &occluded, NULL); 1234 layer->Update(queue_.get(), &occluded, NULL);
1213 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); 1235 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count());
1214 { UpdateTextures(); } 1236 { UpdateTextures(); }
1215 1237
1216 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1238 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1217 EXPECT_NEAR( 1239 EXPECT_NEAR(
1218 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); 1240 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1);
1219 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1241 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload());
1220 1242
1221 layer->fake_layer_updater()->ClearUpdateCount(); 1243 layer->fake_layer_updater()->ClearUpdateCount();
1222 layer->SetTexturePriorities(priority_calculator_); 1244 layer->SetTexturePriorities(priority_calculator_);
1223 resource_manager_->PrioritizeTextures(); 1245 resource_manager_->PrioritizeTextures();
1246 layer->SavePaintProperties();
1224 1247
1225 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted 1248 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted
1226 // now. 1249 // now.
1227 layer->Update(queue_.get(), &occluded, NULL); 1250 layer->Update(queue_.get(), &occluded, NULL);
1228 EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); 1251 EXPECT_EQ(3, layer->fake_layer_updater()->update_count());
1229 1252
1230 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1253 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1231 EXPECT_NEAR( 1254 EXPECT_NEAR(
1232 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); 1255 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1);
1233 EXPECT_EQ(6, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1256 EXPECT_EQ(6, occluded.overdraw_metrics()->tiles_culled_for_upload());
(...skipping 18 matching lines...) Expand all
1252 layer->draw_properties().target_space_transform = screen_transform; 1275 layer->draw_properties().target_space_transform = screen_transform;
1253 1276
1254 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50)); 1277 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50));
1255 layer->draw_properties().drawable_content_rect = 1278 layer->draw_properties().drawable_content_rect =
1256 gfx::Rect(layer->content_bounds()); 1279 gfx::Rect(layer->content_bounds());
1257 layer->draw_properties().visible_content_rect = 1280 layer->draw_properties().visible_content_rect =
1258 gfx::Rect(layer->content_bounds()); 1281 gfx::Rect(layer->content_bounds());
1259 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1282 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1260 layer->SetTexturePriorities(priority_calculator_); 1283 layer->SetTexturePriorities(priority_calculator_);
1261 resource_manager_->PrioritizeTextures(); 1284 resource_manager_->PrioritizeTextures();
1285 layer->SavePaintProperties();
1262 layer->Update(queue_.get(), &occluded, NULL); 1286 layer->Update(queue_.get(), &occluded, NULL);
1263 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); 1287 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count());
1264 1288
1265 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1289 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1266 EXPECT_NEAR( 1290 EXPECT_NEAR(
1267 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1); 1291 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 330000, 1);
1268 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1292 EXPECT_EQ(3, occluded.overdraw_metrics()->tiles_culled_for_upload());
1269 } 1293 }
1270 1294
1271 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { 1295 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) {
(...skipping 19 matching lines...) Expand all
1291 layer->draw_properties().screen_space_transform = draw_transform; 1315 layer->draw_properties().screen_space_transform = draw_transform;
1292 1316
1293 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); 1317 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100));
1294 layer->draw_properties().drawable_content_rect = 1318 layer->draw_properties().drawable_content_rect =
1295 gfx::Rect(layer->bounds()); 1319 gfx::Rect(layer->bounds());
1296 layer->draw_properties().visible_content_rect = 1320 layer->draw_properties().visible_content_rect =
1297 gfx::Rect(layer->content_bounds()); 1321 gfx::Rect(layer->content_bounds());
1298 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1322 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1299 layer->SetTexturePriorities(priority_calculator_); 1323 layer->SetTexturePriorities(priority_calculator_);
1300 resource_manager_->PrioritizeTextures(); 1324 resource_manager_->PrioritizeTextures();
1325 layer->SavePaintProperties();
1301 layer->Update(queue_.get(), &occluded, NULL); 1326 layer->Update(queue_.get(), &occluded, NULL);
1302 // The content is half the size of the layer (so the number of tiles is 1327 // 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 1328 // fewer). In this case, the content is 300x300, and since the tile size is
1304 // 100, the number of tiles 3x3. 1329 // 100, the number of tiles 3x3.
1305 EXPECT_EQ(9, layer->fake_layer_updater()->update_count()); 1330 EXPECT_EQ(9, layer->fake_layer_updater()->update_count());
1306 1331
1307 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1332 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1308 EXPECT_NEAR( 1333 EXPECT_NEAR(
1309 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 90000, 1); 1334 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 90000, 1);
1310 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1335 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload());
1311 1336
1312 layer->fake_layer_updater()->ClearUpdateCount(); 1337 layer->fake_layer_updater()->ClearUpdateCount();
1313 1338
1314 // This makes sure the painting works when the content space is scaled to 1339 // 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 1340 // a different layer space. In this case the occluded region catches the
1316 // blown up tiles. 1341 // blown up tiles.
1317 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 200)); 1342 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 200));
1318 layer->draw_properties().drawable_content_rect = 1343 layer->draw_properties().drawable_content_rect =
1319 gfx::Rect(layer->bounds()); 1344 gfx::Rect(layer->bounds());
1320 layer->draw_properties().visible_content_rect = 1345 layer->draw_properties().visible_content_rect =
1321 gfx::Rect(layer->content_bounds()); 1346 gfx::Rect(layer->content_bounds());
1322 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1347 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1323 layer->SetTexturePriorities(priority_calculator_); 1348 layer->SetTexturePriorities(priority_calculator_);
1324 resource_manager_->PrioritizeTextures(); 1349 resource_manager_->PrioritizeTextures();
1350 layer->SavePaintProperties();
1325 layer->Update(queue_.get(), &occluded, NULL); 1351 layer->Update(queue_.get(), &occluded, NULL);
1326 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); 1352 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count());
1327 1353
1328 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1354 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1329 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1355 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1330 90000 + 80000, 1356 90000 + 80000,
1331 1); 1357 1);
1332 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1358 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload());
1333 1359
1334 layer->fake_layer_updater()->ClearUpdateCount(); 1360 layer->fake_layer_updater()->ClearUpdateCount();
1335 1361
1336 // This makes sure content scaling and transforms work together. 1362 // This makes sure content scaling and transforms work together.
1337 gfx::Transform screen_transform; 1363 gfx::Transform screen_transform;
1338 screen_transform.Scale(0.5, 0.5); 1364 screen_transform.Scale(0.5, 0.5);
1339 layer->draw_properties().screen_space_transform = screen_transform; 1365 layer->draw_properties().screen_space_transform = screen_transform;
1340 layer->draw_properties().target_space_transform = screen_transform; 1366 layer->draw_properties().target_space_transform = screen_transform;
1341 1367
1342 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 100)); 1368 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 100));
1343 1369
1344 gfx::Rect layer_bounds_rect(layer->bounds()); 1370 gfx::Rect layer_bounds_rect(layer->bounds());
1345 layer->draw_properties().drawable_content_rect = 1371 layer->draw_properties().drawable_content_rect =
1346 gfx::ToEnclosingRect(gfx::ScaleRect(layer_bounds_rect, 0.5)); 1372 gfx::ToEnclosingRect(gfx::ScaleRect(layer_bounds_rect, 0.5));
1347 layer->draw_properties().visible_content_rect = 1373 layer->draw_properties().visible_content_rect =
1348 gfx::Rect(layer->content_bounds()); 1374 gfx::Rect(layer->content_bounds());
1349 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1375 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1350 layer->SetTexturePriorities(priority_calculator_); 1376 layer->SetTexturePriorities(priority_calculator_);
1351 resource_manager_->PrioritizeTextures(); 1377 resource_manager_->PrioritizeTextures();
1378 layer->SavePaintProperties();
1352 layer->Update(queue_.get(), &occluded, NULL); 1379 layer->Update(queue_.get(), &occluded, NULL);
1353 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); 1380 EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count());
1354 1381
1355 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1382 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1356 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1383 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1357 90000 + 80000 + 80000, 1384 90000 + 80000 + 80000,
1358 1); 1385 1);
1359 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1386 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload());
1360 } 1387 }
1361 1388
(...skipping 17 matching lines...) Expand all
1379 CalcDrawProps(layer); 1406 CalcDrawProps(layer);
1380 layer->draw_properties().drawable_content_rect = visible_bounds; 1407 layer->draw_properties().drawable_content_rect = visible_bounds;
1381 layer->draw_properties().visible_content_rect = visible_bounds; 1408 layer->draw_properties().visible_content_rect = visible_bounds;
1382 1409
1383 // If the layer doesn't paint opaque content, then the 1410 // If the layer doesn't paint opaque content, then the
1384 // VisibleContentOpaqueRegion should be empty. 1411 // VisibleContentOpaqueRegion should be empty.
1385 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); 1412 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect());
1386 layer->InvalidateContentRect(content_bounds); 1413 layer->InvalidateContentRect(content_bounds);
1387 layer->SetTexturePriorities(priority_calculator_); 1414 layer->SetTexturePriorities(priority_calculator_);
1388 resource_manager_->PrioritizeTextures(); 1415 resource_manager_->PrioritizeTextures();
1416 layer->SavePaintProperties();
1389 layer->Update(queue_.get(), &occluded, NULL); 1417 layer->Update(queue_.get(), &occluded, NULL);
1390 opaque_contents = layer->VisibleContentOpaqueRegion(); 1418 opaque_contents = layer->VisibleContentOpaqueRegion();
1391 EXPECT_TRUE(opaque_contents.IsEmpty()); 1419 EXPECT_TRUE(opaque_contents.IsEmpty());
1392 1420
1393 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000, 1); 1421 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000, 1);
1394 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1422 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1395 EXPECT_NEAR( 1423 EXPECT_NEAR(
1396 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); 1424 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1);
1397 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1425 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload());
1398 1426
1399 // VisibleContentOpaqueRegion should match the visible part of what is painted 1427 // VisibleContentOpaqueRegion should match the visible part of what is painted
1400 // opaque. 1428 // opaque.
1401 opaque_paint_rect = gfx::Rect(10, 10, 90, 190); 1429 opaque_paint_rect = gfx::Rect(10, 10, 90, 190);
1402 layer->fake_layer_updater()->SetOpaquePaintRect(opaque_paint_rect); 1430 layer->fake_layer_updater()->SetOpaquePaintRect(opaque_paint_rect);
1403 layer->InvalidateContentRect(content_bounds); 1431 layer->InvalidateContentRect(content_bounds);
1404 layer->SetTexturePriorities(priority_calculator_); 1432 layer->SetTexturePriorities(priority_calculator_);
1405 resource_manager_->PrioritizeTextures(); 1433 resource_manager_->PrioritizeTextures();
1434 layer->SavePaintProperties();
1406 layer->Update(queue_.get(), &occluded, NULL); 1435 layer->Update(queue_.get(), &occluded, NULL);
1407 UpdateTextures(); 1436 UpdateTextures();
1408 opaque_contents = layer->VisibleContentOpaqueRegion(); 1437 opaque_contents = layer->VisibleContentOpaqueRegion();
1409 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), 1438 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(),
1410 opaque_contents.ToString()); 1439 opaque_contents.ToString());
1411 1440
1412 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); 1441 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1);
1413 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); 1442 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1);
1414 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1443 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1415 20000 + 20000 - 17100, 1444 20000 + 20000 - 17100,
1416 1); 1445 1);
1417 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1446 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload());
1418 1447
1419 // If we paint again without invalidating, the same stuff should be opaque. 1448 // If we paint again without invalidating, the same stuff should be opaque.
1420 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); 1449 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect());
1421 layer->SetTexturePriorities(priority_calculator_); 1450 layer->SetTexturePriorities(priority_calculator_);
1422 resource_manager_->PrioritizeTextures(); 1451 resource_manager_->PrioritizeTextures();
1452 layer->SavePaintProperties();
1423 layer->Update(queue_.get(), &occluded, NULL); 1453 layer->Update(queue_.get(), &occluded, NULL);
1424 UpdateTextures(); 1454 UpdateTextures();
1425 opaque_contents = layer->VisibleContentOpaqueRegion(); 1455 opaque_contents = layer->VisibleContentOpaqueRegion();
1426 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), 1456 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(),
1427 opaque_contents.ToString()); 1457 opaque_contents.ToString());
1428 1458
1429 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1); 1459 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2, 1);
1430 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); 1460 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1);
1431 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1461 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1432 20000 + 20000 - 17100, 1462 20000 + 20000 - 17100,
1433 1); 1463 1);
1434 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1464 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload());
1435 1465
1436 // If we repaint a non-opaque part of the tile, then it shouldn't lose its 1466 // If we repaint a non-opaque part of the tile, then it shouldn't lose its
1437 // opaque-ness. And other tiles should not be affected. 1467 // opaque-ness. And other tiles should not be affected.
1438 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); 1468 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect());
1439 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); 1469 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1));
1440 layer->SetTexturePriorities(priority_calculator_); 1470 layer->SetTexturePriorities(priority_calculator_);
1441 resource_manager_->PrioritizeTextures(); 1471 resource_manager_->PrioritizeTextures();
1472 layer->SavePaintProperties();
1442 layer->Update(queue_.get(), &occluded, NULL); 1473 layer->Update(queue_.get(), &occluded, NULL);
1443 UpdateTextures(); 1474 UpdateTextures();
1444 opaque_contents = layer->VisibleContentOpaqueRegion(); 1475 opaque_contents = layer->VisibleContentOpaqueRegion();
1445 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), 1476 EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(),
1446 opaque_contents.ToString()); 1477 opaque_contents.ToString());
1447 1478
1448 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1, 1); 1479 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1, 1);
1449 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); 1480 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1);
1450 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(), 1481 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_translucent(),
1451 20000 + 20000 - 17100 + 1, 1482 20000 + 20000 - 17100 + 1,
1452 1); 1483 1);
1453 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1484 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload());
1454 1485
1455 // If we repaint an opaque part of the tile, then it should lose its 1486 // If we repaint an opaque part of the tile, then it should lose its
1456 // opaque-ness. But other tiles should still not be affected. 1487 // opaque-ness. But other tiles should still not be affected.
1457 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); 1488 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect());
1458 layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1)); 1489 layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1));
1459 layer->SetTexturePriorities(priority_calculator_); 1490 layer->SetTexturePriorities(priority_calculator_);
1460 resource_manager_->PrioritizeTextures(); 1491 resource_manager_->PrioritizeTextures();
1492 layer->SavePaintProperties();
1461 layer->Update(queue_.get(), &occluded, NULL); 1493 layer->Update(queue_.get(), &occluded, NULL);
1462 UpdateTextures(); 1494 UpdateTextures();
1463 opaque_contents = layer->VisibleContentOpaqueRegion(); 1495 opaque_contents = layer->VisibleContentOpaqueRegion();
1464 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), 1496 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100),
1465 visible_bounds).ToString(), 1497 visible_bounds).ToString(),
1466 opaque_contents.ToString()); 1498 opaque_contents.ToString());
1467 1499
1468 EXPECT_NEAR( 1500 EXPECT_NEAR(
1469 occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1 + 1, 1); 1501 occluded.overdraw_metrics()->pixels_painted(), 20000 * 2 + 1 + 1, 1);
1470 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1); 1502 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 17100, 1);
(...skipping 18 matching lines...) Expand all
1489 1521
1490 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300); 1522 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300);
1491 layer->SetBounds(content_bounds.size()); 1523 layer->SetBounds(content_bounds.size());
1492 CalcDrawProps(layer); 1524 CalcDrawProps(layer);
1493 1525
1494 // Invalidates and paints the whole layer. 1526 // Invalidates and paints the whole layer.
1495 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); 1527 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect());
1496 layer->InvalidateContentRect(content_bounds); 1528 layer->InvalidateContentRect(content_bounds);
1497 layer->SetTexturePriorities(priority_calculator_); 1529 layer->SetTexturePriorities(priority_calculator_);
1498 resource_manager_->PrioritizeTextures(); 1530 resource_manager_->PrioritizeTextures();
1531 layer->SavePaintProperties();
1499 layer->Update(queue_.get(), &occluded, NULL); 1532 layer->Update(queue_.get(), &occluded, NULL);
1500 UpdateTextures(); 1533 UpdateTextures();
1501 opaque_contents = layer->VisibleContentOpaqueRegion(); 1534 opaque_contents = layer->VisibleContentOpaqueRegion();
1502 EXPECT_TRUE(opaque_contents.IsEmpty()); 1535 EXPECT_TRUE(opaque_contents.IsEmpty());
1503 1536
1504 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000, 1); 1537 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_painted(), 30000, 1);
1505 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); 1538 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1);
1506 EXPECT_NEAR( 1539 EXPECT_NEAR(
1507 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 30000, 1); 1540 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 30000, 1);
1508 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); 1541 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload());
1509 1542
1510 // Invalidates an area on the top and bottom tile, which will cause us to 1543 // Invalidates an area on the top and bottom tile, which will cause us to
1511 // paint the tile in the middle, even though it is not dirty and will not be 1544 // paint the tile in the middle, even though it is not dirty and will not be
1512 // uploaded. 1545 // uploaded.
1513 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); 1546 layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect());
1514 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); 1547 layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1));
1515 layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10)); 1548 layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10));
1516 layer->SetTexturePriorities(priority_calculator_); 1549 layer->SetTexturePriorities(priority_calculator_);
1517 resource_manager_->PrioritizeTextures(); 1550 resource_manager_->PrioritizeTextures();
1551 layer->SavePaintProperties();
1518 layer->Update(queue_.get(), &occluded, NULL); 1552 layer->Update(queue_.get(), &occluded, NULL);
1519 UpdateTextures(); 1553 UpdateTextures();
1520 opaque_contents = layer->VisibleContentOpaqueRegion(); 1554 opaque_contents = layer->VisibleContentOpaqueRegion();
1521 EXPECT_TRUE(opaque_contents.IsEmpty()); 1555 EXPECT_TRUE(opaque_contents.IsEmpty());
1522 1556
1523 // The middle tile was painted even though not invalidated. 1557 // The middle tile was painted even though not invalidated.
1524 EXPECT_NEAR( 1558 EXPECT_NEAR(
1525 occluded.overdraw_metrics()->pixels_painted(), 30000 + 60 * 210, 1); 1559 occluded.overdraw_metrics()->pixels_painted(), 30000 + 60 * 210, 1);
1526 // The pixels uploaded will not include the non-invalidated tile in the 1560 // The pixels uploaded will not include the non-invalidated tile in the
1527 // middle. 1561 // middle.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 layer->SetBounds(layer_rect.size()); 1779 layer->SetBounds(layer_rect.size());
1746 layer->UpdateContentsScale(1.5f); 1780 layer->UpdateContentsScale(1.5f);
1747 1781
1748 gfx::Rect content_rect(0, 0, 45, 47); 1782 gfx::Rect content_rect(0, 0, 45, 47);
1749 EXPECT_EQ(content_rect.size(), layer->content_bounds()); 1783 EXPECT_EQ(content_rect.size(), layer->content_bounds());
1750 layer->draw_properties().visible_content_rect = content_rect; 1784 layer->draw_properties().visible_content_rect = content_rect;
1751 layer->draw_properties().drawable_content_rect = content_rect; 1785 layer->draw_properties().drawable_content_rect = content_rect;
1752 1786
1753 layer->SetTexturePriorities(priority_calculator_); 1787 layer->SetTexturePriorities(priority_calculator_);
1754 resource_manager_->PrioritizeTextures(); 1788 resource_manager_->PrioritizeTextures();
1789 layer->SavePaintProperties();
1755 1790
1756 // Update the whole tile. 1791 // Update the whole tile.
1757 layer->Update(queue_.get(), 0, NULL); 1792 layer->Update(queue_.get(), 0, NULL);
1758 layer->tracking_layer_painter()->ResetPaintedRect(); 1793 layer->tracking_layer_painter()->ResetPaintedRect();
1759 1794
1760 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); 1795 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect());
1761 UpdateTextures(); 1796 UpdateTextures();
1762 1797
1763 // Invalidate the entire layer in content space. When painting, the rect given 1798 // Invalidate the entire layer in content space. When painting, the rect given
1764 // to webkit should match the layer's bounds. 1799 // to webkit should match the layer's bounds.
(...skipping 12 matching lines...) Expand all
1777 layer->SetPosition(layer_rect.origin()); 1812 layer->SetPosition(layer_rect.origin());
1778 layer->SetBounds(layer_rect.size()); 1813 layer->SetBounds(layer_rect.size());
1779 layer->UpdateContentsScale(1.3f); 1814 layer->UpdateContentsScale(1.3f);
1780 1815
1781 gfx::Rect content_rect(layer->content_bounds()); 1816 gfx::Rect content_rect(layer->content_bounds());
1782 layer->draw_properties().visible_content_rect = content_rect; 1817 layer->draw_properties().visible_content_rect = content_rect;
1783 layer->draw_properties().drawable_content_rect = content_rect; 1818 layer->draw_properties().drawable_content_rect = content_rect;
1784 1819
1785 layer->SetTexturePriorities(priority_calculator_); 1820 layer->SetTexturePriorities(priority_calculator_);
1786 resource_manager_->PrioritizeTextures(); 1821 resource_manager_->PrioritizeTextures();
1822 layer->SavePaintProperties();
1787 1823
1788 // Update the whole tile. 1824 // Update the whole tile.
1789 layer->Update(queue_.get(), 0, NULL); 1825 layer->Update(queue_.get(), 0, NULL);
1790 layer->tracking_layer_painter()->ResetPaintedRect(); 1826 layer->tracking_layer_painter()->ResetPaintedRect();
1791 1827
1792 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); 1828 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect());
1793 UpdateTextures(); 1829 UpdateTextures();
1794 1830
1795 // Invalidate the entire layer in layer space. When painting, the rect given 1831 // Invalidate the entire layer in layer space. When painting, the rect given
1796 // to webkit should match the layer's bounds. 1832 // to webkit should match the layer's bounds.
1797 layer->SetNeedsDisplayRect(layer_rect); 1833 layer->SetNeedsDisplayRect(layer_rect);
1798 layer->Update(queue_.get(), 0, NULL); 1834 layer->Update(queue_.get(), 0, NULL);
1799 1835
1800 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); 1836 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect());
1801 } 1837 }
1802 1838
1803 } // namespace 1839 } // namespace
1804 } // namespace cc 1840 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698