| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 7 #include <limits> | 8 #include <limits> |
| 8 #include <set> | 9 #include <set> |
| 9 | 10 |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
| 12 #include "cc/animation/keyframed_animation_curve.h" | 13 #include "cc/animation/keyframed_animation_curve.h" |
| 13 #include "cc/animation/scrollbar_animation_controller.h" | 14 #include "cc/animation/scrollbar_animation_controller.h" |
| 14 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 15 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
| 15 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 16 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
| 16 #include "cc/base/math_util.h" | 17 #include "cc/base/math_util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 private: | 70 private: |
| 70 LayerImpl* layer_; | 71 LayerImpl* layer_; |
| 71 LayerScrollOffsetDelegate* delegate_; | 72 LayerScrollOffsetDelegate* delegate_; |
| 72 LayerTreeImpl* layer_tree_impl_; | 73 LayerTreeImpl* layer_tree_impl_; |
| 73 gfx::ScrollOffset last_set_scroll_offset_; | 74 gfx::ScrollOffset last_set_scroll_offset_; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 LayerTreeImpl::LayerTreeImpl( | 77 LayerTreeImpl::LayerTreeImpl( |
| 77 LayerTreeHostImpl* layer_tree_host_impl, | 78 LayerTreeHostImpl* layer_tree_host_impl, |
| 78 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 79 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
| 80 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
| 79 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 81 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
| 80 : layer_tree_host_impl_(layer_tree_host_impl), | 82 : layer_tree_host_impl_(layer_tree_host_impl), |
| 81 source_frame_number_(-1), | 83 source_frame_number_(-1), |
| 82 hud_layer_(0), | 84 hud_layer_(0), |
| 83 currently_scrolling_layer_(NULL), | 85 currently_scrolling_layer_(NULL), |
| 84 root_layer_scroll_offset_delegate_(NULL), | 86 root_layer_scroll_offset_delegate_(NULL), |
| 85 background_color_(0), | 87 background_color_(0), |
| 86 has_transparent_background_(false), | 88 has_transparent_background_(false), |
| 87 overscroll_elasticity_layer_(NULL), | 89 overscroll_elasticity_layer_(NULL), |
| 88 page_scale_layer_(NULL), | 90 page_scale_layer_(NULL), |
| 89 inner_viewport_scroll_layer_(NULL), | 91 inner_viewport_scroll_layer_(NULL), |
| 90 outer_viewport_scroll_layer_(NULL), | 92 outer_viewport_scroll_layer_(NULL), |
| 91 page_scale_factor_(page_scale_factor), | 93 page_scale_factor_(page_scale_factor), |
| 92 min_page_scale_factor_(0), | 94 min_page_scale_factor_(0), |
| 93 max_page_scale_factor_(0), | 95 max_page_scale_factor_(0), |
| 94 elastic_overscroll_(elastic_overscroll), | 96 elastic_overscroll_(elastic_overscroll), |
| 95 scrolling_layer_id_from_previous_tree_(0), | 97 scrolling_layer_id_from_previous_tree_(0), |
| 96 contents_textures_purged_(false), | 98 contents_textures_purged_(false), |
| 97 viewport_size_invalid_(false), | 99 viewport_size_invalid_(false), |
| 98 needs_update_draw_properties_(true), | 100 needs_update_draw_properties_(true), |
| 99 needs_full_tree_sync_(true), | 101 needs_full_tree_sync_(true), |
| 100 next_activation_forces_redraw_(false), | 102 next_activation_forces_redraw_(false), |
| 101 has_ever_been_drawn_(false), | 103 has_ever_been_drawn_(false), |
| 102 render_surface_layer_list_id_(0), | 104 render_surface_layer_list_id_(0), |
| 103 top_controls_shrink_blink_size_(false), | 105 top_controls_shrink_blink_size_(false), |
| 104 top_controls_height_(0), | 106 top_controls_height_(0), |
| 105 top_controls_content_offset_(0), | 107 top_controls_shown_ratio_(top_controls_shown_ratio) { |
| 106 top_controls_delta_(0), | |
| 107 sent_top_controls_delta_(0) { | |
| 108 } | 108 } |
| 109 | 109 |
| 110 LayerTreeImpl::~LayerTreeImpl() { | 110 LayerTreeImpl::~LayerTreeImpl() { |
| 111 BreakSwapPromises(SwapPromise::SWAP_FAILS); | 111 BreakSwapPromises(SwapPromise::SWAP_FAILS); |
| 112 | 112 |
| 113 // Need to explicitly clear the tree prior to destroying this so that | 113 // Need to explicitly clear the tree prior to destroying this so that |
| 114 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. | 114 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
| 115 DCHECK(!root_layer_); | 115 DCHECK(!root_layer_); |
| 116 DCHECK(layers_with_copy_output_request_.empty()); | 116 DCHECK(layers_with_copy_output_request_.empty()); |
| 117 } | 117 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // The request queue should have been processed and does not require a push. | 203 // The request queue should have been processed and does not require a push. |
| 204 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); | 204 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); |
| 205 | 205 |
| 206 if (next_activation_forces_redraw_) { | 206 if (next_activation_forces_redraw_) { |
| 207 target_tree->ForceRedrawNextActivation(); | 207 target_tree->ForceRedrawNextActivation(); |
| 208 next_activation_forces_redraw_ = false; | 208 next_activation_forces_redraw_ = false; |
| 209 } | 209 } |
| 210 | 210 |
| 211 target_tree->PassSwapPromises(&swap_promise_list_); | 211 target_tree->PassSwapPromises(&swap_promise_list_); |
| 212 | 212 |
| 213 // Track the change in top controls height to offset the top_controls_delta | 213 target_tree->set_top_controls_shrink_blink_size( |
| 214 // properly. This is so that the top controls offset will be maintained | 214 top_controls_shrink_blink_size_); |
| 215 // across height changes. | 215 target_tree->set_top_controls_height(top_controls_height_); |
| 216 float top_controls_height_delta = | 216 target_tree->PushTopControls(nullptr); |
| 217 target_tree->top_controls_height_ - top_controls_height_; | |
| 218 | |
| 219 target_tree->top_controls_shrink_blink_size_ = | |
| 220 top_controls_shrink_blink_size_; | |
| 221 target_tree->top_controls_height_ = top_controls_height_; | |
| 222 target_tree->top_controls_content_offset_ = top_controls_content_offset_; | |
| 223 target_tree->top_controls_delta_ = target_tree->top_controls_delta_ - | |
| 224 target_tree->sent_top_controls_delta_ - | |
| 225 top_controls_height_delta; | |
| 226 target_tree->sent_top_controls_delta_ = 0.f; | |
| 227 | 217 |
| 228 // Active tree already shares the page_scale_factor object with pending | 218 // Active tree already shares the page_scale_factor object with pending |
| 229 // tree so only the limits need to be provided. | 219 // tree so only the limits need to be provided. |
| 230 target_tree->PushPageScaleFactorAndLimits(nullptr, min_page_scale_factor(), | 220 target_tree->PushPageScaleFactorAndLimits(nullptr, min_page_scale_factor(), |
| 231 max_page_scale_factor()); | 221 max_page_scale_factor()); |
| 232 target_tree->elastic_overscroll()->PushPendingToActive(); | 222 target_tree->elastic_overscroll()->PushPendingToActive(); |
| 233 | 223 |
| 234 target_tree->pending_page_scale_animation_ = | 224 target_tree->pending_page_scale_animation_ = |
| 235 pending_page_scale_animation_.Pass(); | 225 pending_page_scale_animation_.Pass(); |
| 236 | 226 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 347 } |
| 358 if (IsActiveTree()) | 348 if (IsActiveTree()) |
| 359 changed_page_scale |= page_scale_factor_->PushPendingToActive(); | 349 changed_page_scale |= page_scale_factor_->PushPendingToActive(); |
| 360 changed_page_scale |= | 350 changed_page_scale |= |
| 361 SetPageScaleFactorLimits(min_page_scale_factor, max_page_scale_factor); | 351 SetPageScaleFactorLimits(min_page_scale_factor, max_page_scale_factor); |
| 362 | 352 |
| 363 if (changed_page_scale) | 353 if (changed_page_scale) |
| 364 DidUpdatePageScale(); | 354 DidUpdatePageScale(); |
| 365 } | 355 } |
| 366 | 356 |
| 357 void LayerTreeImpl::set_top_controls_shrink_blink_size(bool shrink) { |
| 358 if (top_controls_shrink_blink_size_ == shrink) |
| 359 return; |
| 360 |
| 361 top_controls_shrink_blink_size_ = shrink; |
| 362 if (IsActiveTree()) |
| 363 layer_tree_host_impl_->UpdateViewportContainerSizes(); |
| 364 } |
| 365 |
| 366 void LayerTreeImpl::set_top_controls_height(float top_controls_height) { |
| 367 if (top_controls_height_ == top_controls_height) |
| 368 return; |
| 369 |
| 370 top_controls_height_ = top_controls_height; |
| 371 if (IsActiveTree()) |
| 372 layer_tree_host_impl_->UpdateViewportContainerSizes(); |
| 373 } |
| 374 |
| 375 bool LayerTreeImpl::SetCurrentTopControlsShownRatio(float ratio) { |
| 376 ratio = std::max(ratio, 0.f); |
| 377 ratio = std::min(ratio, 1.f); |
| 378 return top_controls_shown_ratio_->SetCurrent(ratio); |
| 379 } |
| 380 |
| 381 void LayerTreeImpl::PushTopControlsFromMainThread( |
| 382 float top_controls_shown_ratio) { |
| 383 PushTopControls(&top_controls_shown_ratio); |
| 384 } |
| 385 |
| 386 void LayerTreeImpl::PushTopControls(const float* top_controls_shown_ratio) { |
| 387 DCHECK(top_controls_shown_ratio || IsActiveTree()); |
| 388 |
| 389 if (top_controls_shown_ratio) { |
| 390 DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree()); |
| 391 top_controls_shown_ratio_->PushFromMainThread(*top_controls_shown_ratio); |
| 392 } |
| 393 if (IsActiveTree()) { |
| 394 if (top_controls_shown_ratio_->PushPendingToActive()) |
| 395 layer_tree_host_impl_->DidChangeTopControlsPosition(); |
| 396 } |
| 397 } |
| 398 |
| 367 bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor, | 399 bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor, |
| 368 float max_page_scale_factor) { | 400 float max_page_scale_factor) { |
| 369 if (min_page_scale_factor == min_page_scale_factor_ && | 401 if (min_page_scale_factor == min_page_scale_factor_ && |
| 370 max_page_scale_factor == max_page_scale_factor_) | 402 max_page_scale_factor == max_page_scale_factor_) |
| 371 return false; | 403 return false; |
| 372 | 404 |
| 373 min_page_scale_factor_ = min_page_scale_factor; | 405 min_page_scale_factor_ = min_page_scale_factor; |
| 374 max_page_scale_factor_ = max_page_scale_factor; | 406 max_page_scale_factor_ = max_page_scale_factor; |
| 375 | 407 |
| 376 return true; | 408 return true; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 476 } |
| 445 | 477 |
| 446 static void ApplySentScrollDeltasFromAbortedCommitTo(LayerImpl* layer) { | 478 static void ApplySentScrollDeltasFromAbortedCommitTo(LayerImpl* layer) { |
| 447 layer->ApplySentScrollDeltasFromAbortedCommit(); | 479 layer->ApplySentScrollDeltasFromAbortedCommit(); |
| 448 } | 480 } |
| 449 | 481 |
| 450 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { | 482 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { |
| 451 DCHECK(IsActiveTree()); | 483 DCHECK(IsActiveTree()); |
| 452 | 484 |
| 453 page_scale_factor()->AbortCommit(); | 485 page_scale_factor()->AbortCommit(); |
| 486 top_controls_shown_ratio()->AbortCommit(); |
| 454 elastic_overscroll()->AbortCommit(); | 487 elastic_overscroll()->AbortCommit(); |
| 455 | 488 |
| 456 top_controls_content_offset_ += sent_top_controls_delta_; | |
| 457 top_controls_delta_ -= sent_top_controls_delta_; | |
| 458 sent_top_controls_delta_ = 0.f; | |
| 459 | |
| 460 if (!root_layer()) | 489 if (!root_layer()) |
| 461 return; | 490 return; |
| 462 | 491 |
| 463 LayerTreeHostCommon::CallFunctionForSubtree( | 492 LayerTreeHostCommon::CallFunctionForSubtree( |
| 464 root_layer(), base::Bind(&ApplySentScrollDeltasFromAbortedCommitTo)); | 493 root_layer(), base::Bind(&ApplySentScrollDeltasFromAbortedCommitTo)); |
| 465 } | 494 } |
| 466 | 495 |
| 467 void LayerTreeImpl::SetViewportLayersFromIds( | 496 void LayerTreeImpl::SetViewportLayersFromIds( |
| 468 int overscroll_elasticity_layer_id, | 497 int overscroll_elasticity_layer_id, |
| 469 int page_scale_layer_id, | 498 int page_scale_layer_id, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (!layer_tree_host_impl_->renderer()) | 542 if (!layer_tree_host_impl_->renderer()) |
| 514 return false; | 543 return false; |
| 515 | 544 |
| 516 if (!root_layer()) | 545 if (!root_layer()) |
| 517 return false; | 546 return false; |
| 518 | 547 |
| 519 needs_update_draw_properties_ = false; | 548 needs_update_draw_properties_ = false; |
| 520 render_surface_layer_list_.clear(); | 549 render_surface_layer_list_.clear(); |
| 521 | 550 |
| 522 { | 551 { |
| 523 TRACE_EVENT2("cc", | 552 TRACE_EVENT2( |
| 524 "LayerTreeImpl::UpdateDrawProperties", | 553 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties", |
| 525 "IsActive", | 554 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_); |
| 526 IsActiveTree(), | |
| 527 "SourceFrameNumber", | |
| 528 source_frame_number_); | |
| 529 LayerImpl* page_scale_layer = | 555 LayerImpl* page_scale_layer = |
| 530 page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); | 556 page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); |
| 531 bool can_render_to_separate_surface = | 557 bool can_render_to_separate_surface = |
| 532 (layer_tree_host_impl_->GetDrawMode() != | 558 (layer_tree_host_impl_->GetDrawMode() != |
| 533 DRAW_MODE_RESOURCELESS_SOFTWARE); | 559 DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 534 | 560 |
| 535 ++render_surface_layer_list_id_; | 561 ++render_surface_layer_list_id_; |
| 536 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( | 562 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( |
| 537 root_layer(), DrawViewportSize(), | 563 root_layer(), DrawViewportSize(), |
| 538 layer_tree_host_impl_->DrawTransform(), device_scale_factor(), | 564 layer_tree_host_impl_->DrawTransform(), device_scale_factor(), |
| 539 current_page_scale_factor(), page_scale_layer, | 565 current_page_scale_factor(), page_scale_layer, |
| 540 elastic_overscroll()->Current(IsActiveTree()), | 566 elastic_overscroll()->Current(IsActiveTree()), |
| 541 overscroll_elasticity_layer_, resource_provider()->max_texture_size(), | 567 overscroll_elasticity_layer_, resource_provider()->max_texture_size(), |
| 542 settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text, | 568 settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text, |
| 543 can_render_to_separate_surface, | 569 can_render_to_separate_surface, |
| 544 settings().layer_transforms_should_scale_layer_contents, | 570 settings().layer_transforms_should_scale_layer_contents, |
| 545 settings().verify_property_trees, | 571 settings().verify_property_trees, |
| 546 &render_surface_layer_list_, render_surface_layer_list_id_); | 572 &render_surface_layer_list_, render_surface_layer_list_id_); |
| 547 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 573 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 548 } | 574 } |
| 549 | 575 |
| 550 { | 576 { |
| 551 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateTilePriorities", "IsActive", | 577 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", |
| 552 IsActiveTree(), "SourceFrameNumber", | 578 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 553 source_frame_number_); | 579 source_frame_number_); |
| 554 scoped_ptr<OcclusionTracker<LayerImpl>> occlusion_tracker; | 580 OcclusionTracker<LayerImpl> occlusion_tracker( |
| 555 if (settings().use_occlusion_for_tile_prioritization) { | 581 root_layer()->render_surface()->content_rect()); |
| 556 occlusion_tracker.reset(new OcclusionTracker<LayerImpl>( | 582 occlusion_tracker.set_minimum_tracking_size( |
| 557 root_layer()->render_surface()->content_rect())); | 583 settings().minimum_occlusion_tracking_size); |
| 558 occlusion_tracker->set_minimum_tracking_size( | |
| 559 settings().minimum_occlusion_tracking_size); | |
| 560 } | |
| 561 | |
| 562 bool resourceless_software_draw = (layer_tree_host_impl_->GetDrawMode() == | |
| 563 DRAW_MODE_RESOURCELESS_SOFTWARE); | |
| 564 | 584 |
| 565 // LayerIterator is used here instead of CallFunctionForSubtree to only | 585 // LayerIterator is used here instead of CallFunctionForSubtree to only |
| 566 // UpdateTilePriorities on layers that will be visible (and thus have valid | 586 // UpdateTilePriorities on layers that will be visible (and thus have valid |
| 567 // draw properties) and not because any ordering is required. | 587 // draw properties) and not because any ordering is required. |
| 568 typedef LayerIterator<LayerImpl> LayerIteratorType; | 588 auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list_); |
| 569 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); | 589 for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list_); |
| 590 it != end; ++it) { |
| 591 occlusion_tracker.EnterLayer(it); |
| 592 |
| 593 // There are very few render targets so this should be cheap to do for |
| 594 // each layer instead of something more complicated. |
| 595 bool inside_replica = false; |
| 596 LayerImpl* layer = it->render_target(); |
| 597 while (layer && !inside_replica) { |
| 598 if (layer->render_target()->has_replica()) |
| 599 inside_replica = true; |
| 600 layer = layer->render_target()->parent(); |
| 601 } |
| 602 |
| 603 // Don't use occlusion if a layer will appear in a replica, since the |
| 604 // tile raster code does not know how to look for the replica and would |
| 605 // consider it occluded even though the replica is visible. |
| 606 // Since occlusion is only used for browser compositor (i.e. |
| 607 // use_occlusion_for_tile_prioritization) and it won't use replicas, |
| 608 // this should matter not. |
| 609 |
| 610 if (it.represents_itself()) { |
| 611 Occlusion occlusion = |
| 612 inside_replica ? Occlusion() |
| 613 : occlusion_tracker.GetCurrentOcclusionForLayer( |
| 614 it->draw_transform()); |
| 615 it->draw_properties().occlusion_in_content_space = occlusion; |
| 616 } |
| 617 |
| 618 if (it.represents_contributing_render_surface()) { |
| 619 // Surfaces aren't used by the tile raster code, so they can have |
| 620 // occlusion regardless of replicas. |
| 621 Occlusion occlusion = |
| 622 occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
| 623 it->render_surface()->draw_transform()); |
| 624 it->render_surface()->set_occlusion_in_content_space(occlusion); |
| 625 // Masks are used to draw the contributing surface, so should have |
| 626 // the same occlusion as the surface (nothing inside the surface |
| 627 // occludes them). |
| 628 if (LayerImpl* mask = it->mask_layer()) { |
| 629 Occlusion mask_occlusion = |
| 630 inside_replica |
| 631 ? Occlusion() |
| 632 : occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
| 633 it->render_surface()->draw_transform() * |
| 634 it->draw_transform()); |
| 635 mask->draw_properties().occlusion_in_content_space = mask_occlusion; |
| 636 } |
| 637 if (LayerImpl* replica = it->replica_layer()) { |
| 638 if (LayerImpl* mask = replica->mask_layer()) |
| 639 mask->draw_properties().occlusion_in_content_space = Occlusion(); |
| 640 } |
| 641 } |
| 642 |
| 643 occlusion_tracker.LeaveLayer(it); |
| 644 } |
| 645 |
| 646 unoccluded_screen_space_region_ = |
| 647 occlusion_tracker.ComputeVisibleRegionInScreen(); |
| 648 } |
| 649 |
| 650 { |
| 651 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
| 652 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 653 source_frame_number_); |
| 654 const bool resourceless_software_draw = |
| 655 (layer_tree_host_impl_->GetDrawMode() == |
| 656 DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 570 size_t layers_updated_count = 0; | 657 size_t layers_updated_count = 0; |
| 571 bool tile_priorities_updated = false; | 658 bool tile_priorities_updated = false; |
| 572 for (LayerIteratorType it = | 659 for (PictureLayerImpl* layer : picture_layers_) { |
| 573 LayerIteratorType::Begin(&render_surface_layer_list_); | 660 if (!layer->IsDrawnRenderSurfaceLayerListMember()) |
| 574 it != end; | |
| 575 ++it) { | |
| 576 if (occlusion_tracker) | |
| 577 occlusion_tracker->EnterLayer(it); | |
| 578 | |
| 579 LayerImpl* layer = *it; | |
| 580 const Occlusion& occlusion_in_content_space = | |
| 581 occlusion_tracker ? occlusion_tracker->GetCurrentOcclusionForLayer( | |
| 582 layer->draw_transform()) | |
| 583 : Occlusion(); | |
| 584 | |
| 585 if (it.represents_itself()) { | |
| 586 tile_priorities_updated |= layer->UpdateTiles( | |
| 587 occlusion_in_content_space, resourceless_software_draw); | |
| 588 ++layers_updated_count; | |
| 589 } | |
| 590 | |
| 591 if (!it.represents_contributing_render_surface()) { | |
| 592 if (occlusion_tracker) | |
| 593 occlusion_tracker->LeaveLayer(it); | |
| 594 continue; | 661 continue; |
| 595 } | 662 ++layers_updated_count; |
| 596 | 663 tile_priorities_updated |= layer->UpdateTiles(resourceless_software_draw); |
| 597 if (layer->mask_layer()) { | |
| 598 tile_priorities_updated |= layer->mask_layer()->UpdateTiles( | |
| 599 occlusion_in_content_space, resourceless_software_draw); | |
| 600 ++layers_updated_count; | |
| 601 } | |
| 602 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { | |
| 603 tile_priorities_updated |= | |
| 604 layer->replica_layer()->mask_layer()->UpdateTiles( | |
| 605 occlusion_in_content_space, resourceless_software_draw); | |
| 606 ++layers_updated_count; | |
| 607 } | |
| 608 | |
| 609 if (occlusion_tracker) | |
| 610 occlusion_tracker->LeaveLayer(it); | |
| 611 } | 664 } |
| 612 | 665 |
| 613 if (tile_priorities_updated) | 666 if (tile_priorities_updated) |
| 614 DidModifyTilePriorities(); | 667 DidModifyTilePriorities(); |
| 615 | 668 |
| 616 TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateTilePriorities", | 669 TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateTilePriorities", |
| 617 "layers_updated_count", layers_updated_count); | 670 "layers_updated_count", layers_updated_count); |
| 618 } | 671 } |
| 619 | 672 |
| 620 DCHECK(!needs_update_draw_properties_) << | 673 DCHECK(!needs_update_draw_properties_) << |
| 621 "CalcDrawProperties should not set_needs_update_draw_properties()"; | 674 "CalcDrawProperties should not set_needs_update_draw_properties()"; |
| 622 return true; | 675 return true; |
| 623 } | 676 } |
| 624 | 677 |
| 625 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { | 678 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { |
| 626 // If this assert triggers, then the list is dirty. | 679 // If this assert triggers, then the list is dirty. |
| 627 DCHECK(!needs_update_draw_properties_); | 680 DCHECK(!needs_update_draw_properties_); |
| 628 return render_surface_layer_list_; | 681 return render_surface_layer_list_; |
| 629 } | 682 } |
| 630 | 683 |
| 684 const Region& LayerTreeImpl::UnoccludedScreenSpaceRegion() const { |
| 685 // If this assert triggers, then the render_surface_layer_list_ is dirty, so |
| 686 // the unoccluded_screen_space_region_ is not valid anymore. |
| 687 DCHECK(!needs_update_draw_properties_); |
| 688 return unoccluded_screen_space_region_; |
| 689 } |
| 690 |
| 631 gfx::Size LayerTreeImpl::ScrollableSize() const { | 691 gfx::Size LayerTreeImpl::ScrollableSize() const { |
| 632 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 692 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 633 ? OuterViewportScrollLayer() | 693 ? OuterViewportScrollLayer() |
| 634 : InnerViewportScrollLayer(); | 694 : InnerViewportScrollLayer(); |
| 635 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 695 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
| 636 return gfx::Size(); | 696 return gfx::Size(); |
| 637 return root_scroll_layer->children()[0]->bounds(); | 697 return root_scroll_layer->children()[0]->bounds(); |
| 638 } | 698 } |
| 639 | 699 |
| 640 LayerImpl* LayerTreeImpl::LayerById(int id) { | 700 LayerImpl* LayerTreeImpl::LayerById(int id) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 792 } |
| 733 | 793 |
| 734 Proxy* LayerTreeImpl::proxy() const { | 794 Proxy* LayerTreeImpl::proxy() const { |
| 735 return layer_tree_host_impl_->proxy(); | 795 return layer_tree_host_impl_->proxy(); |
| 736 } | 796 } |
| 737 | 797 |
| 738 const LayerTreeSettings& LayerTreeImpl::settings() const { | 798 const LayerTreeSettings& LayerTreeImpl::settings() const { |
| 739 return layer_tree_host_impl_->settings(); | 799 return layer_tree_host_impl_->settings(); |
| 740 } | 800 } |
| 741 | 801 |
| 802 const LayerTreeDebugState& LayerTreeImpl::debug_state() const { |
| 803 return layer_tree_host_impl_->debug_state(); |
| 804 } |
| 805 |
| 742 const RendererCapabilitiesImpl& LayerTreeImpl::GetRendererCapabilities() const { | 806 const RendererCapabilitiesImpl& LayerTreeImpl::GetRendererCapabilities() const { |
| 743 return layer_tree_host_impl_->GetRendererCapabilities(); | 807 return layer_tree_host_impl_->GetRendererCapabilities(); |
| 744 } | 808 } |
| 745 | 809 |
| 746 ContextProvider* LayerTreeImpl::context_provider() const { | 810 ContextProvider* LayerTreeImpl::context_provider() const { |
| 747 return output_surface()->context_provider(); | 811 return output_surface()->context_provider(); |
| 748 } | 812 } |
| 749 | 813 |
| 750 OutputSurface* LayerTreeImpl::output_surface() const { | 814 OutputSurface* LayerTreeImpl::output_surface() const { |
| 751 return layer_tree_host_impl_->output_surface(); | 815 return layer_tree_host_impl_->output_surface(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 768 } | 832 } |
| 769 | 833 |
| 770 MemoryHistory* LayerTreeImpl::memory_history() const { | 834 MemoryHistory* LayerTreeImpl::memory_history() const { |
| 771 return layer_tree_host_impl_->memory_history(); | 835 return layer_tree_host_impl_->memory_history(); |
| 772 } | 836 } |
| 773 | 837 |
| 774 gfx::Size LayerTreeImpl::device_viewport_size() const { | 838 gfx::Size LayerTreeImpl::device_viewport_size() const { |
| 775 return layer_tree_host_impl_->device_viewport_size(); | 839 return layer_tree_host_impl_->device_viewport_size(); |
| 776 } | 840 } |
| 777 | 841 |
| 842 float LayerTreeImpl::device_scale_factor() const { |
| 843 return layer_tree_host_impl_->device_scale_factor(); |
| 844 } |
| 845 |
| 846 DebugRectHistory* LayerTreeImpl::debug_rect_history() const { |
| 847 return layer_tree_host_impl_->debug_rect_history(); |
| 848 } |
| 849 |
| 778 bool LayerTreeImpl::IsActiveTree() const { | 850 bool LayerTreeImpl::IsActiveTree() const { |
| 779 return layer_tree_host_impl_->active_tree() == this; | 851 return layer_tree_host_impl_->active_tree() == this; |
| 780 } | 852 } |
| 781 | 853 |
| 782 bool LayerTreeImpl::IsPendingTree() const { | 854 bool LayerTreeImpl::IsPendingTree() const { |
| 783 return layer_tree_host_impl_->pending_tree() == this; | 855 return layer_tree_host_impl_->pending_tree() == this; |
| 784 } | 856 } |
| 785 | 857 |
| 786 bool LayerTreeImpl::IsRecycleTree() const { | 858 bool LayerTreeImpl::IsRecycleTree() const { |
| 787 return layer_tree_host_impl_->recycle_tree() == this; | 859 return layer_tree_host_impl_->recycle_tree() == this; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 } | 947 } |
| 876 | 948 |
| 877 bool LayerTreeImpl::create_low_res_tiling() const { | 949 bool LayerTreeImpl::create_low_res_tiling() const { |
| 878 return layer_tree_host_impl_->create_low_res_tiling(); | 950 return layer_tree_host_impl_->create_low_res_tiling(); |
| 879 } | 951 } |
| 880 | 952 |
| 881 void LayerTreeImpl::SetNeedsRedraw() { | 953 void LayerTreeImpl::SetNeedsRedraw() { |
| 882 layer_tree_host_impl_->SetNeedsRedraw(); | 954 layer_tree_host_impl_->SetNeedsRedraw(); |
| 883 } | 955 } |
| 884 | 956 |
| 885 const LayerTreeDebugState& LayerTreeImpl::debug_state() const { | |
| 886 return layer_tree_host_impl_->debug_state(); | |
| 887 } | |
| 888 | |
| 889 float LayerTreeImpl::device_scale_factor() const { | |
| 890 return layer_tree_host_impl_->device_scale_factor(); | |
| 891 } | |
| 892 | |
| 893 DebugRectHistory* LayerTreeImpl::debug_rect_history() const { | |
| 894 return layer_tree_host_impl_->debug_rect_history(); | |
| 895 } | |
| 896 | |
| 897 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { | 957 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { |
| 898 return layer_tree_host_impl_->animation_registrar(); | 958 return layer_tree_host_impl_->animation_registrar(); |
| 899 } | 959 } |
| 900 | 960 |
| 901 void LayerTreeImpl::GetAllTilesForTracing(std::set<const Tile*>* tiles) const { | 961 void LayerTreeImpl::GetAllTilesForTracing(std::set<const Tile*>* tiles) const { |
| 902 typedef LayerIterator<LayerImpl> LayerIteratorType; | 962 typedef LayerIterator<LayerImpl> LayerIteratorType; |
| 903 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); | 963 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| 904 for (LayerIteratorType it = | 964 for (LayerIteratorType it = |
| 905 LayerIteratorType::Begin(&render_surface_layer_list_); | 965 LayerIteratorType::Begin(&render_surface_layer_list_); |
| 906 it != end; | 966 it != end; |
| 907 ++it) { | 967 ++it) { |
| 908 if (!it.represents_itself()) | 968 if (!it.represents_itself()) |
| 909 continue; | 969 continue; |
| 910 LayerImpl* layer_impl = *it; | 970 LayerImpl* layer_impl = *it; |
| 911 layer_impl->GetAllTilesForTracing(tiles); | 971 layer_impl->GetAllTilesForTracing(tiles); |
| 912 } | 972 } |
| 913 } | 973 } |
| 914 | 974 |
| 915 void LayerTreeImpl::AsValueInto(base::debug::TracedValue* state) const { | 975 void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const { |
| 916 TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); | 976 TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); |
| 917 state->SetInteger("source_frame_number", source_frame_number_); | 977 state->SetInteger("source_frame_number", source_frame_number_); |
| 918 | 978 |
| 919 state->BeginDictionary("root_layer"); | 979 state->BeginDictionary("root_layer"); |
| 920 root_layer_->AsValueInto(state); | 980 root_layer_->AsValueInto(state); |
| 921 state->EndDictionary(); | 981 state->EndDictionary(); |
| 922 | 982 |
| 923 state->BeginArray("render_surface_layer_list"); | 983 state->BeginArray("render_surface_layer_list"); |
| 924 typedef LayerIterator<LayerImpl> LayerIteratorType; | 984 typedef LayerIterator<LayerImpl> LayerIteratorType; |
| 925 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); | 985 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 } | 1173 } |
| 1114 } | 1174 } |
| 1115 ui_resource_request_queue_.clear(); | 1175 ui_resource_request_queue_.clear(); |
| 1116 | 1176 |
| 1117 // If all UI resource evictions were not recreated by processing this queue, | 1177 // If all UI resource evictions were not recreated by processing this queue, |
| 1118 // then another commit is required. | 1178 // then another commit is required. |
| 1119 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 1179 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
| 1120 layer_tree_host_impl_->SetNeedsCommit(); | 1180 layer_tree_host_impl_->SetNeedsCommit(); |
| 1121 } | 1181 } |
| 1122 | 1182 |
| 1183 void LayerTreeImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 1184 DCHECK(std::find(picture_layers_.begin(), picture_layers_.end(), layer) == |
| 1185 picture_layers_.end()); |
| 1186 picture_layers_.push_back(layer); |
| 1187 } |
| 1188 |
| 1189 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 1190 std::vector<PictureLayerImpl*>::iterator it = |
| 1191 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 1192 DCHECK(it != picture_layers_.end()); |
| 1193 picture_layers_.erase(it); |
| 1194 } |
| 1195 |
| 1123 void LayerTreeImpl::AddLayerWithCopyOutputRequest(LayerImpl* layer) { | 1196 void LayerTreeImpl::AddLayerWithCopyOutputRequest(LayerImpl* layer) { |
| 1124 // Only the active tree needs to know about layers with copy requests, as | 1197 // Only the active tree needs to know about layers with copy requests, as |
| 1125 // they are aborted if not serviced during draw. | 1198 // they are aborted if not serviced during draw. |
| 1126 DCHECK(IsActiveTree()); | 1199 DCHECK(IsActiveTree()); |
| 1127 | 1200 |
| 1128 // DCHECK(std::find(layers_with_copy_output_request_.begin(), | 1201 // DCHECK(std::find(layers_with_copy_output_request_.begin(), |
| 1129 // layers_with_copy_output_request_.end(), | 1202 // layers_with_copy_output_request_.end(), |
| 1130 // layer) == layers_with_copy_output_request_.end()); | 1203 // layer) == layers_with_copy_output_request_.end()); |
| 1131 // TODO(danakj): Remove this once crash is found crbug.com/309777 | 1204 // TODO(danakj): Remove this once crash is found crbug.com/309777 |
| 1132 for (size_t i = 0; i < layers_with_copy_output_request_.size(); ++i) { | 1205 for (size_t i = 0; i < layers_with_copy_output_request_.size(); ++i) { |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 start->type == SELECTION_BOUND_EMPTY) { | 1598 start->type == SELECTION_BOUND_EMPTY) { |
| 1526 *end = *start; | 1599 *end = *start; |
| 1527 } else { | 1600 } else { |
| 1528 *end = ComputeViewportSelection( | 1601 *end = ComputeViewportSelection( |
| 1529 selection_end_, | 1602 selection_end_, |
| 1530 selection_end_.layer_id ? LayerById(selection_end_.layer_id) : NULL, | 1603 selection_end_.layer_id ? LayerById(selection_end_.layer_id) : NULL, |
| 1531 device_scale_factor()); | 1604 device_scale_factor()); |
| 1532 } | 1605 } |
| 1533 } | 1606 } |
| 1534 | 1607 |
| 1535 void LayerTreeImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { | |
| 1536 layer_tree_host_impl_->RegisterPictureLayerImpl(layer); | |
| 1537 } | |
| 1538 | |
| 1539 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | |
| 1540 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer); | |
| 1541 } | |
| 1542 | |
| 1543 void LayerTreeImpl::InputScrollAnimationFinished() { | 1608 void LayerTreeImpl::InputScrollAnimationFinished() { |
| 1544 layer_tree_host_impl_->ScrollEnd(); | 1609 layer_tree_host_impl_->ScrollEnd(); |
| 1545 } | 1610 } |
| 1546 | 1611 |
| 1547 bool LayerTreeImpl::SmoothnessTakesPriority() const { | 1612 bool LayerTreeImpl::SmoothnessTakesPriority() const { |
| 1548 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; | 1613 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; |
| 1549 } | 1614 } |
| 1550 | 1615 |
| 1551 BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const { | 1616 BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const { |
| 1552 return proxy()->blocking_main_thread_task_runner(); | 1617 return proxy()->blocking_main_thread_task_runner(); |
| 1553 } | 1618 } |
| 1554 | 1619 |
| 1555 void LayerTreeImpl::SetPendingPageScaleAnimation( | 1620 void LayerTreeImpl::SetPendingPageScaleAnimation( |
| 1556 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1621 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1557 pending_page_scale_animation_ = pending_animation.Pass(); | 1622 pending_page_scale_animation_ = pending_animation.Pass(); |
| 1558 } | 1623 } |
| 1559 | 1624 |
| 1560 scoped_ptr<PendingPageScaleAnimation> | 1625 scoped_ptr<PendingPageScaleAnimation> |
| 1561 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1626 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1562 return pending_page_scale_animation_.Pass(); | 1627 return pending_page_scale_animation_.Pass(); |
| 1563 } | 1628 } |
| 1564 | 1629 |
| 1565 } // namespace cc | 1630 } // namespace cc |
| OLD | NEW |