Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: cc/surfaces/surface_aggregator_perftest.cc

Issue 1496103002: Reusing base::IdType<...> to implement SurfaceId. Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-id-base
Patch Set: Rebasing + dusting off... Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void RunTest(int num_surfaces, 49 void RunTest(int num_surfaces,
50 int num_textures, 50 int num_textures,
51 float opacity, 51 float opacity,
52 bool optimize_damage, 52 bool optimize_damage,
53 bool full_damage, 53 bool full_damage,
54 const std::string& name) { 54 const std::string& name) {
55 aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_, 55 aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_,
56 &manager_, resource_provider_.get(), 56 &manager_, resource_provider_.get(),
57 optimize_damage)); 57 optimize_damage));
58 for (int i = 1; i <= num_surfaces; i++) { 58 for (int i = 1; i <= num_surfaces; i++) {
59 factory_.Create(SurfaceId(i)); 59 factory_.Create(SurfaceId::FromUnsafeValue(i));
60 scoped_ptr<RenderPass> pass(RenderPass::Create()); 60 scoped_ptr<RenderPass> pass(RenderPass::Create());
61 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 61 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
62 62
63 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 63 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
64 for (int j = 0; j < num_textures; j++) { 64 for (int j = 0; j < num_textures; j++) {
65 TransferableResource resource; 65 TransferableResource resource;
66 resource.id = j; 66 resource.id = j;
67 resource.is_software = true; 67 resource.is_software = true;
68 frame_data->resource_list.push_back(resource); 68 frame_data->resource_list.push_back(resource);
69 69
(...skipping 16 matching lines...) Expand all
86 gfx::Size(), premultiplied_alpha, uv_top_left, 86 gfx::Size(), premultiplied_alpha, uv_top_left,
87 uv_bottom_right, background_color, vertex_opacity, flipped, 87 uv_bottom_right, background_color, vertex_opacity, flipped,
88 nearest_neighbor); 88 nearest_neighbor);
89 } 89 }
90 sqs = pass->CreateAndAppendSharedQuadState(); 90 sqs = pass->CreateAndAppendSharedQuadState();
91 sqs->opacity = opacity; 91 sqs->opacity = opacity;
92 if (i > 1) { 92 if (i > 1) {
93 SurfaceDrawQuad* surface_quad = 93 SurfaceDrawQuad* surface_quad =
94 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 94 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
95 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 95 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
96 SurfaceId(i - 1)); 96 SurfaceId::FromUnsafeValue(i - 1));
97 } 97 }
98 98
99 frame_data->render_pass_list.push_back(std::move(pass)); 99 frame_data->render_pass_list.push_back(std::move(pass));
100 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 100 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
101 frame->delegated_frame_data = std::move(frame_data); 101 frame->delegated_frame_data = std::move(frame_data);
102 factory_.SubmitCompositorFrame(SurfaceId(i), std::move(frame), 102 factory_.SubmitCompositorFrame(SurfaceId::FromUnsafeValue(i),
103 std::move(frame),
103 SurfaceFactory::DrawCallback()); 104 SurfaceFactory::DrawCallback());
104 } 105 }
105 106
106 factory_.Create(SurfaceId(num_surfaces + 1)); 107 factory_.Create(SurfaceId::FromUnsafeValue(num_surfaces + 1));
107 timer_.Reset(); 108 timer_.Reset();
108 do { 109 do {
109 scoped_ptr<RenderPass> pass(RenderPass::Create()); 110 scoped_ptr<RenderPass> pass(RenderPass::Create());
110 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 111 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
111 112
112 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 113 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
113 SurfaceDrawQuad* surface_quad = 114 SurfaceDrawQuad* surface_quad =
114 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 115 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
115 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 100, 100), 116 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 100, 100),
116 gfx::Rect(0, 0, 100, 100), SurfaceId(num_surfaces)); 117 gfx::Rect(0, 0, 100, 100),
118 SurfaceId::FromUnsafeValue(num_surfaces));
117 119
118 if (full_damage) 120 if (full_damage)
119 pass->damage_rect = gfx::Rect(0, 0, 100, 100); 121 pass->damage_rect = gfx::Rect(0, 0, 100, 100);
120 else 122 else
121 pass->damage_rect = gfx::Rect(0, 0, 1, 1); 123 pass->damage_rect = gfx::Rect(0, 0, 1, 1);
122 124
123 frame_data->render_pass_list.push_back(std::move(pass)); 125 frame_data->render_pass_list.push_back(std::move(pass));
124 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 126 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
125 frame->delegated_frame_data = std::move(frame_data); 127 frame->delegated_frame_data = std::move(frame_data);
126 factory_.SubmitCompositorFrame(SurfaceId(num_surfaces + 1), 128 factory_.SubmitCompositorFrame(
127 std::move(frame), 129 SurfaceId::FromUnsafeValue(num_surfaces + 1), std::move(frame),
128 SurfaceFactory::DrawCallback()); 130 SurfaceFactory::DrawCallback());
129 131
130 scoped_ptr<CompositorFrame> aggregated = 132 scoped_ptr<CompositorFrame> aggregated =
131 aggregator_->Aggregate(SurfaceId(num_surfaces + 1)); 133 aggregator_->Aggregate(SurfaceId::FromUnsafeValue(num_surfaces + 1));
132 timer_.NextLap(); 134 timer_.NextLap();
133 } while (!timer_.HasTimeLimitExpired()); 135 } while (!timer_.HasTimeLimitExpired());
134 136
135 perf_test::PrintResult("aggregator_speed", "", name, timer_.LapsPerSecond(), 137 perf_test::PrintResult("aggregator_speed", "", name, timer_.LapsPerSecond(),
136 "runs/s", true); 138 "runs/s", true);
137 139
138 factory_.Destroy(SurfaceId(num_surfaces + 1)); 140 factory_.Destroy(SurfaceId::FromUnsafeValue(num_surfaces + 1));
139 for (int i = 1; i <= num_surfaces; i++) 141 for (int i = 1; i <= num_surfaces; i++)
140 factory_.Destroy(SurfaceId(i)); 142 factory_.Destroy(SurfaceId::FromUnsafeValue(i));
141 } 143 }
142 144
143 protected: 145 protected:
144 SurfaceManager manager_; 146 SurfaceManager manager_;
145 EmptySurfaceFactoryClient empty_client_; 147 EmptySurfaceFactoryClient empty_client_;
146 SurfaceFactory factory_; 148 SurfaceFactory factory_;
147 FakeOutputSurfaceClient output_surface_client_; 149 FakeOutputSurfaceClient output_surface_client_;
148 scoped_ptr<OutputSurface> output_surface_; 150 scoped_ptr<OutputSurface> output_surface_;
149 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 151 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
150 scoped_ptr<ResourceProvider> resource_provider_; 152 scoped_ptr<ResourceProvider> resource_provider_;
(...skipping 25 matching lines...) Expand all
176 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) { 178 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) {
177 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc"); 179 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc");
178 } 180 }
179 181
180 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) { 182 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) {
181 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged"); 183 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged");
182 } 184 }
183 185
184 } // namespace 186 } // namespace
185 } // namespace cc 187 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698