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

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

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 years, 9 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/test/layer_tree_test.cc ('k') | cc/trees/layer_tree_host.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/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/playback/display_list_raster_source.h" 10 #include "cc/playback/display_list_raster_source.h"
11 #include "cc/playback/display_list_recording_source.h" 11 #include "cc/playback/display_list_recording_source.h"
12 #include "cc/raster/raster_buffer.h" 12 #include "cc/raster/raster_buffer.h"
13 #include "cc/resources/resource_pool.h" 13 #include "cc/resources/resource_pool.h"
14 #include "cc/test/begin_frame_args_test.h" 14 #include "cc/test/begin_frame_args_test.h"
15 #include "cc/test/fake_display_list_raster_source.h" 15 #include "cc/test/fake_display_list_raster_source.h"
16 #include "cc/test/fake_display_list_recording_source.h" 16 #include "cc/test/fake_display_list_recording_source.h"
17 #include "cc/test/fake_impl_task_runner_provider.h" 17 #include "cc/test/fake_impl_task_runner_provider.h"
18 #include "cc/test/fake_layer_tree_host_impl.h" 18 #include "cc/test/fake_layer_tree_host_impl.h"
19 #include "cc/test/fake_output_surface.h" 19 #include "cc/test/fake_output_surface.h"
20 #include "cc/test/fake_output_surface_client.h" 20 #include "cc/test/fake_output_surface_client.h"
21 #include "cc/test/fake_picture_layer_impl.h" 21 #include "cc/test/fake_picture_layer_impl.h"
22 #include "cc/test/fake_picture_layer_tiling_client.h" 22 #include "cc/test/fake_picture_layer_tiling_client.h"
23 #include "cc/test/fake_tile_manager.h" 23 #include "cc/test/fake_tile_manager.h"
24 #include "cc/test/layer_tree_settings_for_testing.h"
25 #include "cc/test/test_gpu_memory_buffer_manager.h" 24 #include "cc/test/test_gpu_memory_buffer_manager.h"
26 #include "cc/test/test_shared_bitmap_manager.h" 25 #include "cc/test/test_shared_bitmap_manager.h"
27 #include "cc/test/test_task_graph_runner.h" 26 #include "cc/test/test_task_graph_runner.h"
28 #include "cc/test/test_tile_priorities.h" 27 #include "cc/test/test_tile_priorities.h"
29 #include "cc/tiles/eviction_tile_priority_queue.h" 28 #include "cc/tiles/eviction_tile_priority_queue.h"
30 #include "cc/tiles/raster_tile_priority_queue.h" 29 #include "cc/tiles/raster_tile_priority_queue.h"
31 #include "cc/tiles/tile.h" 30 #include "cc/tiles/tile.h"
32 #include "cc/tiles/tile_priority.h" 31 #include "cc/tiles/tile_priority.h"
33 #include "cc/tiles/tiling_set_raster_queue_all.h" 32 #include "cc/tiles/tiling_set_raster_queue_all.h"
34 #include "cc/trees/layer_tree_impl.h" 33 #include "cc/trees/layer_tree_impl.h"
35 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
36 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
37 #include "third_party/skia/include/core/SkSurface.h" 36 #include "third_party/skia/include/core/SkSurface.h"
38 37
39 namespace cc { 38 namespace cc {
40 namespace { 39 namespace {
41 40
42 class LowResTilingsSettings : public LayerTreeSettingsForTesting { 41 class LowResTilingsSettings : public LayerTreeSettings {
43 public: 42 public:
44 LowResTilingsSettings() { 43 LowResTilingsSettings() {
45 create_low_res_tiling = true; 44 create_low_res_tiling = true;
46 } 45 }
47 }; 46 };
48 47
49 class TileManagerTilePriorityQueueTest : public testing::Test { 48 class TileManagerTilePriorityQueueTest : public testing::Test {
50 public: 49 public:
51 TileManagerTilePriorityQueueTest() 50 TileManagerTilePriorityQueueTest()
52 : memory_limit_policy_(ALLOW_ANYTHING), 51 : memory_limit_policy_(ALLOW_ANYTHING),
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 FakePictureLayerTilingClient client; 1126 FakePictureLayerTilingClient client;
1128 1127
1129 gfx::Rect viewport(50, 50, 500, 500); 1128 gfx::Rect viewport(50, 50, 500, 500);
1130 gfx::Size layer_bounds(1600, 1600); 1129 gfx::Size layer_bounds(1600, 1600);
1131 1130
1132 float inset = PictureLayerTiling::CalculateSoonBorderDistance(viewport, 1.0f); 1131 float inset = PictureLayerTiling::CalculateSoonBorderDistance(viewport, 1.0f);
1133 gfx::Rect soon_rect = viewport; 1132 gfx::Rect soon_rect = viewport;
1134 soon_rect.Inset(-inset, -inset); 1133 soon_rect.Inset(-inset, -inset);
1135 1134
1136 client.SetTileSize(gfx::Size(30, 30)); 1135 client.SetTileSize(gfx::Size(30, 30));
1137 LayerTreeSettingsForTesting settings; 1136 LayerTreeSettings settings;
1138 1137
1139 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( 1138 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create(
1140 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, 1139 ACTIVE_TREE, &client, settings.tiling_interest_area_padding,
1141 settings.skewport_target_time_in_seconds, 1140 settings.skewport_target_time_in_seconds,
1142 settings.skewport_extrapolation_limit_in_content_pixels); 1141 settings.skewport_extrapolation_limit_in_content_pixels);
1143 1142
1144 scoped_refptr<FakeDisplayListRasterSource> raster_source = 1143 scoped_refptr<FakeDisplayListRasterSource> raster_source =
1145 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1144 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1146 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); 1145 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source);
1147 tiling->set_resolution(HIGH_RESOLUTION); 1146 tiling->set_resolution(HIGH_RESOLUTION);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 1235
1237 TEST_F(TileManagerTilePriorityQueueTest, 1236 TEST_F(TileManagerTilePriorityQueueTest,
1238 RasterTilePriorityQueueMovingViewport) { 1237 RasterTilePriorityQueueMovingViewport) {
1239 FakePictureLayerTilingClient client; 1238 FakePictureLayerTilingClient client;
1240 1239
1241 gfx::Rect viewport(50, 0, 100, 100); 1240 gfx::Rect viewport(50, 0, 100, 100);
1242 gfx::Rect moved_viewport(50, 0, 100, 500); 1241 gfx::Rect moved_viewport(50, 0, 100, 500);
1243 gfx::Size layer_bounds(1000, 1000); 1242 gfx::Size layer_bounds(1000, 1000);
1244 1243
1245 client.SetTileSize(gfx::Size(30, 30)); 1244 client.SetTileSize(gfx::Size(30, 30));
1246 LayerTreeSettingsForTesting settings; 1245 LayerTreeSettings settings;
1247 1246
1248 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( 1247 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create(
1249 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, 1248 ACTIVE_TREE, &client, settings.tiling_interest_area_padding,
1250 settings.skewport_target_time_in_seconds, 1249 settings.skewport_target_time_in_seconds,
1251 settings.skewport_extrapolation_limit_in_content_pixels); 1250 settings.skewport_extrapolation_limit_in_content_pixels);
1252 1251
1253 scoped_refptr<FakeDisplayListRasterSource> raster_source = 1252 scoped_refptr<FakeDisplayListRasterSource> raster_source =
1254 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1253 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1255 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); 1254 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source);
1256 tiling->set_resolution(HIGH_RESOLUTION); 1255 tiling->set_resolution(HIGH_RESOLUTION);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 } 1510 }
1512 1511
1513 // TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest. 1512 // TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest.
1514 class TileManagerTest : public testing::Test { 1513 class TileManagerTest : public testing::Test {
1515 public: 1514 public:
1516 TileManagerTest() 1515 TileManagerTest()
1517 : output_surface_(FakeOutputSurface::CreateSoftware( 1516 : output_surface_(FakeOutputSurface::CreateSoftware(
1518 make_scoped_ptr(new SoftwareOutputDevice))) {} 1517 make_scoped_ptr(new SoftwareOutputDevice))) {}
1519 1518
1520 void SetUp() override { 1519 void SetUp() override {
1521 LayerTreeSettingsForTesting settings; 1520 LayerTreeSettings settings;
1522 CustomizeSettings(&settings); 1521 CustomizeSettings(&settings);
1523 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_, 1522 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_,
1524 &shared_bitmap_manager_, 1523 &shared_bitmap_manager_,
1525 &task_graph_runner_)); 1524 &task_graph_runner_));
1526 host_impl_->SetVisible(true); 1525 host_impl_->SetVisible(true);
1527 host_impl_->InitializeRenderer(output_surface_.get()); 1526 host_impl_->InitializeRenderer(output_surface_.get());
1528 } 1527 }
1529 1528
1530 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 1529 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
1531 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1530 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 // Add tilings/tiles for the layer. 1575 // Add tilings/tiles for the layer.
1577 bool update_lcd_text = false; 1576 bool update_lcd_text = false;
1578 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 1577 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
1579 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); 1578 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text);
1580 } 1579 }
1581 1580
1582 protected: 1581 protected:
1583 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. 1582 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks.
1584 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { 1583 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl {
1585 public: 1584 public:
1586 MockLayerTreeHostImpl(const LayerTreeSettingsForTesting& settings, 1585 MockLayerTreeHostImpl(const LayerTreeSettings& settings,
1587 TaskRunnerProvider* task_runner_provider, 1586 TaskRunnerProvider* task_runner_provider,
1588 SharedBitmapManager* manager, 1587 SharedBitmapManager* manager,
1589 TaskGraphRunner* task_graph_runner) 1588 TaskGraphRunner* task_graph_runner)
1590 : FakeLayerTreeHostImpl(settings, 1589 : FakeLayerTreeHostImpl(settings,
1591 task_runner_provider, 1590 task_runner_provider,
1592 manager, 1591 manager,
1593 task_graph_runner) {} 1592 task_graph_runner) {}
1594 1593
1595 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); 1594 MOCK_METHOD0(NotifyAllTileTasksCompleted, void());
1596 }; 1595 };
1597 1596
1598 // By default do no customization. 1597 // By default do no customization.
1599 virtual void CustomizeSettings(LayerTreeSettingsForTesting* settings) {} 1598 virtual void CustomizeSettings(LayerTreeSettings* settings) {}
1600 1599
1601 TestSharedBitmapManager shared_bitmap_manager_; 1600 TestSharedBitmapManager shared_bitmap_manager_;
1602 TestTaskGraphRunner task_graph_runner_; 1601 TestTaskGraphRunner task_graph_runner_;
1603 FakeImplTaskRunnerProvider task_runner_provider_; 1602 FakeImplTaskRunnerProvider task_runner_provider_;
1604 scoped_ptr<OutputSurface> output_surface_; 1603 scoped_ptr<OutputSurface> output_surface_;
1605 scoped_ptr<MockLayerTreeHostImpl> host_impl_; 1604 scoped_ptr<MockLayerTreeHostImpl> host_impl_;
1606 }; 1605 };
1607 1606
1608 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is 1607 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is
1609 // called. 1608 // called.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 // Just call CompleteOnOriginThread on each item in the queue. As none of 1790 // Just call CompleteOnOriginThread on each item in the queue. As none of
1792 // these items have run yet, they will be treated as cancelled tasks. 1791 // these items have run yet, they will be treated as cancelled tasks.
1793 for (const auto& node : graph->nodes) { 1792 for (const auto& node : graph->nodes) {
1794 static_cast<TileTask*>(node.task)->CompleteOnOriginThread(this); 1793 static_cast<TileTask*>(node.task)->CompleteOnOriginThread(this);
1795 } 1794 }
1796 } 1795 }
1797 }; 1796 };
1798 1797
1799 class PartialRasterTileManagerTest : public TileManagerTest { 1798 class PartialRasterTileManagerTest : public TileManagerTest {
1800 public: 1799 public:
1801 void CustomizeSettings(LayerTreeSettingsForTesting* settings) override { 1800 void CustomizeSettings(LayerTreeSettings* settings) override {
1802 settings->use_partial_raster = true; 1801 settings->use_partial_raster = true;
1803 } 1802 }
1804 }; 1803 };
1805 1804
1806 // Ensures that if a raster task is cancelled, it gets returned to the resource 1805 // Ensures that if a raster task is cancelled, it gets returned to the resource
1807 // pool with an invalid content ID, not with its invalidated content ID. 1806 // pool with an invalid content ID, not with its invalidated content ID.
1808 TEST_F(PartialRasterTileManagerTest, CancelledTasksHaveNoContentId) { 1807 TEST_F(PartialRasterTileManagerTest, CancelledTasksHaveNoContentId) {
1809 // Create a CancellingTaskRunner and set it on the tile manager so that all 1808 // Create a CancellingTaskRunner and set it on the tile manager so that all
1810 // scheduled work is immediately cancelled. 1809 // scheduled work is immediately cancelled.
1811 CancellingTileTaskRunner cancelling_runner; 1810 CancellingTileTaskRunner cancelling_runner;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 1953
1955 // Ensures that the tile manager does not attempt to reuse tiles when partial 1954 // Ensures that the tile manager does not attempt to reuse tiles when partial
1956 // raster is disabled. 1955 // raster is disabled.
1957 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 1956 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
1958 RunPartialRasterCheck(std::move(host_impl_), 1957 RunPartialRasterCheck(std::move(host_impl_),
1959 false /* partial_raster_enabled */); 1958 false /* partial_raster_enabled */);
1960 } 1959 }
1961 1960
1962 } // namespace 1961 } // namespace
1963 } // namespace cc 1962 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698