[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #include "cc/trees/layer_tree_host.h" |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 6 | |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 7 | #include <sstream> |
| 8 | |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 9 | #include "base/file_util.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 10 | #include "base/files/file_path.h" |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 11 | #include "base/path_service.h" |
[email protected] | daf079a | 2013-04-17 21:42:40 | [diff] [blame] | 12 | #include "base/strings/string_piece.h" |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 13 | #include "base/time/time.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 14 | #include "cc/layers/content_layer.h" |
| 15 | #include "cc/layers/nine_patch_layer.h" |
| 16 | #include "cc/layers/solid_color_layer.h" |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 17 | #include "cc/layers/texture_layer.h" |
| 18 | #include "cc/resources/texture_mailbox.h" |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 19 | #include "cc/test/fake_content_layer_client.h" |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 20 | #include "cc/test/lap_timer.h" |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 21 | #include "cc/test/layer_tree_json_parser.h" |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 22 | #include "cc/test/layer_tree_test.h" |
[email protected] | 1b901a3 | 2012-12-07 08:52:03 | [diff] [blame] | 23 | #include "cc/test/paths.h" |
[email protected] | d993e03 | 2013-06-07 00:16:16 | [diff] [blame] | 24 | #include "cc/trees/layer_tree_impl.h" |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 25 | #include "testing/perf/perf_test.h" |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 26 | |
| 27 | namespace cc { |
| 28 | namespace { |
| 29 | |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 30 | static const int kTimeLimitMillis = 2000; |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 31 | static const int kWarmupRuns = 5; |
| 32 | static const int kTimeCheckInterval = 10; |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 33 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 34 | class LayerTreeHostPerfTest : public LayerTreeTest { |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 35 | public: |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 36 | LayerTreeHostPerfTest() |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 37 | : draw_timer_(kWarmupRuns, |
| 38 | base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 39 | kTimeCheckInterval), |
| 40 | commit_timer_(0, base::TimeDelta(), 1), |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 41 | full_damage_each_frame_(false), |
| 42 | animation_driven_drawing_(false), |
| 43 | measure_commit_cost_(false) { |
[email protected] | 2384c8a | 2013-03-21 08:35:04 | [diff] [blame] | 44 | fake_content_layer_client_.set_paint_all_opaque(true); |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 45 | } |
| 46 | |
[email protected] | 1673d6e | 2013-10-28 21:51:17 | [diff] [blame] | 47 | virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 48 | settings->throttle_frame_production = false; |
| 49 | } |
| 50 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 51 | virtual void BeginTest() OVERRIDE { |
| 52 | BuildTree(); |
| 53 | PostSetNeedsCommitToMainThread(); |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 54 | } |
| 55 | |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 56 | virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { |
[email protected] | 5f6fe596 | 2014-03-03 21:03:40 | [diff] [blame] | 57 | if (animation_driven_drawing_ && !TestEnded()) { |
[email protected] | 8b9e52b | 2014-01-17 16:35:31 | [diff] [blame] | 58 | layer_tree_host()->SetNeedsAnimate(); |
[email protected] | 5f6fe596 | 2014-03-03 21:03:40 | [diff] [blame] | 59 | layer_tree_host()->SetNextCommitForcesRedraw(); |
| 60 | } |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 64 | if (measure_commit_cost_) |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 65 | commit_timer_.Start(); |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 69 | if (measure_commit_cost_ && draw_timer_.IsWarmedUp()) { |
| 70 | commit_timer_.NextLap(); |
[email protected] | d993e03 | 2013-06-07 00:16:16 | [diff] [blame] | 71 | } |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 72 | } |
| 73 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 74 | virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 75 | if (TestEnded() || CleanUpStarted()) |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 76 | return; |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 77 | draw_timer_.NextLap(); |
| 78 | if (draw_timer_.HasTimeLimitExpired()) { |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 79 | CleanUpAndEndTest(impl); |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 80 | return; |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 81 | } |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 82 | if (!animation_driven_drawing_) |
| 83 | impl->SetNeedsRedraw(); |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 84 | if (full_damage_each_frame_) |
| 85 | impl->SetFullRootLayerDamage(); |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 86 | } |
| 87 | |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 88 | virtual void CleanUpAndEndTest(LayerTreeHostImpl* host_impl) { EndTest(); } |
| 89 | |
| 90 | virtual bool CleanUpStarted() { return false; } |
| 91 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 92 | virtual void BuildTree() {} |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 93 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 94 | virtual void AfterTest() OVERRIDE { |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 95 | CHECK(!test_name_.empty()) << "Must SetTestName() before AfterTest()."; |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 96 | perf_test::PrintResult("layer_tree_host_frame_time", "", test_name_, |
| 97 | 1000 * draw_timer_.MsPerLap(), "us", true); |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 98 | if (measure_commit_cost_) { |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 99 | perf_test::PrintResult("layer_tree_host_commit_time", "", test_name_, |
| 100 | 1000 * commit_timer_.MsPerLap(), "us", true); |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 101 | } |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 102 | } |
| 103 | |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 104 | protected: |
[email protected] | 542ce1a | 2013-08-29 14:25:44 | [diff] [blame] | 105 | LapTimer draw_timer_; |
| 106 | LapTimer commit_timer_; |
| 107 | |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 108 | std::string test_name_; |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 109 | FakeContentLayerClient fake_content_layer_client_; |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 110 | bool full_damage_each_frame_; |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 111 | bool animation_driven_drawing_; |
| 112 | |
| 113 | bool measure_commit_cost_; |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 114 | }; |
| 115 | |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 116 | |
| 117 | class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest { |
| 118 | public: |
| 119 | LayerTreeHostPerfTestJsonReader() |
| 120 | : LayerTreeHostPerfTest() { |
| 121 | } |
| 122 | |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 123 | void SetTestName(const std::string& name) { |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 124 | test_name_ = name; |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | void ReadTestFile(const std::string& name) { |
[email protected] | 6d4b67a | 2013-02-10 04:49:30 | [diff] [blame] | 128 | base::FilePath test_data_dir; |
[email protected] | e51444a | 2013-12-10 23:05:01 | [diff] [blame] | 129 | ASSERT_TRUE(PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)); |
[email protected] | 6d4b67a | 2013-02-10 04:49:30 | [diff] [blame] | 130 | base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); |
[email protected] | 82f84b9 | 2013-08-30 18:23:50 | [diff] [blame] | 131 | ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 132 | } |
| 133 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 134 | virtual void BuildTree() OVERRIDE { |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 135 | gfx::Size viewport = gfx::Size(720, 1038); |
[email protected] | 18ce5970 | 2013-04-09 04:58:40 | [diff] [blame] | 136 | layer_tree_host()->SetViewportSize(viewport); |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 137 | scoped_refptr<Layer> root = ParseTreeFromJson(json_, |
| 138 | &fake_content_layer_client_); |
| 139 | ASSERT_TRUE(root.get()); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 140 | layer_tree_host()->SetRootLayer(root); |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | private: |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 144 | std::string json_; |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 145 | }; |
| 146 | |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 147 | // Simulates a tab switcher scene with two stacks of 10 tabs each. |
| 148 | TEST_F(LayerTreeHostPerfTestJsonReader, TenTenSingleThread) { |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 149 | SetTestName("10_10_single_thread"); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 150 | ReadTestFile("10_10_layer_tree"); |
[email protected] | 2a61ad5 | 2013-05-13 14:01:29 | [diff] [blame] | 151 | RunTest(false, false, false); |
[email protected] | 91cd748 | 2012-11-30 05:51:45 | [diff] [blame] | 152 | } |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 153 | |
[email protected] | c0f7a7f | 2013-10-15 21:33:56 | [diff] [blame] | 154 | TEST_F(LayerTreeHostPerfTestJsonReader, TenTenThreadedImplSide) { |
| 155 | SetTestName("10_10_threaded_impl_side"); |
| 156 | ReadTestFile("10_10_layer_tree"); |
| 157 | RunTestWithImplSidePainting(); |
| 158 | } |
| 159 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 160 | // Simulates a tab switcher scene with two stacks of 10 tabs each. |
| 161 | TEST_F(LayerTreeHostPerfTestJsonReader, |
| 162 | TenTenSingleThread_FullDamageEachFrame) { |
| 163 | full_damage_each_frame_ = true; |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 164 | SetTestName("10_10_single_thread_full_damage_each_frame"); |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 165 | ReadTestFile("10_10_layer_tree"); |
[email protected] | 2a61ad5 | 2013-05-13 14:01:29 | [diff] [blame] | 166 | RunTest(false, false, false); |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 167 | } |
| 168 | |
[email protected] | c0f7a7f | 2013-10-15 21:33:56 | [diff] [blame] | 169 | TEST_F(LayerTreeHostPerfTestJsonReader, |
| 170 | TenTenThreadedImplSide_FullDamageEachFrame) { |
| 171 | full_damage_each_frame_ = true; |
| 172 | SetTestName("10_10_threaded_impl_side_full_damage_each_frame"); |
| 173 | ReadTestFile("10_10_layer_tree"); |
| 174 | RunTestWithImplSidePainting(); |
| 175 | } |
| 176 | |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 177 | // Invalidates a leaf layer in the tree on the main thread after every commit. |
| 178 | class LayerTreeHostPerfTestLeafInvalidates |
| 179 | : public LayerTreeHostPerfTestJsonReader { |
| 180 | public: |
| 181 | virtual void BuildTree() OVERRIDE { |
| 182 | LayerTreeHostPerfTestJsonReader::BuildTree(); |
| 183 | |
| 184 | // Find a leaf layer. |
| 185 | for (layer_to_invalidate_ = layer_tree_host()->root_layer(); |
| 186 | layer_to_invalidate_->children().size(); |
| 187 | layer_to_invalidate_ = layer_to_invalidate_->children()[0]) {} |
| 188 | } |
| 189 | |
| 190 | virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 191 | if (TestEnded()) |
| 192 | return; |
| 193 | |
| 194 | static bool flip = true; |
| 195 | layer_to_invalidate_->SetOpacity(flip ? 1.f : 0.5f); |
| 196 | flip = !flip; |
| 197 | } |
| 198 | |
| 199 | protected: |
| 200 | Layer* layer_to_invalidate_; |
| 201 | }; |
| 202 | |
| 203 | // Simulates a tab switcher scene with two stacks of 10 tabs each. Invalidate a |
| 204 | // property on a leaf layer in the tree every commit. |
| 205 | TEST_F(LayerTreeHostPerfTestLeafInvalidates, TenTenSingleThread) { |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 206 | SetTestName("10_10_single_thread_leaf_invalidates"); |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 207 | ReadTestFile("10_10_layer_tree"); |
| 208 | RunTest(false, false, false); |
| 209 | } |
| 210 | |
[email protected] | c0f7a7f | 2013-10-15 21:33:56 | [diff] [blame] | 211 | TEST_F(LayerTreeHostPerfTestLeafInvalidates, TenTenThreadedImplSide) { |
| 212 | SetTestName("10_10_threaded_impl_side_leaf_invalidates"); |
| 213 | ReadTestFile("10_10_layer_tree"); |
| 214 | RunTestWithImplSidePainting(); |
| 215 | } |
| 216 | |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 217 | // Simulates main-thread scrolling on each frame. |
| 218 | class ScrollingLayerTreePerfTest : public LayerTreeHostPerfTestJsonReader { |
| 219 | public: |
| 220 | ScrollingLayerTreePerfTest() |
| 221 | : LayerTreeHostPerfTestJsonReader() { |
| 222 | } |
| 223 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 224 | virtual void BuildTree() OVERRIDE { |
| 225 | LayerTreeHostPerfTestJsonReader::BuildTree(); |
| 226 | scrollable_ = layer_tree_host()->root_layer()->children()[1]; |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 227 | ASSERT_TRUE(scrollable_.get()); |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 228 | } |
| 229 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 230 | virtual void Layout() OVERRIDE { |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 231 | static const gfx::Vector2d delta = gfx::Vector2d(0, 10); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 232 | scrollable_->SetScrollOffset(scrollable_->scroll_offset() + delta); |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | private: |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 236 | scoped_refptr<Layer> scrollable_; |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 237 | }; |
| 238 | |
[email protected] | c0f7a7f | 2013-10-15 21:33:56 | [diff] [blame] | 239 | TEST_F(ScrollingLayerTreePerfTest, LongScrollablePageSingleThread) { |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 240 | SetTestName("long_scrollable_page"); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 241 | ReadTestFile("long_scrollable_page"); |
[email protected] | 2a61ad5 | 2013-05-13 14:01:29 | [diff] [blame] | 242 | RunTest(false, false, false); |
[email protected] | f8fef2bd | 2013-02-04 23:39:22 | [diff] [blame] | 243 | } |
| 244 | |
[email protected] | c0f7a7f | 2013-10-15 21:33:56 | [diff] [blame] | 245 | TEST_F(ScrollingLayerTreePerfTest, LongScrollablePageThreadedImplSide) { |
| 246 | SetTestName("long_scrollable_page_threaded_impl_side"); |
| 247 | ReadTestFile("long_scrollable_page"); |
| 248 | RunTestWithImplSidePainting(); |
| 249 | } |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 250 | |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 251 | static void EmptyReleaseCallback(uint32 sync_point, bool lost_resource) {} |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 252 | |
| 253 | // Simulates main-thread scrolling on each frame. |
| 254 | class BrowserCompositorInvalidateLayerTreePerfTest |
| 255 | : public LayerTreeHostPerfTestJsonReader { |
| 256 | public: |
| 257 | BrowserCompositorInvalidateLayerTreePerfTest() |
[email protected] | 00c51dc | 2014-03-19 21:16:50 | [diff] [blame] | 258 | : LayerTreeHostPerfTestJsonReader(), |
| 259 | next_sync_point_(1), |
| 260 | clean_up_started_(false) {} |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 261 | |
| 262 | virtual void BuildTree() OVERRIDE { |
| 263 | LayerTreeHostPerfTestJsonReader::BuildTree(); |
| 264 | tab_contents_ = |
| 265 | static_cast<TextureLayer*>( |
| 266 | layer_tree_host()->root_layer()->children()[0]-> |
| 267 | children()[0]-> |
| 268 | children()[0]-> |
| 269 | children()[0].get()); |
| 270 | ASSERT_TRUE(tab_contents_.get()); |
[email protected] | e9b29f1c4 | 2013-12-11 02:14:54 | [diff] [blame] | 271 | } |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 272 | |
[email protected] | e9b29f1c4 | 2013-12-11 02:14:54 | [diff] [blame] | 273 | virtual void WillCommit() OVERRIDE { |
[email protected] | 00c51dc | 2014-03-19 21:16:50 | [diff] [blame] | 274 | if (CleanUpStarted()) |
| 275 | return; |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 276 | gpu::Mailbox gpu_mailbox; |
| 277 | std::ostringstream name_stream; |
| 278 | name_stream << "name" << next_sync_point_; |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 279 | gpu_mailbox.SetName( |
| 280 | reinterpret_cast<const int8*>(name_stream.str().c_str())); |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 281 | scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 282 | base::Bind(&EmptyReleaseCallback)); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 283 | TextureMailbox mailbox(gpu_mailbox, GL_TEXTURE_2D, next_sync_point_); |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 284 | next_sync_point_++; |
| 285 | |
| 286 | tab_contents_->SetTextureMailbox(mailbox, callback.Pass()); |
| 287 | } |
| 288 | |
[email protected] | e9b29f1c4 | 2013-12-11 02:14:54 | [diff] [blame] | 289 | virtual void DidCommit() OVERRIDE { |
| 290 | if (CleanUpStarted()) |
| 291 | return; |
| 292 | layer_tree_host()->SetNeedsCommit(); |
| 293 | } |
| 294 | |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 295 | virtual void CleanUpAndEndTest(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 296 | clean_up_started_ = true; |
| 297 | MainThreadTaskRunner()->PostTask( |
| 298 | FROM_HERE, |
| 299 | base::Bind(&BrowserCompositorInvalidateLayerTreePerfTest:: |
| 300 | CleanUpAndEndTestOnMainThread, |
| 301 | base::Unretained(this))); |
| 302 | } |
| 303 | |
| 304 | void CleanUpAndEndTestOnMainThread() { |
| 305 | tab_contents_->SetTextureMailbox(TextureMailbox(), |
| 306 | scoped_ptr<SingleReleaseCallback>()); |
[email protected] | 00c51dc | 2014-03-19 21:16:50 | [diff] [blame] | 307 | EndTest(); |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | virtual bool CleanUpStarted() OVERRIDE { return clean_up_started_; } |
| 311 | |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 312 | private: |
| 313 | scoped_refptr<TextureLayer> tab_contents_; |
| 314 | unsigned next_sync_point_; |
[email protected] | 6485a30 | 2013-12-10 22:19:17 | [diff] [blame] | 315 | bool clean_up_started_; |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 316 | }; |
| 317 | |
[email protected] | 00c51dc | 2014-03-19 21:16:50 | [diff] [blame] | 318 | TEST_F(BrowserCompositorInvalidateLayerTreePerfTest, DenseBrowserUI) { |
| 319 | measure_commit_cost_ = true; |
[email protected] | 3393fa9 | 2013-10-18 03:37:52 | [diff] [blame] | 320 | SetTestName("dense_layer_tree"); |
| 321 | ReadTestFile("dense_layer_tree"); |
| 322 | RunTestWithImplSidePainting(); |
| 323 | } |
| 324 | |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 325 | // Simulates a page with several large, transformed and animated layers. |
[email protected] | c0f7a7f | 2013-10-15 21:33:56 | [diff] [blame] | 326 | TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreadedImplSide) { |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 327 | animation_driven_drawing_ = true; |
| 328 | measure_commit_cost_ = true; |
[email protected] | ab1555a | 2013-09-04 02:16:16 | [diff] [blame] | 329 | SetTestName("heavy_page"); |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 330 | ReadTestFile("heavy_layer_tree"); |
[email protected] | 2a61ad5 | 2013-05-13 14:01:29 | [diff] [blame] | 331 | RunTestWithImplSidePainting(); |
[email protected] | a49d0f8a | 2013-05-09 23:26:19 | [diff] [blame] | 332 | } |
| 333 | |
[email protected] | ed9b489a | 2012-11-28 22:01:40 | [diff] [blame] | 334 | } // namespace |
| 335 | } // namespace cc |