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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 void SetScrollOffsetDelegate( | 367 void SetScrollOffsetDelegate( |
368 LayerScrollOffsetDelegate* scroll_offset_delegate); | 368 LayerScrollOffsetDelegate* scroll_offset_delegate); |
369 bool IsExternalFlingActive() const; | 369 bool IsExternalFlingActive() const; |
370 | 370 |
371 void SetScrollOffset(gfx::Vector2d scroll_offset); | 371 void SetScrollOffset(gfx::Vector2d scroll_offset); |
372 void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset, | 372 void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset, |
373 const gfx::Vector2dF& scroll_delta); | 373 const gfx::Vector2dF& scroll_delta); |
374 gfx::Vector2d scroll_offset() const { return scroll_offset_; } | 374 gfx::Vector2d scroll_offset() const { return scroll_offset_; } |
375 | 375 |
376 gfx::Vector2d MaxScrollOffset() const; | 376 void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset); |
377 gfx::Vector2dF ClampScrollToMaxScrollOffset(); | 377 gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; } |
378 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, | |
379 LayerImpl* scrollbar_clip_layer) const; | |
380 | 378 |
381 void SetScrollDelta(const gfx::Vector2dF& scroll_delta); | 379 void SetScrollDelta(const gfx::Vector2dF& scroll_delta); |
382 gfx::Vector2dF ScrollDelta() const; | 380 gfx::Vector2dF ScrollDelta() const; |
383 | 381 |
384 gfx::Vector2dF TotalScrollOffset() const; | 382 gfx::Vector2dF TotalScrollOffset() const; |
385 | 383 |
386 void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta); | 384 void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta); |
387 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } | 385 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } |
388 | 386 |
389 // Returns the delta of the scroll that was outside of the bounds of the | 387 // Returns the delta of the scroll that was outside of the bounds of the |
390 // initial scroll | 388 // initial scroll |
391 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll); | 389 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll); |
392 | 390 |
393 void SetScrollClipLayer(int scroll_clip_layer_id); | 391 void SetScrollable(bool scrollable) { scrollable_ = scrollable; } |
394 bool scrollable() const { return !!scroll_clip_layer_; } | 392 bool scrollable() const { return scrollable_; } |
395 | 393 |
396 void set_user_scrollable_horizontal(bool scrollable) { | 394 void set_user_scrollable_horizontal(bool scrollable) { |
397 user_scrollable_horizontal_ = scrollable; | 395 user_scrollable_horizontal_ = scrollable; |
398 } | 396 } |
399 void set_user_scrollable_vertical(bool scrollable) { | 397 void set_user_scrollable_vertical(bool scrollable) { |
400 user_scrollable_vertical_ = scrollable; | 398 user_scrollable_vertical_ = scrollable; |
401 } | 399 } |
402 | 400 |
403 void ApplySentScrollDeltasFromAbortedCommit(); | 401 void ApplySentScrollDeltasFromAbortedCommit(); |
404 void ApplyScrollDeltasSinceBeginMainFrame(); | 402 void ApplyScrollDeltasSinceBeginMainFrame(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 virtual void DidBeginTracing(); | 472 virtual void DidBeginTracing(); |
475 | 473 |
476 // Release resources held by this layer. Called when the output surface | 474 // Release resources held by this layer. Called when the output surface |
477 // that rendered this layer was lost or a rendering mode switch has occured. | 475 // that rendered this layer was lost or a rendering mode switch has occured. |
478 virtual void ReleaseResources(); | 476 virtual void ReleaseResources(); |
479 | 477 |
480 ScrollbarAnimationController* scrollbar_animation_controller() const { | 478 ScrollbarAnimationController* scrollbar_animation_controller() const { |
481 return scrollbar_animation_controller_.get(); | 479 return scrollbar_animation_controller_.get(); |
482 } | 480 } |
483 | 481 |
484 typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet; | 482 void SetHorizontalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer); |
485 ScrollbarSet* scrollbars() { return scrollbars_.get(); } | 483 ScrollbarLayerImplBase* horizontal_scrollbar_layer() { |
486 void ClearScrollbars(); | 484 return horizontal_scrollbar_layer_; |
487 void AddScrollbar(ScrollbarLayerImplBase* layer); | 485 } |
488 void RemoveScrollbar(ScrollbarLayerImplBase* layer); | 486 |
489 bool HasScrollbar(ScrollbarOrientation orientation) const; | 487 void SetVerticalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer); |
490 void ScrollbarParametersDidChange(); | 488 ScrollbarLayerImplBase* vertical_scrollbar_layer() { |
491 int clip_height() { | 489 return vertical_scrollbar_layer_; |
492 return scroll_clip_layer_ ? scroll_clip_layer_->bounds().height() : 0; | |
493 } | 490 } |
494 | 491 |
495 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; | 492 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; |
496 | 493 |
497 virtual skia::RefPtr<SkPicture> GetPicture(); | 494 virtual skia::RefPtr<SkPicture> GetPicture(); |
498 | 495 |
499 virtual bool AreVisibleResourcesReady() const; | 496 virtual bool AreVisibleResourcesReady() const; |
500 | 497 |
501 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); | 498 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
502 virtual void PushPropertiesTo(LayerImpl* layer); | 499 virtual void PushPropertiesTo(LayerImpl* layer); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 537 |
541 void NoteLayerPropertyChanged(); | 538 void NoteLayerPropertyChanged(); |
542 void NoteLayerPropertyChangedForSubtree(); | 539 void NoteLayerPropertyChangedForSubtree(); |
543 | 540 |
544 // Note carefully this does not affect the current layer. | 541 // Note carefully this does not affect the current layer. |
545 void NoteLayerPropertyChangedForDescendants(); | 542 void NoteLayerPropertyChangedForDescendants(); |
546 | 543 |
547 private: | 544 private: |
548 void NoteLayerPropertyChangedForDescendantsInternal(); | 545 void NoteLayerPropertyChangedForDescendantsInternal(); |
549 | 546 |
| 547 void UpdateScrollbarPositions(); |
| 548 |
550 virtual const char* LayerTypeAsString() const; | 549 virtual const char* LayerTypeAsString() const; |
551 | 550 |
552 // Properties internal to LayerImpl | 551 // Properties internal to LayerImpl |
553 LayerImpl* parent_; | 552 LayerImpl* parent_; |
554 OwnedLayerImplList children_; | 553 OwnedLayerImplList children_; |
555 | 554 |
556 LayerImpl* scroll_parent_; | 555 LayerImpl* scroll_parent_; |
557 | 556 |
558 // Storing a pointer to a set rather than a set since this will be rarely | 557 // Storing a pointer to a set rather than a set since this will be rarely |
559 // used. If this pointer turns out to be too heavy, we could have this (and | 558 // used. If this pointer turns out to be too heavy, we could have this (and |
(...skipping 12 matching lines...) Expand all Loading... |
572 scoped_ptr<LayerImpl> replica_layer_; | 571 scoped_ptr<LayerImpl> replica_layer_; |
573 int layer_id_; | 572 int layer_id_; |
574 LayerTreeImpl* layer_tree_impl_; | 573 LayerTreeImpl* layer_tree_impl_; |
575 | 574 |
576 // Properties synchronized from the associated Layer. | 575 // Properties synchronized from the associated Layer. |
577 gfx::PointF anchor_point_; | 576 gfx::PointF anchor_point_; |
578 float anchor_point_z_; | 577 float anchor_point_z_; |
579 gfx::Size bounds_; | 578 gfx::Size bounds_; |
580 gfx::Vector2d scroll_offset_; | 579 gfx::Vector2d scroll_offset_; |
581 LayerScrollOffsetDelegate* scroll_offset_delegate_; | 580 LayerScrollOffsetDelegate* scroll_offset_delegate_; |
582 LayerImpl* scroll_clip_layer_; | |
583 bool scrollable_ : 1; | 581 bool scrollable_ : 1; |
584 bool should_scroll_on_main_thread_ : 1; | 582 bool should_scroll_on_main_thread_ : 1; |
585 bool have_wheel_event_handlers_ : 1; | 583 bool have_wheel_event_handlers_ : 1; |
586 bool user_scrollable_horizontal_ : 1; | 584 bool user_scrollable_horizontal_ : 1; |
587 bool user_scrollable_vertical_ : 1; | 585 bool user_scrollable_vertical_ : 1; |
588 bool stacking_order_changed_ : 1; | 586 bool stacking_order_changed_ : 1; |
589 // Whether the "back" of this layer should draw. | 587 // Whether the "back" of this layer should draw. |
590 bool double_sided_ : 1; | 588 bool double_sided_ : 1; |
591 | 589 |
592 // Tracks if drawing-related properties have changed since last redraw. | 590 // Tracks if drawing-related properties have changed since last redraw. |
(...skipping 22 matching lines...) Expand all Loading... |
615 gfx::Transform transform_; | 613 gfx::Transform transform_; |
616 | 614 |
617 // This property is effective when | 615 // This property is effective when |
618 // is_container_for_fixed_position_layers_ == true, | 616 // is_container_for_fixed_position_layers_ == true, |
619 gfx::Vector2dF fixed_container_size_delta_; | 617 gfx::Vector2dF fixed_container_size_delta_; |
620 | 618 |
621 LayerPositionConstraint position_constraint_; | 619 LayerPositionConstraint position_constraint_; |
622 | 620 |
623 gfx::Vector2dF scroll_delta_; | 621 gfx::Vector2dF scroll_delta_; |
624 gfx::Vector2d sent_scroll_delta_; | 622 gfx::Vector2d sent_scroll_delta_; |
| 623 gfx::Vector2d max_scroll_offset_; |
625 gfx::Vector2dF last_scroll_offset_; | 624 gfx::Vector2dF last_scroll_offset_; |
626 | 625 |
627 // The global depth value of the center of the layer. This value is used | 626 // The global depth value of the center of the layer. This value is used |
628 // to sort layers from back to front. | 627 // to sort layers from back to front. |
629 float draw_depth_; | 628 float draw_depth_; |
630 | 629 |
631 FilterOperations filters_; | 630 FilterOperations filters_; |
632 FilterOperations background_filters_; | 631 FilterOperations background_filters_; |
633 | 632 |
634 protected: | 633 protected: |
(...skipping 15 matching lines...) Expand all Loading... |
650 // Note that plugin layers bypass this and leave it empty. | 649 // Note that plugin layers bypass this and leave it empty. |
651 // Uses layer (not content) space. | 650 // Uses layer (not content) space. |
652 gfx::RectF update_rect_; | 651 gfx::RectF update_rect_; |
653 | 652 |
654 // Manages animations for this layer. | 653 // Manages animations for this layer. |
655 scoped_refptr<LayerAnimationController> layer_animation_controller_; | 654 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
656 | 655 |
657 // Manages scrollbars for this layer | 656 // Manages scrollbars for this layer |
658 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; | 657 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; |
659 | 658 |
660 scoped_ptr<ScrollbarSet> scrollbars_; | 659 // Weak pointers to this layer's scrollbars, if it has them. Updated during |
| 660 // tree synchronization. |
| 661 ScrollbarLayerImplBase* horizontal_scrollbar_layer_; |
| 662 ScrollbarLayerImplBase* vertical_scrollbar_layer_; |
661 | 663 |
662 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 664 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
663 | 665 |
664 // Group of properties that need to be computed based on the layer tree | 666 // Group of properties that need to be computed based on the layer tree |
665 // hierarchy before layers can be drawn. | 667 // hierarchy before layers can be drawn. |
666 DrawProperties<LayerImpl> draw_properties_; | 668 DrawProperties<LayerImpl> draw_properties_; |
667 | 669 |
668 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; | 670 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; |
669 | 671 |
670 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 672 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
671 }; | 673 }; |
672 | 674 |
673 } // namespace cc | 675 } // namespace cc |
674 | 676 |
675 #endif // CC_LAYERS_LAYER_IMPL_H_ | 677 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |