Title: [88799] trunk/Source/WebKit2
Revision
88799
Author
[email protected]
Date
2011-06-14 07:07:55 -0700 (Tue, 14 Jun 2011)

Log Message

2011-06-14  No'am Rosenthal  <[email protected]> and Viatcheslav Ostapenko <[email protected]>

        Reviewed by Kenneth Rohde Christiansen.

        [Qt] Implement accelerated compositing on WK2 Qt port
        https://bugs.webkit.org/show_bug.cgi?id=56935

        Implementing LayerTreeHost and LayerTreeContext and LayerTreeHost for Qt.
        Add the necessary plumbing to make the LayerTreeHost work with Qt, based on the original Mac
        implementation (the code is nearly identical). This includes creating the right layers for the
        overlay and for the non-composited content, and passing the root layer to the UI process.

        Also, since LayerTreeHostQt is compiled, we have to add some of the rest of the existing patches,
        namely the new messages: syncCompositingLayers and updateCompositingLayerContent, and create a
        stub implementation for them in DrawingAreaProxy.

        Note that this is not activated yet, until we enable accelerated compositing in the settings and
        create the right GraphicsLayer.

        * Scripts/webkit2/messages.py:
        * Shared/LayerTreeContext.h:
        * Shared/qt/LayerTreeContextQt.cpp:
        (WebKit::LayerTreeContext::LayerTreeContext):
        (WebKit::LayerTreeContext::~LayerTreeContext):
        (WebKit::LayerTreeContext::encode):
        (WebKit::LayerTreeContext::decode):
        (WebKit::LayerTreeContext::isEmpty):
        (WebKit::operator==):
        * UIProcess/DrawingAreaProxy.h:
        (WebKit::DrawingAreaProxy::syncCompositingLayers):
        (WebKit::DrawingAreaProxy::updateCompositingLayerContent):
        * UIProcess/DrawingAreaProxy.messages.in:
        * WebKit2.pro:
        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
        (WebCore::collectCompositingInfoForThisLayer):
        * WebProcess/WebPage/LayerTreeHost.cpp:
        (WebKit::LayerTreeHost::create):
        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
        (WebKit::LayerTreeHostQt::create):
        (WebKit::LayerTreeHostQt::~LayerTreeHostQt):
        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
        (WebKit::LayerTreeHostQt::setLayerFlushSchedulingEnabled):
        (WebKit::LayerTreeHostQt::scheduleLayerFlush):
        (WebKit::LayerTreeHostQt::cancelPendingLayerFlush):
        (WebKit::LayerTreeHostQt::setShouldNotifyAfterNextScheduledLayerFlush):
        (WebKit::LayerTreeHostQt::setRootCompositingLayer):
        (WebKit::LayerTreeHostQt::invalidate):
        (WebKit::LayerTreeHostQt::setNonCompositedContentsNeedDisplay):
        (WebKit::LayerTreeHostQt::scrollNonCompositedContents):
        (WebKit::LayerTreeHostQt::forceRepaint):
        (WebKit::LayerTreeHostQt::sizeDidChange):
        (WebKit::LayerTreeHostQt::didInstallPageOverlay):
        (WebKit::LayerTreeHostQt::didUninstallPageOverlay):
        (WebKit::LayerTreeHostQt::setPageOverlayNeedsDisplay):
        (WebKit::LayerTreeHostQt::flushPendingLayerChanges):
        (WebKit::LayerTreeHostQt::performScheduledLayerFlush):
        (WebKit::LayerTreeHostQt::layerFlushTimerFired):
        (WebKit::LayerTreeHostQt::createPageOverlayLayer):
        (WebKit::LayerTreeHostQt::destroyPageOverlayLayer):
        (WebKit::LayerTreeHostQt::notifyAnimationStarted):
        (WebKit::LayerTreeHostQt::notifySyncRequired):
        (WebKit::LayerTreeHostQt::paintContents):
        (WebKit::LayerTreeHostQt::showDebugBorders):
        (WebKit::LayerTreeHostQt::showRepaintCounter):
        (WebKit::LayerTreeHost::supportsAcceleratedCompositing):
        * WebProcess/WebPage/qt/LayerTreeHostQt.h: Added.
        (WebKit::LayerTreeHostQt::layerTreeContext):
        (WebKit::LayerTreeHostQt::pauseRendering):
        (WebKit::LayerTreeHostQt::resumeRendering):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (88798 => 88799)


