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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: nit Created 4 years, 1 month 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_hittest_unittest.cc ('k') | cc/test/fake_compositor_frame_sink.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/output/compositor_frame.h" 5 #include "cc/output/compositor_frame.h"
6 #include "cc/quads/render_pass.h" 6 #include "cc/quads/render_pass.h"
7 #include "cc/quads/solid_color_draw_quad.h" 7 #include "cc/quads/solid_color_draw_quad.h"
8 #include "cc/quads/surface_draw_quad.h" 8 #include "cc/quads/surface_draw_quad.h"
9 #include "cc/surfaces/surface.h" 9 #include "cc/surfaces/surface.h"
10 #include "cc/surfaces/surface_aggregator.h" 10 #include "cc/surfaces/surface_aggregator.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 SolidColorDrawQuad* color_quad = 69 SolidColorDrawQuad* color_quad =
70 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 70 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
71 bool force_anti_aliasing_off = false; 71 bool force_anti_aliasing_off = false;
72 color_quad->SetNew(pass->shared_quad_state_list.back(), 72 color_quad->SetNew(pass->shared_quad_state_list.back(),
73 rect, 73 rect,
74 rect, 74 rect,
75 SK_ColorGREEN, 75 SK_ColorGREEN,
76 force_anti_aliasing_off); 76 force_anti_aliasing_off);
77 77
78 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
79 new DelegatedFrameData);
80 delegated_frame_data->render_pass_list.push_back(std::move(pass));
81 78
82 CompositorFrame root_frame; 79 CompositorFrame root_frame;
83 root_frame.delegated_frame_data = std::move(delegated_frame_data); 80 root_frame.render_pass_list.push_back(std::move(pass));
84 81
85 LocalFrameId root_local_frame_id = allocator_.GenerateId(); 82 LocalFrameId root_local_frame_id = allocator_.GenerateId();
86 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); 83 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id);
87 factory_.Create(root_local_frame_id); 84 factory_.Create(root_local_frame_id);
88 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), 85 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame),
89 SurfaceFactory::DrawCallback()); 86 SurfaceFactory::DrawCallback());
90 87
91 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); 88 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true);
92 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); 89 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id);
93 factory_.Destroy(root_local_frame_id); 90 factory_.Destroy(root_local_frame_id);
94 91
95 bool discard_alpha = false; 92 bool discard_alpha = false;
96 ExactPixelComparator pixel_comparator(discard_alpha); 93 ExactPixelComparator pixel_comparator(discard_alpha);
97 RenderPassList* pass_list = 94 RenderPassList* pass_list = &aggregated_frame.render_pass_list;
98 &aggregated_frame.delegated_frame_data->render_pass_list;
99 EXPECT_TRUE(RunPixelTest(pass_list, 95 EXPECT_TRUE(RunPixelTest(pass_list,
100 base::FilePath(FILE_PATH_LITERAL("green.png")), 96 base::FilePath(FILE_PATH_LITERAL("green.png")),
101 pixel_comparator)); 97 pixel_comparator));
102 } 98 }
103 99
104 // Draws a frame with simple surface embedding. 100 // Draws a frame with simple surface embedding.
105 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { 101 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) {
106 gfx::Size child_size(200, 100); 102 gfx::Size child_size(200, 100);
107 LocalFrameId child_local_frame_id = allocator_.GenerateId(); 103 LocalFrameId child_local_frame_id = allocator_.GenerateId();
108 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); 104 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
(...skipping 20 matching lines...) Expand all
129 125
130 SolidColorDrawQuad* color_quad = 126 SolidColorDrawQuad* color_quad =
131 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 127 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
132 bool force_anti_aliasing_off = false; 128 bool force_anti_aliasing_off = false;
133 color_quad->SetNew(pass->shared_quad_state_list.back(), 129 color_quad->SetNew(pass->shared_quad_state_list.back(),
134 rect, 130 rect,
135 rect, 131 rect,
136 SK_ColorYELLOW, 132 SK_ColorYELLOW,
137 force_anti_aliasing_off); 133 force_anti_aliasing_off);
138 134
139 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
140 new DelegatedFrameData);
141 delegated_frame_data->render_pass_list.push_back(std::move(pass));
142
143 CompositorFrame root_frame; 135 CompositorFrame root_frame;
144 root_frame.delegated_frame_data = std::move(delegated_frame_data); 136 root_frame.render_pass_list.push_back(std::move(pass));
145 137
146 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), 138 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame),
147 SurfaceFactory::DrawCallback()); 139 SurfaceFactory::DrawCallback());
148 } 140 }
149 141
150 { 142 {
151 gfx::Rect rect(child_size); 143 gfx::Rect rect(child_size);
152 RenderPassId id(1, 1); 144 RenderPassId id(1, 1);
153 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 145 std::unique_ptr<RenderPass> pass = RenderPass::Create();
154 pass->SetNew(id, rect, rect, gfx::Transform()); 146 pass->SetNew(id, rect, rect, gfx::Transform());
155 147
156 CreateAndAppendTestSharedQuadState( 148 CreateAndAppendTestSharedQuadState(
157 pass.get(), gfx::Transform(), child_size); 149 pass.get(), gfx::Transform(), child_size);
158 150
159 SolidColorDrawQuad* color_quad = 151 SolidColorDrawQuad* color_quad =
160 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 152 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
161 bool force_anti_aliasing_off = false; 153 bool force_anti_aliasing_off = false;
162 color_quad->SetNew(pass->shared_quad_state_list.back(), 154 color_quad->SetNew(pass->shared_quad_state_list.back(),
163 rect, 155 rect,
164 rect, 156 rect,
165 SK_ColorBLUE, 157 SK_ColorBLUE,
166 force_anti_aliasing_off); 158 force_anti_aliasing_off);
167 159
168 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
169 new DelegatedFrameData);
170 delegated_frame_data->render_pass_list.push_back(std::move(pass));
171
172 CompositorFrame child_frame; 160 CompositorFrame child_frame;
173 child_frame.delegated_frame_data = std::move(delegated_frame_data); 161 child_frame.render_pass_list.push_back(std::move(pass));
174 162
175 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), 163 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
176 SurfaceFactory::DrawCallback()); 164 SurfaceFactory::DrawCallback());
177 } 165 }
178 166
179 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); 167 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true);
180 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); 168 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id);
181 169
182 bool discard_alpha = false; 170 bool discard_alpha = false;
183 ExactPixelComparator pixel_comparator(discard_alpha); 171 ExactPixelComparator pixel_comparator(discard_alpha);
184 RenderPassList* pass_list = 172 RenderPassList* pass_list = &aggregated_frame.render_pass_list;
185 &aggregated_frame.delegated_frame_data->render_pass_list;
186 EXPECT_TRUE(RunPixelTest(pass_list, 173 EXPECT_TRUE(RunPixelTest(pass_list,
187 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), 174 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")),
188 pixel_comparator)); 175 pixel_comparator));
189 factory_.Destroy(root_local_frame_id); 176 factory_.Destroy(root_local_frame_id);
190 factory_.Destroy(child_local_frame_id); 177 factory_.Destroy(child_local_frame_id);
191 } 178 }
192 179
193 // Tests a surface quad that has a non-identity transform into its pass. 180 // Tests a surface quad that has a non-identity transform into its pass.
194 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { 181 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) {
195 gfx::Size child_size(100, 200); 182 gfx::Size child_size(100, 200);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 CreateAndAppendTestSharedQuadState( 219 CreateAndAppendTestSharedQuadState(
233 pass.get(), surface_transform, device_viewport_size_); 220 pass.get(), surface_transform, device_viewport_size_);
234 221
235 SurfaceDrawQuad* right_surface_quad = 222 SurfaceDrawQuad* right_surface_quad =
236 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 223 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
237 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), 224 right_surface_quad->SetNew(pass->shared_quad_state_list.back(),
238 gfx::Rect(child_size), 225 gfx::Rect(child_size),
239 gfx::Rect(child_size), 226 gfx::Rect(child_size),
240 right_child_id); 227 right_child_id);
241 228
242 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
243 new DelegatedFrameData);
244 delegated_frame_data->render_pass_list.push_back(std::move(pass));
245
246 CompositorFrame root_frame; 229 CompositorFrame root_frame;
247 root_frame.delegated_frame_data = std::move(delegated_frame_data); 230 root_frame.render_pass_list.push_back(std::move(pass));
248 231
249 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), 232 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame),
250 SurfaceFactory::DrawCallback()); 233 SurfaceFactory::DrawCallback());
251 } 234 }
252 235
253 { 236 {
254 gfx::Rect rect(child_size); 237 gfx::Rect rect(child_size);
255 RenderPassId id(1, 1); 238 RenderPassId id(1, 1);
256 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 239 std::unique_ptr<RenderPass> pass = RenderPass::Create();
257 pass->SetNew(id, rect, rect, gfx::Transform()); 240 pass->SetNew(id, rect, rect, gfx::Transform());
(...skipping 11 matching lines...) Expand all
269 force_anti_aliasing_off); 252 force_anti_aliasing_off);
270 253
271 SolidColorDrawQuad* bottom_color_quad = 254 SolidColorDrawQuad* bottom_color_quad =
272 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 255 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
273 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), 256 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(),
274 gfx::Rect(0, 100, 100, 100), 257 gfx::Rect(0, 100, 100, 100),
275 gfx::Rect(0, 100, 100, 100), 258 gfx::Rect(0, 100, 100, 100),
276 SK_ColorBLUE, 259 SK_ColorBLUE,
277 force_anti_aliasing_off); 260 force_anti_aliasing_off);
278 261
279 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
280 new DelegatedFrameData);
281 delegated_frame_data->render_pass_list.push_back(std::move(pass));
282
283 CompositorFrame child_frame; 262 CompositorFrame child_frame;
284 child_frame.delegated_frame_data = std::move(delegated_frame_data); 263 child_frame.render_pass_list.push_back(std::move(pass));
285 264
286 factory_.SubmitCompositorFrame(left_child_local_id, std::move(child_frame), 265 factory_.SubmitCompositorFrame(left_child_local_id, std::move(child_frame),
287 SurfaceFactory::DrawCallback()); 266 SurfaceFactory::DrawCallback());
288 } 267 }
289 268
290 { 269 {
291 gfx::Rect rect(child_size); 270 gfx::Rect rect(child_size);
292 RenderPassId id(1, 1); 271 RenderPassId id(1, 1);
293 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 272 std::unique_ptr<RenderPass> pass = RenderPass::Create();
294 pass->SetNew(id, rect, rect, gfx::Transform()); 273 pass->SetNew(id, rect, rect, gfx::Transform());
(...skipping 11 matching lines...) Expand all
306 force_anti_aliasing_off); 285 force_anti_aliasing_off);
307 286
308 SolidColorDrawQuad* bottom_color_quad = 287 SolidColorDrawQuad* bottom_color_quad =
309 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 288 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
310 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), 289 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(),
311 gfx::Rect(0, 100, 100, 100), 290 gfx::Rect(0, 100, 100, 100),
312 gfx::Rect(0, 100, 100, 100), 291 gfx::Rect(0, 100, 100, 100),
313 SK_ColorGREEN, 292 SK_ColorGREEN,
314 force_anti_aliasing_off); 293 force_anti_aliasing_off);
315 294
316 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
317 new DelegatedFrameData);
318 delegated_frame_data->render_pass_list.push_back(std::move(pass));
319
320 CompositorFrame child_frame; 295 CompositorFrame child_frame;
321 child_frame.delegated_frame_data = std::move(delegated_frame_data); 296 child_frame.render_pass_list.push_back(std::move(pass));
322 297
323 factory_.SubmitCompositorFrame(right_child_local_id, std::move(child_frame), 298 factory_.SubmitCompositorFrame(right_child_local_id, std::move(child_frame),
324 SurfaceFactory::DrawCallback()); 299 SurfaceFactory::DrawCallback());
325 } 300 }
326 301
327 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); 302 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true);
328 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); 303 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id);
329 304
330 bool discard_alpha = false; 305 bool discard_alpha = false;
331 ExactPixelComparator pixel_comparator(discard_alpha); 306 ExactPixelComparator pixel_comparator(discard_alpha);
332 RenderPassList* pass_list = 307 RenderPassList* pass_list = &aggregated_frame.render_pass_list;
333 &aggregated_frame.delegated_frame_data->render_pass_list;
334 EXPECT_TRUE(RunPixelTest( 308 EXPECT_TRUE(RunPixelTest(
335 pass_list, 309 pass_list,
336 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), 310 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")),
337 pixel_comparator)); 311 pixel_comparator));
338 312
339 factory_.Destroy(root_local_frame_id); 313 factory_.Destroy(root_local_frame_id);
340 factory_.Destroy(left_child_local_id); 314 factory_.Destroy(left_child_local_id);
341 factory_.Destroy(right_child_local_id); 315 factory_.Destroy(right_child_local_id);
342 } 316 }
343 317
344 } // namespace 318 } // namespace
345 } // namespace cc 319 } // namespace cc
346 320
347 #endif // !defined(OS_ANDROID) 321 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « cc/surfaces/surface_hittest_unittest.cc ('k') | cc/test/fake_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698