Make accelerated compositing work in WebKit2 on Windows
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2011 18:01:52 +0000 (18:01 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2011 18:01:52 +0000 (18:01 +0000)
LayerTreeHostCAWin uses WKCACFView to render each frame to an image, then has
DrawingAreaImpl send that image over to the UI process (just like it does for
non-accelerated rendering). It's unfortunate that this requires reading every frame back
from the GPU into system memory. More efficient solutions can be explored in the future.

Fixes <http://webkit.org/b/45567>.

Reviewed by Anders Carlsson.

* DerivedSources.make: Added $(WebKit2) to the VPATH so that DerivedSources.make can be
found when used as a target dependency. Added rules to generate a HeaderDetection.h file on
Windows. If we can find WebKitQuartzCoreAdditions headers, we define HAVE_WKQCA in
HeaderDetection.h.

* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::setLayerHostNeedsDisplay):
* WebProcess/WebPage/DrawingAreaImpl.h:
Added setLayerHostNeedsDisplay. Lets the layer host tell the DrawingAreaImpl that it has a
new frame to render. This should only be called by layer hosts that participate in
DrawingAreaImpl's display mechanism.

* WebProcess/WebPage/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::create): Only try to instantiate LayerTreeHostCAWin if we have
WebKitQuartzCoreAdditions, since it depends on that library.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Removed code that forced accelerated compositing to be
disabled on Windows.

* WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp:
(WebKit::registerDummyWindowClass): Registers the window class we use for the dummy window.
(WebKit::createDummyWindow): Creates the dummy window we pass to WKCACFView so that D3D can
determine the display mode, etc. (The window is never shown on screen.)
(WebKit::LayerTreeHostCAWin::LayerTreeHostCAWin): Initialize new members.
(WebKit::LayerTreeHostCAWin::platformInitialize): Create our dummy window and view and
associate the two. We set ourselves as the view's context's user data so that
PlatformCALayer can get our AbstractCACFLayerTreeHost pointer as needed.
(WebKit::LayerTreeHostCAWin::invalidate): Cancel any pending flushes, tear down our view,
and destroy the dummy window if no other layer host is using it.
(WebKit::LayerTreeHostCAWin::scheduleLayerFlush): Ask LayerChangesFlusher to call us back
soon to perform the flush.
(WebKit::LayerTreeHostCAWin::participatesInDisplay): Added. Returns true, since we render
each frame to an image.
(WebKit::LayerTreeHostCAWin::needsDisplay): Added. Returns true if it's now time to
displayReturns true if it's now time to display.
(WebKit::LayerTreeHostCAWin::timeUntilNextDisplay): Added. Returns how many seconds remain
before we need to display again.
(WebKit::size): Added. Helper function to get the size of a WKCACFImage.
(WebKit::toShareableBitmap): Added. Helper function to convert a WKCACFImage to a
ShareableBitmap.
(WebKit::LayerTreeHostCAWin::display): Added. Renders the next frame to an image and stuffs
the image into the UpdateInfo struct.
(WebKit::LayerTreeHostCAWin::sizeDidChange): Added. Tells the view about the new size.
(WebKit::LayerTreeHostCAWin::forceRepaint): Added. Flushes any pending changes to the view.
(WebKit::LayerTreeHostCAWin::contextDidChangeCallback): Added. WKCACFView calls this
whenever any changes made to the view or its layer tree have been flushed. Just calls
through to contextDidChange.
(WebKit::LayerTreeHostCAWin::contextDidChange): Added. Tells layers that they've started
animating, and tells the DrawingAreaImpl that we need to display again.
(WebKit::LayerTreeHostCAWin::rootLayer): Added. Gets the root layer's PlatformCALayer.
(WebKit::LayerTreeHostCAWin::addPendingAnimatedLayer): Added. Stores the layer so that we
can tell it animations have started the next time we get a contextDidChange callback.
(WebKit::LayerTreeHostCAWin::layerTreeDidChange): Added. Schedules a flush, unless we're
already in the process of flushing. This code came from WebCore::WKCACFViewLayerTreeHost.
(WebKit::LayerTreeHostCAWin::flushPendingLayerChangesNow): Added. Performs the flush. This
code was adapted from WebCore::WKCACFViewLayerTreeHost.

* WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h: Wrapped this whole header in HAVE(WKQCA),
since this class only works when WebKitQuartzCoreAdditions is available. Added a bunch of
new members.

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

Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.make
Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp
Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h

index 12eb0f1..29bf95f 100644 (file)
@@ -1,3 +1,78 @@
+2011-04-05  Adam Roben  <aroben@apple.com>
+
+        Make accelerated compositing work in WebKit2 on Windows
+
+        LayerTreeHostCAWin uses WKCACFView to render each frame to an image, then has
+        DrawingAreaImpl send that image over to the UI process (just like it does for
+        non-accelerated rendering). It's unfortunate that this requires reading every frame back
+        from the GPU into system memory. More efficient solutions can be explored in the future.
+
+        Fixes <http://webkit.org/b/45567>.
+
+        Reviewed by Anders Carlsson.
+
+        * DerivedSources.make: Added $(WebKit2) to the VPATH so that DerivedSources.make can be
+        found when used as a target dependency. Added rules to generate a HeaderDetection.h file on
+        Windows. If we can find WebKitQuartzCoreAdditions headers, we define HAVE_WKQCA in
+        HeaderDetection.h.
+
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::setLayerHostNeedsDisplay):
+        * WebProcess/WebPage/DrawingAreaImpl.h:
+        Added setLayerHostNeedsDisplay. Lets the layer host tell the DrawingAreaImpl that it has a
+        new frame to render. This should only be called by layer hosts that participate in
+        DrawingAreaImpl's display mechanism.
+
+        * WebProcess/WebPage/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::create): Only try to instantiate LayerTreeHostCAWin if we have
+        WebKitQuartzCoreAdditions, since it depends on that library.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences): Removed code that forced accelerated compositing to be
+        disabled on Windows.
+
+        * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp:
+        (WebKit::registerDummyWindowClass): Registers the window class we use for the dummy window.
+        (WebKit::createDummyWindow): Creates the dummy window we pass to WKCACFView so that D3D can
+        determine the display mode, etc. (The window is never shown on screen.)
+        (WebKit::LayerTreeHostCAWin::LayerTreeHostCAWin): Initialize new members.
+        (WebKit::LayerTreeHostCAWin::platformInitialize): Create our dummy window and view and
+        associate the two. We set ourselves as the view's context's user data so that
+        PlatformCALayer can get our AbstractCACFLayerTreeHost pointer as needed.
+        (WebKit::LayerTreeHostCAWin::invalidate): Cancel any pending flushes, tear down our view,
+        and destroy the dummy window if no other layer host is using it.
+        (WebKit::LayerTreeHostCAWin::scheduleLayerFlush): Ask LayerChangesFlusher to call us back
+        soon to perform the flush.
+        (WebKit::LayerTreeHostCAWin::participatesInDisplay): Added. Returns true, since we render
+        each frame to an image.
+        (WebKit::LayerTreeHostCAWin::needsDisplay): Added. Returns true if it's now time to
+        displayReturns true if it's now time to display.
+        (WebKit::LayerTreeHostCAWin::timeUntilNextDisplay): Added. Returns how many seconds remain
+        before we need to display again.
+        (WebKit::size): Added. Helper function to get the size of a WKCACFImage.
+        (WebKit::toShareableBitmap): Added. Helper function to convert a WKCACFImage to a
+        ShareableBitmap.
+        (WebKit::LayerTreeHostCAWin::display): Added. Renders the next frame to an image and stuffs
+        the image into the UpdateInfo struct.
+        (WebKit::LayerTreeHostCAWin::sizeDidChange): Added. Tells the view about the new size.
+        (WebKit::LayerTreeHostCAWin::forceRepaint): Added. Flushes any pending changes to the view.
+        (WebKit::LayerTreeHostCAWin::contextDidChangeCallback): Added. WKCACFView calls this
+        whenever any changes made to the view or its layer tree have been flushed. Just calls
+        through to contextDidChange.
+        (WebKit::LayerTreeHostCAWin::contextDidChange): Added. Tells layers that they've started
+        animating, and tells the DrawingAreaImpl that we need to display again.
+        (WebKit::LayerTreeHostCAWin::rootLayer): Added. Gets the root layer's PlatformCALayer.
+        (WebKit::LayerTreeHostCAWin::addPendingAnimatedLayer): Added. Stores the layer so that we
+        can tell it animations have started the next time we get a contextDidChange callback.
+        (WebKit::LayerTreeHostCAWin::layerTreeDidChange): Added. Schedules a flush, unless we're
+        already in the process of flushing. This code came from WebCore::WKCACFViewLayerTreeHost.
+        (WebKit::LayerTreeHostCAWin::flushPendingLayerChangesNow): Added. Performs the flush. This
+        code was adapted from WebCore::WKCACFViewLayerTreeHost.
+
+        * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h: Wrapped this whole header in HAVE(WKQCA),
+        since this class only works when WebKitQuartzCoreAdditions is available. Added a bunch of
+        new members.
+
 2011-04-04  Adam Roben  <aroben@apple.com>
 
         Add a way for LayerTreeHost to participate in DrawingAreaImpl's normal display mechanism
