[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

aroben at apple.com aroben at apple.com
Sun Feb 20 23:33:58 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit d0defa3292e766e378e93c6a7c6d7bd90f1b026a
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 21 19:32:59 2011 +0000

    Rename WKCACFLayerRenderer[Client] to CACFLayerTreeHost[Client]
    
    Also renamed a few functions and data members to match.
    
    Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't
    
    Reviewed by Simon Fraser.
    
    Source/WebCore:
    
    * WebCore.vcproj/WebCore.vcproj: Updated files' names and paths.
    
    * WebCore.vcproj/WebCoreQuartzCore.vsprops: Added platform/graphics/ca/win to the include
    path.
    
    * WebCore.vcproj/copyForwardingHeaders.cmd: Copy headers from platform/graphics/ca/win, too.
    
    * platform/graphics/ca/win/CACFLayerTreeHost.cpp: Renamed from Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp.
    * platform/graphics/ca/win/CACFLayerTreeHost.h: Renamed from Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h.
    
    * platform/graphics/ca/win/PlatformCALayerWin.cpp:
    * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
    * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
    Updated for renames.
    
    Source/WebKit/win:
    
    Update for WKCACFLayerRenderer -> CACFLayerTreeHost rename
    
    Also renamed WebView::m_layerRenderer to WebView::m_layerTreeHost to match.
    
    * WebPreferences.cpp:
    * WebView.cpp:
    (WebView::setAcceleratedCompositing): Also made sure to remove our HWND from the layer tree
    host before we get rid of the layer tree host itself.
    * WebView.h:
    
    Source/WebKit2:
    
    Update for WKCACFLayerRenderer -> CACFLayerView rename
    
    * WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp: Just removed all the unnecessary
     #includes.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76370 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 3d87938..2a366e3 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2011-01-21  Adam Roben  <aroben at apple.com>
+
+        Rename WKCACFLayerRenderer[Client] to CACFLayerTreeHost[Client]
+
+        Also renamed a few functions and data members to match.
+
+        Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't
+
+        Reviewed by Simon Fraser.
+
+        * WebCore.vcproj/WebCore.vcproj: Updated files' names and paths.
+
+        * WebCore.vcproj/WebCoreQuartzCore.vsprops: Added platform/graphics/ca/win to the include
+        path.
+
+        * WebCore.vcproj/copyForwardingHeaders.cmd: Copy headers from platform/graphics/ca/win, too.
+
+        * platform/graphics/ca/win/CACFLayerTreeHost.cpp: Renamed from Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp.
+        * platform/graphics/ca/win/CACFLayerTreeHost.h: Renamed from Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h.
+
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
+        Updated for renames.
+
 2011-01-21  Patrick Gansterer  <paroga at paroga.com>
 
         Original patch from François Sausset  <sausset at gmail.com>
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index 5c30699..165a193 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -27396,46 +27396,6 @@
 						>
 					</File>
 					<File
-						RelativePath="..\platform\graphics\win\WKCACFLayerRenderer.cpp"
-						>
-						<FileConfiguration
-							Name="Debug_Cairo_CFLite|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release_Cairo_CFLite|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\platform\graphics\win\WKCACFLayerRenderer.h"
-						>
-						<FileConfiguration
-							Name="Debug_Cairo_CFLite|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCustomBuildTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release_Cairo_CFLite|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCustomBuildTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
 						RelativePath="..\platform\graphics\win\WKCAImageQueue.cpp"
 						>
 						<FileConfiguration
@@ -28895,6 +28855,46 @@
 						Name="win"
 						>
 						<File
+							RelativePath="..\platform\graphics\ca\win\CACFLayerTreeHost.cpp"
+							>
+							<FileConfiguration
+								Name="Debug_Cairo_CFLite|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release_Cairo_CFLite|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+						<File
+							RelativePath="..\platform\graphics\ca\win\CACFLayerTreeHost.h"
+							>
+							<FileConfiguration
+								Name="Debug_Cairo_CFLite|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCustomBuildTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release_Cairo_CFLite|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCustomBuildTool"
+								/>
+							</FileConfiguration>
+						</File>
+						<File
 							RelativePath="..\platform\graphics\ca\win\PlatformCAAnimationWin.cpp"
 							>
 						</File>
diff --git a/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops b/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops
index a9866d9..48328c9 100644
--- a/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops
+++ b/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops
@@ -6,7 +6,7 @@
 	>
 	<Tool
 		Name="VCCLCompilerTool"
-		AdditionalIncludeDirectories="&quot;$(DXSDK_DIR)\Include&quot;"
+		AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\platform\graphics\ca\win&quot;;&quot;$(DXSDK_DIR)\Include&quot;"
 		PreprocessorDefinitions="QUARTZCORE_DLL"
 	/>
 </VisualStudioPropertySheet>
diff --git a/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd b/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd
index 7393d34..b3f19c6 100755
--- a/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd
+++ b/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd
@@ -39,6 +39,7 @@ xcopy /y /d "%ProjectDir%..\platform\graphics\*.h" "%CONFIGURATIONBUILDDIR%\incl
 xcopy /y /d "%ProjectDir%..\platform\graphics\%1\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 xcopy /y /d "%ProjectDir%..\platform\graphics\transforms\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 xcopy /y /d "%ProjectDir%..\platform\graphics\ca\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
+xcopy /y /d "%ProjectDir%..\platform\graphics\ca\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 xcopy /y /d "%ProjectDir%..\platform\graphics\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 xcopy /y /d "%ProjectDir%..\platform\graphics\win\%1\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 xcopy /y /d "%ProjectDir%..\platform\graphics\opentype\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
diff --git a/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
new file mode 100644
index 0000000..61d76a0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
@@ -0,0 +1,598 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#ifndef NDEBUG
+#define D3D_DEBUG_INFO
+#endif
+
+#include "CACFLayerTreeHost.h"
+
+#include "PlatformCALayer.h"
+#include "WebCoreInstanceHandle.h"
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <limits.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/HashMap.h>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/StdLibExtras.h>
+#include <d3d9.h>
+#include <d3dx9.h>
+
+using namespace std;
+
+#pragma comment(lib, "d3d9")
+#pragma comment(lib, "d3dx9")
+#ifdef DEBUG_ALL
+#pragma comment(lib, "QuartzCore_debug")
+#else
+#pragma comment(lib, "QuartzCore")
+#endif
+
+static IDirect3D9* s_d3d = 0;
+static IDirect3D9* d3d()
+{
+    if (s_d3d)
+        return s_d3d;
+
+    if (!LoadLibrary(TEXT("d3d9.dll")))
+        return 0;
+
+    s_d3d = Direct3DCreate9(D3D_SDK_VERSION);
+
+    return s_d3d;
+}
+
+inline static CGRect winRectToCGRect(RECT rc)
+{
+    return CGRectMake(rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top));
+}
+
+inline static CGRect winRectToCGRect(RECT rc, RECT relativeToRect)
+{
+    return CGRectMake(rc.left, (relativeToRect.bottom-rc.bottom), (rc.right - rc.left), (rc.bottom - rc.top));
+}
+
+namespace WebCore {
+
+static D3DPRESENT_PARAMETERS initialPresentationParameters()
+{
+    D3DPRESENT_PARAMETERS parameters = {0};
+    parameters.Windowed = TRUE;
+    parameters.SwapEffect = D3DSWAPEFFECT_COPY;
+    parameters.BackBufferCount = 1;
+    parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
+    parameters.MultiSampleType = D3DMULTISAMPLE_NONE;
+
+    return parameters;
+}
+
+// FIXME: <rdar://6507851> Share this code with CoreAnimation.
+static bool hardwareCapabilitiesIndicateCoreAnimationSupport(const D3DCAPS9& caps)
+{
+    // CoreAnimation needs two or more texture units.
+    if (caps.MaxTextureBlendStages < 2)
+        return false;
+
+    // CoreAnimation needs non-power-of-two textures.
+    if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && !(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL))
+        return false;
+
+    // CoreAnimation needs vertex shader 2.0 or greater.
+    if (D3DSHADER_VERSION_MAJOR(caps.VertexShaderVersion) < 2)
+        return false;
+
+    // CoreAnimation needs pixel shader 2.0 or greater.
+    if (D3DSHADER_VERSION_MAJOR(caps.PixelShaderVersion) < 2)
+        return false;
+
+    return true;
+}
+
+bool CACFLayerTreeHost::acceleratedCompositingAvailable()
+{
+    static bool available;
+    static bool tested;
+
+    if (tested)
+        return available;
+
+    tested = true;
+
+    // Initialize available to true since this function will be called from a 
+    // propagation within createRenderer(). We want to be able to return true 
+    // when that happens so that the test can continue.
+    available = true;
+    
+    HMODULE library = LoadLibrary(TEXT("d3d9.dll"));
+    if (!library) {
+        available = false;
+        return available;
+    }
+
+    FreeLibrary(library);
+#ifdef DEBUG_ALL
+    library = LoadLibrary(TEXT("QuartzCore_debug.dll"));
+#else
+    library = LoadLibrary(TEXT("QuartzCore.dll"));
+#endif
+    if (!library) {
+        available = false;
+        return available;
+    }
+
+    FreeLibrary(library);
+
+    // Make a dummy HWND.
+    WNDCLASSEX wcex = { 0 };
+    wcex.cbSize = sizeof(WNDCLASSEX);
+    wcex.lpfnWndProc = DefWindowProc;
+    wcex.hInstance = WebCore::instanceHandle();
+    wcex.lpszClassName = L"CoreAnimationTesterWindowClass";
+    ::RegisterClassEx(&wcex);
+    HWND testWindow = ::CreateWindow(L"CoreAnimationTesterWindowClass", L"CoreAnimationTesterWindow", WS_POPUP, -500, -500, 0, 0, 0, 0, 0, 0);
+
+    if (!testWindow) {
+        available = false;
+        return available;
+    }
+
+    RefPtr<CACFLayerTreeHost> host = CACFLayerTreeHost::create();
+    host->setWindow(testWindow);
+    available = host->createRenderer();
+    ::DestroyWindow(testWindow);
+
+    return available;
+}
+
+PassRefPtr<CACFLayerTreeHost> CACFLayerTreeHost::create()
+{
+    if (!acceleratedCompositingAvailable())
+        return 0;
+    return adoptRef(new CACFLayerTreeHost());
+}
+
+CACFLayerTreeHost::CACFLayerTreeHost()
+    : m_client(0)
+    , m_mightBeAbleToCreateDeviceLater(true)
+    , m_rootLayer(PlatformCALayer::create(PlatformCALayer::LayerTypeRootLayer, 0))
+    , m_context(wkCACFContextCreate())
+    , m_window(0)
+    , m_renderTimer(this, &CACFLayerTreeHost::renderTimerFired)
+    , m_mustResetLostDeviceBeforeRendering(false)
+    , m_shouldFlushPendingGraphicsLayerChanges(false)
+{
+    // Point the CACFContext to this
+    wkCACFContextSetUserData(m_context, this);
+
+    // Under the root layer, we have a clipping layer to clip the content,
+    // that contains a scroll layer that we use for scrolling the content.
+    // The root layer is the size of the client area of the window.
+    // The clipping layer is the size of the WebView client area (window less the scrollbars).
+    // The scroll layer is the size of the root child layer.
+    // Resizing the window will change the bounds of the rootLayer and the clip layer and will not
+    // cause any repositioning.
+    // Scrolling will affect only the position of the scroll layer without affecting the bounds.
+
+    m_rootLayer->setName("CACFLayerTreeHost rootLayer");
+    m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
+    m_rootLayer->setGeometryFlipped(true);
+
+#ifndef NDEBUG
+    CGColorRef debugColor = CGColorCreateGenericRGB(1, 0, 0, 0.8);
+    m_rootLayer->setBackgroundColor(debugColor);
+    CGColorRelease(debugColor);
+#endif
+
+    if (m_context)
+        wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
+
+#ifndef NDEBUG
+    char* printTreeFlag = getenv("CA_PRINT_TREE");
+    m_printTree = printTreeFlag && atoi(printTreeFlag);
+#endif
+}
+
+CACFLayerTreeHost::~CACFLayerTreeHost()
+{
+    setWindow(0);
+    wkCACFContextDestroy(m_context);
+}
+
+void CACFLayerTreeHost::setWindow(HWND window)
+{
+    if (window == m_window)
+        return;
+
+    if (m_window)
+        destroyRenderer();
+
+    m_window = window;
+
+    if (m_window)
+        createRenderer();
+}
+
+PlatformCALayer* CACFLayerTreeHost::rootLayer() const
+{
+    return m_rootLayer.get();
+}
+
+void CACFLayerTreeHost::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer)
+{
+    m_pendingAnimatedLayers.add(layer);
+}
+
+void CACFLayerTreeHost::setRootChildLayer(PlatformCALayer* layer)
+{
+    m_rootLayer->removeAllSublayers();
+    m_rootChildLayer = layer;
+    if (m_rootChildLayer)
+        m_rootLayer->appendSublayer(m_rootChildLayer.get());
+}
+   
+void CACFLayerTreeHost::layerTreeDidChange()
+{
+    renderSoon();
+}
+
+bool CACFLayerTreeHost::createRenderer()
+{
+    if (m_d3dDevice || !m_mightBeAbleToCreateDeviceLater)
+        return m_d3dDevice;
+
+    m_mightBeAbleToCreateDeviceLater = false;
+    D3DPRESENT_PARAMETERS parameters = initialPresentationParameters();
+
+    if (!d3d() || !::IsWindow(m_window))
+        return false;
+
+    // D3D doesn't like to make back buffers for 0 size windows. We skirt this problem if we make the
+    // passed backbuffer width and height non-zero. The window will necessarily get set to a non-zero
+    // size eventually, and then the backbuffer size will get reset.
+    RECT rect;
+    GetClientRect(m_window, &rect);
+
+    if (rect.left-rect.right == 0 || rect.bottom-rect.top == 0) {
+        parameters.BackBufferWidth = 1;
+        parameters.BackBufferHeight = 1;
+    }
+
+    D3DCAPS9 d3dCaps;
+    if (FAILED(d3d()->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps)))
+        return false;
+
+    DWORD behaviorFlags = D3DCREATE_FPU_PRESERVE;
+    if ((d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) && d3dCaps.VertexProcessingCaps)
+        behaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
+    else
+        behaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+
+    COMPtr<IDirect3DDevice9> device;
+    if (FAILED(d3d()->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_window, behaviorFlags, &parameters, &device))) {
+        // In certain situations (e.g., shortly after waking from sleep), Direct3DCreate9() will
+        // return an IDirect3D9 for which IDirect3D9::CreateDevice will always fail. In case we
+        // have one of these bad IDirect3D9s, get rid of it so we'll fetch a new one the next time
+        // we want to call CreateDevice.
+        s_d3d->Release();
+        s_d3d = 0;
+
+        // Even if we don't have a bad IDirect3D9, in certain situations (e.g., shortly after
+        // waking from sleep), CreateDevice will fail, but will later succeed if called again.
+        m_mightBeAbleToCreateDeviceLater = true;
+
+        return false;
+    }
+
+    // Now that we've created the IDirect3DDevice9 based on the capabilities we
+    // got from the IDirect3D9 global object, we requery the device for its
+    // actual capabilities. The capabilities returned by the device can
+    // sometimes be more complete, for example when using software vertex
+    // processing.
+    D3DCAPS9 deviceCaps;
+    if (FAILED(device->GetDeviceCaps(&deviceCaps)))
+        return false;
+
+    if (!hardwareCapabilitiesIndicateCoreAnimationSupport(deviceCaps))
+        return false;
+
+    m_d3dDevice = device;
+
+    initD3DGeometry();
+
+    wkCACFContextSetD3DDevice(m_context, m_d3dDevice.get());
+
+    if (IsWindow(m_window))
+        m_rootLayer->setBounds(bounds());
+
+    return true;
+}
+
+void CACFLayerTreeHost::destroyRenderer()
+{
+    wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
+
+    wkCACFContextSetD3DDevice(m_context, 0);
+    m_d3dDevice = 0;
+    if (s_d3d)
+        s_d3d->Release();
+
+    s_d3d = 0;
+    m_rootLayer = 0;
+    m_rootChildLayer = 0;
+
+    m_mightBeAbleToCreateDeviceLater = true;
+}
+
+void CACFLayerTreeHost::resize()
+{
+    if (!m_d3dDevice)
+        return;
+
+    // Resetting the device might fail here. But that's OK, because if it does it we will attempt to
+    // reset the device the next time we try to render.
+    resetDevice(ChangedWindowSize);
+
+    if (m_rootLayer) {
+        m_rootLayer->setBounds(bounds());
+        wkCACFContextFlush(m_context);
+    }
+}
+
+static void getDirtyRects(HWND window, Vector<CGRect>& outRects)
+{
+    ASSERT_ARG(outRects, outRects.isEmpty());
+
+    RECT clientRect;
+    if (!GetClientRect(window, &clientRect))
+        return;
+
+    OwnPtr<HRGN> region(CreateRectRgn(0, 0, 0, 0));
+    int regionType = GetUpdateRgn(window, region.get(), false);
+    if (regionType != COMPLEXREGION) {
+        RECT dirtyRect;
+        if (GetUpdateRect(window, &dirtyRect, false))
+            outRects.append(winRectToCGRect(dirtyRect, clientRect));
+        return;
+    }
+
+    DWORD dataSize = GetRegionData(region.get(), 0, 0);
+    OwnArrayPtr<unsigned char> regionDataBuffer(new unsigned char[dataSize]);
+    RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get());
+    if (!GetRegionData(region.get(), dataSize, regionData))
+        return;
+
+    outRects.resize(regionData->rdh.nCount);
+
+    RECT* rect = reinterpret_cast<RECT*>(regionData->Buffer);
+    for (size_t i = 0; i < outRects.size(); ++i, ++rect)
+        outRects[i] = winRectToCGRect(*rect, clientRect);
+}
+
+void CACFLayerTreeHost::renderTimerFired(Timer<CACFLayerTreeHost>*)
+{
+    paint();
+}
+
+void CACFLayerTreeHost::paint()
+{
+    createRenderer();
+    if (!m_d3dDevice) {
+        if (m_mightBeAbleToCreateDeviceLater)
+            renderSoon();
+        return;
+    }
+
+    Vector<CGRect> dirtyRects;
+    getDirtyRects(m_window, dirtyRects);
+    render(dirtyRects);
+}
+
+void CACFLayerTreeHost::render(const Vector<CGRect>& windowDirtyRects)
+{
+    ASSERT(m_d3dDevice);
+
+    if (m_mustResetLostDeviceBeforeRendering && !resetDevice(LostDevice)) {
+        // We can't reset the device right now. Try again soon.
+        renderSoon();
+        return;
+    }
+
+    if (m_client && !m_client->shouldRender()) {
+        renderSoon();
+        return;
+    }
+
+    if (m_shouldFlushPendingGraphicsLayerChanges) {
+        m_client->flushPendingGraphicsLayerChanges();
+        m_shouldFlushPendingGraphicsLayerChanges = false;
+    }
+
+    // Flush the root layer to the render tree.
+    wkCACFContextFlush(m_context);
+
+    // All pending animations will have been started with the flush. Fire the animationStarted calls
+    double currentTime = WTF::currentTime();
+    double currentMediaTime = CACurrentMediaTime();
+    double t = currentTime + wkCACFContextGetLastCommitTime(m_context) - currentMediaTime;
+    ASSERT(t <= currentTime);
+
+    HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
+    for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it) {
+        PlatformCALayerClient* owner = (*it)->owner();
+        owner->platformCALayerAnimationStarted(t);
+    }
+
+    m_pendingAnimatedLayers.clear();
+
+    CGRect bounds = this->bounds();
+
+    // Give the renderer some space to use. This needs to be valid until the
+    // wkCACFContextFinishUpdate() call below.
+    char space[4096];
+    if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), currentMediaTime, bounds, windowDirtyRects.data(), windowDirtyRects.size()))
+        return;
+
+    HRESULT err = S_OK;
+    CFTimeInterval timeToNextRender = numeric_limits<CFTimeInterval>::infinity();
+
+    do {
+        // FIXME: don't need to clear dirty region if layer tree is opaque.
+
+        WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context);
+        if (!e)
+            break;
+
+        Vector<D3DRECT, 64> rects;
+        for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) {
+            D3DRECT rect;
+            rect.x1 = r->origin.x;
+            rect.x2 = rect.x1 + r->size.width;
+            rect.y1 = bounds.origin.y + bounds.size.height - (r->origin.y + r->size.height);
+            rect.y2 = rect.y1 + r->size.height;
+
+            rects.append(rect);
+        }
+        wkCACFUpdateRectEnumeratorRelease(e);
+
+        timeToNextRender = wkCACFContextGetNextUpdateTime(m_context);
+
+        if (rects.isEmpty())
+            break;
+
+        m_d3dDevice->Clear(rects.size(), rects.data(), D3DCLEAR_TARGET, 0, 1.0f, 0);
+
+        m_d3dDevice->BeginScene();
+        wkCACFContextRenderUpdate(m_context);
+        m_d3dDevice->EndScene();
+
+        err = m_d3dDevice->Present(0, 0, 0, 0);
+
+        if (err == D3DERR_DEVICELOST) {
+            wkCACFContextAddUpdateRect(m_context, bounds);
+            if (!resetDevice(LostDevice)) {
+                // We can't reset the device right now. Try again soon.
+                renderSoon();
+                return;
+            }
+        }
+    } while (err == D3DERR_DEVICELOST);
+
+    wkCACFContextFinishUpdate(m_context);
+
+#ifndef NDEBUG
+    if (m_printTree)
+        m_rootLayer->printTree();
+#endif
+
+    // If timeToNextRender is not infinity, it means animations are running, so queue up to render again
+    if (timeToNextRender != numeric_limits<CFTimeInterval>::infinity())
+        renderSoon();
+}
+
+void CACFLayerTreeHost::renderSoon()
+{
+    if (!m_renderTimer.isActive())
+        m_renderTimer.startOneShot(0);
+}
+
+void CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon()
+{
+    m_shouldFlushPendingGraphicsLayerChanges = true;
+    renderSoon();
+}
+
+CGRect CACFLayerTreeHost::bounds() const
+{
+    RECT clientRect;
+    GetClientRect(m_window, &clientRect);
+
+    return winRectToCGRect(clientRect);
+}
+
+void CACFLayerTreeHost::initD3DGeometry()
+{
+    ASSERT(m_d3dDevice);
+
+    CGRect bounds = this->bounds();
+
+    float x0 = bounds.origin.x;
+    float y0 = bounds.origin.y;
+    float x1 = x0 + bounds.size.width;
+    float y1 = y0 + bounds.size.height;
+
+    D3DXMATRIXA16 projection;
+    D3DXMatrixOrthoOffCenterRH(&projection, x0, x1, y0, y1, -1.0f, 1.0f);
+
+    m_d3dDevice->SetTransform(D3DTS_PROJECTION, &projection);
+}
+
+bool CACFLayerTreeHost::resetDevice(ResetReason reason)
+{
+    ASSERT(m_d3dDevice);
+    ASSERT(m_context);
+
+    HRESULT hr = m_d3dDevice->TestCooperativeLevel();
+
+    if (hr == D3DERR_DEVICELOST || hr == D3DERR_DRIVERINTERNALERROR) {
+        // The device cannot be reset at this time. Try again soon.
+        m_mustResetLostDeviceBeforeRendering = true;
+        return false;
+    }
+
+    m_mustResetLostDeviceBeforeRendering = false;
+
+    if (reason == LostDevice && hr == D3D_OK) {
+        // The device wasn't lost after all.
+        return true;
+    }
+
+    // We can reset the device.
+
+    // We have to release the context's D3D resrouces whenever we reset the IDirect3DDevice9 in order to
+    // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used
+    // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>.
+    wkCACFContextReleaseD3DResources(m_context);
+
+    D3DPRESENT_PARAMETERS parameters = initialPresentationParameters();
+    hr = m_d3dDevice->Reset(&parameters);
+
+    // TestCooperativeLevel told us the device may be reset now, so we should
+    // not be told here that the device is lost.
+    ASSERT(hr != D3DERR_DEVICELOST);
+
+    initD3DGeometry();
+
+    return true;
+}
+
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h
new file mode 100644
index 0000000..ffe87ef
--- /dev/null
+++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 CACFLayerTreeHost_h
+#define CACFLayerTreeHost_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "COMPtr.h"
+#include "Timer.h"
+
+#include <wtf/HashSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+
+#include <CoreGraphics/CGGeometry.h>
+
+interface IDirect3DDevice9;
+struct WKCACFContext;
+
+typedef struct CGImage* CGImageRef;
+
+namespace WebCore {
+
+class PlatformCALayer;
+
+class CACFLayerTreeHostClient {
+public:
+    virtual ~CACFLayerTreeHostClient() { }
+    virtual bool shouldRender() const = 0;
+    virtual void flushPendingGraphicsLayerChanges() { }
+};
+
+// FIXME: Currently there is a CACFLayerTreeHost for each WebView and each
+// has its own CARenderOGLContext and Direct3DDevice9, which is inefficient.
+// (https://bugs.webkit.org/show_bug.cgi?id=31855)
+class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost> {
+    friend PlatformCALayer;
+
+public:
+    static PassRefPtr<CACFLayerTreeHost> create();
+    ~CACFLayerTreeHost();
+
+    static bool acceleratedCompositingAvailable();
+
+    void setClient(CACFLayerTreeHostClient* client) { m_client = client; }
+
+    void setRootChildLayer(PlatformCALayer*);
+    void layerTreeDidChange();
+    void setWindow(HWND);
+    void paint();
+    void resize();
+    void flushPendingGraphicsLayerChangesSoon();
+
+protected:
+    PlatformCALayer* rootLayer() const;
+    void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>);
+
+private:
+    CACFLayerTreeHost();
+
+    bool createRenderer();
+    void destroyRenderer();
+    void renderSoon();
+    void renderTimerFired(Timer<CACFLayerTreeHost>*);
+
+    CGRect bounds() const;
+
+    void initD3DGeometry();
+
+    // Call this when the device window has changed size or when IDirect3DDevice9::Present returns
+    // D3DERR_DEVICELOST. Returns true if the device was recovered, false if rendering must be
+    // aborted and reattempted soon.
+    enum ResetReason { ChangedWindowSize, LostDevice };
+    bool resetDevice(ResetReason);
+
+    void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>());
+
+    CACFLayerTreeHostClient* m_client;
+    bool m_mightBeAbleToCreateDeviceLater;
+    COMPtr<IDirect3DDevice9> m_d3dDevice;
+    RefPtr<PlatformCALayer> m_rootLayer;
+    RefPtr<PlatformCALayer> m_rootChildLayer;
+    WKCACFContext* m_context;
+    HWND m_window;
+    Timer<CACFLayerTreeHost> m_renderTimer;
+    bool m_mustResetLostDeviceBeforeRendering;
+    bool m_shouldFlushPendingGraphicsLayerChanges;
+    HashSet<RefPtr<PlatformCALayer> > m_pendingAnimatedLayers;
+
+#ifndef NDEBUG
+    bool m_printTree;
+#endif
+};
+
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // CACFLayerTreeHost_h
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
index 66d0732..b5a26f4 100644
--- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
@@ -29,10 +29,10 @@
 
 #include "PlatformCALayer.h"
 
