Title: [102308] trunk/Source
Revision
102308
Author
commit-qu...@webkit.org
Date
2011-12-07 20:35:33 -0800 (Wed, 07 Dec 2011)

Log Message

[chromium] Add page-scale animation support to Impl thread
https://bugs.webkit.org/show_bug.cgi?id=72996

Patch by Alexandre Elias <ael...@google.com> on 2011-12-07
Reviewed by James Robinson.

This adds a new math helper class to compute the progress of the
animation, and code in the CCLayerTreeHostImpl to apply the animation
frame by frame.

No new tests. (https://bugs.webkit.org/show_bug.cgi?id=71529 filed.)

Source/WebCore:

* WebCore.gypi:
* platform/graphics/chromium/cc/CCInputHandler.h:
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::animate):
(WebCore::CCLayerTreeHostImpl::startPageScaleAnimation):
(WebCore::CCLayerTreeHostImpl::processScrollDeltas):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
* platform/graphics/chromium/cc/CCPageScaleAnimation.cpp: Added.
(WebCore::CCPageScaleAnimation::CCPageScaleAnimation):
(WebCore::CCPageScaleAnimation::initialize):
(WebCore::CCPageScaleAnimation::zoomTo):
(WebCore::CCPageScaleAnimation::zoomWithAnchor):
(WebCore::CCPageScaleAnimation::zoomElsewhere):
(WebCore::CCPageScaleAnimation::scrollOffsetAtTime):
(WebCore::CCPageScaleAnimation::pageScaleAtTime):
(WebCore::CCPageScaleAnimation::isAnimationCompleteAtTime):
(WebCore::CCPageScaleAnimation::progressRatioForTime):
(WebCore::CCPageScaleAnimation::scrollOffsetAtRatio):
(WebCore::CCPageScaleAnimation::pageScaleAtRatio):
* platform/graphics/chromium/cc/CCPageScaleAnimation.h: Added.
(WebCore::CCPageScaleAnimation::startTime):
(WebCore::CCPageScaleAnimation::duration):
(WebCore::CCPageScaleAnimation::endTime):
(WebCore::CCPageScaleAnimation::finalScrollOffset):
(WebCore::CCPageScaleAnimation::finalPageScale):

Source/WebKit/chromium:

* public/WebCompositor.h:
* public/WebInputEvent.h:
(WebKit::WebPageScaleAnimationEvent::WebPageScaleAnimationEvent):
* public/android/WebInputEventFactory.h:
* src/WebCompositorImpl.cpp:
(WebKit::WebCompositorImpl::handlePageScaleAnimationEvent):
* src/WebCompositorImpl.h:
* src/WebPopupMenuImpl.cpp:
(WebKit::WebPopupMenuImpl::handleInputEvent):
* src/android/WebInputEventFactory.cpp:
(WebKit::WebInputEventFactory::pageScaleAnimationEvent):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102307 => 102308)


--- trunk/Source/WebCore/ChangeLog	2011-12-08 04:25:47 UTC (rev 102307)
+++ trunk/Source/WebCore/ChangeLog	2011-12-08 04:35:33 UTC (rev 102308)
@@ -1,3 +1,42 @@
+2011-12-07  Alexandre Elias  <ael...@google.com>
+
+        [chromium] Add page-scale animation support to Impl thread
+        https://bugs.webkit.org/show_bug.cgi?id=72996
+
+        Reviewed by James Robinson.
+
+        This adds a new math helper class to compute the progress of the
+        animation, and code in the CCLayerTreeHostImpl to apply the animation
+        frame by frame.
+
+        No new tests. (https://bugs.webkit.org/show_bug.cgi?id=71529 filed.)
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/cc/CCInputHandler.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::animate):
+        (WebCore::CCLayerTreeHostImpl::startPageScaleAnimation):
+        (WebCore::CCLayerTreeHostImpl::processScrollDeltas):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        * platform/graphics/chromium/cc/CCPageScaleAnimation.cpp: Added.
+        (WebCore::CCPageScaleAnimation::CCPageScaleAnimation):
+        (WebCore::CCPageScaleAnimation::initialize):
+        (WebCore::CCPageScaleAnimation::zoomTo):
+        (WebCore::CCPageScaleAnimation::zoomWithAnchor):
+        (WebCore::CCPageScaleAnimation::zoomElsewhere):
+        (WebCore::CCPageScaleAnimation::scrollOffsetAtTime):
+        (WebCore::CCPageScaleAnimation::pageScaleAtTime):
+        (WebCore::CCPageScaleAnimation::isAnimationCompleteAtTime):
+        (WebCore::CCPageScaleAnimation::progressRatioForTime):
+        (WebCore::CCPageScaleAnimation::scrollOffsetAtRatio):
+        (WebCore::CCPageScaleAnimation::pageScaleAtRatio):
+        * platform/graphics/chromium/cc/CCPageScaleAnimation.h: Added.
+        (WebCore::CCPageScaleAnimation::startTime):
+        (WebCore::CCPageScaleAnimation::duration):
+        (WebCore::CCPageScaleAnimation::endTime):
+        (WebCore::CCPageScaleAnimation::finalScrollOffset):
+        (WebCore::CCPageScaleAnimation::finalPageScale):
+
 2011-12-07  Shinya Kawanaka  <shin...@google.com>
 
         Editor::markAndReplaceFor should take Range instead of TextCheckingParagraph.

