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

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

Issue 1996783002: Make cc::SurfaceId unguessable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ben's comment Created 4 years, 6 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.cc ('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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "cc/debug/lap_timer.h" 6 #include "cc/debug/lap_timer.h"
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/delegated_frame_data.h" 8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/surface_draw_quad.h" 9 #include "cc/quads/surface_draw_quad.h"
10 #include "cc/quads/texture_draw_quad.h" 10 #include "cc/quads/texture_draw_quad.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 void RunTest(int num_surfaces, 43 void RunTest(int num_surfaces,
44 int num_textures, 44 int num_textures,
45 float opacity, 45 float opacity,
46 bool optimize_damage, 46 bool optimize_damage,
47 bool full_damage, 47 bool full_damage,
48 const std::string& name) { 48 const std::string& name) {
49 aggregator_.reset(new SurfaceAggregator(&manager_, resource_provider_.get(), 49 aggregator_.reset(new SurfaceAggregator(&manager_, resource_provider_.get(),
50 optimize_damage)); 50 optimize_damage));
51 for (int i = 1; i <= num_surfaces; i++) { 51 for (int i = 1; i <= num_surfaces; i++) {
52 factory_.Create(SurfaceId(i)); 52 factory_.Create(SurfaceId(0, i, 0));
53 std::unique_ptr<RenderPass> pass(RenderPass::Create()); 53 std::unique_ptr<RenderPass> pass(RenderPass::Create());
54 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 54 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
55 55
56 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 56 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
57 for (int j = 0; j < num_textures; j++) { 57 for (int j = 0; j < num_textures; j++) {
58 TransferableResource resource; 58 TransferableResource resource;
59 resource.id = j; 59 resource.id = j;
60 resource.is_software = true; 60 resource.is_software = true;
61 frame_data->resource_list.push_back(resource); 61 frame_data->resource_list.push_back(resource);
62 62
(...skipping 16 matching lines...) Expand all
79 gfx::Size(), premultiplied_alpha, uv_top_left, 79 gfx::Size(), premultiplied_alpha, uv_top_left,
80 uv_bottom_right, background_color, vertex_opacity, flipped, 80 uv_bottom_right, background_color, vertex_opacity, flipped,
81 nearest_neighbor, false); 81 nearest_neighbor, false);
82 } 82 }
83 sqs = pass->CreateAndAppendSharedQuadState(); 83 sqs = pass->CreateAndAppendSharedQuadState();
84 sqs->opacity = opacity; 84 sqs->opacity = opacity;
85 if (i > 1) { 85 if (i > 1) {
86 SurfaceDrawQuad* surface_quad = 86 SurfaceDrawQuad* surface_quad =
87 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 87 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
88 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 88 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
89 SurfaceId(i - 1)); 89 SurfaceId(0, i - 1, 0));
90 } 90 }
91 91
92 frame_data->render_pass_list.push_back(std::move(pass)); 92 frame_data->render_pass_list.push_back(std::move(pass));
93 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 93 std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
94 frame->delegated_frame_data = std::move(frame_data); 94 frame->delegated_frame_data = std::move(frame_data);
95 factory_.SubmitCompositorFrame(SurfaceId(i), std::move(frame), 95 factory_.SubmitCompositorFrame(SurfaceId(0, i, 0), std::move(frame),
96 SurfaceFactory::DrawCallback()); 96 SurfaceFactory::DrawCallback());
97 } 97 }
98 98
99 factory_.Create(SurfaceId(num_surfaces + 1)); 99 factory_.Create(SurfaceId(0, num_surfaces + 1, 0));
100 timer_.Reset(); 100 timer_.Reset();
101 do { 101 do {
102 std::unique_ptr<RenderPass> pass(RenderPass::Create()); 102 std::unique_ptr<RenderPass> pass(RenderPass::Create());
103 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 103 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
104 104
105 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 105 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
106 SurfaceDrawQuad* surface_quad = 106 SurfaceDrawQuad* surface_quad =
107 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 107 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
108 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 100, 100), 108 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 100, 100),
109 gfx::Rect(0, 0, 100, 100), SurfaceId(num_surfaces)); 109 gfx::Rect(0, 0, 100, 100),
110 SurfaceId(0, num_surfaces, 0));
110 111
111 if (full_damage) 112 if (full_damage)
112 pass->damage_rect = gfx::Rect(0, 0, 100, 100); 113 pass->damage_rect = gfx::Rect(0, 0, 100, 100);
113 else 114 else
114 pass->damage_rect = gfx::Rect(0, 0, 1, 1); 115 pass->damage_rect = gfx::Rect(0, 0, 1, 1);
115 116
116 frame_data->render_pass_list.push_back(std::move(pass)); 117 frame_data->render_pass_list.push_back(std::move(pass));
117 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 118 std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
118 frame->delegated_frame_data = std::move(frame_data); 119 frame->delegated_frame_data = std::move(frame_data);
119 factory_.SubmitCompositorFrame(SurfaceId(num_surfaces + 1), 120 factory_.SubmitCompositorFrame(SurfaceId(0, num_surfaces + 1, 0),
120 std::move(frame), 121 std::move(frame),
121 SurfaceFactory::DrawCallback()); 122 SurfaceFactory::DrawCallback());
122 123
123 std::unique_ptr<CompositorFrame> aggregated = 124 std::unique_ptr<CompositorFrame> aggregated =
124 aggregator_->Aggregate(SurfaceId(num_surfaces + 1)); 125 aggregator_->Aggregate(SurfaceId(0, num_surfaces + 1, 0));
125 timer_.NextLap(); 126 timer_.NextLap();
126 } while (!timer_.HasTimeLimitExpired()); 127 } while (!timer_.HasTimeLimitExpired());
127 128
128 perf_test::PrintResult("aggregator_speed", "", name, timer_.LapsPerSecond(), 129 perf_test::PrintResult("aggregator_speed", "", name, timer_.LapsPerSecond(),
129 "runs/s", true); 130 "runs/s", true);
130 131
131 factory_.Destroy(SurfaceId(num_surfaces + 1)); 132 factory_.Destroy(SurfaceId(0, num_surfaces + 1, 0));
132 for (int i = 1; i <= num_surfaces; i++) 133 for (int i = 1; i <= num_surfaces; i++)
133 factory_.Destroy(SurfaceId(i)); 134 factory_.Destroy(SurfaceId(0, i, 0));
134 } 135 }
135 136
136 protected: 137 protected:
137 SurfaceManager manager_; 138 SurfaceManager manager_;
138 EmptySurfaceFactoryClient empty_client_; 139 EmptySurfaceFactoryClient empty_client_;
139 SurfaceFactory factory_; 140 SurfaceFactory factory_;
140 FakeOutputSurfaceClient output_surface_client_; 141 FakeOutputSurfaceClient output_surface_client_;
141 std::unique_ptr<OutputSurface> output_surface_; 142 std::unique_ptr<OutputSurface> output_surface_;
142 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; 143 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
143 std::unique_ptr<ResourceProvider> resource_provider_; 144 std::unique_ptr<ResourceProvider> resource_provider_;
(...skipping 24 matching lines...) Expand all
168 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) { 169 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesDamageCalc) {
169 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc"); 170 RunTest(3, 1000, 1.f, true, true, "few_surfaces_damage_calc");
170 } 171 }
171 172
172 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) { 173 TEST_F(SurfaceAggregatorPerfTest, FewSurfacesAggregateDamaged) {
173 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged"); 174 RunTest(3, 1000, 1.f, true, false, "few_surfaces_aggregate_damaged");
174 } 175 }
175 176
176 } // namespace 177 } // namespace
177 } // namespace cc 178 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface.cc ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698