Accelerated overflow scrolling for Coordinated Graphics.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 12:07:26 +0000 (12:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 12:07:26 +0000 (12:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110323

Source/WebCore:

Patch by Luiz Agostini <luiz.agostini@nokia.com> on 2013-03-06
Reviewed by Noam Rosenthal.

A scroll offset is applied to individual layers on UI process and the
web process is notified assynchronously.
The new API WKCoordinatedScene may be used to scroll layers in the UI process.

Tests will be added on bug #111140.

Scrolling coordinator is used to provide a ScrollableArea to CoordinatedGraphicsLayer.

* page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:
(WebCore::ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange):
(WebCore):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea):
* page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h:
(ScrollingCoordinatorCoordinatedGraphics):

GraphicsLayerTextureMapper is responsible for receiving the 'did commit' messages and to pass
them to its TextureMapperLayer on the appropriated time.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
(WebCore::GraphicsLayerTextureMapper::didCommitScrollOffset):
(WebCore):
(WebCore::GraphicsLayerTextureMapper::setIsScrollable):
(WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
(WebCore::GraphicsLayerTextureMapper::setScrollClient):
(WebCore::GraphicsLayerTextureMapper::setID):
(GraphicsLayerTextureMapper):
(WebCore::GraphicsLayerTextureMapper::isScrollable):

TextureMapperLayer is responsible for applying the requested scroll offset and for
sending the commit messages to web process. It is also able to hittest layers and identify
the ones that are scrollable.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::hitTest):
(WebCore):
(WebCore::TextureMapperLayer::scrollableLayerHitTestCondition):
(WebCore::TextureMapperLayer::findScrollableContentsLayerAt):
(WebCore::TextureMapperLayer::mapScrollOffset):
(WebCore::TextureMapperLayer::commitScrollOffset):
(WebCore::TextureMapperLayer::scrollBy):
(WebCore::TextureMapperLayer::didCommitScrollOffset):
* platform/graphics/texmap/TextureMapperLayer.h:
(TextureMapperLayer):
(ScrollingClient):
(WebCore::TextureMapperLayer::TextureMapperLayer):
(WebCore::TextureMapperLayer::setID):
(WebCore::TextureMapperLayer::id):
(WebCore::TextureMapperLayer::setScrollClient):
(WebCore::TextureMapperLayer::setIsScrollable):
(WebCore::TextureMapperLayer::isScrollable):
(WebCore::TextureMapperLayer::adjustedPosition):

CoordinatedGraphicsLayer receives the commit messages and updates its ScrollableArea.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
(WebCore::CoordinatedGraphicsLayer::setScrollableArea):
(WebCore):
(WebCore::CoordinatedGraphicsLayer::commitScrollOffset):
(WebCore::CoordinatedGraphicsLayer::resetLayerState):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
(WebCore):
(CoordinatedGraphicsLayer):
(WebCore::CoordinatedGraphicsLayer::isScrollable):

CoordinatedGraphicsScene receives the commit messages from TextureMapperLayer and
dispatches them on the main thread. It also has a new method that is used to find
the topmost scrollable layer at a given point.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::setLayerState):
(WebCore::CoordinatedGraphicsScene::createLayer):
(WebCore::CoordinatedGraphicsScene::dispatchCommitScrollOffset):
(WebCore):
(WebCore::CoordinatedGraphicsScene::commitScrollOffset):
(WebCore::CoordinatedGraphicsScene::findScrollableContentsLayerAt):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
(WebCore):
(CoordinatedGraphicsSceneClient):
(CoordinatedGraphicsScene):

New fields have been added to CoordinatedGraphicsLayerState.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
(CoordinatedGraphicsLayerState):

Source/WebKit2:

Patch by Luiz Agostini <luiz.agostini@nokia.com> on 2013-03-06
Reviewed by Noam Rosenthal.
Signed off for WebKit2 by Simon Fraser.

A scroll offset is applied to individual layers on UI process and the
web process is notified assynchronously.
The new API WKCoordinatedScene may be used to scroll layers in the UI process.

* CMakeLists.txt:

Encoding and decoding the new members of CoordinatedGraphicsLayerState.

* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(CoreIPC::::encode):
(CoreIPC::::decode):

Adding acceleratedCompositingForOverflowScrollEnabled to WebPreferencesStore.

* Shared/WebPreferencesStore.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

New API WKCoordinatedScene is used to scroll layers on UI side.

* UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.cpp:
* UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.h:
* UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h:

A new message is used to send scroll commit messages to web process.

* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
(WebKit::CoordinatedLayerTreeHostProxy::commitScrollOffset):
(WebKit):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
(CoordinatedLayerTreeHostProxy):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::detachLayer):
(WebKit::CoordinatedLayerTreeHost::createGraphicsLayer):
(WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
(WebKit::CoordinatedLayerTreeHost::purgeBackingStores):
(WebKit::CoordinatedLayerTreeHost::commitScrollOffset):
(WebKit):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
(CoordinatedLayerTreeHost):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144907 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.h [new file with mode: 0644]
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h
Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index c518f65..558164c 100644 (file)
@@ -1,3 +1,98 @@
+2013-03-06  Luiz Agostini  <luiz.agostini@nokia.com>
+
+        Accelerated overflow scrolling for Coordinated Graphics.
+        https://bugs.webkit.org/show_bug.cgi?id=110323
+
+        Reviewed by Noam Rosenthal.
+
+        A scroll offset is applied to individual layers on UI process and the
+        web process is notified assynchronously.
+        The new API WKCoordinatedScene may be used to scroll layers in the UI process.
+
+        Tests will be added on bug #111140.
+
+        Scrolling coordinator is used to provide a ScrollableArea to CoordinatedGraphicsLayer.
+
+        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:
+        (WebCore::ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange):
+        (WebCore):
+        (WebCore::ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea):
+        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h:
+        (ScrollingCoordinatorCoordinatedGraphics):
+
+        GraphicsLayerTextureMapper is responsible for receiving the 'did commit' messages and to pass
+        them to its TextureMapperLayer on the appropriated time.
+
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
+        (WebCore::GraphicsLayerTextureMapper::didCommitScrollOffset):
+        (WebCore):
+        (WebCore::GraphicsLayerTextureMapper::setIsScrollable):
+        (WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
+        (WebCore::GraphicsLayerTextureMapper::setScrollClient):
+        (WebCore::GraphicsLayerTextureMapper::setID):
+        (GraphicsLayerTextureMapper):
+        (WebCore::GraphicsLayerTextureMapper::isScrollable):
+
+        TextureMapperLayer is responsible for applying the requested scroll offset and for
+        sending the commit messages to web process. It is also able to hittest layers and identify
+        the ones that are scrollable.
+
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::hitTest):
+        (WebCore):
+        (WebCore::TextureMapperLayer::scrollableLayerHitTestCondition):
+        (WebCore::TextureMapperLayer::findScrollableContentsLayerAt):
+        (WebCore::TextureMapperLayer::mapScrollOffset):
+        (WebCore::TextureMapperLayer::commitScrollOffset):
+        (WebCore::TextureMapperLayer::scrollBy):
+        (WebCore::TextureMapperLayer::didCommitScrollOffset):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (TextureMapperLayer):
+        (ScrollingClient):
+        (WebCore::TextureMapperLayer::TextureMapperLayer):
+        (WebCore::TextureMapperLayer::setID):
+        (WebCore::TextureMapperLayer::id):
+        (WebCore::TextureMapperLayer::setScrollClient):
+        (WebCore::TextureMapperLayer::setIsScrollable):
+        (WebCore::TextureMapperLayer::isScrollable):
+        (WebCore::TextureMapperLayer::adjustedPosition):
+
+        CoordinatedGraphicsLayer receives the commit messages and updates its ScrollableArea.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
+        (WebCore::CoordinatedGraphicsLayer::setScrollableArea):
+        (WebCore):
+        (WebCore::CoordinatedGraphicsLayer::commitScrollOffset):
+        (WebCore::CoordinatedGraphicsLayer::resetLayerState):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+        (WebCore):
+        (CoordinatedGraphicsLayer):
+        (WebCore::CoordinatedGraphicsLayer::isScrollable):
+
+        CoordinatedGraphicsScene receives the commit messages from TextureMapperLayer and
+        dispatches them on the main thread. It also has a new method that is used to find
+        the topmost scrollable layer at a given point.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
+        (WebCore::CoordinatedGraphicsScene::setLayerState):
+        (WebCore::CoordinatedGraphicsScene::createLayer):
+        (WebCore::CoordinatedGraphicsScene::dispatchCommitScrollOffset):
+        (WebCore):
+        (WebCore::CoordinatedGraphicsScene::commitScrollOffset):
+        (WebCore::CoordinatedGraphicsScene::findScrollableContentsLayerAt):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
+        (WebCore):
+        (CoordinatedGraphicsSceneClient):
+        (CoordinatedGraphicsScene):
+
+        New fields have been added to CoordinatedGraphicsLayerState.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
+        (CoordinatedGraphicsLayerState):
+
 2013-03-06  Allan Sandfeld Jensen  <allan.jensen@digia.com>
 
         REGGRESSION (r142112): It made compositing tests fail on EFL, Qt.
index a1bf3bd..9d8ec47 100644 (file)
@@ -47,6 +47,24 @@ void ScrollingCoordinatorCoordinatedGraphics::setLayerIsFixedToContainerLayer(Gr
     toCoordinatedGraphicsLayer(layer)->setFixedToViewport(enable);
 }
 
+void ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange(ScrollableArea* scrollableArea)
+{
+    CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea));
+    if (!layer)
+        return;
+
+    layer->setScrollableArea(scrollableArea);
+}
+
+void ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea(ScrollableArea* scrollableArea)
+{
+    CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea));
+    if (!layer)
+        return;
+
+    layer->setScrollableArea(0);
+}
+
 } // namespace WebCore
 
 #endif // USE(COORDINATED_GRAPHICS)
index 4e04bbe..6748e4e 100644 (file)
@@ -39,6 +39,8 @@ public:
     virtual bool supportsFixedPositionLayers() const { return true; }
 
     virtual void setLayerIsFixedToContainerLayer(GraphicsLayer*, bool);
+    virtual void scrollableAreaScrollLayerDidChange(ScrollableArea*);
+    virtual void willDestroyScrollableArea(ScrollableArea*);
 };
 
 } // namespace WebCore