Modified: trunk/Source/WebCore/WebCore.gypi (102307 => 102308)


--- trunk/Source/WebCore/WebCore.gypi	2011-12-08 04:25:47 UTC (rev 102307)
+++ trunk/Source/WebCore/WebCore.gypi	2011-12-08 04:35:33 UTC (rev 102308)
@@ -3611,6 +3611,8 @@
             'platform/graphics/chromium/cc/CCLayerTreeHost.h',
             'platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp',
             'platform/graphics/chromium/cc/CCLayerTreeHostImpl.h',
+            'platform/graphics/chromium/cc/CCPageScaleAnimation.cpp',
+            'platform/graphics/chromium/cc/CCPageScaleAnimation.h',
             'platform/graphics/chromium/cc/CCPluginLayerImpl.cpp',
             'platform/graphics/chromium/cc/CCPluginLayerImpl.h',
             'platform/graphics/chromium/cc/CCProxy.cpp',

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCInputHandler.h (102307 => 102308)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCInputHandler.h	2011-12-08 04:25:47 UTC (rev 102307)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCInputHandler.h	2011-12-08 04:35:33 UTC (rev 102308)
@@ -70,6 +70,11 @@
     virtual void pinchGestureUpdate(float magnifyDelta, const IntPoint& anchor) = 0;
     virtual void pinchGestureEnd() = 0;
 
+    virtual void startPageScaleAnimation(const IntSize& targetPosition,
+                                         bool anchorPoint,
+                                         float pageScale,
+                                         double durationMs) = 0;
+
 protected:
     CCInputHandlerClient() { }
     virtual ~CCInputHandlerClient() { }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (102307 => 102308)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2011-12-08 04:25:47 UTC (rev 102307)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2011-12-08 04:35:33 UTC (rev 102308)
@@ -31,6 +31,7 @@
 #include "LayerRendererChromium.h"
 #include "TraceEvent.h"
 #include "cc/CCLayerTreeHost.h"
+#include "cc/CCPageScaleAnimation.h"
 #include "cc/CCThreadTask.h"
 #include <wtf/CurrentTime.h>
 
@@ -84,8 +85,47 @@
 
 void CCLayerTreeHostImpl::animate(double frameBeginTimeMs)
 {
+    if (!m_pageScaleAnimation)
+        return;
+
+    IntSize scrollTotal = toSize(m_scrollLayerImpl->scrollPosition() + m_scrollLayerImpl->scrollDelta());
+
+    setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(frameBeginTimeMs) / m_pageScale);
+    IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(frameBeginTimeMs);
+    nextScroll.scale(1 / m_pageScaleDelta);
+    m_scrollLayerImpl->scrollBy(nextScroll - scrollTotal);
+    m_client->setNeedsRedrawOnImplThread();
+
+    if (m_pageScaleAnimation->isAnimationCompleteAtTime(frameBeginTimeMs)) {
+        m_pageScaleAnimation.clear();
+        m_client->setNeedsCommitOnImplThread();
+    }
 }
 
