Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_VIEWPORT_H_ | 5 #ifndef CC_LAYERS_VIEWPORT_H_ |
| 6 #define CC_LAYERS_VIEWPORT_H_ | 6 #define CC_LAYERS_VIEWPORT_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
| 11 #include "ui/gfx/geometry/vector2d_f.h" | 12 #include "ui/gfx/geometry/vector2d_f.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 class LayerTreeHostImpl; | 16 class LayerTreeHostImpl; |
| 16 | 17 |
| 17 // Encapsulates gesture handling logic on the viewport layers. The "viewport" | 18 // Encapsulates gesture handling logic on the viewport layers. The "viewport" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 39 // affecting the top controls or outer viewport. | 40 // affecting the top controls or outer viewport. |
| 40 void Pan(const gfx::Vector2dF& delta); | 41 void Pan(const gfx::Vector2dF& delta); |
| 41 | 42 |
| 42 // Scrolls the viewport, applying the unique bubbling between the inner and | 43 // Scrolls the viewport, applying the unique bubbling between the inner and |
| 43 // outer viewport. Scrolls can be consumed by top controls. | 44 // outer viewport. Scrolls can be consumed by top controls. |
| 44 ScrollResult ScrollBy(const gfx::Vector2dF& delta, | 45 ScrollResult ScrollBy(const gfx::Vector2dF& delta, |
| 45 const gfx::Point& viewport_point, | 46 const gfx::Point& viewport_point, |
| 46 bool is_wheel_scroll, | 47 bool is_wheel_scroll, |
| 47 bool affect_top_controls); | 48 bool affect_top_controls); |
| 48 | 49 |
| 50 // Scrolls the viewport, bubbling the delta between the inner and outer | |
| 51 // viewport. Only animates either of the two viewports. | |
| 52 gfx::Vector2dF ScrollAnimated(const gfx::Vector2dF& delta); | |
| 53 | |
| 49 void PinchUpdate(float magnify_delta, const gfx::Point& anchor); | 54 void PinchUpdate(float magnify_delta, const gfx::Point& anchor); |
| 50 void PinchEnd(); | 55 void PinchEnd(); |
| 51 | 56 |
| 52 private: | 57 private: |
| 53 explicit Viewport(LayerTreeHostImpl* host_impl); | 58 explicit Viewport(LayerTreeHostImpl* host_impl); |
| 54 | 59 |
| 60 // Returns true if viewport_delta is stricly less than pendinf_delta. | |
|
bokan
2016/04/06 13:35:52
Nit: s/pendinf_delta/pending_delta
ymalik
2016/04/06 15:33:45
Done.
| |
| 61 static bool ShouldAnimateViewport(const gfx::Vector2dF& viewport_delta, | |
| 62 const gfx::Vector2dF& pending_delta); | |
| 55 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const; | 63 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const; |
| 56 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const; | 64 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const; |
| 57 | 65 |
| 58 // Sends the delta to the top controls, returns the amount applied. | 66 // Sends the delta to the top controls, returns the amount applied. |
| 59 gfx::Vector2dF ScrollTopControls(const gfx::Vector2dF& delta); | 67 gfx::Vector2dF ScrollTopControls(const gfx::Vector2dF& delta); |
| 60 | 68 |
| 61 gfx::ScrollOffset MaxTotalScrollOffset() const; | 69 gfx::ScrollOffset MaxTotalScrollOffset() const; |
| 62 gfx::ScrollOffset TotalScrollOffset() const; | 70 gfx::ScrollOffset TotalScrollOffset() const; |
| 63 | 71 |
| 64 LayerImpl* InnerScrollLayer() const; | 72 LayerImpl* InnerScrollLayer() const; |
| 65 LayerImpl* OuterScrollLayer() const; | 73 LayerImpl* OuterScrollLayer() const; |
| 66 | 74 |
| 67 void SnapPinchAnchorIfWithinMargin(const gfx::Point& anchor); | 75 void SnapPinchAnchorIfWithinMargin(const gfx::Point& anchor); |
| 68 | 76 |
| 69 LayerTreeHostImpl* host_impl_; | 77 LayerTreeHostImpl* host_impl_; |
| 70 | 78 |
| 71 bool pinch_zoom_active_; | 79 bool pinch_zoom_active_; |
| 72 | 80 |
| 73 // The pinch zoom anchor point is adjusted by this amount during a pinch. This | 81 // The pinch zoom anchor point is adjusted by this amount during a pinch. This |
| 74 // is used to "snap" a pinch-zoom to the edge of the screen. | 82 // is used to "snap" a pinch-zoom to the edge of the screen. |
| 75 gfx::Vector2d pinch_anchor_adjustment_; | 83 gfx::Vector2d pinch_anchor_adjustment_; |
| 76 | 84 |
| 85 FRIEND_TEST_ALL_PREFIXES(ViewportTest, ShouldAnimateViewport); | |
| 86 | |
| 77 DISALLOW_COPY_AND_ASSIGN(Viewport); | 87 DISALLOW_COPY_AND_ASSIGN(Viewport); |
| 78 }; | 88 }; |
| 79 | 89 |
| 80 } // namespace cc | 90 } // namespace cc |
| 81 | 91 |
| 82 #endif // CC_LAYERS_VIEWPORT_H_ | 92 #endif // CC_LAYERS_VIEWPORT_H_ |
| OLD | NEW |