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 20 matching lines...) Expand all Loading... |
31 static const int kWarmupRuns = 5; | 31 static const int kWarmupRuns = 5; |
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 animation_frame_(0), |
41 full_damage_each_frame_(false), | 42 full_damage_each_frame_(false), |
42 animation_driven_drawing_(false), | 43 animation_driven_drawing_(false), |
43 measure_commit_cost_(false) { | 44 measure_commit_cost_(false) { |
44 fake_content_layer_client_.set_paint_all_opaque(true); | 45 fake_content_layer_client_.set_paint_all_opaque(true); |
45 } | 46 } |
46 | 47 |
47 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 48 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
48 settings->throttle_frame_production = false; | 49 settings->throttle_frame_production = false; |
49 } | 50 } |
50 | 51 |
51 virtual void BeginTest() OVERRIDE { | 52 virtual void BeginTest() OVERRIDE { |
52 BuildTree(); | 53 BuildTree(); |
53 PostSetNeedsCommitToMainThread(); | 54 PostSetNeedsCommitToMainThread(); |
54 } | 55 } |
55 | 56 |
56 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { | 57 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { |
57 if (animation_driven_drawing_ && !TestEnded()) { | 58 if (animation_driven_drawing_ && !TestEnded()) { |
58 layer_tree_host()->SetNeedsAnimate(); | 59 layer_tree_host()->SetNeedsAnimate(); |
59 layer_tree_host()->SetNextCommitForcesRedraw(); | 60 // Simulate a transform animation on the root layer. |
| 61 Layer* layer = layer_tree_host()->root_layer(); |
| 62 layer->SetPosition(gfx::PointF(0, animation_frame_++ % 2)); |
60 } | 63 } |
61 } | 64 } |
62 | 65 |
63 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 66 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
64 if (measure_commit_cost_) | 67 if (measure_commit_cost_) |
65 commit_timer_.Start(); | 68 commit_timer_.Start(); |
66 } | 69 } |
67 | 70 |
68 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 71 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
69 if (measure_commit_cost_ && draw_timer_.IsWarmedUp()) { | 72 if (measure_commit_cost_ && draw_timer_.IsWarmedUp()) { |
(...skipping 27 matching lines...) Expand all Loading... |
97 1000 * draw_timer_.MsPerLap(), "us", true); | 100 1000 * draw_timer_.MsPerLap(), "us", true); |
98 if (measure_commit_cost_) { | 101 if (measure_commit_cost_) { |
99 perf_test::PrintResult("layer_tree_host_commit_time", "", test_name_, | 102 perf_test::PrintResult("layer_tree_host_commit_time", "", test_name_, |
100 1000 * commit_timer_.MsPerLap(), "us", true); | 103 1000 * commit_timer_.MsPerLap(), "us", true); |
101 } | 104 } |
102 } | 105 } |
103 | 106 |
104 protected: | 107 protected: |
105 LapTimer draw_timer_; | 108 LapTimer draw_timer_; |
106 LapTimer commit_timer_; | 109 LapTimer commit_timer_; |
| 110 int animation_frame_; |
107 | 111 |
108 std::string test_name_; | 112 std::string test_name_; |
109 FakeContentLayerClient fake_content_layer_client_; | 113 FakeContentLayerClient fake_content_layer_client_; |
110 bool full_damage_each_frame_; | 114 bool full_damage_each_frame_; |
111 bool animation_driven_drawing_; | 115 bool animation_driven_drawing_; |
112 | 116 |
113 bool measure_commit_cost_; | 117 bool measure_commit_cost_; |
114 }; | 118 }; |
115 | 119 |
116 | 120 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreadedImplSide) { | 330 TEST_F(LayerTreeHostPerfTestJsonReader, HeavyPageThreadedImplSide) { |
327 animation_driven_drawing_ = true; | 331 animation_driven_drawing_ = true; |
328 measure_commit_cost_ = true; | 332 measure_commit_cost_ = true; |
329 SetTestName("heavy_page"); | 333 SetTestName("heavy_page"); |
330 ReadTestFile("heavy_layer_tree"); | 334 ReadTestFile("heavy_layer_tree"); |
331 RunTestWithImplSidePainting(); | 335 RunTestWithImplSidePainting(); |
332 } | 336 } |
333 | 337 |
334 } // namespace | 338 } // namespace |
335 } // namespace cc | 339 } // namespace cc |
OLD | NEW |