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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 void ActivateTree() { | 122 void ActivateTree() { |
123 host_impl_.ActivateSyncTree(); | 123 host_impl_.ActivateSyncTree(); |
124 CHECK(!host_impl_.pending_tree()); | 124 CHECK(!host_impl_.pending_tree()); |
125 CHECK(host_impl_.recycle_tree()); | 125 CHECK(host_impl_.recycle_tree()); |
126 old_pending_layer_ = pending_layer_; | 126 old_pending_layer_ = pending_layer_; |
127 pending_layer_ = nullptr; | 127 pending_layer_ = nullptr; |
128 active_layer_ = static_cast<FakePictureLayerImpl*>( | 128 active_layer_ = static_cast<FakePictureLayerImpl*>( |
129 host_impl_.active_tree()->LayerById(id_)); | 129 host_impl_.active_tree()->LayerById(id_)); |
130 | 130 |
131 bool update_lcd_text = false; | 131 host_impl_.active_tree()->UpdateDrawProperties(); |
132 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | |
133 } | 132 } |
134 | 133 |
135 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 134 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
136 const gfx::Size& tile_size, | 135 const gfx::Size& tile_size, |
137 const Region& invalidation) { | 136 const Region& invalidation) { |
138 gfx::Size pile_tile_size(100, 100); | 137 gfx::Size pile_tile_size(100, 100); |
139 | 138 |
140 scoped_refptr<FakePicturePileImpl> pending_pile = | 139 scoped_refptr<FakePicturePileImpl> pending_pile = |
141 FakePicturePileImpl::CreateFilledPile(pile_tile_size, layer_bounds); | 140 FakePicturePileImpl::CreateFilledPile(pile_tile_size, layer_bounds); |
142 scoped_refptr<FakePicturePileImpl> active_pile = | 141 scoped_refptr<FakePicturePileImpl> active_pile = |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 pending_layer->SetContentBounds(raster_source->GetSize()); | 216 pending_layer->SetContentBounds(raster_source->GetSize()); |
218 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); | 217 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); |
219 | 218 |
220 pending_root->AddChild(pending_layer.Pass()); | 219 pending_root->AddChild(pending_layer.Pass()); |
221 pending_tree->SetRootLayer(pending_root.Pass()); | 220 pending_tree->SetRootLayer(pending_root.Pass()); |
222 | 221 |
223 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 222 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
224 host_impl_.pending_tree()->LayerById(id_)); | 223 host_impl_.pending_tree()->LayerById(id_)); |
225 | 224 |
226 // Add tilings/tiles for the layer. | 225 // Add tilings/tiles for the layer. |
227 bool update_lcd_text = false; | 226 host_impl_.pending_tree()->UpdateDrawProperties(); |
228 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
229 } | 227 } |
230 | 228 |
231 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, | 229 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, |
232 float ideal_contents_scale, | 230 float ideal_contents_scale, |
233 float device_scale_factor, | 231 float device_scale_factor, |
234 float page_scale_factor, | 232 float page_scale_factor, |
235 float maximum_animation_contents_scale, | 233 float maximum_animation_contents_scale, |
236 bool animating_transform_to_screen) { | 234 bool animating_transform_to_screen) { |
237 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | 235 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
238 layer->draw_properties().device_scale_factor = device_scale_factor; | 236 layer->draw_properties().device_scale_factor = device_scale_factor; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 gfx::Rect viewport = gfx::Rect(layer_bounds), | 424 gfx::Rect viewport = gfx::Rect(layer_bounds), |
427 viewport_rect_for_tile_priority = gfx::Rect(0, 0, 100, 100); | 425 viewport_rect_for_tile_priority = gfx::Rect(0, 0, 100, 100); |
428 gfx::Transform transform, transform_for_tile_priority; | 426 gfx::Transform transform, transform_for_tile_priority; |
429 | 427 |
430 host_impl_.SetExternalDrawConstraints(transform, | 428 host_impl_.SetExternalDrawConstraints(transform, |
431 viewport, | 429 viewport, |
432 viewport, | 430 viewport, |
433 viewport_rect_for_tile_priority, | 431 viewport_rect_for_tile_priority, |
434 transform_for_tile_priority, | 432 transform_for_tile_priority, |
435 resourceless_software_draw); | 433 resourceless_software_draw); |
436 bool update_lcd_text = false; | 434 host_impl_.active_tree()->UpdateDrawProperties(); |
437 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | |
438 | 435 |
439 gfx::Rect viewport_rect_for_tile_priority_in_view_space = | 436 gfx::Rect viewport_rect_for_tile_priority_in_view_space = |
440 viewport_rect_for_tile_priority; | 437 viewport_rect_for_tile_priority; |
441 | 438 |
442 // Verify the viewport rect for tile priority is used in picture layer tiling. | 439 // Verify the viewport rect for tile priority is used in picture layer tiling. |
443 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 440 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
444 active_layer_->viewport_rect_for_tile_priority_in_content_space()); | 441 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
445 PictureLayerTilingSet* tilings = active_layer_->tilings(); | 442 PictureLayerTilingSet* tilings = active_layer_->tilings(); |
446 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 443 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
447 PictureLayerTiling* tiling = tilings->tiling_at(i); | 444 PictureLayerTiling* tiling = tilings->tiling_at(i); |
(...skipping 13 matching lines...) Expand all Loading... |
461 | 458 |
462 viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); | 459 viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); |
463 transform_for_tile_priority.Translate(100, 100); | 460 transform_for_tile_priority.Translate(100, 100); |
464 transform_for_tile_priority.Rotate(45); | 461 transform_for_tile_priority.Rotate(45); |
465 host_impl_.SetExternalDrawConstraints(transform, | 462 host_impl_.SetExternalDrawConstraints(transform, |
466 viewport, | 463 viewport, |
467 viewport, | 464 viewport, |
468 viewport_rect_for_tile_priority, | 465 viewport_rect_for_tile_priority, |
469 transform_for_tile_priority, | 466 transform_for_tile_priority, |
470 resourceless_software_draw); | 467 resourceless_software_draw); |
471 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | 468 host_impl_.active_tree()->UpdateDrawProperties(); |
472 | 469 |
473 gfx::Transform screen_to_view(gfx::Transform::kSkipInitialization); | 470 gfx::Transform screen_to_view(gfx::Transform::kSkipInitialization); |
474 bool success = transform_for_tile_priority.GetInverse(&screen_to_view); | 471 bool success = transform_for_tile_priority.GetInverse(&screen_to_view); |
475 EXPECT_TRUE(success); | 472 EXPECT_TRUE(success); |
476 | 473 |
477 // Note that we don't clip this to the layer bounds, since it is expected that | 474 // Note that we don't clip this to the layer bounds, since it is expected that |
478 // the rect will sometimes be outside of the layer bounds. If we clip to | 475 // the rect will sometimes be outside of the layer bounds. If we clip to |
479 // bounds, then tile priorities will end up being incorrect in cases of fully | 476 // bounds, then tile priorities will end up being incorrect in cases of fully |
480 // offscreen layer. | 477 // offscreen layer. |
481 viewport_rect_for_tile_priority_in_view_space = | 478 viewport_rect_for_tile_priority_in_view_space = |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 596 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
600 | 597 |
601 bool resourceless_software_draw = false; | 598 bool resourceless_software_draw = false; |
602 gfx::Rect viewport = gfx::Rect(layer_bounds); | 599 gfx::Rect viewport = gfx::Rect(layer_bounds); |
603 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); | 600 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); |
604 gfx::Transform transform, transform_for_tile_priority; | 601 gfx::Transform transform, transform_for_tile_priority; |
605 | 602 |
606 host_impl_.SetExternalDrawConstraints( | 603 host_impl_.SetExternalDrawConstraints( |
607 transform, viewport, viewport, viewport_rect_for_tile_priority, | 604 transform, viewport, viewport, viewport_rect_for_tile_priority, |
608 transform_for_tile_priority, resourceless_software_draw); | 605 transform_for_tile_priority, resourceless_software_draw); |
609 bool update_lcd_text = false; | 606 host_impl_.active_tree()->UpdateDrawProperties(); |
610 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | |
611 | 607 |
612 EXPECT_EQ(viewport_rect_for_tile_priority, | 608 EXPECT_EQ(viewport_rect_for_tile_priority, |
613 active_layer_->viewport_rect_for_tile_priority_in_content_space()); | 609 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
614 | 610 |
615 time_ticks += base::TimeDelta::FromMilliseconds(200); | 611 time_ticks += base::TimeDelta::FromMilliseconds(200); |
616 host_impl_.SetCurrentBeginFrameArgs( | 612 host_impl_.SetCurrentBeginFrameArgs( |
617 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 613 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
618 | 614 |
619 gfx::Rect another_viewport_rect_for_tile_priority(11, 11, 50, 50); | 615 gfx::Rect another_viewport_rect_for_tile_priority(11, 11, 50, 50); |
620 host_impl_.SetExternalDrawConstraints( | 616 host_impl_.SetExternalDrawConstraints( |
621 transform, viewport, viewport, another_viewport_rect_for_tile_priority, | 617 transform, viewport, viewport, another_viewport_rect_for_tile_priority, |
622 transform_for_tile_priority, resourceless_software_draw); | 618 transform_for_tile_priority, resourceless_software_draw); |
623 | 619 |
624 // Didn't call UpdateDrawProperties yet. The viewport rect for tile priority | 620 // Didn't call UpdateDrawProperties yet. The viewport rect for tile priority |
625 // should remain to be the previously cached value. | 621 // should remain to be the previously cached value. |
626 EXPECT_EQ(viewport_rect_for_tile_priority, | 622 EXPECT_EQ(viewport_rect_for_tile_priority, |
627 active_layer_->viewport_rect_for_tile_priority_in_content_space()); | 623 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
628 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | 624 host_impl_.active_tree()->UpdateDrawProperties(); |
629 | 625 |
630 // Now the UpdateDrawProperties is called. The viewport rect for tile | 626 // Now the UpdateDrawProperties is called. The viewport rect for tile |
631 // priority should be the latest value. | 627 // priority should be the latest value. |
632 EXPECT_EQ(another_viewport_rect_for_tile_priority, | 628 EXPECT_EQ(another_viewport_rect_for_tile_priority, |
633 active_layer_->viewport_rect_for_tile_priority_in_content_space()); | 629 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
634 } | 630 } |
635 | 631 |
636 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { | 632 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { |
637 gfx::Size tile_size(100, 100); | 633 gfx::Size tile_size(100, 100); |
638 gfx::Size layer_bounds(400, 400); | 634 gfx::Size layer_bounds(400, 400); |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 host_impl_.pending_tree(), 3, valid_pile); | 1305 host_impl_.pending_tree(), 3, valid_pile); |
1310 mask_ptr->SetBounds(layer_bounds); | 1306 mask_ptr->SetBounds(layer_bounds); |
1311 mask_ptr->SetContentBounds(layer_bounds); | 1307 mask_ptr->SetContentBounds(layer_bounds); |
1312 mask_ptr->SetDrawsContent(true); | 1308 mask_ptr->SetDrawsContent(true); |
1313 pending_layer_->SetMaskLayer(mask_ptr.Pass()); | 1309 pending_layer_->SetMaskLayer(mask_ptr.Pass()); |
1314 pending_layer_->SetHasRenderSurface(true); | 1310 pending_layer_->SetHasRenderSurface(true); |
1315 | 1311 |
1316 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1312 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1317 host_impl_.SetCurrentBeginFrameArgs( | 1313 host_impl_.SetCurrentBeginFrameArgs( |
1318 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1314 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1319 bool update_lcd_text = false; | 1315 host_impl_.pending_tree()->UpdateDrawProperties(); |
1320 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
1321 | 1316 |
1322 FakePictureLayerImpl* pending_mask = | 1317 FakePictureLayerImpl* pending_mask = |
1323 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); | 1318 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
1324 | 1319 |
1325 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); | 1320 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); |
1326 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1321 EXPECT_EQ(1u, pending_mask->num_tilings()); |
1327 | 1322 |
1328 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1323 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1329 pending_mask->HighResTiling()->AllTilesForTesting()); | 1324 pending_mask->HighResTiling()->AllTilesForTesting()); |
1330 | 1325 |
(...skipping 29 matching lines...) Expand all Loading... |
1360 FakePicturePileImpl::CreateFilledPile(tile_size, huge_bounds); | 1355 FakePicturePileImpl::CreateFilledPile(tile_size, huge_bounds); |
1361 | 1356 |
1362 SetupPendingTree(huge_pile); | 1357 SetupPendingTree(huge_pile); |
1363 pending_mask->SetBounds(huge_bounds); | 1358 pending_mask->SetBounds(huge_bounds); |
1364 pending_mask->SetContentBounds(huge_bounds); | 1359 pending_mask->SetContentBounds(huge_bounds); |
1365 pending_mask->SetRasterSourceOnPending(huge_pile, Region()); | 1360 pending_mask->SetRasterSourceOnPending(huge_pile, Region()); |
1366 | 1361 |
1367 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1362 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1368 host_impl_.SetCurrentBeginFrameArgs( | 1363 host_impl_.SetCurrentBeginFrameArgs( |
1369 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1364 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1370 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 1365 host_impl_.pending_tree()->UpdateDrawProperties(); |
1371 | 1366 |
1372 // The mask tiling gets scaled down. | 1367 // The mask tiling gets scaled down. |
1373 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); | 1368 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); |
1374 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1369 EXPECT_EQ(1u, pending_mask->num_tilings()); |
1375 | 1370 |
1376 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1371 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1377 pending_mask->HighResTiling()->AllTilesForTesting()); | 1372 pending_mask->HighResTiling()->AllTilesForTesting()); |
1378 | 1373 |
1379 ActivateTree(); | 1374 ActivateTree(); |
1380 | 1375 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 SetupPendingTree(extra_huge_pile); | 1411 SetupPendingTree(extra_huge_pile); |
1417 pending_mask->SetBounds(extra_huge_bounds); | 1412 pending_mask->SetBounds(extra_huge_bounds); |
1418 pending_mask->SetContentBounds(extra_huge_bounds); | 1413 pending_mask->SetContentBounds(extra_huge_bounds); |
1419 pending_mask->SetRasterSourceOnPending(extra_huge_pile, Region()); | 1414 pending_mask->SetRasterSourceOnPending(extra_huge_pile, Region()); |
1420 | 1415 |
1421 EXPECT_FALSE(pending_mask->CanHaveTilings()); | 1416 EXPECT_FALSE(pending_mask->CanHaveTilings()); |
1422 | 1417 |
1423 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1418 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1424 host_impl_.SetCurrentBeginFrameArgs( | 1419 host_impl_.SetCurrentBeginFrameArgs( |
1425 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1420 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1426 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 1421 host_impl_.pending_tree()->UpdateDrawProperties(); |
1427 | 1422 |
1428 EXPECT_EQ(0u, pending_mask->num_tilings()); | 1423 EXPECT_EQ(0u, pending_mask->num_tilings()); |
1429 } | 1424 } |
1430 | 1425 |
1431 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { | 1426 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { |
1432 base::TimeTicks time_ticks; | 1427 base::TimeTicks time_ticks; |
1433 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1428 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1434 host_impl_.SetCurrentBeginFrameArgs( | 1429 host_impl_.SetCurrentBeginFrameArgs( |
1435 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1430 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1436 | 1431 |
(...skipping 11 matching lines...) Expand all Loading... |
1448 host_impl_.pending_tree(), 3, valid_pile); | 1443 host_impl_.pending_tree(), 3, valid_pile); |
1449 mask_ptr->SetBounds(layer_bounds); | 1444 mask_ptr->SetBounds(layer_bounds); |
1450 mask_ptr->SetContentBounds(layer_bounds); | 1445 mask_ptr->SetContentBounds(layer_bounds); |
1451 mask_ptr->SetDrawsContent(true); | 1446 mask_ptr->SetDrawsContent(true); |
1452 pending_layer_->SetMaskLayer(mask_ptr.Pass()); | 1447 pending_layer_->SetMaskLayer(mask_ptr.Pass()); |
1453 pending_layer_->SetHasRenderSurface(true); | 1448 pending_layer_->SetHasRenderSurface(true); |
1454 | 1449 |
1455 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1450 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1456 host_impl_.SetCurrentBeginFrameArgs( | 1451 host_impl_.SetCurrentBeginFrameArgs( |
1457 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1452 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1458 bool update_lcd_text = false; | 1453 host_impl_.pending_tree()->UpdateDrawProperties(); |
1459 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
1460 | 1454 |
1461 FakePictureLayerImpl* pending_mask = | 1455 FakePictureLayerImpl* pending_mask = |
1462 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); | 1456 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
1463 | 1457 |
1464 // Masks are scaled, and do not have a low res tiling. | 1458 // Masks are scaled, and do not have a low res tiling. |
1465 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); | 1459 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); |
1466 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1460 EXPECT_EQ(1u, pending_mask->num_tilings()); |
1467 | 1461 |
1468 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1462 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1469 pending_mask->HighResTiling()->AllTilesForTesting()); | 1463 pending_mask->HighResTiling()->AllTilesForTesting()); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 bool resourceless_software_draw = false; | 1764 bool resourceless_software_draw = false; |
1771 host_impl_.SetExternalDrawConstraints(transform, | 1765 host_impl_.SetExternalDrawConstraints(transform, |
1772 viewport, | 1766 viewport, |
1773 viewport, | 1767 viewport, |
1774 external_viewport_for_tile_priority, | 1768 external_viewport_for_tile_priority, |
1775 transform_for_tile_priority, | 1769 transform_for_tile_priority, |
1776 resourceless_software_draw); | 1770 resourceless_software_draw); |
1777 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1771 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1778 host_impl_.SetCurrentBeginFrameArgs( | 1772 host_impl_.SetCurrentBeginFrameArgs( |
1779 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1773 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1780 bool update_lcd_text = false; | 1774 host_impl_.pending_tree()->UpdateDrawProperties(); |
1781 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
1782 | 1775 |
1783 // Set visible content rect that is different from | 1776 // Set visible content rect that is different from |
1784 // external_viewport_for_tile_priority. | 1777 // external_viewport_for_tile_priority. |
1785 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; | 1778 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; |
1786 time_ticks += base::TimeDelta::FromMilliseconds(200); | 1779 time_ticks += base::TimeDelta::FromMilliseconds(200); |
1787 host_impl_.SetCurrentBeginFrameArgs( | 1780 host_impl_.SetCurrentBeginFrameArgs( |
1788 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1781 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1789 pending_layer_->UpdateTiles(resourceless_software_draw); | 1782 pending_layer_->UpdateTiles(resourceless_software_draw); |
1790 | 1783 |
1791 // Intersect the two rects. Any tile outside should not be required for | 1784 // Intersect the two rects. Any tile outside should not be required for |
(...skipping 19 matching lines...) Expand all Loading... |
1811 num_outside++; | 1804 num_outside++; |
1812 EXPECT_FALSE(tile->required_for_activation()); | 1805 EXPECT_FALSE(tile->required_for_activation()); |
1813 } | 1806 } |
1814 } | 1807 } |
1815 | 1808 |
1816 EXPECT_GT(num_inside, 0); | 1809 EXPECT_GT(num_inside, 0); |
1817 EXPECT_GT(num_outside, 0); | 1810 EXPECT_GT(num_outside, 0); |
1818 | 1811 |
1819 // Activate and draw active layer. | 1812 // Activate and draw active layer. |
1820 host_impl_.ActivateSyncTree(); | 1813 host_impl_.ActivateSyncTree(); |
1821 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | 1814 host_impl_.active_tree()->UpdateDrawProperties(); |
1822 active_layer_->draw_properties().visible_content_rect = visible_content_rect; | 1815 active_layer_->draw_properties().visible_content_rect = visible_content_rect; |
1823 | 1816 |
1824 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1817 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
1825 AppendQuadsData data; | 1818 AppendQuadsData data; |
1826 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1819 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
1827 active_layer_->AppendQuads(render_pass.get(), &data); | 1820 active_layer_->AppendQuads(render_pass.get(), &data); |
1828 active_layer_->DidDraw(nullptr); | 1821 active_layer_->DidDraw(nullptr); |
1829 | 1822 |
1830 // All tiles in activation rect is ready to draw. | 1823 // All tiles in activation rect is ready to draw. |
1831 EXPECT_EQ(0u, data.num_missing_tiles); | 1824 EXPECT_EQ(0u, data.num_missing_tiles); |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 // Toggling the gpu rasterization clears all tilings on both trees. | 2408 // Toggling the gpu rasterization clears all tilings on both trees. |
2416 host_impl_.SetUseGpuRasterization(true); | 2409 host_impl_.SetUseGpuRasterization(true); |
2417 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2410 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
2418 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 2411 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
2419 | 2412 |
2420 // Make sure that we can still add tiling to the pending layer, | 2413 // Make sure that we can still add tiling to the pending layer, |
2421 // that gets synced to the active layer. | 2414 // that gets synced to the active layer. |
2422 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2415 time_ticks += base::TimeDelta::FromMilliseconds(1); |
2423 host_impl_.SetCurrentBeginFrameArgs( | 2416 host_impl_.SetCurrentBeginFrameArgs( |
2424 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2417 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
2425 bool update_lcd_text = false; | 2418 host_impl_.pending_tree()->UpdateDrawProperties(); |
2426 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
2427 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); | 2419 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); |
2428 | 2420 |
2429 ActivateTree(); | 2421 ActivateTree(); |
2430 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); | 2422 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); |
2431 | 2423 |
2432 SetupPendingTree(pending_pile); | 2424 SetupPendingTree(pending_pile); |
2433 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); | 2425 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); |
2434 | 2426 |
2435 // Toggling the gpu rasterization clears all tilings on both trees. | 2427 // Toggling the gpu rasterization clears all tilings on both trees. |
2436 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 2428 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 | 2589 |
2598 SetupTrees(pending_pile, active_pile); | 2590 SetupTrees(pending_pile, active_pile); |
2599 } | 2591 } |
2600 }; | 2592 }; |
2601 | 2593 |
2602 // This test is really a LayerTreeHostImpl test, in that it makes sure | 2594 // This test is really a LayerTreeHostImpl test, in that it makes sure |
2603 // that trees need update draw properties after deferred initialization. | 2595 // that trees need update draw properties after deferred initialization. |
2604 // However, this is also a regression test for PictureLayerImpl in that | 2596 // However, this is also a regression test for PictureLayerImpl in that |
2605 // not having this update will cause a crash. | 2597 // not having this update will cause a crash. |
2606 TEST_F(DeferredInitPictureLayerImplTest, PreventUpdateTilesDuringLostContext) { | 2598 TEST_F(DeferredInitPictureLayerImplTest, PreventUpdateTilesDuringLostContext) { |
2607 host_impl_.pending_tree()->UpdateDrawProperties(true); | 2599 host_impl_.pending_tree()->UpdateDrawProperties(); |
2608 host_impl_.active_tree()->UpdateDrawProperties(false); | 2600 host_impl_.active_tree()->UpdateDrawProperties(); |
2609 EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); | 2601 EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); |
2610 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | 2602 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
2611 | 2603 |
2612 FakeOutputSurface* fake_output_surface = | 2604 FakeOutputSurface* fake_output_surface = |
2613 static_cast<FakeOutputSurface*>(host_impl_.output_surface()); | 2605 static_cast<FakeOutputSurface*>(host_impl_.output_surface()); |
2614 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( | 2606 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( |
2615 TestContextProvider::Create(), TestContextProvider::Create())); | 2607 TestContextProvider::Create(), TestContextProvider::Create())); |
2616 | 2608 |
2617 // These will crash PictureLayerImpl if this is not true. | 2609 // These will crash PictureLayerImpl if this is not true. |
2618 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 2610 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
2619 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 2611 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
2620 host_impl_.active_tree()->UpdateDrawProperties(false); | 2612 host_impl_.active_tree()->UpdateDrawProperties(); |
2621 } | 2613 } |
2622 | 2614 |
2623 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { | 2615 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { |
2624 gfx::Size viewport_size(1000, 1000); | 2616 gfx::Size viewport_size(1000, 1000); |
2625 host_impl_.SetViewportSize(viewport_size); | 2617 host_impl_.SetViewportSize(viewport_size); |
2626 | 2618 |
2627 gfx::Size layer_bounds(100, 100); | 2619 gfx::Size layer_bounds(100, 100); |
2628 SetupDefaultTrees(layer_bounds); | 2620 SetupDefaultTrees(layer_bounds); |
2629 | 2621 |
2630 float contents_scale = 1.f; | 2622 float contents_scale = 1.f; |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3856 // raster on demand is not allowed and tile is OOM. | 3848 // raster on demand is not allowed and tile is OOM. |
3857 gfx::Size tile_size = host_impl_.settings().default_tile_size; | 3849 gfx::Size tile_size = host_impl_.settings().default_tile_size; |
3858 gfx::Size layer_bounds(1000, 1000); | 3850 gfx::Size layer_bounds(1000, 1000); |
3859 | 3851 |
3860 // Create tiles. | 3852 // Create tiles. |
3861 scoped_refptr<FakePicturePileImpl> pending_pile = | 3853 scoped_refptr<FakePicturePileImpl> pending_pile = |
3862 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3854 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3863 SetupPendingTree(pending_pile); | 3855 SetupPendingTree(pending_pile); |
3864 pending_layer_->SetBounds(layer_bounds); | 3856 pending_layer_->SetBounds(layer_bounds); |
3865 ActivateTree(); | 3857 ActivateTree(); |
3866 bool update_lcd_text = false; | 3858 host_impl_.active_tree()->UpdateDrawProperties(); |
3867 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | |
3868 std::vector<Tile*> tiles = | 3859 std::vector<Tile*> tiles = |
3869 active_layer_->HighResTiling()->AllTilesForTesting(); | 3860 active_layer_->HighResTiling()->AllTilesForTesting(); |
3870 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 3861 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
3871 | 3862 |
3872 // Force tiles after max_tiles to be OOM. TileManager uses | 3863 // Force tiles after max_tiles to be OOM. TileManager uses |
3873 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot | 3864 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot |
3874 // directly set state to host_impl_, so we set policy that would change the | 3865 // directly set state to host_impl_, so we set policy that would change the |
3875 // state. We also need to update tree priority separately. | 3866 // state. We also need to update tree priority separately. |
3876 GlobalStateThatImpactsTilePriority state; | 3867 GlobalStateThatImpactsTilePriority state; |
3877 size_t max_tiles = 1; | 3868 size_t max_tiles = 1; |
(...skipping 29 matching lines...) Expand all Loading... |
3907 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3898 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
3908 public: | 3899 public: |
3909 OcclusionTrackingPictureLayerImplTest() | 3900 OcclusionTrackingPictureLayerImplTest() |
3910 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3901 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
3911 | 3902 |
3912 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3903 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
3913 FakePictureLayerImpl* twin_layer, | 3904 FakePictureLayerImpl* twin_layer, |
3914 WhichTree tree, | 3905 WhichTree tree, |
3915 size_t expected_occluded_tile_count) { | 3906 size_t expected_occluded_tile_count) { |
3916 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 3907 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
3917 for (int priority_count = 0; priority_count <= LAST_TREE_PRIORITY; | 3908 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES; |
3918 ++priority_count) { | 3909 ++priority_count) { |
3919 TreePriority tree_priority = static_cast<TreePriority>(priority_count); | 3910 TreePriority tree_priority = static_cast<TreePriority>(priority_count); |
3920 size_t occluded_tile_count = 0u; | 3911 size_t occluded_tile_count = 0u; |
3921 Tile* last_tile = nullptr; | 3912 Tile* last_tile = nullptr; |
3922 std::set<Tile*> shared_tiles; | 3913 std::set<Tile*> shared_tiles; |
3923 | 3914 |
3924 scoped_ptr<TilingSetEvictionQueue> queue( | 3915 scoped_ptr<TilingSetEvictionQueue> queue( |
3925 new TilingSetEvictionQueue(layer->picture_layer_tiling_set(), | 3916 new TilingSetEvictionQueue(layer->picture_layer_tiling_set(), |
3926 tree_priority, layer && twin_layer)); | 3917 tree_priority, layer && twin_layer)); |
3927 while (!queue->IsEmpty()) { | 3918 while (!queue->IsEmpty()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4008 case SMOOTHNESS_TAKES_PRIORITY: | 3999 case SMOOTHNESS_TAKES_PRIORITY: |
4009 // Shared tiles should be returned only by an active tree | 4000 // Shared tiles should be returned only by an active tree |
4010 // eviction queue. | 4001 // eviction queue. |
4011 EXPECT_EQ(PENDING_TREE, tree); | 4002 EXPECT_EQ(PENDING_TREE, tree); |
4012 break; | 4003 break; |
4013 case NEW_CONTENT_TAKES_PRIORITY: | 4004 case NEW_CONTENT_TAKES_PRIORITY: |
4014 // Shared tiles should be returned only by a pending tree | 4005 // Shared tiles should be returned only by a pending tree |
4015 // eviction queue. | 4006 // eviction queue. |
4016 EXPECT_EQ(ACTIVE_TREE, tree); | 4007 EXPECT_EQ(ACTIVE_TREE, tree); |
4017 break; | 4008 break; |
| 4009 case NUM_TREE_PRIORITIES: |
| 4010 NOTREACHED(); |
| 4011 break; |
4018 } | 4012 } |
4019 } | 4013 } |
4020 queue->Pop(); | 4014 queue->Pop(); |
4021 } | 4015 } |
4022 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count); | 4016 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count); |
4023 } | 4017 } |
4024 } | 4018 } |
4025 }; | 4019 }; |
4026 | 4020 |
4027 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4021 TEST_F(OcclusionTrackingPictureLayerImplTest, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4067 LayerImpl* layer1 = pending_layer_->children()[0]; | 4061 LayerImpl* layer1 = pending_layer_->children()[0]; |
4068 layer1->SetBounds(layer_bounds); | 4062 layer1->SetBounds(layer_bounds); |
4069 layer1->SetContentBounds(layer_bounds); | 4063 layer1->SetContentBounds(layer_bounds); |
4070 layer1->SetDrawsContent(true); | 4064 layer1->SetDrawsContent(true); |
4071 layer1->SetContentsOpaque(true); | 4065 layer1->SetContentsOpaque(true); |
4072 layer1->SetPosition(occluding_layer_position); | 4066 layer1->SetPosition(occluding_layer_position); |
4073 | 4067 |
4074 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4068 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4075 host_impl_.SetCurrentBeginFrameArgs( | 4069 host_impl_.SetCurrentBeginFrameArgs( |
4076 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4070 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4077 bool update_lcd_text = false; | 4071 host_impl_.pending_tree()->UpdateDrawProperties(); |
4078 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
4079 | 4072 |
4080 unoccluded_tile_count = 0; | 4073 unoccluded_tile_count = 0; |
4081 queue.reset(new TilingSetRasterQueueAll( | 4074 queue.reset(new TilingSetRasterQueueAll( |
4082 pending_layer_->picture_layer_tiling_set(), false)); | 4075 pending_layer_->picture_layer_tiling_set(), false)); |
4083 while (!queue->IsEmpty()) { | 4076 while (!queue->IsEmpty()) { |
4084 Tile* tile = queue->Top(); | 4077 Tile* tile = queue->Top(); |
4085 | 4078 |
4086 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4079 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
4087 | 4080 |
4088 bool tile_is_visible = | 4081 bool tile_is_visible = |
4089 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4082 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
4090 if (tile_is_visible) | 4083 if (tile_is_visible) |
4091 unoccluded_tile_count++; | 4084 unoccluded_tile_count++; |
4092 queue->Pop(); | 4085 queue->Pop(); |
4093 } | 4086 } |
4094 EXPECT_EQ(20, unoccluded_tile_count); | 4087 EXPECT_EQ(20, unoccluded_tile_count); |
4095 | 4088 |
4096 // Full occlusion. | 4089 // Full occlusion. |
4097 layer1->SetPosition(gfx::Point(0, 0)); | 4090 layer1->SetPosition(gfx::Point(0, 0)); |
4098 | 4091 |
4099 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4092 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4100 host_impl_.SetCurrentBeginFrameArgs( | 4093 host_impl_.SetCurrentBeginFrameArgs( |
4101 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4094 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4102 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4095 host_impl_.pending_tree()->UpdateDrawProperties(); |
4103 | 4096 |
4104 unoccluded_tile_count = 0; | 4097 unoccluded_tile_count = 0; |
4105 queue.reset(new TilingSetRasterQueueAll( | 4098 queue.reset(new TilingSetRasterQueueAll( |
4106 pending_layer_->picture_layer_tiling_set(), false)); | 4099 pending_layer_->picture_layer_tiling_set(), false)); |
4107 while (!queue->IsEmpty()) { | 4100 while (!queue->IsEmpty()) { |
4108 Tile* tile = queue->Top(); | 4101 Tile* tile = queue->Top(); |
4109 | 4102 |
4110 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4103 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
4111 | 4104 |
4112 bool tile_is_visible = | 4105 bool tile_is_visible = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4166 LayerImpl* layer1 = pending_layer_->children()[0]; | 4159 LayerImpl* layer1 = pending_layer_->children()[0]; |
4167 layer1->SetBounds(layer_bounds); | 4160 layer1->SetBounds(layer_bounds); |
4168 layer1->SetContentBounds(layer_bounds); | 4161 layer1->SetContentBounds(layer_bounds); |
4169 layer1->SetDrawsContent(true); | 4162 layer1->SetDrawsContent(true); |
4170 layer1->SetContentsOpaque(true); | 4163 layer1->SetContentsOpaque(true); |
4171 layer1->SetPosition(occluding_layer_position); | 4164 layer1->SetPosition(occluding_layer_position); |
4172 | 4165 |
4173 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4166 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4174 host_impl_.SetCurrentBeginFrameArgs( | 4167 host_impl_.SetCurrentBeginFrameArgs( |
4175 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4168 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4176 bool update_lcd_text = false; | 4169 host_impl_.pending_tree()->UpdateDrawProperties(); |
4177 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
4178 | 4170 |
4179 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4171 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4180 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4172 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4181 tiling->UpdateAllTilePrioritiesForTesting(); | 4173 tiling->UpdateAllTilePrioritiesForTesting(); |
4182 | 4174 |
4183 occluded_tile_count = 0; | 4175 occluded_tile_count = 0; |
4184 for (PictureLayerTiling::CoverageIterator iter( | 4176 for (PictureLayerTiling::CoverageIterator iter( |
4185 tiling, | 4177 tiling, |
4186 pending_layer_->contents_scale_x(), | 4178 pending_layer_->contents_scale_x(), |
4187 gfx::Rect(layer_bounds)); | 4179 gfx::Rect(layer_bounds)); |
(...skipping 19 matching lines...) Expand all Loading... |
4207 NOTREACHED(); | 4199 NOTREACHED(); |
4208 } | 4200 } |
4209 } | 4201 } |
4210 | 4202 |
4211 // Full occlusion. | 4203 // Full occlusion. |
4212 layer1->SetPosition(gfx::PointF(0, 0)); | 4204 layer1->SetPosition(gfx::PointF(0, 0)); |
4213 | 4205 |
4214 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4206 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4215 host_impl_.SetCurrentBeginFrameArgs( | 4207 host_impl_.SetCurrentBeginFrameArgs( |
4216 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4208 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4217 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4209 host_impl_.pending_tree()->UpdateDrawProperties(); |
4218 | 4210 |
4219 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4211 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4220 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4212 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4221 tiling->UpdateAllTilePrioritiesForTesting(); | 4213 tiling->UpdateAllTilePrioritiesForTesting(); |
4222 | 4214 |
4223 occluded_tile_count = 0; | 4215 occluded_tile_count = 0; |
4224 for (PictureLayerTiling::CoverageIterator iter( | 4216 for (PictureLayerTiling::CoverageIterator iter( |
4225 tiling, | 4217 tiling, |
4226 pending_layer_->contents_scale_x(), | 4218 pending_layer_->contents_scale_x(), |
4227 gfx::Rect(layer_bounds)); | 4219 gfx::Rect(layer_bounds)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4281 pending_layer_->AddTiling(low_res_factor); | 4273 pending_layer_->AddTiling(low_res_factor); |
4282 pending_layer_->AddTiling(0.3f); | 4274 pending_layer_->AddTiling(0.3f); |
4283 pending_layer_->AddTiling(0.7f); | 4275 pending_layer_->AddTiling(0.7f); |
4284 pending_layer_->AddTiling(1.0f); | 4276 pending_layer_->AddTiling(1.0f); |
4285 pending_layer_->AddTiling(2.0f); | 4277 pending_layer_->AddTiling(2.0f); |
4286 | 4278 |
4287 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4279 time_ticks += base::TimeDelta::FromMilliseconds(1); |
4288 host_impl_.SetCurrentBeginFrameArgs( | 4280 host_impl_.SetCurrentBeginFrameArgs( |
4289 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4281 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4290 // UpdateDrawProperties with the occluding layer. | 4282 // UpdateDrawProperties with the occluding layer. |
4291 bool update_lcd_text = false; | 4283 host_impl_.pending_tree()->UpdateDrawProperties(); |
4292 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
4293 | 4284 |
4294 EXPECT_EQ(5u, pending_layer_->num_tilings()); | 4285 EXPECT_EQ(5u, pending_layer_->num_tilings()); |
4295 | 4286 |
4296 int occluded_tile_count = 0; | 4287 int occluded_tile_count = 0; |
4297 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4288 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4298 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4289 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4299 tiling->UpdateAllTilePrioritiesForTesting(); | 4290 tiling->UpdateAllTilePrioritiesForTesting(); |
4300 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4291 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
4301 | 4292 |
4302 occluded_tile_count = 0; | 4293 occluded_tile_count = 0; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4481 pending_occluding_layer->SetContentsOpaque(true); | 4472 pending_occluding_layer->SetContentsOpaque(true); |
4482 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4473 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
4483 | 4474 |
4484 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 4475 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
4485 EXPECT_EQ(2u, active_layer_->num_tilings()); | 4476 EXPECT_EQ(2u, active_layer_->num_tilings()); |
4486 | 4477 |
4487 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4478 time_ticks += base::TimeDelta::FromMilliseconds(1); |
4488 host_impl_.SetCurrentBeginFrameArgs( | 4479 host_impl_.SetCurrentBeginFrameArgs( |
4489 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4480 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4490 // UpdateDrawProperties with the occluding layer. | 4481 // UpdateDrawProperties with the occluding layer. |
4491 bool update_lcd_text = false; | 4482 host_impl_.pending_tree()->UpdateDrawProperties(); |
4492 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | |
4493 | 4483 |
4494 // The expected number of occluded tiles on each of the 2 tilings for each of | 4484 // The expected number of occluded tiles on each of the 2 tilings for each of |
4495 // the 3 tree priorities. | 4485 // the 3 tree priorities. |
4496 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; | 4486 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; |
4497 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; | 4487 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; |
4498 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; | 4488 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; |
4499 | 4489 |
4500 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u}; | 4490 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u}; |
4501 | 4491 |
4502 // Verify number of occluded tiles on the pending layer for each tiling. | 4492 // Verify number of occluded tiles on the pending layer for each tiling. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4673 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4663 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
4674 host->SetRootLayer(layer); | 4664 host->SetRootLayer(layer); |
4675 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4665 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4676 | 4666 |
4677 int frame_number = 0; | 4667 int frame_number = 0; |
4678 | 4668 |
4679 client.set_fill_with_nonsolid_color(!test_for_solid); | 4669 client.set_fill_with_nonsolid_color(!test_for_solid); |
4680 | 4670 |
4681 Region invalidation(layer_rect); | 4671 Region invalidation(layer_rect); |
4682 recording_source->UpdateAndExpandInvalidation( | 4672 recording_source->UpdateAndExpandInvalidation( |
4683 &client, &invalidation, layer_bounds, layer_rect, frame_number++, | 4673 &client, &invalidation, false, layer_bounds, layer_rect, frame_number++, |
4684 RecordingSource::RECORD_NORMALLY); | 4674 RecordingSource::RECORD_NORMALLY); |
4685 | 4675 |
4686 scoped_refptr<RasterSource> pending_raster_source = | 4676 scoped_refptr<RasterSource> pending_raster_source = |
4687 recording_source->CreateRasterSource(true); | 4677 recording_source->CreateRasterSource(); |
4688 | 4678 |
4689 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 4679 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
4690 ActivateTree(); | 4680 ActivateTree(); |
4691 | 4681 |
4692 if (test_for_solid) { | 4682 if (test_for_solid) { |
4693 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4683 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
4694 } else { | 4684 } else { |
4695 ASSERT_TRUE(active_layer_->tilings()); | 4685 ASSERT_TRUE(active_layer_->tilings()); |
4696 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4686 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
4697 std::vector<Tile*> tiles = | 4687 std::vector<Tile*> tiles = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4736 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4726 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
4737 host->SetRootLayer(layer); | 4727 host->SetRootLayer(layer); |
4738 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4728 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4739 | 4729 |
4740 int frame_number = 0; | 4730 int frame_number = 0; |
4741 | 4731 |
4742 client.set_fill_with_nonsolid_color(true); | 4732 client.set_fill_with_nonsolid_color(true); |
4743 | 4733 |
4744 Region invalidation1(layer_rect); | 4734 Region invalidation1(layer_rect); |
4745 recording_source->UpdateAndExpandInvalidation( | 4735 recording_source->UpdateAndExpandInvalidation( |
4746 &client, &invalidation1, layer_bounds, layer_rect, frame_number++, | 4736 &client, &invalidation1, false, layer_bounds, layer_rect, frame_number++, |
4747 RecordingSource::RECORD_NORMALLY); | 4737 RecordingSource::RECORD_NORMALLY); |
4748 | 4738 |
4749 scoped_refptr<RasterSource> raster_source1 = | 4739 scoped_refptr<RasterSource> raster_source1 = |
4750 recording_source->CreateRasterSource(true); | 4740 recording_source->CreateRasterSource(); |
4751 | 4741 |
4752 SetupPendingTree(raster_source1); | 4742 SetupPendingTree(raster_source1); |
4753 ActivateTree(); | 4743 ActivateTree(); |
4754 bool update_lcd_text = false; | 4744 host_impl_.active_tree()->UpdateDrawProperties(); |
4755 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | |
4756 | 4745 |
4757 // We've started with a solid layer that contains some tilings. | 4746 // We've started with a solid layer that contains some tilings. |
4758 ASSERT_TRUE(active_layer_->tilings()); | 4747 ASSERT_TRUE(active_layer_->tilings()); |
4759 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); | 4748 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); |
4760 | 4749 |
4761 client.set_fill_with_nonsolid_color(false); | 4750 client.set_fill_with_nonsolid_color(false); |
4762 | 4751 |
4763 Region invalidation2(layer_rect); | 4752 Region invalidation2(layer_rect); |
4764 recording_source->UpdateAndExpandInvalidation( | 4753 recording_source->UpdateAndExpandInvalidation( |
4765 &client, &invalidation2, layer_bounds, layer_rect, frame_number++, | 4754 &client, &invalidation2, false, layer_bounds, layer_rect, frame_number++, |
4766 RecordingSource::RECORD_NORMALLY); | 4755 RecordingSource::RECORD_NORMALLY); |
4767 | 4756 |
4768 scoped_refptr<RasterSource> raster_source2 = | 4757 scoped_refptr<RasterSource> raster_source2 = |
4769 recording_source->CreateRasterSource(true); | 4758 recording_source->CreateRasterSource(); |
4770 | 4759 |
4771 SetupPendingTree(raster_source2); | 4760 SetupPendingTree(raster_source2); |
4772 ActivateTree(); | 4761 ActivateTree(); |
4773 | 4762 |
4774 // We've switched to a solid color, so we should end up with no tilings. | 4763 // We've switched to a solid color, so we should end up with no tilings. |
4775 ASSERT_TRUE(active_layer_->tilings()); | 4764 ASSERT_TRUE(active_layer_->tilings()); |
4776 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4765 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
4777 } | 4766 } |
4778 | 4767 |
4779 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { | 4768 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4958 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4947 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4959 EXPECT_EQ(result.width(), 448); | 4948 EXPECT_EQ(result.width(), 448); |
4960 EXPECT_EQ(result.height(), 448); | 4949 EXPECT_EQ(result.height(), 448); |
4961 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4950 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4962 EXPECT_EQ(result.width(), 512); | 4951 EXPECT_EQ(result.width(), 512); |
4963 EXPECT_EQ(result.height(), 500 + 2); | 4952 EXPECT_EQ(result.height(), 500 + 2); |
4964 } | 4953 } |
4965 | 4954 |
4966 } // namespace | 4955 } // namespace |
4967 } // namespace cc | 4956 } // namespace cc |
OLD | NEW |