OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 pending_layer_->AddTiling(2.0f); | 1189 pending_layer_->AddTiling(2.0f); |
1190 | 1190 |
1191 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | 1191 // It should be safe to call this (and MarkVisibleResourcesAsRequired) |
1192 // on a layer with no recordings. | 1192 // on a layer with no recordings. |
1193 host_impl_.pending_tree()->UpdateDrawProperties(); | 1193 host_impl_.pending_tree()->UpdateDrawProperties(); |
1194 pending_layer_->MarkVisibleResourcesAsRequired(); | 1194 pending_layer_->MarkVisibleResourcesAsRequired(); |
1195 } | 1195 } |
1196 | 1196 |
1197 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1197 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
1198 gfx::Size tile_size(100, 100); | 1198 gfx::Size tile_size(100, 100); |
1199 gfx::Size layer_bounds(200, 100); | 1199 gfx::Size layer_bounds(200, 200); |
1200 | 1200 |
1201 scoped_refptr<FakePicturePileImpl> pending_pile = | 1201 scoped_refptr<FakePicturePileImpl> pending_pile = |
1202 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1202 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1203 SetupPendingTree(pending_pile); | 1203 SetupPendingTree(pending_pile); |
1204 | 1204 |
1205 pending_layer_->set_fixed_tile_size(tile_size); | 1205 pending_layer_->set_fixed_tile_size(tile_size); |
1206 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1206 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
1207 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1207 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
1208 host_impl_.pending_tree()->UpdateDrawProperties(); | 1208 host_impl_.pending_tree()->UpdateDrawProperties(); |
1209 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); | 1209 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
1210 | 1210 |
| 1211 pending_layer_->draw_properties().visible_content_rect = |
| 1212 gfx::Rect(0, 0, 100, 200); |
| 1213 |
1211 // Fake set priorities. | 1214 // Fake set priorities. |
1212 int tile_count = 0; | |
1213 for (PictureLayerTiling::CoverageIterator iter( | 1215 for (PictureLayerTiling::CoverageIterator iter( |
1214 tiling, | 1216 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
1215 pending_layer_->contents_scale_x(), | |
1216 gfx::Rect(pending_layer_->visible_content_rect())); | |
1217 iter; | 1217 iter; |
1218 ++iter) { | 1218 ++iter) { |
1219 if (!*iter) | 1219 if (!*iter) |
1220 continue; | 1220 continue; |
1221 Tile* tile = *iter; | 1221 Tile* tile = *iter; |
1222 TilePriority priority; | 1222 TilePriority priority; |
1223 priority.resolution = HIGH_RESOLUTION; | 1223 priority.resolution = HIGH_RESOLUTION; |
1224 if (++tile_count % 2) { | 1224 gfx::Rect tile_bounds = iter.geometry_rect(); |
1225 priority.time_to_visible_in_seconds = 0.f; | 1225 if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) { |
1226 priority.distance_to_visible_in_pixels = 0.f; | 1226 priority.priority_bin = TilePriority::NOW; |
| 1227 priority.distance_to_visible = 0.f; |
1227 } else { | 1228 } else { |
1228 priority.time_to_visible_in_seconds = 1.f; | 1229 priority.priority_bin = TilePriority::SOON; |
1229 priority.distance_to_visible_in_pixels = 1.f; | 1230 priority.distance_to_visible = 1.f; |
1230 } | 1231 } |
1231 tile->SetPriority(PENDING_TREE, priority); | 1232 tile->SetPriority(PENDING_TREE, priority); |
1232 } | 1233 } |
1233 | 1234 |
1234 pending_layer_->MarkVisibleResourcesAsRequired(); | 1235 pending_layer_->MarkVisibleResourcesAsRequired(); |
1235 | 1236 |
1236 int num_visible = 0; | 1237 int num_visible = 0; |
1237 int num_offscreen = 0; | 1238 int num_offscreen = 0; |
1238 | 1239 |
1239 for (PictureLayerTiling::CoverageIterator iter( | 1240 for (PictureLayerTiling::CoverageIterator iter( |
1240 tiling, | 1241 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
1241 pending_layer_->contents_scale_x(), | |
1242 gfx::Rect(pending_layer_->visible_content_rect())); | |
1243 iter; | 1242 iter; |
1244 ++iter) { | 1243 ++iter) { |
1245 if (!*iter) | 1244 if (!*iter) |
1246 continue; | 1245 continue; |
1247 const Tile* tile = *iter; | 1246 const Tile* tile = *iter; |
1248 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels == 0.f) { | 1247 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
1249 EXPECT_TRUE(tile->required_for_activation()); | 1248 EXPECT_TRUE(tile->required_for_activation()); |
1250 num_visible++; | 1249 num_visible++; |
1251 } else { | 1250 } else { |
1252 EXPECT_FALSE(tile->required_for_activation()); | 1251 EXPECT_FALSE(tile->required_for_activation()); |
1253 num_offscreen++; | 1252 num_offscreen++; |
1254 } | 1253 } |
1255 } | 1254 } |
1256 | 1255 |
1257 EXPECT_GT(num_visible, 0); | 1256 EXPECT_GT(num_visible, 0); |
1258 EXPECT_GT(num_offscreen, 0); | 1257 EXPECT_GT(num_offscreen, 0); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 TestContextProvider::Create(), NULL)); | 1558 TestContextProvider::Create(), NULL)); |
1560 | 1559 |
1561 // These will crash PictureLayerImpl if this is not true. | 1560 // These will crash PictureLayerImpl if this is not true. |
1562 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 1561 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
1563 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 1562 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
1564 host_impl_.active_tree()->UpdateDrawProperties(); | 1563 host_impl_.active_tree()->UpdateDrawProperties(); |
1565 } | 1564 } |
1566 | 1565 |
1567 } // namespace | 1566 } // namespace |
1568 } // namespace cc | 1567 } // namespace cc |
OLD | NEW |