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 12 matching lines...) Expand all Loading... |
23 #include "cc/layers/layer_lists.h" | 23 #include "cc/layers/layer_lists.h" |
24 #include "cc/layers/layer_position_constraint.h" | 24 #include "cc/layers/layer_position_constraint.h" |
25 #include "cc/layers/render_surface_impl.h" | 25 #include "cc/layers/render_surface_impl.h" |
26 #include "cc/output/filter_operations.h" | 26 #include "cc/output/filter_operations.h" |
27 #include "cc/quads/shared_quad_state.h" | 27 #include "cc/quads/shared_quad_state.h" |
28 #include "cc/resources/resource_provider.h" | 28 #include "cc/resources/resource_provider.h" |
29 #include "skia/ext/refptr.h" | 29 #include "skia/ext/refptr.h" |
30 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
31 #include "third_party/skia/include/core/SkImageFilter.h" | 31 #include "third_party/skia/include/core/SkImageFilter.h" |
32 #include "third_party/skia/include/core/SkPicture.h" | 32 #include "third_party/skia/include/core/SkPicture.h" |
| 33 #include "ui/gfx/geometry/scroll_offset.h" |
33 #include "ui/gfx/point3_f.h" | 34 #include "ui/gfx/point3_f.h" |
34 #include "ui/gfx/rect.h" | 35 #include "ui/gfx/rect.h" |
35 #include "ui/gfx/rect_f.h" | 36 #include "ui/gfx/rect_f.h" |
36 #include "ui/gfx/transform.h" | 37 #include "ui/gfx/transform.h" |
37 | 38 |
38 namespace base { | 39 namespace base { |
39 namespace debug { | 40 namespace debug { |
40 class ConvertableToTraceFormat; | 41 class ConvertableToTraceFormat; |
41 class TracedValue; | 42 class TracedValue; |
42 } | 43 } |
(...skipping 27 matching lines...) Expand all Loading... |
70 }; | 71 }; |
71 | 72 |
72 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, | 73 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, |
73 public LayerAnimationValueProvider, | 74 public LayerAnimationValueProvider, |
74 public AnimationDelegate { | 75 public AnimationDelegate { |
75 public: | 76 public: |
76 // Allows for the ownership of the total scroll offset to be delegated outside | 77 // Allows for the ownership of the total scroll offset to be delegated outside |
77 // of the layer. | 78 // of the layer. |
78 class ScrollOffsetDelegate { | 79 class ScrollOffsetDelegate { |
79 public: | 80 public: |
80 virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) = 0; | 81 virtual void SetTotalScrollOffset(const gfx::ScrollOffset& new_value) = 0; |
81 virtual gfx::Vector2dF GetTotalScrollOffset() = 0; | 82 virtual gfx::ScrollOffset GetTotalScrollOffset() = 0; |
82 virtual bool IsExternalFlingActive() const = 0; | 83 virtual bool IsExternalFlingActive() const = 0; |
83 }; | 84 }; |
84 | 85 |
85 typedef LayerImplList RenderSurfaceListType; | 86 typedef LayerImplList RenderSurfaceListType; |
86 typedef LayerImplList LayerListType; | 87 typedef LayerImplList LayerListType; |
87 typedef RenderSurfaceImpl RenderSurfaceType; | 88 typedef RenderSurfaceImpl RenderSurfaceType; |
88 | 89 |
89 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; | 90 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; |
90 | 91 |
91 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 92 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
92 return make_scoped_ptr(new LayerImpl(tree_impl, id)); | 93 return make_scoped_ptr(new LayerImpl(tree_impl, id)); |
93 } | 94 } |
94 | 95 |
95 virtual ~LayerImpl(); | 96 virtual ~LayerImpl(); |
96 | 97 |
97 int id() const { return layer_id_; } | 98 int id() const { return layer_id_; } |
98 | 99 |
99 // LayerAnimationValueProvider implementation. | 100 // LayerAnimationValueProvider implementation. |
100 virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE; | 101 virtual gfx::ScrollOffset ScrollOffsetForAnimation() const OVERRIDE; |
101 | 102 |
102 // LayerAnimationValueObserver implementation. | 103 // LayerAnimationValueObserver implementation. |
103 virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE; | 104 virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE; |
104 virtual void OnOpacityAnimated(float opacity) OVERRIDE; | 105 virtual void OnOpacityAnimated(float opacity) OVERRIDE; |
105 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; | 106 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; |
106 virtual void OnScrollOffsetAnimated( | 107 virtual void OnScrollOffsetAnimated( |
107 const gfx::Vector2dF& scroll_offset) OVERRIDE; | 108 const gfx::ScrollOffset& scroll_offset) OVERRIDE; |
108 virtual void OnAnimationWaitingForDeletion() OVERRIDE; | 109 virtual void OnAnimationWaitingForDeletion() OVERRIDE; |
109 virtual bool IsActive() const OVERRIDE; | 110 virtual bool IsActive() const OVERRIDE; |
110 | 111 |
111 // AnimationDelegate implementation. | 112 // AnimationDelegate implementation. |
112 virtual void NotifyAnimationStarted( | 113 virtual void NotifyAnimationStarted( |
113 base::TimeTicks monotonic_time, | 114 base::TimeTicks monotonic_time, |
114 Animation::TargetProperty target_property) OVERRIDE{}; | 115 Animation::TargetProperty target_property) OVERRIDE{}; |
115 virtual void NotifyAnimationFinished( | 116 virtual void NotifyAnimationFinished( |
116 base::TimeTicks monotonic_time, | 117 base::TimeTicks monotonic_time, |
117 Animation::TargetProperty target_property) OVERRIDE; | 118 Animation::TargetProperty target_property) OVERRIDE; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 void SetContentBounds(const gfx::Size& content_bounds); | 370 void SetContentBounds(const gfx::Size& content_bounds); |
370 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } | 371 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } |
371 | 372 |
372 float contents_scale_x() const { return draw_properties_.contents_scale_x; } | 373 float contents_scale_x() const { return draw_properties_.contents_scale_x; } |
373 float contents_scale_y() const { return draw_properties_.contents_scale_y; } | 374 float contents_scale_y() const { return draw_properties_.contents_scale_y; } |
374 void SetContentsScale(float contents_scale_x, float contents_scale_y); | 375 void SetContentsScale(float contents_scale_x, float contents_scale_y); |
375 | 376 |
376 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate); | 377 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate); |
377 bool IsExternalFlingActive() const; | 378 bool IsExternalFlingActive() const; |
378 | 379 |
379 void SetScrollOffset(const gfx::Vector2d& scroll_offset); | 380 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); |
380 void SetScrollOffsetAndDelta(const gfx::Vector2d& scroll_offset, | 381 void SetScrollOffsetAndDelta(const gfx::ScrollOffset& scroll_offset, |
381 const gfx::Vector2dF& scroll_delta); | 382 const gfx::Vector2dF& scroll_delta); |
382 gfx::Vector2d scroll_offset() const { return scroll_offset_; } | 383 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } |
383 | 384 |
384 gfx::Vector2d MaxScrollOffset() const; | 385 gfx::ScrollOffset MaxScrollOffset() const; |
385 gfx::Vector2dF ClampScrollToMaxScrollOffset(); | 386 gfx::Vector2dF ClampScrollToMaxScrollOffset(); |
386 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, | 387 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, |
387 LayerImpl* scrollbar_clip_layer) const; | 388 LayerImpl* scrollbar_clip_layer) const; |
388 void SetScrollDelta(const gfx::Vector2dF& scroll_delta); | 389 void SetScrollDelta(const gfx::Vector2dF& scroll_delta); |
389 gfx::Vector2dF ScrollDelta() const; | 390 gfx::Vector2dF ScrollDelta() const; |
390 | 391 |
391 gfx::Vector2dF TotalScrollOffset() const; | 392 gfx::ScrollOffset TotalScrollOffset() const; |
392 | 393 |
393 void SetSentScrollDelta(const gfx::Vector2d& sent_scroll_delta); | 394 void SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta); |
394 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } | 395 gfx::Vector2dF sent_scroll_delta() const { return sent_scroll_delta_; } |
395 | 396 |
396 // Returns the delta of the scroll that was outside of the bounds of the | 397 // Returns the delta of the scroll that was outside of the bounds of the |
397 // initial scroll | 398 // initial scroll |
398 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll); | 399 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll); |
399 | 400 |
400 void SetScrollClipLayer(int scroll_clip_layer_id); | 401 void SetScrollClipLayer(int scroll_clip_layer_id); |
401 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; } | 402 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; } |
402 bool scrollable() const { return !!scroll_clip_layer_; } | 403 bool scrollable() const { return !!scroll_clip_layer_; } |
403 | 404 |
404 void set_user_scrollable_horizontal(bool scrollable) { | 405 void set_user_scrollable_horizontal(bool scrollable) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 scoped_ptr<LayerImpl> mask_layer_; | 600 scoped_ptr<LayerImpl> mask_layer_; |
600 int replica_layer_id_; // ditto | 601 int replica_layer_id_; // ditto |
601 scoped_ptr<LayerImpl> replica_layer_; | 602 scoped_ptr<LayerImpl> replica_layer_; |
602 int layer_id_; | 603 int layer_id_; |
603 LayerTreeImpl* layer_tree_impl_; | 604 LayerTreeImpl* layer_tree_impl_; |
604 | 605 |
605 // Properties synchronized from the associated Layer. | 606 // Properties synchronized from the associated Layer. |
606 gfx::Point3F transform_origin_; | 607 gfx::Point3F transform_origin_; |
607 gfx::Size bounds_; | 608 gfx::Size bounds_; |
608 gfx::Vector2dF bounds_delta_; | 609 gfx::Vector2dF bounds_delta_; |
609 gfx::Vector2d scroll_offset_; | 610 gfx::ScrollOffset scroll_offset_; |
610 ScrollOffsetDelegate* scroll_offset_delegate_; | 611 ScrollOffsetDelegate* scroll_offset_delegate_; |
611 LayerImpl* scroll_clip_layer_; | 612 LayerImpl* scroll_clip_layer_; |
612 bool scrollable_ : 1; | 613 bool scrollable_ : 1; |
613 bool should_scroll_on_main_thread_ : 1; | 614 bool should_scroll_on_main_thread_ : 1; |
614 bool have_wheel_event_handlers_ : 1; | 615 bool have_wheel_event_handlers_ : 1; |
615 bool have_scroll_event_handlers_ : 1; | 616 bool have_scroll_event_handlers_ : 1; |
616 bool user_scrollable_horizontal_ : 1; | 617 bool user_scrollable_horizontal_ : 1; |
617 bool user_scrollable_vertical_ : 1; | 618 bool user_scrollable_vertical_ : 1; |
618 bool stacking_order_changed_ : 1; | 619 bool stacking_order_changed_ : 1; |
619 // Whether the "back" of this layer should draw. | 620 // Whether the "back" of this layer should draw. |
(...skipping 22 matching lines...) Expand all Loading... |
642 SkColor background_color_; | 643 SkColor background_color_; |
643 | 644 |
644 float opacity_; | 645 float opacity_; |
645 SkXfermode::Mode blend_mode_; | 646 SkXfermode::Mode blend_mode_; |
646 gfx::PointF position_; | 647 gfx::PointF position_; |
647 gfx::Transform transform_; | 648 gfx::Transform transform_; |
648 | 649 |
649 LayerPositionConstraint position_constraint_; | 650 LayerPositionConstraint position_constraint_; |
650 | 651 |
651 gfx::Vector2dF scroll_delta_; | 652 gfx::Vector2dF scroll_delta_; |
652 gfx::Vector2d sent_scroll_delta_; | 653 gfx::Vector2dF sent_scroll_delta_; |
653 gfx::Vector2dF last_scroll_offset_; | 654 gfx::ScrollOffset last_scroll_offset_; |
654 | 655 |
655 int num_descendants_that_draw_content_; | 656 int num_descendants_that_draw_content_; |
656 | 657 |
657 // The global depth value of the center of the layer. This value is used | 658 // The global depth value of the center of the layer. This value is used |
658 // to sort layers from back to front. | 659 // to sort layers from back to front. |
659 float draw_depth_; | 660 float draw_depth_; |
660 | 661 |
661 FilterOperations filters_; | 662 FilterOperations filters_; |
662 FilterOperations background_filters_; | 663 FilterOperations background_filters_; |
663 | 664 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 DrawProperties<LayerImpl> draw_properties_; | 705 DrawProperties<LayerImpl> draw_properties_; |
705 | 706 |
706 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; | 707 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; |
707 | 708 |
708 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 709 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
709 }; | 710 }; |
710 | 711 |
711 } // namespace cc | 712 } // namespace cc |
712 | 713 |
713 #endif // CC_LAYERS_LAYER_IMPL_H_ | 714 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |