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