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