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 #include "cc/pinch_zoom_viewport.h" | 5 #include "cc/pinch_zoom_viewport.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 max_page_scale_factor == max_page_scale_factor_) | 43 max_page_scale_factor == max_page_scale_factor_) |
44 return false; | 44 return false; |
45 | 45 |
46 min_page_scale_factor_ = min_page_scale_factor; | 46 min_page_scale_factor_ = min_page_scale_factor; |
47 max_page_scale_factor_ = max_page_scale_factor; | 47 max_page_scale_factor_ = max_page_scale_factor; |
48 | 48 |
49 page_scale_factor_ = page_scale_factor; | 49 page_scale_factor_ = page_scale_factor; |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 gfx::RectF PinchZoomViewport::Bounds() const { | 53 gfx::RectF PinchZoomViewport::ZoomedViewport() const { |
54 gfx::RectF bounds(gfx::PointF(), layout_viewport_size_); | 54 gfx::SizeF layout_space_device_viewport_size = gfx::ScaleSize( |
55 bounds.Scale(1 / total_page_scale_factor()); | 55 device_viewport_size_, |
56 bounds += zoomed_viewport_offset_; | 56 1 / (device_scale_factor_ * total_page_scale_factor())); |
57 return bounds; | 57 return gfx::RectF(gfx::PointAtOffsetFromOrigin(zoomed_viewport_offset_), |
| 58 layout_space_device_viewport_size); |
58 } | 59 } |
59 | 60 |
60 gfx::Vector2dF PinchZoomViewport::ApplyScroll(const gfx::Vector2dF delta) { | 61 gfx::Vector2dF PinchZoomViewport::ApplyScroll(const gfx::Vector2dF delta) { |
61 gfx::Vector2dF overflow; | 62 gfx::Vector2dF overflow; |
62 gfx::RectF pinched_bounds = Bounds() + delta; | 63 gfx::RectF pinched_bounds = ZoomedViewport() + delta; |
63 | 64 |
64 if (pinched_bounds.x() < 0) { | 65 if (pinched_bounds.x() < 0) { |
65 overflow.set_x(pinched_bounds.x()); | 66 overflow.set_x(pinched_bounds.x()); |
66 pinched_bounds.set_x(0); | 67 pinched_bounds.set_x(0); |
67 } | 68 } |
68 | 69 |
69 if (pinched_bounds.y() < 0) { | 70 if (pinched_bounds.y() < 0) { |
70 overflow.set_y(pinched_bounds.y()); | 71 overflow.set_y(pinched_bounds.y()); |
71 pinched_bounds.set_y(0); | 72 pinched_bounds.set_y(0); |
72 } | 73 } |
(...skipping 28 matching lines...) Expand all Loading... |
101 gfx::Vector2dF zoomed_device_viewport_offset | 102 gfx::Vector2dF zoomed_device_viewport_offset |
102 = gfx::ScaleVector2d(zoomed_viewport_offset_, device_scale_factor_); | 103 = gfx::ScaleVector2d(zoomed_viewport_offset_, device_scale_factor_); |
103 transform.Translate(-zoomed_device_viewport_offset.x(), | 104 transform.Translate(-zoomed_device_viewport_offset.x(), |
104 -zoomed_device_viewport_offset.y()); | 105 -zoomed_device_viewport_offset.y()); |
105 } | 106 } |
106 | 107 |
107 return transform; | 108 return transform; |
108 } | 109 } |
109 | 110 |
110 } // namespace cc | 111 } // namespace cc |
OLD | NEW |