+#include "CACFLayerTreeHost.h"
 #include "Font.h"
 #include "GraphicsContext.h"
 #include "PlatformCALayerWinInternal.h"
-#include "WKCACFLayerRenderer.h"
 #include <QuartzCore/CoreAnimationCF.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <wtf/CurrentTime.h>
@@ -65,14 +65,14 @@ static CFStringRef toCACFFilterType(PlatformCALayer::FilterType type)
     }
 }
 
-static WKCACFLayerRenderer* rendererForLayer(const PlatformCALayer* layer)
+static CACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer)
 {
-    // We need the WKCACFLayerRenderer associated with this layer, which is stored in the UserData of the CACFContext
+    // We need the CACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext
     void* userData = wkCACFLayerGetContextUserData(layer->platformLayer());
     if (!userData)
         return 0;
 
-    return static_cast<WKCACFLayerRenderer*>(userData);
+    return static_cast<CACFLayerTreeHost*>(userData);
 }
 
 static PlatformCALayerWinInternal* intern(const PlatformCALayer* layer)
@@ -156,8 +156,8 @@ PlatformLayer* PlatformCALayer::platformLayer() const
 
 PlatformCALayer* PlatformCALayer::rootLayer() const
 {
-    WKCACFLayerRenderer* renderer = rendererForLayer(this);
-    return renderer ? renderer->rootLayer() : 0;
+    CACFLayerTreeHost* host = layerTreeHostForLayer(this);
+    return host ? host->rootLayer() : 0;
 }
 
 void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect)
