OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PINCH_ZOOM_VIEWPORT_H_ | 5 #ifndef CC_PINCH_ZOOM_VIEWPORT_H_ |
6 #define CC_PINCH_ZOOM_VIEWPORT_H_ | 6 #define CC_PINCH_ZOOM_VIEWPORT_H_ |
7 | 7 |
8 #include "cc/cc_export.h" | 8 #include "cc/cc_export.h" |
9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
10 #include "ui/gfx/transform.h" | 10 #include "ui/gfx/transform.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 | 40 |
41 void set_device_scale_factor(float factor) { device_scale_factor_ = factor; } | 41 void set_device_scale_factor(float factor) { device_scale_factor_ = factor; } |
42 float device_scale_factor() const { return device_scale_factor_; } | 42 float device_scale_factor() const { return device_scale_factor_; } |
43 | 43 |
44 // Returns true if the passed parameters were different from those previously | 44 // Returns true if the passed parameters were different from those previously |
45 // cached. | 45 // cached. |
46 bool SetPageScaleFactorAndLimits(float page_scale_factor, | 46 bool SetPageScaleFactorAndLimits(float page_scale_factor, |
47 float min_page_scale_factor, | 47 float min_page_scale_factor, |
48 float max_page_scale_factor); | 48 float max_page_scale_factor); |
49 | 49 |
50 // Returns the bounds and offset of the scaled and translated viewport to use | 50 // Returns the zoomed viewport in layout space. The rect's position is an |
51 // for pinch-zoom. | 51 // offset from the root layer's scroll position (therefore, zero if fully |
52 gfx::RectF Bounds() const; | 52 // zoomed out). |
53 gfx::RectF ZoomedViewport() const; | |
53 | 54 |
54 const gfx::Vector2dF& zoomed_viewport_offset() const { | 55 const gfx::Vector2dF& zoomed_viewport_offset() const { |
55 return zoomed_viewport_offset_; | 56 return zoomed_viewport_offset_; |
56 } | 57 } |
57 | 58 |
58 void set_layout_viewport_size(const gfx::SizeF& size) { | 59 void set_layout_viewport_size(const gfx::SizeF& size) { |
59 layout_viewport_size_ = size; | 60 layout_viewport_size_ = size; |
60 } | 61 } |
62 void set_device_viewport_size(const gfx::SizeF& size) { | |
wjmaclean
2013/01/17 19:45:52
Perhaps add a comment explaining why we need to st
aelias_OOO_until_Jul13
2013/01/17 19:59:46
Done.
| |
63 device_viewport_size_ = size; | |
64 } | |
61 | 65 |
62 // Apply the scroll offset in layout space to the offset of the pinch-zoom | 66 // Apply the scroll offset in layout space to the offset of the pinch-zoom |
63 // viewport. The viewport cannot be scrolled outside of the layout viewport | 67 // viewport. The viewport cannot be scrolled outside of the layout viewport |
64 // bounds. Returns the component of the scroll that is un-applied due to this | 68 // bounds. Returns the component of the scroll that is un-applied due to this |
65 // constraint. | 69 // constraint. |
66 gfx::Vector2dF ApplyScroll(const gfx::Vector2dF); | 70 gfx::Vector2dF ApplyScroll(const gfx::Vector2dF); |
67 | 71 |
68 // The implTransform goes from the origin of the unzoomedDeviceViewport to the | 72 // The implTransform goes from the origin of the unzoomedDeviceViewport to the |
69 // origin of the zoomedDeviceViewport. | 73 // origin of the zoomedDeviceViewport. |
70 // | 74 // |
71 // implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset] | 75 // implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset] |
72 gfx::Transform ImplTransform(bool page_scale_pinch_zoom_enabled) const; | 76 gfx::Transform ImplTransform(bool page_scale_pinch_zoom_enabled) const; |
73 | 77 |
74 private: | 78 private: |
75 float page_scale_factor_; | 79 float page_scale_factor_; |
76 float page_scale_delta_; | 80 float page_scale_delta_; |
77 float sent_page_scale_delta_; | 81 float sent_page_scale_delta_; |
78 float max_page_scale_factor_; | 82 float max_page_scale_factor_; |
79 float min_page_scale_factor_; | 83 float min_page_scale_factor_; |
80 float device_scale_factor_; | 84 float device_scale_factor_; |
81 | 85 |
82 gfx::Vector2dF zoomed_viewport_offset_; | 86 gfx::Vector2dF zoomed_viewport_offset_; |
83 gfx::SizeF layout_viewport_size_; | 87 gfx::SizeF layout_viewport_size_; |
88 gfx::SizeF device_viewport_size_; | |
84 }; | 89 }; |
85 | 90 |
86 } // namespace cc | 91 } // namespace cc |
87 | 92 |
88 #endif // CC_PINCH_ZOOM_VIEWPORT_H_ | 93 #endif // CC_PINCH_ZOOM_VIEWPORT_H_ |
OLD | NEW |