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

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

Issue 633773004: cc: Pass Occlusion instead of OcclusionTracker to LayerImpls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 6 years, 2 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/layers/delegated_renderer_layer_impl.h ('k') | cc/layers/heads_up_display_layer_impl.h » ('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 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/render_pass_sink.h" 14 #include "cc/layers/render_pass_sink.h"
15 #include "cc/output/delegated_frame_data.h" 15 #include "cc/output/delegated_frame_data.h"
16 #include "cc/quads/render_pass_draw_quad.h" 16 #include "cc/quads/render_pass_draw_quad.h"
17 #include "cc/quads/solid_color_draw_quad.h" 17 #include "cc/quads/solid_color_draw_quad.h"
18 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
19 #include "cc/trees/occlusion_tracker.h" 19 #include "cc/trees/occlusion.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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 bool DelegatedRendererLayerImpl::WillDraw(DrawMode draw_mode, 248 bool DelegatedRendererLayerImpl::WillDraw(DrawMode draw_mode,
249 ResourceProvider* resource_provider) { 249 ResourceProvider* resource_provider) {
250 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) 250 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
251 return false; 251 return false;
252 return LayerImpl::WillDraw(draw_mode, resource_provider); 252 return LayerImpl::WillDraw(draw_mode, resource_provider);
253 } 253 }
254 254
255 void DelegatedRendererLayerImpl::AppendQuads( 255 void DelegatedRendererLayerImpl::AppendQuads(
256 RenderPass* render_pass, 256 RenderPass* render_pass,
257 const OcclusionTracker<LayerImpl>& occlusion_tracker, 257 const Occlusion& occlusion_in_content_space,
258 AppendQuadsData* append_quads_data) { 258 AppendQuadsData* append_quads_data) {
259 AppendRainbowDebugBorder(render_pass, append_quads_data); 259 AppendRainbowDebugBorder(render_pass, append_quads_data);
260 260
261 // This list will be empty after a lost context until a new frame arrives. 261 // This list will be empty after a lost context until a new frame arrives.
262 if (render_passes_in_draw_order_.empty()) 262 if (render_passes_in_draw_order_.empty())
263 return; 263 return;
264 264
265 RenderPassId target_render_pass_id = append_quads_data->render_pass_id; 265 RenderPassId target_render_pass_id = append_quads_data->render_pass_id;
266 266
267 const RenderPass* root_delegated_render_pass = 267 const RenderPass* root_delegated_render_pass =
268 render_passes_in_draw_order_.back(); 268 render_passes_in_draw_order_.back();
269 269
270 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin()); 270 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin());
271 gfx::Size frame_size = root_delegated_render_pass->output_rect.size(); 271 gfx::Size frame_size = root_delegated_render_pass->output_rect.size();
272 272
273 // If the index of the RenderPassId is 0, then it is a RenderPass generated 273 // If the index of the RenderPassId is 0, then it is a RenderPass generated
274 // for a layer in this compositor, not the delegating renderer. Then we want 274 // for a layer in this compositor, not the delegating renderer. Then we want
275 // to merge our root RenderPass with the target RenderPass. Otherwise, it is 275 // to merge our root RenderPass with the target RenderPass. Otherwise, it is
276 // some RenderPass which we added from the delegating renderer. 276 // some RenderPass which we added from the delegating renderer.
277 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index; 277 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index;
278 if (should_merge_root_render_pass_with_target) { 278 if (should_merge_root_render_pass_with_target) {
279 // Verify that the RenderPass we are appending to is created by our 279 // Verify that the RenderPass we are appending to is created by our
280 // render_target. 280 // render_target.
281 DCHECK(target_render_pass_id.layer_id == render_target()->id()); 281 DCHECK(target_render_pass_id.layer_id == render_target()->id());
282 282
283 AppendRenderPassQuads(render_pass, 283 AppendRenderPassQuads(render_pass,
284 occlusion_tracker, 284 occlusion_in_content_space,
285 append_quads_data, 285 append_quads_data,
286 root_delegated_render_pass, 286 root_delegated_render_pass,
287 frame_size); 287 frame_size);
288 } else { 288 } else {
289 // Verify that the RenderPass we are appending to was created by us. 289 // Verify that the RenderPass we are appending to was created by us.
290 DCHECK(target_render_pass_id.layer_id == id()); 290 DCHECK(target_render_pass_id.layer_id == id());
291 291
292 int render_pass_index = IdToIndex(target_render_pass_id.index); 292 int render_pass_index = IdToIndex(target_render_pass_id.index);
293 const RenderPass* delegated_render_pass = 293 const RenderPass* delegated_render_pass =
294 render_passes_in_draw_order_[render_pass_index]; 294 render_passes_in_draw_order_[render_pass_index];
295 AppendRenderPassQuads(render_pass, 295 AppendRenderPassQuads(render_pass,
296 occlusion_tracker, 296 occlusion_in_content_space,
297 append_quads_data, 297 append_quads_data,
298 delegated_render_pass, 298 delegated_render_pass,
299 frame_size); 299 frame_size);
300 } 300 }
301 } 301 }
302 302
303 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder( 303 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder(
304 RenderPass* render_pass, 304 RenderPass* render_pass,
305 AppendQuadsData* append_quads_data) { 305 AppendQuadsData* append_quads_data) {
306 if (!ShowDebugBorders()) 306 if (!ShowDebugBorders())
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 SolidColorDrawQuad* right_quad = 376 SolidColorDrawQuad* right_quad =
377 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 377 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
378 right_quad->SetNew( 378 right_quad->SetNew(
379 shared_quad_state, right, right, colors[i % kNumColors], false); 379 shared_quad_state, right, right, colors[i % kNumColors], false);
380 } 380 }
381 } 381 }
382 } 382 }
383 383
384 void DelegatedRendererLayerImpl::AppendRenderPassQuads( 384 void DelegatedRendererLayerImpl::AppendRenderPassQuads(
385 RenderPass* render_pass, 385 RenderPass* render_pass,
386 const OcclusionTracker<LayerImpl>& occlusion_tracker, 386 const Occlusion& occlusion_in_content_space,
387 AppendQuadsData* append_quads_data, 387 AppendQuadsData* append_quads_data,
388 const RenderPass* delegated_render_pass, 388 const RenderPass* delegated_render_pass,
389 const gfx::Size& frame_size) const { 389 const gfx::Size& frame_size) const {
390 const SharedQuadState* delegated_shared_quad_state = NULL; 390 const SharedQuadState* delegated_shared_quad_state = NULL;
391 SharedQuadState* output_shared_quad_state = NULL; 391 SharedQuadState* output_shared_quad_state = NULL;
392 392
393 for (const auto& delegated_quad : delegated_render_pass->quad_list) { 393 for (const auto& delegated_quad : delegated_render_pass->quad_list) {
394 bool is_root_delegated_render_pass = 394 bool is_root_delegated_render_pass =
395 delegated_render_pass == render_passes_in_draw_order_.back(); 395 delegated_render_pass == render_passes_in_draw_order_.back();
396 396
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 DCHECK(output_shared_quad_state); 432 DCHECK(output_shared_quad_state);
433 433
434 gfx::Transform quad_content_to_delegated_target_space = 434 gfx::Transform quad_content_to_delegated_target_space =
435 output_shared_quad_state->content_to_target_transform; 435 output_shared_quad_state->content_to_target_transform;
436 if (!is_root_delegated_render_pass) { 436 if (!is_root_delegated_render_pass) {
437 quad_content_to_delegated_target_space.ConcatTransform( 437 quad_content_to_delegated_target_space.ConcatTransform(
438 delegated_render_pass->transform_to_root_target); 438 delegated_render_pass->transform_to_root_target);
439 quad_content_to_delegated_target_space.ConcatTransform(draw_transform()); 439 quad_content_to_delegated_target_space.ConcatTransform(draw_transform());
440 } 440 }
441 441
442 Occlusion occlusion_in_quad_space =
443 occlusion_in_content_space.GetOcclusionWithGivenDrawTransform(
444 quad_content_to_delegated_target_space);
445
442 gfx::Rect quad_visible_rect = 446 gfx::Rect quad_visible_rect =
443 occlusion_tracker.GetCurrentOcclusionForLayer( 447 occlusion_in_quad_space.GetUnoccludedContentRect(
444 quad_content_to_delegated_target_space) 448 delegated_quad.visible_rect);
445 .GetUnoccludedContentRect(delegated_quad.visible_rect);
446 449
447 if (quad_visible_rect.IsEmpty()) 450 if (quad_visible_rect.IsEmpty())
448 continue; 451 continue;
449 452
450 if (delegated_quad.material != DrawQuad::RENDER_PASS) { 453 if (delegated_quad.material != DrawQuad::RENDER_PASS) {
451 DrawQuad* output_quad = render_pass->CopyFromAndAppendDrawQuad( 454 DrawQuad* output_quad = render_pass->CopyFromAndAppendDrawQuad(
452 &delegated_quad, output_shared_quad_state); 455 &delegated_quad, output_shared_quad_state);
453 output_quad->visible_rect = quad_visible_rect; 456 output_quad->visible_rect = quad_visible_rect;
454 } else { 457 } else {
455 RenderPassId delegated_contributing_render_pass_id = 458 RenderPassId delegated_contributing_render_pass_id =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 if (own_child_id_) { 491 if (own_child_id_) {
489 ResourceProvider* provider = layer_tree_impl()->resource_provider(); 492 ResourceProvider* provider = layer_tree_impl()->resource_provider();
490 provider->DestroyChild(child_id_); 493 provider->DestroyChild(child_id_);
491 } 494 }
492 495
493 resources_.clear(); 496 resources_.clear();
494 child_id_ = 0; 497 child_id_ = 0;
495 } 498 }
496 499
497 } // namespace cc 500 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.h ('k') | cc/layers/heads_up_display_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698