@@ -167,9 +167,9 @@ void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect)
     
 void PlatformCALayer::setNeedsCommit()
 {
-    WKCACFLayerRenderer* renderer = rendererForLayer(this);
-    if (renderer)
-        renderer->layerTreeDidChange();
+    CACFLayerTreeHost* host = layerTreeHostForLayer(this);
+    if (host)
+        host->layerTreeDidChange();
 }
 
 void PlatformCALayer::setContentsChanged()
@@ -269,10 +269,10 @@ void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation*
     CACFLayerAddAnimation(m_layer.get(), s.get(), animation->platformAnimation());
     setNeedsCommit();
 
-    // Tell the renderer about it so we can fire the start animation event
-    WKCACFLayerRenderer* renderer = rendererForLayer(this);
-    if (renderer)
-        renderer->addPendingAnimatedLayer(this);
+    // Tell the host about it so we can fire the start animation event
+    CACFLayerTreeHost* host = layerTreeHostForLayer(this);
+    if (host)
+        host->addPendingAnimatedLayer(this);
 }
 
 void PlatformCALayer::removeAnimationForKey(const String& key)
@@ -283,7 +283,7 @@ void PlatformCALayer::removeAnimationForKey(const String& key)
     RetainPtr<CFStringRef> s(AdoptCF, key.createCFString());
     CACFLayerRemoveAnimation(m_layer.get(), s.get());
 
