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

Side by Side Diff: cc/tiles/tile_manager_unittest.cc

Issue 2084233002: cc: Move LayerImpl::AddChild and RemoveChild to LayerImplTestProperties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « cc/tiles/tile_manager_perftest.cc ('k') | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 SetupDefaultTrees(layer_bounds); 557 SetupDefaultTrees(layer_bounds);
558 558
559 // Create a pending child layer. 559 // Create a pending child layer.
560 scoped_refptr<FakeRasterSource> pending_raster_source = 560 scoped_refptr<FakeRasterSource> pending_raster_source =
561 FakeRasterSource::CreateFilled(layer_bounds); 561 FakeRasterSource::CreateFilled(layer_bounds);
562 std::unique_ptr<FakePictureLayerImpl> pending_child = 562 std::unique_ptr<FakePictureLayerImpl> pending_child =
563 FakePictureLayerImpl::CreateWithRasterSource( 563 FakePictureLayerImpl::CreateWithRasterSource(
564 host_impl()->pending_tree(), layer_id() + 1, pending_raster_source); 564 host_impl()->pending_tree(), layer_id() + 1, pending_raster_source);
565 FakePictureLayerImpl* pending_child_raw = pending_child.get(); 565 FakePictureLayerImpl* pending_child_raw = pending_child.get();
566 pending_child_raw->SetDrawsContent(true); 566 pending_child_raw->SetDrawsContent(true);
567 pending_layer()->AddChild(std::move(pending_child)); 567 pending_layer()->test_properties()->AddChild(std::move(pending_child));
568 568
569 // Set a small viewport, so we have soon and eventually tiles. 569 // Set a small viewport, so we have soon and eventually tiles.
570 host_impl()->SetViewportSize(gfx::Size(200, 200)); 570 host_impl()->SetViewportSize(gfx::Size(200, 200));
571 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 571 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
572 bool update_lcd_text = false; 572 bool update_lcd_text = false;
573 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; 573 host_impl()->pending_tree()->property_trees()->needs_rebuild = true;
574 host_impl()->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 574 host_impl()->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
575 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); 575 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text);
576 576
577 host_impl()->SetRequiresHighResToDraw(); 577 host_impl()->SetRequiresHighResToDraw();
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 host_impl()->SetViewportSize(layer_bounds); 778 host_impl()->SetViewportSize(layer_bounds);
779 779
780 scoped_refptr<FakeRasterSource> pending_raster_source = 780 scoped_refptr<FakeRasterSource> pending_raster_source =
781 FakeRasterSource::CreateFilled(layer_bounds); 781 FakeRasterSource::CreateFilled(layer_bounds);
782 SetupPendingTree(pending_raster_source); 782 SetupPendingTree(pending_raster_source);
783 783
784 std::unique_ptr<FakePictureLayerImpl> pending_child = 784 std::unique_ptr<FakePictureLayerImpl> pending_child =
785 FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(), 785 FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(),
786 2, pending_raster_source); 786 2, pending_raster_source);
787 int child_id = pending_child->id(); 787 int child_id = pending_child->id();
788 pending_layer()->AddChild(std::move(pending_child)); 788 pending_layer()->test_properties()->AddChild(std::move(pending_child));
789 789
790 FakePictureLayerImpl* pending_child_layer = 790 FakePictureLayerImpl* pending_child_layer =
791 static_cast<FakePictureLayerImpl*>( 791 static_cast<FakePictureLayerImpl*>(
792 pending_layer()->test_properties()->children[0]); 792 pending_layer()->test_properties()->children[0]);
793 pending_child_layer->SetDrawsContent(true); 793 pending_child_layer->SetDrawsContent(true);
794 794
795 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 795 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
796 bool update_lcd_text = false; 796 bool update_lcd_text = false;
797 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; 797 host_impl()->pending_tree()->property_trees()->needs_rebuild = true;
798 host_impl()->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 798 host_impl()->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 gfx::Size layer_bounds(1000, 1000); 893 gfx::Size layer_bounds(1000, 1000);
894 894
895 scoped_refptr<FakeRasterSource> pending_raster_source = 895 scoped_refptr<FakeRasterSource> pending_raster_source =
896 FakeRasterSource::CreateFilled(layer_bounds); 896 FakeRasterSource::CreateFilled(layer_bounds);
897 SetupPendingTree(pending_raster_source); 897 SetupPendingTree(pending_raster_source);
898 898
899 std::unique_ptr<FakePictureLayerImpl> pending_child = 899 std::unique_ptr<FakePictureLayerImpl> pending_child =
900 FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(), 900 FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(),
901 2, pending_raster_source); 901 2, pending_raster_source);
902 FakePictureLayerImpl* pending_child_layer = pending_child.get(); 902 FakePictureLayerImpl* pending_child_layer = pending_child.get();
903 pending_layer()->AddChild(std::move(pending_child)); 903 pending_layer()->test_properties()->AddChild(std::move(pending_child));
904 904
905 // Create a fully transparent child layer so that its tile priorities are not 905 // Create a fully transparent child layer so that its tile priorities are not
906 // considered to be valid. 906 // considered to be valid.
907 pending_child_layer->SetDrawsContent(true); 907 pending_child_layer->SetDrawsContent(true);
908 pending_child_layer->test_properties()->force_render_surface = true; 908 pending_child_layer->test_properties()->force_render_surface = true;
909 909
910 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 910 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
911 bool update_lcd_text = false; 911 bool update_lcd_text = false;
912 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; 912 host_impl()->pending_tree()->property_trees()->needs_rebuild = true;
913 host_impl()->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 913 host_impl()->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 996
997 EXPECT_EQ(tile_count, all_tiles.size()); 997 EXPECT_EQ(tile_count, all_tiles.size());
998 EXPECT_EQ(16u, tile_count); 998 EXPECT_EQ(16u, tile_count);
999 999
1000 for (int i = 1; i < 10; ++i) { 1000 for (int i = 1; i < 10; ++i) {
1001 std::unique_ptr<FakePictureLayerImpl> pending_child_layer = 1001 std::unique_ptr<FakePictureLayerImpl> pending_child_layer =
1002 FakePictureLayerImpl::Create(host_impl()->pending_tree(), 1002 FakePictureLayerImpl::Create(host_impl()->pending_tree(),
1003 layer_id() + i); 1003 layer_id() + i);
1004 pending_child_layer->SetDrawsContent(true); 1004 pending_child_layer->SetDrawsContent(true);
1005 pending_child_layer->set_has_valid_tile_priorities(true); 1005 pending_child_layer->set_has_valid_tile_priorities(true);
1006 pending_layer()->AddChild(std::move(pending_child_layer)); 1006 pending_layer()->test_properties()->AddChild(
1007 std::move(pending_child_layer));
1007 } 1008 }
1008 1009
1009 queue = host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, 1010 queue = host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES,
1010 RasterTilePriorityQueue::Type::ALL); 1011 RasterTilePriorityQueue::Type::ALL);
1011 EXPECT_FALSE(queue->IsEmpty()); 1012 EXPECT_FALSE(queue->IsEmpty());
1012 1013
1013 tile_count = 0; 1014 tile_count = 0;
1014 all_tiles.clear(); 1015 all_tiles.clear();
1015 while (!queue->IsEmpty()) { 1016 while (!queue->IsEmpty()) {
1016 EXPECT_TRUE(queue->Top().tile()); 1017 EXPECT_TRUE(queue->Top().tile());
(...skipping 28 matching lines...) Expand all
1045 1046
1046 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); 1047 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end());
1047 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 1048 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
1048 1049
1049 for (int i = 1; i < 10; ++i) { 1050 for (int i = 1; i < 10; ++i) {
1050 std::unique_ptr<FakePictureLayerImpl> pending_child_layer = 1051 std::unique_ptr<FakePictureLayerImpl> pending_child_layer =
1051 FakePictureLayerImpl::Create(host_impl()->pending_tree(), 1052 FakePictureLayerImpl::Create(host_impl()->pending_tree(),
1052 layer_id() + i); 1053 layer_id() + i);
1053 pending_child_layer->SetDrawsContent(true); 1054 pending_child_layer->SetDrawsContent(true);
1054 pending_child_layer->set_has_valid_tile_priorities(true); 1055 pending_child_layer->set_has_valid_tile_priorities(true);
1055 pending_layer()->AddChild(std::move(pending_child_layer)); 1056 pending_layer()->test_properties()->AddChild(
1057 std::move(pending_child_layer));
1056 } 1058 }
1057 1059
1058 std::unique_ptr<EvictionTilePriorityQueue> queue( 1060 std::unique_ptr<EvictionTilePriorityQueue> queue(
1059 host_impl()->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); 1061 host_impl()->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES));
1060 EXPECT_FALSE(queue->IsEmpty()); 1062 EXPECT_FALSE(queue->IsEmpty());
1061 1063
1062 tile_count = 0; 1064 tile_count = 0;
1063 all_tiles.clear(); 1065 all_tiles.clear();
1064 while (!queue->IsEmpty()) { 1066 while (!queue->IsEmpty()) {
1065 EXPECT_TRUE(queue->Top().tile()); 1067 EXPECT_TRUE(queue->Top().tile());
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 } 1886 }
1885 1887
1886 // Ensures that the tile manager does not attempt to reuse tiles when partial 1888 // Ensures that the tile manager does not attempt to reuse tiles when partial
1887 // raster is disabled. 1889 // raster is disabled.
1888 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 1890 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
1889 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); 1891 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */);
1890 } 1892 }
1891 1893
1892 } // namespace 1894 } // namespace
1893 } // namespace cc 1895 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager_perftest.cc ('k') | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698