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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 3884 matching lines...) Expand 10 before | Expand all | Expand 10 after
3895 } 3895 }
3896 }; 3896 };
3897 3897
3898 TEST_F(OcclusionTrackingPictureLayerImplTest, 3898 TEST_F(OcclusionTrackingPictureLayerImplTest,
3899 OccludedTilesSkippedDuringRasterization) { 3899 OccludedTilesSkippedDuringRasterization) {
3900 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3900 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3901 3901
3902 gfx::Size tile_size(102, 102); 3902 gfx::Size tile_size(102, 102);
3903 gfx::Size layer_bounds(1000, 1000); 3903 gfx::Size layer_bounds(1000, 1000);
3904 gfx::Size viewport_size(500, 500); 3904 gfx::Size viewport_size(500, 500);
3905 gfx::Point occluding_layer_position(310, 0); 3905 gfx::PointF occluding_layer_position(310.f, 0.f);
3906 3906
3907 host_impl_.SetViewportSize(viewport_size); 3907 host_impl_.SetViewportSize(viewport_size);
3908 3908
3909 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3909 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3910 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3910 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
3911 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 3911 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
3912 3912
3913 // No occlusion. 3913 // No occlusion.
3914 int unoccluded_tile_count = 0; 3914 int unoccluded_tile_count = 0;
3915 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( 3915 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3954 3954
3955 bool tile_is_visible = 3955 bool tile_is_visible =
3956 tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); 3956 tile->content_rect().Intersects(pending_layer_->visible_layer_rect());
3957 if (tile_is_visible) 3957 if (tile_is_visible)
3958 unoccluded_tile_count++; 3958 unoccluded_tile_count++;
3959 queue->Pop(); 3959 queue->Pop();
3960 } 3960 }
3961 EXPECT_EQ(20, unoccluded_tile_count); 3961 EXPECT_EQ(20, unoccluded_tile_count);
3962 3962
3963 // Full occlusion. 3963 // Full occlusion.
3964 layer1->SetPosition(gfx::Point(0, 0)); 3964 layer1->SetPosition(gfx::PointF());
vmpstr 2015/09/29 05:04:26 nit: I kind of weakly prefer to have explicit 0, 0
danakj 2015/10/12 17:32:01 PointF() is always 0,0 and I think that is pretty
3965 3965
3966 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); 3966 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200));
3967 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 3967 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
3968 3968
3969 unoccluded_tile_count = 0; 3969 unoccluded_tile_count = 0;
3970 queue.reset(new TilingSetRasterQueueAll( 3970 queue.reset(new TilingSetRasterQueueAll(
3971 pending_layer_->picture_layer_tiling_set(), false)); 3971 pending_layer_->picture_layer_tiling_set(), false));
3972 while (!queue->IsEmpty()) { 3972 while (!queue->IsEmpty()) {
3973 PrioritizedTile prioritized_tile = queue->Top(); 3973 PrioritizedTile prioritized_tile = queue->Top();
3974 Tile* tile = prioritized_tile.tile(); 3974 Tile* tile = prioritized_tile.tile();
3975 3975
3976 EXPECT_FALSE(prioritized_tile.is_occluded()); 3976 EXPECT_FALSE(prioritized_tile.is_occluded());
3977 3977
3978 bool tile_is_visible = 3978 bool tile_is_visible =
3979 tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); 3979 tile->content_rect().Intersects(pending_layer_->visible_layer_rect());
3980 if (tile_is_visible) 3980 if (tile_is_visible)
3981 unoccluded_tile_count++; 3981 unoccluded_tile_count++;
3982 queue->Pop(); 3982 queue->Pop();
3983 } 3983 }
3984 EXPECT_EQ(unoccluded_tile_count, 0); 3984 EXPECT_EQ(unoccluded_tile_count, 0);
3985 } 3985 }
3986 3986
3987 TEST_F(OcclusionTrackingPictureLayerImplTest, 3987 TEST_F(OcclusionTrackingPictureLayerImplTest,
3988 OccludedTilesNotMarkedAsRequired) { 3988 OccludedTilesNotMarkedAsRequired) {
3989 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3989 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3990 3990
3991 gfx::Size tile_size(102, 102); 3991 gfx::Size tile_size(102, 102);
3992 gfx::Size layer_bounds(1000, 1000); 3992 gfx::Size layer_bounds(1000, 1000);
3993 gfx::Size viewport_size(500, 500); 3993 gfx::Size viewport_size(500, 500);
3994 gfx::Point occluding_layer_position(310, 0); 3994 gfx::PointF occluding_layer_position(310.f, 0.f);
3995 3995
3996 host_impl_.SetViewportSize(viewport_size); 3996 host_impl_.SetViewportSize(viewport_size);
3997 3997
3998 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3998 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3999 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3999 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4000 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 4000 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4001 4001
4002 // No occlusion. 4002 // No occlusion.
4003 int occluded_tile_count = 0; 4003 int occluded_tile_count = 0;
4004 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4004 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4059 break; 4059 break;
4060 case 1: 4060 case 1:
4061 EXPECT_EQ(occluded_tile_count, 2); 4061 EXPECT_EQ(occluded_tile_count, 2);
4062 break; 4062 break;
4063 default: 4063 default:
4064 NOTREACHED(); 4064 NOTREACHED();
4065 } 4065 }
4066 } 4066 }
4067 4067
4068 // Full occlusion. 4068 // Full occlusion.
4069 layer1->SetPosition(gfx::PointF(0, 0)); 4069 layer1->SetPosition(gfx::PointF());
4070 4070
4071 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); 4071 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200));
4072 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 4072 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4073 4073
4074 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4074 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4075 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4075 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4076 auto prioritized_tiles = 4076 auto prioritized_tiles =
4077 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 4077 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
4078 4078
4079 occluded_tile_count = 0; 4079 occluded_tile_count = 0;
(...skipping 21 matching lines...) Expand all
4101 } 4101 }
4102 } 4102 }
4103 } 4103 }
4104 4104
4105 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { 4105 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) {
4106 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4106 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4107 4107
4108 gfx::Size tile_size(102, 102); 4108 gfx::Size tile_size(102, 102);
4109 gfx::Size layer_bounds(1000, 1000); 4109 gfx::Size layer_bounds(1000, 1000);
4110 gfx::Size viewport_size(500, 500); 4110 gfx::Size viewport_size(500, 500);
4111 gfx::Point occluding_layer_position(310, 0); 4111 gfx::PointF occluding_layer_position(310.f, 0.f);
4112 4112
4113 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4113 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4114 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4114 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4115 4115
4116 host_impl_.SetViewportSize(viewport_size); 4116 host_impl_.SetViewportSize(viewport_size);
4117 4117
4118 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 4118 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4119 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 4119 ASSERT_TRUE(pending_layer_->CanHaveTilings());
4120 4120
4121 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); 4121 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4173 break; 4173 break;
4174 default: 4174 default:
4175 NOTREACHED(); 4175 NOTREACHED();
4176 } 4176 }
4177 } 4177 }
4178 } 4178 }
4179 4179
4180 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { 4180 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) {
4181 gfx::Size layer_bounds(1000, 1000); 4181 gfx::Size layer_bounds(1000, 1000);
4182 gfx::Size viewport_size(1000, 1000); 4182 gfx::Size viewport_size(1000, 1000);
4183 gfx::Point occluding_layer_position(310, 0); 4183 gfx::PointF occluding_layer_position(310.f, 0.f);
4184 gfx::Rect invalidation_rect(230, 230, 102, 102); 4184 gfx::Rect invalidation_rect(230, 230, 102, 102);
4185 4185
4186 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4186 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4187 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4187 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4188 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 4188 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
4189 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4189 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4190 4190
4191 host_impl_.SetViewportSize(viewport_size); 4191 host_impl_.SetViewportSize(viewport_size);
4192 SetupPendingTree(active_raster_source); 4192 SetupPendingTree(active_raster_source);
4193 4193
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4263 } 4263 }
4264 } 4264 }
4265 4265
4266 TEST_F(OcclusionTrackingPictureLayerImplTest, 4266 TEST_F(OcclusionTrackingPictureLayerImplTest,
4267 OccludedTilesConsideredDuringEviction) { 4267 OccludedTilesConsideredDuringEviction) {
4268 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4268 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4269 4269
4270 gfx::Size tile_size(102, 102); 4270 gfx::Size tile_size(102, 102);
4271 gfx::Size layer_bounds(1000, 1000); 4271 gfx::Size layer_bounds(1000, 1000);
4272 gfx::Size viewport_size(1000, 1000); 4272 gfx::Size viewport_size(1000, 1000);
4273 gfx::Point pending_occluding_layer_position(310, 0); 4273 gfx::PointF pending_occluding_layer_position(310.f, 0.f);
4274 gfx::Point active_occluding_layer_position(0, 310); 4274 gfx::PointF active_occluding_layer_position(0.f, 310.f);
4275 gfx::Rect invalidation_rect(230, 230, 152, 152); 4275 gfx::Rect invalidation_rect(230, 230, 152, 152);
4276 4276
4277 host_impl_.SetViewportSize(viewport_size); 4277 host_impl_.SetViewportSize(viewport_size);
4278 SetInitialDeviceScaleFactor(2.f); 4278 SetInitialDeviceScaleFactor(2.f);
4279 4279
4280 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4280 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4281 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4281 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4282 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 4282 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
4283 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4283 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4284 4284
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4991 // New low res tiling. 4991 // New low res tiling.
4992 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); 4992 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles());
4993 4993
4994 // This tiling will be high res now, it won't contain low res content since it 4994 // This tiling will be high res now, it won't contain low res content since it
4995 // was all destroyed. 4995 // was all destroyed.
4996 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); 4996 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles());
4997 } 4997 }
4998 4998
4999 } // namespace 4999 } // namespace
5000 } // namespace cc 5000 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698