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

Side by Side Diff: cc/layers/delegated_renderer_layer_impl.cc

Issue 308193003: Removed QuadSink and MockQuadCuller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumLayerImpl
Patch Set: rebase Created 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/delegated_renderer_layer_impl.h" 5 #include "cc/layers/delegated_renderer_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "cc/base/math_util.h" 12 #include "cc/base/math_util.h"
13 #include "cc/layers/append_quads_data.h" 13 #include "cc/layers/append_quads_data.h"
14 #include "cc/layers/quad_sink.h"
15 #include "cc/layers/render_pass_sink.h" 14 #include "cc/layers/render_pass_sink.h"
16 #include "cc/output/delegated_frame_data.h" 15 #include "cc/output/delegated_frame_data.h"
17 #include "cc/quads/render_pass_draw_quad.h" 16 #include "cc/quads/render_pass_draw_quad.h"
18 #include "cc/quads/solid_color_draw_quad.h" 17 #include "cc/quads/solid_color_draw_quad.h"
19 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
19 #include "cc/trees/occlusion_tracker.h"
20 20
21 namespace cc { 21 namespace cc {
22 22
23 DelegatedRendererLayerImpl::DelegatedRendererLayerImpl(LayerTreeImpl* tree_impl, 23 DelegatedRendererLayerImpl::DelegatedRendererLayerImpl(LayerTreeImpl* tree_impl,
24 int id) 24 int id)
25 : LayerImpl(tree_impl, id), 25 : LayerImpl(tree_impl, id),
26 have_render_passes_to_push_(false), 26 have_render_passes_to_push_(false),
27 inverse_device_scale_factor_(1.0f), 27 inverse_device_scale_factor_(1.0f),
28 child_id_(0), 28 child_id_(0),
29 own_child_id_(false) { 29 own_child_id_(false) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 250
251 bool DelegatedRendererLayerImpl::WillDraw(DrawMode draw_mode, 251 bool DelegatedRendererLayerImpl::WillDraw(DrawMode draw_mode,
252 ResourceProvider* resource_provider) { 252 ResourceProvider* resource_provider) {
253 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) 253 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
254 return false; 254 return false;
255 return LayerImpl::WillDraw(draw_mode, resource_provider); 255 return LayerImpl::WillDraw(draw_mode, resource_provider);
256 } 256 }
257 257
258 void DelegatedRendererLayerImpl::AppendQuads( 258 void DelegatedRendererLayerImpl::AppendQuads(
259 QuadSink* quad_sink, 259 RenderPass* render_pass,
260 const OcclusionTracker<LayerImpl>& occlusion_tracker,
260 AppendQuadsData* append_quads_data) { 261 AppendQuadsData* append_quads_data) {
261 AppendRainbowDebugBorder(quad_sink, append_quads_data); 262 AppendRainbowDebugBorder(render_pass, append_quads_data);
262 263
263 // This list will be empty after a lost context until a new frame arrives. 264 // This list will be empty after a lost context until a new frame arrives.
264 if (render_passes_in_draw_order_.empty()) 265 if (render_passes_in_draw_order_.empty())
265 return; 266 return;
266 267
267 RenderPass::Id target_render_pass_id = append_quads_data->render_pass_id; 268 RenderPass::Id target_render_pass_id = append_quads_data->render_pass_id;
268 269
269 const RenderPass* root_delegated_render_pass = 270 const RenderPass* root_delegated_render_pass =
270 render_passes_in_draw_order_.back(); 271 render_passes_in_draw_order_.back();
271 272
272 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin()); 273 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin());
273 gfx::Size frame_size = root_delegated_render_pass->output_rect.size(); 274 gfx::Size frame_size = root_delegated_render_pass->output_rect.size();
274 275
275 // If the index of the RenderPassId is 0, then it is a RenderPass generated 276 // If the index of the RenderPassId is 0, then it is a RenderPass generated
276 // for a layer in this compositor, not the delegating renderer. Then we want 277 // for a layer in this compositor, not the delegating renderer. Then we want
277 // to merge our root RenderPass with the target RenderPass. Otherwise, it is 278 // to merge our root RenderPass with the target RenderPass. Otherwise, it is
278 // some RenderPass which we added from the delegating renderer. 279 // some RenderPass which we added from the delegating renderer.
279 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index; 280 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index;
280 if (should_merge_root_render_pass_with_target) { 281 if (should_merge_root_render_pass_with_target) {
281 // Verify that the RenderPass we are appending to is created by our 282 // Verify that the RenderPass we are appending to is created by our
282 // render_target. 283 // render_target.
283 DCHECK(target_render_pass_id.layer_id == render_target()->id()); 284 DCHECK(target_render_pass_id.layer_id == render_target()->id());
284 285
285 AppendRenderPassQuads( 286 AppendRenderPassQuads(render_pass,
286 quad_sink, append_quads_data, root_delegated_render_pass, frame_size); 287 occlusion_tracker,
288 append_quads_data,
289 root_delegated_render_pass,
290 frame_size);
287 } else { 291 } else {
288 // Verify that the RenderPass we are appending to was created by us. 292 // Verify that the RenderPass we are appending to was created by us.
289 DCHECK(target_render_pass_id.layer_id == id()); 293 DCHECK(target_render_pass_id.layer_id == id());
290 294
291 int render_pass_index = IdToIndex(target_render_pass_id.index); 295 int render_pass_index = IdToIndex(target_render_pass_id.index);
292 const RenderPass* delegated_render_pass = 296 const RenderPass* delegated_render_pass =
293 render_passes_in_draw_order_[render_pass_index]; 297 render_passes_in_draw_order_[render_pass_index];
294 AppendRenderPassQuads( 298 AppendRenderPassQuads(render_pass,
295 quad_sink, append_quads_data, delegated_render_pass, frame_size); 299 occlusion_tracker,
300 append_quads_data,
301 delegated_render_pass,
302 frame_size);
296 } 303 }
297 } 304 }
298 305
299 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder( 306 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder(
300 QuadSink* quad_sink, 307 RenderPass* render_pass,
301 AppendQuadsData* append_quads_data) { 308 AppendQuadsData* append_quads_data) {
302 if (!ShowDebugBorders()) 309 if (!ShowDebugBorders())
303 return; 310 return;
304 311
305 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); 312 SharedQuadState* shared_quad_state =
313 render_pass->CreateAndAppendSharedQuadState();
306 PopulateSharedQuadState(shared_quad_state); 314 PopulateSharedQuadState(shared_quad_state);
307 315
308 SkColor color; 316 SkColor color;
309 float border_width; 317 float border_width;
310 GetDebugBorderProperties(&color, &border_width); 318 GetDebugBorderProperties(&color, &border_width);
311 319
312 SkColor colors[] = { 320 SkColor colors[] = {
313 0x80ff0000, // Red. 321 0x80ff0000, // Red.
314 0x80ffa500, // Orange. 322 0x80ffa500, // Orange.
315 0x80ffff00, // Yellow. 323 0x80ffff00, // Yellow.
(...skipping 26 matching lines...) Expand all
342 border_width, 350 border_width,
343 height); 351 height);
344 352
345 if (top.IsEmpty() && left.IsEmpty()) 353 if (top.IsEmpty() && left.IsEmpty())
346 break; 354 break;
347 355
348 if (!top.IsEmpty()) { 356 if (!top.IsEmpty()) {
349 scoped_ptr<SolidColorDrawQuad> top_quad = SolidColorDrawQuad::Create(); 357 scoped_ptr<SolidColorDrawQuad> top_quad = SolidColorDrawQuad::Create();
350 top_quad->SetNew( 358 top_quad->SetNew(
351 shared_quad_state, top, top, colors[i % kNumColors], false); 359 shared_quad_state, top, top, colors[i % kNumColors], false);
352 quad_sink->Append(top_quad.PassAs<DrawQuad>()); 360 render_pass->AppendDrawQuad(top_quad.PassAs<DrawQuad>());
353 361
354 scoped_ptr<SolidColorDrawQuad> bottom_quad = SolidColorDrawQuad::Create(); 362 scoped_ptr<SolidColorDrawQuad> bottom_quad = SolidColorDrawQuad::Create();
355 bottom_quad->SetNew(shared_quad_state, 363 bottom_quad->SetNew(shared_quad_state,
356 bottom, 364 bottom,
357 bottom, 365 bottom,
358 colors[kNumColors - 1 - (i % kNumColors)], 366 colors[kNumColors - 1 - (i % kNumColors)],
359 false); 367 false);
360 quad_sink->Append(bottom_quad.PassAs<DrawQuad>()); 368 render_pass->AppendDrawQuad(bottom_quad.PassAs<DrawQuad>());
361 } 369 }
362 if (!left.IsEmpty()) { 370 if (!left.IsEmpty()) {
363 scoped_ptr<SolidColorDrawQuad> left_quad = SolidColorDrawQuad::Create(); 371 scoped_ptr<SolidColorDrawQuad> left_quad = SolidColorDrawQuad::Create();
364 left_quad->SetNew(shared_quad_state, 372 left_quad->SetNew(shared_quad_state,
365 left, 373 left,
366 left, 374 left,
367 colors[kNumColors - 1 - (i % kNumColors)], 375 colors[kNumColors - 1 - (i % kNumColors)],
368 false); 376 false);
369 quad_sink->Append(left_quad.PassAs<DrawQuad>()); 377 render_pass->AppendDrawQuad(left_quad.PassAs<DrawQuad>());
370 378
371 scoped_ptr<SolidColorDrawQuad> right_quad = SolidColorDrawQuad::Create(); 379 scoped_ptr<SolidColorDrawQuad> right_quad = SolidColorDrawQuad::Create();
372 right_quad->SetNew( 380 right_quad->SetNew(
373 shared_quad_state, right, right, colors[i % kNumColors], false); 381 shared_quad_state, right, right, colors[i % kNumColors], false);
374 quad_sink->Append(right_quad.PassAs<DrawQuad>()); 382 render_pass->AppendDrawQuad(right_quad.PassAs<DrawQuad>());
375 } 383 }
376 } 384 }
377 } 385 }
378 386
379 void DelegatedRendererLayerImpl::AppendRenderPassQuads( 387 void DelegatedRendererLayerImpl::AppendRenderPassQuads(
380 QuadSink* quad_sink, 388 RenderPass* render_pass,
389 const OcclusionTracker<LayerImpl>& occlusion_tracker,
381 AppendQuadsData* append_quads_data, 390 AppendQuadsData* append_quads_data,
382 const RenderPass* delegated_render_pass, 391 const RenderPass* delegated_render_pass,
383 const gfx::Size& frame_size) const { 392 const gfx::Size& frame_size) const {
384
385 const SharedQuadState* delegated_shared_quad_state = NULL; 393 const SharedQuadState* delegated_shared_quad_state = NULL;
386 SharedQuadState* output_shared_quad_state = NULL; 394 SharedQuadState* output_shared_quad_state = NULL;
387 395
388 for (size_t i = 0; i < delegated_render_pass->quad_list.size(); ++i) { 396 for (size_t i = 0; i < delegated_render_pass->quad_list.size(); ++i) {
389 const DrawQuad* delegated_quad = delegated_render_pass->quad_list[i]; 397 const DrawQuad* delegated_quad = delegated_render_pass->quad_list[i];
390 398
391 if (delegated_quad->shared_quad_state != delegated_shared_quad_state) { 399 if (delegated_quad->shared_quad_state != delegated_shared_quad_state) {
392 delegated_shared_quad_state = delegated_quad->shared_quad_state; 400 delegated_shared_quad_state = delegated_quad->shared_quad_state;
393 output_shared_quad_state = quad_sink->CreateSharedQuadState(); 401 output_shared_quad_state = render_pass->CreateAndAppendSharedQuadState();
394 output_shared_quad_state->CopyFrom(delegated_shared_quad_state); 402 output_shared_quad_state->CopyFrom(delegated_shared_quad_state);
395 403
396 bool is_root_delegated_render_pass = 404 bool is_root_delegated_render_pass =
397 delegated_render_pass == render_passes_in_draw_order_.back(); 405 delegated_render_pass == render_passes_in_draw_order_.back();
398 if (is_root_delegated_render_pass) { 406 if (is_root_delegated_render_pass) {
399 gfx::Transform delegated_frame_to_target_transform = draw_transform(); 407 gfx::Transform delegated_frame_to_target_transform = draw_transform();
400 delegated_frame_to_target_transform.Scale(inverse_device_scale_factor_, 408 delegated_frame_to_target_transform.Scale(inverse_device_scale_factor_,
401 inverse_device_scale_factor_); 409 inverse_device_scale_factor_);
402 410
403 output_shared_quad_state->content_to_target_transform.ConcatTransform( 411 output_shared_quad_state->content_to_target_transform.ConcatTransform(
(...skipping 16 matching lines...) Expand all
420 } 428 }
421 output_shared_quad_state->clip_rect = clip_rect; 429 output_shared_quad_state->clip_rect = clip_rect;
422 output_shared_quad_state->is_clipped = true; 430 output_shared_quad_state->is_clipped = true;
423 } 431 }
424 432
425 output_shared_quad_state->opacity *= draw_opacity(); 433 output_shared_quad_state->opacity *= draw_opacity();
426 } 434 }
427 } 435 }
428 DCHECK(output_shared_quad_state); 436 DCHECK(output_shared_quad_state);
429 437
430 gfx::Rect quad_visible_rect = quad_sink->UnoccludedContentRect( 438 gfx::Rect quad_visible_rect = occlusion_tracker.UnoccludedContentRect(
431 delegated_quad->visible_rect, 439 delegated_quad->visible_rect,
432 output_shared_quad_state->content_to_target_transform); 440 output_shared_quad_state->content_to_target_transform);
433 if (quad_visible_rect.IsEmpty()) 441 if (quad_visible_rect.IsEmpty())
434 continue; 442 continue;
435 443
436 scoped_ptr<DrawQuad> output_quad; 444 scoped_ptr<DrawQuad> output_quad;
437 if (delegated_quad->material != DrawQuad::RENDER_PASS) { 445 if (delegated_quad->material != DrawQuad::RENDER_PASS) {
438 output_quad = delegated_quad->Copy(output_shared_quad_state); 446 output_quad = delegated_quad->Copy(output_shared_quad_state);
439 output_quad->visible_rect = quad_visible_rect; 447 output_quad->visible_rect = quad_visible_rect;
440 } else { 448 } else {
(...skipping 12 matching lines...) Expand all
453 append_quads_data->render_pass_id); 461 append_quads_data->render_pass_id);
454 462
455 output_quad = RenderPassDrawQuad::MaterialCast(delegated_quad)->Copy( 463 output_quad = RenderPassDrawQuad::MaterialCast(delegated_quad)->Copy(
456 output_shared_quad_state, 464 output_shared_quad_state,
457 output_contributing_render_pass_id).PassAs<DrawQuad>(); 465 output_contributing_render_pass_id).PassAs<DrawQuad>();
458 output_quad->visible_rect = quad_visible_rect; 466 output_quad->visible_rect = quad_visible_rect;
459 } 467 }
460 } 468 }
461 469
462 if (output_quad) 470 if (output_quad)
463 quad_sink->Append(output_quad.Pass()); 471 render_pass->AppendDrawQuad(output_quad.Pass());
464 } 472 }
465 } 473 }
466 474
467 const char* DelegatedRendererLayerImpl::LayerTypeAsString() const { 475 const char* DelegatedRendererLayerImpl::LayerTypeAsString() const {
468 return "cc::DelegatedRendererLayerImpl"; 476 return "cc::DelegatedRendererLayerImpl";
469 } 477 }
470 478
471 void DelegatedRendererLayerImpl::ClearChildId() { 479 void DelegatedRendererLayerImpl::ClearChildId() {
472 if (!child_id_) 480 if (!child_id_)
473 return; 481 return;
474 482
475 if (own_child_id_) { 483 if (own_child_id_) {
476 ResourceProvider* provider = layer_tree_impl()->resource_provider(); 484 ResourceProvider* provider = layer_tree_impl()->resource_provider();
477 provider->DestroyChild(child_id_); 485 provider->DestroyChild(child_id_);
478 } 486 }
479 487
480 resources_.clear(); 488 resources_.clear();
481 child_id_ = 0; 489 child_id_ = 0;
482 } 490 }
483 491
484 } // namespace cc 492 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.h ('k') | cc/layers/delegated_renderer_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698