index 8013ec4..f326235 100644 (file)
@@ -57,6 +57,7 @@ GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(GraphicsLayerClient* clie
     , m_debugBorderWidth(0)
     , m_contentsLayer(0)
     , m_animationStartTime(0)
+    , m_isScrollable(false)
 {
 }
 
@@ -403,6 +404,24 @@ void GraphicsLayerTextureMapper::setShowRepaintCounter(bool show)
     notifyChange(DebugVisualsChange);
 }
 
+void GraphicsLayerTextureMapper::didCommitScrollOffset(const IntSize& offset)
+{
+    if (offset.isZero())
+        return;
+
+    m_committedScrollOffset = offset;
+    notifyChange(CommittedScrollOffsetChange);
+}
+
+void GraphicsLayerTextureMapper::setIsScrollable(bool isScrollable)
+{
+    if (m_isScrollable == isScrollable)
+        return;
+
+    m_isScrollable = isScrollable;
+    notifyChange(IsScrollableChange);
+}
+
 /* \reimp (GraphicsLayer.h)
 */
 void GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly()
@@ -543,6 +562,12 @@ void GraphicsLayerTextureMapper::commitLayerChanges()
     if (m_changeMask & FixedToViewporChange)
         m_layer->setFixedToViewport(fixedToViewport());
 
+    if (m_changeMask & IsScrollableChange)
+        m_layer->setIsScrollable(isScrollable());
+
+    if (m_changeMask & CommittedScrollOffsetChange)
+        m_layer->didCommitScrollOffset(m_committedScrollOffset);
+
     m_changeMask = NoChanges;
 }
 
index 9329fbc..60444ee 100644 (file)
@@ -34,6 +34,9 @@ public:
     explicit GraphicsLayerTextureMapper(GraphicsLayerClient*);
     virtual ~GraphicsLayerTextureMapper();
 
+    void setScrollClient(TextureMapperLayer::ScrollingClient* client) { m_layer->setScrollClient(client); }
+    void setID(uint32_t id) { m_layer->setID(id); }
+
     // reimps from GraphicsLayer.h
     virtual void setNeedsDisplay();
     virtual void setContentsNeedsDisplay();
@@ -81,6 +84,10 @@ public:
 
     TextureMapperLayer* layer() const { return m_layer.get(); }
 
+    void didCommitScrollOffset(const IntSize&);
+    void setIsScrollable(bool);
+    bool isScrollable() const { return m_isScrollable; }
+
 #if ENABLE(CSS_FILTERS)
     virtual bool setFilters(const FilterOperations&);
 #endif
@@ -143,7 +150,10 @@ private:
         RepaintCountChange =        (1L << 25),
 
         FixedToViewporChange =      (1L << 26),
-        AnimationStarted =          (1L << 27)
+        AnimationStarted =          (1L << 27),
+
+        CommittedScrollOffsetChange =     (1L << 28),
+        IsScrollableChange =              (1L << 29)
     };
     void notifyChange(ChangeMask);
 
@@ -165,6 +175,9 @@ private:
     FloatRect m_needsDisplayRect;
     GraphicsLayerAnimations m_animations;
     double m_animationStartTime;
+
+    IntSize m_committedScrollOffset;
+    bool m_isScrollable;
 };
 
 inline static GraphicsLayerTextureMapper* toGraphicsLayerTextureMapper(GraphicsLayer* layer)
index 10bef26..1d0ac44 100644 (file)
@@ -20,7 +20,9 @@
 #include "config.h"
 #include "TextureMapperLayer.h"
 
+#include "FloatQuad.h"
 #include "Region.h"
+#include <wtf/MathExtras.h>
 
 #if USE(ACCELERATED_COMPOSITING)
 
@@ -673,5 +675,84 @@ void TextureMapperLayer::setScrollPositionDeltaIfNeeded(const FloatSize& delta)
     m_currentTransform.setPosition(adjustedPosition());
 }
 
