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(SurfaceId surface_id, | 27 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
28 BeginFrameSource* begin_frame_source) override {} | |
29 }; | |
30 | |
31 class EmptySurfaceAggregatorClient : public SurfaceAggregatorClient { | |
32 public: | |
33 void AddSurface(Surface* surface) override {} | |
34 void RemoveSurface(Surface* surface) override {} | |
35 }; | 28 }; |
36 | 29 |
37 class SurfaceAggregatorPerfTest : public testing::Test { | 30 class SurfaceAggregatorPerfTest : public testing::Test { |
38 public: | 31 public: |
39 SurfaceAggregatorPerfTest() : factory_(&manager_, &empty_client_) { | 32 SurfaceAggregatorPerfTest() : factory_(&manager_, &empty_client_) { |
40 output_surface_ = FakeOutputSurface::CreateSoftware( | 33 output_surface_ = FakeOutputSurface::CreateSoftware( |
41 make_scoped_ptr(new SoftwareOutputDevice)); | 34 make_scoped_ptr(new SoftwareOutputDevice)); |
42 output_surface_->BindToClient(&output_surface_client_); | 35 output_surface_->BindToClient(&output_surface_client_); |
43 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 36 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
44 | 37 |
45 resource_provider_ = FakeResourceProvider::Create( | 38 resource_provider_ = FakeResourceProvider::Create( |
46 output_surface_.get(), shared_bitmap_manager_.get()); | 39 output_surface_.get(), shared_bitmap_manager_.get()); |
47 } | 40 } |
48 | 41 |
49 void RunTest(int num_surfaces, | 42 void RunTest(int num_surfaces, |
50 int num_textures, | 43 int num_textures, |
51 float opacity, | 44 float opacity, |
52 bool optimize_damage, | 45 bool optimize_damage, |
53 bool full_damage, | 46 bool full_damage, |
54 const std::string& name) { | 47 const std::string& name) { |
55 aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_, | 48 aggregator_.reset(new SurfaceAggregator(&manager_, resource_provider_.get(), |
56 &manager_, resource_provider_.get(), | |
57 optimize_damage)); | 49 optimize_damage)); |
58 for (int i = 1; i <= num_surfaces; i++) { | 50 for (int i = 1; i <= num_surfaces; i++) { |
59 factory_.Create(SurfaceId(i)); | 51 factory_.Create(SurfaceId(i)); |
60 scoped_ptr<RenderPass> pass(RenderPass::Create()); | 52 scoped_ptr<RenderPass> pass(RenderPass::Create()); |
61 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 53 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
62 | 54 |
63 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 55 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
64 for (int j = 0; j < num_textures; j++) { | 56 for (int j = 0; j < num_textures; j++) { |
65 TransferableResource resource; | 57 TransferableResource resource; |
66 resource.id = j; | 58 resource.id = j; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 134 |
143 protected: | 135 protected: |
144 SurfaceManager manager_; | 136 SurfaceManager manager_; |
145 EmptySurfaceFactoryClient empty_client_; | 137 EmptySurfaceFactoryClient empty_client_; |
146 SurfaceFactory factory_; | 138 SurfaceFactory factory_; |
147 FakeOutputSurfaceClient output_surface_client_; | 139 FakeOutputSurfaceClient output_surface_client_; |
148 scoped_ptr<OutputSurface> output_surface_; | 140 scoped_ptr<OutputSurface> output_surface_; |
149 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 141 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
150 scoped_ptr<ResourceProvider> resource_provider_; | 142 scoped_ptr<ResourceProvider> resource_provider_; |
151 scoped_ptr<SurfaceAggregator> aggregator_; | 143 scoped_ptr<SurfaceAggregator> aggregator_; |
152 EmptySurfaceAggregatorClient surface_aggregator_client_; | |
153 LapTimer timer_; | 144 LapTimer timer_; |
154 }; | 145 }; |
155 | 146 |
156 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesOpaque) { | 147 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesOpaque) { |
157 RunTest(20, 100, 1.f, false, true, "many_surfaces_opaque"); | 148 RunTest(20, 100, 1.f, false, true, "many_surfaces_opaque"); |
158 } | 149 } |
159 | 150 |
160 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesTransparent) { | 151 TEST_F(SurfaceAggregatorPerfTest, ManySurfacesTransparent) { |
161 RunTest(20, 100, .5f, false, true, "many_surfaces_transparent"); | 152 RunTest(20, 100, .5f, false, true, "many_surfaces_transparent"); |
162 } | 153 } |
(...skipping 13 matching lines...) Expand all Loading... |
176 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) { | 167 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) { |
177 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc"); | 168 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc"); |
178 } | 169 } |
179 | 170 |
180 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) { | 171 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) { |
181 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged"); | 172 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged"); |
182 } | 173 } |
183 | 174 |
184 } // namespace | 175 } // namespace |
185 } // namespace cc | 176 } // namespace cc |
OLD | NEW |