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

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 2090223002: Clamp compositor's top controls shown ratio on commit from main thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clamp from helper method Created 4 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
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 715
716 void LayerTreeImpl::set_top_controls_height(float top_controls_height) { 716 void LayerTreeImpl::set_top_controls_height(float top_controls_height) {
717 if (top_controls_height_ == top_controls_height) 717 if (top_controls_height_ == top_controls_height)
718 return; 718 return;
719 719
720 top_controls_height_ = top_controls_height; 720 top_controls_height_ = top_controls_height;
721 if (IsActiveTree()) 721 if (IsActiveTree())
722 layer_tree_host_impl_->UpdateViewportContainerSizes(); 722 layer_tree_host_impl_->UpdateViewportContainerSizes();
723 } 723 }
724 724
725 bool LayerTreeImpl::SetCurrentTopControlsShownRatio(float ratio) { 725 bool LayerTreeImpl::ClampTopControlsShownRatio() {
726 float ratio = top_controls_shown_ratio_->Current(true);
726 ratio = std::max(ratio, 0.f); 727 ratio = std::max(ratio, 0.f);
727 ratio = std::min(ratio, 1.f); 728 ratio = std::min(ratio, 1.f);
728 return top_controls_shown_ratio_->SetCurrent(ratio); 729 return top_controls_shown_ratio_->SetCurrent(ratio);
729 } 730 }
730 731
732 bool LayerTreeImpl::SetCurrentTopControlsShownRatio(float ratio) {
733 bool changed = top_controls_shown_ratio_->SetCurrent(ratio);
734 changed |= ClampTopControlsShownRatio();
735 return changed;
736 }
737
731 void LayerTreeImpl::PushTopControlsFromMainThread( 738 void LayerTreeImpl::PushTopControlsFromMainThread(
732 float top_controls_shown_ratio) { 739 float top_controls_shown_ratio) {
733 PushTopControls(&top_controls_shown_ratio); 740 PushTopControls(&top_controls_shown_ratio);
734 } 741 }
735 742
736 void LayerTreeImpl::PushTopControls(const float* top_controls_shown_ratio) { 743 void LayerTreeImpl::PushTopControls(const float* top_controls_shown_ratio) {
737 DCHECK(top_controls_shown_ratio || IsActiveTree()); 744 DCHECK(top_controls_shown_ratio || IsActiveTree());
738 745
739 if (top_controls_shown_ratio) { 746 if (top_controls_shown_ratio) {
740 DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree()); 747 DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree());
741 top_controls_shown_ratio_->PushFromMainThread(*top_controls_shown_ratio); 748 top_controls_shown_ratio_->PushFromMainThread(*top_controls_shown_ratio);
742 } 749 }
743 if (IsActiveTree()) { 750 if (IsActiveTree()) {
744 if (top_controls_shown_ratio_->PushPendingToActive()) 751 bool changed_active = top_controls_shown_ratio_->PushPendingToActive();
752 changed_active |= ClampTopControlsShownRatio();
753 if (changed_active)
745 layer_tree_host_impl_->DidChangeTopControlsPosition(); 754 layer_tree_host_impl_->DidChangeTopControlsPosition();
746 } 755 }
747 } 756 }
748 757
749 bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor, 758 bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor,
750 float max_page_scale_factor) { 759 float max_page_scale_factor) {
751 if (min_page_scale_factor == min_page_scale_factor_ && 760 if (min_page_scale_factor == min_page_scale_factor_ &&
752 max_page_scale_factor == max_page_scale_factor_) 761 max_page_scale_factor == max_page_scale_factor_)
753 return false; 762 return false;
754 763
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 2095
2087 void LayerTreeImpl::ResetAllChangeTracking() { 2096 void LayerTreeImpl::ResetAllChangeTracking() {
2088 layers_that_should_push_properties_.clear(); 2097 layers_that_should_push_properties_.clear();
2089 // Iterate over all layers, including masks and replicas. 2098 // Iterate over all layers, including masks and replicas.
2090 for (auto& layer : *layers_) 2099 for (auto& layer : *layers_)
2091 layer->ResetChangeTracking(); 2100 layer->ResetChangeTracking();
2092 property_trees_.ResetAllChangeTracking(); 2101 property_trees_.ResetAllChangeTracking();
2093 } 2102 }
2094 2103
2095 } // namespace cc 2104 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698