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