--- trunk/Source/WebKit2/ChangeLog	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-14 14:07:55 UTC (rev 88799)
@@ -1,3 +1,73 @@
+2011-06-14  No'am Rosenthal  <[email protected]> and Viatcheslav Ostapenko <[email protected]>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Implement accelerated compositing on WK2 Qt port
+        https://bugs.webkit.org/show_bug.cgi?id=56935
+
+        Implementing LayerTreeHost and LayerTreeContext and LayerTreeHost for Qt.
+        Add the necessary plumbing to make the LayerTreeHost work with Qt, based on the original Mac
+        implementation (the code is nearly identical). This includes creating the right layers for the
+        overlay and for the non-composited content, and passing the root layer to the UI process.
+
+        Also, since LayerTreeHostQt is compiled, we have to add some of the rest of the existing patches,
+        namely the new messages: syncCompositingLayers and updateCompositingLayerContent, and create a
+        stub implementation for them in DrawingAreaProxy.
+
+        Note that this is not activated yet, until we enable accelerated compositing in the settings and
+        create the right GraphicsLayer.
+
+        * Scripts/webkit2/messages.py:
+        * Shared/LayerTreeContext.h:
+        * Shared/qt/LayerTreeContextQt.cpp:
+        (WebKit::LayerTreeContext::LayerTreeContext):
+        (WebKit::LayerTreeContext::~LayerTreeContext):
+        (WebKit::LayerTreeContext::encode):
+        (WebKit::LayerTreeContext::decode):
+        (WebKit::LayerTreeContext::isEmpty):
+        (WebKit::operator==):
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::syncCompositingLayers):
+        (WebKit::DrawingAreaProxy::updateCompositingLayerContent):
+        * UIProcess/DrawingAreaProxy.messages.in:
+        * WebKit2.pro:
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+        (WebCore::collectCompositingInfoForThisLayer):
+        * WebProcess/WebPage/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::create):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+        (WebKit::LayerTreeHostQt::create):
+        (WebKit::LayerTreeHostQt::~LayerTreeHostQt):
+        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
+        (WebKit::LayerTreeHostQt::setLayerFlushSchedulingEnabled):
+        (WebKit::LayerTreeHostQt::scheduleLayerFlush):
+        (WebKit::LayerTreeHostQt::cancelPendingLayerFlush):
+        (WebKit::LayerTreeHostQt::setShouldNotifyAfterNextScheduledLayerFlush):
+        (WebKit::LayerTreeHostQt::setRootCompositingLayer):
+        (WebKit::LayerTreeHostQt::invalidate):
+        (WebKit::LayerTreeHostQt::setNonCompositedContentsNeedDisplay):
+        (WebKit::LayerTreeHostQt::scrollNonCompositedContents):
+        (WebKit::LayerTreeHostQt::forceRepaint):
+        (WebKit::LayerTreeHostQt::sizeDidChange):
+        (WebKit::LayerTreeHostQt::didInstallPageOverlay):
+        (WebKit::LayerTreeHostQt::didUninstallPageOverlay):
+        (WebKit::LayerTreeHostQt::setPageOverlayNeedsDisplay):
+        (WebKit::LayerTreeHostQt::flushPendingLayerChanges):
+        (WebKit::LayerTreeHostQt::performScheduledLayerFlush):
+        (WebKit::LayerTreeHostQt::layerFlushTimerFired):
+        (WebKit::LayerTreeHostQt::createPageOverlayLayer):
+        (WebKit::LayerTreeHostQt::destroyPageOverlayLayer):
+        (WebKit::LayerTreeHostQt::notifyAnimationStarted):
+        (WebKit::LayerTreeHostQt::notifySyncRequired):
+        (WebKit::LayerTreeHostQt::paintContents):
+        (WebKit::LayerTreeHostQt::showDebugBorders):
+        (WebKit::LayerTreeHostQt::showRepaintCounter):
+        (WebKit::LayerTreeHost::supportsAcceleratedCompositing):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.h: Added.
+        (WebKit::LayerTreeHostQt::layerTreeContext):
+        (WebKit::LayerTreeHostQt::pauseRendering):
+        (WebKit::LayerTreeHostQt::resumeRendering):
+
 2011-06-14  Noam Rosenthal  <[email protected]>
 
         Reviewed by Kenneth Rohde Christiansen.

Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (88798 => 88799)