+template<class HitTestCondition> TextureMapperLayer* TextureMapperLayer::hitTest(const FloatPoint& point, HitTestCondition condition)
+{
+    if (!m_state.visible || !m_state.contentsVisible)
+        return 0;
+
+    TextureMapperLayer* result = 0;
+    for (int i = m_children.size() - 1; !result && i >= 0; --i)
+        result = m_children[i]->hitTest(point, condition);
+
+    if (result)
+        return result;
+
+    return condition(this, point) ? this : 0;
+}
+
+bool TextureMapperLayer::scrollableLayerHitTestCondition(TextureMapperLayer* layer, const FloatPoint& point)
+{
+    // scrolling layer's m_parent->m_parent, the parent of the scrolling layes, is the one that defines the
+    // rectangle to be used for hit testing.
+    if (!layer->isScrollable() || !layer->m_parent || !layer->m_parent->m_parent)
+        return false;
+
+    TextureMapperLayer* parentLayer = layer->m_parent->m_parent;
+
+    FloatRect rect;
+    if (parentLayer->m_backingStore)
+        rect = parentLayer->layerRect();
+    else if (parentLayer->m_contentsLayer)
+        rect = parentLayer->m_state.contentsRect;
+
+    return parentLayer->m_currentTransform.combined().mapQuad(rect).containsPoint(point);
+}
+
+TextureMapperLayer* TextureMapperLayer::findScrollableContentsLayerAt(const FloatPoint& point)
+{
+    return hitTest(point, &TextureMapperLayer::scrollableLayerHitTestCondition);
+}
+
+FloatSize TextureMapperLayer::mapScrollOffset(const FloatSize& offset)
+{
+    double zeroX, zeroY, offsetX, offsetY;
+    TransformationMatrix transform = m_currentTransform.combined().inverse();
+    transform.map(0, 0, zeroX, zeroY);
+    transform.map(offset.width(), offset.height(), offsetX, offsetY);
+    return FloatSize(offsetX - zeroX, offsetY - zeroY);
+}
+
+void TextureMapperLayer::commitScrollOffset(const FloatSize& offset)
+{
+    FloatSize fullOffset = m_accumulatedScrollOffsetFractionalPart + offset;
+
+    int intWidth = round(fullOffset.width());
+    int intHeight = round(fullOffset.height());
+
+    // m_accumulatedScrollOffsetFractionalPart holds the fractional part of the user scroll offset that
+    // has not yet been synced with the web process because the web process expects an IntSize.
+    m_accumulatedScrollOffsetFractionalPart = FloatSize(fullOffset.width() - intWidth, fullOffset.height() - intHeight);
+
+    m_scrollClient->commitScrollOffset(m_id, IntSize(intWidth, intHeight));
+}
+
+void TextureMapperLayer::scrollBy(const FloatSize& offset)
+{
+    if (!isScrollable() || !m_scrollClient || offset.isZero())
+        return;
+
+    FloatSize scrollOffset = mapScrollOffset(offset);
+    m_userScrollOffset += scrollOffset;
+
+    m_currentTransform.setPosition(adjustedPosition());
+    commitScrollOffset(scrollOffset);
+}
+
+void TextureMapperLayer::didCommitScrollOffset(const IntSize& offset)
+{
+    m_userScrollOffset = FloatSize(m_userScrollOffset.width() - offset.width(), m_userScrollOffset.height() - offset.height());
+    m_currentTransform.setPosition(adjustedPosition());
+}
+
 }
 #endif
index 602b2c3..1d3c678 100644 (file)
@@ -39,6 +39,12 @@ class TextureMapperLayer : public GraphicsLayerAnimation::Client {
     WTF_MAKE_NONCOPYABLE(TextureMapperLayer);
     WTF_MAKE_FAST_ALLOCATED;
 public:
+
+    class ScrollingClient {
+    public:
+        virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset) = 0;
+    };
+
     TextureMapperLayer()
         : m_parent(0)
         , m_effectTarget(0)
@@ -47,10 +53,25 @@ public:
         , m_centerZ(0)
         , m_textureMapper(0)
         , m_fixedToViewport(false)
+        , m_id(0)
+        , m_scrollClient(0)
+        , m_isScrollable(false)
     { }
 
     virtual ~TextureMapperLayer();
 
+    void setID(uint32_t id) { m_id = id; }
+    uint32_t id() { return m_id; }
+
+    TextureMapperLayer* findScrollableContentsLayerAt(const FloatPoint& pos);
+
+    void setScrollClient(ScrollingClient* scrollClient) { m_scrollClient = scrollClient; }
+    void scrollBy(const WebCore::FloatSize&);
+
+    void didCommitScrollOffset(const IntSize&);
+    void setIsScrollable(bool isScrollable) { m_isScrollable = isScrollable; }
+    bool isScrollable() const { return m_isScrollable; }
+
     TextureMapper* textureMapper() const;
     void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; }
 
@@ -108,7 +129,7 @@ private:
     static void sortByZOrder(Vector<TextureMapperLayer* >& array, int first, int last);
 
     PassRefPtr<BitmapTexture> texture() { return m_backingStore ? m_backingStore->texture() : 0; }
-    FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta; }
+    FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta - m_userScrollOffset; }
     bool isAncestorFixedToViewport() const;
     TransformationMatrix replicaTransform();
     void addChild(TextureMapperLayer*);
@@ -159,6 +180,12 @@ private:
 #endif
     float m_centerZ;
 
+    template<class HitTestCondition> TextureMapperLayer* hitTest(const FloatPoint&, HitTestCondition);
+    static bool scrollableLayerHitTestCondition(TextureMapperLayer*, const FloatPoint&);
+
+    FloatSize mapScrollOffset(const FloatSize&);
+    void commitScrollOffset(const FloatSize&);
+
     struct State {
         FloatPoint pos;
         FloatPoint3D anchorPoint;
@@ -211,6 +238,11 @@ private:
     GraphicsLayerAnimations m_animations;
     FloatSize m_scrollPositionDelta;
     bool m_fixedToViewport;
+    uint32_t m_id;
+    ScrollingClient* m_scrollClient;
+    bool m_isScrollable;
+    FloatSize m_userScrollOffset;
+    FloatSize m_accumulatedScrollOffsetFractionalPart;
 };
 
 }
index 6e90036..5437ac5 100644 (file)
@@ -32,6 +32,7 @@
 #include "GraphicsContext.h"
 #include "GraphicsLayer.h"
 #include "Page.h"
+#include "ScrollableArea.h"
 #include "TextureMapperPlatformLayer.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/HashMap.h>
@@ -122,6 +123,7 @@ CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(GraphicsLayerClient* client)
     , m_compositedNativeImagePtr(0)
     , m_canvasPlatformLayer(0)
     , m_animationStartedTimer(this, &CoordinatedGraphicsLayer::animationStartedTimerFired)
