Changeset 107357 in webkit


Ignore:
Timestamp:
Feb 9, 2012 9:51:57 PM (12 years ago)
Author:
wjmaclean@chromium.org
Message:

[chromium] Add support for starting page/scale animations on CC impl thread from WebViewImpl
https://bugs.webkit.org/show_bug.cgi?id=77872

Reviewed by James Robinson.

Source/WebCore:

Added unit test.

Provides a pathway to invoke CCLayerTreeHostImpl::startPageScaleAnimation() from
WebViewImpl. This is intended to support scale and scroll animations, such as WebInputEvent::GestureDoubleTap.

  • platform/CrossThreadCopier.h:

(WebCore):

  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:

(WebCore::CCLayerTreeHost::startPageScaleAnimation):

  • platform/graphics/chromium/cc/CCLayerTreeHost.h:

(CCLayerTreeHost):

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:

(CCLayerTreeHostImpl):

  • platform/graphics/chromium/cc/CCProxy.h:

(CCProxy):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:

(WebCore::CCSingleThreadProxy::startPageScaleAnimation):
(WebCore):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.h:

(CCSingleThreadProxy):

  • platform/graphics/chromium/cc/CCThreadProxy.cpp:

(WebCore::CCThreadProxy::startPageScaleAnimation):
(WebCore):
(WebCore::CCThreadProxy::requestStartPageScaleAnimationOnImplThread):

  • platform/graphics/chromium/cc/CCThreadProxy.h:

(CCThreadProxy):

Source/WebKit/chromium:

Provides a pathway to invoke CCLayerTreeHostImpl::startPageScaleAnimation() from
WebViewImpl. This is intended to support scale and scroll animations, such as WebInputEvent::GestureDoubleTap.

  • src/WebViewImpl.cpp:

(WebKit):
(WebKit::WebViewImpl::startPageScaleAnimation):

  • src/WebViewImpl.h:

(WebViewImpl):

  • tests/CCLayerTreeHostTest.cpp:

