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