OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/debug/lap_timer.h" | 5 #include "cc/debug/lap_timer.h" |
6 #include "cc/output/compositor_frame.h" | 6 #include "cc/output/compositor_frame.h" |
7 #include "cc/output/delegated_frame_data.h" | 7 #include "cc/output/delegated_frame_data.h" |
8 #include "cc/quads/surface_draw_quad.h" | 8 #include "cc/quads/surface_draw_quad.h" |
9 #include "cc/quads/texture_draw_quad.h" | 9 #include "cc/quads/texture_draw_quad.h" |
10 #include "cc/surfaces/surface_aggregator.h" | 10 #include "cc/surfaces/surface_aggregator.h" |
11 #include "cc/surfaces/surface_factory.h" | 11 #include "cc/surfaces/surface_factory.h" |
12 #include "cc/surfaces/surface_factory_client.h" | 12 #include "cc/surfaces/surface_factory_client.h" |
13 #include "cc/surfaces/surface_manager.h" | 13 #include "cc/surfaces/surface_manager.h" |
14 #include "cc/test/fake_output_surface.h" | 14 #include "cc/test/fake_output_surface.h" |
15 #include "cc/test/fake_output_surface_client.h" | 15 #include "cc/test/fake_output_surface_client.h" |
16 #include "cc/test/fake_resource_provider.h" | 16 #include "cc/test/fake_resource_provider.h" |
17 #include "cc/test/test_shared_bitmap_manager.h" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "testing/perf/perf_test.h" | 19 #include "testing/perf/perf_test.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 namespace { | 22 namespace { |
23 | 23 |
24 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | 24 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { |
25 public: | 25 public: |
26 void ReturnResources(const ReturnedResourceArray& resources) override {} | 26 void ReturnResources(const ReturnedResourceArray& resources) override {} |
| 27 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
| 28 }; |
| 29 |
| 30 class EmptySurfaceAggregatorClient : public SurfaceAggregatorClient { |
| 31 public: |
| 32 void AddSurface(Surface* surface) override {} |
| 33 void RemoveSurface(Surface* surface) override {} |
27 }; | 34 }; |
28 | 35 |
29 class SurfaceAggregatorPerfTest : public testing::Test { | 36 class SurfaceAggregatorPerfTest : public testing::Test { |
30 public: | 37 public: |
31 SurfaceAggregatorPerfTest() : factory_(&manager_, &empty_client_) { | 38 SurfaceAggregatorPerfTest() : factory_(&manager_, &empty_client_) { |
32 output_surface_ = FakeOutputSurface::CreateSoftware( | 39 output_surface_ = FakeOutputSurface::CreateSoftware( |
33 make_scoped_ptr(new SoftwareOutputDevice)); | 40 make_scoped_ptr(new SoftwareOutputDevice)); |
34 output_surface_->BindToClient(&output_surface_client_); | 41 output_surface_->BindToClient(&output_surface_client_); |
35 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 42 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
36 | 43 |
37 resource_provider_ = FakeResourceProvider::Create( | 44 resource_provider_ = FakeResourceProvider::Create( |
38 output_surface_.get(), shared_bitmap_manager_.get()); | 45 output_surface_.get(), shared_bitmap_manager_.get()); |
39 } | 46 } |
40 | 47 |
41 void RunTest(int num_surfaces, | 48 void RunTest(int num_surfaces, |
42 int num_textures, | 49 int num_textures, |
43 float opacity, | 50 float opacity, |
44 bool optimize_damage, | 51 bool optimize_damage, |
45 bool full_damage, | 52 bool full_damage, |
46 const std::string& name) { | 53 const std::string& name) { |
47 aggregator_.reset(new SurfaceAggregator(&manager_, resource_provider_.get(), | 54 aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_, |
| 55 &manager_, resource_provider_.get(), |
48 optimize_damage)); | 56 optimize_damage)); |
49 for (int i = 1; i <= num_surfaces; i++) { | 57 for (int i = 1; i <= num_surfaces; i++) { |
50 factory_.Create(SurfaceId(i)); | 58 factory_.Create(SurfaceId(i)); |
51 scoped_ptr<RenderPass> pass(RenderPass::Create()); | 59 scoped_ptr<RenderPass> pass(RenderPass::Create()); |
52 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 60 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
53 | 61 |
54 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 62 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
55 for (int j = 0; j < num_textures; j++) { | 63 for (int j = 0; j < num_textures; j++) { |
56 TransferableResource resource; | 64 TransferableResource resource; |
57 resource.id = j; | 65 resource.id = j; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 140 |
133 protected: | 141 protected: |
134 SurfaceManager manager_; | 142 SurfaceManager manager_; |
135 EmptySurfaceFactoryClient empty_client_; | 143 EmptySurfaceFactoryClient empty_client_; |
136 SurfaceFactory factory_; | 144 SurfaceFactory factory_; |
137 FakeOutputSurfaceClient output_surface_client_; | 145 FakeOutputSurfaceClient output_surface_client_; |
138 scoped_ptr<OutputSurface> output_surface_; | 146 scoped_ptr<OutputSurface> output_surface_; |
139 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 147 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
140 scoped_ptr<ResourceProvider> resource_provider_; | 148 scoped_ptr<ResourceProvider> resource_provider_; |
141 scoped_ptr<SurfaceAggregator> aggregator_; | 149 scoped_ptr<SurfaceAggregator> aggregator_; |
| 150 EmptySurfaceAggregatorClient surface_aggregator_client_; |
142 LapTimer timer_; | 151 LapTimer timer_; |
143 }; | 152 }; |
144 | 153 |
145 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesOpaque) { | 154 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesOpaque) { |
146 RunTest(20, 100, 1.f, false, true, "many_surfaces_opaque"); | 155 RunTest(20, 100, 1.f, false, true, "many_surfaces_opaque"); |
147 } | 156 } |
148 | 157 |
149 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesTransparent) { | 158 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesTransparent) { |
150 RunTest(20, 100, .5f, false, true, "many_surfaces_transparent"); | 159 RunTest(20, 100, .5f, false, true, "many_surfaces_transparent"); |
151 } | 160 } |
(...skipping 13 matching lines...) Expand all Loading... |
165 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) { | 174 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) { |
166 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc"); | 175 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc"); |
167 } | 176 } |
168 | 177 |
169 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) { | 178 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) { |
170 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged"); | 179 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged"); |
171 } | 180 } |
172 | 181 |
173 } // namespace | 182 } // namespace |
174 } // namespace cc | 183 } // namespace cc |
OLD | NEW |