| 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 // We need to store device_viewport_size separately because in mobile |
| 63 // fixed-layout mode, there is not necessarily a simple mapping between layout |
| 64 // viewport size and device viewport size. |
| 65 void set_device_viewport_size(const gfx::SizeF& size) { |
| 66 device_viewport_size_ = size; |
| 67 } |
| 61 | 68 |
| 62 // Apply the scroll offset in layout space to the offset of the pinch-zoom | 69 // 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 | 70 // 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 | 71 // bounds. Returns the component of the scroll that is un-applied due to this |
| 65 // constraint. | 72 // constraint. |
| 66 gfx::Vector2dF ApplyScroll(const gfx::Vector2dF); | 73 gfx::Vector2dF ApplyScroll(const gfx::Vector2dF); |
| 67 | 74 |
| 68 // The implTransform goes from the origin of the unzoomedDeviceViewport to the | 75 // The implTransform goes from the origin of the unzoomedDeviceViewport to the |
| 69 // origin of the zoomedDeviceViewport. | 76 // origin of the zoomedDeviceViewport. |
| 70 // | 77 // |
| 71 // implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset] | 78 // implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset] |
| 72 gfx::Transform ImplTransform(bool page_scale_pinch_zoom_enabled) const; | 79 gfx::Transform ImplTransform(bool page_scale_pinch_zoom_enabled) const; |
| 73 | 80 |
| 74 private: | 81 private: |
| 75 float page_scale_factor_; | 82 float page_scale_factor_; |
| 76 float page_scale_delta_; | 83 float page_scale_delta_; |
| 77 float sent_page_scale_delta_; | 84 float sent_page_scale_delta_; |
| 78 float max_page_scale_factor_; | 85 float max_page_scale_factor_; |
| 79 float min_page_scale_factor_; | 86 float min_page_scale_factor_; |
| 80 float device_scale_factor_; | 87 float device_scale_factor_; |
| 81 | 88 |
| 82 gfx::Vector2dF zoomed_viewport_offset_; | 89 gfx::Vector2dF zoomed_viewport_offset_; |
| 83 gfx::SizeF layout_viewport_size_; | 90 gfx::SizeF layout_viewport_size_; |
| 91 gfx::SizeF device_viewport_size_; |
| 84 }; | 92 }; |
| 85 | 93 |
| 86 } // namespace cc | 94 } // namespace cc |
| 87 | 95 |
| 88 #endif // CC_PINCH_ZOOM_VIEWPORT_H_ | 96 #endif // CC_PINCH_ZOOM_VIEWPORT_H_ |
| OLD | NEW |