+void CCLayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, double durationMs)
+{
+    if (!m_scrollLayerImpl)
+        return;
+
+    IntSize scrollTotal = toSize(m_scrollLayerImpl->scrollPosition() + m_scrollLayerImpl->scrollDelta());
+    scrollTotal.scale(m_pageScaleDelta);
+    float scaleTotal = m_pageScale * m_pageScaleDelta;
+    IntSize scaledContentSize = m_scrollLayerImpl->children()[0]->contentBounds();
+    scaledContentSize.scale(m_pageScaleDelta);
+
+    m_pageScaleAnimation = CCPageScaleAnimation::create(scrollTotal, scaleTotal, m_viewportSize, scaledContentSize, currentTimeMs());
+
+    if (anchorPoint) {
+        IntSize windowAnchor(targetPosition);
+        windowAnchor.scale(scaleTotal / pageScale);
+        windowAnchor -= scrollTotal;
+        m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, durationMs);
+    } else
+        m_pageScaleAnimation->zoomTo(targetPosition, pageScale, durationMs);
+
+    m_client->setNeedsRedrawOnImplThread();
+}
+
 void CCLayerTreeHostImpl::drawLayers()
 {
     TRACE_EVENT("CCLayerTreeHostImpl::drawLayers", this, 0);
@@ -364,7 +404,7 @@
 {
     OwnPtr<CCScrollAndScaleSet> scrollInfo = adoptPtr(new CCScrollAndScaleSet());
     bool didMove = m_scrollLayerImpl && (!m_scrollLayerImpl->scrollDelta().isZero() || m_pageScaleDelta != 1.0f);
-    if (!didMove || m_pinchGestureActive) {
+    if (!didMove || m_pinchGestureActive || m_pageScaleAnimation) {
         m_sentPageScaleDelta = scrollInfo->pageScaleDelta = 1;
         return scrollInfo.release();
     }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (102307 => 102308)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2011-12-08 04:25:47 UTC (rev 102307)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2011-12-08 04:35:33 UTC (rev 102308)
@@ -37,6 +37,7 @@
 namespace WebCore {
 
 class CCCompletionEvent;
+class CCPageScaleAnimation;
 class CCLayerImpl;
 class LayerRendererChromium;
 class TextureAllocator;
@@ -110,6 +111,8 @@
     void setPageScaleFactorAndLimits(float pageScale, float minPageScale, float maxPageScale);
     float pageScale() const { return m_pageScale; }
 
+    void startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, double durationMs);
+
     const CCSettings& settings() const { return m_settings; }
 
     PassOwnPtr<CCScrollAndScaleSet> processScrollDeltas();
@@ -140,6 +143,8 @@
     float m_minPageScale, m_maxPageScale;
 
     bool m_pinchGestureActive;
+
+    OwnPtr<CCPageScaleAnimation> m_pageScaleAnimation;
 };
 
 };

Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPageScaleAnimation.cpp (0 => 102308)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPageScaleAnimation.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPageScaleAnimation.cpp	2011-12-08 04:35:33 UTC (rev 102308)
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Alp Toker <a...@atoker.com>
+ * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#include "cc/CCPageScaleAnimation.h"
+
+#include "FloatRect.h"
+#include "FloatSize.h"
+
+#include <math.h>
+
+namespace WebCore {
+
+PassOwnPtr<CCPageScaleAnimation> CCPageScaleAnimation::create(const IntSize& scrollStart, float pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, double startTimeMs)
+{
+    return adoptPtr(new CCPageScaleAnimation(scrollStart, pageScaleStart, windowSize, contentSize, startTimeMs));
+}
+
+
+CCPageScaleAnimation::CCPageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, double startTimeMs)
+    : m_scrollStart(scrollStart)
+    , m_pageScaleStart(pageScaleStart)
+    , m_windowSize(windowSize)
+    , m_contentSize(contentSize)
+    , m_anchorMode(false)
+    , m_scrollEnd(scrollStart)
+    , m_pageScaleEnd(pageScaleStart)
+    , m_startTimeMs(startTimeMs)
+{
+}
+
+void CCPageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale, double durationMs)
+{
+    if (m_pageScaleStart != finalPageScale) {
+        // For uniform-looking zooming, infer the anchor (point that remains in
+        // place throughout the zoom) from the start and end rects.
+        FloatRect startRect(IntPoint(m_scrollStart), m_windowSize);
+        FloatRect endRect(IntPoint(finalScroll), m_windowSize);
+        endRect.scale(m_pageScaleStart / finalPageScale);
+
+        // The anchor is the point which is at the same ratio of the sides of
+        // both startRect and endRect. For example, a zoom-in double-tap to a
+        // perfectly centered rect will have anchor ratios (0.5, 0.5), while one
+        // to a rect touching the bottom-right of the screen will have anchor
+        // ratios (1.0, 1.0). In other words, it obeys the equations:
+        // anchorX = start_width * ratioX + start_x
+        // anchorX = end_width * ratioX + end_x
+        // anchorY = start_height * ratioY + start_y
+        // anchorY = end_height * ratioY + end_y
+        // where both anchor{x,y} and ratio{x,y} begin as unknowns. Solving
+        // for the ratios, we get the following formulas:
+        float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width());
+        float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height());
+
+        IntSize anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY);
+        zoomWithAnchor(anchor, finalPageScale, durationMs);
+    } else {
+        // If this is a pure translation, then there exists no anchor. Linearly
+        // interpolate the scroll offset instead.
+        m_scrollEnd = finalScroll;
+        m_pageScaleEnd = finalPageScale;
+        m_durationMs = durationMs;
+        m_anchorMode = false;
+    }
+}
+
+void CCPageScaleAnimation::zoomWithAnchor(const IntSize& anchor, float finalPageScale, double durationMs)
+{
+    m_scrollEnd = m_scrollStart + anchor;
+    m_scrollEnd.scale(finalPageScale / m_pageScaleStart);
+    m_scrollEnd -= anchor;
+
+    m_scrollEnd.clampNegativeToZero();
+    FloatSize scaledContentSize(m_contentSize);
+    scaledContentSize.scale(finalPageScale / m_pageScaleStart);
+    IntSize maxScrollPosition = roundedIntSize(scaledContentSize - m_windowSize);
+    m_scrollEnd = m_scrollEnd.shrunkTo(maxScrollPosition);
+
+    m_anchor = anchor;
+    m_pageScaleEnd = finalPageScale;
+    m_durationMs = durationMs;
+    m_anchorMode = true;
+}
+
+IntSize CCPageScaleAnimation::scrollOffsetAtTime(double timeMs) const
+{
+    return scrollOffsetAtRatio(progressRatioForTime(timeMs));
+}
+
+float CCPageScaleAnimation::pageScaleAtTime(double timeMs) const
+{
+    return pageScaleAtRatio(progressRatioForTime(timeMs));
+}
+
+bool CCPageScaleAnimation::isAnimationCompleteAtTime(double timeMs) const
+{
+    return timeMs >= endTimeMs();
+}
+
+float CCPageScaleAnimation::progressRatioForTime(double timeMs) const
+{
+    if (isAnimationCompleteAtTime(timeMs))
+        return 1;
+
+    return (timeMs - m_startTimeMs) / m_durationMs;
+}
+
+IntSize CCPageScaleAnimation::scrollOffsetAtRatio(float ratio) const
+{
+    if (ratio <= 0)
+        return m_scrollStart;
+    if (ratio >= 1)
+        return m_scrollEnd;
+
+    float currentPageScale = pageScaleAtRatio(ratio);
+    IntSize currentScrollOffset;
+    if (m_anchorMode) {
+        // Keep the anchor stable on the screen at the current scale.
+        IntSize documentAnchor = m_scrollStart + m_anchor;
+        documentAnchor.scale(currentPageScale / m_pageScaleStart);
+        currentScrollOffset = documentAnchor - m_anchor;
+    } else {
+        // First move both scroll offsets to the current coordinate space.
+        FloatSize scaledStartScroll(m_scrollStart);
+        scaledStartScroll.scale(currentPageScale / m_pageScaleStart);
+        FloatSize scaledEndScroll(m_scrollEnd);
+        scaledEndScroll.scale(currentPageScale / m_pageScaleEnd);
+
+        // Linearly interpolate between them.
+        FloatSize delta = scaledEndScroll - scaledStartScroll;
+        delta.scale(ratio);
+        currentScrollOffset = roundedIntSize(scaledStartScroll + delta);
+    }
+
+    return currentScrollOffset;
+}
+
+float CCPageScaleAnimation::pageScaleAtRatio(float ratio) const
+{
+    if (ratio <= 0)
+        return m_pageScaleStart;
+    if (ratio >= 1)
+        return m_pageScaleEnd;
+
+    // Linearly interpolate the magnitude in log scale.
+    // Log scale is needed to maintain the appearance of uniform zoom. For
+    // example, if we zoom from 0.5 to 4.0 in 3 seconds, then we should
+    // be zooming by 2x every second.
+    float diff = m_pageScaleEnd / m_pageScaleStart;
+    float logDiff = log(diff);
+    logDiff *= ratio;
+    diff = exp(logDiff);
+    return m_pageScaleStart * diff;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPageScaleAnimation.h (0 => 102308)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPageScaleAnimation.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPageScaleAnimation.h	2011-12-08 04:35:33 UTC (rev 102308)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CCPageScaleAnimation_h
+#define CCPageScaleAnimation_h
+
+#include "IntSize.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+// A small helper class that does the math for zoom animations, primarily for
+// double-tap zoom. Initialize it with starting and ending scroll/page scale
+// positions and an animation length time, then call ...AtTime() at every frame
+// to obtain the current interpolated position.
+class CCPageScaleAnimation {
+public:
+    // Construct with the starting page scale and scroll offset (which is in
+    // pageScaleStart space). The window size is the user-viewable area
+    // in pixels.
+    static PassOwnPtr<CCPageScaleAnimation> create(const IntSize& scrollStart, float pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, double startTimeMs);
+
+    // The following methods initialize the animation. Call one of them
+    // immediately after construction to set the final scroll and page scale.
+
+    // Zoom while explicitly specifying the top-left scroll position. The
+    // scroll offset is in finalPageScale coordinates.
+    void zoomTo(const IntSize& finalScroll, float finalPageScale, double durationMs);
+
+    // Zoom based on a specified onscreen anchor, which will remain at the same
+    // position on the screen throughout the animation. The anchor is in local
+    // space relative to scrollStart.
+    void zoomWithAnchor(const IntSize& anchor, float finalPageScale, double durationMs);
+
+    // Call these functions while the animation is in progress to output the
+    // current state.
+    IntSize scrollOffsetAtTime(double timeMs) const;
+    float pageScaleAtTime(double timeMs) const;
+    bool isAnimationCompleteAtTime(double timeMs) const;
+
+    // The following methods return state which is invariant throughout the
+    // course of the animation.
+    double startTimeMs() const { return m_startTimeMs; }
+    double durationMs() const { return m_durationMs; }
+    double endTimeMs() const { return m_startTimeMs + m_durationMs; }
+    const IntSize& finalScrollOffset() const { return m_scrollEnd; }
+    float finalPageScale() const { return m_pageScaleEnd; }
+
+protected:
+    CCPageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, double startTimeMs);
+
+private:
+    float progressRatioForTime(double timeMs) const;
+    IntSize scrollOffsetAtRatio(float ratio) const;
+    float pageScaleAtRatio(float ratio) const;
+
+    IntSize m_scrollStart;
+    float m_pageScaleStart;
+    IntSize m_windowSize;
+    IntSize m_contentSize;
+
+    bool m_anchorMode;
+    IntSize m_anchor;
+    IntSize m_scrollEnd;
+    float m_pageScaleEnd;
+
+    double m_startTimeMs;
+    double m_durationMs;
+};
+
+} // namespace WebCore
+
+#endif