(WTF):
(CCLayerTreeHostTestStartPageScaleAnimation):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::CCLayerTreeHostTestStartPageScaleAnimation):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::beginTest):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::requestStartPageScaleAnimation):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::drawLayersOnCCThread):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::applyScrollAndScale):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::commitCompleteOnCCThread):
(WTF::CCLayerTreeHostTestStartPageScaleAnimation::afterTest):
(WTF::TEST_F):

Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107352 r107357  
     12012-02-09  W. James MacLean  <wjmaclean@chromium.org>
     2
     3        [chromium] Add support for starting page/scale animations on CC impl thread from WebViewImpl
     4        https://bugs.webkit.org/show_bug.cgi?id=77872
     5
     6        Reviewed by James Robinson.
     7
     8        Added unit test.
     9
     10        Provides a pathway to invoke CCLayerTreeHostImpl::startPageScaleAnimation() from
     11        WebViewImpl. This is intended to support scale and scroll animations, such as WebInputEvent::GestureDoubleTap.
     12
     13        * platform/CrossThreadCopier.h:
     14        (WebCore):
     15        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     16        (WebCore::CCLayerTreeHost::startPageScaleAnimation):
     17        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     18        (CCLayerTreeHost):
     19        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
     20        (CCLayerTreeHostImpl):
     21        * platform/graphics/chromium/cc/CCProxy.h:
     22        (CCProxy):
     23        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     24        (WebCore::CCSingleThreadProxy::startPageScaleAnimation):
     25        (WebCore):
     26        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
     27        (CCSingleThreadProxy):
     28        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     29        (WebCore::CCThreadProxy::startPageScaleAnimation):
     30        (WebCore):
     31        (WebCore::CCThreadProxy::requestStartPageScaleAnimationOnImplThread):
     32        * platform/graphics/chromium/cc/CCThreadProxy.h:
     33        (CCThreadProxy):
     34
    1352012-02-09  Xianzhu Wang  <wangxianzhu@chromium.org>
    236
  • trunk/Source/WebCore/platform/CrossThreadCopier.h

    r96066 r107357  
    4343
    4444    class IntRect;
     45    class IntSize;
    4546    class KURL;
    4647    class ResourceError;
     
    7172
    7273    template<> struct CrossThreadCopierBase<false, false, IntRect> : public CrossThreadCopierPassThrough<IntRect> {
     74    };
     75
     76    template<> struct CrossThreadCopierBase<false, false, IntSize> : public CrossThreadCopierPassThrough<IntSize> {
    7377    };
    7478
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r107282 r107357  
    357357}
    358358
     359void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
     360{
     361    m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationSec);
     362}
    359363
    360364void CCLayerTreeHost::loseCompositorContext(int numTimes)
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r107177 r107357  
    189189    bool updateLayers();
    190190
     191    void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec);
     192
    191193    void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
    192194    void applyScrollAndScale(const CCScrollAndScaleSet&);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r107243 r107357  
    118118    void setFullRootLayerDamage();
    119119
     120    void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor, float scale, double durationSec);
     121
    120122protected:
    121123    CCLayerTreeHostImpl(const CCSettings&, CCLayerTreeHostImplClient*);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h

    r107177 r107357  
    5858    virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0;
    5959
     60    virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec) = 0;
     61
    6062    virtual void finishAllRendering() = 0;
    6163
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp

    r107243 r107357  
    9494}
    9595
     96void CCSingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
     97{
     98    m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime() * 1000.0, durationSec * 1000.0);
     99}
     100
    96101GraphicsContext3D* CCSingleThreadProxy::context()
    97102{
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h

    r107177 r107357  
    4343    // CCProxy implementation
    4444    virtual bool compositeAndReadback(void *pixels, const IntRect&);
     45    virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec);
    4546    virtual GraphicsContext3D* context();
    4647    virtual void finishAllRendering();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r107243 r107357  
    134134}
    135135
     136void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
     137{
     138    ASSERT(CCProxy::isMainThread());
     139    CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::requestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durationSec));
     140}
     141
     142void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, double durationSec)
     143{
     144    ASSERT(CCProxy::isImplThread());
     145    if (m_layerTreeHostImpl)
     146        m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime() * 1000.0, durationSec * 1000.0);
     147}
     148
    136149GraphicsContext3D* CCThreadProxy::context()
    137150{
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h

    r107243 r107357  
    5050    // CCProxy implementation
    5151    virtual bool compositeAndReadback(void *pixels, const IntRect&);
     52    virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec);
    5253    virtual GraphicsContext3D* context();
    5354    virtual void finishAllRendering();
     
    9899    void beginFrameCompleteOnImplThread(CCCompletionEvent*);
    99100    void requestReadbackOnImplThread(ReadbackRequest*);
     101    void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, double durationSec);
    100102    void finishAllRenderingOnImplThread(CCCompletionEvent*);
    101103    void initializeImplOnImplThread(CCCompletionEvent*);
  • trunk/Source/WebKit/chromium/ChangeLog

    r107291 r107357  
     12012-02-09  W. James MacLean  <wjmaclean@chromium.org>
     2
     3        [chromium] Add support for starting page/scale animations on CC impl thread from WebViewImpl
     4        https://bugs.webkit.org/show_bug.cgi?id=77872
     5
     6        Reviewed by James Robinson.
     7
     8        Provides a pathway to invoke CCLayerTreeHostImpl::startPageScaleAnimation() from
     9        WebViewImpl. This is intended to support scale and scroll animations, such as WebInputEvent::GestureDoubleTap.
     10
     11        * src/WebViewImpl.cpp:
     12        (WebKit):
     13        (WebKit::WebViewImpl::startPageScaleAnimation):
     14        * src/WebViewImpl.h:
     15        (WebViewImpl):
     16        * tests/CCLayerTreeHostTest.cpp:
     17        (WTF):
     18        (CCLayerTreeHostTestStartPageScaleAnimation):
     19        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::CCLayerTreeHostTestStartPageScaleAnimation):
     20        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::beginTest):
     21        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::requestStartPageScaleAnimation):
     22        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::drawLayersOnCCThread):
     23        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::applyScrollAndScale):
     24        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::commitCompleteOnCCThread):
     25        (WTF::CCLayerTreeHostTestStartPageScaleAnimation::afterTest):
     26        (WTF::TEST_F):
     27
    1282012-02-09  John Bates  <jbates@google.com>
    229
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r107243 r107357  
    624624    return handled;
    625625}
     626
     627void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
     628{
     629    if (m_layerTreeHost)
     630        m_layerTreeHost->startPageScaleAnimation(IntSize(scroll.x(), scroll.y()), useAnchor, newScale, durationSec);
     631}
    626632#endif
    627633
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r107243 r107357  
    4646#include "GraphicsLayer.h"
    4747#include "InspectorClientImpl.h"
     48#include "IntPoint.h"
    4849#include "IntRect.h"
    4950#include "NotificationPresenterImpl.h"
     
    316317    bool mouseWheel(const WebMouseWheelEvent&);
    317318    bool gestureEvent(const WebGestureEvent&);
     319    void startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationSec);
    318320    bool keyEvent(const WebKeyboardEvent&);
    319321    bool charEvent(const WebKeyboardEvent&);
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r107177 r107357  
    939939}
    940940
     941// Verifies that startPageScaleAnimation events propagate correctly from CCLayerTreeHost to
     942// CCLayerTreeHostImpl in the MT compositor.
     943class CCLayerTreeHostTestStartPageScaleAnimation : public CCLayerTreeHostTest {
     944public:
     945
     946    CCLayerTreeHostTestStartPageScaleAnimation()
     947        : m_animationRequested(false)
     948    {
     949    }
     950
     951    virtual void beginTest()
     952    {
     953        m_layerTreeHost->rootLayer()->setScrollable(true);
     954        m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint());
     955        postSetNeedsRedrawToMainThread();
     956    }
     957
     958    static void requestStartPageScaleAnimation(void* self)
     959    {
     960        CCLayerTreeHostTestStartPageScaleAnimation* test = static_cast<CCLayerTreeHostTestStartPageScaleAnimation*>(self);
     961        if (test->layerTreeHost())
     962            test->layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, 0);
     963    }
     964
     965    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
     966    {
     967        impl->rootLayer()->setScrollable(true);
     968        impl->rootLayer()->setScrollPosition(IntPoint());
     969        impl->setPageScaleFactorAndLimits(impl->pageScale(), 0.5, 2);
     970
     971        // We request animation only once.
     972        if (!m_animationRequested) {
     973            callOnMainThread(CCLayerTreeHostTestStartPageScaleAnimation::requestStartPageScaleAnimation, this);
     974            m_animationRequested = true;
     975        }
     976    }
     977
     978    virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale)
     979    {
     980        IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
     981        m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
     982        m_layerTreeHost->setPageScale(scale);
     983    }
     984
     985    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)
     986    {
     987        impl->processScrollDeltas();
     988        // We get one commit before the first draw, and the animation doesn't happen until the second draw,
     989        // so results available on the third commit.
     990        if (impl->frameNumber() == 2) {
     991            EXPECT_EQ(1.25, impl->pageScale());
     992            endTest();
     993        } else
     994            postSetNeedsRedrawToMainThread();
     995    }
     996
     997    virtual void afterTest()
     998    {
     999    }
     1000
     1001private:
     1002    bool m_animationRequested;
     1003};
     1004
     1005TEST_F(CCLayerTreeHostTestStartPageScaleAnimation, runTest)
     1006{
     1007    runTest(true);
     1008}
     1009
    9411010class CCLayerTreeHostTestSetVisible : public CCLayerTreeHostTest {
    9421011public:
Note: See TracChangeset for help on using the changeset viewer.