OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include "cc/debug/lap_timer.h" | 7 #include "cc/debug/lap_timer.h" |
8 #include "cc/test/fake_impl_proxy.h" | 8 #include "cc/test/fake_impl_proxy.h" |
9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 scoped_ptr<FakePictureLayerImpl> pending_layer = | 50 scoped_ptr<FakePictureLayerImpl> pending_layer = |
51 FakePictureLayerImpl::CreateWithPile(pending_tree, 7, pile); | 51 FakePictureLayerImpl::CreateWithPile(pending_tree, 7, pile); |
52 pending_layer->SetDrawsContent(true); | 52 pending_layer->SetDrawsContent(true); |
53 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 53 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
54 | 54 |
55 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 55 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
56 host_impl_.pending_tree()->LayerById(7)); | 56 host_impl_.pending_tree()->LayerById(7)); |
57 pending_layer_->DoPostCommitInitializationIfNeeded(); | 57 pending_layer_->DoPostCommitInitializationIfNeeded(); |
58 } | 58 } |
59 | 59 |
60 void RunLayerRasterTileIteratorTest(const std::string& test_name, | 60 void RunRasterIteratorConstructAndIterateTest( |
61 int num_tiles, | 61 const std::string& test_name, |
62 const gfx::Size& viewport_size) { | 62 int num_tiles, |
| 63 const gfx::Size& viewport_size) { |
63 host_impl_.SetViewportSize(viewport_size); | 64 host_impl_.SetViewportSize(viewport_size); |
64 host_impl_.pending_tree()->UpdateDrawProperties(); | 65 host_impl_.pending_tree()->UpdateDrawProperties(); |
65 | 66 |
66 timer_.Reset(); | 67 timer_.Reset(); |
67 do { | 68 do { |
68 int count = num_tiles; | 69 int count = num_tiles; |
69 for (PictureLayerImpl::LayerRasterTileIterator it(pending_layer_, false); | 70 PictureLayerImpl::LayerRasterTileIterator it(pending_layer_, false); |
70 it && count; | 71 while (count--) { |
71 ++it) { | 72 ASSERT_TRUE(it) << "count: " << count; |
72 --count; | 73 ASSERT_TRUE(*it != NULL) << "count: " << count; |
| 74 ++it; |
73 } | 75 } |
74 timer_.NextLap(); | 76 timer_.NextLap(); |
75 } while (!timer_.HasTimeLimitExpired()); | 77 } while (!timer_.HasTimeLimitExpired()); |
76 | 78 |
77 perf_test::PrintResult("layer_raster_tile_iterator", | 79 perf_test::PrintResult("layer_raster_tile_iterator_construct_and_iterate", |
78 "", | 80 "", |
79 test_name, | 81 test_name, |
80 timer_.LapsPerSecond(), | 82 timer_.LapsPerSecond(), |
| 83 "runs/s", |
| 84 true); |
| 85 } |
| 86 |
| 87 void RunRasterIteratorConstructTest(const std::string& test_name, |
| 88 const gfx::Rect& viewport) { |
| 89 host_impl_.SetViewportSize(viewport.size()); |
| 90 pending_layer_->SetScrollOffset(gfx::Vector2d(viewport.x(), viewport.y())); |
| 91 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 92 |
| 93 timer_.Reset(); |
| 94 do { |
| 95 PictureLayerImpl::LayerRasterTileIterator it(pending_layer_, false); |
| 96 timer_.NextLap(); |
| 97 } while (!timer_.HasTimeLimitExpired()); |
| 98 |
| 99 perf_test::PrintResult("layer_raster_tile_iterator_construct", |
| 100 "", |
| 101 test_name, |
| 102 timer_.LapsPerSecond(), |
81 "runs/s", | 103 "runs/s", |
82 true); | 104 true); |
83 } | 105 } |
84 | 106 |
85 protected: | 107 protected: |
86 TestSharedBitmapManager shared_bitmap_manager_; | 108 TestSharedBitmapManager shared_bitmap_manager_; |
87 FakeImplProxy proxy_; | 109 FakeImplProxy proxy_; |
88 FakeLayerTreeHostImpl host_impl_; | 110 FakeLayerTreeHostImpl host_impl_; |
89 FakePictureLayerImpl* pending_layer_; | 111 FakePictureLayerImpl* pending_layer_; |
90 LapTimer timer_; | 112 LapTimer timer_; |
91 | 113 |
92 private: | 114 private: |
93 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); | 115 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); |
94 }; | 116 }; |
95 | 117 |
96 TEST_F(PictureLayerImplPerfTest, LayerRasterTileIterator) { | 118 TEST_F(PictureLayerImplPerfTest, LayerRasterTileIteratorConstructAndIterate) { |
97 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 119 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); |
98 | 120 |
99 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 121 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 122 |
| 123 pending_layer_->AddTiling(low_res_factor); |
| 124 pending_layer_->AddTiling(0.3f); |
| 125 pending_layer_->AddTiling(0.7f); |
| 126 pending_layer_->AddTiling(1.0f); |
| 127 pending_layer_->AddTiling(2.0f); |
| 128 |
| 129 RunRasterIteratorConstructAndIterateTest( |
| 130 "32_100x100", 32, gfx::Size(100, 100)); |
| 131 RunRasterIteratorConstructAndIterateTest( |
| 132 "32_500x500", 32, gfx::Size(500, 500)); |
| 133 RunRasterIteratorConstructAndIterateTest( |
| 134 "64_100x100", 64, gfx::Size(100, 100)); |
| 135 RunRasterIteratorConstructAndIterateTest( |
| 136 "64_500x500", 64, gfx::Size(500, 500)); |
| 137 } |
| 138 |
| 139 TEST_F(PictureLayerImplPerfTest, LayerRasterTileIteratorConstruct) { |
| 140 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); |
| 141 |
| 142 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
100 | 143 |
101 pending_layer_->AddTiling(low_res_factor); | 144 pending_layer_->AddTiling(low_res_factor); |
102 pending_layer_->AddTiling(0.3f); | 145 pending_layer_->AddTiling(0.3f); |
103 pending_layer_->AddTiling(0.7f); | 146 pending_layer_->AddTiling(0.7f); |
104 pending_layer_->AddTiling(1.0f); | 147 pending_layer_->AddTiling(1.0f); |
105 pending_layer_->AddTiling(2.0f); | 148 pending_layer_->AddTiling(2.0f); |
106 | 149 |
107 RunLayerRasterTileIteratorTest("32_100x100", 32, gfx::Size(100, 100)); | 150 RunRasterIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
108 RunLayerRasterTileIteratorTest("32_500x500", 32, gfx::Size(500, 500)); | 151 RunRasterIteratorConstructTest("5000_0_100x100", |
109 RunLayerRasterTileIteratorTest("64_100x100", 64, gfx::Size(100, 100)); | 152 gfx::Rect(5000, 0, 100, 100)); |
110 RunLayerRasterTileIteratorTest("64_500x500", 64, gfx::Size(500, 500)); | 153 RunRasterIteratorConstructTest("9999_0_100x100", |
| 154 gfx::Rect(9999, 0, 100, 100)); |
111 } | 155 } |
112 | 156 |
113 } // namespace | 157 } // namespace |
114 } // namespace cc | 158 } // namespace cc |
OLD | NEW |