Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: cc/layers/layer_impl.h

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "cc/animation/animation_delegate.h" 15 #include "cc/animation/animation_delegate.h"
16 #include "cc/animation/layer_animation_controller.h" 16 #include "cc/animation/layer_animation_controller.h"
17 #include "cc/animation/layer_animation_value_observer.h" 17 #include "cc/animation/layer_animation_value_observer.h"
18 #include "cc/animation/layer_animation_value_provider.h" 18 #include "cc/animation/layer_animation_value_provider.h"
19 #include "cc/base/cc_export.h" 19 #include "cc/base/cc_export.h"
20 #include "cc/base/region.h" 20 #include "cc/base/region.h"
21 #include "cc/base/scoped_ptr_vector.h" 21 #include "cc/base/scoped_ptr_vector.h"
22 #include "cc/base/synced_property.h"
22 #include "cc/debug/frame_timing_request.h" 23 #include "cc/debug/frame_timing_request.h"
23 #include "cc/input/input_handler.h" 24 #include "cc/input/input_handler.h"
24 #include "cc/input/scrollbar.h" 25 #include "cc/input/scrollbar.h"
25 #include "cc/layers/draw_properties.h" 26 #include "cc/layers/draw_properties.h"
26 #include "cc/layers/layer_lists.h" 27 #include "cc/layers/layer_lists.h"
27 #include "cc/layers/layer_position_constraint.h" 28 #include "cc/layers/layer_position_constraint.h"
28 #include "cc/layers/render_surface_impl.h" 29 #include "cc/layers/render_surface_impl.h"
29 #include "cc/output/filter_operations.h" 30 #include "cc/output/filter_operations.h"
30 #include "cc/quads/shared_quad_state.h" 31 #include "cc/quads/shared_quad_state.h"
31 #include "cc/resources/resource_provider.h" 32 #include "cc/resources/resource_provider.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 }; 75 };
75 76
76 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, 77 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
77 public LayerAnimationValueProvider, 78 public LayerAnimationValueProvider,
78 public AnimationDelegate { 79 public AnimationDelegate {
79 public: 80 public:
80 // Allows for the ownership of the total scroll offset to be delegated outside 81 // Allows for the ownership of the total scroll offset to be delegated outside
81 // of the layer. 82 // of the layer.
82 class ScrollOffsetDelegate { 83 class ScrollOffsetDelegate {
83 public: 84 public:
84 virtual void SetTotalScrollOffset(const gfx::ScrollOffset& new_value) = 0; 85 virtual void SetCurrentScrollOffset(const gfx::ScrollOffset& new_value) = 0;
85 virtual gfx::ScrollOffset GetTotalScrollOffset() = 0; 86 virtual gfx::ScrollOffset GetCurrentScrollOffset() = 0;
86 virtual bool IsExternalFlingActive() const = 0; 87 virtual bool IsExternalFlingActive() const = 0;
87 virtual void Update() const = 0; 88 virtual void Update() const = 0;
88 }; 89 };
89 90
91 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset;
90 typedef LayerImplList RenderSurfaceListType; 92 typedef LayerImplList RenderSurfaceListType;
91 typedef LayerImplList LayerListType; 93 typedef LayerImplList LayerListType;
92 typedef RenderSurfaceImpl RenderSurfaceType; 94 typedef RenderSurfaceImpl RenderSurfaceType;
93 95
94 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; 96 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
95 97
98 static scoped_ptr<LayerImpl> Create(
99 LayerTreeImpl* tree_impl,
100 int id,
101 scoped_refptr<SyncedScrollOffset> scroll_offset) {
102 return make_scoped_ptr(new LayerImpl(tree_impl, id, scroll_offset));
103 }
104
96 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 105 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
97 return make_scoped_ptr(new LayerImpl(tree_impl, id)); 106 return make_scoped_ptr(new LayerImpl(tree_impl, id));
98 } 107 }
99 108
100 ~LayerImpl() override; 109 ~LayerImpl() override;
101 110
102 int id() const { return layer_id_; } 111 int id() const { return layer_id_; }
103 112
104 // LayerAnimationValueProvider implementation. 113 // LayerAnimationValueProvider implementation.
105 gfx::ScrollOffset ScrollOffsetForAnimation() const override; 114 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } 387 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
379 388
380 void SetContentBounds(const gfx::Size& content_bounds); 389 void SetContentBounds(const gfx::Size& content_bounds);
381 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } 390 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
382 391
383 float contents_scale_x() const { return draw_properties_.contents_scale_x; } 392 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
384 float contents_scale_y() const { return draw_properties_.contents_scale_y; } 393 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
385 void SetContentsScale(float contents_scale_x, float contents_scale_y); 394 void SetContentsScale(float contents_scale_x, float contents_scale_y);
386 395
387 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate); 396 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate);
388 void DidScroll(); 397 void RefreshFromScrollDelegate();
389 bool IsExternalFlingActive() const; 398 bool IsExternalFlingActive() const;
390 399
391 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); 400 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset);
392 void SetScrollOffsetAndDelta(const gfx::ScrollOffset& scroll_offset, 401 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset);
393 const gfx::Vector2dF& scroll_delta); 402 gfx::ScrollOffset PullDeltaForMainThread();
394 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } 403 gfx::ScrollOffset CurrentScrollOffset() const;
404 gfx::ScrollOffset BaseScrollOffset() const;
405 gfx::Vector2dF ScrollDelta() const;
406 void SetScrollDelta(const gfx::Vector2dF& delta);
395 407
396 gfx::ScrollOffset MaxScrollOffset() const; 408 gfx::ScrollOffset MaxScrollOffset() const;
409 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const;
397 gfx::Vector2dF ClampScrollToMaxScrollOffset(); 410 gfx::Vector2dF ClampScrollToMaxScrollOffset();
398 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, 411 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
399 LayerImpl* scrollbar_clip_layer, 412 LayerImpl* scrollbar_clip_layer,
400 bool on_resize) const; 413 bool on_resize) const;
401 void SetScrollDelta(const gfx::Vector2dF& scroll_delta); 414 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) {
402 gfx::Vector2dF ScrollDelta() const; 415 scroll_compensation_adjustment_ = scroll_offset;
403 416 }
404 gfx::ScrollOffset TotalScrollOffset() const; 417 gfx::Vector2dF ScrollCompensationAdjustment() const {
405 418 return scroll_compensation_adjustment_;
406 void SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta); 419 }
407 gfx::Vector2dF sent_scroll_delta() const { return sent_scroll_delta_; }
408 420
409 // Returns the delta of the scroll that was outside of the bounds of the 421 // Returns the delta of the scroll that was outside of the bounds of the
410 // initial scroll 422 // initial scroll
411 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll); 423 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
412 424
413 void SetScrollClipLayer(int scroll_clip_layer_id); 425 void SetScrollClipLayer(int scroll_clip_layer_id);
414 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; } 426 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
415 bool scrollable() const { return !!scroll_clip_layer_; } 427 bool scrollable() const { return !!scroll_clip_layer_; }
416 428
417 void set_user_scrollable_horizontal(bool scrollable) { 429 void set_user_scrollable_horizontal(bool scrollable) {
418 user_scrollable_horizontal_ = scrollable; 430 user_scrollable_horizontal_ = scrollable;
419 } 431 }
420 bool user_scrollable_horizontal() const { 432 bool user_scrollable_horizontal() const {
421 return user_scrollable_horizontal_; 433 return user_scrollable_horizontal_;
422 } 434 }
423 void set_user_scrollable_vertical(bool scrollable) { 435 void set_user_scrollable_vertical(bool scrollable) {
424 user_scrollable_vertical_ = scrollable; 436 user_scrollable_vertical_ = scrollable;
425 } 437 }
426 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 438 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
427 439
428 bool user_scrollable(ScrollbarOrientation orientation) const; 440 bool user_scrollable(ScrollbarOrientation orientation) const;
429 441
430 void ApplySentScrollDeltasFromAbortedCommit(); 442 void ApplySentScrollDeltasFromAbortedCommit();
431 void ApplyScrollDeltasSinceBeginMainFrame();
432 443
433 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) { 444 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
434 should_scroll_on_main_thread_ = should_scroll_on_main_thread; 445 should_scroll_on_main_thread_ = should_scroll_on_main_thread;
435 } 446 }
436 bool should_scroll_on_main_thread() const { 447 bool should_scroll_on_main_thread() const {
437 return should_scroll_on_main_thread_; 448 return should_scroll_on_main_thread_;
438 } 449 }
439 450
440 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { 451 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
441 have_wheel_event_handlers_ = have_wheel_event_handlers; 452 have_wheel_event_handlers_ = have_wheel_event_handlers;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 578
568 void Set3dSortingContextId(int id); 579 void Set3dSortingContextId(int id);
569 int sorting_context_id() { return sorting_context_id_; } 580 int sorting_context_id() { return sorting_context_id_; }
570 581
571 void PassFrameTimingRequests( 582 void PassFrameTimingRequests(
572 std::vector<FrameTimingRequest>* frame_timing_requests); 583 std::vector<FrameTimingRequest>* frame_timing_requests);
573 const std::vector<FrameTimingRequest>& frame_timing_requests() const { 584 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
574 return frame_timing_requests_; 585 return frame_timing_requests_;
575 } 586 }
576 587
588 SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); }
589
577 protected: 590 protected:
591 LayerImpl(LayerTreeImpl* layer_impl,
592 int id,
593 scoped_refptr<SyncedScrollOffset> scroll_offset);
578 LayerImpl(LayerTreeImpl* layer_impl, int id); 594 LayerImpl(LayerTreeImpl* layer_impl, int id);
579 595
580 // Get the color and size of the layer's debug border. 596 // Get the color and size of the layer's debug border.
581 virtual void GetDebugBorderProperties(SkColor* color, float* width) const; 597 virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
582 598
583 void AppendDebugBorderQuad(RenderPass* render_pass, 599 void AppendDebugBorderQuad(RenderPass* render_pass,
584 const gfx::Size& content_bounds, 600 const gfx::Size& content_bounds,
585 const SharedQuadState* shared_quad_state, 601 const SharedQuadState* shared_quad_state,
586 AppendQuadsData* append_quads_data) const; 602 AppendQuadsData* append_quads_data) const;
587 void AppendDebugBorderQuad(RenderPass* render_pass, 603 void AppendDebugBorderQuad(RenderPass* render_pass,
588 const gfx::Size& content_bounds, 604 const gfx::Size& content_bounds,
589 const SharedQuadState* shared_quad_state, 605 const SharedQuadState* shared_quad_state,
590 AppendQuadsData* append_quads_data, 606 AppendQuadsData* append_quads_data,
591 SkColor color, 607 SkColor color,
592 float width) const; 608 float width) const;
593 609
594 void NoteLayerPropertyChanged(); 610 void NoteLayerPropertyChanged();
595 void NoteLayerPropertyChangedForSubtree(); 611 void NoteLayerPropertyChangedForSubtree();
596 612
597 // Note carefully this does not affect the current layer. 613 // Note carefully this does not affect the current layer.
598 void NoteLayerPropertyChangedForDescendants(); 614 void NoteLayerPropertyChangedForDescendants();
599 615
600 private: 616 private:
617 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset);
618 void DidUpdateScrollOffset();
601 void NoteLayerPropertyChangedForDescendantsInternal(); 619 void NoteLayerPropertyChangedForDescendantsInternal();
602 620
603 virtual const char* LayerTypeAsString() const; 621 virtual const char* LayerTypeAsString() const;
604 622
605 // Properties internal to LayerImpl 623 // Properties internal to LayerImpl
606 LayerImpl* parent_; 624 LayerImpl* parent_;
607 OwnedLayerImplList children_; 625 OwnedLayerImplList children_;
608 626
609 LayerImpl* scroll_parent_; 627 LayerImpl* scroll_parent_;
610 628
611 // Storing a pointer to a set rather than a set since this will be rarely 629 // Storing a pointer to a set rather than a set since this will be rarely
612 // used. If this pointer turns out to be too heavy, we could have this (and 630 // used. If this pointer turns out to be too heavy, we could have this (and
613 // the scroll parent above) be stored in a LayerImpl -> scroll_info 631 // the scroll parent above) be stored in a LayerImpl -> scroll_info
614 // map somewhere. 632 // map somewhere.
615 scoped_ptr<std::set<LayerImpl*>> scroll_children_; 633 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
616 634
617 LayerImpl* clip_parent_; 635 LayerImpl* clip_parent_;
618 scoped_ptr<std::set<LayerImpl*>> clip_children_; 636 scoped_ptr<std::set<LayerImpl*>> clip_children_;
619 637
620 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 638 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
621 // confirm newly assigned layer is still the previous one 639 // confirm newly assigned layer is still the previous one
622 int mask_layer_id_; 640 int mask_layer_id_;
623 scoped_ptr<LayerImpl> mask_layer_; 641 scoped_ptr<LayerImpl> mask_layer_;
624 int replica_layer_id_; // ditto 642 int replica_layer_id_; // ditto
625 scoped_ptr<LayerImpl> replica_layer_; 643 scoped_ptr<LayerImpl> replica_layer_;
626 int layer_id_; 644 int layer_id_;
627 LayerTreeImpl* layer_tree_impl_; 645 LayerTreeImpl* layer_tree_impl_;
628 646
647 // Properties dynamically changeable on active tree.
648 scoped_refptr<SyncedScrollOffset> scroll_offset_;
649 gfx::Vector2dF bounds_delta_;
650
629 // Properties synchronized from the associated Layer. 651 // Properties synchronized from the associated Layer.
630 gfx::Point3F transform_origin_; 652 gfx::Point3F transform_origin_;
631 gfx::Size bounds_; 653 gfx::Size bounds_;
632 gfx::Vector2dF bounds_delta_;
633 gfx::ScrollOffset scroll_offset_;
634 ScrollOffsetDelegate* scroll_offset_delegate_; 654 ScrollOffsetDelegate* scroll_offset_delegate_;
635 LayerImpl* scroll_clip_layer_; 655 LayerImpl* scroll_clip_layer_;
636 bool scrollable_ : 1; 656 bool scrollable_ : 1;
637 bool should_scroll_on_main_thread_ : 1; 657 bool should_scroll_on_main_thread_ : 1;
638 bool have_wheel_event_handlers_ : 1; 658 bool have_wheel_event_handlers_ : 1;
639 bool have_scroll_event_handlers_ : 1; 659 bool have_scroll_event_handlers_ : 1;
640 bool user_scrollable_horizontal_ : 1; 660 bool user_scrollable_horizontal_ : 1;
641 bool user_scrollable_vertical_ : 1; 661 bool user_scrollable_vertical_ : 1;
642 bool stacking_order_changed_ : 1; 662 bool stacking_order_changed_ : 1;
643 // Whether the "back" of this layer should draw. 663 // Whether the "back" of this layer should draw.
(...skipping 20 matching lines...) Expand all
664 Region touch_event_handler_region_; 684 Region touch_event_handler_region_;
665 SkColor background_color_; 685 SkColor background_color_;
666 686
667 float opacity_; 687 float opacity_;
668 SkXfermode::Mode blend_mode_; 688 SkXfermode::Mode blend_mode_;
669 gfx::PointF position_; 689 gfx::PointF position_;
670 gfx::Transform transform_; 690 gfx::Transform transform_;
671 691
672 LayerPositionConstraint position_constraint_; 692 LayerPositionConstraint position_constraint_;
673 693
674 gfx::Vector2dF scroll_delta_; 694 gfx::Vector2dF scroll_compensation_adjustment_;
675 gfx::Vector2dF sent_scroll_delta_;
676 gfx::ScrollOffset last_scroll_offset_;
677 695
678 int num_descendants_that_draw_content_; 696 int num_descendants_that_draw_content_;
679 697
680 // The global depth value of the center of the layer. This value is used 698 // The global depth value of the center of the layer. This value is used
681 // to sort layers from back to front. 699 // to sort layers from back to front.
682 float draw_depth_; 700 float draw_depth_;
683 701
684 FilterOperations filters_; 702 FilterOperations filters_;
685 FilterOperations background_filters_; 703 FilterOperations background_filters_;
686 704
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 749
732 std::vector<FrameTimingRequest> frame_timing_requests_; 750 std::vector<FrameTimingRequest> frame_timing_requests_;
733 bool frame_timing_requests_dirty_; 751 bool frame_timing_requests_dirty_;
734 752
735 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 753 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
736 }; 754 };
737 755
738 } // namespace cc 756 } // namespace cc
739 757
740 #endif // CC_LAYERS_LAYER_IMPL_H_ 758 #endif // CC_LAYERS_LAYER_IMPL_H_
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698