OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCLayerTreeHostImpl.h" | 7 #include "CCLayerTreeHostImpl.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "CCAppendQuadsData.h" | 10 #include "CCAppendQuadsData.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 TRACE_EVENT_ASYNC_END0("webkit", "CCLayerTreeHostImpl::setVisible", id); | 47 TRACE_EVENT_ASYNC_END0("webkit", "CCLayerTreeHostImpl::setVisible", id); |
48 } | 48 } |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 namespace cc { | 52 namespace cc { |
53 | 53 |
| 54 CCPinchZoomViewport::CCPinchZoomViewport() |
| 55 : m_pageScaleFactor(1) |
| 56 , m_pageScaleDelta(1) |
| 57 , m_sentPageScaleDelta(1) |
| 58 , m_minPageScaleFactor(0) |
| 59 , m_maxPageScaleFactor(0) |
| 60 { |
| 61 } |
| 62 |
| 63 float CCPinchZoomViewport::totalPageScaleFactor() const |
| 64 { |
| 65 return m_pageScaleFactor * m_pageScaleDelta; |
| 66 } |
| 67 |
| 68 void CCPinchZoomViewport::setPageScaleDelta(float delta) |
| 69 { |
| 70 // Clamp to the current min/max limits. |
| 71 float totalPageScaleFactor = m_pageScaleFactor * delta; |
| 72 if (m_minPageScaleFactor && totalPageScaleFactor < m_minPageScaleFactor) |
| 73 delta = m_minPageScaleFactor / m_pageScaleFactor; |
| 74 else if (m_maxPageScaleFactor && totalPageScaleFactor > m_maxPageScaleFactor
) |
| 75 delta = m_maxPageScaleFactor / m_pageScaleFactor; |
| 76 |
| 77 if (delta == m_pageScaleDelta) |
| 78 return; |
| 79 |
| 80 m_pageScaleDelta = delta; |
| 81 } |
| 82 |
| 83 bool CCPinchZoomViewport::setPageScaleFactorAndLimits(float pageScaleFactor, flo
at minPageScaleFactor, float maxPageScaleFactor) |
| 84 { |
| 85 ASSERT(pageScaleFactor); |
| 86 |
| 87 if (m_sentPageScaleDelta == 1 && pageScaleFactor == m_pageScaleFactor && min
PageScaleFactor == m_minPageScaleFactor && maxPageScaleFactor == m_maxPageScaleF
actor) |
| 88 return false; |
| 89 |
| 90 m_minPageScaleFactor = minPageScaleFactor; |
| 91 m_maxPageScaleFactor = maxPageScaleFactor; |
| 92 |
| 93 m_pageScaleFactor = pageScaleFactor; |
| 94 return true; |
| 95 } |
| 96 |
| 97 FloatRect CCPinchZoomViewport::bounds() const |
| 98 { |
| 99 FloatSize scaledViewportSize = m_layoutViewportSize; |
| 100 scaledViewportSize.scale(1 / totalPageScaleFactor()); |
| 101 |
| 102 FloatRect bounds(FloatPoint(0, 0), scaledViewportSize); |
| 103 bounds.setLocation(m_pinchViewportScrollDelta); |
| 104 |
| 105 return bounds; |
| 106 } |
| 107 |
| 108 FloatSize CCPinchZoomViewport::applyScroll(FloatSize& delta) |
| 109 { |
| 110 FloatSize overflow; |
| 111 FloatRect pinchedBounds = bounds(); |
| 112 |
| 113 pinchedBounds.move(delta); |
| 114 if (pinchedBounds.x() < 0) { |
| 115 overflow.setWidth(pinchedBounds.x()); |
| 116 pinchedBounds.setX(0); |
| 117 } |
| 118 |
| 119 if (pinchedBounds.y() < 0) { |
| 120 overflow.setHeight(pinchedBounds.y()); |
| 121 pinchedBounds.setY(0); |
| 122 } |
| 123 |
| 124 if (pinchedBounds.maxX() > m_layoutViewportSize.width()) { |
| 125 overflow.setWidth( |
| 126 pinchedBounds.maxX() - m_layoutViewportSize.width()); |
| 127 pinchedBounds.move( |
| 128 m_layoutViewportSize.width() - pinchedBounds.maxX(), 0); |
| 129 } |
| 130 |
| 131 if (pinchedBounds.maxY() > m_layoutViewportSize.height()) { |
| 132 overflow.setHeight( |
| 133 pinchedBounds.maxY() - m_layoutViewportSize.height()); |
| 134 pinchedBounds.move( |
| 135 0, m_layoutViewportSize.height() - pinchedBounds.maxY()); |
| 136 } |
| 137 m_pinchViewportScrollDelta = pinchedBounds.location(); |
| 138 |
| 139 return overflow; |
| 140 } |
| 141 |
| 142 WebTransformationMatrix CCPinchZoomViewport::implTransform() const |
| 143 { |
| 144 WebTransformationMatrix transform; |
| 145 transform.scale(m_pageScaleDelta); |
| 146 |
| 147 // If the pinch state is applied in the impl, then push it to the |
| 148 // impl transform, otherwise the scale is handled by WebCore. |
| 149 if (CCSettings::pageScalePinchZoomEnabled()) { |
| 150 transform.scale(m_pageScaleFactor); |
| 151 transform.translate(-m_pinchViewportScrollDelta.x(), |
| 152 -m_pinchViewportScrollDelta.y()); |
| 153 } |
| 154 |
| 155 return transform; |
| 156 } |
| 157 |
54 class CCLayerTreeHostImplTimeSourceAdapter : public CCTimeSourceClient { | 158 class CCLayerTreeHostImplTimeSourceAdapter : public CCTimeSourceClient { |
55 public: | 159 public: |
56 static PassOwnPtr<CCLayerTreeHostImplTimeSourceAdapter> create(CCLayerTreeHo
stImpl* layerTreeHostImpl, PassRefPtr<CCDelayBasedTimeSource> timeSource) | 160 static PassOwnPtr<CCLayerTreeHostImplTimeSourceAdapter> create(CCLayerTreeHo
stImpl* layerTreeHostImpl, PassRefPtr<CCDelayBasedTimeSource> timeSource) |
57 { | 161 { |
58 return adoptPtr(new CCLayerTreeHostImplTimeSourceAdapter(layerTreeHostIm
pl, timeSource)); | 162 return adoptPtr(new CCLayerTreeHostImplTimeSourceAdapter(layerTreeHostIm
pl, timeSource)); |
59 } | 163 } |
60 virtual ~CCLayerTreeHostImplTimeSourceAdapter() | 164 virtual ~CCLayerTreeHostImplTimeSourceAdapter() |
61 { | 165 { |
62 m_timeSource->setClient(0); | 166 m_timeSource->setClient(0); |
63 m_timeSource->setActive(false); | 167 m_timeSource->setActive(false); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 , m_rootScrollLayerImpl(0) | 216 , m_rootScrollLayerImpl(0) |
113 , m_currentlyScrollingLayerImpl(0) | 217 , m_currentlyScrollingLayerImpl(0) |
114 , m_hudLayerImpl(0) | 218 , m_hudLayerImpl(0) |
115 , m_scrollingLayerIdFromPreviousTree(-1) | 219 , m_scrollingLayerIdFromPreviousTree(-1) |
116 , m_scrollDeltaIsInScreenSpace(false) | 220 , m_scrollDeltaIsInScreenSpace(false) |
117 , m_settings(settings) | 221 , m_settings(settings) |
118 , m_deviceScaleFactor(1) | 222 , m_deviceScaleFactor(1) |
119 , m_visible(true) | 223 , m_visible(true) |
120 , m_contentsTexturesPurged(false) | 224 , m_contentsTexturesPurged(false) |
121 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll
ocationLimit()) | 225 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll
ocationLimit()) |
122 , m_pageScale(1) | |
123 , m_pageScaleDelta(1) | |
124 , m_sentPageScaleDelta(1) | |
125 , m_minPageScale(0) | |
126 , m_maxPageScale(0) | |
127 , m_backgroundColor(0) | 226 , m_backgroundColor(0) |
128 , m_hasTransparentBackground(false) | 227 , m_hasTransparentBackground(false) |
129 , m_needsAnimateLayers(false) | 228 , m_needsAnimateLayers(false) |
130 , m_pinchGestureActive(false) | 229 , m_pinchGestureActive(false) |
131 , m_fpsCounter(CCFrameRateCounter::create()) | 230 , m_fpsCounter(CCFrameRateCounter::create()) |
132 , m_debugRectHistory(CCDebugRectHistory::create()) | 231 , m_debugRectHistory(CCDebugRectHistory::create()) |
133 { | 232 { |
134 ASSERT(CCProxy::isImplThread()); | 233 ASSERT(CCProxy::isImplThread()); |
135 didVisibilityChange(this, m_visible); | 234 didVisibilityChange(this, m_visible); |
136 } | 235 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 animateLayers(monotonicTime, wallClockTime); | 291 animateLayers(monotonicTime, wallClockTime); |
193 animateScrollbars(monotonicTime); | 292 animateScrollbars(monotonicTime); |
194 } | 293 } |
195 | 294 |
196 void CCLayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition,
bool anchorPoint, float pageScale, double startTime, double duration) | 295 void CCLayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition,
bool anchorPoint, float pageScale, double startTime, double duration) |
197 { | 296 { |
198 if (!m_rootScrollLayerImpl) | 297 if (!m_rootScrollLayerImpl) |
199 return; | 298 return; |
200 | 299 |
201 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition()
+ m_rootScrollLayerImpl->scrollDelta()); | 300 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition()
+ m_rootScrollLayerImpl->scrollDelta()); |
202 scrollTotal.scale(m_pageScaleDelta); | 301 scrollTotal.scale(m_pinchZoomViewport.pageScaleDelta()); |
203 float scaleTotal = m_pageScale * m_pageScaleDelta; | 302 float scaleTotal = m_pinchZoomViewport.totalPageScaleFactor(); |
204 IntSize scaledContentSize = contentSize(); | 303 IntSize scaledContentSize = contentSize(); |
205 scaledContentSize.scale(m_pageScaleDelta); | 304 scaledContentSize.scale(m_pinchZoomViewport.pageScaleDelta()); |
206 | 305 |
207 m_pageScaleAnimation = CCPageScaleAnimation::create(scrollTotal, scaleTotal,
m_deviceViewportSize, scaledContentSize, startTime); | 306 m_pageScaleAnimation = CCPageScaleAnimation::create(scrollTotal, scaleTotal,
m_deviceViewportSize, scaledContentSize, startTime); |
208 | 307 |
209 if (anchorPoint) { | 308 if (anchorPoint) { |
210 IntSize windowAnchor(targetPosition); | 309 IntSize windowAnchor(targetPosition); |
211 windowAnchor.scale(scaleTotal / pageScale); | 310 windowAnchor.scale(scaleTotal / pageScale); |
212 windowAnchor -= scrollTotal; | 311 windowAnchor -= scrollTotal; |
213 m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration); | 312 m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration); |
214 } else | 313 } else |
215 m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration); | 314 m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration); |
(...skipping 14 matching lines...) Expand all Loading... |
230 // damage rect. The root damage rect is then used to scissor each surface. | 329 // damage rect. The root damage rect is then used to scissor each surface. |
231 | 330 |
232 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0
; --surfaceIndex) { | 331 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0
; --surfaceIndex) { |
233 CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex]; | 332 CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex]; |
234 CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface(); | 333 CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface(); |
235 ASSERT(renderSurface); | 334 ASSERT(renderSurface); |
236 renderSurface->damageTracker()->updateDamageTrackingState(renderSurface-
>layerList(), renderSurfaceLayer->id(), renderSurface->surfacePropertyChangedOnl
yFromDescendant(), renderSurface->contentRect(), renderSurfaceLayer->maskLayer()
, renderSurfaceLayer->filters()); | 335 renderSurface->damageTracker()->updateDamageTrackingState(renderSurface-
>layerList(), renderSurfaceLayer->id(), renderSurface->surfacePropertyChangedOnl
yFromDescendant(), renderSurface->contentRect(), renderSurfaceLayer->maskLayer()
, renderSurfaceLayer->filters()); |
237 } | 336 } |
238 } | 337 } |
239 | 338 |
| 339 void CCLayerTreeHostImpl::updateRootScrollLayerImplTransform() |
| 340 { |
| 341 if (m_rootScrollLayerImpl) { |
| 342 m_rootScrollLayerImpl->setImplTransform(implTransform()); |
| 343 } |
| 344 } |
| 345 |
240 void CCLayerTreeHostImpl::calculateRenderSurfaceLayerList(CCLayerList& renderSur
faceLayerList) | 346 void CCLayerTreeHostImpl::calculateRenderSurfaceLayerList(CCLayerList& renderSur
faceLayerList) |
241 { | 347 { |
242 ASSERT(renderSurfaceLayerList.isEmpty()); | 348 ASSERT(renderSurfaceLayerList.isEmpty()); |
243 ASSERT(m_rootLayerImpl); | 349 ASSERT(m_rootLayerImpl); |
244 ASSERT(m_renderer); // For maxTextureSize. | 350 ASSERT(m_renderer); // For maxTextureSize. |
245 | 351 |
246 { | 352 { |
| 353 updateRootScrollLayerImplTransform(); |
| 354 |
247 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::calcDrawEtc"); | 355 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::calcDrawEtc"); |
248 CCLayerTreeHostCommon::calculateDrawTransforms(m_rootLayerImpl.get(), de
viceViewportSize(), m_deviceScaleFactor, &m_layerSorter, rendererCapabilities().
maxTextureSize, renderSurfaceLayerList); | 356 CCLayerTreeHostCommon::calculateDrawTransforms(m_rootLayerImpl.get(), de
viceViewportSize(), m_deviceScaleFactor, &m_layerSorter, rendererCapabilities().
maxTextureSize, renderSurfaceLayerList); |
249 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 357 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
250 | 358 |
251 trackDamageForAllSurfaces(m_rootLayerImpl.get(), renderSurfaceLayerList)
; | 359 trackDamageForAllSurfaces(m_rootLayerImpl.get(), renderSurfaceLayerList)
; |
252 } | 360 } |
253 } | 361 } |
254 | 362 |
255 void CCLayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<CCRenderPass> r
enderPass) | 363 void CCLayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<CCRenderPass> r
enderPass) |
256 { | 364 { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 } | 872 } |
765 | 873 |
766 void CCLayerTreeHostImpl::setViewportSize(const IntSize& layoutViewportSize, con
st IntSize& deviceViewportSize) | 874 void CCLayerTreeHostImpl::setViewportSize(const IntSize& layoutViewportSize, con
st IntSize& deviceViewportSize) |
767 { | 875 { |
768 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de
viceViewportSize) | 876 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de
viceViewportSize) |
769 return; | 877 return; |
770 | 878 |
771 m_layoutViewportSize = layoutViewportSize; | 879 m_layoutViewportSize = layoutViewportSize; |
772 m_deviceViewportSize = deviceViewportSize; | 880 m_deviceViewportSize = deviceViewportSize; |
773 | 881 |
| 882 m_pinchZoomViewport.setLayoutViewportSize(FloatSize(layoutViewportSize)); |
| 883 |
774 updateMaxScrollPosition(); | 884 updateMaxScrollPosition(); |
775 | 885 |
776 if (m_renderer) | 886 if (m_renderer) |
777 m_renderer->viewportChanged(); | 887 m_renderer->viewportChanged(); |
778 | 888 |
779 m_client->onCanDrawStateChanged(canDraw()); | 889 m_client->onCanDrawStateChanged(canDraw()); |
780 } | 890 } |
781 | 891 |
782 static void adjustScrollsForPageScaleChange(CCLayerImpl* layerImpl, float pageSc
aleChange) | 892 static void adjustScrollsForPageScaleChange(CCLayerImpl* layerImpl, float pageSc
aleChange) |
783 { | 893 { |
(...skipping 13 matching lines...) Expand all Loading... |
797 | 907 |
798 void CCLayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor) | 908 void CCLayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor) |
799 { | 909 { |
800 if (deviceScaleFactor == m_deviceScaleFactor) | 910 if (deviceScaleFactor == m_deviceScaleFactor) |
801 return; | 911 return; |
802 m_deviceScaleFactor = deviceScaleFactor; | 912 m_deviceScaleFactor = deviceScaleFactor; |
803 | 913 |
804 updateMaxScrollPosition(); | 914 updateMaxScrollPosition(); |
805 } | 915 } |
806 | 916 |
| 917 float CCLayerTreeHostImpl::pageScaleFactor() const |
| 918 { |
| 919 return m_pinchZoomViewport.pageScaleFactor(); |
| 920 } |
807 | 921 |
808 void CCLayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScale, float min
PageScale, float maxPageScale) | 922 void CCLayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, flo
at minPageScaleFactor, float maxPageScaleFactor) |
809 { | 923 { |
810 if (!pageScale) | 924 if (!pageScaleFactor) |
811 return; | 925 return; |
812 | 926 |
813 if (m_sentPageScaleDelta == 1 && pageScale == m_pageScale && minPageScale ==
m_minPageScale && maxPageScale == m_maxPageScale) | 927 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); |
814 return; | 928 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); |
815 | 929 |
816 m_minPageScale = minPageScale; | 930 if (!CCSettings::pageScalePinchZoomEnabled()) { |
817 m_maxPageScale = maxPageScale; | 931 if (pageScaleChange != 1) |
818 | 932 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChan
ge); |
819 float pageScaleChange = pageScale / m_pageScale; | 933 } |
820 m_pageScale = pageScale; | |
821 | |
822 if (pageScaleChange != 1) | |
823 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChange); | |
824 | 934 |
825 // Clamp delta to limits and refresh display matrix. | 935 // Clamp delta to limits and refresh display matrix. |
826 setPageScaleDelta(m_pageScaleDelta / m_sentPageScaleDelta); | 936 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); |
827 m_sentPageScaleDelta = 1; | 937 m_pinchZoomViewport.setSentPageScaleDelta(1); |
828 if (m_rootScrollLayerImpl) | |
829 m_rootScrollLayerImpl->setPageScaleDelta(m_pageScaleDelta); | |
830 } | 938 } |
831 | 939 |
832 void CCLayerTreeHostImpl::setPageScaleDelta(float delta) | 940 void CCLayerTreeHostImpl::setPageScaleDelta(float delta) |
833 { | 941 { |
834 // Clamp to the current min/max limits. | 942 m_pinchZoomViewport.setPageScaleDelta(delta); |
835 float finalMagnifyScale = m_pageScale * delta; | |
836 if (m_minPageScale && finalMagnifyScale < m_minPageScale) | |
837 delta = m_minPageScale / m_pageScale; | |
838 else if (m_maxPageScale && finalMagnifyScale > m_maxPageScale) | |
839 delta = m_maxPageScale / m_pageScale; | |
840 | |
841 if (delta == m_pageScaleDelta) | |
842 return; | |
843 | |
844 m_pageScaleDelta = delta; | |
845 | 943 |
846 updateMaxScrollPosition(); | 944 updateMaxScrollPosition(); |
847 if (m_rootScrollLayerImpl) | |
848 m_rootScrollLayerImpl->setPageScaleDelta(m_pageScaleDelta); | |
849 } | 945 } |
850 | 946 |
851 void CCLayerTreeHostImpl::updateMaxScrollPosition() | 947 void CCLayerTreeHostImpl::updateMaxScrollPosition() |
852 { | 948 { |
853 if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size()) | 949 if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size()) |
854 return; | 950 return; |
855 | 951 |
856 FloatSize viewBounds = m_deviceViewportSize; | 952 FloatSize viewBounds = m_deviceViewportSize; |
857 if (CCLayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) { | 953 if (CCLayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) { |
858 // Compensate for non-overlay scrollbars. | 954 // Compensate for non-overlay scrollbars. |
859 if (clipLayer->masksToBounds()) { | 955 if (clipLayer->masksToBounds()) { |
860 viewBounds = clipLayer->bounds(); | 956 viewBounds = clipLayer->bounds(); |
861 viewBounds.scale(m_deviceScaleFactor); | 957 viewBounds.scale(m_deviceScaleFactor); |
862 } | 958 } |
863 } | 959 } |
864 viewBounds.scale(1 / m_pageScaleDelta); | |
865 | 960 |
866 // maxScroll is computed in physical pixels, but scroll positions are in lay
out pixels. | 961 IntSize contentBounds = contentSize(); |
867 IntSize maxScroll = contentSize() - expandedIntSize(viewBounds); | 962 if (CCSettings::pageScalePinchZoomEnabled()) { |
| 963 // Pinch with pageScale scrolls entirely in layout space. contentSize |
| 964 // returns the bounds including the page scale factor, so calculate the |
| 965 // pre page-scale layout size here. |
| 966 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); |
| 967 contentBounds.setWidth(contentBounds.width() / pageScaleFactor); |
| 968 contentBounds.setHeight(contentBounds.height() / pageScaleFactor); |
| 969 } else { |
| 970 viewBounds.scale(1 / m_pinchZoomViewport.pageScaleDelta()); |
| 971 } |
| 972 |
| 973 IntSize maxScroll = contentBounds - expandedIntSize(viewBounds); |
868 maxScroll.scale(1 / m_deviceScaleFactor); | 974 maxScroll.scale(1 / m_deviceScaleFactor); |
| 975 |
869 // The viewport may be larger than the contents in some cases, such as | 976 // The viewport may be larger than the contents in some cases, such as |
870 // having a vertical scrollbar but no horizontal overflow. | 977 // having a vertical scrollbar but no horizontal overflow. |
871 maxScroll.clampNegativeToZero(); | 978 maxScroll.clampNegativeToZero(); |
872 | 979 |
873 m_rootScrollLayerImpl->setMaxScrollPosition(maxScroll); | 980 m_rootScrollLayerImpl->setMaxScrollPosition(maxScroll); |
874 } | 981 } |
875 | 982 |
876 void CCLayerTreeHostImpl::setNeedsRedraw() | 983 void CCLayerTreeHostImpl::setNeedsRedraw() |
877 { | 984 { |
878 m_client->setNeedsRedrawOnImplThread(); | 985 m_client->setNeedsRedrawOnImplThread(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; | 1048 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; |
942 // Gesture events need to be transformed from screen coordinates to loca
l layer coordinates | 1049 // Gesture events need to be transformed from screen coordinates to loca
l layer coordinates |
943 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel | 1050 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel |
944 // events are already in local layer coordinates so we can just apply th
em directly. | 1051 // events are already in local layer coordinates so we can just apply th
em directly. |
945 m_scrollDeltaIsInScreenSpace = (type == Gesture); | 1052 m_scrollDeltaIsInScreenSpace = (type == Gesture); |
946 return ScrollStarted; | 1053 return ScrollStarted; |
947 } | 1054 } |
948 return ScrollIgnored; | 1055 return ScrollIgnored; |
949 } | 1056 } |
950 | 1057 |
951 static FloatSize scrollLayerWithScreenSpaceDelta(CCLayerImpl& layerImpl, const F
loatPoint& screenSpacePoint, const FloatSize& screenSpaceDelta) | 1058 static FloatSize scrollLayerWithScreenSpaceDelta(CCPinchZoomViewport* viewport,
CCLayerImpl& layerImpl, const FloatPoint& screenSpacePoint, const FloatSize& scr
eenSpaceDelta) |
952 { | 1059 { |
953 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 1060 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
954 // test in the first place. | 1061 // test in the first place. |
955 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); | 1062 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); |
956 WebTransformationMatrix inverseScreenSpaceTransform = layerImpl.screenSpaceT
ransform().inverse(); | 1063 WebTransformationMatrix inverseScreenSpaceTransform = layerImpl.screenSpaceT
ransform().inverse(); |
957 | 1064 |
958 // First project the scroll start and end points to local layer space to fin
d the scroll delta | 1065 // First project the scroll start and end points to local layer space to fin
d the scroll delta |
959 // in layer coordinates. | 1066 // in layer coordinates. |
960 bool startClipped, endClipped; | 1067 bool startClipped, endClipped; |
961 FloatPoint screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; | 1068 FloatPoint screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; |
962 FloatPoint localStartPoint = CCMathUtil::projectPoint(inverseScreenSpaceTran
sform, screenSpacePoint, startClipped); | 1069 FloatPoint localStartPoint = CCMathUtil::projectPoint(inverseScreenSpaceTran
sform, screenSpacePoint, startClipped); |
963 FloatPoint localEndPoint = CCMathUtil::projectPoint(inverseScreenSpaceTransf
orm, screenSpaceEndPoint, endClipped); | 1070 FloatPoint localEndPoint = CCMathUtil::projectPoint(inverseScreenSpaceTransf
orm, screenSpaceEndPoint, endClipped); |
964 | 1071 |
965 // In general scroll point coordinates should not get clipped. | 1072 // In general scroll point coordinates should not get clipped. |
966 ASSERT(!startClipped); | 1073 ASSERT(!startClipped); |
967 ASSERT(!endClipped); | 1074 ASSERT(!endClipped); |
968 if (startClipped || endClipped) | 1075 if (startClipped || endClipped) |
969 return FloatSize(); | 1076 return FloatSize(); |
970 | 1077 |
971 // Apply the scroll delta. | 1078 // Apply the scroll delta. |
972 FloatSize previousDelta(layerImpl.scrollDelta()); | 1079 FloatSize previousDelta(layerImpl.scrollDelta()); |
973 layerImpl.scrollBy(localEndPoint - localStartPoint); | 1080 FloatSize unscrolled = layerImpl.scrollBy(localEndPoint - localStartPoint); |
| 1081 |
| 1082 if (viewport) |
| 1083 viewport->applyScroll(unscrolled); |
974 | 1084 |
975 // Calculate the applied scroll delta in screen space coordinates. | 1085 // Calculate the applied scroll delta in screen space coordinates. |
976 FloatPoint actualLocalEndPoint = localStartPoint + layerImpl.scrollDelta() -
previousDelta; | 1086 FloatPoint actualLocalEndPoint = localStartPoint + layerImpl.scrollDelta() -
previousDelta; |
977 FloatPoint actualScreenSpaceEndPoint = CCMathUtil::mapPoint(layerImpl.screen
SpaceTransform(), actualLocalEndPoint, endClipped); | 1087 FloatPoint actualScreenSpaceEndPoint = CCMathUtil::mapPoint(layerImpl.screen
SpaceTransform(), actualLocalEndPoint, endClipped); |
978 ASSERT(!endClipped); | 1088 ASSERT(!endClipped); |
979 if (endClipped) | 1089 if (endClipped) |
980 return FloatSize(); | 1090 return FloatSize(); |
981 return actualScreenSpaceEndPoint - screenSpacePoint; | 1091 return actualScreenSpaceEndPoint - screenSpacePoint; |
982 } | 1092 } |
983 | 1093 |
(...skipping 11 matching lines...) Expand all Loading... |
995 return; | 1105 return; |
996 | 1106 |
997 FloatSize pendingDelta(scrollDelta); | 1107 FloatSize pendingDelta(scrollDelta); |
998 | 1108 |
999 pendingDelta.scale(m_deviceScaleFactor); | 1109 pendingDelta.scale(m_deviceScaleFactor); |
1000 | 1110 |
1001 for (CCLayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; laye
rImpl = layerImpl->parent()) { | 1111 for (CCLayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; laye
rImpl = layerImpl->parent()) { |
1002 if (!layerImpl->scrollable()) | 1112 if (!layerImpl->scrollable()) |
1003 continue; | 1113 continue; |
1004 | 1114 |
| 1115 CCPinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_
pinchZoomViewport : 0; |
1005 FloatSize appliedDelta; | 1116 FloatSize appliedDelta; |
1006 if (m_scrollDeltaIsInScreenSpace) | 1117 if (m_scrollDeltaIsInScreenSpace) |
1007 appliedDelta = scrollLayerWithScreenSpaceDelta(*layerImpl, viewportP
oint, pendingDelta); | 1118 appliedDelta = scrollLayerWithScreenSpaceDelta(viewport, *layerImpl,
viewportPoint, pendingDelta); |
1008 else | 1119 else |
1009 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); | 1120 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); |
1010 | 1121 |
1011 // If the layer wasn't able to move, try the next one in the hierarchy. | 1122 // If the layer wasn't able to move, try the next one in the hierarchy. |
1012 float moveThresholdSquared = 0.1f * 0.1f; | 1123 float moveThresholdSquared = 0.1f * 0.1f; |
1013 if (appliedDelta.diagonalLengthSquared() < moveThresholdSquared) | 1124 if (appliedDelta.diagonalLengthSquared() < moveThresholdSquared) |
1014 continue; | 1125 continue; |
1015 | 1126 |
1016 // If the applied delta is within 45 degrees of the input delta, bail ou
t to make it easier | 1127 // If the applied delta is within 45 degrees of the input delta, bail ou
t to make it easier |
1017 // to scroll just one layer in one direction without affecting any of it
s parents. | 1128 // to scroll just one layer in one direction without affecting any of it
s parents. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::pinchGestureUpdate"); | 1173 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::pinchGestureUpdate"); |
1063 | 1174 |
1064 if (!m_rootScrollLayerImpl) | 1175 if (!m_rootScrollLayerImpl) |
1065 return; | 1176 return; |
1066 | 1177 |
1067 if (m_previousPinchAnchor == IntPoint::zero()) | 1178 if (m_previousPinchAnchor == IntPoint::zero()) |
1068 m_previousPinchAnchor = anchor; | 1179 m_previousPinchAnchor = anchor; |
1069 | 1180 |
1070 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 1181 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
1071 // position over the course of the magnify. | 1182 // position over the course of the magnify. |
1072 FloatPoint previousScaleAnchor(m_previousPinchAnchor.x() / m_pageScaleDelta,
m_previousPinchAnchor.y() / m_pageScaleDelta); | 1183 float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
1073 setPageScaleDelta(m_pageScaleDelta * magnifyDelta); | 1184 FloatPoint previousScaleAnchor(m_previousPinchAnchor.x() / pageScaleDelta, |
1074 FloatPoint newScaleAnchor(anchor.x() / m_pageScaleDelta, anchor.y() / m_page
ScaleDelta); | 1185 m_previousPinchAnchor.y() / pageScaleDelta); |
| 1186 setPageScaleDelta(pageScaleDelta * magnifyDelta); |
| 1187 pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
| 1188 FloatPoint newScaleAnchor(anchor.x() / pageScaleDelta, anchor.y() / pageScal
eDelta); |
1075 FloatSize move = previousScaleAnchor - newScaleAnchor; | 1189 FloatSize move = previousScaleAnchor - newScaleAnchor; |
1076 | 1190 |
1077 m_previousPinchAnchor = anchor; | 1191 m_previousPinchAnchor = anchor; |
1078 | 1192 |
1079 m_rootScrollLayerImpl->scrollBy(roundedIntSize(move)); | 1193 if (CCSettings::pageScalePinchZoomEnabled()) { |
| 1194 // Compute the application of the delta with respect to the current page
zoom of the page. |
| 1195 move.scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFac
tor)); |
| 1196 } |
| 1197 |
| 1198 FloatSize scrollOverflow = CCSettings::pageScalePinchZoomEnabled() ? m_pinch
ZoomViewport.applyScroll(move) : move; |
| 1199 m_rootScrollLayerImpl->scrollBy(roundedIntSize(scrollOverflow)); |
1080 | 1200 |
1081 if (m_rootScrollLayerImpl->scrollbarAnimationController()) | 1201 if (m_rootScrollLayerImpl->scrollbarAnimationController()) |
1082 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp
date(); | 1202 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp
date(); |
1083 | 1203 |
1084 m_client->setNeedsCommitOnImplThread(); | 1204 m_client->setNeedsCommitOnImplThread(); |
1085 m_client->setNeedsRedrawOnImplThread(); | 1205 m_client->setNeedsRedrawOnImplThread(); |
1086 } | 1206 } |
1087 | 1207 |
1088 void CCLayerTreeHostImpl::pinchGestureEnd() | 1208 void CCLayerTreeHostImpl::pinchGestureEnd() |
1089 { | 1209 { |
1090 m_pinchGestureActive = false; | 1210 m_pinchGestureActive = false; |
1091 | 1211 |
1092 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro
ller()) | 1212 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro
ller()) |
1093 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn
d(); | 1213 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn
d(); |
1094 | 1214 |
1095 m_client->setNeedsCommitOnImplThread(); | 1215 m_client->setNeedsCommitOnImplThread(); |
1096 } | 1216 } |
1097 | 1217 |
1098 void CCLayerTreeHostImpl::computeDoubleTapZoomDeltas(CCScrollAndScaleSet* scroll
Info) | 1218 void CCLayerTreeHostImpl::computeDoubleTapZoomDeltas(CCScrollAndScaleSet* scroll
Info) |
1099 { | 1219 { |
1100 float pageScale = m_pageScaleAnimation->finalPageScale(); | 1220 float pageScale = m_pageScaleAnimation->finalPageScale(); |
1101 IntSize scrollOffset = m_pageScaleAnimation->finalScrollOffset(); | 1221 IntSize scrollOffset = m_pageScaleAnimation->finalScrollOffset(); |
1102 scrollOffset.scale(m_pageScale / pageScale); | 1222 scrollOffset.scale(m_pinchZoomViewport.pageScaleFactor() / pageScale); |
1103 makeScrollAndScaleSet(scrollInfo, scrollOffset, pageScale); | 1223 makeScrollAndScaleSet(scrollInfo, scrollOffset, pageScale); |
1104 } | 1224 } |
1105 | 1225 |
1106 void CCLayerTreeHostImpl::computePinchZoomDeltas(CCScrollAndScaleSet* scrollInfo
) | 1226 void CCLayerTreeHostImpl::computePinchZoomDeltas(CCScrollAndScaleSet* scrollInfo
) |
1107 { | 1227 { |
1108 if (!m_rootScrollLayerImpl) | 1228 if (!m_rootScrollLayerImpl) |
1109 return; | 1229 return; |
1110 | 1230 |
1111 // Only send fake scroll/zoom deltas if we're pinch zooming out by a | 1231 // Only send fake scroll/zoom deltas if we're pinch zooming out by a |
1112 // significant amount. This also ensures only one fake delta set will be | 1232 // significant amount. This also ensures only one fake delta set will be |
1113 // sent. | 1233 // sent. |
1114 const float pinchZoomOutSensitivity = 0.95f; | 1234 const float pinchZoomOutSensitivity = 0.95f; |
1115 if (m_pageScaleDelta > pinchZoomOutSensitivity) | 1235 if (m_pinchZoomViewport.pageScaleDelta() > pinchZoomOutSensitivity) |
1116 return; | 1236 return; |
1117 | 1237 |
1118 // Compute where the scroll offset/page scale would be if fully pinch-zoomed | 1238 // Compute where the scroll offset/page scale would be if fully pinch-zoomed |
1119 // out from the anchor point. | 1239 // out from the anchor point. |
1120 IntSize scrollBegin = flooredIntSize(m_rootScrollLayerImpl->scrollPosition()
+ m_rootScrollLayerImpl->scrollDelta()); | 1240 IntSize scrollBegin = flooredIntSize(m_rootScrollLayerImpl->scrollPosition()
+ m_rootScrollLayerImpl->scrollDelta()); |
1121 scrollBegin.scale(m_pageScaleDelta); | 1241 scrollBegin.scale(m_pinchZoomViewport.pageScaleDelta()); |
1122 float scaleBegin = m_pageScale * m_pageScaleDelta; | 1242 float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor(); |
1123 float pageScaleDeltaToSend = m_minPageScale / m_pageScale; | 1243 float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pi
nchZoomViewport.pageScaleFactor(); |
1124 FloatSize scaledContentsSize = contentSize(); | 1244 FloatSize scaledContentsSize = contentSize(); |
1125 scaledContentsSize.scale(pageScaleDeltaToSend); | 1245 scaledContentsSize.scale(pageScaleDeltaToSend); |
1126 | 1246 |
1127 FloatSize anchor = toSize(m_previousPinchAnchor); | 1247 FloatSize anchor = toSize(m_previousPinchAnchor); |
1128 FloatSize scrollEnd = scrollBegin + anchor; | 1248 FloatSize scrollEnd = scrollBegin + anchor; |
1129 scrollEnd.scale(m_minPageScale / scaleBegin); | 1249 scrollEnd.scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin); |
1130 scrollEnd -= anchor; | 1250 scrollEnd -= anchor; |
1131 scrollEnd = scrollEnd.shrunkTo(roundedIntSize(scaledContentsSize - m_deviceV
iewportSize)).expandedTo(FloatSize(0, 0)); | 1251 scrollEnd = scrollEnd.shrunkTo(roundedIntSize(scaledContentsSize - m_deviceV
iewportSize)).expandedTo(FloatSize(0, 0)); |
1132 scrollEnd.scale(1 / pageScaleDeltaToSend); | 1252 scrollEnd.scale(1 / pageScaleDeltaToSend); |
1133 scrollEnd.scale(m_deviceScaleFactor); | 1253 scrollEnd.scale(m_deviceScaleFactor); |
1134 | 1254 |
1135 makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_minPageScale)
; | 1255 makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_pinchZoomView
port.minPageScaleFactor()); |
1136 } | 1256 } |
1137 | 1257 |
1138 void CCLayerTreeHostImpl::makeScrollAndScaleSet(CCScrollAndScaleSet* scrollInfo,
const IntSize& scrollOffset, float pageScale) | 1258 void CCLayerTreeHostImpl::makeScrollAndScaleSet(CCScrollAndScaleSet* scrollInfo,
const IntSize& scrollOffset, float pageScale) |
1139 { | 1259 { |
1140 if (!m_rootScrollLayerImpl) | 1260 if (!m_rootScrollLayerImpl) |
1141 return; | 1261 return; |
1142 | 1262 |
1143 CCLayerTreeHostCommon::ScrollUpdateInfo scroll; | 1263 CCLayerTreeHostCommon::ScrollUpdateInfo scroll; |
1144 scroll.layerId = m_rootScrollLayerImpl->id(); | 1264 scroll.layerId = m_rootScrollLayerImpl->id(); |
1145 scroll.scrollDelta = scrollOffset - toSize(m_rootScrollLayerImpl->scrollPosi
tion()); | 1265 scroll.scrollDelta = scrollOffset - toSize(m_rootScrollLayerImpl->scrollPosi
tion()); |
1146 scrollInfo->scrolls.append(scroll); | 1266 scrollInfo->scrolls.append(scroll); |
1147 m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta); | 1267 m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta); |
1148 m_sentPageScaleDelta = scrollInfo->pageScaleDelta = pageScale / m_pageScale; | 1268 scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor
(); |
| 1269 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
1149 } | 1270 } |
1150 | 1271 |
1151 static void collectScrollDeltas(CCScrollAndScaleSet* scrollInfo, CCLayerImpl* la
yerImpl) | 1272 static void collectScrollDeltas(CCScrollAndScaleSet* scrollInfo, CCLayerImpl* la
yerImpl) |
1152 { | 1273 { |
1153 if (!layerImpl) | 1274 if (!layerImpl) |
1154 return; | 1275 return; |
1155 | 1276 |
1156 if (!layerImpl->scrollDelta().isZero()) { | 1277 if (!layerImpl->scrollDelta().isZero()) { |
1157 IntSize scrollDelta = flooredIntSize(layerImpl->scrollDelta()); | 1278 IntSize scrollDelta = flooredIntSize(layerImpl->scrollDelta()); |
1158 CCLayerTreeHostCommon::ScrollUpdateInfo scroll; | 1279 CCLayerTreeHostCommon::ScrollUpdateInfo scroll; |
1159 scroll.layerId = layerImpl->id(); | 1280 scroll.layerId = layerImpl->id(); |
1160 scroll.scrollDelta = scrollDelta; | 1281 scroll.scrollDelta = scrollDelta; |
1161 scrollInfo->scrolls.append(scroll); | 1282 scrollInfo->scrolls.append(scroll); |
1162 layerImpl->setSentScrollDelta(scrollDelta); | 1283 layerImpl->setSentScrollDelta(scrollDelta); |
1163 } | 1284 } |
1164 | 1285 |
1165 for (size_t i = 0; i < layerImpl->children().size(); ++i) | 1286 for (size_t i = 0; i < layerImpl->children().size(); ++i) |
1166 collectScrollDeltas(scrollInfo, layerImpl->children()[i]); | 1287 collectScrollDeltas(scrollInfo, layerImpl->children()[i]); |
1167 } | 1288 } |
1168 | 1289 |
1169 PassOwnPtr<CCScrollAndScaleSet> CCLayerTreeHostImpl::processScrollDeltas() | 1290 PassOwnPtr<CCScrollAndScaleSet> CCLayerTreeHostImpl::processScrollDeltas() |
1170 { | 1291 { |
1171 OwnPtr<CCScrollAndScaleSet> scrollInfo = adoptPtr(new CCScrollAndScaleSet())
; | 1292 OwnPtr<CCScrollAndScaleSet> scrollInfo = adoptPtr(new CCScrollAndScaleSet())
; |
1172 | 1293 |
1173 if (m_pinchGestureActive || m_pageScaleAnimation) { | 1294 if (m_pinchGestureActive || m_pageScaleAnimation) { |
1174 m_sentPageScaleDelta = scrollInfo->pageScaleDelta = 1; | 1295 scrollInfo->pageScaleDelta = 1; |
1175 if (m_pinchGestureActive) | 1296 m_pinchZoomViewport.setSentPageScaleDelta(1); |
1176 computePinchZoomDeltas(scrollInfo.get()); | 1297 // FIXME(aelias): Make these painting optimizations compatible with |
1177 else if (m_pageScaleAnimation.get()) | 1298 // compositor-side scaling. |
1178 computeDoubleTapZoomDeltas(scrollInfo.get()); | 1299 if (!CCSettings::pageScalePinchZoomEnabled()) { |
| 1300 if (m_pinchGestureActive) |
| 1301 computePinchZoomDeltas(scrollInfo.get()); |
| 1302 else if (m_pageScaleAnimation.get()) |
| 1303 computeDoubleTapZoomDeltas(scrollInfo.get()); |
| 1304 } |
1179 return scrollInfo.release(); | 1305 return scrollInfo.release(); |
1180 } | 1306 } |
1181 | 1307 |
1182 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); | 1308 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); |
1183 m_sentPageScaleDelta = scrollInfo->pageScaleDelta = m_pageScaleDelta; | 1309 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
| 1310 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
1184 | 1311 |
1185 return scrollInfo.release(); | 1312 return scrollInfo.release(); |
1186 } | 1313 } |
1187 | 1314 |
| 1315 WebTransformationMatrix CCLayerTreeHostImpl::implTransform() const |
| 1316 { |
| 1317 return m_pinchZoomViewport.implTransform(); |
| 1318 } |
| 1319 |
1188 void CCLayerTreeHostImpl::setFullRootLayerDamage() | 1320 void CCLayerTreeHostImpl::setFullRootLayerDamage() |
1189 { | 1321 { |
1190 if (m_rootLayerImpl) { | 1322 if (m_rootLayerImpl) { |
1191 CCRenderSurface* renderSurface = m_rootLayerImpl->renderSurface(); | 1323 CCRenderSurface* renderSurface = m_rootLayerImpl->renderSurface(); |
1192 if (renderSurface) | 1324 if (renderSurface) |
1193 renderSurface->damageTracker()->forceFullDamageNextUpdate(); | 1325 renderSurface->damageTracker()->forceFullDamageNextUpdate(); |
1194 } | 1326 } |
1195 } | 1327 } |
1196 | 1328 |
1197 void CCLayerTreeHostImpl::animatePageScale(double monotonicTime) | 1329 void CCLayerTreeHostImpl::animatePageScale(double monotonicTime) |
1198 { | 1330 { |
1199 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl) | 1331 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl) |
1200 return; | 1332 return; |
1201 | 1333 |
1202 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition()
+ m_rootScrollLayerImpl->scrollDelta()); | 1334 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition()
+ m_rootScrollLayerImpl->scrollDelta()); |
1203 | 1335 |
1204 setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_p
ageScale); | 1336 setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_p
inchZoomViewport.pageScaleFactor()); |
1205 IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime)
; | 1337 IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime)
; |
1206 nextScroll.scale(1 / m_pageScaleDelta); | 1338 nextScroll.scale(1 / m_pinchZoomViewport.pageScaleDelta()); |
1207 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); | 1339 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); |
1208 m_client->setNeedsRedrawOnImplThread(); | 1340 m_client->setNeedsRedrawOnImplThread(); |
1209 | 1341 |
1210 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { | 1342 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { |
1211 m_pageScaleAnimation.clear(); | 1343 m_pageScaleAnimation.clear(); |
1212 m_client->setNeedsCommitOnImplThread(); | 1344 m_client->setNeedsCommitOnImplThread(); |
1213 } | 1345 } |
1214 } | 1346 } |
1215 | 1347 |
1216 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi
me) | 1348 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi
me) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 | 1440 |
1309 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); | 1441 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); |
1310 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1442 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1311 m_client->setNeedsRedrawOnImplThread(); | 1443 m_client->setNeedsRedrawOnImplThread(); |
1312 | 1444 |
1313 for (size_t i = 0; i < layer->children().size(); ++i) | 1445 for (size_t i = 0; i < layer->children().size(); ++i) |
1314 animateScrollbarsRecursive(layer->children()[i], monotonicTime); | 1446 animateScrollbarsRecursive(layer->children()[i], monotonicTime); |
1315 } | 1447 } |
1316 | 1448 |
1317 } // namespace cc | 1449 } // namespace cc |
OLD | NEW |