index 6f30dd4..865050c 100644 (file)
@@ -21,6 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 VPATH = \
+    $(WebKit2) \
     $(WebKit2)/PluginProcess \
     $(WebKit2)/Shared/Plugins \
     $(WebKit2)/WebProcess/ApplicationCache \
@@ -100,3 +101,16 @@ all : \
 %Messages.h : %.messages.in $(SCRIPTS)
        @echo Generating message receiver for $*...
        @python $(WebKit2)/Scripts/generate-messages-header.py $< > $@
+
+# ------------------------
+
+# Windows-specific rules
+
+ifeq ($(OS),Windows_NT)
+
+all : HeaderDetection.h
+
+HeaderDetection.h : DerivedSources.make
+       if [ -f "$(WEBKITLIBRARIESDIR)/include/WebKitQuartzCoreAdditions/WebKitQuartzCoreAdditionsBase.h" ]; then echo "#define HAVE_WKQCA 1" > $@; else echo > $@; fi
+
+endif # Windows_NT
index cfd63f4..38a8ec3 100644 (file)
@@ -192,6 +192,13 @@ void DrawingAreaImpl::setPageOverlayNeedsDisplay(const IntRect& rect)
     setNeedsDisplay(rect);
 }
 
+void DrawingAreaImpl::setLayerHostNeedsDisplay()
+{
+    ASSERT(m_layerTreeHost);
+    ASSERT(m_layerTreeHost->participatesInDisplay());
+    scheduleDisplay();
+}
+
 void DrawingAreaImpl::layerHostDidFlushLayers()
 {
     ASSERT(m_layerTreeHost);
index 9e93869..471ba56 100644 (file)
@@ -40,6 +40,7 @@ public:
     static PassOwnPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&);
     virtual ~DrawingAreaImpl();
 
+    void setLayerHostNeedsDisplay();
     void layerHostDidFlushLayers();
 
 private:
index 5c688e3..b820637 100644 (file)
@@ -44,12 +44,10 @@ namespace WebKit {
 
 PassRefPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage)
 {
-#if PLATFORM(CA)
 #if PLATFORM(MAC)
     return LayerTreeHostCAMac::create(webPage);
-#elif PLATFORM(WIN)
+#elif PLATFORM(WIN) && HAVE(WKQCA)
     return LayerTreeHostCAWin::create(webPage);
-#endif
 #else
     return 0;
 #endif
index 3e15d8d..99cefaa 100644 (file)
@@ -1411,16 +1411,9 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey()));
     settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey()));
 
-#if PLATFORM(WIN)
-    // Temporarily turn off accelerated compositing until we have a good solution for rendering it.
-    settings->setAcceleratedCompositingEnabled(false);
-    settings->setAcceleratedDrawingEnabled(false);
-    settings->setCanvasUsesAcceleratedDrawing(false);
-#else
     settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey()));
     settings->setAcceleratedDrawingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedDrawingEnabledKey()));
     settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey()));
