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