--- trunk/Source/WebKit2/Scripts/webkit2/messages.py	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py	2011-06-14 14:07:55 UTC (rev 88799)
@@ -464,6 +464,7 @@
         'WebCore::TextCheckingResult': '<WebCore/TextCheckerClient.h>',
         'WebKit::WebGestureEvent': '"WebEvent.h"',
         'WebKit::WebKeyboardEvent': '"WebEvent.h"',
+        'WebKit::WebLayerUpdateInfo': '"WebLayerTreeInfo.h"',
         'WebKit::WebMouseEvent': '"WebEvent.h"',
         'WebKit::WebTouchEvent': '"WebEvent.h"',
         'WebKit::WebWheelEvent': '"WebEvent.h"',

Modified: trunk/Source/WebKit2/Shared/LayerTreeContext.h (88798 => 88799)


--- trunk/Source/WebKit2/Shared/LayerTreeContext.h	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/Shared/LayerTreeContext.h	2011-06-14 14:07:55 UTC (rev 88799)
@@ -47,6 +47,8 @@
     uint32_t contextID;
 #elif PLATFORM(WIN)
     HWND window;
+#elif PLATFORM(QT)
+    uint32_t webLayerID;
 #endif
 };
 

Modified: trunk/Source/WebKit2/Shared/qt/LayerTreeContextQt.cpp (88798 => 88799)


--- trunk/Source/WebKit2/Shared/qt/LayerTreeContextQt.cpp	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/Shared/qt/LayerTreeContextQt.cpp	2011-06-14 14:07:55 UTC (rev 88799)
@@ -26,41 +26,38 @@
 #include "config.h"
 #include "LayerTreeContext.h"
 
-#include "NotImplemented.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
 
 namespace WebKit {
 
 LayerTreeContext::LayerTreeContext()
+    : webLayerID(0)
 {
-    notImplemented();
 }
 
 LayerTreeContext::~LayerTreeContext()
 {
-    notImplemented();
 }
 
-void LayerTreeContext::encode(CoreIPC::ArgumentEncoder*) const
+void LayerTreeContext::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    notImplemented();
+    encoder->encode(webLayerID);
 }
 
-bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder*, LayerTreeContext&)
+bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder* decoder, LayerTreeContext& context)
 {
-    notImplemented();
-    return true;
+    return decoder->decode(context.webLayerID);
 }
 
 bool LayerTreeContext::isEmpty() const
 {
-    notImplemented();
-    return true;
+    return !webLayerID;
 }
 
-bool operator==(const LayerTreeContext&, const LayerTreeContext&)
+bool operator==(const LayerTreeContext& a, const LayerTreeContext& b)
 {
-    notImplemented();
-    return true;
+    return a.webLayerID == b.webLayerID;
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (88798 => 88799)


--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h	2011-06-14 14:07:55 UTC (rev 88799)
@@ -52,6 +52,8 @@
 
 class LayerTreeContext;
 class UpdateInfo;
+class WebLayerTreeInfo;
+class WebLayerUpdateInfo;
 class WebPageProxy;
 
 #if PLATFORM(MAC)
@@ -107,7 +109,11 @@
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) { }
     virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) { }