-#endif
     settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey()));
     settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey()));
     settings->setWebGLEnabled(store.getBoolValueForKey(WebPreferencesKey::webGLEnabledKey()));
index c9a7110..b90599c 100644 (file)
 #include "config.h"
 #include "LayerTreeHostCAWin.h"
 
-#include <WebCore/NotImplemented.h>
-#include <wtf/RefPtr.h>
+#if HAVE(WKQCA)
+
+#include "DrawingAreaImpl.h"
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
+#include "WebPage.h"
+#include <WebCore/GraphicsLayerCA.h>
+#include <WebCore/LayerChangesFlusher.h>
+#include <WebCore/PlatformCALayer.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <WebKitQuartzCoreAdditions/WKCACFImage.h>
+#include <WebKitQuartzCoreAdditions/WKCACFView.h>
+#include <wtf/CurrentTime.h>
+
+#ifdef DEBUG_ALL
+#pragma comment(lib, "WebKitQuartzCoreAdditions_debug")
+#else
+#pragma comment(lib, "WebKitQuartzCoreAdditions")
+#endif
+
+using namespace WebCore;
 
 namespace WebKit {
 
+static HWND dummyWindow;
+static LPCWSTR dummyWindowClass = L"LayerTreeHostCAWindowClass";
+static size_t validLayerTreeHostCount;
+
+static void registerDummyWindowClass()
+{
+    static bool didRegister;
+    if (didRegister)
+        return;
+    didRegister = true;
+
+    WNDCLASSW wndClass = {0};
+    wndClass.lpszClassName = dummyWindowClass;
+    wndClass.lpfnWndProc = ::DefWindowProcW;
+    wndClass.hInstance = instanceHandle();
+
+    ::RegisterClassW(&wndClass);
+}
+
+// This window is never shown. It is only needed so that D3D can determine the display mode, etc.
+static HWND createDummyWindow()
+{
+    registerDummyWindowClass();
+    return ::CreateWindowW(dummyWindowClass, 0, WS_POPUP, 0, 0, 10, 10, 0, 0, instanceHandle(), 0);
+}
+
 PassRefPtr<LayerTreeHostCAWin> LayerTreeHostCAWin::create(WebPage* webPage)
 {
     RefPtr<LayerTreeHostCAWin> host = adoptRef(new LayerTreeHostCAWin(webPage));
@@ -40,6 +85,8 @@ PassRefPtr<LayerTreeHostCAWin> LayerTreeHostCAWin::create(WebPage* webPage)
 
 LayerTreeHostCAWin::LayerTreeHostCAWin(WebPage* webPage)
     : LayerTreeHostCA(webPage)
+    , m_isFlushingLayerChanges(false)
+    , m_nextDisplayTime(0)
 {
 }
 
@@ -49,14 +96,174 @@ LayerTreeHostCAWin::~LayerTreeHostCAWin()
 
 void LayerTreeHostCAWin::platformInitialize(LayerTreeContext&)
 {
-    // FIXME: <http://webkit.org/b/45567> Implement this!
-    notImplemented();
+    ++validLayerTreeHostCount;
+    if (!dummyWindow)
+        dummyWindow = createDummyWindow();
+
+    m_view.adoptCF(WKCACFViewCreate(kWKCACFViewDrawingDestinationImage));
+    WKCACFViewSetContextUserData(m_view.get(), static_cast<AbstractCACFLayerTreeHost*>(this));
+    WKCACFViewSetLayer(m_view.get(), rootLayer()->platformLayer());
+    WKCACFViewSetContextDidChangeCallback(m_view.get(), contextDidChangeCallback, this);
+
+    CGRect bounds = m_webPage->bounds();
+    WKCACFViewUpdate(m_view.get(), dummyWindow, &bounds);
+}
+
+void LayerTreeHostCAWin::invalidate()
+{
+    LayerChangesFlusher::shared().cancelPendingFlush(this);
+
+    WKCACFViewUpdate(m_view.get(), 0, 0);
+    WKCACFViewSetContextUserData(m_view.get(), 0);
+    WKCACFViewSetLayer(m_view.get(), 0);
+    WKCACFViewSetContextDidChangeCallback(m_view.get(), 0, 0);
+
+    LayerTreeHostCA::invalidate();
+
+    if (--validLayerTreeHostCount)
+        return;
+    ::DestroyWindow(dummyWindow);
+    dummyWindow = 0;
 }
 
 void LayerTreeHostCAWin::scheduleLayerFlush()
 {
-    // FIXME: <http://webkit.org/b/45567> Implement this!
-    notImplemented();
+    LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this);
+}
+
+bool LayerTreeHostCAWin::participatesInDisplay()
+{
+    return true;
+}
+
+bool LayerTreeHostCAWin::needsDisplay()
+{
+    return timeUntilNextDisplay() <= 0;
+}
+
+double LayerTreeHostCAWin::timeUntilNextDisplay()
+{
+    return m_nextDisplayTime - currentTime();
+}
+
+static IntSize size(WKCACFImageRef image)
+{
+    return IntSize(WKCACFImageGetWidth(image), WKCACFImageGetHeight(image));
+}
+
+static PassRefPtr<ShareableBitmap> toShareableBitmap(WKCACFImageRef image)
+{
+    size_t fileMappingSize;
+    HANDLE mapping = WKCACFImageCopyFileMapping(image, &fileMappingSize);
+    if (!mapping)
+        return 0;
+
+    RefPtr<SharedMemory> sharedMemory = SharedMemory::adopt(mapping, fileMappingSize, SharedMemory::ReadWrite);
+    if (!sharedMemory) {
+        ::CloseHandle(mapping);
+        return 0;
+    }
+
+    // WKCACFImage never has an alpha channel.
+    return ShareableBitmap::create(size(image), 0, sharedMemory.release());
+}
+
+void LayerTreeHostCAWin::display(UpdateInfo& updateInfo)
+{
+    CGPoint imageOrigin;
+    CFTimeInterval nextDrawTime;
+    RetainPtr<WKCACFImageRef> image(AdoptCF, WKCACFViewCopyDrawnImage(m_view.get(), &imageOrigin, &nextDrawTime));
+    m_nextDisplayTime = nextDrawTime - CACurrentMediaTime() + currentTime();
+    if (!image)
+        return;
+    RefPtr<ShareableBitmap> bitmap = toShareableBitmap(image.get());
+    if (!bitmap)
+        return;
+    if (!bitmap->createHandle(updateInfo.bitmapHandle))
+        return;
+    updateInfo.updateRectBounds = IntRect(IntPoint(imageOrigin.x, m_webPage->size().height() - imageOrigin.y - bitmap->size().height()), bitmap->size());
+    updateInfo.updateRects.append(updateInfo.updateRectBounds);
+}
+
+void LayerTreeHostCAWin::sizeDidChange(const IntSize& newSize)
+{
+    LayerTreeHostCA::sizeDidChange(newSize);
+    CGRect bounds = CGRectMake(0, 0, newSize.width(), newSize.height());
+    WKCACFViewUpdate(m_view.get(), dummyWindow, &bounds);
+    WKCACFViewFlushContext(m_view.get());
+}
+
+void LayerTreeHostCAWin::forceRepaint()
+{
+    LayerTreeHostCA::forceRepaint();
+    WKCACFViewFlushContext(m_view.get());
+}
+
+void LayerTreeHostCAWin::contextDidChangeCallback(WKCACFViewRef view, void* info)
+{
+    LayerTreeHostCAWin* host = static_cast<LayerTreeHostCAWin*>(info);
+    ASSERT_ARG(view, view == host->m_view);
+    host->contextDidChange();
+}
+
+void LayerTreeHostCAWin::contextDidChange()
+{
+    // Send currentTime to the pending animations. This function is called by CACF in a callback
+    // which occurs after the drawInContext calls. So currentTime is very close to the time
+    // the animations actually start
+    double currentTime = WTF::currentTime();
+
+    HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
+    for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it)
+        (*it)->animationStarted(currentTime);
+
+    m_pendingAnimatedLayers.clear();
+
+    m_nextDisplayTime = 0;
+    static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->setLayerHostNeedsDisplay();
+}
+
+PlatformCALayer* LayerTreeHostCAWin::rootLayer() const
+{
+    return static_cast<GraphicsLayerCA*>(LayerTreeHostCA::rootLayer())->platformCALayer();
+}
+
+void LayerTreeHostCAWin::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer)
+{
+    m_pendingAnimatedLayers.add(layer);
+}
+
+void LayerTreeHostCAWin::layerTreeDidChange()
+{
+    if (m_isFlushingLayerChanges) {
+        // The layer tree is changing as a result of flushing GraphicsLayer changes to their
+        // underlying PlatformCALayers. We'll flush those changes to the context as part of that
+        // process, so there's no need to schedule another flush here.
+        return;
+    }
+
+    // The layer tree is changing as a result of someone modifying a PlatformCALayer that doesn't
+    // have a corresponding GraphicsLayer. Schedule a flush since we won't schedule one through the
+    // normal GraphicsLayer mechanisms.
+    LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this);
+}
+
+void LayerTreeHostCAWin::flushPendingLayerChangesNow()
+{
+    RefPtr<LayerTreeHostCA> protector(this);
+
+    m_isFlushingLayerChanges = true;
+
+    // Flush changes stored up in GraphicsLayers to their underlying PlatformCALayers, if
+    // requested.
+    performScheduledLayerFlush();
+
+    // Flush changes stored up in PlatformCALayers to the context so they will be rendered.
+    WKCACFViewFlushContext(m_view.get());
+
+    m_isFlushingLayerChanges = false;
 }
 
 } // namespace WebKit
