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