+    , m_scrollableArea(0)
 {
     static CoordinatedLayerID nextLayerID = 1;
     m_id = nextLayerID++;
@@ -514,6 +516,29 @@ CoordinatedLayerID CoordinatedGraphicsLayer::id() const
     return m_id;
 }
 
+void CoordinatedGraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea)
+{
+    bool oldScrollable = isScrollable();
+    m_scrollableArea = scrollableArea;
+    if (oldScrollable == isScrollable())
+        return;
+
+    m_layerState.isScrollable = isScrollable();
+    m_layerState.isScrollableChanged = true;
+    didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::commitScrollOffset(const IntSize& offset)
+{
+    if (!isScrollable() || offset.isZero())
+        return;
+
+    m_scrollableArea->notifyScrollPositionChanged(m_scrollableArea->scrollPosition() + offset);
+    m_layerState.committedScrollOffset += offset;
+    m_layerState.committedScrollOffsetChanged = true;
+    didChangeLayerState();
+}
+
 void CoordinatedGraphicsLayer::setFixedToViewport(bool isFixed)
 {
     if (m_fixedToViewport == isFixed)
@@ -737,6 +762,7 @@ void CoordinatedGraphicsLayer::resetLayerState()
     m_layerState.tilesToCreate.clear();
     m_layerState.tilesToRemove.clear();
     m_layerState.tilesToUpdate.clear();
+    m_layerState.committedScrollOffset = IntSize();
 }
 
 bool CoordinatedGraphicsLayer::imageBackingVisible()
index 790fe96..a0708dc 100644 (file)
@@ -44,6 +44,7 @@
 namespace WebCore {
 class CoordinatedGraphicsLayer;
 class GraphicsLayerAnimations;
+class ScrollableArea;
 
 class CoordinatedGraphicsLayerClient {
 public:
@@ -115,6 +116,10 @@ public:
 
     void setRootLayer(bool);
 
+    void setScrollableArea(ScrollableArea*);
+    bool isScrollable() const { return !!m_scrollableArea; }
+    void commitScrollOffset(const IntSize&);
+
     CoordinatedLayerID id() const;
 
     void setFixedToViewport(bool isFixed);
@@ -240,6 +245,8 @@ private:
     Timer<CoordinatedGraphicsLayer> m_animationStartedTimer;
     GraphicsLayerAnimations m_animations;
     double m_lastAnimationStartTime;
+
+    ScrollableArea* m_scrollableArea;
 };
 
 CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer*);
index 41e353e..b82e4de 100644 (file)
@@ -360,6 +360,12 @@ void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const Coordi
         layer->setShowRepaintCounter(layerState.showRepaintCounter);
     }
 
+    if (layerState.isScrollableChanged)
+        toGraphicsLayerTextureMapper(layer)->setIsScrollable(layerState.isScrollable);
+
+    if (layerState.committedScrollOffsetChanged)
+        toGraphicsLayerTextureMapper(layer)->didCommitScrollOffset(layerState.committedScrollOffset);
+
     if (layerState.fixedToViewport)
         m_fixedLayers.add(id, layer);
     else
@@ -397,6 +403,8 @@ void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id)
 {
     OwnPtr<GraphicsLayer> newLayer = GraphicsLayer::create(0 /* factory */, this);
     toGraphicsLayerTextureMapper(newLayer.get())->setHasOwnBackingStore(false);
+    toGraphicsLayerTextureMapper(newLayer.get())->setID(id);
+    toGraphicsLayerTextureMapper(newLayer.get())->setScrollClient(this);
     m_layers.add(id, newLayer.release());
 }
 
@@ -686,6 +694,16 @@ void CoordinatedGraphicsScene::purgeGLResources()
     dispatchOnMainThread(bind(&CoordinatedGraphicsScene::purgeBackingStores, this));
 }
 
+void CoordinatedGraphicsScene::dispatchCommitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+    m_client->commitScrollOffset(layerID, offset);
+}
+
+void CoordinatedGraphicsScene::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+    dispatchOnMainThread(bind(&CoordinatedGraphicsScene::dispatchCommitScrollOffset, this, layerID, offset));
+}
+
 void CoordinatedGraphicsScene::purgeBackingStores()
 {
     if (m_client)
@@ -753,6 +771,11 @@ void CoordinatedGraphicsScene::setBackgroundColor(const Color& color)
     m_backgroundColor = color;
 }
 
+TextureMapperLayer* CoordinatedGraphicsScene::findScrollableContentsLayerAt(const FloatPoint& point)
+{
+    return rootLayer() ? toTextureMapperLayer(rootLayer())->findScrollableContentsLayerAt(point) : 0;
+}
+
 } // namespace WebCore
 
 #endif // USE(COORDINATED_GRAPHICS)
index ed5dbe0..68fc619 100644 (file)
@@ -33,6 +33,7 @@
 #include "TextureMapper.h"
 #include "TextureMapperBackingStore.h"
 #include "TextureMapperFPSCounter.h"
+#include "TextureMapperLayer.h"
 #include "Timer.h"
 #include <wtf/Functional.h>
 #include <wtf/HashSet.h>
@@ -48,7 +49,6 @@ namespace WebCore {
 class CoordinatedBackingStore;
 class CustomFilterProgram;
 class CustomFilterProgramInfo;
-class TextureMapperLayer;
 
 class CoordinatedGraphicsSceneClient {
 public:
@@ -59,9 +59,10 @@ public:
     virtual void purgeBackingStores() = 0;
     virtual void renderNextFrame() = 0;
     virtual void updateViewport() = 0;
+    virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset) = 0;
 };
 
-class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public GraphicsLayerClient {
+class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public GraphicsLayerClient, public TextureMapperLayer::ScrollingClient {
 public:
     explicit CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient*);
     virtual ~CoordinatedGraphicsScene();
@@ -71,6 +72,10 @@ public:
     void detach();
     void appendUpdate(const Function<void()>&);
 
+    WebCore::TextureMapperLayer* findScrollableContentsLayerAt(const WebCore::FloatPoint&);
+
+    virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset);
+
     // The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_client.
     // Currently, QQuickWebPage::updatePaintNode() locks the main thread before calling both methods.
     void purgeGLResources();
@@ -157,6 +162,8 @@ private:
     void removeBackingStoreIfNeeded(GraphicsLayer*);
     void resetBackingStoreSizeToLayerSize(GraphicsLayer*);
 
+    void dispatchCommitScrollOffset(uint32_t layerID, const IntSize& offset);
+
     // Render queue can be accessed ony from main thread or updatePaintNode call stack!
     Vector<Function<void()> > m_renderQueue;
     Mutex m_renderQueueMutex;
index 7cc6289..29c8e45 100644 (file)
@@ -90,6 +90,8 @@ struct CoordinatedGraphicsLayerState {
             bool repaintCountChanged : 1;
             bool canvasChanged: 1;
             bool canvasShouldSwapBuffers: 1;
+            bool isScrollableChanged: 1;
+            bool committedScrollOffsetChanged: 1;
         };
         unsigned changeMask;
     };
@@ -105,6 +107,7 @@ struct CoordinatedGraphicsLayerState {
             bool fixedToViewport : 1;
             bool showDebugBorders : 1;
             bool showRepaintCounter : 1;
+            bool isScrollable: 1;
         };
         unsigned flags;
     };
@@ -161,6 +164,8 @@ struct CoordinatedGraphicsLayerState {
     GraphicsSurfaceToken canvasToken;
     uint32_t canvasFrontBuffer;
 #endif
+
+    IntSize committedScrollOffset;
 };
 
 struct CoordinatedGraphicsState {
index 6f2b1f6..42fa77d 100644 (file)
@@ -17,6 +17,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/UIProcess"
     "${WEBKIT2_DIR}/UIProcess/API"
     "${WEBKIT2_DIR}/UIProcess/API/C"
+    "${WEBKIT2_DIR}/UIProcess/API/CoordinatedGraphics"
     "${WEBKIT2_DIR}/UIProcess/API/cpp"
     "${WEBKIT2_DIR}/UIProcess/Authentication"
     "${WEBKIT2_DIR}/UIProcess/CoordinatedGraphics"
@@ -75,6 +76,8 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/loader/cache"
     "${WEBCORE_DIR}/page"
     "${WEBCORE_DIR}/page/animation"
+    "${WEBCORE_DIR}/page/scrolling"
+    "${WEBCORE_DIR}/page/scrolling/coordinatedgraphics"
     "${WEBCORE_DIR}/platform"
     "${WEBCORE_DIR}/platform/animation"
     "${WEBCORE_DIR}/platform/graphics"
@@ -341,6 +344,8 @@ set(WebKit2_SOURCES
     UIProcess/API/C/WKTextChecker.cpp
     UIProcess/API/C/WKVibration.cpp
 
+    UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.cpp
+
     UIProcess/Authentication/AuthenticationChallengeProxy.cpp
     UIProcess/Authentication/AuthenticationDecisionListener.cpp
     UIProcess/Authentication/WebCredential.cpp
index efe2f17..6f35dbf 100644 (file)
@@ -1,3 +1,54 @@
+2013-03-06  Luiz Agostini  <luiz.agostini@nokia.com>
+
+        Accelerated overflow scrolling for Coordinated Graphics.
+        https://bugs.webkit.org/show_bug.cgi?id=110323
+
+        Reviewed by Noam Rosenthal.
+        Signed off for WebKit2 by Simon Fraser.
+
+        A scroll offset is applied to individual layers on UI process and the
+        web process is notified assynchronously.
+        The new API WKCoordinatedScene may be used to scroll layers in the UI process.
+
+        * CMakeLists.txt:
+
+        Encoding and decoding the new members of CoordinatedGraphicsLayerState.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+        (CoreIPC::::encode):
+        (CoreIPC::::decode):
+
+        Adding acceleratedCompositingForOverflowScrollEnabled to WebPreferencesStore.
+
+        * Shared/WebPreferencesStore.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
+        New API WKCoordinatedScene is used to scroll layers on UI side.
+
+        * UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.cpp:
+        * UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.h:
+        * UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h:
+
+        A new message is used to send scroll commit messages to web process.
+
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
+        (WebKit::CoordinatedLayerTreeHostProxy::commitScrollOffset):
+        (WebKit):
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
+        (CoordinatedLayerTreeHostProxy):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost):
+        (WebKit::CoordinatedLayerTreeHost::detachLayer):
+        (WebKit::CoordinatedLayerTreeHost::createGraphicsLayer):
+        (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
+        (WebKit::CoordinatedLayerTreeHost::purgeBackingStores):
+        (WebKit::CoordinatedLayerTreeHost::commitScrollOffset):
+        (WebKit):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+        (CoordinatedLayerTreeHost):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in:
+
 2013-03-06  Huang Dongsung  <luxtella@company100.net>
 
         [EFL][WK2] Convert from device view size to UI view size only in EwkView.
index 80c7259..5aaad3d 100644 (file)
@@ -896,6 +896,9 @@ void ArgumentCoder<CoordinatedGraphicsLayerState>::encode(ArgumentEncoder& encod
         encoder << state.canvasFrontBuffer;
     }
 #endif
+
+    if (state.committedScrollOffsetChanged)
+        encoder << state.committedScrollOffset;
 }
 
 bool ArgumentCoder<CoordinatedGraphicsLayerState>::decode(ArgumentDecoder& decoder, CoordinatedGraphicsLayerState& state)
@@ -981,6 +984,9 @@ bool ArgumentCoder<CoordinatedGraphicsLayerState>::decode(ArgumentDecoder& decod
     }
 #endif
 
+    if (state.committedScrollOffsetChanged && !decoder.decode(state.committedScrollOffset))
+        return false;
+
     return true;
 }
 