+#if USE(TEXTURE_MAPPER)
+    virtual void syncCompositingLayers(const WebLayerTreeInfo&) { }
+    virtual void updateCompositingLayerContent(const WebLayerUpdateInfo&) { }
 #endif
+#endif
 #if ENABLE(TILED_BACKING_STORE)
     virtual void didSetSize(const WebCore::IntSize&) { }
     virtual void invalidate(const WebCore::IntRect&) { }

Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in (88798 => 88799)


--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in	2011-06-14 14:07:55 UTC (rev 88799)
@@ -27,6 +27,10 @@
     EnterAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
     ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
 #endif
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+    SyncCompositingLayers(WebKit::WebLayerTreeInfo layerTreeInfo)
+    UpdateCompositingLayerContent(WebKit::WebLayerUpdateInfo layerUpdateInfo)
+#endif
 #if ENABLE(TILED_BACKING_STORE)
     Invalidate(WebCore::IntRect dirtyRect)
     DidSetSize(WebCore::IntSize viewSize)

Modified: trunk/Source/WebKit2/WebKit2.pro (88798 => 88799)


--- trunk/Source/WebKit2/WebKit2.pro	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/WebKit2.pro	2011-06-14 14:07:55 UTC (rev 88799)
@@ -149,6 +149,7 @@
     Shared/WebGeolocationPosition.h \
     Shared/WebGraphicsContext.h \
     Shared/WebImage.h \
+    Shared/WebLayerTreeInfo.h \
     Shared/WebNavigationDataStore.h \
     Shared/WebNumber.h \
     Shared/WebOpenPanelParameters.h \
@@ -279,6 +280,7 @@
     WebProcess/WebCoreSupport/WebErrors.h \
     WebProcess/WebCoreSupport/WebFrameLoaderClient.h \
     WebProcess/WebCoreSupport/WebGeolocationClient.h \
+    WebProcess/WebCoreSupport/WebGraphicsLayer.h \
     WebProcess/WebCoreSupport/WebInspectorClient.h \
     WebProcess/WebCoreSupport/WebInspectorFrontendClient.h \
     WebProcess/WebCoreSupport/WebPlatformStrategies.h \
@@ -357,6 +359,7 @@
     Shared/WebGraphicsContext.cpp \
     Shared/WebKeyboardEvent.cpp \
     Shared/WebImage.cpp \
+    Shared/WebLayerTreeInfo.cpp \
     Shared/WebMouseEvent.cpp \
     Shared/WebOpenPanelParameters.cpp \
     Shared/WebPageCreationParameters.cpp \
@@ -504,6 +507,7 @@
     WebProcess/WebCoreSupport/WebEditorClient.cpp \
     WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp \
     WebProcess/WebCoreSupport/WebGeolocationClient.cpp \
+    WebProcess/WebCoreSupport/WebGraphicsLayer.cpp \
     WebProcess/WebCoreSupport/WebInspectorClient.cpp \
     WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp \
     WebProcess/WebCoreSupport/WebPlatformStrategies.cpp \

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp (88798 => 88799)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2011-06-14 14:07:55 UTC (rev 88799)
@@ -405,9 +405,9 @@
     return tiles;
 }
 