-    // We don't "remove" a layer from WKCACFLayerRenderer when it loses an animation.
+    // We don't "remove" a layer from CACFLayerTreeHost when it loses an animation.
     // There may be other active animations on the layer and if an animation
     // callback is fired on a layer without any animations no harm is done.
 
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
index 6f28860..01db7f2 100644
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
@@ -40,7 +40,7 @@ MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlay
     : m_client(client)
     , m_hwnd(0)
 #if USE(ACCELERATED_COMPOSITING)
-    , m_layerRenderer(WKCACFLayerRenderer::create())
+    , m_layerTreeHost(CACFLayerTreeHost::create())
 #endif
 {
 }
@@ -81,7 +81,7 @@ void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd)
     ASSERT(IsWindow(m_hwnd));
 
 #if USE(ACCELERATED_COMPOSITING)
-    m_layerRenderer->setHostWindow(m_hwnd);
+    m_layerTreeHost->setWindow(m_hwnd);
 #endif
 
     ::SetFocus(m_hwnd);
@@ -107,7 +107,7 @@ void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCA
     if (!m_rootChild)
         return;
 
-    m_layerRenderer->setRootChildLayer(m_rootChild.get());
+    m_layerTreeHost->setRootChildLayer(m_rootChild.get());
     PlatformCALayer* rootLayer = m_rootChild->rootLayer();
     CGRect rootBounds = m_rootChild->rootLayer()->bounds();
     m_rootChild->setFrame(rootBounds);
@@ -147,7 +147,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA
     case WM_DESTROY:
         m_hwnd = 0;
 #if USE(ACCELERATED_COMPOSITING)
-        m_layerRenderer->setHostWindow(0);
+        m_layerTreeHost->setWindow(0);
 #endif
         break;
     case WM_WINDOWPOSCHANGED:
@@ -156,7 +156,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA
             if (wp->flags & SWP_NOSIZE)
                 break;
 #if USE(ACCELERATED_COMPOSITING)
-            m_layerRenderer->resize();
+            m_layerTreeHost->resize();
             PlatformCALayer* rootLayer = m_rootChild->rootLayer();
             CGRect rootBounds = m_rootChild->rootLayer()->bounds();
             m_rootChild->setFrame(rootBounds);
@@ -166,7 +166,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA
         break;
     case WM_PAINT:
 #if USE(ACCELERATED_COMPOSITING)
-        m_layerRenderer->paint();
+        m_layerTreeHost->paint();
         ::ValidateRect(m_hwnd, 0);
 #endif
         break;
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
index 4619f2a..c1ae762 100644
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
@@ -27,8 +27,8 @@
 #define MediaPlayerPrivateFullscreenWindow_h
 
 #if USE(ACCELERATED_COMPOSITING)
