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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "ui/gfx/geometry/point_conversions.h" | 49 #include "ui/gfx/geometry/point_conversions.h" |
50 #include "ui/gfx/geometry/rect_conversions.h" | 50 #include "ui/gfx/geometry/rect_conversions.h" |
51 #include "ui/gfx/geometry/size_conversions.h" | 51 #include "ui/gfx/geometry/size_conversions.h" |
52 #include "ui/gfx/geometry/vector2d_conversions.h" | 52 #include "ui/gfx/geometry/vector2d_conversions.h" |
53 | 53 |
54 namespace cc { | 54 namespace cc { |
55 | 55 |
56 LayerTreeImpl::LayerTreeImpl( | 56 LayerTreeImpl::LayerTreeImpl( |
57 LayerTreeHostImpl* layer_tree_host_impl, | 57 LayerTreeHostImpl* layer_tree_host_impl, |
58 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 58 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
59 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 59 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio, |
60 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 60 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
61 : layer_tree_host_impl_(layer_tree_host_impl), | 61 : layer_tree_host_impl_(layer_tree_host_impl), |
62 source_frame_number_(-1), | 62 source_frame_number_(-1), |
63 is_first_frame_after_commit_tracker_(-1), | 63 is_first_frame_after_commit_tracker_(-1), |
64 root_layer_for_testing_(nullptr), | 64 root_layer_for_testing_(nullptr), |
65 hud_layer_(nullptr), | 65 hud_layer_(nullptr), |
66 background_color_(0), | 66 background_color_(0), |
67 has_transparent_background_(false), | 67 has_transparent_background_(false), |
68 last_scrolled_layer_id_(Layer::INVALID_ID), | 68 last_scrolled_layer_id_(Layer::INVALID_ID), |
69 overscroll_elasticity_layer_id_(Layer::INVALID_ID), | 69 overscroll_elasticity_layer_id_(Layer::INVALID_ID), |
70 page_scale_layer_id_(Layer::INVALID_ID), | 70 page_scale_layer_id_(Layer::INVALID_ID), |
71 inner_viewport_scroll_layer_id_(Layer::INVALID_ID), | 71 inner_viewport_scroll_layer_id_(Layer::INVALID_ID), |
72 outer_viewport_scroll_layer_id_(Layer::INVALID_ID), | 72 outer_viewport_scroll_layer_id_(Layer::INVALID_ID), |
73 page_scale_factor_(page_scale_factor), | 73 page_scale_factor_(page_scale_factor), |
74 min_page_scale_factor_(0), | 74 min_page_scale_factor_(0), |
75 max_page_scale_factor_(0), | 75 max_page_scale_factor_(0), |
76 device_scale_factor_(1.f), | 76 device_scale_factor_(1.f), |
77 painted_device_scale_factor_(1.f), | 77 painted_device_scale_factor_(1.f), |
78 elastic_overscroll_(elastic_overscroll), | 78 elastic_overscroll_(elastic_overscroll), |
79 layers_(new OwnedLayerImplList), | 79 layers_(new OwnedLayerImplList), |
80 viewport_size_invalid_(false), | 80 viewport_size_invalid_(false), |
81 needs_update_draw_properties_(true), | 81 needs_update_draw_properties_(true), |
82 needs_full_tree_sync_(true), | 82 needs_full_tree_sync_(true), |
83 next_activation_forces_redraw_(false), | 83 next_activation_forces_redraw_(false), |
84 has_ever_been_drawn_(false), | 84 has_ever_been_drawn_(false), |
85 have_scroll_event_handlers_(false), | 85 have_scroll_event_handlers_(false), |
86 event_listener_properties_(), | 86 event_listener_properties_(), |
87 top_controls_shrink_blink_size_(false), | 87 browser_controls_shrink_blink_size_(false), |
88 top_controls_height_(0), | 88 top_controls_height_(0), |
89 bottom_controls_height_(0), | 89 bottom_controls_height_(0), |
90 top_controls_shown_ratio_(top_controls_shown_ratio) { | 90 top_controls_shown_ratio_(top_controls_shown_ratio) { |
91 property_trees()->is_main_thread = false; | 91 property_trees()->is_main_thread = false; |
92 } | 92 } |
93 | 93 |
94 LayerTreeImpl::~LayerTreeImpl() { | 94 LayerTreeImpl::~LayerTreeImpl() { |
95 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS | 95 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS |
96 : SwapPromise::ACTIVATION_FAILS); | 96 : SwapPromise::ACTIVATION_FAILS); |
97 | 97 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // The request queue should have been processed and does not require a push. | 412 // The request queue should have been processed and does not require a push. |
413 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); | 413 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); |
414 | 414 |
415 LayerImpl* layer = target_tree->CurrentlyScrollingLayer(); | 415 LayerImpl* layer = target_tree->CurrentlyScrollingLayer(); |
416 target_tree->SetPropertyTrees(&property_trees_); | 416 target_tree->SetPropertyTrees(&property_trees_); |
417 target_tree->SetCurrentlyScrollingLayer(layer); | 417 target_tree->SetCurrentlyScrollingLayer(layer); |
418 target_tree->UpdatePropertyTreeScrollOffset(&property_trees_); | 418 target_tree->UpdatePropertyTreeScrollOffset(&property_trees_); |
419 | 419 |
420 // This needs to be called early so that we don't clamp with incorrect max | 420 // This needs to be called early so that we don't clamp with incorrect max |
421 // offsets when UpdateViewportContainerSizes is called from e.g. | 421 // offsets when UpdateViewportContainerSizes is called from e.g. |
422 // PushTopControls | 422 // PushBrowserControls |
423 target_tree->UpdatePropertyTreesForBoundsDelta(); | 423 target_tree->UpdatePropertyTreesForBoundsDelta(); |
424 | 424 |
425 if (next_activation_forces_redraw_) { | 425 if (next_activation_forces_redraw_) { |
426 target_tree->ForceRedrawNextActivation(); | 426 target_tree->ForceRedrawNextActivation(); |
427 next_activation_forces_redraw_ = false; | 427 next_activation_forces_redraw_ = false; |
428 } | 428 } |
429 | 429 |
430 target_tree->PassSwapPromises(std::move(swap_promise_list_)); | 430 target_tree->PassSwapPromises(std::move(swap_promise_list_)); |
431 swap_promise_list_.clear(); | 431 swap_promise_list_.clear(); |
432 | 432 |
433 target_tree->set_top_controls_shrink_blink_size( | 433 target_tree->set_browser_controls_shrink_blink_size( |
434 top_controls_shrink_blink_size_); | 434 browser_controls_shrink_blink_size_); |
435 target_tree->set_top_controls_height(top_controls_height_); | 435 target_tree->set_top_controls_height(top_controls_height_); |
436 target_tree->set_bottom_controls_height(bottom_controls_height_); | 436 target_tree->set_bottom_controls_height(bottom_controls_height_); |
437 target_tree->PushTopControls(nullptr); | 437 target_tree->PushBrowserControls(nullptr); |
438 | 438 |
439 // Active tree already shares the page_scale_factor object with pending | 439 // Active tree already shares the page_scale_factor object with pending |
440 // tree so only the limits need to be provided. | 440 // tree so only the limits need to be provided. |
441 target_tree->PushPageScaleFactorAndLimits(nullptr, min_page_scale_factor(), | 441 target_tree->PushPageScaleFactorAndLimits(nullptr, min_page_scale_factor(), |
442 max_page_scale_factor()); | 442 max_page_scale_factor()); |
443 target_tree->SetDeviceScaleFactor(device_scale_factor()); | 443 target_tree->SetDeviceScaleFactor(device_scale_factor()); |
444 target_tree->set_painted_device_scale_factor(painted_device_scale_factor()); | 444 target_tree->set_painted_device_scale_factor(painted_device_scale_factor()); |
445 target_tree->SetDeviceColorSpace(device_color_space_); | 445 target_tree->SetDeviceColorSpace(device_color_space_); |
446 target_tree->elastic_overscroll()->PushPendingToActive(); | 446 target_tree->elastic_overscroll()->PushPendingToActive(); |
447 | 447 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 if (PageScaleLayer()) { | 762 if (PageScaleLayer()) { |
763 draw_property_utils::UpdatePageScaleFactor( | 763 draw_property_utils::UpdatePageScaleFactor( |
764 property_trees(), PageScaleLayer(), current_page_scale_factor(), | 764 property_trees(), PageScaleLayer(), current_page_scale_factor(), |
765 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); | 765 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); |
766 } else { | 766 } else { |
767 DCHECK(layer_list_.empty() || *page_scale_factor == 1); | 767 DCHECK(layer_list_.empty() || *page_scale_factor == 1); |
768 } | 768 } |
769 } | 769 } |
770 } | 770 } |
771 | 771 |
772 void LayerTreeImpl::set_top_controls_shrink_blink_size(bool shrink) { | 772 void LayerTreeImpl::set_browser_controls_shrink_blink_size(bool shrink) { |
773 if (top_controls_shrink_blink_size_ == shrink) | 773 if (browser_controls_shrink_blink_size_ == shrink) |
774 return; | 774 return; |
775 | 775 |
776 top_controls_shrink_blink_size_ = shrink; | 776 browser_controls_shrink_blink_size_ = shrink; |
777 if (IsActiveTree()) | 777 if (IsActiveTree()) |
778 layer_tree_host_impl_->UpdateViewportContainerSizes(); | 778 layer_tree_host_impl_->UpdateViewportContainerSizes(); |
779 } | 779 } |
780 | 780 |
781 void LayerTreeImpl::set_top_controls_height(float top_controls_height) { | 781 void LayerTreeImpl::set_top_controls_height(float top_controls_height) { |
782 if (top_controls_height_ == top_controls_height) | 782 if (top_controls_height_ == top_controls_height) |
783 return; | 783 return; |
784 | 784 |
785 top_controls_height_ = top_controls_height; | 785 top_controls_height_ = top_controls_height; |
786 if (IsActiveTree()) | 786 if (IsActiveTree()) |
787 layer_tree_host_impl_->UpdateViewportContainerSizes(); | 787 layer_tree_host_impl_->UpdateViewportContainerSizes(); |
788 } | 788 } |
789 | 789 |
790 void LayerTreeImpl::set_bottom_controls_height(float bottom_controls_height) { | 790 void LayerTreeImpl::set_bottom_controls_height(float bottom_controls_height) { |
791 if (bottom_controls_height_ == bottom_controls_height) | 791 if (bottom_controls_height_ == bottom_controls_height) |
792 return; | 792 return; |
793 | 793 |
794 bottom_controls_height_ = bottom_controls_height; | 794 bottom_controls_height_ = bottom_controls_height; |
795 if (IsActiveTree()) | 795 if (IsActiveTree()) |
796 layer_tree_host_impl_->UpdateViewportContainerSizes(); | 796 layer_tree_host_impl_->UpdateViewportContainerSizes(); |
797 } | 797 } |
798 | 798 |
799 bool LayerTreeImpl::ClampTopControlsShownRatio() { | 799 bool LayerTreeImpl::ClampBrowserControlsShownRatio() { |
800 float ratio = top_controls_shown_ratio_->Current(true); | 800 float ratio = top_controls_shown_ratio_->Current(true); |
801 ratio = std::max(ratio, 0.f); | 801 ratio = std::max(ratio, 0.f); |
802 ratio = std::min(ratio, 1.f); | 802 ratio = std::min(ratio, 1.f); |
803 return top_controls_shown_ratio_->SetCurrent(ratio); | 803 return top_controls_shown_ratio_->SetCurrent(ratio); |
804 } | 804 } |
805 | 805 |
806 bool LayerTreeImpl::SetCurrentTopControlsShownRatio(float ratio) { | 806 bool LayerTreeImpl::SetCurrentBrowserControlsShownRatio(float ratio) { |
807 bool changed = top_controls_shown_ratio_->SetCurrent(ratio); | 807 bool changed = top_controls_shown_ratio_->SetCurrent(ratio); |
808 changed |= ClampTopControlsShownRatio(); | 808 changed |= ClampBrowserControlsShownRatio(); |
809 return changed; | 809 return changed; |
810 } | 810 } |
811 | 811 |
812 void LayerTreeImpl::PushTopControlsFromMainThread( | 812 void LayerTreeImpl::PushBrowserControlsFromMainThread( |
813 float top_controls_shown_ratio) { | 813 float top_controls_shown_ratio) { |
814 PushTopControls(&top_controls_shown_ratio); | 814 PushBrowserControls(&top_controls_shown_ratio); |
815 } | 815 } |
816 | 816 |
817 void LayerTreeImpl::PushTopControls(const float* top_controls_shown_ratio) { | 817 void LayerTreeImpl::PushBrowserControls(const float* top_controls_shown_ratio) { |
818 DCHECK(top_controls_shown_ratio || IsActiveTree()); | 818 DCHECK(top_controls_shown_ratio || IsActiveTree()); |
819 | 819 |
820 if (top_controls_shown_ratio) { | 820 if (top_controls_shown_ratio) { |
821 DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree()); | 821 DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree()); |
822 top_controls_shown_ratio_->PushFromMainThread(*top_controls_shown_ratio); | 822 top_controls_shown_ratio_->PushFromMainThread(*top_controls_shown_ratio); |
823 } | 823 } |
824 if (IsActiveTree()) { | 824 if (IsActiveTree()) { |
825 bool changed_active = top_controls_shown_ratio_->PushPendingToActive(); | 825 bool changed_active = top_controls_shown_ratio_->PushPendingToActive(); |
826 changed_active |= ClampTopControlsShownRatio(); | 826 changed_active |= ClampBrowserControlsShownRatio(); |
827 if (changed_active) | 827 if (changed_active) |
828 layer_tree_host_impl_->DidChangeTopControlsPosition(); | 828 layer_tree_host_impl_->DidChangeBrowserControlsPosition(); |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor, | 832 bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor, |
833 float max_page_scale_factor) { | 833 float max_page_scale_factor) { |
834 if (min_page_scale_factor == min_page_scale_factor_ && | 834 if (min_page_scale_factor == min_page_scale_factor_ && |
835 max_page_scale_factor == max_page_scale_factor_) | 835 max_page_scale_factor == max_page_scale_factor_) |
836 return false; | 836 return false; |
837 | 837 |
838 min_page_scale_factor_ = min_page_scale_factor; | 838 min_page_scale_factor_ = min_page_scale_factor; |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 | 2076 |
2077 void LayerTreeImpl::ResetAllChangeTracking() { | 2077 void LayerTreeImpl::ResetAllChangeTracking() { |
2078 layers_that_should_push_properties_.clear(); | 2078 layers_that_should_push_properties_.clear(); |
2079 // Iterate over all layers, including masks. | 2079 // Iterate over all layers, including masks. |
2080 for (auto& layer : *layers_) | 2080 for (auto& layer : *layers_) |
2081 layer->ResetChangeTracking(); | 2081 layer->ResetChangeTracking(); |
2082 property_trees_.ResetAllChangeTracking(); | 2082 property_trees_.ResetAllChangeTracking(); |
2083 } | 2083 } |
2084 | 2084 |
2085 } // namespace cc | 2085 } // namespace cc |
OLD | NEW |