-static void collectCompositingInfoForThisLayer(GraphicsLayer* layer, WebLayerTreeInfo& outInfo, Vector<WebGraphicsLayer*>& outLayers)
+static void collectCompositingInfoForThisLayer(GraphicsLayer* graphicsLayer, WebLayerTreeInfo& outInfo, Vector<WebGraphicsLayer*>& outLayers)
 {
-    WebGraphicsLayer* layer = toWebGraphicsLayer(layer);
+    WebGraphicsLayer* layer = toWebGraphicsLayer(graphicsLayer);
     if (!layer)
         return;
     if (!layer->isModified())

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp (88798 => 88799)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp	2011-06-14 14:07:55 UTC (rev 88799)
@@ -34,6 +34,10 @@
 #endif
 #endif
 
+#if PLATFORM(QT) && USE(TEXTURE_MAPPER)
+#include "qt/LayerTreeHostQt.h"
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -44,6 +48,8 @@
     return LayerTreeHostCAMac::create(webPage);
 #elif PLATFORM(WIN) && HAVE(WKQCA)
     return LayerTreeHostCAWin::create(webPage);
+#elif PLATFORM(QT) && USE(TEXTURE_MAPPER)
+    return LayerTreeHostQt::create(webPage);
 #else
     return 0;
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (88798 => 88799)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2011-06-14 13:58:11 UTC (rev 88798)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2011-06-14 14:07:55 UTC (rev 88799)
@@ -25,8 +25,277 @@
  */
 
 #include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerTreeHostQt.h"
+
+#include "DrawingAreaImpl.h"
+#include "DrawingAreaMessages.h"
+#include "DrawingAreaProxyMessages.h"
+#include "GraphicsContext.h"
+#include "MessageID.h"
+#include "WebGraphicsLayer.h"
+#include "WebPage.h"
+#include <WebCore/Frame.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/Page.h>
+#include <WebCore/Settings.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<LayerTreeHostQt> LayerTreeHostQt::create(WebPage* webPage)
+{
+    return adoptRef(new LayerTreeHostQt(webPage));
+}
+
+LayerTreeHostQt::~LayerTreeHostQt()
+{
+}
+
+LayerTreeHostQt::LayerTreeHostQt(WebPage* webPage)
+    : LayerTreeHost(webPage)
+    , m_notifyAfterScheduledLayerFlush(false)
+    , m_isValid(true)
+    , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
+    , m_layerFlushSchedulingEnabled(true)
+{
+    // Create a root layer.
+    m_rootLayer = GraphicsLayer::create(this);
+#ifndef NDEBUG
+    m_rootLayer->setName("LayerTreeHostQt root layer");
+#endif
+    m_rootLayer->setDrawsContent(false);
+    m_rootLayer->setSize(m_webPage->size());
+    m_layerTreeContext.webLayerID = toWebGraphicsLayer(m_rootLayer.get())->id();
+
+    m_nonCompositedContentLayer = GraphicsLayer::create(this);
+#ifndef NDEBUG
+    m_nonCompositedContentLayer->setName("LayerTreeHostQt non-composited content");
+#endif
+    m_nonCompositedContentLayer->setDrawsContent(true);
+    m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
+    m_nonCompositedContentLayer->setSize(m_webPage->size());
+
+    m_rootLayer->addChild(m_nonCompositedContentLayer.get());
+
+    if (m_webPage->hasPageOverlay())
+        createPageOverlayLayer();
+
+    scheduleLayerFlush();
+}
+
+void LayerTreeHostQt::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
+{
+    if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
+        return;
+
+    m_layerFlushSchedulingEnabled = layerFlushingEnabled;
+
+    if (m_layerFlushSchedulingEnabled)
+        return;
+
+    cancelPendingLayerFlush();
+}
+
+void LayerTreeHostQt::scheduleLayerFlush()
+{
+    if (!m_layerFlushSchedulingEnabled)
+        return;
+
+    if (!m_layerFlushTimer.isActive())
+        m_layerFlushTimer.startOneShot(0);
+}
+
+void LayerTreeHostQt::cancelPendingLayerFlush()
+{
+    m_layerFlushTimer.stop();
+}
+
+void LayerTreeHostQt::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)
+{
+    m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;
+}
+
+void LayerTreeHostQt::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
+{
+    m_nonCompositedContentLayer->removeAllChildren();
+
+    // Add the accelerated layer tree hierarchy.
+    if (graphicsLayer)
+        m_nonCompositedContentLayer->addChild(graphicsLayer);
+}
+
+void LayerTreeHostQt::invalidate()
+{
+    cancelPendingLayerFlush();
+
+    ASSERT(m_isValid);
+    m_rootLayer = nullptr;
+    m_isValid = false;
+}
+
+void LayerTreeHostQt::setNonCompositedContentsNeedDisplay(const WebCore::IntRect& rect)
+{
+    m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
+    if (m_pageOverlayLayer)
+        m_pageOverlayLayer->setNeedsDisplayInRect(rect);
+
+    scheduleLayerFlush();
+}
+
+void LayerTreeHostQt::scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
+{
+    setNonCompositedContentsNeedDisplay(scrollRect);
+}
+
+void LayerTreeHostQt::forceRepaint()
+{
+    scheduleLayerFlush();
+}
+
+void LayerTreeHostQt::sizeDidChange(const WebCore::IntSize& newSize)
+{
+    m_rootLayer->setSize(newSize);
+
+    // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
+    // for those newly exposed areas.
+    FloatSize oldSize = m_nonCompositedContentLayer->size();
+    m_nonCompositedContentLayer->setSize(newSize);
+
+    if (newSize.width() > oldSize.width()) {
+        float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
+        m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
+    }
+
+    if (newSize.height() > oldSize.height())
+        m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
+
+    if (m_pageOverlayLayer)
+        m_pageOverlayLayer->setSize(newSize);
+
+    scheduleLayerFlush();
+}
+
+void LayerTreeHostQt::didInstallPageOverlay()
+{
+    createPageOverlayLayer();
+    scheduleLayerFlush();
+
+}
+
+void LayerTreeHostQt::didUninstallPageOverlay()
+{
+    destroyPageOverlayLayer();
+    scheduleLayerFlush();
+}
+
+void LayerTreeHostQt::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect)
+{
+    ASSERT(m_pageOverlayLayer);
+    m_pageOverlayLayer->setNeedsDisplayInRect(rect);
+    scheduleLayerFlush();
+}
+
+bool LayerTreeHostQt::flushPendingLayerChanges()
+{
+    m_rootLayer->syncCompositingStateForThisLayerOnly();
+    m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly();
+    if (m_pageOverlayLayer)
+        m_pageOverlayLayer->syncCompositingStateForThisLayerOnly();
+
+    return m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
+}
+
+
+void LayerTreeHostQt::performScheduledLayerFlush()
+{
+    m_webPage->layoutIfNeeded();
+
+    if (!m_isValid)
+        return;
+
+    if (flushPendingLayerChanges()) {
+        if (m_notifyAfterScheduledLayerFlush) {
+            // Let the drawing area know that we've done a flush of the layer changes.
+            static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
+            m_notifyAfterScheduledLayerFlush = false;
+        }
+        WebGraphicsLayer::sendLayersToUIProcess(m_rootLayer.get(), m_webPage);
+    }
+}
+
+void LayerTreeHostQt::layerFlushTimerFired(Timer<LayerTreeHostQt>*)
+{
+    performScheduledLayerFlush();
+}
+
+void LayerTreeHostQt::createPageOverlayLayer()
+{
+    ASSERT(!m_pageOverlayLayer);
+
+    m_pageOverlayLayer = GraphicsLayer::create(this);
+#ifndef NDEBUG
+    m_pageOverlayLayer->setName("LayerTreeHostQt page overlay content");
+#endif
+
+    m_pageOverlayLayer->setDrawsContent(true);
+    m_pageOverlayLayer->setSize(m_webPage->size());
+
+    m_rootLayer->addChild(m_pageOverlayLayer.get());
+}
+
+void LayerTreeHostQt::destroyPageOverlayLayer()
+{
+    ASSERT(m_pageOverlayLayer);
+    m_pageOverlayLayer->removeFromParent();
+    m_pageOverlayLayer = nullptr;
+}
+
+void LayerTreeHostQt::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time)
+{
+}
+
+void LayerTreeHostQt::notifySyncRequired(const WebCore::GraphicsLayer*)
+{
+}
+
+void LayerTreeHostQt::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
+{
+    if (graphicsLayer == m_nonCompositedContentLayer) {
+        m_webPage->drawRect(graphicsContext, clipRect);
+        return;
+    }
+
+    if (graphicsLayer == m_pageOverlayLayer) {
+        m_webPage->drawPageOverlay(graphicsContext, clipRect);
+        return;
+    }
+}
+
+bool LayerTreeHostQt::showDebugBorders() const
+{
+    return m_webPage->corePage()->settings()->showDebugBorders();
+}
+
+bool LayerTreeHostQt::showRepaintCounter() const
+{
+    return m_webPage->corePage()->settings()->showRepaintCounter();
+}
+
+bool LayerTreeHost::supportsAcceleratedCompositing()
+{
+    return true;
+}
+
+} // namespace WebKit
+#else
 #include "LayerTreeHost.h"
 