+#include "CACFLayerTreeHost.h"
 #include "PlatformCALayer.h"
-#include "WKCACFLayerRenderer.h"
 #endif
 
 typedef unsigned WPARAM;
@@ -58,7 +58,7 @@ public:
     HWND hwnd() const { return m_hwnd; }
 
 #if USE(ACCELERATED_COMPOSITING)
-    WKCACFLayerRenderer* layerRenderer() const { return m_layerRenderer.get(); }
+    CACFLayerTreeHost* layerView() const { return m_layerTreeHost.get(); }
 
     PlatformCALayer* rootChildLayer() const { return m_rootChild.get(); }
     void setRootChildLayer(PassRefPtr<PlatformCALayer>);
@@ -70,7 +70,7 @@ private:
 
     MediaPlayerPrivateFullscreenClient* m_client;
 #if USE(ACCELERATED_COMPOSITING)
-    RefPtr<WKCACFLayerRenderer> m_layerRenderer;
+    RefPtr<CACFLayerTreeHost> m_layerTreeHost;
     RefPtr<PlatformCALayer> m_rootChild;
 #endif
     HWND m_hwnd;
diff --git a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
deleted file mode 100644
index 9ff8e1c..0000000
--- a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
+++ /dev/null
@@ -1,598 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#ifndef NDEBUG
-#define D3D_DEBUG_INFO
-#endif
-
-#include "WKCACFLayerRenderer.h"
-
-#include "PlatformCALayer.h"
-#include "WebCoreInstanceHandle.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <limits.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/HashMap.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/StdLibExtras.h>
-#include <d3d9.h>
-#include <d3dx9.h>
-
-using namespace std;
-
-#pragma comment(lib, "d3d9")
-#pragma comment(lib, "d3dx9")
-#ifdef DEBUG_ALL
-#pragma comment(lib, "QuartzCore_debug")
-#else
-#pragma comment(lib, "QuartzCore")
-#endif
-
-static IDirect3D9* s_d3d = 0;
-static IDirect3D9* d3d()
-{
-    if (s_d3d)
-        return s_d3d;
-
-    if (!LoadLibrary(TEXT("d3d9.dll")))
-        return 0;
-
-    s_d3d = Direct3DCreate9(D3D_SDK_VERSION);
-
-    return s_d3d;
-}
-
-inline static CGRect winRectToCGRect(RECT rc)
-{
-    return CGRectMake(rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top));
-}
-
-inline static CGRect winRectToCGRect(RECT rc, RECT relativeToRect)
-{
-    return CGRectMake(rc.left, (relativeToRect.bottom-rc.bottom), (rc.right - rc.left), (rc.bottom - rc.top));
-}
-
-namespace WebCore {
-
-static D3DPRESENT_PARAMETERS initialPresentationParameters()
-{
-    D3DPRESENT_PARAMETERS parameters = {0};
-    parameters.Windowed = TRUE;
-    parameters.SwapEffect = D3DSWAPEFFECT_COPY;
-    parameters.BackBufferCount = 1;
-    parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
-    parameters.MultiSampleType = D3DMULTISAMPLE_NONE;
-
-    return parameters;
-}
-
-// FIXME: <rdar://6507851> Share this code with CoreAnimation.
-static bool hardwareCapabilitiesIndicateCoreAnimationSupport(const D3DCAPS9& caps)
-{
-    // CoreAnimation needs two or more texture units.
-    if (caps.MaxTextureBlendStages < 2)
-        return false;
-
-    // CoreAnimation needs non-power-of-two textures.
-    if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && !(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL))
-        return false;
-
-    // CoreAnimation needs vertex shader 2.0 or greater.
-    if (D3DSHADER_VERSION_MAJOR(caps.VertexShaderVersion) < 2)
-        return false;
-
-    // CoreAnimation needs pixel shader 2.0 or greater.
-    if (D3DSHADER_VERSION_MAJOR(caps.PixelShaderVersion) < 2)
-        return false;
-
-    return true;
-}
-
-bool WKCACFLayerRenderer::acceleratedCompositingAvailable()
-{
-    static bool available;
-    static bool tested;
-
-    if (tested)
-        return available;
-
-    tested = true;
-
-    // Initialize available to true since this function will be called from a 
-    // propagation within createRenderer(). We want to be able to return true 
-    // when that happens so that the test can continue.
-    available = true;
-    
-    HMODULE library = LoadLibrary(TEXT("d3d9.dll"));
-    if (!library) {
-        available = false;
-        return available;
-    }
-
-    FreeLibrary(library);
-#ifdef DEBUG_ALL
-    library = LoadLibrary(TEXT("QuartzCore_debug.dll"));
-#else
-    library = LoadLibrary(TEXT("QuartzCore.dll"));
-#endif
-    if (!library) {
-        available = false;
-        return available;
-    }
-
-    FreeLibrary(library);
-
-    // Make a dummy HWND.
-    WNDCLASSEX wcex = { 0 };
-    wcex.cbSize = sizeof(WNDCLASSEX);
-    wcex.lpfnWndProc = DefWindowProc;
-    wcex.hInstance = WebCore::instanceHandle();
-    wcex.lpszClassName = L"CoreAnimationTesterWindowClass";
-    ::RegisterClassEx(&wcex);
-    HWND testWindow = ::CreateWindow(L"CoreAnimationTesterWindowClass", L"CoreAnimationTesterWindow", WS_POPUP, -500, -500, 0, 0, 0, 0, 0, 0);
-
-    if (!testWindow) {
-        available = false;
-        return available;
-    }
-
-    RefPtr<WKCACFLayerRenderer> testLayerRenderer = WKCACFLayerRenderer::create();
-    testLayerRenderer->setHostWindow(testWindow);
-    available = testLayerRenderer->createRenderer();
-    ::DestroyWindow(testWindow);
-
-    return available;
-}
-
-PassRefPtr<WKCACFLayerRenderer> WKCACFLayerRenderer::create()
-{
-    if (!acceleratedCompositingAvailable())
-        return 0;
-    return adoptRef(new WKCACFLayerRenderer());
-}
-
-WKCACFLayerRenderer::WKCACFLayerRenderer()
-    : m_client(0)
-    , m_mightBeAbleToCreateDeviceLater(true)
-    , m_rootLayer(PlatformCALayer::create(PlatformCALayer::LayerTypeRootLayer, 0))
-    , m_context(wkCACFContextCreate())
-    , m_hostWindow(0)
-    , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired)
-    , m_mustResetLostDeviceBeforeRendering(false)
-    , m_shouldFlushPendingGraphicsLayerChanges(false)
-{
-    // Point the CACFContext to this
-    wkCACFContextSetUserData(m_context, this);
-
-    // Under the root layer, we have a clipping layer to clip the content,
-    // that contains a scroll layer that we use for scrolling the content.
-    // The root layer is the size of the client area of the window.
-    // The clipping layer is the size of the WebView client area (window less the scrollbars).
-    // The scroll layer is the size of the root child layer.
-    // Resizing the window will change the bounds of the rootLayer and the clip layer and will not
-    // cause any repositioning.
-    // Scrolling will affect only the position of the scroll layer without affecting the bounds.
-
-    m_rootLayer->setName("WKCACFLayerRenderer rootLayer");
-    m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
-    m_rootLayer->setGeometryFlipped(true);
-
-#ifndef NDEBUG
-    CGColorRef debugColor = CGColorCreateGenericRGB(1, 0, 0, 0.8);
-    m_rootLayer->setBackgroundColor(debugColor);
-    CGColorRelease(debugColor);
-#endif
-
-    if (m_context)
-        wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
-
-#ifndef NDEBUG
-    char* printTreeFlag = getenv("CA_PRINT_TREE");
-    m_printTree = printTreeFlag && atoi(printTreeFlag);
-#endif
-}
-
-WKCACFLayerRenderer::~WKCACFLayerRenderer()
-{
-    setHostWindow(0);
-    wkCACFContextDestroy(m_context);
-}
-
-void WKCACFLayerRenderer::setHostWindow(HWND window)
-{
-    if (window == m_hostWindow)
-        return;
-
-    if (m_hostWindow)
-        destroyRenderer();
-
-    m_hostWindow = window;
-
-    if (m_hostWindow)
-        createRenderer();
-}
-
-PlatformCALayer* WKCACFLayerRenderer::rootLayer() const
-{
-    return m_rootLayer.get();
-}
-
-void WKCACFLayerRenderer::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer)
-{
-    m_pendingAnimatedLayers.add(layer);
-}
-
-void WKCACFLayerRenderer::setRootChildLayer(PlatformCALayer* layer)
-{
-    m_rootLayer->removeAllSublayers();
-    m_rootChildLayer = layer;
-    if (m_rootChildLayer)
-        m_rootLayer->appendSublayer(m_rootChildLayer.get());
-}
-   
-void WKCACFLayerRenderer::layerTreeDidChange()
-{
-    renderSoon();
-}
-
-bool WKCACFLayerRenderer::createRenderer()
-{
-    if (m_d3dDevice || !m_mightBeAbleToCreateDeviceLater)
-        return m_d3dDevice;
-
-    m_mightBeAbleToCreateDeviceLater = false;
-    D3DPRESENT_PARAMETERS parameters = initialPresentationParameters();
-
-    if (!d3d() || !::IsWindow(m_hostWindow))
-        return false;
-
-    // D3D doesn't like to make back buffers for 0 size windows. We skirt this problem if we make the
-    // passed backbuffer width and height non-zero. The window will necessarily get set to a non-zero
-    // size eventually, and then the backbuffer size will get reset.
-    RECT rect;
-    GetClientRect(m_hostWindow, &rect);
-
-    if (rect.left-rect.right == 0 || rect.bottom-rect.top == 0) {
-        parameters.BackBufferWidth = 1;
-        parameters.BackBufferHeight = 1;
-    }
-
-    D3DCAPS9 d3dCaps;
-    if (FAILED(d3d()->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps)))
-        return false;
-
-    DWORD behaviorFlags = D3DCREATE_FPU_PRESERVE;
-    if ((d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) && d3dCaps.VertexProcessingCaps)
-        behaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
-    else
-        behaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
-
-    COMPtr<IDirect3DDevice9> device;
-    if (FAILED(d3d()->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hostWindow, behaviorFlags, &parameters, &device))) {
-        // In certain situations (e.g., shortly after waking from sleep), Direct3DCreate9() will
-        // return an IDirect3D9 for which IDirect3D9::CreateDevice will always fail. In case we
-        // have one of these bad IDirect3D9s, get rid of it so we'll fetch a new one the next time
-        // we want to call CreateDevice.
-        s_d3d->Release();
-        s_d3d = 0;
-
-        // Even if we don't have a bad IDirect3D9, in certain situations (e.g., shortly after
-        // waking from sleep), CreateDevice will fail, but will later succeed if called again.
-        m_mightBeAbleToCreateDeviceLater = true;
-
-        return false;
-    }
-
-    // Now that we've created the IDirect3DDevice9 based on the capabilities we
-    // got from the IDirect3D9 global object, we requery the device for its
-    // actual capabilities. The capabilities returned by the device can
-    // sometimes be more complete, for example when using software vertex
-    // processing.
-    D3DCAPS9 deviceCaps;
-    if (FAILED(device->GetDeviceCaps(&deviceCaps)))
-        return false;
-
-    if (!hardwareCapabilitiesIndicateCoreAnimationSupport(deviceCaps))
-        return false;
-
-    m_d3dDevice = device;
-
-    initD3DGeometry();
-
-    wkCACFContextSetD3DDevice(m_context, m_d3dDevice.get());
-
-    if (IsWindow(m_hostWindow))
-        m_rootLayer->setBounds(bounds());
-
-    return true;
-}
-
-void WKCACFLayerRenderer::destroyRenderer()
-{
-    wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
-
-    wkCACFContextSetD3DDevice(m_context, 0);
-    m_d3dDevice = 0;
-    if (s_d3d)
-        s_d3d->Release();
-
-    s_d3d = 0;
-    m_rootLayer = 0;
-    m_rootChildLayer = 0;
-
-    m_mightBeAbleToCreateDeviceLater = true;
-}
-
-void WKCACFLayerRenderer::resize()
-{
-    if (!m_d3dDevice)
-        return;
-
-    // Resetting the device might fail here. But that's OK, because if it does it we will attempt to
-    // reset the device the next time we try to render.
-    resetDevice(ChangedWindowSize);
-
-    if (m_rootLayer) {
-        m_rootLayer->setBounds(bounds());
-        wkCACFContextFlush(m_context);
-    }
-}
-
-static void getDirtyRects(HWND window, Vector<CGRect>& outRects)
-{
-    ASSERT_ARG(outRects, outRects.isEmpty());
-
-    RECT clientRect;
-    if (!GetClientRect(window, &clientRect))
-        return;
-
-    OwnPtr<HRGN> region(CreateRectRgn(0, 0, 0, 0));
-    int regionType = GetUpdateRgn(window, region.get(), false);
-    if (regionType != COMPLEXREGION) {
-        RECT dirtyRect;
-        if (GetUpdateRect(window, &dirtyRect, false))
-            outRects.append(winRectToCGRect(dirtyRect, clientRect));
-        return;
-    }
-
-    DWORD dataSize = GetRegionData(region.get(), 0, 0);
-    OwnArrayPtr<unsigned char> regionDataBuffer(new unsigned char[dataSize]);
-    RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get());
-    if (!GetRegionData(region.get(), dataSize, regionData))
-        return;
-
-    outRects.resize(regionData->rdh.nCount);
-
-    RECT* rect = reinterpret_cast<RECT*>(regionData->Buffer);
-    for (size_t i = 0; i < outRects.size(); ++i, ++rect)
-        outRects[i] = winRectToCGRect(*rect, clientRect);
-}
-
-void WKCACFLayerRenderer::renderTimerFired(Timer<WKCACFLayerRenderer>*)
-{
-    paint();
-}
-
-void WKCACFLayerRenderer::paint()
-{
-    createRenderer();
-    if (!m_d3dDevice) {
-        if (m_mightBeAbleToCreateDeviceLater)
-            renderSoon();
-        return;
-    }
-
-    Vector<CGRect> dirtyRects;
-    getDirtyRects(m_hostWindow, dirtyRects);
-    render(dirtyRects);
-}
-
-void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects)
-{
-    ASSERT(m_d3dDevice);
-
-    if (m_mustResetLostDeviceBeforeRendering && !resetDevice(LostDevice)) {
-        // We can't reset the device right now. Try again soon.
-        renderSoon();
-        return;
-    }
-
-    if (m_client && !m_client->shouldRender()) {
-        renderSoon();
-        return;
-    }
-
-    if (m_shouldFlushPendingGraphicsLayerChanges) {
-        m_client->flushPendingGraphicsLayerChanges();
-        m_shouldFlushPendingGraphicsLayerChanges = false;
-    }
-
-    // Flush the root layer to the render tree.
-    wkCACFContextFlush(m_context);
-
-    // All pending animations will have been started with the flush. Fire the animationStarted calls
-    double currentTime = WTF::currentTime();
-    double currentMediaTime = CACurrentMediaTime();
-    double t = currentTime + wkCACFContextGetLastCommitTime(m_context) - currentMediaTime;
-    ASSERT(t <= currentTime);
-
-    HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
-    for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it) {
-        PlatformCALayerClient* owner = (*it)->owner();
-        owner->platformCALayerAnimationStarted(t);
-    }
-
-    m_pendingAnimatedLayers.clear();
-
-    CGRect bounds = this->bounds();
-
-    // Give the renderer some space to use. This needs to be valid until the
-    // wkCACFContextFinishUpdate() call below.
-    char space[4096];
-    if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), currentMediaTime, bounds, windowDirtyRects.data(), windowDirtyRects.size()))
-        return;
-
-    HRESULT err = S_OK;
-    CFTimeInterval timeToNextRender = numeric_limits<CFTimeInterval>::infinity();
-
-    do {
-        // FIXME: don't need to clear dirty region if layer tree is opaque.
-
-        WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context);
-        if (!e)
-            break;
-
-        Vector<D3DRECT, 64> rects;
-        for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) {
-            D3DRECT rect;
-            rect.x1 = r->origin.x;
-            rect.x2 = rect.x1 + r->size.width;
-            rect.y1 = bounds.origin.y + bounds.size.height - (r->origin.y + r->size.height);
-            rect.y2 = rect.y1 + r->size.height;
-
-            rects.append(rect);
-        }
-        wkCACFUpdateRectEnumeratorRelease(e);
-
-        timeToNextRender = wkCACFContextGetNextUpdateTime(m_context);
-
-        if (rects.isEmpty())
-            break;
-
-        m_d3dDevice->Clear(rects.size(), rects.data(), D3DCLEAR_TARGET, 0, 1.0f, 0);
-
-        m_d3dDevice->BeginScene();
-        wkCACFContextRenderUpdate(m_context);
-        m_d3dDevice->EndScene();
-
-        err = m_d3dDevice->Present(0, 0, 0, 0);
-
-        if (err == D3DERR_DEVICELOST) {
-            wkCACFContextAddUpdateRect(m_context, bounds);
-            if (!resetDevice(LostDevice)) {
-                // We can't reset the device right now. Try again soon.
-                renderSoon();
-                return;
-            }
-        }
-    } while (err == D3DERR_DEVICELOST);
-
-    wkCACFContextFinishUpdate(m_context);
-
-#ifndef NDEBUG
-    if (m_printTree)
-        m_rootLayer->printTree();
-#endif
-
-    // If timeToNextRender is not infinity, it means animations are running, so queue up to render again
-    if (timeToNextRender != numeric_limits<CFTimeInterval>::infinity())
-        renderSoon();
-}
-
-void WKCACFLayerRenderer::renderSoon()
-{
-    if (!m_renderTimer.isActive())
-        m_renderTimer.startOneShot(0);
-}
-
-void WKCACFLayerRenderer::flushPendingGraphicsLayerChangesSoon()
-{
-    m_shouldFlushPendingGraphicsLayerChanges = true;
-    renderSoon();
-}
-
-CGRect WKCACFLayerRenderer::bounds() const
-{
-    RECT clientRect;
-    GetClientRect(m_hostWindow, &clientRect);
-
-    return winRectToCGRect(clientRect);
-}
-
-void WKCACFLayerRenderer::initD3DGeometry()
-{
-    ASSERT(m_d3dDevice);
-
-    CGRect bounds = this->bounds();
-
-    float x0 = bounds.origin.x;
-    float y0 = bounds.origin.y;
-    float x1 = x0 + bounds.size.width;
-    float y1 = y0 + bounds.size.height;
-
-    D3DXMATRIXA16 projection;
-    D3DXMatrixOrthoOffCenterRH(&projection, x0, x1, y0, y1, -1.0f, 1.0f);
-
-    m_d3dDevice->SetTransform(D3DTS_PROJECTION, &projection);
-}
-
-bool WKCACFLayerRenderer::resetDevice(ResetReason reason)
-{
-    ASSERT(m_d3dDevice);
-    ASSERT(m_context);
-
-    HRESULT hr = m_d3dDevice->TestCooperativeLevel();
-
-    if (hr == D3DERR_DEVICELOST || hr == D3DERR_DRIVERINTERNALERROR) {
-        // The device cannot be reset at this time. Try again soon.
-        m_mustResetLostDeviceBeforeRendering = true;
-        return false;
-    }
-
-    m_mustResetLostDeviceBeforeRendering = false;
-
-    if (reason == LostDevice && hr == D3D_OK) {
-        // The device wasn't lost after all.
-        return true;
-    }
-
-    // We can reset the device.
-
-    // We have to release the context's D3D resrouces whenever we reset the IDirect3DDevice9 in order to
-    // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used
-    // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>.
-    wkCACFContextReleaseD3DResources(m_context);
-
-    D3DPRESENT_PARAMETERS parameters = initialPresentationParameters();
-    hr = m_d3dDevice->Reset(&parameters);
-
-    // TestCooperativeLevel told us the device may be reset now, so we should
-    // not be told here that the device is lost.
-    ASSERT(hr != D3DERR_DEVICELOST);
-
-    initD3DGeometry();
-
-    return true;
-}
-
-}
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
deleted file mode 100644
index 149106e..0000000
--- a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 WKCACFLayerRenderer_h
-#define WKCACFLayerRenderer_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "COMPtr.h"
-#include "Timer.h"
-
-#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-
-#include <CoreGraphics/CGGeometry.h>
-
-interface IDirect3DDevice9;
-struct WKCACFContext;
-
-typedef struct CGImage* CGImageRef;
-
-namespace WebCore {
-
-class PlatformCALayer;
-
-class WKCACFLayerRendererClient {
-public:
-    virtual ~WKCACFLayerRendererClient() { }
-    virtual bool shouldRender() const = 0;
-    virtual void flushPendingGraphicsLayerChanges() { }
-};
-
-// FIXME: Currently there is a WKCACFLayerRenderer for each WebView and each
-// has its own CARenderOGLContext and Direct3DDevice9, which is inefficient.
-// (https://bugs.webkit.org/show_bug.cgi?id=31855)
-class WKCACFLayerRenderer : public RefCounted<WKCACFLayerRenderer> {
-    friend PlatformCALayer;
-
-public:
-    static PassRefPtr<WKCACFLayerRenderer> create();
-    ~WKCACFLayerRenderer();
-
-    static bool acceleratedCompositingAvailable();
-
-    void setClient(WKCACFLayerRendererClient* client) { m_client = client; }
-
-    void setRootChildLayer(PlatformCALayer*);
-    void layerTreeDidChange();
-    void setHostWindow(HWND);
-    void paint();
-    void resize();
-    void flushPendingGraphicsLayerChangesSoon();
-
-protected:
-    PlatformCALayer* rootLayer() const;
-    void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>);
-
-private:
-    WKCACFLayerRenderer();
-
-    bool createRenderer();
-    void destroyRenderer();
-    void renderSoon();
-    void renderTimerFired(Timer<WKCACFLayerRenderer>*);
-
-    CGRect bounds() const;
-
-    void initD3DGeometry();
-
-    // Call this when the device window has changed size or when IDirect3DDevice9::Present returns
-    // D3DERR_DEVICELOST. Returns true if the device was recovered, false if rendering must be
-    // aborted and reattempted soon.
-    enum ResetReason { ChangedWindowSize, LostDevice };
-    bool resetDevice(ResetReason);
-
-    void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>());
-
-    WKCACFLayerRendererClient* m_client;
-    bool m_mightBeAbleToCreateDeviceLater;
-    COMPtr<IDirect3DDevice9> m_d3dDevice;
-    RefPtr<PlatformCALayer> m_rootLayer;
-    RefPtr<PlatformCALayer> m_rootChildLayer;
-    WKCACFContext* m_context;
-    HWND m_hostWindow;
-    Timer<WKCACFLayerRenderer> m_renderTimer;
-    bool m_mustResetLostDeviceBeforeRendering;
-    bool m_shouldFlushPendingGraphicsLayerChanges;
-    HashSet<RefPtr<PlatformCALayer> > m_pendingAnimatedLayers;
-
-#ifndef NDEBUG
-    bool m_printTree;
-#endif
-};
-
-}
-
-#endif // USE(ACCELERATED_COMPOSITING)
-
-#endif // WKCACFLayerRenderer_h
diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog
index 23f8ee4..3e3cc49 100644
--- a/Source/WebKit/win/ChangeLog
+++ b/Source/WebKit/win/ChangeLog
@@ -1,5 +1,21 @@
 2011-01-21  Adam Roben  <aroben at apple.com>
 
