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