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

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

Issue 1736073002: cc: Move SyncedScrollOffset to scroll tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments Created 4 years, 9 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 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 #ifndef CC_LAYERS_LAYER_IMPL_H_ 5 #ifndef CC_LAYERS_LAYER_IMPL_H_
6 #define CC_LAYERS_LAYER_IMPL_H_ 6 #define CC_LAYERS_LAYER_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 DRAW_MODE_NONE, 76 DRAW_MODE_NONE,
77 DRAW_MODE_HARDWARE, 77 DRAW_MODE_HARDWARE,
78 DRAW_MODE_SOFTWARE, 78 DRAW_MODE_SOFTWARE,
79 DRAW_MODE_RESOURCELESS_SOFTWARE 79 DRAW_MODE_RESOURCELESS_SOFTWARE
80 }; 80 };
81 81
82 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, 82 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
83 public LayerAnimationValueProvider, 83 public LayerAnimationValueProvider,
84 public AnimationDelegate { 84 public AnimationDelegate {
85 public: 85 public:
86 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset;
87 typedef LayerImplList RenderSurfaceListType; 86 typedef LayerImplList RenderSurfaceListType;
88 typedef LayerImplList LayerListType; 87 typedef LayerImplList LayerListType;
89 typedef RenderSurfaceImpl RenderSurfaceType; 88 typedef RenderSurfaceImpl RenderSurfaceType;
90 89
91 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; 90 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
92 91
93 static scoped_ptr<LayerImpl> Create( 92 static scoped_ptr<LayerImpl> Create(
94 LayerTreeImpl* tree_impl, 93 LayerTreeImpl* tree_impl,
95 int id, 94 int id,
96 scoped_refptr<SyncedScrollOffset> scroll_offset) { 95 scoped_refptr<SyncedScrollOffset> scroll_offset) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 454
456 void SetBounds(const gfx::Size& bounds); 455 void SetBounds(const gfx::Size& bounds);
457 gfx::Size bounds() const; 456 gfx::Size bounds() const;
458 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions 457 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
459 // of pixels) due to use of single precision float. 458 // of pixels) due to use of single precision float.
460 gfx::SizeF BoundsForScrolling() const; 459 gfx::SizeF BoundsForScrolling() const;
461 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta); 460 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
462 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } 461 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
463 462
464 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset); 463 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset);
464 // must only be called by tests when updating scroll offset of a single layer,
465 // the standard process to update scroll offsets is to call
466 // ScrollTree::UpdateScrollOffsetMap() which updates scroll offsets of all
467 // layers.
465 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset); 468 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset);
466 // This method is similar to PushScrollOffsetFromMainThread but will cause the 469
467 // scroll offset given to clobber any scroll changes on the active tree in the
468 // time until this value is pushed to the active tree.
469 void PushScrollOffsetFromMainThreadAndClobberActiveValue(
470 const gfx::ScrollOffset& scroll_offset);
471 gfx::ScrollOffset PullDeltaForMainThread();
472 gfx::ScrollOffset CurrentScrollOffset() const; 470 gfx::ScrollOffset CurrentScrollOffset() const;
473 gfx::ScrollOffset BaseScrollOffset() const; 471 gfx::ScrollOffset BaseScrollOffset() const;
474 gfx::Vector2dF ScrollDelta() const; 472 gfx::Vector2dF ScrollDelta() const;
475 void SetScrollDelta(const gfx::Vector2dF& delta); 473 void SetScrollDelta(const gfx::Vector2dF& delta);
474 // This is a mirror function of Layer::scroll_offset, which is supposed to be
475 // called only by PropertyTreeBuilder
476 gfx::ScrollOffset scroll_offset() const {
477 return synced_scroll_offset()->PendingBase();
478 }
476 479
477 gfx::ScrollOffset MaxScrollOffset() const; 480 gfx::ScrollOffset MaxScrollOffset() const;
478 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const; 481 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const;
479 gfx::Vector2dF ClampScrollToMaxScrollOffset(); 482 gfx::Vector2dF ClampScrollToMaxScrollOffset();
480 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) { 483 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) {
481 scroll_compensation_adjustment_ = scroll_offset; 484 scroll_compensation_adjustment_ = scroll_offset;
482 } 485 }
483 gfx::Vector2dF ScrollCompensationAdjustment() const { 486 gfx::Vector2dF ScrollCompensationAdjustment() const {
484 return scroll_compensation_adjustment_; 487 return scroll_compensation_adjustment_;
485 } 488 }
(...skipping 13 matching lines...) Expand all
499 bool user_scrollable_horizontal() const { 502 bool user_scrollable_horizontal() const {
500 return user_scrollable_horizontal_; 503 return user_scrollable_horizontal_;
501 } 504 }
502 void set_user_scrollable_vertical(bool scrollable) { 505 void set_user_scrollable_vertical(bool scrollable) {
503 user_scrollable_vertical_ = scrollable; 506 user_scrollable_vertical_ = scrollable;
504 } 507 }
505 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 508 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
506 509
507 bool user_scrollable(ScrollbarOrientation orientation) const; 510 bool user_scrollable(ScrollbarOrientation orientation) const;
508 511
509 void ApplySentScrollDeltasFromAbortedCommit();
510
511 void set_main_thread_scrolling_reasons( 512 void set_main_thread_scrolling_reasons(
512 uint32_t main_thread_scrolling_reasons); 513 uint32_t main_thread_scrolling_reasons);
513 uint32_t main_thread_scrolling_reasons() const { 514 uint32_t main_thread_scrolling_reasons() const {
514 return main_thread_scrolling_reasons_; 515 return main_thread_scrolling_reasons_;
515 } 516 }
516 bool should_scroll_on_main_thread() const { 517 bool should_scroll_on_main_thread() const {
517 return !!main_thread_scrolling_reasons_; 518 return !!main_thread_scrolling_reasons_;
518 } 519 }
519 520
520 void SetNonFastScrollableRegion(const Region& region) { 521 void SetNonFastScrollableRegion(const Region& region) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 void Set3dSortingContextId(int id); 630 void Set3dSortingContextId(int id);
630 int sorting_context_id() { return sorting_context_id_; } 631 int sorting_context_id() { return sorting_context_id_; }
631 632
632 void SetFrameTimingRequests( 633 void SetFrameTimingRequests(
633 const std::vector<FrameTimingRequest>& frame_timing_requests); 634 const std::vector<FrameTimingRequest>& frame_timing_requests);
634 const std::vector<FrameTimingRequest>& frame_timing_requests() const { 635 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
635 return frame_timing_requests_; 636 return frame_timing_requests_;
636 } 637 }
637 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids); 638 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids);
638 639
639 SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); } 640 const SyncedScrollOffset* synced_scroll_offset() const;
641 SyncedScrollOffset* synced_scroll_offset();
640 642
641 // Get the correct invalidation region instead of conservative Rect 643 // Get the correct invalidation region instead of conservative Rect
642 // for layers that provide it. 644 // for layers that provide it.
643 virtual Region GetInvalidationRegion(); 645 virtual Region GetInvalidationRegion();
644 646
645 virtual gfx::Rect GetEnclosingRectInTargetSpace() const; 647 virtual gfx::Rect GetEnclosingRectInTargetSpace() const;
646 648
647 void set_visited(bool visited) { visited_ = visited; } 649 void set_visited(bool visited) { visited_ = visited; }
648 650
649 bool visited() { return visited_; } 651 bool visited() { return visited_; }
(...skipping 29 matching lines...) Expand all
679 681
680 bool was_ever_ready_since_last_transform_animation() const { 682 bool was_ever_ready_since_last_transform_animation() const {
681 return was_ever_ready_since_last_transform_animation_; 683 return was_ever_ready_since_last_transform_animation_;
682 } 684 }
683 685
684 void set_was_ever_ready_since_last_transform_animation(bool was_ready) { 686 void set_was_ever_ready_since_last_transform_animation(bool was_ready) {
685 was_ever_ready_since_last_transform_animation_ = was_ready; 687 was_ever_ready_since_last_transform_animation_ = was_ready;
686 } 688 }
687 689
688 void NoteLayerPropertyChanged(); 690 void NoteLayerPropertyChanged();
691 void DidUpdateScrollOffset();
689 692
690 void PushLayerPropertyChangedForSubtree(); 693 void PushLayerPropertyChangedForSubtree();
691 694
692 protected: 695 protected:
693 LayerImpl(LayerTreeImpl* layer_impl, 696 LayerImpl(LayerTreeImpl* layer_impl,
694 int id, 697 int id,
695 scoped_refptr<SyncedScrollOffset> scroll_offset); 698 scoped_refptr<SyncedScrollOffset> scroll_offset);
696 LayerImpl(LayerTreeImpl* layer_impl, int id); 699 LayerImpl(LayerTreeImpl* layer_impl, int id);
697 700
698 // Get the color and size of the layer's debug border. 701 // Get the color and size of the layer's debug border.
(...skipping 13 matching lines...) Expand all
712 void NoteLayerPropertyChangedForSubtree(); 715 void NoteLayerPropertyChangedForSubtree();
713 716
714 // Note carefully this does not affect the current layer. 717 // Note carefully this does not affect the current layer.
715 void NoteLayerPropertyChangedForDescendants(); 718 void NoteLayerPropertyChangedForDescendants();
716 719
717 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; 720 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const;
718 721
719 private: 722 private:
720 void ValidateQuadResourcesInternal(DrawQuad* quad) const; 723 void ValidateQuadResourcesInternal(DrawQuad* quad) const;
721 724
722 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset);
723 void DidUpdateScrollOffset();
724 void NoteLayerPropertyChangedForDescendantsInternal(); 725 void NoteLayerPropertyChangedForDescendantsInternal();
725 void PushLayerPropertyChangedForSubtreeInternal(); 726 void PushLayerPropertyChangedForSubtreeInternal();
726 727
727 virtual const char* LayerTypeAsString() const; 728 virtual const char* LayerTypeAsString() const;
728 729
729 // Properties internal to LayerImpl 730 // Properties internal to LayerImpl
730 LayerImpl* parent_; 731 LayerImpl* parent_;
731 OwnedLayerImplList children_; 732 OwnedLayerImplList children_;
732 733
733 LayerImpl* scroll_parent_; 734 LayerImpl* scroll_parent_;
734 735
735 // Storing a pointer to a set rather than a set since this will be rarely 736 // Storing a pointer to a set rather than a set since this will be rarely
736 // used. If this pointer turns out to be too heavy, we could have this (and 737 // used. If this pointer turns out to be too heavy, we could have this (and
737 // the scroll parent above) be stored in a LayerImpl -> scroll_info 738 // the scroll parent above) be stored in a LayerImpl -> scroll_info
738 // map somewhere. 739 // map somewhere.
739 scoped_ptr<std::set<LayerImpl*>> scroll_children_; 740 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
740 741
741 LayerImpl* clip_parent_; 742 LayerImpl* clip_parent_;
742 scoped_ptr<std::set<LayerImpl*>> clip_children_; 743 scoped_ptr<std::set<LayerImpl*>> clip_children_;
743 744
744 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 745 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
745 // confirm newly assigned layer is still the previous one 746 // confirm newly assigned layer is still the previous one
746 int mask_layer_id_; 747 int mask_layer_id_;
747 scoped_ptr<LayerImpl> mask_layer_; 748 scoped_ptr<LayerImpl> mask_layer_;
748 int replica_layer_id_; // ditto 749 int replica_layer_id_; // ditto
749 scoped_ptr<LayerImpl> replica_layer_; 750 scoped_ptr<LayerImpl> replica_layer_;
750 int layer_id_; 751 int layer_id_;
751 LayerTreeImpl* layer_tree_impl_; 752 LayerTreeImpl* layer_tree_impl_;
752 753
753 // Properties dynamically changeable on active tree.
754 scoped_refptr<SyncedScrollOffset> scroll_offset_;
755 gfx::Vector2dF bounds_delta_; 754 gfx::Vector2dF bounds_delta_;
756 755
757 // Properties synchronized from the associated Layer. 756 // Properties synchronized from the associated Layer.
758 gfx::Point3F transform_origin_; 757 gfx::Point3F transform_origin_;
759 gfx::Size bounds_; 758 gfx::Size bounds_;
760 int scroll_clip_layer_id_; 759 int scroll_clip_layer_id_;
761 760
762 gfx::Vector2dF offset_to_transform_parent_; 761 gfx::Vector2dF offset_to_transform_parent_;
763 uint32_t main_thread_scrolling_reasons_; 762 uint32_t main_thread_scrolling_reasons_;
764 763
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // If true, the layer or one of its descendants has a touch handler. 878 // If true, the layer or one of its descendants has a touch handler.
880 bool layer_or_descendant_has_touch_handler_; 879 bool layer_or_descendant_has_touch_handler_;
881 bool sorted_for_recursion_; 880 bool sorted_for_recursion_;
882 881
883 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 882 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
884 }; 883 };
885 884
886 } // namespace cc 885 } // namespace cc
887 886
888 #endif // CC_LAYERS_LAYER_IMPL_H_ 887 #endif // CC_LAYERS_LAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698