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

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

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

Powered by Google App Engine
This is Rietveld 408576698