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