+        Update for WKCACFLayerRenderer -> CACFLayerTreeHost rename
+
+        Also renamed WebView::m_layerRenderer to WebView::m_layerTreeHost to match.
+
+        Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't
+
+        Reviewed by Simon Fraser.
+
+        * WebPreferences.cpp:
+        * WebView.cpp:
+        (WebView::setAcceleratedCompositing): Also made sure to remove our HWND from the layer tree
+        host before we get rid of the layer tree host itself.
+        * WebView.h:
+
+2011-01-21  Adam Roben  <aroben at apple.com>
+
         Replace some "sync compositing state" terminology with "flush pending GraphicsLayer changes"
 
         This seems to be the direction in which our code is moving. I chose "GraphicsLayer" as
diff --git a/Source/WebKit/win/WebPreferences.cpp b/Source/WebKit/win/WebPreferences.cpp
index 5a2c19b..a962471 100644
--- a/Source/WebKit/win/WebPreferences.cpp
+++ b/Source/WebKit/win/WebPreferences.cpp
@@ -29,23 +29,22 @@
 #include "WebPreferences.h"
 
 #include "COMPtr.h"
+#include "WebLocalizableStrings.h"
 #include "WebNotificationCenter.h"
 #include "WebPreferenceKeysPrivate.h"
 
