| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_INPUT_SCROLL_ELASTICITY_HELPER_H_ | 5 #ifndef CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
| 6 #define CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ | 6 #define CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 8 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 9 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 10 #include "ui/gfx/geometry/scroll_offset.h" | 13 #include "ui/gfx/geometry/scroll_offset.h" |
| 11 #include "ui/gfx/geometry/vector2d_f.h" | 14 #include "ui/gfx/geometry/vector2d_f.h" |
| 12 | 15 |
| 13 namespace cc { | 16 namespace cc { |
| 14 | 17 |
| 15 class LayerTreeHostImpl; | 18 class LayerTreeHostImpl; |
| 16 | 19 |
| 17 // ScrollElasticityHelper is based on | 20 // ScrollElasticityHelper is based on |
| (...skipping 22 matching lines...) Expand all Loading... |
| 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 43 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 41 * THE POSSIBILITY OF SUCH DAMAGE. | 44 * THE POSSIBILITY OF SUCH DAMAGE. |
| 42 */ | 45 */ |
| 43 | 46 |
| 44 // Interface between a LayerTreeHostImpl and the ScrollElasticityController. It | 47 // Interface between a LayerTreeHostImpl and the ScrollElasticityController. It |
| 45 // would be possible, in principle, for LayerTreeHostImpl to implement this | 48 // would be possible, in principle, for LayerTreeHostImpl to implement this |
| 46 // interface itself. This artificial boundary is introduced to reduce the amount | 49 // interface itself. This artificial boundary is introduced to reduce the amount |
| 47 // of logic and state held directly inside LayerTreeHostImpl. | 50 // of logic and state held directly inside LayerTreeHostImpl. |
| 48 class CC_EXPORT ScrollElasticityHelper { | 51 class CC_EXPORT ScrollElasticityHelper { |
| 49 public: | 52 public: |
| 53 static std::unique_ptr<ScrollElasticityHelper> CreateForLayer( |
| 54 int layer_scroll_layer_id, |
| 55 LayerTreeHostImpl* layer_tree_host_impl); |
| 50 static ScrollElasticityHelper* CreateForLayerTreeHostImpl( | 56 static ScrollElasticityHelper* CreateForLayerTreeHostImpl( |
| 51 LayerTreeHostImpl* layer_tree_host_impl); | 57 LayerTreeHostImpl* layer_tree_host_impl); |
| 52 | 58 |
| 53 virtual ~ScrollElasticityHelper() {} | 59 virtual ~ScrollElasticityHelper() {} |
| 54 | 60 |
| 55 virtual bool IsUserScrollable() const = 0; | 61 virtual bool IsUserScrollable() const = 0; |
| 56 | 62 |
| 57 // The amount that the view is stretched past the normal allowable bounds. | 63 // The amount that the view is stretched past the normal allowable bounds. |
| 58 virtual gfx::Vector2dF StretchAmount() const = 0; | 64 virtual gfx::Vector2dF StretchAmount() const = 0; |
| 59 virtual void SetStretchAmount(const gfx::Vector2dF& stretch_amount) = 0; | 65 virtual void SetStretchAmount(const gfx::Vector2dF& stretch_amount) = 0; |
| 60 | 66 |
| 61 // Functions for the scrolling of the root scroll layer. | 67 // Functions for the scrolling of the root scroll layer. |
| 62 virtual gfx::ScrollOffset ScrollOffset() const = 0; | 68 virtual gfx::ScrollOffset ScrollOffset() const = 0; |
| 63 virtual gfx::ScrollOffset MaxScrollOffset() const = 0; | 69 virtual gfx::ScrollOffset MaxScrollOffset() const = 0; |
| 64 virtual void ScrollBy(const gfx::Vector2dF& delta) = 0; | 70 virtual void ScrollBy(const gfx::Vector2dF& delta) = 0; |
| 65 | 71 |
| 72 virtual base::WeakPtr<ScrollElasticityHelper> GetWeakPtr() = 0; |
| 73 |
| 66 // Requests that another frame happens for the controller to continue ticking | 74 // Requests that another frame happens for the controller to continue ticking |
| 67 // animations. | 75 // animations. |
| 68 virtual void RequestOneBeginFrame() = 0; | 76 virtual void RequestOneBeginFrame() = 0; |
| 69 }; | 77 }; |
| 70 | 78 |
| 71 } // namespace cc | 79 } // namespace cc |
| 72 | 80 |
| 73 #endif // CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ | 81 #endif // CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
| OLD | NEW |