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

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

Issue 800613009: Convert scroll offsets to use SyncedProperty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "cc/animation/animation_delegate.h" 14 #include "cc/animation/animation_delegate.h"
15 #include "cc/animation/layer_animation_controller.h" 15 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/animation/layer_animation_value_observer.h" 16 #include "cc/animation/layer_animation_value_observer.h"
17 #include "cc/animation/layer_animation_value_provider.h" 17 #include "cc/animation/layer_animation_value_provider.h"
18 #include "cc/base/cc_export.h" 18 #include "cc/base/cc_export.h"
19 #include "cc/base/region.h" 19 #include "cc/base/region.h"
20 #include "cc/base/scoped_ptr_vector.h" 20 #include "cc/base/scoped_ptr_vector.h"
21 #include "cc/base/synced_property.h"
21 #include "cc/input/input_handler.h" 22 #include "cc/input/input_handler.h"
22 #include "cc/input/scrollbar.h" 23 #include "cc/input/scrollbar.h"
23 #include "cc/layers/draw_properties.h" 24 #include "cc/layers/draw_properties.h"
24 #include "cc/layers/layer_lists.h" 25 #include "cc/layers/layer_lists.h"
25 #include "cc/layers/layer_position_constraint.h" 26 #include "cc/layers/layer_position_constraint.h"
26 #include "cc/layers/render_surface_impl.h" 27 #include "cc/layers/render_surface_impl.h"
27 #include "cc/output/filter_operations.h" 28 #include "cc/output/filter_operations.h"
28 #include "cc/quads/shared_quad_state.h" 29 #include "cc/quads/shared_quad_state.h"
29 #include "cc/resources/resource_provider.h" 30 #include "cc/resources/resource_provider.h"
30 #include "skia/ext/refptr.h" 31 #include "skia/ext/refptr.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Allows for the ownership of the total scroll offset to be delegated outside 79 // Allows for the ownership of the total scroll offset to be delegated outside
79 // of the layer. 80 // of the layer.
80 class ScrollOffsetDelegate { 81 class ScrollOffsetDelegate {
81 public: 82 public:
82 virtual void SetTotalScrollOffset(const gfx::ScrollOffset& new_value) = 0; 83 virtual void SetTotalScrollOffset(const gfx::ScrollOffset& new_value) = 0;
83 virtual gfx::ScrollOffset GetTotalScrollOffset() = 0; 84 virtual gfx::ScrollOffset GetTotalScrollOffset() = 0;
84 virtual bool IsExternalFlingActive() const = 0; 85 virtual bool IsExternalFlingActive() const = 0;
85 virtual void Update() const = 0; 86 virtual void Update() const = 0;
86 }; 87 };
87 88
89 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset;
88 typedef LayerImplList RenderSurfaceListType; 90 typedef LayerImplList RenderSurfaceListType;
89 typedef LayerImplList LayerListType; 91 typedef LayerImplList LayerListType;
90 typedef RenderSurfaceImpl RenderSurfaceType; 92 typedef RenderSurfaceImpl RenderSurfaceType;
91 93
92 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; 94 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
93 95
94 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 96 static scoped_ptr<LayerImpl> Create(
95 return make_scoped_ptr(new LayerImpl(tree_impl, id)); 97 LayerTreeImpl* tree_impl,
98 int id,
99 scoped_refptr<SyncedScrollOffset> scroll_offset) {
100 return make_scoped_ptr(new LayerImpl(tree_impl, id, scroll_offset));
96 } 101 }
97 102
98 ~LayerImpl() override; 103 ~LayerImpl() override;
99 104
100 int id() const { return layer_id_; } 105 int id() const { return layer_id_; }
101 106
102 // LayerAnimationValueProvider implementation. 107 // LayerAnimationValueProvider implementation.
103 gfx::ScrollOffset ScrollOffsetForAnimation() const override; 108 gfx::ScrollOffset ScrollOffsetForAnimation() override;
104 109
105 // LayerAnimationValueObserver implementation. 110 // LayerAnimationValueObserver implementation.
106 void OnFilterAnimated(const FilterOperations& filters) override; 111 void OnFilterAnimated(const FilterOperations& filters) override;
107 void OnOpacityAnimated(float opacity) override; 112 void OnOpacityAnimated(float opacity) override;
108 void OnTransformAnimated(const gfx::Transform& transform) override; 113 void OnTransformAnimated(const gfx::Transform& transform) override;
109 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; 114 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
110 void OnAnimationWaitingForDeletion() override; 115 void OnAnimationWaitingForDeletion() override;
111 bool IsActive() const override; 116 bool IsActive() const override;
112 117
113 // AnimationDelegate implementation. 118 // AnimationDelegate implementation.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 gfx::Vector2dF bounds_delta() const { return bounds_delta_; } 381 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
377 382
378 void SetContentBounds(const gfx::Size& content_bounds); 383 void SetContentBounds(const gfx::Size& content_bounds);
379 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } 384 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
380 385
381 float contents_scale_x() const { return draw_properties_.contents_scale_x; } 386 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
382 float contents_scale_y() const { return draw_properties_.contents_scale_y; } 387 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
383 void SetContentsScale(float contents_scale_x, float contents_scale_y); 388 void SetContentsScale(float contents_scale_x, float contents_scale_y);
384 389
385 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate); 390 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate);
386 void DidScroll();
387 bool IsExternalFlingActive() const; 391 bool IsExternalFlingActive() const;
388 392
389 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); 393 void SetScrollOffsetOnActiveTree(const gfx::ScrollOffset& scroll_offset);
390 void SetScrollOffsetAndDelta(const gfx::ScrollOffset& scroll_offset, 394 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset);
391 const gfx::Vector2dF& scroll_delta); 395 gfx::ScrollOffset CurrentScrollOffset();
392 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } 396 gfx::ScrollOffset ScrollDelta() const { return scroll_offset_->Delta(); }
397 void RefreshScrollDelegate();
398
399 SyncedScrollOffset* scroll_offset() { return scroll_offset_.get(); }
400 const SyncedScrollOffset* scroll_offset() const {
401 return scroll_offset_.get();
402 }
393 403
394 gfx::ScrollOffset MaxScrollOffset() const; 404 gfx::ScrollOffset MaxScrollOffset() const;
405 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const;
395 gfx::Vector2dF ClampScrollToMaxScrollOffset(); 406 gfx::Vector2dF ClampScrollToMaxScrollOffset();
396 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, 407 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
397 LayerImpl* scrollbar_clip_layer, 408 LayerImpl* scrollbar_clip_layer,
398 bool on_resize) const; 409 bool on_resize) const;
399 void SetScrollDelta(const gfx::Vector2dF& scroll_delta);
400 gfx::Vector2dF ScrollDelta() const;
401
402 gfx::ScrollOffset TotalScrollOffset() const;
403
404 void SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta);
405 gfx::Vector2dF sent_scroll_delta() const { return sent_scroll_delta_; }
406 410
407 // Returns the delta of the scroll that was outside of the bounds of the 411 // Returns the delta of the scroll that was outside of the bounds of the
408 // initial scroll 412 // initial scroll
409 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll); 413 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
410 414
411 void SetScrollClipLayer(int scroll_clip_layer_id); 415 void SetScrollClipLayer(int scroll_clip_layer_id);
412 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; } 416 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
413 bool scrollable() const { return !!scroll_clip_layer_; } 417 bool scrollable() const { return !!scroll_clip_layer_; }
414 418
415 void set_user_scrollable_horizontal(bool scrollable) { 419 void set_user_scrollable_horizontal(bool scrollable) {
416 user_scrollable_horizontal_ = scrollable; 420 user_scrollable_horizontal_ = scrollable;
417 } 421 }
418 bool user_scrollable_horizontal() const { 422 bool user_scrollable_horizontal() const {
419 return user_scrollable_horizontal_; 423 return user_scrollable_horizontal_;
420 } 424 }
421 void set_user_scrollable_vertical(bool scrollable) { 425 void set_user_scrollable_vertical(bool scrollable) {
422 user_scrollable_vertical_ = scrollable; 426 user_scrollable_vertical_ = scrollable;
423 } 427 }
424 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 428 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
425 429
426 bool user_scrollable(ScrollbarOrientation orientation) const; 430 bool user_scrollable(ScrollbarOrientation orientation) const;
427 431
428 void ApplySentScrollDeltasFromAbortedCommit(); 432 void ApplySentScrollDeltasFromAbortedCommit();
429 void ApplyScrollDeltasSinceBeginMainFrame();
430 433
431 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) { 434 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
432 should_scroll_on_main_thread_ = should_scroll_on_main_thread; 435 should_scroll_on_main_thread_ = should_scroll_on_main_thread;
433 } 436 }
434 bool should_scroll_on_main_thread() const { 437 bool should_scroll_on_main_thread() const {
435 return should_scroll_on_main_thread_; 438 return should_scroll_on_main_thread_;
436 } 439 }
437 440
438 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { 441 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
439 have_wheel_event_handlers_ = have_wheel_event_handlers; 442 have_wheel_event_handlers_ = have_wheel_event_handlers;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 563
561 virtual void SetDebugInfo( 564 virtual void SetDebugInfo(
562 scoped_refptr<base::debug::ConvertableToTraceFormat> other); 565 scoped_refptr<base::debug::ConvertableToTraceFormat> other);
563 566
564 bool IsDrawnRenderSurfaceLayerListMember() const; 567 bool IsDrawnRenderSurfaceLayerListMember() const;
565 568
566 void Set3dSortingContextId(int id); 569 void Set3dSortingContextId(int id);
567 int sorting_context_id() { return sorting_context_id_; } 570 int sorting_context_id() { return sorting_context_id_; }
568 571
569 protected: 572 protected:
573 LayerImpl(LayerTreeImpl* layer_impl,
574 int id,
575 scoped_refptr<SyncedScrollOffset> scroll_offset);
570 LayerImpl(LayerTreeImpl* layer_impl, int id); 576 LayerImpl(LayerTreeImpl* layer_impl, int id);
571 577
572 // Get the color and size of the layer's debug border. 578 // Get the color and size of the layer's debug border.
573 virtual void GetDebugBorderProperties(SkColor* color, float* width) const; 579 virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
574 580
575 void AppendDebugBorderQuad(RenderPass* render_pass, 581 void AppendDebugBorderQuad(RenderPass* render_pass,
576 const gfx::Size& content_bounds, 582 const gfx::Size& content_bounds,
577 const SharedQuadState* shared_quad_state, 583 const SharedQuadState* shared_quad_state,
578 AppendQuadsData* append_quads_data) const; 584 AppendQuadsData* append_quads_data) const;
579 void AppendDebugBorderQuad(RenderPass* render_pass, 585 void AppendDebugBorderQuad(RenderPass* render_pass,
580 const gfx::Size& content_bounds, 586 const gfx::Size& content_bounds,
581 const SharedQuadState* shared_quad_state, 587 const SharedQuadState* shared_quad_state,
582 AppendQuadsData* append_quads_data, 588 AppendQuadsData* append_quads_data,
583 SkColor color, 589 SkColor color,
584 float width) const; 590 float width) const;
585 591
586 void NoteLayerPropertyChanged(); 592 void NoteLayerPropertyChanged();
587 void NoteLayerPropertyChangedForSubtree(); 593 void NoteLayerPropertyChangedForSubtree();
588 594
589 // Note carefully this does not affect the current layer. 595 // Note carefully this does not affect the current layer.
590 void NoteLayerPropertyChangedForDescendants(); 596 void NoteLayerPropertyChangedForDescendants();
591 597
592 private: 598 private:
599 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset);
600 void DidUpdateScrollOffset();
593 void NoteLayerPropertyChangedForDescendantsInternal(); 601 void NoteLayerPropertyChangedForDescendantsInternal();
594 602
595 virtual const char* LayerTypeAsString() const; 603 virtual const char* LayerTypeAsString() const;
596 604
597 // Properties internal to LayerImpl 605 // Properties internal to LayerImpl
598 LayerImpl* parent_; 606 LayerImpl* parent_;
599 OwnedLayerImplList children_; 607 OwnedLayerImplList children_;
600 608
601 LayerImpl* scroll_parent_; 609 LayerImpl* scroll_parent_;
602 610
603 // Storing a pointer to a set rather than a set since this will be rarely 611 // Storing a pointer to a set rather than a set since this will be rarely
604 // used. If this pointer turns out to be too heavy, we could have this (and 612 // used. If this pointer turns out to be too heavy, we could have this (and
605 // the scroll parent above) be stored in a LayerImpl -> scroll_info 613 // the scroll parent above) be stored in a LayerImpl -> scroll_info
606 // map somewhere. 614 // map somewhere.
607 scoped_ptr<std::set<LayerImpl*>> scroll_children_; 615 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
608 616
609 LayerImpl* clip_parent_; 617 LayerImpl* clip_parent_;
610 scoped_ptr<std::set<LayerImpl*>> clip_children_; 618 scoped_ptr<std::set<LayerImpl*>> clip_children_;
611 619
612 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 620 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
613 // confirm newly assigned layer is still the previous one 621 // confirm newly assigned layer is still the previous one
614 int mask_layer_id_; 622 int mask_layer_id_;
615 scoped_ptr<LayerImpl> mask_layer_; 623 scoped_ptr<LayerImpl> mask_layer_;
616 int replica_layer_id_; // ditto 624 int replica_layer_id_; // ditto
617 scoped_ptr<LayerImpl> replica_layer_; 625 scoped_ptr<LayerImpl> replica_layer_;
618 int layer_id_; 626 int layer_id_;
619 LayerTreeImpl* layer_tree_impl_; 627 LayerTreeImpl* layer_tree_impl_;
620 628
629 // Properties dynamically changeable on active tree.
630 scoped_refptr<SyncedScrollOffset> scroll_offset_;
631 gfx::Vector2dF bounds_delta_;
632
621 // Properties synchronized from the associated Layer. 633 // Properties synchronized from the associated Layer.
622 gfx::Point3F transform_origin_; 634 gfx::Point3F transform_origin_;
623 gfx::Size bounds_; 635 gfx::Size bounds_;
624 gfx::Vector2dF bounds_delta_;
625 gfx::ScrollOffset scroll_offset_;
626 ScrollOffsetDelegate* scroll_offset_delegate_; 636 ScrollOffsetDelegate* scroll_offset_delegate_;
627 LayerImpl* scroll_clip_layer_; 637 LayerImpl* scroll_clip_layer_;
628 bool scrollable_ : 1; 638 bool scrollable_ : 1;
629 bool should_scroll_on_main_thread_ : 1; 639 bool should_scroll_on_main_thread_ : 1;
630 bool have_wheel_event_handlers_ : 1; 640 bool have_wheel_event_handlers_ : 1;
631 bool have_scroll_event_handlers_ : 1; 641 bool have_scroll_event_handlers_ : 1;
632 bool user_scrollable_horizontal_ : 1; 642 bool user_scrollable_horizontal_ : 1;
633 bool user_scrollable_vertical_ : 1; 643 bool user_scrollable_vertical_ : 1;
634 bool stacking_order_changed_ : 1; 644 bool stacking_order_changed_ : 1;
635 // Whether the "back" of this layer should draw. 645 // Whether the "back" of this layer should draw.
(...skipping 20 matching lines...) Expand all
656 Region touch_event_handler_region_; 666 Region touch_event_handler_region_;
657 SkColor background_color_; 667 SkColor background_color_;
658 668
659 float opacity_; 669 float opacity_;
660 SkXfermode::Mode blend_mode_; 670 SkXfermode::Mode blend_mode_;
661 gfx::PointF position_; 671 gfx::PointF position_;
662 gfx::Transform transform_; 672 gfx::Transform transform_;
663 673
664 LayerPositionConstraint position_constraint_; 674 LayerPositionConstraint position_constraint_;
665 675
666 gfx::Vector2dF scroll_delta_;
667 gfx::Vector2dF sent_scroll_delta_;
668 gfx::ScrollOffset last_scroll_offset_;
669
670 int num_descendants_that_draw_content_; 676 int num_descendants_that_draw_content_;
671 677
672 // The global depth value of the center of the layer. This value is used 678 // The global depth value of the center of the layer. This value is used
673 // to sort layers from back to front. 679 // to sort layers from back to front.
674 float draw_depth_; 680 float draw_depth_;
675 681
676 FilterOperations filters_; 682 FilterOperations filters_;
677 FilterOperations background_filters_; 683 FilterOperations background_filters_;
678 684
679 protected: 685 protected:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 DrawProperties<LayerImpl> draw_properties_; 725 DrawProperties<LayerImpl> draw_properties_;
720 726
721 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; 727 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_;
722 scoped_ptr<RenderSurfaceImpl> render_surface_; 728 scoped_ptr<RenderSurfaceImpl> render_surface_;
723 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 729 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
724 }; 730 };
725 731
726 } // namespace cc 732 } // namespace cc
727 733
728 #endif // CC_LAYERS_LAYER_IMPL_H_ 734 #endif // CC_LAYERS_LAYER_IMPL_H_
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_impl.cc » ('j') | cc/layers/layer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698