| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 377 |
| 378 void SetScrollOffsetDelegate( | 378 void SetScrollOffsetDelegate( |
| 379 LayerScrollOffsetDelegate* scroll_offset_delegate); | 379 LayerScrollOffsetDelegate* scroll_offset_delegate); |
| 380 bool IsExternalFlingActive() const; | 380 bool IsExternalFlingActive() const; |
| 381 | 381 |
| 382 void SetScrollOffset(gfx::Vector2d scroll_offset); | 382 void SetScrollOffset(gfx::Vector2d scroll_offset); |
| 383 void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset, | 383 void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset, |
| 384 gfx::Vector2dF scroll_delta); | 384 gfx::Vector2dF scroll_delta); |
| 385 gfx::Vector2d scroll_offset() const { return scroll_offset_; } | 385 gfx::Vector2d scroll_offset() const { return scroll_offset_; } |
| 386 | 386 |
| 387 void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset); | 387 gfx::Vector2d MaxScrollOffset() const; |
| 388 gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; } | 388 gfx::Vector2dF ClampScrollToMaxScrollOffset(); |
| 389 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, |
| 390 LayerImpl* scrollbar_clip_layer) const; |
| 389 | 391 |
| 390 void SetScrollDelta(gfx::Vector2dF scroll_delta); | 392 void SetScrollDelta(gfx::Vector2dF scroll_delta); |
| 391 gfx::Vector2dF ScrollDelta() const; | 393 gfx::Vector2dF ScrollDelta() const; |
| 392 | 394 |
| 393 gfx::Vector2dF TotalScrollOffset() const; | 395 gfx::Vector2dF TotalScrollOffset() const; |
| 394 | 396 |
| 395 void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta); | 397 void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta); |
| 396 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } | 398 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } |
| 397 | 399 |
| 398 // Returns the delta of the scroll that was outside of the bounds of the | 400 // Returns the delta of the scroll that was outside of the bounds of the |
| 399 // initial scroll | 401 // initial scroll |
| 400 gfx::Vector2dF ScrollBy(gfx::Vector2dF scroll); | 402 gfx::Vector2dF ScrollBy(gfx::Vector2dF scroll); |
| 401 | 403 |
| 402 void SetScrollable(bool scrollable) { scrollable_ = scrollable; } | 404 void SetScrollClipLayer(int clip_layer_id); |
| 403 bool scrollable() const { return scrollable_; } | 405 bool scrollable() const { return clip_layer_; } |
| 404 | 406 |
| 405 void set_user_scrollable_horizontal(bool scrollable) { | 407 void set_user_scrollable_horizontal(bool scrollable) { |
| 406 user_scrollable_horizontal_ = scrollable; | 408 user_scrollable_horizontal_ = scrollable; |
| 407 } | 409 } |
| 408 void set_user_scrollable_vertical(bool scrollable) { | 410 void set_user_scrollable_vertical(bool scrollable) { |
| 409 user_scrollable_vertical_ = scrollable; | 411 user_scrollable_vertical_ = scrollable; |
| 410 } | 412 } |
| 411 | 413 |
| 412 void ApplySentScrollDeltasFromAbortedCommit(); | 414 void ApplySentScrollDeltasFromAbortedCommit(); |
| 413 void ApplyScrollDeltasSinceBeginMainFrame(); | 415 void ApplyScrollDeltasSinceBeginMainFrame(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 487 |
| 486 // Indicates that the surface previously used to render this layer | 488 // Indicates that the surface previously used to render this layer |
| 487 // was lost and that a new one has been created. Won't be called | 489 // was lost and that a new one has been created. Won't be called |
| 488 // until the new surface has been created successfully. | 490 // until the new surface has been created successfully. |
| 489 virtual void DidLoseOutputSurface(); | 491 virtual void DidLoseOutputSurface(); |
| 490 | 492 |
| 491 ScrollbarAnimationController* scrollbar_animation_controller() const { | 493 ScrollbarAnimationController* scrollbar_animation_controller() const { |
| 492 return scrollbar_animation_controller_.get(); | 494 return scrollbar_animation_controller_.get(); |
| 493 } | 495 } |
| 494 | 496 |
| 495 void SetHorizontalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer); | 497 typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet; |
| 496 ScrollbarLayerImplBase* horizontal_scrollbar_layer() { | 498 ScrollbarSet* scrollbars() { return scrollbars_.get(); } |
| 497 return horizontal_scrollbar_layer_; | 499 void ClearScrollbars(); |
| 498 } | 500 void AddScrollbar(ScrollbarLayerImplBase* layer); |
| 499 | 501 void RemoveScrollbar(ScrollbarLayerImplBase* layer); |
| 500 void SetVerticalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer); | 502 bool HasScrollbar(ScrollbarOrientation orientation) const; |
| 501 ScrollbarLayerImplBase* vertical_scrollbar_layer() { | 503 void ScrollbarParametersDidChange(); |
| 502 return vertical_scrollbar_layer_; | 504 int clip_height() { return clip_layer_ ? clip_layer_->bounds().height() : 0; } |
| 503 } | |
| 504 | 505 |
| 505 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; | 506 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; |
| 506 | 507 |
| 507 virtual skia::RefPtr<SkPicture> GetPicture(); | 508 virtual skia::RefPtr<SkPicture> GetPicture(); |
| 508 | 509 |
| 509 virtual bool AreVisibleResourcesReady() const; | 510 virtual bool AreVisibleResourcesReady() const; |
| 510 | 511 |
| 511 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); | 512 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
| 512 virtual void PushPropertiesTo(LayerImpl* layer); | 513 virtual void PushPropertiesTo(LayerImpl* layer); |
| 513 | 514 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 540 | 541 |
| 541 virtual void AsValueInto(base::DictionaryValue* dict) const; | 542 virtual void AsValueInto(base::DictionaryValue* dict) const; |
| 542 | 543 |
| 543 void NoteLayerPropertyChanged(); | 544 void NoteLayerPropertyChanged(); |
| 544 void NoteLayerPropertyChangedForSubtree(); | 545 void NoteLayerPropertyChangedForSubtree(); |
| 545 | 546 |
| 546 // Note carefully this does not affect the current layer. | 547 // Note carefully this does not affect the current layer. |
| 547 void NoteLayerPropertyChangedForDescendants(); | 548 void NoteLayerPropertyChangedForDescendants(); |
| 548 | 549 |
| 549 private: | 550 private: |
| 550 void UpdateScrollbarPositions(); | |
| 551 | |
| 552 virtual const char* LayerTypeAsString() const; | 551 virtual const char* LayerTypeAsString() const; |
| 553 | 552 |
| 554 // Properties internal to LayerImpl | 553 // Properties internal to LayerImpl |
| 555 LayerImpl* parent_; | 554 LayerImpl* parent_; |
| 556 OwnedLayerImplList children_; | 555 OwnedLayerImplList children_; |
| 557 | 556 |
| 558 LayerImpl* scroll_parent_; | 557 LayerImpl* scroll_parent_; |
| 559 | 558 |
| 560 // Storing a pointer to a set rather than a set since this will be rarely | 559 // Storing a pointer to a set rather than a set since this will be rarely |
| 561 // used. If this pointer turns out to be too heavy, we could have this (and | 560 // used. If this pointer turns out to be too heavy, we could have this (and |
| (...skipping 12 matching lines...) Expand all Loading... |
| 574 scoped_ptr<LayerImpl> replica_layer_; | 573 scoped_ptr<LayerImpl> replica_layer_; |
| 575 int layer_id_; | 574 int layer_id_; |
| 576 LayerTreeImpl* layer_tree_impl_; | 575 LayerTreeImpl* layer_tree_impl_; |
| 577 | 576 |
| 578 // Properties synchronized from the associated Layer. | 577 // Properties synchronized from the associated Layer. |
| 579 gfx::PointF anchor_point_; | 578 gfx::PointF anchor_point_; |
| 580 float anchor_point_z_; | 579 float anchor_point_z_; |
| 581 gfx::Size bounds_; | 580 gfx::Size bounds_; |
| 582 gfx::Vector2d scroll_offset_; | 581 gfx::Vector2d scroll_offset_; |
| 583 LayerScrollOffsetDelegate* scroll_offset_delegate_; | 582 LayerScrollOffsetDelegate* scroll_offset_delegate_; |
| 583 LayerImpl* clip_layer_; |
| 584 bool scrollable_ : 1; | 584 bool scrollable_ : 1; |
| 585 bool should_scroll_on_main_thread_ : 1; | 585 bool should_scroll_on_main_thread_ : 1; |
| 586 bool have_wheel_event_handlers_ : 1; | 586 bool have_wheel_event_handlers_ : 1; |
| 587 bool user_scrollable_horizontal_ : 1; | 587 bool user_scrollable_horizontal_ : 1; |
| 588 bool user_scrollable_vertical_ : 1; | 588 bool user_scrollable_vertical_ : 1; |
| 589 bool stacking_order_changed_ : 1; | 589 bool stacking_order_changed_ : 1; |
| 590 // Whether the "back" of this layer should draw. | 590 // Whether the "back" of this layer should draw. |
| 591 bool double_sided_ : 1; | 591 bool double_sided_ : 1; |
| 592 | 592 |
| 593 // Tracks if drawing-related properties have changed since last redraw. | 593 // Tracks if drawing-related properties have changed since last redraw. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 616 gfx::Transform transform_; | 616 gfx::Transform transform_; |
| 617 | 617 |
| 618 // This property is effective when | 618 // This property is effective when |
| 619 // is_container_for_fixed_position_layers_ == true, | 619 // is_container_for_fixed_position_layers_ == true, |
| 620 gfx::Vector2dF fixed_container_size_delta_; | 620 gfx::Vector2dF fixed_container_size_delta_; |
| 621 | 621 |
| 622 LayerPositionConstraint position_constraint_; | 622 LayerPositionConstraint position_constraint_; |
| 623 | 623 |
| 624 gfx::Vector2dF scroll_delta_; | 624 gfx::Vector2dF scroll_delta_; |
| 625 gfx::Vector2d sent_scroll_delta_; | 625 gfx::Vector2d sent_scroll_delta_; |
| 626 gfx::Vector2d max_scroll_offset_; | |
| 627 gfx::Vector2dF last_scroll_offset_; | 626 gfx::Vector2dF last_scroll_offset_; |
| 628 | 627 |
| 629 // The global depth value of the center of the layer. This value is used | 628 // The global depth value of the center of the layer. This value is used |
| 630 // to sort layers from back to front. | 629 // to sort layers from back to front. |
| 631 float draw_depth_; | 630 float draw_depth_; |
| 632 | 631 |
| 633 // Debug layer name. | 632 // Debug layer name. |
| 634 std::string debug_name_; | 633 std::string debug_name_; |
| 635 CompositingReasons compositing_reasons_; | 634 CompositingReasons compositing_reasons_; |
| 636 | 635 |
| 637 FilterOperations filters_; | 636 FilterOperations filters_; |
| 638 FilterOperations background_filters_; | 637 FilterOperations background_filters_; |
| 639 | 638 |
| 640 protected: | 639 protected: |
| 641 DrawMode current_draw_mode_; | 640 DrawMode current_draw_mode_; |
| 642 | 641 |
| 643 private: | 642 private: |
| 644 // Rect indicating what was repainted/updated during update. | 643 // Rect indicating what was repainted/updated during update. |
| 645 // Note that plugin layers bypass this and leave it empty. | 644 // Note that plugin layers bypass this and leave it empty. |
| 646 // Uses layer (not content) space. | 645 // Uses layer (not content) space. |
| 647 gfx::RectF update_rect_; | 646 gfx::RectF update_rect_; |
| 648 | 647 |
| 649 // Manages animations for this layer. | 648 // Manages animations for this layer. |
| 650 scoped_refptr<LayerAnimationController> layer_animation_controller_; | 649 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
| 651 | 650 |
| 652 // Manages scrollbars for this layer | 651 // Manages scrollbars for this layer |
| 653 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; | 652 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; |
| 654 | 653 |
| 655 // Weak pointers to this layer's scrollbars, if it has them. Updated during | 654 scoped_ptr<ScrollbarSet> scrollbars_; |
| 656 // tree synchronization. | |
| 657 ScrollbarLayerImplBase* horizontal_scrollbar_layer_; | |
| 658 ScrollbarLayerImplBase* vertical_scrollbar_layer_; | |
| 659 | 655 |
| 660 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 656 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
| 661 | 657 |
| 662 // Group of properties that need to be computed based on the layer tree | 658 // Group of properties that need to be computed based on the layer tree |
| 663 // hierarchy before layers can be drawn. | 659 // hierarchy before layers can be drawn. |
| 664 DrawProperties<LayerImpl> draw_properties_; | 660 DrawProperties<LayerImpl> draw_properties_; |
| 665 | 661 |
| 666 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; | 662 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; |
| 667 | 663 |
| 668 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 664 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
| 669 }; | 665 }; |
| 670 | 666 |
| 671 } // namespace cc | 667 } // namespace cc |
| 672 | 668 |
| 673 #endif // CC_LAYERS_LAYER_IMPL_H_ | 669 #endif // CC_LAYERS_LAYER_IMPL_H_ |
| OLD | NEW |