index 9b9050e..daccaf3 100644 (file)
@@ -143,6 +143,7 @@ namespace WebKit {
     macro(PageVisibilityBasedProcessSuppressionEnabled, pageVisibilityBasedProcessSuppressionEnabled, Bool, bool, false) \
     macro(SmartInsertDeleteEnabled, smartInsertDeleteEnabled, Bool, bool, true) \
     macro(ShowsURLsInToolTipsEnabled, showsURLsInToolTipsEnabled, Bool, bool, false) \
+    macro(AcceleratedCompositingForOverflowScrollEnabled, acceleratedCompositingForOverflowScrollEnabled, Bool, bool, false) \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
diff --git a/Source/WebKit2/UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.cpp b/Source/WebKit2/UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.cpp
new file mode 100644 (file)
index 0000000..9a8950a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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 "WKCoordinatedScene.h"
+
+#include "WKCoordinatedSceneAPICast.h"
+
+#include <WebCore/CoordinatedGraphicsScene.h>
+#include <WebCore/TextureMapperLayer.h>
+
+WK_EXPORT WKCoordinatedSceneLayer WKCoordinatedSceneFindScrollableContentsLayerAt(WKCoordinatedScene scene, WKPoint point)
+{
+    return toAPI(toImpl(scene)->findScrollableContentsLayerAt(WebCore::FloatPoint(point.x, point.y)));
+}
+
+WK_EXPORT uint32_t WKCoordinatedSceneGetLayerID(WKCoordinatedSceneLayer layer)
+{
+    return toImpl(layer)->id();
+}
+
+WK_EXPORT void WKCoordinatedSceneScrollBy(WKCoordinatedSceneLayer layer, WKSize offset)
+{
+    toImpl(layer)->scrollBy(WebCore::FloatSize(offset.width, offset.height));
+}
diff --git a/Source/WebKit2/UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.h b/Source/WebKit2/UIProcess/API/CoordinatedGraphics/WKCoordinatedScene.h
new file mode 100644 (file)
index 0000000..c4e88dc
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ */
+
+#ifndef WKCoordinatedScene_h
+#define WKCoordinatedScene_h
+
+#include <WebKit2/WKGeometry.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+typedef struct OpaqueCGScene* WKCoordinatedScene;
+typedef struct OpaqueCGLayer* WKCoordinatedSceneLayer;
+
+WK_EXPORT WKCoordinatedSceneLayer WKCoordinatedSceneFindScrollableContentsLayerAt(WKCoordinatedScene, WKPoint);
+WK_EXPORT uint32_t WKCoordinatedSceneGetLayerID(WKCoordinatedSceneLayer);
+WK_EXPORT void WKCoordinatedSceneScrollBy(WKCoordinatedSceneLayer, WKSize);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // WKCoordinatedScene_h
index 018bd17..f7e31d3 100644 (file)
@@ -168,5 +168,10 @@ void CoordinatedLayerTreeHostProxy::setBackgroundColor(const Color& color)
     dispatchUpdate(bind(&CoordinatedGraphicsScene::setBackgroundColor, m_scene.get(), color));
 }
 
+void CoordinatedLayerTreeHostProxy::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+    m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::CommitScrollOffset(layerID, offset), m_drawingAreaProxy->page()->pageID());
+}
+
 }
 #endif // USE(COORDINATED_GRAPHICS)
index d168bcd..4486a0f 100644 (file)
@@ -87,6 +87,8 @@ public:
     virtual void renderNextFrame() OVERRIDE;
     virtual void purgeBackingStores() OVERRIDE;
 
+    virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
+
 protected:
     void dispatchUpdate(const Function<void()>&);
 
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h
new file mode 100644 (file)
index 0000000..fc9f0d6
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ */
+
+#ifndef WKCoordinatedSceneAPICast_h
+#define WKCoordinatedSceneAPICast_h
+
+#include <WebKit2/WKCoordinatedScene.h>
+
+namespace WebCore {
+
+class CoordinatedGraphicsScene;
+class TextureMapperLayer;
+
+} // namespace WebCore
+
+inline WebCore::CoordinatedGraphicsScene* toImpl(WKCoordinatedScene scene)
+{
+    return reinterpret_cast<WebCore::CoordinatedGraphicsScene*>(scene);
+}
+
+inline WKCoordinatedScene toAPI(WebCore::CoordinatedGraphicsScene* scene)
+{
+    return reinterpret_cast<WKCoordinatedScene>(scene);
+}
+
+inline WebCore::TextureMapperLayer* toImpl(WKCoordinatedSceneLayer layer)
+{
+    return reinterpret_cast<WebCore::TextureMapperLayer*>(layer);
+}
+
+inline WKCoordinatedSceneLayer toAPI(WebCore::TextureMapperLayer* layer)
+{
+    return reinterpret_cast<WKCoordinatedSceneLayer>(layer);
+}
+
+#endif // WKCoordinatedSceneAPICast_h
index 45fd395..ccf8ee0 100644 (file)
@@ -72,9 +72,9 @@ CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost()
 #endif
     purgeBackingStores();
 
-    HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end();
-    for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it)
-        (*it)->setCoordinator(0);
+    LayerMap::iterator end = m_registeredLayers.end();
+    for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
+        it->value->setCoordinator(0);
 }
 
 CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
@@ -452,7 +452,7 @@ void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms()
 
 void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer)
 {
-    m_registeredLayers.remove(layer);
+    m_registeredLayers.remove(layer->id());
     m_layersToDelete.append(layer->id());
     scheduleLayerFlush();
 }
@@ -624,7 +624,7 @@ PassOwnPtr<GraphicsLayer> CoordinatedLayerTreeHost::createGraphicsLayer(Graphics
 {
     CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
     layer->setCoordinator(this);
-    m_registeredLayers.add(layer);
+    m_registeredLayers.add(layer->id(), layer);
     m_layersToCreate.append(layer->id());
     layer->setNeedsVisibleRectAdjustment();
     scheduleLayerFlush();
@@ -682,9 +682,9 @@ void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, con
     if (contentsRectDidChange) {
         m_visibleContentsRect = rect;
 
-        HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end();
-        for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) {
-            (*it)->setNeedsVisibleRectAdjustment();
+        LayerMap::iterator end = m_registeredLayers.end();
+        for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) {
+            it->value->setNeedsVisibleRectAdjustment();
         }
     }
 
@@ -733,9 +733,9 @@ void CoordinatedLayerTreeHost::purgeBackingStores()
 {
     TemporaryChange<bool> purgingToggle(m_isPurging, true);
 
-    HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end();
-    for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it)
-        (*it)->purgeBackingStores();
+    LayerMap::iterator end = m_registeredLayers.end();
+    for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
+        it->value->purgeBackingStores();
 
     m_imageBackings.clear();
     m_updateAtlases.clear();
@@ -799,5 +799,14 @@ void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color)
     m_state.backgroundColor = color;
 }
 
+void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
+{
+    LayerMap::iterator i = m_registeredLayers.find(layerID);
+    if (i == m_registeredLayers.end())
+        return;
+
+    i->value->commitScrollOffset(offset);
+}
+
 } // namespace WebKit
 #endif // USE(COORDINATED_GRAPHICS)
index 6536ad7..a2174e2 100644 (file)
@@ -95,6 +95,8 @@ public:
 
     static PassRefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
 
+    void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
+
 protected:
     explicit CoordinatedLayerTreeHost(WebPage*);
 
@@ -172,7 +174,8 @@ private:
 
     WebCore::CoordinatedGraphicsState m_state;
 
-    HashSet<WebCore::CoordinatedGraphicsLayer*> m_registeredLayers;
+    typedef HashMap<WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayer*> LayerMap;
+    LayerMap m_registeredLayers;
     Vector<WebCore::CoordinatedLayerID> m_layersToCreate;
     Vector<WebCore::CoordinatedLayerID> m_layersToDelete;
     typedef HashMap<WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedImageBacking> > ImageBackingMap;
index 6671b32..e7321db 100644 (file)
@@ -27,5 +27,6 @@ messages -> CoordinatedLayerTreeHost LegacyReceiver {
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     AnimationFrameReady()
 #endif
+    CommitScrollOffset(uint32_t layerID, WebCore::IntSize offset)
 }
 #endif
index ed0ac10..20e8e92 100644 (file)
@@ -2324,6 +2324,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings->setEditableLinkBehavior(static_cast<WebCore::EditableLinkBehavior>(store.getUInt32ValueForKey(WebPreferencesKey::editableLinkBehaviorKey())));
     settings->setShowsToolTipOverTruncatedText(store.getBoolValueForKey(WebPreferencesKey::showsToolTipOverTruncatedTextKey()));
 
+    settings->setAcceleratedCompositingForOverflowScrollEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingForOverflowScrollEnabledKey()));
     settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey()) && LayerTreeHost::supportsAcceleratedCompositing());
     settings->setAcceleratedDrawingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedDrawingEnabledKey()) && LayerTreeHost::supportsAcceleratedCompositing());
     settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey()) && LayerTreeHost::supportsAcceleratedCompositing());