Modified: trunk/Source/WebKit/chromium/ChangeLog (102307 => 102308)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-12-08 04:25:47 UTC (rev 102307)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-12-08 04:35:33 UTC (rev 102308)
@@ -1,3 +1,28 @@
+2011-12-07  Alexandre Elias  <ael...@google.com>
+
+        [chromium] Add page-scale animation support to Impl thread
+        https://bugs.webkit.org/show_bug.cgi?id=72996
+
+        Reviewed by James Robinson.
+
+        This adds a new math helper class to compute the progress of the
+        animation, and code in the CCLayerTreeHostImpl to apply the animation
+        frame by frame.
+
+        No new tests. (https://bugs.webkit.org/show_bug.cgi?id=71529 filed.)
+
+        * public/WebCompositor.h:
+        * public/WebInputEvent.h:
+        (WebKit::WebPageScaleAnimationEvent::WebPageScaleAnimationEvent):
+        * public/android/WebInputEventFactory.h:
+        * src/WebCompositorImpl.cpp:
+        (WebKit::WebCompositorImpl::handlePageScaleAnimationEvent):
+        * src/WebCompositorImpl.h:
+        * src/WebPopupMenuImpl.cpp:
+        (WebKit::WebPopupMenuImpl::handleInputEvent):
+        * src/android/WebInputEventFactory.cpp:
+        (WebKit::WebInputEventFactory::pageScaleAnimationEvent):
+
 2011-12-07  Fady Samuel  <fsam...@chromium.org>
 
         [Chromium] Plumb DPI info into PlatformScreen
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to