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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 DRAW_MODE_NONE, | 73 DRAW_MODE_NONE, |
74 DRAW_MODE_HARDWARE, | 74 DRAW_MODE_HARDWARE, |
75 DRAW_MODE_SOFTWARE, | 75 DRAW_MODE_SOFTWARE, |
76 DRAW_MODE_RESOURCELESS_SOFTWARE | 76 DRAW_MODE_RESOURCELESS_SOFTWARE |
77 }; | 77 }; |
78 | 78 |
79 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, | 79 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, |
80 public LayerAnimationValueProvider, | 80 public LayerAnimationValueProvider, |
81 public AnimationDelegate { | 81 public AnimationDelegate { |
82 public: | 82 public: |
83 // Allows for the ownership of the total scroll offset to be delegated outside | |
84 // of the layer. | |
85 class ScrollOffsetDelegate { | |
86 public: | |
87 virtual void SetCurrentScrollOffset(const gfx::ScrollOffset& new_value) = 0; | |
88 virtual gfx::ScrollOffset GetCurrentScrollOffset() = 0; | |
89 virtual bool IsExternalFlingActive() const = 0; | |
90 virtual void Update() const = 0; | |
91 }; | |
92 | |
93 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset; | 83 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset; |
94 typedef LayerImplList RenderSurfaceListType; | 84 typedef LayerImplList RenderSurfaceListType; |
95 typedef LayerImplList LayerListType; | 85 typedef LayerImplList LayerListType; |
96 typedef RenderSurfaceImpl RenderSurfaceType; | 86 typedef RenderSurfaceImpl RenderSurfaceType; |
97 | 87 |
98 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; | 88 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; |
99 | 89 |
100 static scoped_ptr<LayerImpl> Create( | 90 static scoped_ptr<LayerImpl> Create( |
101 LayerTreeImpl* tree_impl, | 91 LayerTreeImpl* tree_impl, |
102 int id, | 92 int id, |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta); | 373 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta); |
384 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } | 374 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } |
385 | 375 |
386 void SetContentBounds(const gfx::Size& content_bounds); | 376 void SetContentBounds(const gfx::Size& content_bounds); |
387 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } | 377 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } |
388 | 378 |
389 float contents_scale_x() const { return draw_properties_.contents_scale_x; } | 379 float contents_scale_x() const { return draw_properties_.contents_scale_x; } |
390 float contents_scale_y() const { return draw_properties_.contents_scale_y; } | 380 float contents_scale_y() const { return draw_properties_.contents_scale_y; } |
391 void SetContentsScale(float contents_scale_x, float contents_scale_y); | 381 void SetContentsScale(float contents_scale_x, float contents_scale_y); |
392 | 382 |
393 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate); | |
394 void RefreshFromScrollDelegate(); | |
395 bool IsExternalFlingActive() const; | 383 bool IsExternalFlingActive() const; |
396 | 384 |
397 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset); | 385 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset); |
| 386 void SetCurrentScrollOffsetFromDelegate( |
| 387 const gfx::ScrollOffset& scroll_offset); |
398 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset); | 388 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset); |
399 // This method is similar to PushScrollOffsetFromMainThread but will cause the | 389 // This method is similar to PushScrollOffsetFromMainThread but will cause the |
400 // scroll offset given to clobber any scroll changes on the active tree in the | 390 // scroll offset given to clobber any scroll changes on the active tree in the |
401 // time until this value is pushed to the active tree. | 391 // time until this value is pushed to the active tree. |
402 void PushScrollOffsetFromMainThreadAndClobberActiveValue( | 392 void PushScrollOffsetFromMainThreadAndClobberActiveValue( |
403 const gfx::ScrollOffset& scroll_offset); | 393 const gfx::ScrollOffset& scroll_offset); |
404 gfx::ScrollOffset PullDeltaForMainThread(); | 394 gfx::ScrollOffset PullDeltaForMainThread(); |
405 gfx::ScrollOffset CurrentScrollOffset() const; | 395 gfx::ScrollOffset CurrentScrollOffset() const; |
406 gfx::ScrollOffset BaseScrollOffset() const; | 396 gfx::ScrollOffset BaseScrollOffset() const; |
407 gfx::Vector2dF ScrollDelta() const; | 397 gfx::Vector2dF ScrollDelta() const; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 void NoteLayerPropertyChanged(); | 619 void NoteLayerPropertyChanged(); |
630 void NoteLayerPropertyChangedForSubtree(); | 620 void NoteLayerPropertyChangedForSubtree(); |
631 | 621 |
632 // Note carefully this does not affect the current layer. | 622 // Note carefully this does not affect the current layer. |
633 void NoteLayerPropertyChangedForDescendants(); | 623 void NoteLayerPropertyChangedForDescendants(); |
634 | 624 |
635 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; | 625 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; |
636 | 626 |
637 private: | 627 private: |
638 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset); | 628 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset); |
639 void DidUpdateScrollOffset(); | 629 // If the new scroll offset is assigned from the root scroll offset delegate, |
| 630 // LayerImpl won't inform the root scroll offset delegate about the scroll |
| 631 // change to avoid feedback. |
| 632 void DidUpdateScrollOffset(bool is_from_root_delegate); |
640 void NoteLayerPropertyChangedForDescendantsInternal(); | 633 void NoteLayerPropertyChangedForDescendantsInternal(); |
641 | 634 |
642 virtual const char* LayerTypeAsString() const; | 635 virtual const char* LayerTypeAsString() const; |
643 | 636 |
644 // Properties internal to LayerImpl | 637 // Properties internal to LayerImpl |
645 LayerImpl* parent_; | 638 LayerImpl* parent_; |
646 OwnedLayerImplList children_; | 639 OwnedLayerImplList children_; |
647 | 640 |
648 LayerImpl* scroll_parent_; | 641 LayerImpl* scroll_parent_; |
649 | 642 |
(...skipping 15 matching lines...) Expand all Loading... |
665 int layer_id_; | 658 int layer_id_; |
666 LayerTreeImpl* layer_tree_impl_; | 659 LayerTreeImpl* layer_tree_impl_; |
667 | 660 |
668 // Properties dynamically changeable on active tree. | 661 // Properties dynamically changeable on active tree. |
669 scoped_refptr<SyncedScrollOffset> scroll_offset_; | 662 scoped_refptr<SyncedScrollOffset> scroll_offset_; |
670 gfx::Vector2dF bounds_delta_; | 663 gfx::Vector2dF bounds_delta_; |
671 | 664 |
672 // Properties synchronized from the associated Layer. | 665 // Properties synchronized from the associated Layer. |
673 gfx::Point3F transform_origin_; | 666 gfx::Point3F transform_origin_; |
674 gfx::Size bounds_; | 667 gfx::Size bounds_; |
675 ScrollOffsetDelegate* scroll_offset_delegate_; | |
676 LayerImpl* scroll_clip_layer_; | 668 LayerImpl* scroll_clip_layer_; |
677 bool scrollable_ : 1; | 669 bool scrollable_ : 1; |
678 bool should_scroll_on_main_thread_ : 1; | 670 bool should_scroll_on_main_thread_ : 1; |
679 bool have_wheel_event_handlers_ : 1; | 671 bool have_wheel_event_handlers_ : 1; |
680 bool have_scroll_event_handlers_ : 1; | 672 bool have_scroll_event_handlers_ : 1; |
681 | 673 |
682 static_assert(SCROLL_BLOCKS_ON_MAX < (1 << 3), "ScrollBlocksOn too big"); | 674 static_assert(SCROLL_BLOCKS_ON_MAX < (1 << 3), "ScrollBlocksOn too big"); |
683 ScrollBlocksOn scroll_blocks_on_ : 3; | 675 ScrollBlocksOn scroll_blocks_on_ : 3; |
684 | 676 |
685 bool user_scrollable_horizontal_ : 1; | 677 bool user_scrollable_horizontal_ : 1; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 766 |
775 std::vector<FrameTimingRequest> frame_timing_requests_; | 767 std::vector<FrameTimingRequest> frame_timing_requests_; |
776 bool frame_timing_requests_dirty_; | 768 bool frame_timing_requests_dirty_; |
777 | 769 |
778 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 770 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
779 }; | 771 }; |
780 | 772 |
781 } // namespace cc | 773 } // namespace cc |
782 | 774 |
783 #endif // CC_LAYERS_LAYER_IMPL_H_ | 775 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |