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

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

Issue 2194833002: Overscroll and Elasticity for views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-RouteThroughInputHandler
Patch Set: Restore functionality and fix bugs \o/ Created 4 years, 1 month 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/layers/layer_impl.h ('k') | cc/layers/layer_unittest.cc » ('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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 namespace cc { 50 namespace cc {
51 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) 51 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
52 : layer_id_(id), 52 : layer_id_(id),
53 layer_tree_impl_(tree_impl), 53 layer_tree_impl_(tree_impl),
54 test_properties_(nullptr), 54 test_properties_(nullptr),
55 scroll_clip_layer_id_(Layer::INVALID_ID), 55 scroll_clip_layer_id_(Layer::INVALID_ID),
56 main_thread_scrolling_reasons_( 56 main_thread_scrolling_reasons_(
57 MainThreadScrollingReason::kNotScrollingOnMain), 57 MainThreadScrollingReason::kNotScrollingOnMain),
58 user_scrollable_horizontal_(true), 58 user_scrollable_horizontal_(true),
59 user_scrollable_vertical_(true), 59 user_scrollable_vertical_(true),
60 can_overscroll_(false),
60 should_flatten_transform_from_property_tree_(false), 61 should_flatten_transform_from_property_tree_(false),
61 layer_property_changed_(false), 62 layer_property_changed_(false),
62 may_contain_video_(false), 63 may_contain_video_(false),
63 masks_to_bounds_(false), 64 masks_to_bounds_(false),
64 contents_opaque_(false), 65 contents_opaque_(false),
65 use_parent_backface_visibility_(false), 66 use_parent_backface_visibility_(false),
66 use_local_transform_for_backface_visibility_(false), 67 use_local_transform_for_backface_visibility_(false),
67 should_check_backface_visibility_(false), 68 should_check_backface_visibility_(false),
68 draws_content_(false), 69 draws_content_(false),
69 is_drawn_render_surface_layer_list_member_(false), 70 is_drawn_render_surface_layer_list_member_(false),
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 NOTREACHED(); 281 NOTREACHED();
281 *resource_id = 0; 282 *resource_id = 0;
282 } 283 }
283 284
284 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { 285 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) {
285 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree; 286 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
286 ScrollNode* scroll_node = scroll_tree.Node(scroll_tree_index()); 287 ScrollNode* scroll_node = scroll_tree.Node(scroll_tree_index());
287 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl()); 288 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl());
288 } 289 }
289 290
290 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { 291 void LayerImpl::SetScrollClipAndCanOverscroll(int scroll_clip_layer_id,
291 if (scroll_clip_layer_id_ == scroll_clip_layer_id) 292 bool can_overscroll) {
293 if (scroll_clip_layer_id_ == scroll_clip_layer_id &&
294 can_overscroll_ == can_overscroll)
292 return; 295 return;
293 296
294 layer_tree_impl()->UnregisterScrollLayer(this); 297 layer_tree_impl()->UnregisterScrollLayer(this);
295 scroll_clip_layer_id_ = scroll_clip_layer_id; 298 scroll_clip_layer_id_ = scroll_clip_layer_id;
299 can_overscroll_ = can_overscroll;
296 layer_tree_impl()->RegisterScrollLayer(this); 300 layer_tree_impl()->RegisterScrollLayer(this);
297 } 301 }
298 302
299 LayerImpl* LayerImpl::scroll_clip_layer() const { 303 LayerImpl* LayerImpl::scroll_clip_layer() const {
300 return layer_tree_impl()->LayerById(scroll_clip_layer_id_); 304 return layer_tree_impl()->LayerById(scroll_clip_layer_id_);
301 } 305 }
302 306
303 bool LayerImpl::scrollable() const { 307 bool LayerImpl::scrollable() const {
304 return scroll_clip_layer_id_ != Layer::INVALID_ID; 308 return scroll_clip_layer_id_ != Layer::INVALID_ID;
305 } 309 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 layer->layer_property_changed_ = true; 365 layer->layer_property_changed_ = true;
362 } 366 }
363 367
364 // If whether layer has render surface changes, we need to update draw 368 // If whether layer has render surface changes, we need to update draw
365 // properties. 369 // properties.
366 // TODO(weiliangc): Should be safely removed after impl side is able to 370 // TODO(weiliangc): Should be safely removed after impl side is able to
367 // update render surfaces without rebuilding property trees. 371 // update render surfaces without rebuilding property trees.
368 if (layer->has_render_surface() != has_render_surface()) 372 if (layer->has_render_surface() != has_render_surface())
369 layer->layer_tree_impl()->set_needs_update_draw_properties(); 373 layer->layer_tree_impl()->set_needs_update_draw_properties();
370 layer->SetBounds(bounds_); 374 layer->SetBounds(bounds_);
371 layer->SetScrollClipLayer(scroll_clip_layer_id_); 375 layer->SetScrollClipAndCanOverscroll(scroll_clip_layer_id_, can_overscroll_);
372 layer->SetElementId(element_id_); 376 layer->SetElementId(element_id_);
373 layer->SetMutableProperties(mutable_properties_); 377 layer->SetMutableProperties(mutable_properties_);
374 378
375 // If the main thread commits multiple times before the impl thread actually 379 // If the main thread commits multiple times before the impl thread actually
376 // draws, then damage tracking will become incorrect if we simply clobber the 380 // draws, then damage tracking will become incorrect if we simply clobber the
377 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 381 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
378 // union) any update changes that have occurred on the main thread. 382 // union) any update changes that have occurred on the main thread.
379 update_rect_.Union(layer->update_rect()); 383 update_rect_.Union(layer->update_rect());
380 layer->SetUpdateRect(update_rect_); 384 layer->SetUpdateRect(update_rect_);
381 385
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 update_rect_ = update_rect; 830 update_rect_ = update_rect;
827 SetNeedsPushProperties(); 831 SetNeedsPushProperties();
828 } 832 }
829 833
830 void LayerImpl::AddDamageRect(const gfx::Rect& damage_rect) { 834 void LayerImpl::AddDamageRect(const gfx::Rect& damage_rect) {
831 damage_rect_.Union(damage_rect); 835 damage_rect_.Union(damage_rect);
832 } 836 }
833 837
834 void LayerImpl::SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset) { 838 void LayerImpl::SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset) {
835 DCHECK(IsActive()); 839 DCHECK(IsActive());
836 if (layer_tree_impl()->property_trees()->scroll_tree.SetScrollOffset( 840 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
837 id(), scroll_offset)) 841 if (scroll_tree.SetScrollOffset(id(), scroll_offset, CurrentOverscroll()))
838 layer_tree_impl()->DidUpdateScrollOffset(id()); 842 layer_tree_impl()->DidUpdateScrollOffset(id());
839 } 843 }
840 844
841 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const { 845 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const {
842 return layer_tree_impl()->property_trees()->scroll_tree.current_scroll_offset( 846 return layer_tree_impl()->property_trees()->scroll_tree.current_scroll_offset(
843 id()); 847 id());
844 } 848 }
845 849
850 void LayerImpl::SetCurrentOverscroll(const gfx::ScrollOffset& overscroll) {
851 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
852 if (scroll_tree.SetScrollOffset(id(), CurrentScrollOffset(), overscroll))
853 layer_tree_impl()->DidUpdateScrollOffset(id());
854 }
855
856 gfx::ScrollOffset LayerImpl::CurrentOverscroll() const {
857 return layer_tree_impl()->property_trees()->scroll_tree.current_overscroll(
858 id());
859 }
860
846 void LayerImpl::UpdatePropertyTreeScrollOffset() { 861 void LayerImpl::UpdatePropertyTreeScrollOffset() {
847 // TODO(enne): in the future, scrolling should update the scroll tree 862 // TODO(enne): in the future, scrolling should update the scroll tree
848 // directly instead of going through layers. 863 // directly instead of going through layers.
849 TransformTree& transform_tree = 864 TransformTree& transform_tree =
850 layer_tree_impl()->property_trees()->transform_tree; 865 layer_tree_impl()->property_trees()->transform_tree;
851 TransformNode* node = transform_tree.Node(transform_tree_index_); 866 TransformNode* node = transform_tree.Node(transform_tree_index_);
852 gfx::ScrollOffset current_offset = CurrentScrollOffset(); 867 gfx::ScrollOffset current_offset =
853 if (node->scroll_offset != current_offset) { 868 CurrentScrollOffset() + CurrentOverscroll();
854 node->scroll_offset = current_offset; 869 if (node->scroll_offset_with_overscroll != current_offset) {
870 node->scroll_offset_with_overscroll = current_offset;
855 node->needs_local_transform_update = true; 871 node->needs_local_transform_update = true;
856 transform_tree.set_needs_update(true); 872 transform_tree.set_needs_update(true);
857 } 873 }
858 } 874 }
859 875
860 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { 876 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const {
861 if (contents_opaque()) 877 if (contents_opaque())
862 return SimpleEnclosedRegion(visible_layer_rect()); 878 return SimpleEnclosedRegion(visible_layer_rect());
863 return SimpleEnclosedRegion(); 879 return SimpleEnclosedRegion();
864 } 880 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 .layer_transforms_should_scale_layer_contents) { 1113 .layer_transforms_should_scale_layer_contents) {
1098 return default_scale; 1114 return default_scale;
1099 } 1115 }
1100 1116
1101 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1117 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1102 ScreenSpaceTransform(), default_scale); 1118 ScreenSpaceTransform(), default_scale);
1103 return std::max(transform_scales.x(), transform_scales.y()); 1119 return std::max(transform_scales.x(), transform_scales.y());
1104 } 1120 }
1105 1121
1106 } // namespace cc 1122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698