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

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: Fix after rebase 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 const LayerImpl* replica_layer() const { return replica_layer_.get(); } 251 const LayerImpl* replica_layer() const { return replica_layer_.get(); }
252 scoped_ptr<LayerImpl> TakeReplicaLayer(); 252 scoped_ptr<LayerImpl> TakeReplicaLayer();
253 253
254 bool has_mask() const { return !!mask_layer_; } 254 bool has_mask() const { return !!mask_layer_; }
255 bool has_replica() const { return !!replica_layer_; } 255 bool has_replica() const { return !!replica_layer_; }
256 bool replica_has_mask() const { 256 bool replica_has_mask() const {
257 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); 257 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
258 } 258 }
259 259
260 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } 260 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; }
261 LayerListImpl* layer_list_impl() const { return layer_list_impl_; }
261 262
262 void PopulateSharedQuadState(SharedQuadState* state) const; 263 void PopulateSharedQuadState(SharedQuadState* state) const;
263 void PopulateScaledSharedQuadState(SharedQuadState* state, float scale) const; 264 void PopulateScaledSharedQuadState(SharedQuadState* state, float scale) const;
264 // WillDraw must be called before AppendQuads. If WillDraw returns false, 265 // WillDraw must be called before AppendQuads. If WillDraw returns false,
265 // AppendQuads and DidDraw will not be called. If WillDraw returns true, 266 // AppendQuads and DidDraw will not be called. If WillDraw returns true,
266 // DidDraw is guaranteed to be called before another WillDraw or before 267 // DidDraw is guaranteed to be called before another WillDraw or before
267 // the layer is destroyed. To enforce this, any class that overrides 268 // the layer is destroyed. To enforce this, any class that overrides
268 // WillDraw/DidDraw must call the base class version only if WillDraw 269 // WillDraw/DidDraw must call the base class version only if WillDraw
269 // returns true. 270 // returns true.
270 virtual bool WillDraw(DrawMode draw_mode, 271 virtual bool WillDraw(DrawMode draw_mode,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 457
457 void SetBounds(const gfx::Size& bounds); 458 void SetBounds(const gfx::Size& bounds);
458 gfx::Size bounds() const; 459 gfx::Size bounds() const;
459 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions 460 // 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. 461 // of pixels) due to use of single precision float.
461 gfx::SizeF BoundsForScrolling() const; 462 gfx::SizeF BoundsForScrolling() const;
462 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta); 463 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
463 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } 464 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
464 465
465 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset); 466 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset);
467 // must only be called by tests when updating scroll offset of a single layer,
468 // the standard process to update scroll offsets is
469 // ScrollTree::UpdateScrollOffsetMap()
ajuma 2016/03/01 22:54:20 Please make this a complete sentence.
sunxd 2016/03/02 17:45:34 Done.
466 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset); 470 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset);
ajuma 2016/03/01 22:54:20 If this is only for tests, it should be called som
sunxd 2016/03/02 17:45:34 I think some tests call this function to set the i
ajuma 2016/03/02 18:43:09 Refactoring the tests in another CL seems fine. Wh
sunxd 2016/03/02 20:52:55 I think the function will probably go away in next
467 // This method is similar to PushScrollOffsetFromMainThread but will cause the 471
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; 472 gfx::ScrollOffset CurrentScrollOffset() const;
474 gfx::ScrollOffset BaseScrollOffset() const; 473 gfx::ScrollOffset BaseScrollOffset() const;
475 gfx::Vector2dF ScrollDelta() const; 474 gfx::Vector2dF ScrollDelta() const;
476 void SetScrollDelta(const gfx::Vector2dF& delta); 475 void SetScrollDelta(const gfx::Vector2dF& delta);
476 // This is a mirror function of Layer::scroll_offset, which is supposed to be
477 // called only by PropertyTreeBuilder
478 gfx::ScrollOffset scroll_offset() const {
479 return synced_scroll_offset()->PendingBase();
ajuma 2016/03/01 22:54:20 Could PropertyTreeBuilder call CurrentScrollOffset
sunxd 2016/03/02 17:45:34 Currently CurrentScrollOffset returns the combined
ajuma 2016/03/02 18:43:09 These would only have different values if there ar
sunxd 2016/03/02 20:52:55 The unit test that breaks is https://code.google.c
ajuma 2016/03/02 22:31:08 That test isn't really testing anything meaningful
480 }
477 481
478 gfx::ScrollOffset MaxScrollOffset() const; 482 gfx::ScrollOffset MaxScrollOffset() const;
479 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const; 483 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const;
480 gfx::Vector2dF ClampScrollToMaxScrollOffset(); 484 gfx::Vector2dF ClampScrollToMaxScrollOffset();
481 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) { 485 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) {
482 scroll_compensation_adjustment_ = scroll_offset; 486 scroll_compensation_adjustment_ = scroll_offset;
483 } 487 }
484 gfx::Vector2dF ScrollCompensationAdjustment() const { 488 gfx::Vector2dF ScrollCompensationAdjustment() const {
485 return scroll_compensation_adjustment_; 489 return scroll_compensation_adjustment_;
486 } 490 }
(...skipping 13 matching lines...) Expand all
500 bool user_scrollable_horizontal() const { 504 bool user_scrollable_horizontal() const {
501 return user_scrollable_horizontal_; 505 return user_scrollable_horizontal_;
502 } 506 }
503 void set_user_scrollable_vertical(bool scrollable) { 507 void set_user_scrollable_vertical(bool scrollable) {
504 user_scrollable_vertical_ = scrollable; 508 user_scrollable_vertical_ = scrollable;
505 } 509 }
506 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 510 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
507 511
508 bool user_scrollable(ScrollbarOrientation orientation) const; 512 bool user_scrollable(ScrollbarOrientation orientation) const;
509 513
510 void ApplySentScrollDeltasFromAbortedCommit();
511
512 void set_main_thread_scrolling_reasons( 514 void set_main_thread_scrolling_reasons(
513 uint32_t main_thread_scrolling_reasons); 515 uint32_t main_thread_scrolling_reasons);
514 uint32_t main_thread_scrolling_reasons() const { 516 uint32_t main_thread_scrolling_reasons() const {
515 return main_thread_scrolling_reasons_; 517 return main_thread_scrolling_reasons_;
516 } 518 }
517 bool should_scroll_on_main_thread() const { 519 bool should_scroll_on_main_thread() const {
518 return !!main_thread_scrolling_reasons_; 520 return !!main_thread_scrolling_reasons_;
519 } 521 }
520 522
521 void SetNonFastScrollableRegion(const Region& region) { 523 void SetNonFastScrollableRegion(const Region& region) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 void Set3dSortingContextId(int id); 632 void Set3dSortingContextId(int id);
631 int sorting_context_id() { return sorting_context_id_; } 633 int sorting_context_id() { return sorting_context_id_; }
632 634
633 void SetFrameTimingRequests( 635 void SetFrameTimingRequests(
634 const std::vector<FrameTimingRequest>& frame_timing_requests); 636 const std::vector<FrameTimingRequest>& frame_timing_requests);
635 const std::vector<FrameTimingRequest>& frame_timing_requests() const { 637 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
636 return frame_timing_requests_; 638 return frame_timing_requests_;
637 } 639 }
638 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids); 640 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids);
639 641
640 SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); } 642 const SyncedScrollOffset* synced_scroll_offset() const;
643 SyncedScrollOffset* synced_scroll_offset();
641 644
642 // Get the correct invalidation region instead of conservative Rect 645 // Get the correct invalidation region instead of conservative Rect
643 // for layers that provide it. 646 // for layers that provide it.
644 virtual Region GetInvalidationRegion(); 647 virtual Region GetInvalidationRegion();
645 648
646 virtual gfx::Rect GetEnclosingRectInTargetSpace() const; 649 virtual gfx::Rect GetEnclosingRectInTargetSpace() const;
647 650
648 void set_visited(bool visited) { visited_ = visited; } 651 void set_visited(bool visited) { visited_ = visited; }
649 652
650 bool visited() { return visited_; } 653 bool visited() { return visited_; }
(...skipping 29 matching lines...) Expand all
680 683
681 bool was_ever_ready_since_last_transform_animation() const { 684 bool was_ever_ready_since_last_transform_animation() const {
682 return was_ever_ready_since_last_transform_animation_; 685 return was_ever_ready_since_last_transform_animation_;
683 } 686 }
684 687
685 void set_was_ever_ready_since_last_transform_animation(bool was_ready) { 688 void set_was_ever_ready_since_last_transform_animation(bool was_ready) {
686 was_ever_ready_since_last_transform_animation_ = was_ready; 689 was_ever_ready_since_last_transform_animation_ = was_ready;
687 } 690 }
688 691
689 void NoteLayerPropertyChanged(); 692 void NoteLayerPropertyChanged();
693 void DidUpdateScrollOffset();
690 694
691 void PushLayerPropertyChangedForSubtree(); 695 void PushLayerPropertyChangedForSubtree();
692 696
693 protected: 697 protected:
694 LayerImpl(LayerTreeImpl* layer_impl, 698 LayerImpl(LayerTreeImpl* layer_impl,
695 int id, 699 int id,
696 scoped_refptr<SyncedScrollOffset> scroll_offset); 700 scoped_refptr<SyncedScrollOffset> scroll_offset);
697 LayerImpl(LayerTreeImpl* layer_impl, int id); 701 LayerImpl(LayerTreeImpl* layer_impl, int id);
698 702
699 // Get the color and size of the layer's debug border. 703 // Get the color and size of the layer's debug border.
(...skipping 13 matching lines...) Expand all
713 void NoteLayerPropertyChangedForSubtree(); 717 void NoteLayerPropertyChangedForSubtree();
714 718
715 // Note carefully this does not affect the current layer. 719 // Note carefully this does not affect the current layer.
716 void NoteLayerPropertyChangedForDescendants(); 720 void NoteLayerPropertyChangedForDescendants();
717 721
718 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; 722 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const;
719 723
720 private: 724 private:
721 void ValidateQuadResourcesInternal(DrawQuad* quad) const; 725 void ValidateQuadResourcesInternal(DrawQuad* quad) const;
722 726
723 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset);
724 void DidUpdateScrollOffset();
725 void NoteLayerPropertyChangedForDescendantsInternal(); 727 void NoteLayerPropertyChangedForDescendantsInternal();
726 void PushLayerPropertyChangedForSubtreeInternal(); 728 void PushLayerPropertyChangedForSubtreeInternal();
727 729
728 virtual const char* LayerTypeAsString() const; 730 virtual const char* LayerTypeAsString() const;
729 731
730 // Properties internal to LayerImpl 732 // Properties internal to LayerImpl
731 LayerImpl* parent_; 733 LayerImpl* parent_;
732 OwnedLayerImplList children_; 734 OwnedLayerImplList children_;
733 735
734 LayerImpl* scroll_parent_; 736 LayerImpl* scroll_parent_;
(...skipping 10 matching lines...) Expand all
745 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 747 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
746 // confirm newly assigned layer is still the previous one 748 // confirm newly assigned layer is still the previous one
747 int mask_layer_id_; 749 int mask_layer_id_;
748 scoped_ptr<LayerImpl> mask_layer_; 750 scoped_ptr<LayerImpl> mask_layer_;
749 int replica_layer_id_; // ditto 751 int replica_layer_id_; // ditto
750 scoped_ptr<LayerImpl> replica_layer_; 752 scoped_ptr<LayerImpl> replica_layer_;
751 int layer_id_; 753 int layer_id_;
752 LayerTreeImpl* layer_tree_impl_; 754 LayerTreeImpl* layer_tree_impl_;
753 LayerListImpl* layer_list_impl_; 755 LayerListImpl* layer_list_impl_;
754 756
755 // Properties dynamically changeable on active tree.
756 scoped_refptr<SyncedScrollOffset> scroll_offset_;
757 gfx::Vector2dF bounds_delta_; 757 gfx::Vector2dF bounds_delta_;
758 758
759 // Properties synchronized from the associated Layer. 759 // Properties synchronized from the associated Layer.
760 gfx::Point3F transform_origin_; 760 gfx::Point3F transform_origin_;
761 gfx::Size bounds_; 761 gfx::Size bounds_;
762 int scroll_clip_layer_id_; 762 int scroll_clip_layer_id_;
763 763
764 gfx::Vector2dF offset_to_transform_parent_; 764 gfx::Vector2dF offset_to_transform_parent_;
765 uint32_t main_thread_scrolling_reasons_; 765 uint32_t main_thread_scrolling_reasons_;
766 766
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 // If true, the layer or one of its descendants has a touch handler. 881 // If true, the layer or one of its descendants has a touch handler.
882 bool layer_or_descendant_has_touch_handler_; 882 bool layer_or_descendant_has_touch_handler_;
883 bool sorted_for_recursion_; 883 bool sorted_for_recursion_;
884 884
885 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 885 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
886 }; 886 };
887 887
888 } // namespace cc 888 } // namespace cc
889 889
890 #endif // CC_LAYERS_LAYER_IMPL_H_ 890 #endif // CC_LAYERS_LAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698