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

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

Issue 2189583004: [not for review - epic CL] Adding Elastic+Momentum+Layered scrolling to views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 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/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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 NOTREACHED(); 276 NOTREACHED();
276 *resource_id = 0; 277 *resource_id = 0;
277 } 278 }
278 279
279 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { 280 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) {
280 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree; 281 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
281 ScrollNode* scroll_node = scroll_tree.Node(scroll_tree_index()); 282 ScrollNode* scroll_node = scroll_tree.Node(scroll_tree_index());
282 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl()); 283 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl());
283 } 284 }
284 285
285 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { 286 void LayerImpl::SetScrollClipAndCanOverscroll(int scroll_clip_layer_id,
286 if (scroll_clip_layer_id_ == scroll_clip_layer_id) 287 bool can_overscroll) {
288 if (scroll_clip_layer_id_ == scroll_clip_layer_id &&
289 can_overscroll_ == can_overscroll)
287 return; 290 return;
288 291
289 layer_tree_impl()->UnregisterScrollLayer(this); 292 layer_tree_impl()->UnregisterScrollLayer(this);
290 scroll_clip_layer_id_ = scroll_clip_layer_id; 293 scroll_clip_layer_id_ = scroll_clip_layer_id;
294 can_overscroll_ = can_overscroll;
291 layer_tree_impl()->RegisterScrollLayer(this); 295 layer_tree_impl()->RegisterScrollLayer(this);
292 } 296 }
293 297
294 LayerImpl* LayerImpl::scroll_clip_layer() const { 298 LayerImpl* LayerImpl::scroll_clip_layer() const {
295 return layer_tree_impl()->LayerById(scroll_clip_layer_id_); 299 return layer_tree_impl()->LayerById(scroll_clip_layer_id_);
296 } 300 }
297 301
298 bool LayerImpl::scrollable() const { 302 bool LayerImpl::scrollable() const {
299 return scroll_clip_layer_id_ != Layer::INVALID_ID; 303 return scroll_clip_layer_id_ != Layer::INVALID_ID;
300 } 304 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 layer->layer_property_changed_ = true; 356 layer->layer_property_changed_ = true;
353 } 357 }
354 358
355 // If whether layer has render surface changes, we need to update draw 359 // If whether layer has render surface changes, we need to update draw
356 // properties. 360 // properties.
357 // TODO(weiliangc): Should be safely removed after impl side is able to 361 // TODO(weiliangc): Should be safely removed after impl side is able to
358 // update render surfaces without rebuilding property trees. 362 // update render surfaces without rebuilding property trees.
359 if (layer->has_render_surface() != has_render_surface()) 363 if (layer->has_render_surface() != has_render_surface())
360 layer->layer_tree_impl()->set_needs_update_draw_properties(); 364 layer->layer_tree_impl()->set_needs_update_draw_properties();
361 layer->SetBounds(bounds_); 365 layer->SetBounds(bounds_);
362 layer->SetScrollClipLayer(scroll_clip_layer_id_); 366 layer->SetScrollClipAndCanOverscroll(scroll_clip_layer_id_, can_overscroll_);
363 layer->SetElementId(element_id_); 367 layer->SetElementId(element_id_);
364 layer->SetMutableProperties(mutable_properties_); 368 layer->SetMutableProperties(mutable_properties_);
365 369
366 // If the main thread commits multiple times before the impl thread actually 370 // If the main thread commits multiple times before the impl thread actually
367 // draws, then damage tracking will become incorrect if we simply clobber the 371 // draws, then damage tracking will become incorrect if we simply clobber the
368 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 372 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
369 // union) any update changes that have occurred on the main thread. 373 // union) any update changes that have occurred on the main thread.
370 update_rect_.Union(layer->update_rect()); 374 update_rect_.Union(layer->update_rect());
371 layer->SetUpdateRect(update_rect_); 375 layer->SetUpdateRect(update_rect_);
372 376
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 update_rect_ = update_rect; 821 update_rect_ = update_rect;
818 SetNeedsPushProperties(); 822 SetNeedsPushProperties();
819 } 823 }
820 824
821 void LayerImpl::AddDamageRect(const gfx::Rect& damage_rect) { 825 void LayerImpl::AddDamageRect(const gfx::Rect& damage_rect) {
822 damage_rect_.Union(damage_rect); 826 damage_rect_.Union(damage_rect);
823 } 827 }
824 828
825 void LayerImpl::SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset) { 829 void LayerImpl::SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset) {
826 DCHECK(IsActive()); 830 DCHECK(IsActive());
827 if (layer_tree_impl()->property_trees()->scroll_tree.SetScrollOffset( 831 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
828 id(), scroll_offset)) 832 if (scroll_tree.SetScrollOffset(id(), scroll_offset, CurrentOverscroll()))
829 layer_tree_impl()->DidUpdateScrollOffset(id()); 833 layer_tree_impl()->DidUpdateScrollOffset(id());
830 } 834 }
831 835
832 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const { 836 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const {
833 return layer_tree_impl()->property_trees()->scroll_tree.current_scroll_offset( 837 return layer_tree_impl()->property_trees()->scroll_tree.current_scroll_offset(
834 id()); 838 id());
835 } 839 }
836 840
841 void LayerImpl::SetCurrentOverscroll(const gfx::ScrollOffset& overscroll) {
842 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
843 if (scroll_tree.SetScrollOffset(id(), CurrentScrollOffset(), overscroll))
844 layer_tree_impl()->DidUpdateScrollOffset(id());
845 }
846
847 gfx::ScrollOffset LayerImpl::CurrentOverscroll() const {
848 return layer_tree_impl()->property_trees()->scroll_tree.current_overscroll(
849 id());
850 }
851
837 void LayerImpl::UpdatePropertyTreeScrollOffset() { 852 void LayerImpl::UpdatePropertyTreeScrollOffset() {
838 // TODO(enne): in the future, scrolling should update the scroll tree 853 // TODO(enne): in the future, scrolling should update the scroll tree
839 // directly instead of going through layers. 854 // directly instead of going through layers.
840 TransformTree& transform_tree = 855 TransformTree& transform_tree =
841 layer_tree_impl()->property_trees()->transform_tree; 856 layer_tree_impl()->property_trees()->transform_tree;
842 TransformNode* node = transform_tree.Node(transform_tree_index_); 857 TransformNode* node = transform_tree.Node(transform_tree_index_);
843 gfx::ScrollOffset current_offset = CurrentScrollOffset(); 858 gfx::ScrollOffset current_offset =
844 if (node->scroll_offset != current_offset) { 859 CurrentScrollOffset() + CurrentOverscroll();
845 node->scroll_offset = current_offset; 860 if (node->scroll_offset_with_overscroll != current_offset) {
861 node->scroll_offset_with_overscroll = current_offset;
846 node->needs_local_transform_update = true; 862 node->needs_local_transform_update = true;
847 transform_tree.set_needs_update(true); 863 transform_tree.set_needs_update(true);
848 } 864 }
849 } 865 }
850 866
851 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { 867 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const {
852 if (contents_opaque()) 868 if (contents_opaque())
853 return SimpleEnclosedRegion(visible_layer_rect()); 869 return SimpleEnclosedRegion(visible_layer_rect());
854 return SimpleEnclosedRegion(); 870 return SimpleEnclosedRegion();
855 } 871 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 .layer_transforms_should_scale_layer_contents) { 1104 .layer_transforms_should_scale_layer_contents) {
1089 return default_scale; 1105 return default_scale;
1090 } 1106 }
1091 1107
1092 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1108 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1093 ScreenSpaceTransform(), default_scale); 1109 ScreenSpaceTransform(), default_scale);
1094 return std::max(transform_scales.x(), transform_scales.y()); 1110 return std::max(transform_scales.x(), transform_scales.y());
1095 } 1111 }
1096 1112
1097 } // namespace cc 1113 } // 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