| 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_ = PictureLayerTiling::Create( | 25 picture_layer_tiling_ = PictureLayerTiling::Create( |
| 26 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); | 26 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); |
| 27 picture_layer_tiling_->CreateAllTilesForTesting(); | 27 picture_layer_tiling_->CreateAllPendingTilesForTesting(); |
| 28 picture_layer_tiling_client_.MarkPending(); |
| 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() { |
| 35 elapsed_ = base::TimeTicks::HighResNow() - start_time_; | 36 elapsed_ = base::TimeTicks::HighResNow() - start_time_; |
| 36 } | 37 } |
| 37 | 38 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 | 64 |
| 64 void RunUpdateTilePrioritiesStationaryTest( | 65 void RunUpdateTilePrioritiesStationaryTest( |
| 65 const std::string& test_name, | 66 const std::string& test_name, |
| 66 const gfx::Transform& transform) { | 67 const gfx::Transform& transform) { |
| 67 start_time_ = base::TimeTicks(); | 68 start_time_ = base::TimeTicks(); |
| 68 num_runs_ = 0; | 69 num_runs_ = 0; |
| 69 | 70 |
| 70 gfx::Size layer_bounds(50 * 256, 50 * 256); | 71 gfx::Size layer_bounds(50 * 256, 50 * 256); |
| 71 do { | 72 do { |
| 72 picture_layer_tiling_->UpdateTilePriorities( | 73 picture_layer_tiling_->UpdateTilePriorities( |
| 73 ACTIVE_TREE, | 74 PENDING_TREE, |
| 74 layer_bounds, | 75 layer_bounds, |
| 75 gfx::Rect(layer_bounds), | 76 gfx::Rect(layer_bounds), |
| 76 gfx::Rect(layer_bounds), | 77 gfx::Rect(layer_bounds), |
| 77 layer_bounds, | 78 layer_bounds, |
| 78 layer_bounds, | 79 layer_bounds, |
| 79 1.f, | 80 1.f, |
| 80 1.f, | 81 1.f, |
| 81 transform, | 82 transform, |
| 82 transform, | 83 transform, |
| 83 num_runs_ + 1, | 84 num_runs_ + 1, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 gfx::Size layer_bounds(50 * 256, 50 * 256); | 98 gfx::Size layer_bounds(50 * 256, 50 * 256); |
| 98 gfx::Size viewport_size(1024, 768); | 99 gfx::Size viewport_size(1024, 768); |
| 99 gfx::Rect viewport_rect(viewport_size); | 100 gfx::Rect viewport_rect(viewport_size); |
| 100 int xoffsets[] = {10, 0, -10, 0}; | 101 int xoffsets[] = {10, 0, -10, 0}; |
| 101 int yoffsets[] = {0, 10, 0, -10}; | 102 int yoffsets[] = {0, 10, 0, -10}; |
| 102 int offsetIndex = 0; | 103 int offsetIndex = 0; |
| 103 int offsetCount = 0; | 104 int offsetCount = 0; |
| 104 const int maxOffsetCount = 1000; | 105 const int maxOffsetCount = 1000; |
| 105 do { | 106 do { |
| 106 picture_layer_tiling_->UpdateTilePriorities( | 107 picture_layer_tiling_->UpdateTilePriorities( |
| 107 ACTIVE_TREE, | 108 PENDING_TREE, |
| 108 viewport_size, | 109 viewport_size, |
| 109 viewport_rect, | 110 viewport_rect, |
| 110 gfx::Rect(layer_bounds), | 111 gfx::Rect(layer_bounds), |
| 111 layer_bounds, | 112 layer_bounds, |
| 112 layer_bounds, | 113 layer_bounds, |
| 113 1.f, | 114 1.f, |
| 114 1.f, | 115 1.f, |
| 115 transform, | 116 transform, |
| 116 transform, | 117 transform, |
| 117 num_runs_ + 1, | 118 num_runs_ + 1, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 RunUpdateTilePrioritiesScrollingTest("rotation", transform); | 169 RunUpdateTilePrioritiesScrollingTest("rotation", transform); |
| 169 | 170 |
| 170 transform.ApplyPerspectiveDepth(10); | 171 transform.ApplyPerspectiveDepth(10); |
| 171 RunUpdateTilePrioritiesStationaryTest("perspective", transform); | 172 RunUpdateTilePrioritiesStationaryTest("perspective", transform); |
| 172 RunUpdateTilePrioritiesScrollingTest("perspective", transform); | 173 RunUpdateTilePrioritiesScrollingTest("perspective", transform); |
| 173 } | 174 } |
| 174 | 175 |
| 175 } // namespace | 176 } // namespace |
| 176 | 177 |
| 177 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |