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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 #include "cc/test/fake_picture_layer_tiling_client.h" | 6 #include "cc/test/fake_picture_layer_tiling_client.h" |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "testing/perf/perf_test.h" | 9 #include "testing/perf/perf_test.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 static const int kTimeLimitMillis = 2000; | 15 static const int kTimeLimitMillis = 2000; |
16 static const int kWarmupRuns = 5; | 16 static const int kWarmupRuns = 5; |
17 static const int kTimeCheckInterval = 10; | 17 static const int kTimeCheckInterval = 10; |
18 | 18 |
19 class PictureLayerTilingPerfTest : public testing::Test { | 19 class PictureLayerTilingPerfTest : public testing::Test { |
20 public: | 20 public: |
21 PictureLayerTilingPerfTest() : num_runs_(0) {} | 21 PictureLayerTilingPerfTest() : num_runs_(0) {} |
22 | 22 |
23 virtual void SetUp() OVERRIDE { | 23 virtual void SetUp() OVERRIDE { |
24 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); | 24 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); |
| 25 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); |
25 picture_layer_tiling_ = PictureLayerTiling::Create( | 26 picture_layer_tiling_ = PictureLayerTiling::Create( |
26 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); | 27 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); |
27 picture_layer_tiling_->CreateAllTilesForTesting(); | 28 picture_layer_tiling_->CreateAllTilesForTesting(); |
28 } | 29 } |
29 | 30 |
30 virtual void TearDown() OVERRIDE { | 31 virtual void TearDown() OVERRIDE { |
31 picture_layer_tiling_.reset(NULL); | 32 picture_layer_tiling_.reset(NULL); |
32 } | 33 } |
33 | 34 |
34 void EndTest() { | 35 void EndTest() { |
(...skipping 19 matching lines...) Expand all Loading... |
54 start_time_ = base::TimeTicks(); | 55 start_time_ = base::TimeTicks(); |
55 num_runs_ = 0; | 56 num_runs_ = 0; |
56 do { | 57 do { |
57 picture_layer_tiling_->Invalidate(region); | 58 picture_layer_tiling_->Invalidate(region); |
58 } while (DidRun()); | 59 } while (DidRun()); |
59 | 60 |
60 perf_test::PrintResult("invalidation", "", test_name, | 61 perf_test::PrintResult("invalidation", "", test_name, |
61 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); | 62 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); |
62 } | 63 } |
63 | 64 |
64 void RunUpdateTilePrioritiesStationaryTest( | 65 void RunUpdateTilePrioritiesStationaryTest(const std::string& test_name, |
65 const std::string& test_name, | 66 const gfx::Transform& transform) { |
66 const gfx::Transform& transform) { | |
67 start_time_ = base::TimeTicks(); | 67 start_time_ = base::TimeTicks(); |
68 num_runs_ = 0; | 68 num_runs_ = 0; |
69 | 69 |
70 gfx::Size layer_bounds(50 * 256, 50 * 256); | 70 gfx::Size layer_bounds(50 * 256, 50 * 256); |
| 71 gfx::Rect viewport_rect(0, 0, 1024, 768); |
71 do { | 72 do { |
72 picture_layer_tiling_->UpdateTilePriorities( | 73 picture_layer_tiling_->UpdateTilePriorities( |
73 ACTIVE_TREE, | 74 ACTIVE_TREE, viewport_rect, 1.f, num_runs_ + 1); |
74 layer_bounds, | |
75 gfx::Rect(layer_bounds), | |
76 gfx::Rect(layer_bounds), | |
77 layer_bounds, | |
78 layer_bounds, | |
79 1.f, | |
80 1.f, | |
81 transform, | |
82 transform, | |
83 num_runs_ + 1, | |
84 250); | |
85 } while (DidRun()); | 75 } while (DidRun()); |
86 | 76 |
87 perf_test::PrintResult("update_tile_priorities_stationary", "", test_name, | 77 perf_test::PrintResult("update_tile_priorities_stationary", |
88 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); | 78 "", |
| 79 test_name, |
| 80 num_runs_ / elapsed_.InSecondsF(), |
| 81 "runs/s", |
| 82 true); |
89 } | 83 } |
90 | 84 |
91 void RunUpdateTilePrioritiesScrollingTest( | 85 void RunUpdateTilePrioritiesScrollingTest(const std::string& test_name, |
92 const std::string& test_name, | 86 const gfx::Transform& transform) { |
93 const gfx::Transform& transform) { | |
94 start_time_ = base::TimeTicks(); | 87 start_time_ = base::TimeTicks(); |
95 num_runs_ = 0; | 88 num_runs_ = 0; |
96 | 89 |
97 gfx::Size layer_bounds(50 * 256, 50 * 256); | 90 gfx::Size layer_bounds(50 * 256, 50 * 256); |
98 gfx::Size viewport_size(1024, 768); | 91 gfx::Size viewport_size(1024, 768); |
99 gfx::Rect viewport_rect(viewport_size); | 92 gfx::Rect viewport_rect(viewport_size); |
100 int xoffsets[] = {10, 0, -10, 0}; | 93 int xoffsets[] = {10, 0, -10, 0}; |
101 int yoffsets[] = {0, 10, 0, -10}; | 94 int yoffsets[] = {0, 10, 0, -10}; |
102 int offsetIndex = 0; | 95 int offsetIndex = 0; |
103 int offsetCount = 0; | 96 int offsetCount = 0; |
104 const int maxOffsetCount = 1000; | 97 const int maxOffsetCount = 1000; |
105 do { | 98 do { |
106 picture_layer_tiling_->UpdateTilePriorities( | 99 picture_layer_tiling_->UpdateTilePriorities( |
107 ACTIVE_TREE, | 100 ACTIVE_TREE, viewport_rect, 1.f, num_runs_ + 1); |
108 viewport_size, | |
109 viewport_rect, | |
110 gfx::Rect(layer_bounds), | |
111 layer_bounds, | |
112 layer_bounds, | |
113 1.f, | |
114 1.f, | |
115 transform, | |
116 transform, | |
117 num_runs_ + 1, | |
118 250); | |
119 | 101 |
120 viewport_rect = gfx::Rect( | 102 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], |
121 viewport_rect.x() + xoffsets[offsetIndex], | 103 viewport_rect.y() + yoffsets[offsetIndex], |
122 viewport_rect.y() + yoffsets[offsetIndex], | 104 viewport_rect.width(), |
123 viewport_rect.width(), | 105 viewport_rect.height()); |
124 viewport_rect.height()); | |
125 | 106 |
126 if (++offsetCount > maxOffsetCount) { | 107 if (++offsetCount > maxOffsetCount) { |
127 offsetCount = 0; | 108 offsetCount = 0; |
128 offsetIndex = (offsetIndex + 1) % 4; | 109 offsetIndex = (offsetIndex + 1) % 4; |
129 } | 110 } |
130 } while (DidRun()); | 111 } while (DidRun()); |
131 | 112 |
132 perf_test::PrintResult("update_tile_priorities_scrolling", "", test_name, | 113 perf_test::PrintResult("update_tile_priorities_scrolling", |
133 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); | 114 "", |
| 115 test_name, |
| 116 num_runs_ / elapsed_.InSecondsF(), |
| 117 "runs/s", |
| 118 true); |
134 } | 119 } |
135 | 120 |
136 private: | 121 private: |
137 FakePictureLayerTilingClient picture_layer_tiling_client_; | 122 FakePictureLayerTilingClient picture_layer_tiling_client_; |
138 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; | 123 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; |
139 | 124 |
140 base::TimeTicks start_time_; | 125 base::TimeTicks start_time_; |
141 base::TimeDelta elapsed_; | 126 base::TimeDelta elapsed_; |
142 int num_runs_; | 127 int num_runs_; |
143 }; | 128 }; |
144 | 129 |
145 TEST_F(PictureLayerTilingPerfTest, Invalidate) { | 130 TEST_F(PictureLayerTilingPerfTest, Invalidate) { |
146 Region one_tile(gfx::Rect(256, 256)); | 131 Region one_tile(gfx::Rect(256, 256)); |
147 RunInvalidateTest("1x1", one_tile); | 132 RunInvalidateTest("1x1", one_tile); |
148 | 133 |
149 Region half_region(gfx::Rect(25 * 256, 50 * 256)); | 134 Region half_region(gfx::Rect(25 * 256, 50 * 256)); |
150 RunInvalidateTest("25x50", half_region); | 135 RunInvalidateTest("25x50", half_region); |
151 | 136 |
152 Region full_region(gfx::Rect(50 * 256, 50 * 256)); | 137 Region full_region(gfx::Rect(50 * 256, 50 * 256)); |
153 RunInvalidateTest("50x50", full_region); | 138 RunInvalidateTest("50x50", full_region); |
154 } | 139 } |
155 | 140 |
156 #if defined(OS_ANDROID) | 141 #if defined(OS_ANDROID) |
157 // TODO(vmpstr): Investigate why this is noisy (crbug.com/310220). | 142 // TODO(vmpstr): Investigate why this is noisy (crbug.com/310220). |
158 TEST_F(PictureLayerTilingPerfTest, DISABLED_UpdateTilePriorities) { | 143 TEST_F(PictureLayerTilingPerfTest, DISABLED_UpdateTilePriorities) { |
159 #else | 144 #else |
160 TEST_F(PictureLayerTilingPerfTest, UpdateTilePriorities) { | 145 TEST_F(PictureLayerTilingPerfTest, UpdateTilePriorities) { |
161 #endif // defined(OS_ANDROID) | 146 #endif // defined(OS_ANDROID) |
162 gfx::Transform transform; | 147 gfx::Transform transform; |
| 148 |
163 RunUpdateTilePrioritiesStationaryTest("no_transform", transform); | 149 RunUpdateTilePrioritiesStationaryTest("no_transform", transform); |
164 RunUpdateTilePrioritiesScrollingTest("no_transform", transform); | 150 RunUpdateTilePrioritiesScrollingTest("no_transform", transform); |
165 | 151 |
166 transform.Rotate(10); | 152 transform.Rotate(10); |
167 RunUpdateTilePrioritiesStationaryTest("rotation", transform); | 153 RunUpdateTilePrioritiesStationaryTest("rotation", transform); |
168 RunUpdateTilePrioritiesScrollingTest("rotation", transform); | 154 RunUpdateTilePrioritiesScrollingTest("rotation", transform); |
169 | 155 |
170 transform.ApplyPerspectiveDepth(10); | 156 transform.ApplyPerspectiveDepth(10); |
171 RunUpdateTilePrioritiesStationaryTest("perspective", transform); | 157 RunUpdateTilePrioritiesStationaryTest("perspective", transform); |
172 RunUpdateTilePrioritiesScrollingTest("perspective", transform); | 158 RunUpdateTilePrioritiesScrollingTest("perspective", transform); |
173 } | 159 } |
174 | 160 |
175 } // namespace | 161 } // namespace |
176 | 162 |
177 } // namespace cc | 163 } // namespace cc |
OLD | NEW |