-#include <wtf/text/StringHash.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <WebCore/CACFLayerTreeHost.h>
 #include <WebCore/FileSystem.h>
 #include <WebCore/Font.h>
 #include <WebCore/PlatformString.h>
-#include <WebCore/WKCACFLayerRenderer.h>
-#include "WebLocalizableStrings.h"
-
-#include <CoreFoundation/CoreFoundation.h>
 #include <limits>
 #include <shlobj.h>
 #include <tchar.h>
 #include <wtf/HashMap.h>
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
 
 #if PLATFORM(CG)
 #include <CoreGraphics/CoreGraphics.h>
@@ -1446,7 +1445,7 @@ HRESULT WebPreferences::setAcceleratedCompositingEnabled(BOOL enabled)
 HRESULT WebPreferences::acceleratedCompositingEnabled(BOOL* enabled)
 {
 #if USE(ACCELERATED_COMPOSITING)
-    *enabled = WKCACFLayerRenderer::acceleratedCompositingAvailable() && boolValueForKey(CFSTR(WebKitAcceleratedCompositingEnabledPreferenceKey));
+    *enabled = CACFLayerTreeHost::acceleratedCompositingAvailable() && boolValueForKey(CFSTR(WebKitAcceleratedCompositingEnabledPreferenceKey));
 #else
     *enabled = FALSE;
 #endif
diff --git a/Source/WebKit/win/WebView.cpp b/Source/WebKit/win/WebView.cpp
index 9eb0c0e..5a33d5b 100644
--- a/Source/WebKit/win/WebView.cpp
+++ b/Source/WebKit/win/WebView.cpp
@@ -388,7 +388,7 @@ WebView::~WebView()
     ASSERT(!m_viewWindow);
 
 #if USE(ACCELERATED_COMPOSITING)
-    ASSERT(!m_layerRenderer);
+    ASSERT(!m_layerTreeHost);
     ASSERT(!m_backingLayer);
 #endif
 
@@ -883,8 +883,8 @@ void WebView::sizeChanged(const IntSize& newSize)
         coreFrame->view()->resize(newSize);
 
 #if USE(ACCELERATED_COMPOSITING)
-    if (m_layerRenderer)
-        m_layerRenderer->resize();
+    if (m_layerTreeHost)
+        m_layerTreeHost->resize();
     if (m_backingLayer) {
         m_backingLayer->setSize(newSize);
         m_backingLayer->setNeedsDisplay();
@@ -994,7 +994,7 @@ void WebView::paint(HDC dc, LPARAM options)
         // Flushing might have taken us out of compositing mode.
         if (isAcceleratedCompositing()) {
             // FIXME: We need to paint into dc (if provided). <http://webkit.org/b/52578>
-            m_layerRenderer->paint();
+            m_layerTreeHost->paint();
             ::ValidateRect(m_viewWindow, 0);
             return;
         }
@@ -6274,24 +6274,24 @@ void WebView::setRootChildLayer(GraphicsLayer* layer)
 
 void WebView::flushPendingGraphicsLayerChangesSoon()
 {
-    if (!m_layerRenderer)
+    if (!m_layerTreeHost)
         return;
-    m_layerRenderer->flushPendingGraphicsLayerChangesSoon();
+    m_layerTreeHost->flushPendingGraphicsLayerChangesSoon();
 }
 
 void WebView::setAcceleratedCompositing(bool accelerated)
 {
-    if (m_isAcceleratedCompositing == accelerated || !WKCACFLayerRenderer::acceleratedCompositingAvailable())
+    if (m_isAcceleratedCompositing == accelerated || !CACFLayerTreeHost::acceleratedCompositingAvailable())
         return;
 
     if (accelerated) {
-        m_layerRenderer = WKCACFLayerRenderer::create();
-        if (m_layerRenderer) {
+        m_layerTreeHost = CACFLayerTreeHost::create();
+        if (m_layerTreeHost) {
             m_isAcceleratedCompositing = true;
 
-            m_layerRenderer->setClient(this);
+            m_layerTreeHost->setClient(this);
             ASSERT(m_viewWindow);
-            m_layerRenderer->setHostWindow(m_viewWindow);
+            m_layerTreeHost->setWindow(m_viewWindow);
 
             // FIXME: We could perhaps get better performance by never allowing this layer to
             // become tiled (or choosing a higher-than-normal tiling threshold).
@@ -6304,7 +6304,7 @@ void WebView::setAcceleratedCompositing(bool accelerated)
             m_backingLayer->setSize(IntRect(clientRect).size());
             m_backingLayer->setNeedsDisplay();
 
-            m_layerRenderer->setRootChildLayer(PlatformCALayer::platformCALayer(m_backingLayer->platformLayer()));
+            m_layerTreeHost->setRootChildLayer(PlatformCALayer::platformCALayer(m_backingLayer->platformLayer()));
 
             // We aren't going to be using our backing store while we're in accelerated compositing
             // mode. But don't delete it immediately, in case we switch out of accelerated
@@ -6312,9 +6312,10 @@ void WebView::setAcceleratedCompositing(bool accelerated)
             deleteBackingStoreSoon();
         }
     } else {
-        ASSERT(m_layerRenderer);
-        m_layerRenderer->setClient(0);
-        m_layerRenderer = 0;
+        ASSERT(m_layerTreeHost);
+        m_layerTreeHost->setClient(0);
+        m_layerTreeHost->setWindow(0);
+        m_layerTreeHost = 0;
         m_backingLayer = 0;
         m_isAcceleratedCompositing = false;
     }
diff --git a/Source/WebKit/win/WebView.h b/Source/WebKit/win/WebView.h
index 68b02da..c81f6d6 100644
--- a/Source/WebKit/win/WebView.h
+++ b/Source/WebKit/win/WebView.h
@@ -40,8 +40,8 @@
 #include <wtf/RefPtr.h>
 
 #if USE(ACCELERATED_COMPOSITING)
+#include <WebCore/CACFLayerTreeHost.h>
 #include <WebCore/PlatformCALayer.h>
-#include <WebCore/WKCACFLayerRenderer.h>
 #endif
 
 class FullscreenVideoController;
@@ -71,7 +71,7 @@ class WebView
     , WebCore::WindowMessageListener
 #if USE(ACCELERATED_COMPOSITING)
     , WebCore::GraphicsLayerClient
-    , WebCore::WKCACFLayerRendererClient
+    , WebCore::CACFLayerTreeHostClient
 #endif
 {
 public:
@@ -947,7 +947,7 @@ private:
     virtual bool showDebugBorders() const;
     virtual bool showRepaintCounter() const;
 
-    // WKCACFLayerRendererClient
+    // CACFLayerTreeHostClient
     virtual bool shouldRender() const;
     virtual void flushPendingGraphicsLayerChanges();
 #endif
@@ -1056,7 +1056,7 @@ protected:
     bool isAcceleratedCompositing() const { return m_isAcceleratedCompositing; }
     void setAcceleratedCompositing(bool);
 
-    RefPtr<WebCore::WKCACFLayerRenderer> m_layerRenderer;
+    RefPtr<WebCore::CACFLayerTreeHost> m_layerTreeHost;
     OwnPtr<WebCore::GraphicsLayer> m_backingLayer;
     bool m_isAcceleratedCompositing;
 #endif
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 84330b8..6bfc039 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-21  Adam Roben  <aroben at apple.com>
+
+        Update for WKCACFLayerRenderer -> CACFLayerView rename
+
+        Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp: Just removed all the unnecessary
+        #includes.
+
 2011-01-20  Darin Adler  <darin at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp
index c07e1f5..cae79c2 100644
--- a/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp
@@ -27,16 +27,6 @@
 
 #include "LayerBackedDrawingArea.h"
 
-#include "DrawingAreaProxyMessageKinds.h"
-#include "WebPage.h"
-#include "WebProcess.h"
-#include <WebCore/Frame.h>
-#include <WebCore/FrameView.h>
-#include <WebCore/GraphicsLayer.h>
-#include <WebCore/Page.h>
-#include <WebCore/WKCACFLayerRenderer.h>
-#include <WebCore/WebCoreInstanceHandle.h>
-
 using namespace WebCore;
 
 namespace WebKit {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list