Chromium Code Reviews| 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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1186 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1186 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| 1187 pending_layer_->AddTiling(1.0f); | 1187 pending_layer_->AddTiling(1.0f); |
| 1188 pending_layer_->AddTiling(2.0f); | 1188 pending_layer_->AddTiling(2.0f); |
| 1189 | 1189 |
| 1190 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | 1190 // It should be safe to call this (and MarkVisibleResourcesAsRequired) |
| 1191 // on a layer with no recordings. | 1191 // on a layer with no recordings. |
| 1192 host_impl_.pending_tree()->UpdateDrawProperties(); | 1192 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1193 pending_layer_->MarkVisibleResourcesAsRequired(); | 1193 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1196 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
|
vmpstr
2014/02/03 20:27:24
This change is due to the mark required function n
| |
| 1197 gfx::Size tile_size(100, 100); | 1197 gfx::Size tile_size(100, 100); |
| 1198 gfx::Size layer_bounds(200, 100); | 1198 gfx::Size layer_bounds(200, 200); |
| 1199 | 1199 |
| 1200 scoped_refptr<FakePicturePileImpl> pending_pile = | 1200 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1201 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1201 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1202 SetupPendingTree(pending_pile); | 1202 SetupPendingTree(pending_pile); |
| 1203 | 1203 |
| 1204 pending_layer_->set_fixed_tile_size(tile_size); | 1204 pending_layer_->set_fixed_tile_size(tile_size); |
| 1205 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1205 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| 1206 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1206 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
| 1207 host_impl_.pending_tree()->UpdateDrawProperties(); | 1207 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1208 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); | 1208 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
| 1209 | 1209 |
| 1210 pending_layer_->draw_properties().visible_content_rect = | |
| 1211 gfx::Rect(0, 0, 100, 200); | |
| 1212 | |
| 1210 // Fake set priorities. | 1213 // Fake set priorities. |
| 1211 int tile_count = 0; | |
| 1212 for (PictureLayerTiling::CoverageIterator iter( | 1214 for (PictureLayerTiling::CoverageIterator iter( |
| 1213 tiling, | 1215 tiling, |
| 1214 pending_layer_->contents_scale_x(), | 1216 pending_layer_->contents_scale_x(), |
| 1215 gfx::Rect(pending_layer_->visible_content_rect())); | 1217 gfx::Rect(layer_bounds)); |
| 1216 iter; | 1218 iter; |
| 1217 ++iter) { | 1219 ++iter) { |
| 1218 if (!*iter) | 1220 if (!*iter) |
| 1219 continue; | 1221 continue; |
| 1220 Tile* tile = *iter; | 1222 Tile* tile = *iter; |
| 1221 TilePriority priority; | 1223 TilePriority priority; |
| 1222 priority.resolution = HIGH_RESOLUTION; | 1224 priority.resolution = HIGH_RESOLUTION; |
| 1223 if (++tile_count % 2) { | 1225 gfx::Rect tile_bounds = iter.geometry_rect(); |
| 1224 priority.time_to_visible_in_seconds = 0.f; | 1226 if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) { |
| 1225 priority.distance_to_visible_in_pixels = 0.f; | 1227 priority.priority_bin = TilePriority::NOW; |
| 1228 priority.distance_to_visible = 0.f; | |
| 1226 } else { | 1229 } else { |
| 1227 priority.time_to_visible_in_seconds = 1.f; | 1230 priority.priority_bin = TilePriority::SOON; |
| 1228 priority.distance_to_visible_in_pixels = 1.f; | 1231 priority.distance_to_visible = 1.f; |
| 1229 } | 1232 } |
| 1230 tile->SetPriority(PENDING_TREE, priority); | 1233 tile->SetPriority(PENDING_TREE, priority); |
| 1231 } | 1234 } |
| 1232 | 1235 |
| 1233 pending_layer_->MarkVisibleResourcesAsRequired(); | 1236 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 1234 | 1237 |
| 1235 int num_visible = 0; | 1238 int num_visible = 0; |
| 1236 int num_offscreen = 0; | 1239 int num_offscreen = 0; |
| 1237 | 1240 |
| 1238 for (PictureLayerTiling::CoverageIterator iter( | 1241 for (PictureLayerTiling::CoverageIterator iter( |
| 1239 tiling, | 1242 tiling, |
| 1240 pending_layer_->contents_scale_x(), | 1243 pending_layer_->contents_scale_x(), |
| 1241 gfx::Rect(pending_layer_->visible_content_rect())); | 1244 gfx::Rect(layer_bounds)); |
| 1242 iter; | 1245 iter; |
| 1243 ++iter) { | 1246 ++iter) { |
| 1244 if (!*iter) | 1247 if (!*iter) |
| 1245 continue; | 1248 continue; |
| 1246 const Tile* tile = *iter; | 1249 const Tile* tile = *iter; |
| 1247 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels == 0.f) { | 1250 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
| 1248 EXPECT_TRUE(tile->required_for_activation()); | 1251 EXPECT_TRUE(tile->required_for_activation()); |
| 1249 num_visible++; | 1252 num_visible++; |
| 1250 } else { | 1253 } else { |
| 1251 EXPECT_FALSE(tile->required_for_activation()); | 1254 EXPECT_FALSE(tile->required_for_activation()); |
| 1252 num_offscreen++; | 1255 num_offscreen++; |
| 1253 } | 1256 } |
| 1254 } | 1257 } |
| 1255 | 1258 |
| 1256 EXPECT_GT(num_visible, 0); | 1259 EXPECT_GT(num_visible, 0); |
| 1257 EXPECT_GT(num_offscreen, 0); | 1260 EXPECT_GT(num_offscreen, 0); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1535 TestContextProvider::Create(), NULL)); | 1538 TestContextProvider::Create(), NULL)); |
| 1536 | 1539 |
| 1537 // These will crash PictureLayerImpl if this is not true. | 1540 // These will crash PictureLayerImpl if this is not true. |
| 1538 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 1541 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
| 1539 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 1542 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
| 1540 host_impl_.active_tree()->UpdateDrawProperties(); | 1543 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1541 } | 1544 } |
| 1542 | 1545 |
| 1543 } // namespace | 1546 } // namespace |
| 1544 } // namespace cc | 1547 } // namespace cc |
| OLD | NEW |