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

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

Issue 571873003: [Android]Optimization of scrollbar animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding test case for above patch Created 6 years, 3 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
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/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h" 8 #include "base/debug/trace_event_argument.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 } 1267 }
1268 } 1268 }
1269 // TODO(wjmaclean) Once we move to a model where the two-viewport model is 1269 // TODO(wjmaclean) Once we move to a model where the two-viewport model is
1270 // turned on in all builds, remove the next two lines. For now however, the 1270 // turned on in all builds, remove the next two lines. For now however, the
1271 // page scale layer may coincide with the clip layer, and so this is 1271 // page scale layer may coincide with the clip layer, and so this is
1272 // necessary. 1272 // necessary.
1273 if (page_scale_layer == scrollbar_clip_layer) { 1273 if (page_scale_layer == scrollbar_clip_layer) {
1274 scroll_rect.Scale(layer_tree_impl()->total_page_scale_factor()); 1274 scroll_rect.Scale(layer_tree_impl()->total_page_scale_factor());
1275 current_offset.Scale(layer_tree_impl()->total_page_scale_factor()); 1275 current_offset.Scale(layer_tree_impl()->total_page_scale_factor());
1276 } 1276 }
1277 1277 scrollbar_layer->ResetScrollbarNeedsAnimation();
1278 scrollbar_layer->SetVerticalAdjust(scrollbar_clip_layer->bounds_delta().y()); 1278 scrollbar_layer->SetVerticalAdjust(scrollbar_clip_layer->bounds_delta().y());
1279 if (scrollbar_layer->orientation() == HORIZONTAL) { 1279 if (scrollbar_layer->orientation() == HORIZONTAL) {
1280 float visible_ratio = clip_rect.width() / scroll_rect.width(); 1280 float visible_ratio = clip_rect.width() / scroll_rect.width();
1281 scrollbar_layer->SetCurrentPos(current_offset.x()); 1281 scrollbar_layer->SetCurrentPos(current_offset.x());
1282 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); 1282 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width());
1283 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); 1283 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio);
1284 } else { 1284 } else {
1285 float visible_ratio = clip_rect.height() / scroll_rect.height(); 1285 float visible_ratio = clip_rect.height() / scroll_rect.height();
1286 scrollbar_layer->SetCurrentPos(current_offset.y()); 1286 scrollbar_layer->SetCurrentPos(current_offset.y());
1287 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); 1287 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height());
1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); 1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio);
1289 } 1289 }
1290 1290
1291 layer_tree_impl()->set_needs_update_draw_properties(); 1291 layer_tree_impl()->set_needs_update_draw_properties();
1292 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars should 1292 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars should
1293 // activate for every scroll on the main frame, not just the scrolls that move 1293 // activate for every scroll on the main frame, not just the scrolls that move
1294 // the pinch virtual viewport (i.e. trigger from either inner or outer 1294 // the pinch virtual viewport (i.e. trigger from either inner or outer
1295 // viewport). 1295 // viewport).
1296 if (scrollbar_animation_controller_) { 1296 if (scrollbar_animation_controller_) {
danakj 2014/09/19 23:01:35 move it up here: if (controller && needs animation
1297 // When both non-overlay and overlay scrollbars are both present, don't 1297 // When both non-overlay and overlay scrollbars are both present, don't
1298 // animate the overlay scrollbars when page scale factor is at the min. 1298 // animate the overlay scrollbars when page scale factor is at the min.
1299 // Non-overlay scrollbars also shouldn't trigger animations. 1299 // Non-overlay scrollbars also shouldn't trigger animations.
1300 bool is_animatable_scrollbar = 1300 bool is_animatable_scrollbar =
1301 scrollbar_layer->is_overlay_scrollbar() && 1301 scrollbar_layer->is_overlay_scrollbar() &&
1302 scrollbar_layer->scrollbar_needs_animation() &&
danakj 2014/09/19 23:01:35 remove this here, it's not part of |is_animatable_
1302 ((layer_tree_impl()->total_page_scale_factor() > 1303 ((layer_tree_impl()->total_page_scale_factor() >
1303 layer_tree_impl()->min_page_scale_factor()) || 1304 layer_tree_impl()->min_page_scale_factor()) ||
1304 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); 1305 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars);
1305 if (is_animatable_scrollbar) 1306 if (is_animatable_scrollbar)
1306 scrollbar_animation_controller_->DidScrollUpdate(); 1307 scrollbar_animation_controller_->DidScrollUpdate();
1307 } 1308 }
1308 } 1309 }
1309 1310
1310 void LayerImpl::DidBecomeActive() { 1311 void LayerImpl::DidBecomeActive() {
1311 if (layer_tree_impl_->settings().scrollbar_animator == 1312 if (layer_tree_impl_->settings().scrollbar_animator ==
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 } 1541 }
1541 1542
1542 void LayerImpl::NotifyAnimationFinished( 1543 void LayerImpl::NotifyAnimationFinished(
1543 base::TimeTicks monotonic_time, 1544 base::TimeTicks monotonic_time,
1544 Animation::TargetProperty target_property) { 1545 Animation::TargetProperty target_property) {
1545 if (target_property == Animation::ScrollOffset) 1546 if (target_property == Animation::ScrollOffset)
1546 layer_tree_impl_->InputScrollAnimationFinished(); 1547 layer_tree_impl_->InputScrollAnimationFinished();
1547 } 1548 }
1548 1549
1549 } // namespace cc 1550 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/scrollbar_layer_impl_base.h » ('j') | cc/layers/scrollbar_layer_impl_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698