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

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: Rebase and add comment 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
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_impl.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 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(
94 LayerTreeImpl* tree_impl,
95 int id,
96 scoped_refptr<SyncedScrollOffset> scroll_offset) {
97 return make_scoped_ptr(new LayerImpl(tree_impl, id, scroll_offset));
98 }
99
100 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 92 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
101 return make_scoped_ptr(new LayerImpl(tree_impl, id)); 93 return make_scoped_ptr(new LayerImpl(tree_impl, id));
102 } 94 }
103 95
104 ~LayerImpl() override; 96 ~LayerImpl() override;
105 97
106 int id() const { return layer_id_; } 98 int id() const { return layer_id_; }
107 99
108 // LayerAnimationValueProvider implementation. 100 // LayerAnimationValueProvider implementation.
109 gfx::ScrollOffset ScrollOffsetForAnimation() const override; 101 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 448
457 void SetBounds(const gfx::Size& bounds); 449 void SetBounds(const gfx::Size& bounds);
458 gfx::Size bounds() const; 450 gfx::Size bounds() const;
459 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions 451 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
460 // of pixels) due to use of single precision float. 452 // of pixels) due to use of single precision float.
461 gfx::SizeF BoundsForScrolling() const; 453 gfx::SizeF BoundsForScrolling() const;
462 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta); 454 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
463 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } 455 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
464 456
465 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset); 457 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset);
458 // must only be called by tests when updating scroll offset of a single layer,
459 // the standard process to update scroll offsets is to call
460 // ScrollTree::UpdateScrollOffsetMap() which updates scroll offsets of all
461 // layers.
466 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset); 462 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset);
467 // This method is similar to PushScrollOffsetFromMainThread but will cause the 463
468 // scroll offset given to clobber any scroll changes on the active tree in the
469 // time until this value is pushed to the active tree.
470 void PushScrollOffsetFromMainThreadAndClobberActiveValue(
471 const gfx::ScrollOffset& scroll_offset);
472 gfx::ScrollOffset PullDeltaForMainThread();
473 gfx::ScrollOffset CurrentScrollOffset() const; 464 gfx::ScrollOffset CurrentScrollOffset() const;
474 gfx::ScrollOffset BaseScrollOffset() const; 465 gfx::ScrollOffset BaseScrollOffset() const;
475 gfx::Vector2dF ScrollDelta() const; 466 gfx::Vector2dF ScrollDelta() const;
476 void SetScrollDelta(const gfx::Vector2dF& delta); 467 void SetScrollDelta(const gfx::Vector2dF& delta);
477 468
478 gfx::ScrollOffset MaxScrollOffset() const; 469 gfx::ScrollOffset MaxScrollOffset() const;
479 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const; 470 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const;
480 gfx::Vector2dF ClampScrollToMaxScrollOffset(); 471 gfx::Vector2dF ClampScrollToMaxScrollOffset();
481 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) { 472 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) {
482 scroll_compensation_adjustment_ = scroll_offset; 473 scroll_compensation_adjustment_ = scroll_offset;
(...skipping 17 matching lines...) Expand all
500 bool user_scrollable_horizontal() const { 491 bool user_scrollable_horizontal() const {
501 return user_scrollable_horizontal_; 492 return user_scrollable_horizontal_;
502 } 493 }
503 void set_user_scrollable_vertical(bool scrollable) { 494 void set_user_scrollable_vertical(bool scrollable) {
504 user_scrollable_vertical_ = scrollable; 495 user_scrollable_vertical_ = scrollable;
505 } 496 }
506 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 497 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
507 498
508 bool user_scrollable(ScrollbarOrientation orientation) const; 499 bool user_scrollable(ScrollbarOrientation orientation) const;
509 500
510 void ApplySentScrollDeltasFromAbortedCommit();
511
512 void set_main_thread_scrolling_reasons( 501 void set_main_thread_scrolling_reasons(
513 uint32_t main_thread_scrolling_reasons); 502 uint32_t main_thread_scrolling_reasons);
514 uint32_t main_thread_scrolling_reasons() const { 503 uint32_t main_thread_scrolling_reasons() const {
515 return main_thread_scrolling_reasons_; 504 return main_thread_scrolling_reasons_;
516 } 505 }
517 bool should_scroll_on_main_thread() const { 506 bool should_scroll_on_main_thread() const {
518 return !!main_thread_scrolling_reasons_; 507 return !!main_thread_scrolling_reasons_;
519 } 508 }
520 509
521 void SetNonFastScrollableRegion(const Region& region) { 510 void SetNonFastScrollableRegion(const Region& region) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 void Set3dSortingContextId(int id); 619 void Set3dSortingContextId(int id);
631 int sorting_context_id() { return sorting_context_id_; } 620 int sorting_context_id() { return sorting_context_id_; }
632 621
633 void SetFrameTimingRequests( 622 void SetFrameTimingRequests(
634 const std::vector<FrameTimingRequest>& frame_timing_requests); 623 const std::vector<FrameTimingRequest>& frame_timing_requests);
635 const std::vector<FrameTimingRequest>& frame_timing_requests() const { 624 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
636 return frame_timing_requests_; 625 return frame_timing_requests_;
637 } 626 }
638 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids); 627 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids);
639 628
640 SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); } 629 const SyncedScrollOffset* synced_scroll_offset() const;
630 SyncedScrollOffset* synced_scroll_offset();
641 631
642 // Get the correct invalidation region instead of conservative Rect 632 // Get the correct invalidation region instead of conservative Rect
643 // for layers that provide it. 633 // for layers that provide it.
644 virtual Region GetInvalidationRegion(); 634 virtual Region GetInvalidationRegion();
645 635
646 virtual gfx::Rect GetEnclosingRectInTargetSpace() const; 636 virtual gfx::Rect GetEnclosingRectInTargetSpace() const;
647 637
648 void set_visited(bool visited) { visited_ = visited; } 638 void set_visited(bool visited) { visited_ = visited; }
649 639
650 bool visited() { return visited_; } 640 bool visited() { return visited_; }
(...skipping 29 matching lines...) Expand all
680 670
681 bool was_ever_ready_since_last_transform_animation() const { 671 bool was_ever_ready_since_last_transform_animation() const {
682 return was_ever_ready_since_last_transform_animation_; 672 return was_ever_ready_since_last_transform_animation_;
683 } 673 }
684 674
685 void set_was_ever_ready_since_last_transform_animation(bool was_ready) { 675 void set_was_ever_ready_since_last_transform_animation(bool was_ready) {
686 was_ever_ready_since_last_transform_animation_ = was_ready; 676 was_ever_ready_since_last_transform_animation_ = was_ready;
687 } 677 }
688 678
689 void NoteLayerPropertyChanged(); 679 void NoteLayerPropertyChanged();
680 void DidUpdateScrollOffset();
690 681
691 void PushLayerPropertyChangedForSubtree(); 682 void PushLayerPropertyChangedForSubtree();
692 683
693 protected: 684 protected:
694 LayerImpl(LayerTreeImpl* layer_impl, 685 LayerImpl(LayerTreeImpl* layer_impl,
695 int id, 686 int id,
696 scoped_refptr<SyncedScrollOffset> scroll_offset); 687 scoped_refptr<SyncedScrollOffset> scroll_offset);
697 LayerImpl(LayerTreeImpl* layer_impl, int id); 688 LayerImpl(LayerTreeImpl* layer_impl, int id);
698 689
699 // Get the color and size of the layer's debug border. 690 // Get the color and size of the layer's debug border.
700 virtual void GetDebugBorderProperties(SkColor* color, float* width) const; 691 virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
701 692
702 void AppendDebugBorderQuad(RenderPass* render_pass, 693 void AppendDebugBorderQuad(RenderPass* render_pass,
703 const gfx::Size& bounds, 694 const gfx::Size& bounds,
704 const SharedQuadState* shared_quad_state, 695 const SharedQuadState* shared_quad_state,
705 AppendQuadsData* append_quads_data) const; 696 AppendQuadsData* append_quads_data) const;
706 void AppendDebugBorderQuad(RenderPass* render_pass, 697 void AppendDebugBorderQuad(RenderPass* render_pass,
707 const gfx::Size& bounds, 698 const gfx::Size& bounds,
708 const SharedQuadState* shared_quad_state, 699 const SharedQuadState* shared_quad_state,
709 AppendQuadsData* append_quads_data, 700 AppendQuadsData* append_quads_data,
710 SkColor color, 701 SkColor color,
711 float width) const; 702 float width) const;
712 703
713 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; 704 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const;
714 705
715 private: 706 private:
716 void ValidateQuadResourcesInternal(DrawQuad* quad) const; 707 void ValidateQuadResourcesInternal(DrawQuad* quad) const;
717 708
718 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset);
719 void DidUpdateScrollOffset();
720 void NoteLayerPropertyChangedForDescendantsInternal(); 709 void NoteLayerPropertyChangedForDescendantsInternal();
721 void PushLayerPropertyChangedForSubtreeInternal(); 710 void PushLayerPropertyChangedForSubtreeInternal();
722 711
723 virtual const char* LayerTypeAsString() const; 712 virtual const char* LayerTypeAsString() const;
724 713
725 // Properties internal to LayerImpl 714 // Properties internal to LayerImpl
726 LayerImpl* parent_; 715 LayerImpl* parent_;
727 OwnedLayerImplList children_; 716 OwnedLayerImplList children_;
728 717
729 LayerImpl* scroll_parent_; 718 LayerImpl* scroll_parent_;
730 719
731 // Storing a pointer to a set rather than a set since this will be rarely 720 // Storing a pointer to a set rather than a set since this will be rarely
732 // used. If this pointer turns out to be too heavy, we could have this (and 721 // used. If this pointer turns out to be too heavy, we could have this (and
733 // the scroll parent above) be stored in a LayerImpl -> scroll_info 722 // the scroll parent above) be stored in a LayerImpl -> scroll_info
734 // map somewhere. 723 // map somewhere.
735 scoped_ptr<std::set<LayerImpl*>> scroll_children_; 724 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
736 725
737 LayerImpl* clip_parent_; 726 LayerImpl* clip_parent_;
738 scoped_ptr<std::set<LayerImpl*>> clip_children_; 727 scoped_ptr<std::set<LayerImpl*>> clip_children_;
739 728
740 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 729 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
741 // confirm newly assigned layer is still the previous one 730 // confirm newly assigned layer is still the previous one
742 int mask_layer_id_; 731 int mask_layer_id_;
743 scoped_ptr<LayerImpl> mask_layer_; 732 scoped_ptr<LayerImpl> mask_layer_;
744 int replica_layer_id_; // ditto 733 int replica_layer_id_; // ditto
745 scoped_ptr<LayerImpl> replica_layer_; 734 scoped_ptr<LayerImpl> replica_layer_;
746 int layer_id_; 735 int layer_id_;
747 LayerTreeImpl* layer_tree_impl_; 736 LayerTreeImpl* layer_tree_impl_;
748 737
749 // Properties dynamically changeable on active tree.
750 scoped_refptr<SyncedScrollOffset> scroll_offset_;
751 gfx::Vector2dF bounds_delta_; 738 gfx::Vector2dF bounds_delta_;
752 739
753 // Properties synchronized from the associated Layer. 740 // Properties synchronized from the associated Layer.
754 gfx::Point3F transform_origin_; 741 gfx::Point3F transform_origin_;
755 gfx::Size bounds_; 742 gfx::Size bounds_;
756 int scroll_clip_layer_id_; 743 int scroll_clip_layer_id_;
757 744
758 gfx::Vector2dF offset_to_transform_parent_; 745 gfx::Vector2dF offset_to_transform_parent_;
759 uint32_t main_thread_scrolling_reasons_; 746 uint32_t main_thread_scrolling_reasons_;
760 747
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // If true, the layer or one of its descendants has a touch handler. 863 // If true, the layer or one of its descendants has a touch handler.
877 bool layer_or_descendant_has_touch_handler_; 864 bool layer_or_descendant_has_touch_handler_;
878 bool sorted_for_recursion_; 865 bool sorted_for_recursion_;
879 866
880 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 867 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
881 }; 868 };
882 869
883 } // namespace cc 870 } // namespace cc
884 871
885 #endif // CC_LAYERS_LAYER_IMPL_H_ 872 #endif // CC_LAYERS_LAYER_IMPL_H_
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698