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

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

Issue 913203006: cc: Calculate "can use lcd text" on the compositor thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Param passed to UDP Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
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
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
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
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
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
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
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
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
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
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
4061 LayerImpl* layer1 = pending_layer_->children()[0]; 4070 LayerImpl* layer1 = pending_layer_->children()[0];
4062 layer1->SetBounds(layer_bounds); 4071 layer1->SetBounds(layer_bounds);
4063 layer1->SetContentBounds(layer_bounds); 4072 layer1->SetContentBounds(layer_bounds);
4064 layer1->SetDrawsContent(true); 4073 layer1->SetDrawsContent(true);
4065 layer1->SetContentsOpaque(true); 4074 layer1->SetContentsOpaque(true);
4066 layer1->SetPosition(occluding_layer_position); 4075 layer1->SetPosition(occluding_layer_position);
4067 4076
4068 time_ticks += base::TimeDelta::FromMilliseconds(200); 4077 time_ticks += base::TimeDelta::FromMilliseconds(200);
4069 host_impl_.SetCurrentBeginFrameArgs( 4078 host_impl_.SetCurrentBeginFrameArgs(
4070 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4079 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4071 host_impl_.pending_tree()->UpdateDrawProperties(); 4080 bool update_lcd_text = false;
4081 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4072 4082
4073 unoccluded_tile_count = 0; 4083 unoccluded_tile_count = 0;
4074 queue.reset(new TilingSetRasterQueueAll( 4084 queue.reset(new TilingSetRasterQueueAll(
4075 pending_layer_->picture_layer_tiling_set(), false)); 4085 pending_layer_->picture_layer_tiling_set(), false));
4076 while (!queue->IsEmpty()) { 4086 while (!queue->IsEmpty()) {
4077 Tile* tile = queue->Top(); 4087 Tile* tile = queue->Top();
4078 4088
4079 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 4089 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
4080 4090
4081 bool tile_is_visible = 4091 bool tile_is_visible =
4082 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); 4092 tile->content_rect().Intersects(pending_layer_->visible_content_rect());
4083 if (tile_is_visible) 4093 if (tile_is_visible)
4084 unoccluded_tile_count++; 4094 unoccluded_tile_count++;
4085 queue->Pop(); 4095 queue->Pop();
4086 } 4096 }
4087 EXPECT_EQ(20, unoccluded_tile_count); 4097 EXPECT_EQ(20, unoccluded_tile_count);
4088 4098
4089 // Full occlusion. 4099 // Full occlusion.
4090 layer1->SetPosition(gfx::Point(0, 0)); 4100 layer1->SetPosition(gfx::Point(0, 0));
4091 4101
4092 time_ticks += base::TimeDelta::FromMilliseconds(200); 4102 time_ticks += base::TimeDelta::FromMilliseconds(200);
4093 host_impl_.SetCurrentBeginFrameArgs( 4103 host_impl_.SetCurrentBeginFrameArgs(
4094 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4104 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4095 host_impl_.pending_tree()->UpdateDrawProperties(); 4105 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4096 4106
4097 unoccluded_tile_count = 0; 4107 unoccluded_tile_count = 0;
4098 queue.reset(new TilingSetRasterQueueAll( 4108 queue.reset(new TilingSetRasterQueueAll(
4099 pending_layer_->picture_layer_tiling_set(), false)); 4109 pending_layer_->picture_layer_tiling_set(), false));
4100 while (!queue->IsEmpty()) { 4110 while (!queue->IsEmpty()) {
4101 Tile* tile = queue->Top(); 4111 Tile* tile = queue->Top();
4102 4112
4103 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 4113 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
4104 4114
4105 bool tile_is_visible = 4115 bool tile_is_visible =
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 LayerImpl* layer1 = pending_layer_->children()[0]; 4169 LayerImpl* layer1 = pending_layer_->children()[0];
4160 layer1->SetBounds(layer_bounds); 4170 layer1->SetBounds(layer_bounds);
4161 layer1->SetContentBounds(layer_bounds); 4171 layer1->SetContentBounds(layer_bounds);
4162 layer1->SetDrawsContent(true); 4172 layer1->SetDrawsContent(true);
4163 layer1->SetContentsOpaque(true); 4173 layer1->SetContentsOpaque(true);
4164 layer1->SetPosition(occluding_layer_position); 4174 layer1->SetPosition(occluding_layer_position);
4165 4175
4166 time_ticks += base::TimeDelta::FromMilliseconds(200); 4176 time_ticks += base::TimeDelta::FromMilliseconds(200);
4167 host_impl_.SetCurrentBeginFrameArgs( 4177 host_impl_.SetCurrentBeginFrameArgs(
4168 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4178 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4169 host_impl_.pending_tree()->UpdateDrawProperties(); 4179 bool update_lcd_text = false;
4180 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4170 4181
4171 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4182 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4172 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4183 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4173 tiling->UpdateAllTilePrioritiesForTesting(); 4184 tiling->UpdateAllTilePrioritiesForTesting();
4174 4185
4175 occluded_tile_count = 0; 4186 occluded_tile_count = 0;
4176 for (PictureLayerTiling::CoverageIterator iter( 4187 for (PictureLayerTiling::CoverageIterator iter(
4177 tiling, 4188 tiling,
4178 pending_layer_->contents_scale_x(), 4189 pending_layer_->contents_scale_x(),
4179 gfx::Rect(layer_bounds)); 4190 gfx::Rect(layer_bounds));
(...skipping 19 matching lines...) Expand all
4199 NOTREACHED(); 4210 NOTREACHED();
4200 } 4211 }
4201 } 4212 }
4202 4213
4203 // Full occlusion. 4214 // Full occlusion.
4204 layer1->SetPosition(gfx::PointF(0, 0)); 4215 layer1->SetPosition(gfx::PointF(0, 0));
4205 4216
4206 time_ticks += base::TimeDelta::FromMilliseconds(200); 4217 time_ticks += base::TimeDelta::FromMilliseconds(200);
4207 host_impl_.SetCurrentBeginFrameArgs( 4218 host_impl_.SetCurrentBeginFrameArgs(
4208 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4219 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4209 host_impl_.pending_tree()->UpdateDrawProperties(); 4220 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4210 4221
4211 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4222 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4212 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4223 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4213 tiling->UpdateAllTilePrioritiesForTesting(); 4224 tiling->UpdateAllTilePrioritiesForTesting();
4214 4225
4215 occluded_tile_count = 0; 4226 occluded_tile_count = 0;
4216 for (PictureLayerTiling::CoverageIterator iter( 4227 for (PictureLayerTiling::CoverageIterator iter(
4217 tiling, 4228 tiling,
4218 pending_layer_->contents_scale_x(), 4229 pending_layer_->contents_scale_x(),
4219 gfx::Rect(layer_bounds)); 4230 gfx::Rect(layer_bounds));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4273 pending_layer_->AddTiling(low_res_factor); 4284 pending_layer_->AddTiling(low_res_factor);
4274 pending_layer_->AddTiling(0.3f); 4285 pending_layer_->AddTiling(0.3f);
4275 pending_layer_->AddTiling(0.7f); 4286 pending_layer_->AddTiling(0.7f);
4276 pending_layer_->AddTiling(1.0f); 4287 pending_layer_->AddTiling(1.0f);
4277 pending_layer_->AddTiling(2.0f); 4288 pending_layer_->AddTiling(2.0f);
4278 4289
4279 time_ticks += base::TimeDelta::FromMilliseconds(1); 4290 time_ticks += base::TimeDelta::FromMilliseconds(1);
4280 host_impl_.SetCurrentBeginFrameArgs( 4291 host_impl_.SetCurrentBeginFrameArgs(
4281 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4292 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4282 // UpdateDrawProperties with the occluding layer. 4293 // UpdateDrawProperties with the occluding layer.
4283 host_impl_.pending_tree()->UpdateDrawProperties(); 4294 bool update_lcd_text = false;
4295 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4284 4296
4285 EXPECT_EQ(5u, pending_layer_->num_tilings()); 4297 EXPECT_EQ(5u, pending_layer_->num_tilings());
4286 4298
4287 int occluded_tile_count = 0; 4299 int occluded_tile_count = 0;
4288 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4300 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4289 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4301 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4290 tiling->UpdateAllTilePrioritiesForTesting(); 4302 tiling->UpdateAllTilePrioritiesForTesting();
4291 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 4303 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
4292 4304
4293 occluded_tile_count = 0; 4305 occluded_tile_count = 0;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
4472 pending_occluding_layer->SetContentsOpaque(true); 4484 pending_occluding_layer->SetContentsOpaque(true);
4473 pending_occluding_layer->SetPosition(pending_occluding_layer_position); 4485 pending_occluding_layer->SetPosition(pending_occluding_layer_position);
4474 4486
4475 EXPECT_EQ(2u, pending_layer_->num_tilings()); 4487 EXPECT_EQ(2u, pending_layer_->num_tilings());
4476 EXPECT_EQ(2u, active_layer_->num_tilings()); 4488 EXPECT_EQ(2u, active_layer_->num_tilings());
4477 4489
4478 time_ticks += base::TimeDelta::FromMilliseconds(1); 4490 time_ticks += base::TimeDelta::FromMilliseconds(1);
4479 host_impl_.SetCurrentBeginFrameArgs( 4491 host_impl_.SetCurrentBeginFrameArgs(
4480 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4492 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4481 // UpdateDrawProperties with the occluding layer. 4493 // UpdateDrawProperties with the occluding layer.
4482 host_impl_.pending_tree()->UpdateDrawProperties(); 4494 bool update_lcd_text = false;
4495 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4483 4496
4484 // The expected number of occluded tiles on each of the 2 tilings for each of 4497 // The expected number of occluded tiles on each of the 2 tilings for each of
4485 // the 3 tree priorities. 4498 // the 3 tree priorities.
4486 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; 4499 size_t expected_occluded_tile_count_on_both[] = {9u, 1u};
4487 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; 4500 size_t expected_occluded_tile_count_on_active[] = {30u, 3u};
4488 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; 4501 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u};
4489 4502
4490 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u}; 4503 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u};
4491 4504
4492 // Verify number of occluded tiles on the pending layer for each tiling. 4505 // Verify number of occluded tiles on the pending layer for each tiling.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
4663 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); 4676 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client);
4664 host->SetRootLayer(layer); 4677 host->SetRootLayer(layer);
4665 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); 4678 RecordingSource* recording_source = layer->GetRecordingSourceForTesting();
4666 4679
4667 int frame_number = 0; 4680 int frame_number = 0;
4668 4681
4669 client.set_fill_with_nonsolid_color(!test_for_solid); 4682 client.set_fill_with_nonsolid_color(!test_for_solid);
4670 4683
4671 Region invalidation(layer_rect); 4684 Region invalidation(layer_rect);
4672 recording_source->UpdateAndExpandInvalidation( 4685 recording_source->UpdateAndExpandInvalidation(
4673 &client, &invalidation, false, layer_bounds, layer_rect, frame_number++, 4686 &client, &invalidation, layer_bounds, layer_rect, frame_number++,
4674 RecordingSource::RECORD_NORMALLY); 4687 RecordingSource::RECORD_NORMALLY);
4675 4688
4676 scoped_refptr<RasterSource> pending_raster_source = 4689 scoped_refptr<RasterSource> pending_raster_source =
4677 recording_source->CreateRasterSource(); 4690 recording_source->CreateRasterSource(true);
4678 4691
4679 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 4692 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4680 ActivateTree(); 4693 ActivateTree();
4681 4694
4682 if (test_for_solid) { 4695 if (test_for_solid) {
4683 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4696 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4684 } else { 4697 } else {
4685 ASSERT_TRUE(active_layer_->tilings()); 4698 ASSERT_TRUE(active_layer_->tilings());
4686 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); 4699 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u);
4687 std::vector<Tile*> tiles = 4700 std::vector<Tile*> tiles =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4726 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); 4739 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client);
4727 host->SetRootLayer(layer); 4740 host->SetRootLayer(layer);
4728 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); 4741 RecordingSource* recording_source = layer->GetRecordingSourceForTesting();
4729 4742
4730 int frame_number = 0; 4743 int frame_number = 0;
4731 4744
4732 client.set_fill_with_nonsolid_color(true); 4745 client.set_fill_with_nonsolid_color(true);
4733 4746
4734 Region invalidation1(layer_rect); 4747 Region invalidation1(layer_rect);
4735 recording_source->UpdateAndExpandInvalidation( 4748 recording_source->UpdateAndExpandInvalidation(
4736 &client, &invalidation1, false, layer_bounds, layer_rect, frame_number++, 4749 &client, &invalidation1, layer_bounds, layer_rect, frame_number++,
4737 RecordingSource::RECORD_NORMALLY); 4750 RecordingSource::RECORD_NORMALLY);
4738 4751
4739 scoped_refptr<RasterSource> raster_source1 = 4752 scoped_refptr<RasterSource> raster_source1 =
4740 recording_source->CreateRasterSource(); 4753 recording_source->CreateRasterSource(true);
4741 4754
4742 SetupPendingTree(raster_source1); 4755 SetupPendingTree(raster_source1);
4743 ActivateTree(); 4756 ActivateTree();
4744 host_impl_.active_tree()->UpdateDrawProperties(); 4757 bool update_lcd_text = false;
4758 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
4745 4759
4746 // We've started with a solid layer that contains some tilings. 4760 // We've started with a solid layer that contains some tilings.
4747 ASSERT_TRUE(active_layer_->tilings()); 4761 ASSERT_TRUE(active_layer_->tilings());
4748 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); 4762 EXPECT_NE(0u, active_layer_->tilings()->num_tilings());
4749 4763
4750 client.set_fill_with_nonsolid_color(false); 4764 client.set_fill_with_nonsolid_color(false);
4751 4765
4752 Region invalidation2(layer_rect); 4766 Region invalidation2(layer_rect);
4753 recording_source->UpdateAndExpandInvalidation( 4767 recording_source->UpdateAndExpandInvalidation(
4754 &client, &invalidation2, false, layer_bounds, layer_rect, frame_number++, 4768 &client, &invalidation2, layer_bounds, layer_rect, frame_number++,
4755 RecordingSource::RECORD_NORMALLY); 4769 RecordingSource::RECORD_NORMALLY);
4756 4770
4757 scoped_refptr<RasterSource> raster_source2 = 4771 scoped_refptr<RasterSource> raster_source2 =
4758 recording_source->CreateRasterSource(); 4772 recording_source->CreateRasterSource(true);
4759 4773
4760 SetupPendingTree(raster_source2); 4774 SetupPendingTree(raster_source2);
4761 ActivateTree(); 4775 ActivateTree();
4762 4776
4763 // We've switched to a solid color, so we should end up with no tilings. 4777 // We've switched to a solid color, so we should end up with no tilings.
4764 ASSERT_TRUE(active_layer_->tilings()); 4778 ASSERT_TRUE(active_layer_->tilings());
4765 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4779 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4766 } 4780 }
4767 4781
4768 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { 4782 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
4947 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4961 result = layer->CalculateTileSize(gfx::Size(447, 400));
4948 EXPECT_EQ(result.width(), 448); 4962 EXPECT_EQ(result.width(), 448);
4949 EXPECT_EQ(result.height(), 448); 4963 EXPECT_EQ(result.height(), 448);
4950 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4964 result = layer->CalculateTileSize(gfx::Size(500, 499));
4951 EXPECT_EQ(result.width(), 512); 4965 EXPECT_EQ(result.width(), 512);
4952 EXPECT_EQ(result.height(), 500 + 2); 4966 EXPECT_EQ(result.height(), 500 + 2);
4953 } 4967 }
4954 4968
4955 } // namespace 4969 } // namespace
4956 } // namespace cc 4970 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698