| 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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "cc/layer_tree_host.h" | 21 #include "cc/layer_tree_host.h" |
| 22 #include "cc/layer_tree_host_common.h" | 22 #include "cc/layer_tree_host_common.h" |
| 23 #include "cc/math_util.h" | 23 #include "cc/math_util.h" |
| 24 #include "cc/overdraw_metrics.h" | 24 #include "cc/overdraw_metrics.h" |
| 25 #include "cc/page_scale_animation.h" | 25 #include "cc/page_scale_animation.h" |
| 26 #include "cc/prioritized_resource_manager.h" | 26 #include "cc/prioritized_resource_manager.h" |
| 27 #include "cc/render_pass_draw_quad.h" | 27 #include "cc/render_pass_draw_quad.h" |
| 28 #include "cc/rendering_stats.h" | 28 #include "cc/rendering_stats.h" |
| 29 #include "cc/scrollbar_animation_controller.h" | 29 #include "cc/scrollbar_animation_controller.h" |
| 30 #include "cc/scrollbar_layer_impl.h" | 30 #include "cc/scrollbar_layer_impl.h" |
| 31 #include "cc/settings.h" | |
| 32 #include "cc/single_thread_proxy.h" | 31 #include "cc/single_thread_proxy.h" |
| 33 #include "cc/software_renderer.h" | 32 #include "cc/software_renderer.h" |
| 34 #include "cc/texture_uploader.h" | 33 #include "cc/texture_uploader.h" |
| 35 #include "ui/gfx/size_conversions.h" | 34 #include "ui/gfx/size_conversions.h" |
| 36 #include "ui/gfx/vector2d_conversions.h" | 35 #include "ui/gfx/vector2d_conversions.h" |
| 37 | 36 |
| 38 using WebKit::WebTransformationMatrix; | 37 using WebKit::WebTransformationMatrix; |
| 39 | 38 |
| 40 namespace { | 39 namespace { |
| 41 | 40 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { | 126 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { |
| 128 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); | 127 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); |
| 129 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch
edBounds.bottom()); | 128 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch
edBounds.bottom()); |
| 130 } | 129 } |
| 131 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); | 130 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); |
| 132 | 131 |
| 133 return overflow; | 132 return overflow; |
| 134 } | 133 } |
| 135 | 134 |
| 136 WebTransformationMatrix PinchZoomViewport::implTransform() const | 135 WebTransformationMatrix PinchZoomViewport::implTransform(bool pageScalePinchZoom
Enabled) const |
| 137 { | 136 { |
| 138 WebTransformationMatrix transform; | 137 WebTransformationMatrix transform; |
| 139 transform.scale(m_pageScaleDelta); | 138 transform.scale(m_pageScaleDelta); |
| 140 | 139 |
| 141 // If the pinch state is applied in the impl, then push it to the | 140 // If the pinch state is applied in the impl, then push it to the |
| 142 // impl transform, otherwise the scale is handled by WebCore. | 141 // impl transform, otherwise the scale is handled by WebCore. |
| 143 if (Settings::pageScalePinchZoomEnabled()) { | 142 if (pageScalePinchZoomEnabled) { |
| 144 transform.scale(m_pageScaleFactor); | 143 transform.scale(m_pageScaleFactor); |
| 145 transform.translate(-m_pinchViewportScrollDelta.x(), | 144 transform.translate(-m_pinchViewportScrollDelta.x(), |
| 146 -m_pinchViewportScrollDelta.y()); | 145 -m_pinchViewportScrollDelta.y()); |
| 147 } | 146 } |
| 148 | 147 |
| 149 return transform; | 148 return transform; |
| 150 } | 149 } |
| 151 | 150 |
| 152 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 151 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
| 153 public: | 152 public: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 animateScrollbars(monotonicTime); | 287 animateScrollbars(monotonicTime); |
| 289 } | 288 } |
| 290 | 289 |
| 291 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool
anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati
on) | 290 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool
anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati
on) |
| 292 { | 291 { |
| 293 if (!m_rootScrollLayerImpl) | 292 if (!m_rootScrollLayerImpl) |
| 294 return; | 293 return; |
| 295 | 294 |
| 296 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); | 295 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); |
| 297 gfx::SizeF scaledContentSize = contentSize(); | 296 gfx::SizeF scaledContentSize = contentSize(); |
| 298 if (!Settings::pageScalePinchZoomEnabled()) { | 297 if (!m_settings.pageScalePinchZoomEnabled) { |
| 299 scrollTotal.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); | 298 scrollTotal.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); |
| 300 scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); | 299 scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); |
| 301 } | 300 } |
| 302 gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceS
caleFactor); | 301 gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceS
caleFactor); |
| 303 | 302 |
| 304 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF(); | 303 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF(); |
| 305 m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, m_pinchZoomVi
ewport.totalPageScaleFactor(), viewportSize, scaledContentSize, startTimeSeconds
); | 304 m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, m_pinchZoomVi
ewport.totalPageScaleFactor(), viewportSize, scaledContentSize, startTimeSeconds
); |
| 306 | 305 |
| 307 if (anchorPoint) { | 306 if (anchorPoint) { |
| 308 gfx::Vector2dF anchor(targetOffset); | 307 gfx::Vector2dF anchor(targetOffset); |
| 309 if (!Settings::pageScalePinchZoomEnabled()) | 308 if (!m_settings.pageScalePinchZoomEnabled) |
| 310 anchor.Scale(1 / pageScale); | 309 anchor.Scale(1 / pageScale); |
| 311 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon
dsF()); | 310 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon
dsF()); |
| 312 } else { | 311 } else { |
| 313 gfx::Vector2dF scaledTargetOffset = targetOffset; | 312 gfx::Vector2dF scaledTargetOffset = targetOffset; |
| 314 if (!Settings::pageScalePinchZoomEnabled()) | 313 if (!m_settings.pageScalePinchZoomEnabled) |
| 315 scaledTargetOffset.Scale(1 / pageScale); | 314 scaledTargetOffset.Scale(1 / pageScale); |
| 316 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS
econdsF()); | 315 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS
econdsF()); |
| 317 } | 316 } |
| 318 | 317 |
| 319 m_client->setNeedsRedrawOnImplThread(); | 318 m_client->setNeedsRedrawOnImplThread(); |
| 320 m_client->setNeedsCommitOnImplThread(); | 319 m_client->setNeedsCommitOnImplThread(); |
| 321 } | 320 } |
| 322 | 321 |
| 323 void LayerTreeHostImpl::scheduleAnimation() | 322 void LayerTreeHostImpl::scheduleAnimation() |
| 324 { | 323 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 calculateRenderSurfaceLayerList(*frame.renderSurfaceLayerList); | 376 calculateRenderSurfaceLayerList(*frame.renderSurfaceLayerList); |
| 378 | 377 |
| 379 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac
eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList
->size())); | 378 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac
eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList
->size())); |
| 380 | 379 |
| 381 // Create the render passes in dependency order. | 380 // Create the render passes in dependency order. |
| 382 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { | 381 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { |
| 383 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; | 382 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; |
| 384 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 383 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
| 385 } | 384 } |
| 386 | 385 |
| 387 bool recordMetricsForFrame = Settings::traceOverdraw() && base::debug::Trace
Log::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 386 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
| 388 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); | 387 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); |
| 389 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); | 388 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); |
| 390 | 389 |
| 391 if (settings().showOccludingRects) | 390 if (settings().showOccludingRects) |
| 392 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); | 391 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); |
| 393 | 392 |
| 394 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. | 393 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. |
| 395 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; | 394 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 396 | 395 |
| 397 // Typically when we are missing a texture and use a checkerboard quad, we s
till draw the frame. However when the layer being | 396 // Typically when we are missing a texture and use a checkerboard quad, we s
till draw the frame. However when the layer being |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 } | 949 } |
| 951 | 950 |
| 952 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float
minPageScaleFactor, float maxPageScaleFactor) | 951 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float
minPageScaleFactor, float maxPageScaleFactor) |
| 953 { | 952 { |
| 954 if (!pageScaleFactor) | 953 if (!pageScaleFactor) |
| 955 return; | 954 return; |
| 956 | 955 |
| 957 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); | 956 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); |
| 958 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); | 957 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); |
| 959 | 958 |
| 960 if (!Settings::pageScalePinchZoomEnabled()) { | 959 if (!m_settings.pageScalePinchZoomEnabled) { |
| 961 if (pageScaleChange != 1) | 960 if (pageScaleChange != 1) |
| 962 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChan
ge); | 961 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChan
ge); |
| 963 } | 962 } |
| 964 | 963 |
| 965 // Clamp delta to limits and refresh display matrix. | 964 // Clamp delta to limits and refresh display matrix. |
| 966 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); | 965 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); |
| 967 m_pinchZoomViewport.setSentPageScaleDelta(1); | 966 m_pinchZoomViewport.setSentPageScaleDelta(1); |
| 968 } | 967 } |
| 969 | 968 |
| 970 void LayerTreeHostImpl::setPageScaleDelta(float delta) | 969 void LayerTreeHostImpl::setPageScaleDelta(float delta) |
| 971 { | 970 { |
| 972 m_pinchZoomViewport.setPageScaleDelta(delta); | 971 m_pinchZoomViewport.setPageScaleDelta(delta); |
| 973 | 972 |
| 974 updateMaxScrollOffset(); | 973 updateMaxScrollOffset(); |
| 975 } | 974 } |
| 976 | 975 |
| 977 void LayerTreeHostImpl::updateMaxScrollOffset() | 976 void LayerTreeHostImpl::updateMaxScrollOffset() |
| 978 { | 977 { |
| 979 if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size()) | 978 if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size()) |
| 980 return; | 979 return; |
| 981 | 980 |
| 982 gfx::SizeF viewBounds = m_deviceViewportSize; | 981 gfx::SizeF viewBounds = m_deviceViewportSize; |
| 983 if (LayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) { | 982 if (LayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) { |
| 984 // Compensate for non-overlay scrollbars. | 983 // Compensate for non-overlay scrollbars. |
| 985 if (clipLayer->masksToBounds()) | 984 if (clipLayer->masksToBounds()) |
| 986 viewBounds = gfx::ScaleSize(clipLayer->bounds(), m_deviceScaleFactor
); | 985 viewBounds = gfx::ScaleSize(clipLayer->bounds(), m_deviceScaleFactor
); |
| 987 } | 986 } |
| 988 | 987 |
| 989 gfx::Size contentBounds = contentSize(); | 988 gfx::Size contentBounds = contentSize(); |
| 990 if (Settings::pageScalePinchZoomEnabled()) { | 989 if (m_settings.pageScalePinchZoomEnabled) { |
| 991 // Pinch with pageScale scrolls entirely in layout space. contentSize | 990 // Pinch with pageScale scrolls entirely in layout space. contentSize |
| 992 // returns the bounds including the page scale factor, so calculate the | 991 // returns the bounds including the page scale factor, so calculate the |
| 993 // pre page-scale layout size here. | 992 // pre page-scale layout size here. |
| 994 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); | 993 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); |
| 995 contentBounds.set_width(contentBounds.width() / pageScaleFactor); | 994 contentBounds.set_width(contentBounds.width() / pageScaleFactor); |
| 996 contentBounds.set_height(contentBounds.height() / pageScaleFactor); | 995 contentBounds.set_height(contentBounds.height() / pageScaleFactor); |
| 997 } else { | 996 } else { |
| 998 viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); | 997 viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); |
| 999 } | 998 } |
| 1000 | 999 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 // position over the course of the magnify. | 1226 // position over the course of the magnify. |
| 1228 float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1227 float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
| 1229 gfx::PointF previousScaleAnchor = gfx::ScalePoint(m_previousPinchAnchor, 1 /
pageScaleDelta); | 1228 gfx::PointF previousScaleAnchor = gfx::ScalePoint(m_previousPinchAnchor, 1 /
pageScaleDelta); |
| 1230 setPageScaleDelta(pageScaleDelta * magnifyDelta); | 1229 setPageScaleDelta(pageScaleDelta * magnifyDelta); |
| 1231 pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1230 pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
| 1232 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); | 1231 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); |
| 1233 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; | 1232 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; |
| 1234 | 1233 |
| 1235 m_previousPinchAnchor = anchor; | 1234 m_previousPinchAnchor = anchor; |
| 1236 | 1235 |
| 1237 if (Settings::pageScalePinchZoomEnabled()) { | 1236 if (m_settings.pageScalePinchZoomEnabled) { |
| 1238 // Compute the application of the delta with respect to the current page
zoom of the page. | 1237 // Compute the application of the delta with respect to the current page
zoom of the page. |
| 1239 move.Scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFac
tor)); | 1238 move.Scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFac
tor)); |
| 1240 } | 1239 } |
| 1241 | 1240 |
| 1242 gfx::Vector2dF scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pi
nchZoomViewport.applyScroll(move) : move; | 1241 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin
chZoomViewport.applyScroll(move) : move; |
| 1243 m_rootScrollLayerImpl->scrollBy(scrollOverflow); | 1242 m_rootScrollLayerImpl->scrollBy(scrollOverflow); |
| 1244 | 1243 |
| 1245 if (m_rootScrollLayerImpl->scrollbarAnimationController()) | 1244 if (m_rootScrollLayerImpl->scrollbarAnimationController()) |
| 1246 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp
date(); | 1245 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp
date(); |
| 1247 | 1246 |
| 1248 m_client->setNeedsCommitOnImplThread(); | 1247 m_client->setNeedsCommitOnImplThread(); |
| 1249 m_client->setNeedsRedrawOnImplThread(); | 1248 m_client->setNeedsRedrawOnImplThread(); |
| 1250 } | 1249 } |
| 1251 | 1250 |
| 1252 void LayerTreeHostImpl::pinchGestureEnd() | 1251 void LayerTreeHostImpl::pinchGestureEnd() |
| 1253 { | 1252 { |
| 1254 m_pinchGestureActive = false; | 1253 m_pinchGestureActive = false; |
| 1255 | 1254 |
| 1256 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro
ller()) | 1255 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro
ller()) |
| 1257 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn
d(); | 1256 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn
d(); |
| 1258 | 1257 |
| 1259 m_client->setNeedsCommitOnImplThread(); | 1258 m_client->setNeedsCommitOnImplThread(); |
| 1260 } | 1259 } |
| 1261 | 1260 |
| 1262 void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo
) | 1261 void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo
) |
| 1263 { | 1262 { |
| 1264 gfx::Vector2dF scaledScrollOffset = m_pageScaleAnimation->targetScrollOffset
(); | 1263 gfx::Vector2dF scaledScrollOffset = m_pageScaleAnimation->targetScrollOffset
(); |
| 1265 if (!Settings::pageScalePinchZoomEnabled()) | 1264 if (!m_settings.pageScalePinchZoomEnabled) |
| 1266 scaledScrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1265 scaledScrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor()); |
| 1267 makeScrollAndScaleSet(scrollInfo, ToFlooredVector2d(scaledScrollOffset), m_p
ageScaleAnimation->targetPageScaleFactor()); | 1266 makeScrollAndScaleSet(scrollInfo, ToFlooredVector2d(scaledScrollOffset), m_p
ageScaleAnimation->targetPageScaleFactor()); |
| 1268 } | 1267 } |
| 1269 | 1268 |
| 1270 void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo) | 1269 void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo) |
| 1271 { | 1270 { |
| 1272 if (!m_rootScrollLayerImpl) | 1271 if (!m_rootScrollLayerImpl) |
| 1273 return; | 1272 return; |
| 1274 | 1273 |
| 1275 // Only send fake scroll/zoom deltas if we're pinch zooming out by a | 1274 // Only send fake scroll/zoom deltas if we're pinch zooming out by a |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 | 1332 |
| 1334 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas() | 1333 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas() |
| 1335 { | 1334 { |
| 1336 scoped_ptr<ScrollAndScaleSet> scrollInfo(new ScrollAndScaleSet()); | 1335 scoped_ptr<ScrollAndScaleSet> scrollInfo(new ScrollAndScaleSet()); |
| 1337 | 1336 |
| 1338 if (m_pinchGestureActive || m_pageScaleAnimation) { | 1337 if (m_pinchGestureActive || m_pageScaleAnimation) { |
| 1339 scrollInfo->pageScaleDelta = 1; | 1338 scrollInfo->pageScaleDelta = 1; |
| 1340 m_pinchZoomViewport.setSentPageScaleDelta(1); | 1339 m_pinchZoomViewport.setSentPageScaleDelta(1); |
| 1341 // FIXME(aelias): Make pinch-zoom painting optimization compatible with | 1340 // FIXME(aelias): Make pinch-zoom painting optimization compatible with |
| 1342 // compositor-side scaling. | 1341 // compositor-side scaling. |
| 1343 if (!Settings::pageScalePinchZoomEnabled() && m_pinchGestureActive) | 1342 if (!m_settings.pageScalePinchZoomEnabled && m_pinchGestureActive) |
| 1344 computePinchZoomDeltas(scrollInfo.get()); | 1343 computePinchZoomDeltas(scrollInfo.get()); |
| 1345 else if (m_pageScaleAnimation.get()) | 1344 else if (m_pageScaleAnimation.get()) |
| 1346 computeDoubleTapZoomDeltas(scrollInfo.get()); | 1345 computeDoubleTapZoomDeltas(scrollInfo.get()); |
| 1347 return scrollInfo.Pass(); | 1346 return scrollInfo.Pass(); |
| 1348 } | 1347 } |
| 1349 | 1348 |
| 1350 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); | 1349 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); |
| 1351 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1350 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
| 1352 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); | 1351 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
| 1353 | 1352 |
| 1354 return scrollInfo.Pass(); | 1353 return scrollInfo.Pass(); |
| 1355 } | 1354 } |
| 1356 | 1355 |
| 1357 WebTransformationMatrix LayerTreeHostImpl::implTransform() const | 1356 WebTransformationMatrix LayerTreeHostImpl::implTransform() const |
| 1358 { | 1357 { |
| 1359 return m_pinchZoomViewport.implTransform(); | 1358 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); |
| 1360 } | 1359 } |
| 1361 | 1360 |
| 1362 void LayerTreeHostImpl::setFullRootLayerDamage() | 1361 void LayerTreeHostImpl::setFullRootLayerDamage() |
| 1363 { | 1362 { |
| 1364 if (m_rootLayerImpl) { | 1363 if (m_rootLayerImpl) { |
| 1365 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); | 1364 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); |
| 1366 if (renderSurface) | 1365 if (renderSurface) |
| 1367 renderSurface->damageTracker()->forceFullDamageNextUpdate(); | 1366 renderSurface->damageTracker()->forceFullDamageNextUpdate(); |
| 1368 } | 1367 } |
| 1369 } | 1368 } |
| 1370 | 1369 |
| 1371 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time) | 1370 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time) |
| 1372 { | 1371 { |
| 1373 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl) | 1372 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl) |
| 1374 return; | 1373 return; |
| 1375 | 1374 |
| 1376 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1375 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1377 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); | 1376 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); |
| 1378 | 1377 |
| 1379 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime)
/ m_pinchZoomViewport.pageScaleFactor()); | 1378 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime)
/ m_pinchZoomViewport.pageScaleFactor()); |
| 1380 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton
icTime); | 1379 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton
icTime); |
| 1381 | 1380 |
| 1382 if (!Settings::pageScalePinchZoomEnabled()) | 1381 if (!m_settings.pageScalePinchZoomEnabled) |
| 1383 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1382 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); |
| 1384 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); | 1383 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); |
| 1385 m_client->setNeedsRedrawOnImplThread(); | 1384 m_client->setNeedsRedrawOnImplThread(); |
| 1386 | 1385 |
| 1387 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { | 1386 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { |
| 1388 m_pageScaleAnimation.reset(); | 1387 m_pageScaleAnimation.reset(); |
| 1389 m_client->setNeedsCommitOnImplThread(); | 1388 m_client->setNeedsCommitOnImplThread(); |
| 1390 } | 1389 } |
| 1391 } | 1390 } |
| 1392 | 1391 |
| 1393 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time
wallClockTime) | 1392 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time
wallClockTime) |
| 1394 { | 1393 { |
| 1395 if (!Settings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || !m_
rootLayerImpl) | 1394 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !m_r
ootLayerImpl) |
| 1396 return; | 1395 return; |
| 1397 | 1396 |
| 1398 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 1397 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
| 1399 | 1398 |
| 1400 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); | 1399 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); |
| 1401 | 1400 |
| 1402 bool didAnimate = false; | 1401 bool didAnimate = false; |
| 1403 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime,
events.get(), didAnimate, m_needsAnimateLayers); | 1402 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime,
events.get(), didAnimate, m_needsAnimateLayers); |
| 1404 | 1403 |
| 1405 if (!events->empty()) | 1404 if (!events->empty()) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1487 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1489 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1488 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1490 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1489 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1491 m_client->setNeedsRedrawOnImplThread(); | 1490 m_client->setNeedsRedrawOnImplThread(); |
| 1492 | 1491 |
| 1493 for (size_t i = 0; i < layer->children().size(); ++i) | 1492 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1494 animateScrollbarsRecursive(layer->children()[i], time); | 1493 animateScrollbarsRecursive(layer->children()[i], time); |
| 1495 } | 1494 } |
| 1496 | 1495 |
| 1497 } // namespace cc | 1496 } // namespace cc |
| OLD | NEW |