+
+#endif // HAVE(WKQCA)
index 21b3c58..f93ad77 100644 (file)
 #ifndef LayerTreeHostCAWin_h
 #define LayerTreeHostCAWin_h
 
+#include "HeaderDetection.h"
+
+#if HAVE(WKQCA)
+
 #include "LayerTreeHostCA.h"
+#include <WebCore/AbstractCACFLayerTreeHost.h>
+#include <wtf/HashSet.h>
+#include <wtf/RetainPtr.h>
+
+typedef struct _WKCACFView* WKCACFViewRef;
 
 namespace WebKit {
 
-class LayerTreeHostCAWin : public LayerTreeHostCA {
+class LayerTreeHostCAWin : public LayerTreeHostCA, private WebCore::AbstractCACFLayerTreeHost {
 public:
     static PassRefPtr<LayerTreeHostCAWin> create(WebPage*);
     virtual ~LayerTreeHostCAWin();
@@ -38,13 +47,36 @@ public:
 private:
     explicit LayerTreeHostCAWin(WebPage*);
 
+    static void contextDidChangeCallback(WKCACFViewRef, void* info);
+    void contextDidChange();
+
     // LayerTreeHost
+    virtual void invalidate();
+    virtual void forceRepaint();
+    virtual void sizeDidChange(const WebCore::IntSize& newSize);
     virtual void scheduleLayerFlush();
+    virtual bool participatesInDisplay();
+    virtual bool needsDisplay();
+    virtual double timeUntilNextDisplay();
+    virtual void display(UpdateInfo&);
 
     // LayerTreeHostCA
     virtual void platformInitialize(LayerTreeContext&);
+
+    // AbstractCACFLayerTreeHost
+    virtual WebCore::PlatformCALayer* rootLayer() const;
+    virtual void addPendingAnimatedLayer(PassRefPtr<WebCore::PlatformCALayer>);
+    virtual void layerTreeDidChange();
+    virtual void flushPendingLayerChangesNow();
+
+    RetainPtr<WKCACFViewRef> m_view;
+    HashSet<RefPtr<WebCore::PlatformCALayer> > m_pendingAnimatedLayers;
+    bool m_isFlushingLayerChanges;
+    double m_nextDisplayTime;
 };
 
 } // namespace WebKit
 
+#endif // HAVE(WKQCA)
+
 #endif // LayerTreeHostCAWin_h