+using namespace WebCore;
+
 namespace WebKit {
 
 bool LayerTreeHost::supportsAcceleratedCompositing()
@@ -35,3 +304,4 @@
 }
 
 } // namespace WebKit
+#endif

Added: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h (0 => 88799)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h	2011-06-14 14:07:55 UTC (rev 88799)
@@ -0,0 +1,97 @@
+/*
+    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef LayerTreeHostQt_h
+#define LayerTreeHostQt_h
+
+#include "LayerTreeContext.h"
+#include "LayerTreeHost.h"
+#include "Timer.h"
+#include <WebCore/GraphicsLayerClient.h>
+#include <wtf/OwnPtr.h>
+
+namespace WebKit {
+
+class UpdateInfo;
+class WebPage;
+
+class LayerTreeHostQt : public LayerTreeHost, WebCore::GraphicsLayerClient {
+public:
+    static PassRefPtr<LayerTreeHostQt> create(WebPage*);
+    virtual ~LayerTreeHostQt();
+
+    static bool supportsAcceleratedCompositing();
+
+    virtual const LayerTreeContext& layerTreeContext() { return m_layerTreeContext; }
+    virtual void setLayerFlushSchedulingEnabled(bool);
+    virtual void scheduleLayerFlush();
+    virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool);
+    virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
+    virtual void invalidate();
+
+    virtual void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&);
+    virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+    virtual void forceRepaint();
+    virtual void sizeDidChange(const WebCore::IntSize& newSize);
+
+    virtual void didInstallPageOverlay();
+    virtual void didUninstallPageOverlay();
+    virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&);
+
+    virtual void pauseRendering() { }
+    virtual void resumeRendering() { }
+
+protected:
+    explicit LayerTreeHostQt(WebPage*);
+
+private:
+    // GraphicsLayerClient
+    virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time);
+    virtual void notifySyncRequired(const WebCore::GraphicsLayer*);
+    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect);
+    virtual bool showDebugBorders() const;
+    virtual bool showRepaintCounter() const;
+
+    // LayerTreeHostQt
+    void createPageOverlayLayer();
+    void destroyPageOverlayLayer();
+    bool flushPendingLayerChanges();
+    void cancelPendingLayerFlush();
+    void performScheduledLayerFlush();
+    void sendLayersToUI();
+
+    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
+
+    // The layer which contains all non-composited content.
+    OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
+
+    // The page overlay layer. Will be null if there's no page overlay.
+    OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
+
+    bool m_notifyAfterScheduledLayerFlush;
+    bool m_isValid;
+    LayerTreeContext m_layerTreeContext;
+    void layerFlushTimerFired(WebCore::Timer<LayerTreeHostQt>*);
+    WebCore::Timer<LayerTreeHostQt> m_layerFlushTimer;
+    bool m_layerFlushSchedulingEnabled;
+};
+
+}
+
+#endif // LayerTreeHostQt_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to