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

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

Issue 901813002: Normalize top controls offset to (0, 1), Chromium-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace more EXPECT_EQ with EXPECT_FLOAT_EQ for windows bots Created 5 years, 10 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') | content/renderer/gpu/render_widget_compositor.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 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
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
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
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
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 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 scoped_ptr<PendingPageScaleAnimation> pending_animation) { 1585 scoped_ptr<PendingPageScaleAnimation> pending_animation) {
1557 pending_page_scale_animation_ = pending_animation.Pass(); 1586 pending_page_scale_animation_ = pending_animation.Pass();
1558 } 1587 }
1559 1588
1560 scoped_ptr<PendingPageScaleAnimation> 1589 scoped_ptr<PendingPageScaleAnimation>
1561 LayerTreeImpl::TakePendingPageScaleAnimation() { 1590 LayerTreeImpl::TakePendingPageScaleAnimation() {
1562 return pending_page_scale_animation_.Pass(); 1591 return pending_page_scale_animation_.Pass();
1563 } 1592 }
1564 1593
1565 } // namespace cc 1594 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | content/renderer/gpu/render_widget_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698