void CCLayerTreeHostImpl::computePinchZoomDeltas(CCScrollAndScaleSet* scrollInfo) { if (!m_scrollLayerImpl) return; // Only send fake scroll/zoom deltas if we're pinch zooming out by a // significant amount. This also ensures only one fake delta set will be // sent. const float pinchZoomOutSensitivity = 0.95; if (m_pageScaleDelta > pinchZoomOutSensitivity) return; // Compute where the scroll offset/page scale would be if fully pinch-zoomed // out from the anchor point. FloatSize scrollBegin = toSize(m_scrollLayerImpl->scrollPosition() + m_scrollLayerImpl->scrollDelta()); scrollBegin.scale(m_pageScaleDelta); float scaleBegin = m_pageScale * m_pageScaleDelta; float pageScaleDeltaToSend = m_minPageScale / m_pageScale; FloatSize scaledContentsSize = contentSize(); scaledContentsSize.scale(pageScaleDeltaToSend); FloatSize anchor = toSize(m_previousPinchAnchor); FloatSize scrollEnd = scrollBegin + anchor; scrollEnd.scale(m_minPageScale / scaleBegin); scrollEnd -= anchor; scrollEnd = scrollEnd.shrunkTo(roundedIntSize(scaledContentsSize - m_viewportSize)).expandedTo(FloatSize(0, 0)); scrollEnd.scale(1 / pageScaleDeltaToSend); makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_minPageScale); }
FloatSize ImageBuffer::clampedSize(const FloatSize& size) { return size.shrunkTo(FloatSize(MaxClampedLength, MaxClampedLength)); }