OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 static const int kTimeCheckInterval = 10; | 32 static const int kTimeCheckInterval = 10; |
33 | 33 |
34 class LayerTreeHostPerfTest : public LayerTreeTest { | 34 class LayerTreeHostPerfTest : public LayerTreeTest { |
35 public: | 35 public: |
36 LayerTreeHostPerfTest() | 36 LayerTreeHostPerfTest() |
37 : draw_timer_(kWarmupRuns, | 37 : draw_timer_(kWarmupRuns, |
38 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 38 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
39 kTimeCheckInterval), | 39 kTimeCheckInterval), |
40 commit_timer_(0, base::TimeDelta(), 1), | 40 commit_timer_(0, base::TimeDelta(), 1), |
41 full_damage_each_frame_(false), | 41 full_damage_each_frame_(false), |
42 animation_driven_drawing_(false), | 42 begin_frame_driven_drawing_(false), |
43 measure_commit_cost_(false) { | 43 measure_commit_cost_(false) { |
44 fake_content_layer_client_.set_paint_all_opaque(true); | 44 fake_content_layer_client_.set_paint_all_opaque(true); |
45 } | 45 } |
46 | 46 |
47 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 47 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
48 settings->throttle_frame_production = false; | 48 settings->throttle_frame_production = false; |
49 } | 49 } |
50 | 50 |
51 virtual void BeginTest() OVERRIDE { | 51 virtual void BeginTest() OVERRIDE { |
52 BuildTree(); | 52 BuildTree(); |
53 PostSetNeedsCommitToMainThread(); | 53 PostSetNeedsCommitToMainThread(); |
54 } | 54 } |
55 | 55 |
56 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { | 56 virtual void BeginMainFrame(const BeginFrameArgs& args) OVERRIDE { |
57 if (animation_driven_drawing_ && !TestEnded()) { | 57 if (begin_frame_driven_drawing_ && !TestEnded()) { |
58 layer_tree_host()->SetNeedsAnimate(); | 58 layer_tree_host()->SetNeedsAnimate(); |
59 layer_tree_host()->SetNextCommitForcesRedraw(); | 59 layer_tree_host()->SetNextCommitForcesRedraw(); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 63 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
64 if (measure_commit_cost_) | 64 if (measure_commit_cost_) |
65 commit_timer_.Start(); | 65 commit_timer_.Start(); |
66 } | 66 } |
67 | 67 |
68 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 68 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
69 if (measure_commit_cost_ && draw_timer_.IsWarmedUp()) { | 69 if (measure_commit_cost_ && draw_timer_.IsWarmedUp()) { |
70 commit_timer_.NextLap(); | 70 commit_timer_.NextLap(); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 74 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
75 if (TestEnded() || CleanUpStarted()) | 75 if (TestEnded() || CleanUpStarted()) |
76 return; | 76 return; |
77 draw_timer_.NextLap(); | 77 draw_timer_.NextLap(); |
78 if (draw_timer_.HasTimeLimitExpired()) { | 78 if (draw_timer_.HasTimeLimitExpired()) { |
79 CleanUpAndEndTest(impl); | 79 CleanUpAndEndTest(impl); |
80 return; | 80 return; |
81 } | 81 } |
82 if (!animation_driven_drawing_) | 82 if (!begin_frame_driven_drawing_) |
83 impl->SetNeedsRedraw(); | 83 impl->SetNeedsRedraw(); |
84 if (full_damage_each_frame_) | 84 if (full_damage_each_frame_) |
85 impl->SetFullRootLayerDamage(); | 85 impl->SetFullRootLayerDamage(); |
86 } | 86 } |
87 | 87 |
88 virtual void CleanUpAndEndTest(LayerTreeHostImpl* host_impl) { EndTest(); } | 88 virtual void CleanUpAndEndTest(LayerTreeHostImpl* host_impl) { EndTest(); } |
89 | 89 |
90 virtual bool CleanUpStarted() { return false; } | 90 virtual bool CleanUpStarted() { return false; } |
91 | 91 |
92 virtual void BuildTree() {} | 92 virtual void BuildTree() {} |
93 | 93 |
94 virtual void AfterTest() OVERRIDE { | 94 virtual void AfterTest() OVERRIDE { |
95 CHECK(!test_name_.empty()) << "Must SetTestName() before AfterTest()."; | 95 CHECK(!test_name_.empty()) << "Must SetTestName() before AfterTest()."; |
96 perf_test::PrintResult("layer_tree_host_frame_time", "", test_name_, | 96 perf_test::PrintResult("layer_tree_host_frame_time", "", test_name_, |
97 1000 * draw_timer_.MsPerLap(), "us", true); | 97 1000 * draw_timer_.MsPerLap(), "us", true); |
98 if (measure_commit_cost_) { | 98 if (measure_commit_cost_) { |
99 perf_test::PrintResult("layer_tree_host_commit_time", "", test_name_, | 99 perf_test::PrintResult("layer_tree_host_commit_time", "", test_name_, |
100 1000 * commit_timer_.MsPerLap(), "us", true); | 100 1000 * commit_timer_.MsPerLap(), "us", true); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 protected: | 104 protected: |
105 LapTimer draw_timer_; | 105 LapTimer draw_timer_; |
106 LapTimer commit_timer_; | 106 LapTimer commit_timer_; |
107 | 107 |
108 std::string test_name_; | 108 std::string test_name_; |
109 FakeContentLayerClient fake_content_layer_client_; | 109 FakeContentLayerClient fake_content_layer_client_; |
110 bool full_damage_each_frame_; | 110 bool full_damage_each_frame_; |
111 bool animation_driven_drawing_; | 111 bool begin_frame_driven_drawing_; |
112 | 112 |
113 bool measure_commit_cost_; | 113 bool measure_commit_cost_; |
114 }; | 114 }; |
115 | 115 |
116 | 116 |
117 class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest { | 117 class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest { |
118 public: | 118 public: |
119 LayerTreeHostPerfTestJsonReader() | 119 LayerTreeHostPerfTestJsonReader() |
120 : LayerTreeHostPerfTest() { | 120 : LayerTreeHostPerfTest() { |
121 } | 121 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 TEST_F(BrowserCompositorInvalidateLayerTreePerfTest, DenseBrowserUI) { | 318 TEST_F(BrowserCompositorInvalidateLayerTreePerfTest, DenseBrowserUI) { |
319 measure_commit_cost_ = true; | 319 measure_commit_cost_ = true; |
320 SetTestName("dense_layer_tree"); | 320 SetTestName("dense_layer_tree"); |
321 ReadTestFile("dense_layer_tree"); | 321 ReadTestFile("dense_layer_tree"); |
322 RunTestWithImplSidePainting(); | 322 RunTestWithImplSidePainting(); |
323 } | 323 } |
324 | 324 |
325 // Simulates a page with several large, transformed and animated layers. | 325 // Simulates a page with several large, transformed and animated layers. |
326 TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreadedImplSide) { | 326 TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreadedImplSide) { |
327 animation_driven_drawing_ = true; | 327 begin_frame_driven_drawing_ = true; |
328 measure_commit_cost_ = true; | 328 measure_commit_cost_ = true; |
329 SetTestName("heavy_page"); | 329 SetTestName("heavy_page"); |
330 ReadTestFile("heavy_layer_tree"); | 330 ReadTestFile("heavy_layer_tree"); |
331 RunTestWithImplSidePainting(); | 331 RunTestWithImplSidePainting(); |
332 } | 332 } |
333 | 333 |
334 } // namespace | 334 } // namespace |
335 } // namespace cc | 335 } // namespace cc |
OLD | NEW |