2011-01-07 Chris Marrin <cmarrin@apple.com>
authorcmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jan 2011 20:00:22 +0000 (20:00 +0000)
committercmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jan 2011 20:00:22 +0000 (20:00 +0000)
        Rubber-stamped by Simon Fraser.

        Share code between Mac (CA) and Windows (CACF) GraphicsLayer implementations
        https://bugs.webkit.org/show_bug.cgi?id=49388

        Final step in unifying GraphicsLayer logic across Win and Mac. This
        implements the Windows side classes for PlatformCALayer and supporting
        classes. Also changed MediaPlayer to use new PlatformCALayerClient
        so it can use PlatformCALayer directly rather than a dummy GraphicsLayer.
        WKCACFLayerRenderer now does the task of notifying animations of their
        start time. Also commented out an assert in AnimationBase because
        AnimationController's frame time is not in sync with the new
        AnimationTimeController. I've opened a new bug for that issue:

            https://bugs.webkit.org/show_bug.cgi?id=52037

        This also includes the Mac side changes backed out in
        http://trac.webkit.org/changeset/75227.

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

44 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/tiling/huge-layer-with-layer-children.html
LayoutTests/compositing/tiling/huge-layer.html
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.vcproj/WebCoreCommon.vsprops
WebCore/WebCore.vcproj/copyForwardingHeaders.cmd
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/config.h
WebCore/page/animation/AnimationBase.cpp
WebCore/page/animation/AnimationController.cpp
WebCore/page/animation/KeyframeAnimation.cpp
WebCore/platform/graphics/GraphicsLayer.h
WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
WebCore/platform/graphics/ca/GraphicsLayerCA.h
WebCore/platform/graphics/ca/PlatformCAAnimation.h
WebCore/platform/graphics/ca/PlatformCALayer.h
WebCore/platform/graphics/ca/PlatformCALayerClient.h [new file with mode: 0644]
WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp [new file with mode: 0644]
WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp [new file with mode: 0644]
WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp [new file with mode: 0644]
WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h [new file with mode: 0644]
WebCore/platform/graphics/mac/WebGLLayer.mm
WebCore/platform/graphics/mac/WebLayer.h
WebCore/platform/graphics/mac/WebLayer.mm
WebCore/platform/graphics/mac/WebTiledLayer.mm
WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
WebCore/platform/graphics/win/WKCACFLayerRenderer.h
WebCore/rendering/RenderLayerBacking.cpp
WebCore/rendering/RenderLayerCompositor.cpp
WebCore/rendering/RenderLayerCompositor.h
WebKit/win/ChangeLog
WebKit/win/FullscreenVideoController.cpp
WebKit/win/FullscreenVideoController.h
WebKit/win/WebCoreSupport/WebChromeClient.cpp
WebKit/win/WebView.cpp
WebKit/win/WebView.h

index c0e4809..cdbbe97 100644 (file)
@@ -1,3 +1,17 @@
+2011-01-07  Chris Marrin  <cmarrin@apple.com>
+
+        Rubber-stamped by Simon Fraser.
+
+        Share code between Mac (CA) and Windows (CACF) GraphicsLayer implementations
+        https://bugs.webkit.org/show_bug.cgi?id=49388
+
+        Use a double nested zero length timer like other tests here do
+        to give the renderer time to do the render and switch into tiled
+        layers.
+
+        * compositing/tiling/huge-layer-with-layer-children.html:
+        * compositing/tiling/huge-layer.html:
+
 2011-01-07  Nate Chapin  <japhet@chromium.org>
 
         Reviewed by Darin Fisher.
index c6da256..ca3d8ff 100644 (file)
 
         function testOnLoad()
         {
+            // Wait for a layer update and the tiled layer to fill in.
             window.setTimeout(function() {
-                if (window.layoutTestController) {
-                    document.getElementById('layers').innerHTML = layoutTestController.layerTreeAsText();
-                    layoutTestController.notifyDone();
-                }
+                window.setTimeout(function() {
+                    if (window.layoutTestController) {
+                        document.getElementById('layers').innerHTML = layoutTestController.layerTreeAsText();
+                        layoutTestController.notifyDone();
+                    }
+                }, 0);
             }, 0);
         }
       
index bede109..12d3db7 100644 (file)
 
         function testOnLoad()
         {
+            // Wait for a layer update and the tiled layer to fill in.
             window.setTimeout(function() {
-                if (window.layoutTestController) {
-                    document.getElementById('layers').innerHTML = layoutTestController.layerTreeAsText();
-                    layoutTestController.notifyDone();
-                }
+                window.setTimeout(function() {
+                    if (window.layoutTestController) {
+                        document.getElementById('layers').innerHTML = layoutTestController.layerTreeAsText();
+                        layoutTestController.notifyDone();
+                    }
+                }, 0);
             }, 0);
         }
       
index ce417b4..3222f30 100644 (file)
@@ -1,3 +1,139 @@
+2011-01-07  Chris Marrin  <cmarrin@apple.com>
+
+        Rubber-stamped by Simon Fraser.
+
+        Share code between Mac (CA) and Windows (CACF) GraphicsLayer implementations
+        https://bugs.webkit.org/show_bug.cgi?id=49388
+
+        Final step in unifying GraphicsLayer logic across Win and Mac. This 
+        implements the Windows side classes for PlatformCALayer and supporting
+        classes. Also changed MediaPlayer to use new PlatformCALayerClient
+        so it can use PlatformCALayer directly rather than a dummy GraphicsLayer.
+        WKCACFLayerRenderer now does the task of notifying animations of their
+        start time. Also commented out an assert in AnimationBase because
+        AnimationController's frame time is not in sync with the new 
+        AnimationTimeController. I've opened a new bug for that issue:
+
+            https://bugs.webkit.org/show_bug.cgi?id=52037
+            
+        This also includes the Mac side changes backed out in 
+        http://trac.webkit.org/changeset/75227.
+
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.vcproj/WebCoreCommon.vsprops:
+        * WebCore.vcproj/copyForwardingHeaders.cmd:
+        * WebCore.xcodeproj/project.pbxproj:
+        * config.h:
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::freezeAtTime):
+        (WebCore::AnimationBase::getElapsedTime):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::beginAnimationUpdateTime):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::fetchIntervalEndpointsForProperty):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::layerDidDisplay):
+        (WebCore::GraphicsLayer::showDebugBorders):
+        (WebCore::GraphicsLayer::showRepaintCounter):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::platformCALayerAnimationStarted):
+        (WebCore::GraphicsLayerCA::setContentsToImage):
+        (WebCore::GraphicsLayerCA::setContentsToMedia):
+        (WebCore::GraphicsLayerCA::layerDidDisplay):
+        (WebCore::GraphicsLayerCA::updateSublayerList):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        (WebCore::GraphicsLayerCA::platformCALayer):
+        (WebCore::GraphicsLayerCA::platformCALayerLayoutSublayersOfLayer):
+        (WebCore::GraphicsLayerCA::platformCALayerRespondsToLayoutChanges):
+        (WebCore::GraphicsLayerCA::platformCALayerContentsOrientation):
+        (WebCore::GraphicsLayerCA::platformCALayerPaintContents):
+        (WebCore::GraphicsLayerCA::platformCALayerShowDebugBorders):
+        (WebCore::GraphicsLayerCA::platformCALayerShowRepaintCounter):
+        (WebCore::GraphicsLayerCA::platformCALayerIncrementRepaintCount):
+        (WebCore::GraphicsLayerCA::platformCALayerContentsOpaque):
+        (WebCore::GraphicsLayerCA::platformCALayerDrawsContent):
+        (WebCore::GraphicsLayerCA::platformCALayerLayerDidDisplay):
+        * platform/graphics/ca/PlatformCAAnimation.h:
+        * platform/graphics/ca/PlatformCALayer.h:
+        (WebCore::PlatformCALayer::owner):
+        (WebCore::PlatformCALayer::animationStarted):
+        * platform/graphics/ca/PlatformCALayerClient.h: Copied from WebCore/platform/graphics/ca/PlatformCALayerClient.h.
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayer::setOwner):
+        (PlatformCALayer::create):
+        (PlatformCALayer::PlatformCALayer):
+        (PlatformCALayer::contents):
+        (PlatformCALayer::setContents):
+        * platform/graphics/ca/win: Added.
+        * platform/graphics/ca/win/PlatformCAAnimationWin.cpp: Added.
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp: Added.
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp: Added.
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.h: Added.
+        (WebCore::PlatformCALayerWinInternal::owner):
+        * platform/graphics/mac/WebGLLayer.mm:
+        (-[WebGLLayer display]):
+        * platform/graphics/mac/WebLayer.h:
+        * platform/graphics/mac/WebLayer.mm:
+        (drawLayerContents):
+        (setLayerNeedsDisplayInRect):
+        (-[WebLayer setNeedsDisplay]):
+        (-[WebLayer display]):
+        * platform/graphics/mac/WebTiledLayer.mm:
+        (-[WebTiledLayer setNeedsDisplay]):
+        (-[WebTiledLayer display]):
+        * platform/graphics/win/GraphicsContextCGWin.cpp:
+        (WebCore::CGContextWithHDC):
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
+        (WebCore::MediaPlayerPrivateFullscreenWindow::setRootChildLayer):
+        (WebCore::MediaPlayerPrivateFullscreenWindow::wndProc):
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
+        (WebCore::MediaPlayerPrivateFullscreenWindow::rootChildLayer):
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::~LayerClient):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerRespondsToLayoutChanges):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerAnimationStarted):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerContentsOrientation):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerPaintContents):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerShowDebugBorders):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerShowRepaintCounter):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerIncrementRepaintCount):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerContentsOpaque):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerDrawsContent):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerLayerDidDisplay):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerLayoutSublayersOfLayer):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::MediaPlayerPrivateQuickTimeVisualContext):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::platformMedia):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie):
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h:
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp:
+        (WebCore::MediaPlayerPrivate::movieNewImageAvailable):
+        (WebCore::MediaPlayerPrivate::createLayerForMovie):
+        * platform/graphics/win/WKCACFLayerRenderer.cpp:
+        (WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer):
+        (WebCore::WKCACFLayerRenderer::rootLayer):
+        (WebCore::WKCACFLayerRenderer::addPendingAnimatedLayer):
+        (WebCore::WKCACFLayerRenderer::setRootChildLayer):
+        (WebCore::WKCACFLayerRenderer::setNeedsDisplay):
+        (WebCore::WKCACFLayerRenderer::destroyRenderer):
+        (WebCore::WKCACFLayerRenderer::render):
+        * platform/graphics/win/WKCACFLayerRenderer.h:
+        (WebCore::WKCACFLayerRendererClient::animationsStarted):
+        (WebCore::WKCACFLayerRendererClient::syncCompositingState):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::showDebugBorders):
+        (WebCore::RenderLayerBacking::showRepaintCounter):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::ensureRootPlatformLayer):
+        * rendering/RenderLayerCompositor.h:
+        (WebCore::RenderLayerCompositor::compositorShowDebugBorders):
+        (WebCore::RenderLayerCompositor::compositorShowRepaintCounter):
+        (WebCore::RenderLayerCompositor::notifyAnimationStarted):
+        (WebCore::RenderLayerCompositor::notifySyncRequired):
+        (WebCore::RenderLayerCompositor::paintContents):
+        (WebCore::RenderLayerCompositor::showDebugBorders):
+        (WebCore::RenderLayerCompositor::showRepaintCounter):
+
 2011-01-07  Nate Chapin  <japhet@chromium.org>
 
         Reviewed by Darin Fisher.
index a7ac692..158721e 100755 (executable)
                                                >
                                        </File>
                                        <File
-                                               RelativePath="..\platform\graphics\win\GraphicsLayerCACF.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\GraphicsLayerCACF.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\IconWin.cpp"
                                                >
                                        </File>
                                                >
                                        </File>
                                        <File
-                                               RelativePath="..\platform\graphics\win\WebLayer.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\WebLayer.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\WebTiledLayer.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\WebTiledLayer.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\WKCACFContextFlusher.cpp"
                                                >
                                                <FileConfiguration
                                                </FileConfiguration>
                                        </File>
                                        <File
-                                               RelativePath="..\platform\graphics\win\WKCACFLayer.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\WKCACFLayer.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\WKCACFLayerRenderer.cpp"
                                                >
                                                <FileConfiguration
                                                >
                                        </File>
                                </Filter>
-                       </Filter>
+                               <Filter
+                                       Name="ca"
+                                       >
+                                       <File
+                                               RelativePath="..\platform\graphics\ca\GraphicsLayerCA.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\platform\graphics\ca\GraphicsLayerCA.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\platform\graphics\ca\PlatformCAAnimation.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\platform\graphics\ca\PlatformCALayer.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\platform\graphics\ca\PlatformCALayerClient.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\platform\graphics\ca\TransformationMatrixCA.cpp"
+                                               >
+                                       </File>
+                                       <Filter
+                                               Name="win"
+                                               >
+                                               <File
+                                                       RelativePath="..\platform\graphics\ca\win\PlatformCAAnimationWin.cpp"
+                                                       >
+                                               </File>
+                                               <File
+                                                       RelativePath="..\platform\graphics\ca\win\PlatformCALayerWin.cpp"
+                                                       >
+                                               </File>
+                                               <File
+                                                       RelativePath="..\platform\graphics\ca\win\PlatformCALayerWinInternal.cpp"
+                                                       >
+                                               </File>
+                                               <File
+                                                       RelativePath="..\platform\graphics\ca\win\PlatformCALayerWinInternal.h"
+                                                       >
+                                               </File>
+                                       </Filter>
+                               </Filter>
+            </Filter>
                        <Filter
                                Name="network"
                                >
index 1753a1c..91e046c 100644 (file)
@@ -7,7 +7,7 @@
        >
        <Tool
                Name="VCCLCompilerTool"
-               AdditionalIncludeDirectories="&quot;$(ProjectDir)..&quot;;&quot;$(ProjectDir)..\accessibility&quot;;&quot;$(ProjectDir)..\accessibility\win&quot;;&quot;$(ProjectDir)..\bridge&quot;;&quot;$(ProjectDir)..\bridge\c&quot;;&quot;$(ProjectDir)..\bridge\jsc&quot;;&quot;$(ProjectDir)..\css&quot;;&quot;$(ProjectDir)..\editing&quot;;&quot;$(ProjectDir)..\fileapi&quot;;&quot;$(ProjectDir)..\rendering&quot;;&quot;$(ProjectDir)..\rendering\style&quot;;&quot;$(ProjectDir)..\rendering\svg&quot;;&quot;$(ProjectDir)..\bindings&quot;;&quot;$(ProjectDir)..\bindings\generic&quot;;&quot;$(ProjectDir)..\bindings\js&quot;;&quot;$(ProjectDir)..\bindings\js\specialization&quot;;&quot;$(ProjectDir)..\dom&quot;;&quot;$(ProjectDir)..\dom\default&quot;;&quot;$(ProjectDir)..\history&quot;;&quot;$(ProjectDir)..\html&quot;;&quot;$(ProjectDir)..\html\canvas&quot;;&quot;$(ProjectDir)..\html\parser&quot;;&quot;$(ProjectDir)..\html\shadow&quot;;&quot;$(ProjectDir)..\inspector&quot;;&quot;$(ProjectDir)..\loader&quot;;&quot;$(ProjectDir)..\loader\appcache&quot;;&quot;$(ProjectDir)..\loader\archive&quot;;&quot;$(ProjectDir)..\loader\archive\cf&quot;;&quot;$(ProjectDir)..\loader\cache&quot;;&quot;$(ProjectDir)..\loader\icon&quot;;&quot;$(ProjectDir)..\mathml&quot;;&quot;$(ProjectDir)..\notifications&quot;;&quot;$(ProjectDir)..\page&quot;;&quot;$(ProjectDir)..\page\animation&quot;;&quot;$(ProjectDir)..\page\win&quot;;&quot;$(ProjectDir)..\platform&quot;;&quot;$(ProjectDir)..\platform\animation&quot;;&quot;$(ProjectDir)..\platform\mock&quot;;&quot;$(ProjectDir)..\platform\sql&quot;;&quot;$(ProjectDir)..\platform\win&quot;;&quot;$(ProjectDir)..\platform\network&quot;;&quot;$(ProjectDir)..\platform\network\win&quot;;&quot;$(ProjectDir)..\platform\cf&quot;;&quot;$(ProjectDir)..\platform\graphics&quot;;&quot;$(ProjectDir)..\platform\graphics\filters&quot;;&quot;$(ProjectDir)..\platform\graphics\opentype&quot;;&quot;$(ProjectDir)..\platform\graphics\transforms&quot;;&quot;$(ProjectDir)..\platform\text&quot;;&quot;$(ProjectDir)..\platform\text\transcoder&quot;;&quot;$(ProjectDir)..\platform\graphics\win&quot;;&quot;$(ProjectDir)..\xml&quot;;&quot;$(ConfigurationBuildDir)\obj\WebCore\DerivedSources&quot;;&quot;$(ProjectDir)..\plugins&quot;;&quot;$(ProjectDir)..\plugins\win&quot;;&quot;$(ProjectDir)..\svg\animation&quot;;&quot;$(ProjectDir)..\svg\graphics&quot;;&quot;$(ProjectDir)..\svg\properties&quot;;&quot;$(ProjectDir)..\svg\graphics\filters&quot;;&quot;$(ProjectDir)..\svg&quot;;&quot;$(ProjectDir)..\wml&quot;;&quot;$(ProjectDir)..\storage&quot;;&quot;$(ProjectDir)..\websockets&quot;;&quot;$(ProjectDir)..\workers&quot;;&quot;$(ConfigurationBuildDir)\include&quot;;&quot;$(ConfigurationBuildDir)\include\private&quot;;&quot;$(ConfigurationBuildDir)\include\JavaScriptCore&quot;;&quot;$(ConfigurationBuildDir)\include\private\JavaScriptCore&quot;;&quot;$(ProjectDir)..\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\private\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;;&quot;$(WebKitLibrariesDir)\include\sqlite&quot;;&quot;$(WebKitLibrariesDir)\include\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\zlib&quot;"
+               AdditionalIncludeDirectories="&quot;$(ProjectDir)..&quot;;&quot;$(ProjectDir)..\accessibility&quot;;&quot;$(ProjectDir)..\accessibility\win&quot;;&quot;$(ProjectDir)..\bridge&quot;;&quot;$(ProjectDir)..\bridge\c&quot;;&quot;$(ProjectDir)..\bridge\jsc&quot;;&quot;$(ProjectDir)..\css&quot;;&quot;$(ProjectDir)..\editing&quot;;&quot;$(ProjectDir)..\fileapi&quot;;&quot;$(ProjectDir)..\rendering&quot;;&quot;$(ProjectDir)..\rendering\style&quot;;&quot;$(ProjectDir)..\rendering\svg&quot;;&quot;$(ProjectDir)..\bindings&quot;;&quot;$(ProjectDir)..\bindings\generic&quot;;&quot;$(ProjectDir)..\bindings\js&quot;;&quot;$(ProjectDir)..\bindings\js\specialization&quot;;&quot;$(ProjectDir)..\dom&quot;;&quot;$(ProjectDir)..\dom\default&quot;;&quot;$(ProjectDir)..\history&quot;;&quot;$(ProjectDir)..\html&quot;;&quot;$(ProjectDir)..\html\canvas&quot;;&quot;$(ProjectDir)..\html\parser&quot;;&quot;$(ProjectDir)..\html\shadow&quot;;&quot;$(ProjectDir)..\inspector&quot;;&quot;$(ProjectDir)..\loader&quot;;&quot;$(ProjectDir)..\loader\appcache&quot;;&quot;$(ProjectDir)..\loader\archive&quot;;&quot;$(ProjectDir)..\loader\archive\cf&quot;;&quot;$(ProjectDir)..\loader\cache&quot;;&quot;$(ProjectDir)..\loader\icon&quot;;&quot;$(ProjectDir)..\mathml&quot;;&quot;$(ProjectDir)..\notifications&quot;;&quot;$(ProjectDir)..\page&quot;;&quot;$(ProjectDir)..\page\animation&quot;;&quot;$(ProjectDir)..\page\win&quot;;&quot;$(ProjectDir)..\platform&quot;;&quot;$(ProjectDir)..\platform\animation&quot;;&quot;$(ProjectDir)..\platform\mock&quot;;&quot;$(ProjectDir)..\platform\sql&quot;;&quot;$(ProjectDir)..\platform\win&quot;;&quot;$(ProjectDir)..\platform\network&quot;;&quot;$(ProjectDir)..\platform\network\win&quot;;&quot;$(ProjectDir)..\platform\cf&quot;;&quot;$(ProjectDir)..\platform\graphics&quot;;&quot;$(ProjectDir)..\platform\graphics\ca&quot;;&quot;$(ProjectDir)..\platform\graphics\filters&quot;;&quot;$(ProjectDir)..\platform\graphics\opentype&quot;;&quot;$(ProjectDir)..\platform\graphics\transforms&quot;;&quot;$(ProjectDir)..\platform\text&quot;;&quot;$(ProjectDir)..\platform\text\transcoder&quot;;&quot;$(ProjectDir)..\platform\graphics\win&quot;;&quot;$(ProjectDir)..\xml&quot;;&quot;$(ConfigurationBuildDir)\obj\WebCore\DerivedSources&quot;;&quot;$(ProjectDir)..\plugins&quot;;&quot;$(ProjectDir)..\plugins\win&quot;;&quot;$(ProjectDir)..\svg\animation&quot;;&quot;$(ProjectDir)..\svg\graphics&quot;;&quot;$(ProjectDir)..\svg\properties&quot;;&quot;$(ProjectDir)..\svg\graphics\filters&quot;;&quot;$(ProjectDir)..\svg&quot;;&quot;$(ProjectDir)..\wml&quot;;&quot;$(ProjectDir)..\storage&quot;;&quot;$(ProjectDir)..\websockets&quot;;&quot;$(ProjectDir)..\workers&quot;;&quot;$(ConfigurationBuildDir)\include&quot;;&quot;$(ConfigurationBuildDir)\include\private&quot;;&quot;$(ConfigurationBuildDir)\include\JavaScriptCore&quot;;&quot;$(ConfigurationBuildDir)\include\private\JavaScriptCore&quot;;&quot;$(ProjectDir)..\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\private\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;;&quot;$(WebKitLibrariesDir)\include\sqlite&quot;;&quot;$(WebKitLibrariesDir)\include\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\zlib&quot;"
                PreprocessorDefinitions="__WIN32__;DISABLE_3D_RENDERING;WEBCORE_CONTEXT_MENUS"
                UsePrecompiledHeader="2"
                PrecompiledHeaderThrough="WebCorePrefix.h"
index d95df81..7393d34 100755 (executable)
@@ -38,6 +38,7 @@ xcopy /y /d "%ProjectDir%..\platform\cf\*.h" "%CONFIGURATIONBUILDDIR%\include\We
 xcopy /y /d "%ProjectDir%..\platform\graphics\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 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\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"
index 0c53e09..783e1d2 100644 (file)
                490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */; };
                490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
                492863991253B8FC00F792D6 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 492863981253B8FC00F792D6 /* ResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 493E5E0812D6420500020081 /* PlatformCALayerClient.h */; };
                49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; };
                49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; };
                49484FC4102CF23C00187DD3 /* CanvasPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB6102CF23C00187DD3 /* CanvasPattern.cpp */; };
                490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = "<group>"; };
                490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
                492863981253B8FC00F792D6 /* ResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadInfo.h; sourceTree = "<group>"; };
+               493E5E0812D6420500020081 /* PlatformCALayerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCALayerClient.h; path = ca/PlatformCALayerClient.h; sourceTree = "<group>"; };
                49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; };
                49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; };
                49484FB5102CF23C00187DD3 /* CanvasGradient.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CanvasGradient.idl; path = canvas/CanvasGradient.idl; sourceTree = "<group>"; };
                                499B3ED5128CD31400E726C2 /* GraphicsLayerCA.h */,
                                499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */,
                                499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
+                               493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
                                494BC40C12AEDD9E00743BD2 /* TransformationMatrixCA.cpp */,
                        );
                        name = ca;
                                7EE6846D12D26E3800E79415 /* ResourceRequest.h in Headers */,
                                7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */,
                                7EE6847012D26E3800E79415 /* ResourceResponse.h in Headers */,
+                               493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 404fa95..49eee8a 100644 (file)
@@ -220,6 +220,11 @@ typedef float CGFloat;
 #define WTF_USE_SAFARI_THEME 1
 #endif
 
+// CoreAnimation is available to IOS, Mac and Windows if using CG
+#if PLATFORM(MAC) || PLATFORM(IOS) || (PLATFORM(WIN) && PLATFORM(CG))
+#define WTF_PLATFORM_CA 1
+#endif
+
 #if PLATFORM(QT) && USE(V8) && defined(Q_WS_X11)
 /* protect ourselves from evil X11 defines */
 #include <bridge/npruntime_internal.h>
index ab551bb..0eb0c84 100644 (file)
@@ -1362,6 +1362,11 @@ void AnimationBase::goIntoEndingOrLoopingState()
   
 void AnimationBase::freezeAtTime(double t)
 {
+    if (!m_startTime) {
+        // If we haven't started yet, just generate the start event now
+        m_compAnim->animationController()->receivedStartTimeResponse(currentTime());
+    }
+
     ASSERT(m_startTime);        // if m_startTime is zero, we haven't started yet, so we'll get a bad pause time.
     m_pauseTime = m_startTime + t - m_animation->delay();
 
@@ -1387,6 +1392,7 @@ double AnimationBase::getElapsedTime() const
         return 0;
     if (postActive())
         return 1;
+
     return beginAnimationUpdateTime() - m_startTime;
 }
     
index a4e0063..3f8d2d9 100644 (file)
@@ -317,6 +317,7 @@ double AnimationControllerPrivate::beginAnimationUpdateTime()
 {
     if (m_beginAnimationUpdateTime == cBeginAnimationUpdateTimeNotSet)
         m_beginAnimationUpdateTime = m_frame->currentAnimationTime();
+
     return m_beginAnimationUpdateTime;
 }
 
index 84d6b97..a499188 100644 (file)
@@ -74,7 +74,11 @@ void KeyframeAnimation::fetchIntervalEndpointsForProperty(int property, const Re
 
     double fractionalTime = m_animation->duration() ? (elapsedTime / m_animation->duration()) : 1;
 
-    ASSERT(fractionalTime >= 0);
+    // FIXME: startTime can be before the current animation "frame" time. This is to sync with the frame time
+    // concept in AnimationTimeController. So we need to somehow sync the two. Until then, the possible
+    // error is small and will probably not be noticeable. Until we fix this, remove the assert.
+    // https://bugs.webkit.org/show_bug.cgi?id=52037
+    // ASSERT(fractionalTime >= 0);
     if (fractionalTime < 0)
         fractionalTime = 0;
 
index 60638e7..fdc8811 100644 (file)
@@ -53,10 +53,7 @@ typedef CALayer PlatformLayer;
 typedef void* PlatformLayer;
 #endif
 #elif PLATFORM(WIN)
-namespace WebCore {
-class WKCACFLayer;
-typedef WKCACFLayer PlatformLayer;
-}
+typedef struct _CACFLayer PlatformLayer;
 #elif PLATFORM(QT)
 #if USE(TEXTURE_MAPPER)
 namespace WebCore {
@@ -314,7 +311,7 @@ public:
     // Callback from the underlying graphics system to draw layer contents.
     void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip);
     // Callback from the underlying graphics system when the layer has been displayed
-    virtual void didDisplay(PlatformLayer*) { }
+    virtual void layerDidDisplay(PlatformLayer*) { }
     
     // For hosting this GraphicsLayer in a native layer hierarchy.
     virtual PlatformLayer* platformLayer() const { return 0; }
@@ -330,8 +327,8 @@ public:
     virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation) { m_contentsOrientation = orientation; }
     CompositingCoordinatesOrientation contentsOrientation() const { return m_contentsOrientation; }
 
-    bool showDebugBorders() { return m_client ? m_client->showDebugBorders() : false; }
-    bool showRepaintCounter() { return m_client ? m_client->showRepaintCounter() : false; }
+    bool showDebugBorders() const { return m_client ? m_client->showDebugBorders() : false; }
+    bool showRepaintCounter() const { return m_client ? m_client->showRepaintCounter() : false; }
     
     void updateDebugIndicators();
     
index 06441d2..c3c58fd 100644 (file)
@@ -640,7 +640,7 @@ void GraphicsLayerCA::removeAnimation(const String& animationName)
     noteLayerPropertyChanged(AnimationChanged);
 }
 
-void GraphicsLayerCA::animationStarted(CFTimeInterval startTime)
+void GraphicsLayerCA::platformCALayerAnimationStarted(CFTimeInterval startTime)
 {
     if (m_client)
         m_client->notifyAnimationStarted(this, startTime);
@@ -660,6 +660,8 @@ void GraphicsLayerCA::setContentsToImage(Image* image)
         
         m_uncorrectedContentsImage = newImage;
         m_pendingContentsImage = newImage;
+
+#if !PLATFORM(WIN)
         CGColorSpaceRef colorSpace = CGImageGetColorSpace(m_pendingContentsImage.get());
 
         static CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
@@ -669,6 +671,7 @@ void GraphicsLayerCA::setContentsToImage(Image* image)
             static CGColorSpaceRef genericRGB = CGDisplayCopyColorSpace(kCGDirectMainDisplay);
             m_pendingContentsImage.adoptCF(CGImageCreateCopyWithColorSpace(m_pendingContentsImage.get(), genericRGB));
         }
+#endif
         m_contentsLayerPurpose = ContentsLayerForImage;
         if (!m_contentsLayer)
             noteSublayersChanged();
@@ -688,9 +691,15 @@ void GraphicsLayerCA::setContentsToMedia(PlatformLayer* mediaLayer)
     if (m_contentsLayer && mediaLayer == m_contentsLayer->platformLayer())
         return;
         
-    // Create the PlatformCALayer to wrap the incoming layer
-    m_contentsLayer = mediaLayer ? PlatformCALayer::create(mediaLayer, this) : 0;
-
+    // FIXME: The passed in layer might be a raw layer or an externally created 
+    // PlatformCALayer. To determine this we attempt to get the
+    // PlatformCALayer pointer. If this returns a null pointer we assume it's
+    // raw. This test might be invalid if the raw layer is, for instance, the
+    // PlatformCALayer is using a user data pointer in the raw layer, and
+    // the creator of the raw layer is using it for some other purpose.
+    // For now we don't support such a case.
+    PlatformCALayer* platformCALayer = PlatformCALayer::platformCALayer(mediaLayer);
+    m_contentsLayer = mediaLayer ? (platformCALayer ? platformCALayer : PlatformCALayer::create(mediaLayer, this)) : 0;
     m_contentsLayerPurpose = mediaLayer ? ContentsLayerForMedia : NoContentsLayer;
 
     noteSublayersChanged();
@@ -711,7 +720,7 @@ void GraphicsLayerCA::setContentsToCanvas(PlatformLayer* canvasLayer)
     noteLayerPropertyChanged(ContentsCanvasLayerChanged);
 }
     
-void GraphicsLayerCA::didDisplay(PlatformLayer* layer)
+void GraphicsLayerCA::layerDidDisplay(PlatformLayer* layer)
 {
     PlatformCALayer* currentLayer = PlatformCALayer::platformCALayer(layer);
     PlatformCALayer* sourceLayer;
@@ -903,7 +912,7 @@ void GraphicsLayerCA::updateSublayerList()
             newSublayers.append(childLayer);
         }
 
-        for (size_t i = 0; i < newSublayers.size(); ++i)
+        for (size_t i = 0; i < newSublayers.size(); --i)
             newSublayers[i]->removeFromSuperlayer();
     }
 
index 22921c1..13cbdd1 100644 (file)
@@ -31,6 +31,7 @@
 #include "GraphicsLayer.h"
 #include "Image.h"
 #include "PlatformCAAnimation.h"
+#include "PlatformCALayerClient.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/RetainPtr.h>
@@ -40,7 +41,7 @@ namespace WebCore {
 
 class PlatformCALayer;
 
-class GraphicsLayerCA : public GraphicsLayer {
+class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
 public:
     // The width and height of a single tile in a tiled layer. Should be large enough to
     // avoid lots of small tiles (and therefore lots of drawing callbacks), but small enough
@@ -49,12 +50,11 @@ public:
 
     GraphicsLayerCA(GraphicsLayerClient*);
     virtual ~GraphicsLayerCA();
-    
-    virtual void animationStarted(CFTimeInterval beginTime);
 
     virtual void setName(const String&);
 
     virtual PlatformLayer* platformLayer() const;
+    virtual PlatformCALayer* platformCALayer() const { return primaryLayer(); }
 
     virtual bool setChildren(const Vector<GraphicsLayer*>&);
     virtual void addChild(GraphicsLayer*);
@@ -112,7 +112,7 @@ public:
     virtual void setDebugBackgroundColor(const Color&);
     virtual void setDebugBorder(const Color&, float borderWidth);
 
-    virtual void didDisplay(PlatformLayer*);
+    virtual void layerDidDisplay(PlatformLayer*);
 
     void recursiveCommitChanges();
 
@@ -123,6 +123,21 @@ protected:
     virtual void setOpacityInternal(float);
 
 private:
+    // PlatformCALayerClient overrides
+    virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { }
+    virtual bool platformCALayerRespondsToLayoutChanges() const { return false; }
+
+    virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime);
+    virtual CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return contentsOrientation(); }
+    virtual void platformCALayerPaintContents(GraphicsContext& context, const IntRect& clip) { paintGraphicsLayerContents(context, clip); }
+    virtual bool platformCALayerShowDebugBorders() const { return showDebugBorders(); }
+    virtual bool platformCALayerShowRepaintCounter() const { return showRepaintCounter(); }
+    virtual int platformCALayerIncrementRepaintCount() { return incrementRepaintCount(); }
+
+    virtual bool platformCALayerContentsOpaque() const { return contentsOpaque(); }
+    virtual bool platformCALayerDrawsContent() const { return drawsContent(); }
+    virtual void platformCALayerLayerDidDisplay(PlatformLayer* layer) { return layerDidDisplay(layer); }
+
     void updateOpacityOnLayer();
 
     PlatformCALayer* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); }
index d802700..4bfce63 100644 (file)
@@ -44,10 +44,8 @@ typedef void* CAPropertyAnimation; // So the m_animation declaration works
 typedef void* PlatformAnimationRef;
 #endif
 #elif PLATFORM(WIN)
-namespace WebCore {
-class WKCACFAnimation;
-typedef WKCACFAnimation* PlatformAnimationRef;
-}
+typedef struct _CACFAnimation* CACFAnimationRef;
+typedef CACFAnimationRef PlatformAnimationRef;
 #endif
 
 namespace WebCore {
index 9cf0ccb..46f4bbf 100644 (file)
@@ -29,8 +29,8 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "GraphicsContext.h"
-#include "GraphicsLayerCA.h"
 #include "PlatformCAAnimation.h"
+#include "PlatformCALayerClient.h"
 #include "PlatformString.h"
 #include <wtf/HashMap.h>
 #include <wtf/PassRefPtr.h>
@@ -47,27 +47,17 @@ typedef Vector<RefPtr<PlatformCALayer> > PlatformCALayerList;
 
 class PlatformCALayer : public RefCounted<PlatformCALayer> {
 public:
-    // TiledLayer used in GraphicsLayer has constant settings:
-    //      cTiledLayerTileSize = 512
-    //      setTileSize:(cTiledLayerTileSize, cTiledLayerTileSize)
-    //      setLevelsOfDetail:1
-    //      setLevelsOfDetailBias:0
-    //      setContentsGravity:@"bottomLeft"
-    //
-    // TiledLayer also has drawing functions like WebLayer
-    //
-    // WebLayer is a CALayer with drawing functions specific to WebKit
-    //
-    // Layer and TransformLayer are used as is
-
-    enum LayerType { LayerTypeLayer, LayerTypeWebLayer, LayerTypeTransformLayer, LayerTypeWebTiledLayer, LayerTypeCustom };
+    // LayerTypeRootLayer is used on some platforms. It has no backing store, so setNeedsDisplay
+    // should not call CACFLayerSetNeedsDisplay, but rather just notify the renderer that it
+    // has changed and should be re-rendered.
+    enum LayerType { LayerTypeLayer, LayerTypeWebLayer, LayerTypeTransformLayer, LayerTypeWebTiledLayer, LayerTypeRootLayer, LayerTypeCustom };
     enum FilterType { Linear, Nearest, Trilinear };
 
-    static PassRefPtr<PlatformCALayer> create(LayerType, GraphicsLayerCA*);
+    static PassRefPtr<PlatformCALayer> create(LayerType, PlatformCALayerClient*);
     
     // This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
     // is defined differently for Obj C and C++. This allows callers from both languages.
-    static PassRefPtr<PlatformCALayer> create(void* platformLayer, GraphicsLayerCA*);
+    static PassRefPtr<PlatformCALayer> create(void* platformLayer, PlatformCALayerClient*);
 
     ~PlatformCALayer();
     
@@ -76,20 +66,29 @@ public:
     static PlatformCALayer* platformCALayer(void* platformLayer);
     
     PlatformLayer* platformLayer() const;
+
+    PlatformCALayer* rootLayer() const;
     
     static bool isValueFunctionSupported();
     
-    GraphicsLayerCA* owner() const { return m_owner; }
-    void setOwner(GraphicsLayerCA* owner);
+    PlatformCALayerClient* owner() const { return m_owner; }
+    void setOwner(PlatformCALayerClient*);
 
     void animationStarted(CFTimeInterval beginTime)
     {
         if (m_owner)
-            m_owner->animationStarted(beginTime);
+            m_owner->platformCALayerAnimationStarted(beginTime);
     }
 
+    // Layout support
+    void setNeedsLayout();
+
+
     void setNeedsDisplay(const FloatRect* dirtyRect = 0);
     
+    // This tells the layer tree to commit changes and perform a render, without do a setNeedsDisplay on any layer.
+    void setNeedsCommit();
+
     void setContentsChanged();
     
     LayerType layerType() const { return m_layerType; }
@@ -104,6 +103,7 @@ public:
     size_t sublayerCount() const;
 
     // This method removes the sublayers from the source and reparents them to the current layer.
+    // Any sublayers previously in the current layer are removed.
     void adoptSublayers(PlatformCALayer* source);
     
     void addAnimationForKey(const String& key, PlatformCAAnimation* animation);    
@@ -150,8 +150,8 @@ public:
     bool acceleratesDrawing() const;
     void setAcceleratesDrawing(bool);
 
-    void* contents() const;
-    void setContents(void*);
+    CFTypeRef contents() const;
+    void setContents(CFTypeRef);
 
     FloatRect contentsRect() const;
     void setContentsRect(const FloatRect&);
@@ -183,18 +183,25 @@ public:
     CFTimeInterval timeOffset() const;
     void setTimeOffset(CFTimeInterval);
 
+#if PLATFORM(WIN) && !defined(NDEBUG)
+    void printTree() const;
+#endif
+
 protected:
-    PlatformCALayer(LayerType, PlatformLayer*, GraphicsLayerCA*);
+    PlatformCALayer(LayerType, PlatformLayer*, PlatformCALayerClient*);
     
 private:
-    
-    GraphicsLayerCA* m_owner;
+    PlatformCALayerClient* m_owner;
     LayerType m_layerType;
     
 #if PLATFORM(MAC) || PLATFORM(WIN)
     RetainPtr<PlatformLayer> m_layer;
 #endif
 
+#if PLATFORM(WIN)
+    HashMap<String, RefPtr<PlatformCAAnimation> > m_animations;
+#endif
+
 #if PLATFORM(MAC)
 #ifdef __OBJC__
     RetainPtr<NSObject> m_delegate;
diff --git a/WebCore/platform/graphics/ca/PlatformCALayerClient.h b/WebCore/platform/graphics/ca/PlatformCALayerClient.h
new file mode 100644 (file)
index 0000000..ae1815c
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 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 PlatformCALayerClient_h
+#define PlatformCALayerClient_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "GraphicsContext.h"
+#include "GraphicsLayer.h"
+#include "PlatformCAAnimation.h"
+#include "PlatformString.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class PlatformCALayer;
+
+class PlatformCALayerClient {
+public:
+    virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) = 0;
+    virtual bool platformCALayerRespondsToLayoutChanges() const = 0;
+
+    virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) = 0;
+    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const = 0;
+    virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) = 0;
+    virtual bool platformCALayerShowDebugBorders() const = 0;
+    virtual bool platformCALayerShowRepaintCounter() const = 0;
+    virtual int platformCALayerIncrementRepaintCount() = 0;
+    
+    virtual bool platformCALayerContentsOpaque() const = 0;
+    virtual bool platformCALayerDrawsContent() const = 0;
+    virtual void platformCALayerLayerDidDisplay(PlatformLayer*) = 0;
+
+protected:
+    virtual ~PlatformCALayerClient() {}
+};
+
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // PlatformCALayerClient_h
index 0aecf14..28460a7 100644 (file)
@@ -105,7 +105,7 @@ bool PlatformCALayer::isValueFunctionSupported()
     return sHaveValueFunction;
 }
 
-void PlatformCALayer::setOwner(GraphicsLayerCA* owner)
+void PlatformCALayer::setOwner(PlatformCALayerClient* owner)
 {
     m_owner = owner;
     
@@ -145,17 +145,17 @@ static NSString* toCAFilterType(PlatformCALayer::FilterType type)
 }
 #endif
 
-PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, GraphicsLayerCA* owner)
+PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, PlatformCALayerClient* owner)
 {
     return adoptRef(new PlatformCALayer(layerType, 0, owner));
 }
 
-PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, GraphicsLayerCA* owner)
+PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, PlatformCALayerClient* owner)
 {
     return adoptRef(new PlatformCALayer(LayerTypeCustom, static_cast<PlatformLayer*>(platformLayer), owner));
 }
 
-PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, GraphicsLayerCA* owner)
+PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
     : m_owner(owner)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
@@ -168,6 +168,7 @@ PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, Grap
         Class layerClass = Nil;
         switch(layerType) {
             case LayerTypeLayer:
+            case LayerTypeRootLayer:
                 layerClass = [CALayer class];
                 break;
             case LayerTypeWebLayer:
@@ -568,15 +569,15 @@ void PlatformCALayer::setAcceleratesDrawing(bool acceleratesDrawing)
 #endif
 }
 
-void* PlatformCALayer::contents() const
+CFTypeRef PlatformCALayer::contents() const
 {
     return [m_layer.get() contents];
 }
 
-void PlatformCALayer::setContents(void* value)
+void PlatformCALayer::setContents(CFTypeRef value)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
-    [m_layer.get() setContents:static_cast<id>(value)];
+    [m_layer.get() setContents:static_cast<id>(const_cast<void*>(value))];
     END_BLOCK_OBJC_EXCEPTIONS
 }
 
diff --git a/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp b/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
new file mode 100644 (file)
index 0000000..7230cfc
--- /dev/null
@@ -0,0 +1,538 @@
+/*
+ * Copyright (C) 2011 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)
+
+#include "PlatformCAAnimation.h"
+
+#include "FloatConversion.h"
+#include "PlatformString.h"
+#include "TimingFunction.h"
+#include <QuartzCore/CACFAnimation.h>
+#include <QuartzCore/CACFTiming.h>
+#include <QuartzCore/CACFTimingFunction.h>
+#include <QuartzCore/CACFValueFunction.h>
+#include <QuartzCore/CACFVector.h>
+#include <wtf/UnusedParam.h>
+
+using namespace WebCore;
+
+static String toCACFFillModeType(PlatformCAAnimation::FillModeType type)
+{
+    switch (type) {
+    case PlatformCAAnimation::NoFillMode:
+    case PlatformCAAnimation::Forwards: return kCACFFillModeForwards;
+    case PlatformCAAnimation::Backwards: return kCACFFillModeBackwards;
+    case PlatformCAAnimation::Both: return kCACFFillModeBoth;
+    }
+    return "";
+}
+
+static PlatformCAAnimation::FillModeType fromCACFFillModeType(const String& string)
+{
+    if (string == kCACFFillModeBackwards)
+        return PlatformCAAnimation::Backwards;
+
+    if (string == kCACFFillModeBoth)
+        return PlatformCAAnimation::Both;
+
+    return PlatformCAAnimation::Forwards;
+}
+
+static String toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
+{
+    switch (type) {
+    case PlatformCAAnimation::NoValueFunction: return "";
+    case PlatformCAAnimation::RotateX: return kCACFValueFunctionRotateX;
+    case PlatformCAAnimation::RotateY: return kCACFValueFunctionRotateY;
+    case PlatformCAAnimation::RotateZ: return kCACFValueFunctionRotateZ;
+    case PlatformCAAnimation::ScaleX: return kCACFValueFunctionScaleX;
+    case PlatformCAAnimation::ScaleY: return kCACFValueFunctionScaleY;
+    case PlatformCAAnimation::ScaleZ: return kCACFValueFunctionScaleZ;
+    case PlatformCAAnimation::Scale: return kCACFValueFunctionScale;
+    case PlatformCAAnimation::TranslateX: return kCACFValueFunctionTranslateX;
+    case PlatformCAAnimation::TranslateY: return kCACFValueFunctionTranslateY;
+    case PlatformCAAnimation::TranslateZ: return kCACFValueFunctionTranslateZ;
+    case PlatformCAAnimation::Translate: return kCACFValueFunctionTranslate;
+    }
+    return "";
+}
+
+static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(const String string)
+{
+    if (string == kCACFValueFunctionRotateX)
+        return PlatformCAAnimation::RotateX;
+
+    if (string == kCACFValueFunctionRotateY)
+        return PlatformCAAnimation::RotateY;
+
+    if (string == kCACFValueFunctionRotateZ)
+        return PlatformCAAnimation::RotateZ;
+
+    if (string == kCACFValueFunctionScaleX)
+        return PlatformCAAnimation::ScaleX;
+
+    if (string == kCACFValueFunctionScaleY)
+        return PlatformCAAnimation::ScaleY;
+
+    if (string == kCACFValueFunctionScaleZ)
+        return PlatformCAAnimation::ScaleZ;
+
+    if (string == kCACFValueFunctionScale)
+        return PlatformCAAnimation::Scale;
+
+    if (string == kCACFValueFunctionTranslateX)
+        return PlatformCAAnimation::TranslateX;
+
+    if (string == kCACFValueFunctionTranslateY)
+        return PlatformCAAnimation::TranslateY;
+
+    if (string == kCACFValueFunctionTranslateZ)
+        return PlatformCAAnimation::TranslateZ;
+
+    if (string == kCACFValueFunctionTranslate)
+        return PlatformCAAnimation::Translate;
+
+    return PlatformCAAnimation::NoValueFunction;
+}
+
+static CACFTimingFunctionRef toCACFTimingFunction(const TimingFunction* timingFunction)
+{
+    if (!timingFunction)
+        return CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f);
+            
+    if (timingFunction->isCubicBezierTimingFunction()) {
+        const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(timingFunction);
+        return CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2()));
+    }
+    
+    return CACFTimingFunctionGetFunctionWithName(kCACFTimingFunctionLinear);
+}
+
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(AnimationType type, const String& keyPath)
+{
+    return adoptRef(new PlatformCAAnimation(type, keyPath));
+}
+
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(PlatformAnimationRef animation)
+{
+    return adoptRef(new PlatformCAAnimation(animation));
+}
+
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(const PlatformCAAnimation* animation)
+{
+    return adoptRef(new PlatformCAAnimation(animation));
+}
+
+PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPath)
+    : m_type(type)
+{
+    if (type == Basic)
+        m_animation.adoptCF(CACFAnimationCreate(kCACFBasicAnimation));
+    else
+        m_animation.adoptCF(CACFAnimationCreate(kCACFKeyframeAnimation));
+    
+    RetainPtr<CFStringRef> s(AdoptCF, keyPath.createCFString());
+    CACFAnimationSetKeyPath(m_animation.get(), s.get());
+}
+
+PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
+{
+    if (String(CACFAnimationGetClass(animation)) == kCACFBasicAnimation)
+        m_type = Basic;
+    else if (String(CACFAnimationGetClass(animation)) == kCACFKeyframeAnimation)
+        m_type = Keyframe;
+    else {
+        ASSERT(0);
+        return;
+    }
+    
+    m_animation = animation;
+}
+
+PlatformCAAnimation::PlatformCAAnimation(const PlatformCAAnimation* animation)
+{
+    m_animation.adoptCF(CACFAnimationCreate((animation->animationType() == Basic) ? kCACFBasicAnimation : kCACFKeyframeAnimation));
+    RetainPtr<CFStringRef> keyPath(AdoptCF, animation->keyPath().createCFString());
+    CACFAnimationSetKeyPath(m_animation.get(), keyPath.get());
+
+    setBeginTime(animation->beginTime());
+    setDuration(animation->duration());
+    setSpeed(animation->speed());
+    setTimeOffset(animation->timeOffset());
+    setRepeatCount(animation->repeatCount());
+    setAutoreverses(animation->autoreverses());
+    setFillMode(animation->fillMode());
+    setRemovedOnCompletion(animation->isRemovedOnCompletion());
+    setAdditive(animation->isAdditive());
+    copyTimingFunctionFrom(animation);
+    setValueFunction(animation->valueFunction());
+
+    // Copy the specific Basic or Keyframe values
+    if (animation->animationType() == Keyframe) {
+        copyValuesFrom(animation);
+        copyKeyTimesFrom(animation);
+        copyTimingFunctionsFrom(animation);
+    } else {
+        copyFromValueFrom(animation);
+        copyToValueFrom(animation);
+    }
+}
+
+PlatformCAAnimation::~PlatformCAAnimation()
+{
+}
+
+bool PlatformCAAnimation::supportsValueFunction()
+{
+    return true;
+}
+
+PlatformAnimationRef PlatformCAAnimation::platformAnimation() const
+{
+    return m_animation.get();
+}
+
+String PlatformCAAnimation::keyPath() const
+{
+    return CACFAnimationGetKeyPath(m_animation.get());
+}
+
+CFTimeInterval PlatformCAAnimation::beginTime() const
+{
+    return CACFAnimationGetBeginTime(m_animation.get());
+}
+
+void PlatformCAAnimation::setBeginTime(CFTimeInterval value)
+{
+    CACFAnimationSetBeginTime(m_animation.get(), value);
+}
+
+CFTimeInterval PlatformCAAnimation::duration() const
+{
+    return CACFAnimationGetDuration(m_animation.get());
+}
+
+void PlatformCAAnimation::setDuration(CFTimeInterval value)
+{
+    CACFAnimationSetDuration(m_animation.get(), value);
+}
+
+float PlatformCAAnimation::speed() const
+{
+    return CACFAnimationGetSpeed(m_animation.get());
+}
+
+void PlatformCAAnimation::setSpeed(float value)
+{
+    CACFAnimationSetSpeed(m_animation.get(), value);
+}
+
+CFTimeInterval PlatformCAAnimation::timeOffset() const
+{
+    return CACFAnimationGetTimeOffset(m_animation.get());
+}
+
+void PlatformCAAnimation::setTimeOffset(CFTimeInterval value)
+{
+    CACFAnimationSetTimeOffset(m_animation.get(), value);
+}
+
+float PlatformCAAnimation::repeatCount() const
+{
+    return CACFAnimationGetRepeatCount(m_animation.get());
+}
+
+void PlatformCAAnimation::setRepeatCount(float value)
+{
+    CACFAnimationSetRepeatCount(m_animation.get(), value);
+}
+
+bool PlatformCAAnimation::autoreverses() const
+{
+    return CACFAnimationGetAutoreverses(m_animation.get());
+}
+
+void PlatformCAAnimation::setAutoreverses(bool value)
+{
+    CACFAnimationSetAutoreverses(m_animation.get(), value);
+}
+
+PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const
+{
+    return fromCACFFillModeType(CACFAnimationGetFillMode(m_animation.get()));
+}
+
+void PlatformCAAnimation::setFillMode(FillModeType value)
+{
+    RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFFillModeType(value).createCFString());
+    CACFAnimationSetFillMode(m_animation.get(), keyPath.get());
+}
+
+void PlatformCAAnimation::setTimingFunction(const TimingFunction* value)
+{
+    CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value));
+}
+
+void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value)
+{
+    CACFAnimationSetTimingFunction(m_animation.get(), CACFAnimationGetTimingFunction(value->m_animation.get()));
+}
+
+bool PlatformCAAnimation::isRemovedOnCompletion() const
+{
+    return CACFAnimationIsRemovedOnCompletion(m_animation.get());
+}
+
+void PlatformCAAnimation::setRemovedOnCompletion(bool value)
+{
+    CACFAnimationSetRemovedOnCompletion(m_animation.get(), value);
+}
+
+bool PlatformCAAnimation::isAdditive() const
+{
+    return CACFAnimationIsAdditive(m_animation.get());
+}
+
+void PlatformCAAnimation::setAdditive(bool value)
+{
+    CACFAnimationSetAdditive(m_animation.get(), value);
+}
+
+PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() const
+{
+    return fromCACFValueFunctionType(CACFValueFunctionGetName(CACFAnimationGetValueFunction(m_animation.get())));
+}
+
+void PlatformCAAnimation::setValueFunction(ValueFunctionType value)
+{
+    RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFValueFunctionType(value).createCFString());
+    CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(keyPath.get()));
+}
+
+void PlatformCAAnimation::setFromValue(float value)
+{
+    if (animationType() != Basic)
+        return;
+
+    RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value));
+    CACFAnimationSetFromValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& value)
+{
+    if (animationType() != Basic)
+        return;
+    
+    RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreateTransform(value));
+    CACFAnimationSetFromValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    float a[3] = { value.x(), value.y(), value.z() };
+    RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(3, a));
+    CACFAnimationSetFromValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    float a[4] = { value.red(), value.green(), value.blue(), value.alpha() };
+    RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(4, a));
+    CACFAnimationSetFromValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::copyFromValueFrom(const PlatformCAAnimation* value)
+{
+    if (animationType() != Basic || value->animationType() != Basic)
+        return;
+    
+    CACFAnimationSetFromValue(m_animation.get(), CACFAnimationGetFromValue(value->platformAnimation()));
+}
+
+void PlatformCAAnimation::setToValue(float value)
+{
+    if (animationType() != Basic)
+        return;
+
+    RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value));
+    CACFAnimationSetToValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreateTransform(value));
+    CACFAnimationSetToValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    float a[3] = { value.x(), value.y(), value.z() };
+    RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(3, a));
+    CACFAnimationSetToValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::setToValue(const WebCore::Color& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    float a[4] = { value.red(), value.green(), value.blue(), value.alpha() };
+    RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(4, a));
+    CACFAnimationSetToValue(m_animation.get(), v.get());
+}
+
+void PlatformCAAnimation::copyToValueFrom(const PlatformCAAnimation* value)
+{
+    if (animationType() != Basic || value->animationType() != Basic)
+        return;
+        
+    CACFAnimationSetToValue(m_animation.get(), CACFAnimationGetToValue(value->platformAnimation()));
+}
+
+
+// Keyframe-animation properties.
+void PlatformCAAnimation::setValues(const Vector<float>& value)
+{
+    if (animationType() != Keyframe)
+        return;
+
+    RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < value.size(); ++i) {
+        RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
+        CFArrayAppendValue(array.get(), v.get());
+    }
+
+    CACFAnimationSetValues(m_animation.get(), array.get());
+}
+
+void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>& value)
+{
+    if (animationType() != Keyframe)
+        return;
+
+    RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < value.size(); ++i) {
+        RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreateTransform(value[i]));
+        CFArrayAppendValue(array.get(), v.get());
+    }
+
+    CACFAnimationSetValues(m_animation.get(), array.get());
+}
+
+void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
+{
+    if (animationType() != Keyframe)
+        return;
+        
+    RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < value.size(); ++i) {
+        float a[3] = { value[i].x(), value[i].y(), value[i].z() };
+        RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(3, a));
+        CFArrayAppendValue(array.get(), v.get());
+    }
+
+    CACFAnimationSetValues(m_animation.get(), array.get());
+}
+
+void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
+{
+    if (animationType() != Keyframe)
+        return;
+        
+    RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < value.size(); ++i) {
+        float a[4] = { value[i].red(), value[i].green(), value[i].blue(), value[i].alpha() };
+        RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(4, a));
+        CFArrayAppendValue(array.get(), v.get());
+    }
+
+    CACFAnimationSetValues(m_animation.get(), array.get());
+}
+
+void PlatformCAAnimation::copyValuesFrom(const PlatformCAAnimation* value)
+{
+    if (animationType() != Keyframe || value->animationType() != Keyframe)
+        return;
+    
+    CACFAnimationSetValues(m_animation.get(), CACFAnimationGetValues(value->platformAnimation()));
+}
+
+void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
+{
+    if (animationType() != Keyframe)
+        return;
+        
+    RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < value.size(); ++i) {
+        RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
+        CFArrayAppendValue(array.get(), v.get());
+    }
+
+    CACFAnimationSetKeyTimes(m_animation.get(), array.get());
+}
+
+void PlatformCAAnimation::copyKeyTimesFrom(const PlatformCAAnimation* value)
+{
+    if (animationType() != Keyframe)
+        return;
+
+    CACFAnimationSetKeyTimes(m_animation.get(), CACFAnimationGetKeyTimes(value->platformAnimation()));
+}
+
+void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>& value)
+{
+    if (animationType() != Keyframe)
+        return;
+
+    RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < value.size(); ++i) {
+        RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
+        CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i]));
+    }
+
+    CACFAnimationSetTimingFunctions(m_animation.get(), array.get());
+}
+
+void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
+{
+    CACFAnimationSetTimingFunctions(m_animation.get(), CACFAnimationGetTimingFunctions(value->platformAnimation()));
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
new file mode 100644 (file)
index 0000000..7f52fdf
--- /dev/null
@@ -0,0 +1,713 @@
+/*
+ * Copyright (C) 2011 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)
+
+#include "PlatformCALayer.h"
+
+#include "Font.h"
+#include "GraphicsContext.h"
+#include "PlatformCALayerWinInternal.h"
+#include "WKCACFLayerRenderer.h"
+#include <QuartzCore/CACFAnimation.h>
+#include <QuartzCore/CACFContext.h>
+#include <QuartzCore/CACFLayer.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+bool PlatformCALayer::isValueFunctionSupported()
+{
+    return true;
+}
+
+void PlatformCALayer::setOwner(PlatformCALayerClient* owner)
+{
+    m_owner = owner;
+}
+
+static CFStringRef toCACFLayerType(PlatformCALayer::LayerType type)
+{
+    return (type == PlatformCALayer::LayerTypeTransformLayer) ? kCACFTransformLayer : kCACFLayer;
+}
+
+static CFStringRef toCACFFilterType(PlatformCALayer::FilterType type)
+{
+    switch (type) {
+    case PlatformCALayer::Linear: return kCACFFilterLinear;
+    case PlatformCALayer::Nearest: return kCACFFilterNearest;
+    case PlatformCALayer::Trilinear: return kCACFFilterTrilinear;
+    default: return 0;
+    }
+}
+
+static WKCACFLayerRenderer* rendererForLayer(const PlatformCALayer* layer)
+{
+    // We need the WKCACFLayerRenderer associated with this layer, which is stored in the UserData of the CACFContext
+    CACFContextRef context = CACFLayerGetContext(layer->platformLayer());
+    if (!context)
+        return 0;
+
+    WKCACFLayerRenderer* renderer = static_cast<WKCACFLayerRenderer*>(CACFContextGetUserData(context));
+    ASSERT(renderer);
+    return renderer;
+}
+
+static PlatformCALayerWinInternal* intern(const PlatformCALayer* layer)
+{
+    return static_cast<PlatformCALayerWinInternal*>(CACFLayerGetUserData(layer->platformLayer()));
+}
+
+static PlatformCALayerWinInternal* intern(void* layer)
+{
+    return static_cast<PlatformCALayerWinInternal*>(CACFLayerGetUserData(static_cast<CACFLayerRef>(layer)));
+}
+
+PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, PlatformCALayerClient* owner)
+{
+    return adoptRef(new PlatformCALayer(layerType, 0, owner));
+}
+
+PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, PlatformCALayerClient* owner)
+{
+    return adoptRef(new PlatformCALayer(LayerTypeCustom, static_cast<PlatformLayer*>(platformLayer), owner));
+}
+
+static void displayCallback(CACFLayerRef caLayer, CGContextRef context)
+{
+    ASSERT_ARG(caLayer, CACFLayerGetUserData(caLayer));
+    intern(caLayer)->displayCallback(caLayer, context);
+}
+
+static void layoutSublayersProc(CACFLayerRef caLayer) 
+{
+    PlatformCALayer* layer = PlatformCALayer::platformCALayer(caLayer);
+    if (layer && layer->owner())
+        layer->owner()->platformCALayerLayoutSublayersOfLayer(layer);
+}
+
+PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
+    : m_owner(owner)
+{
+    if (layer) {
+        m_layerType = LayerTypeCustom;
+        m_layer = layer;
+    } else {
+        m_layerType = layerType;
+        m_layer.adoptCF(CACFLayerCreate(toCACFLayerType(layerType)));
+
+        // Create the PlatformCALayerWinInternal object and point to it in the userdata.
+        PlatformCALayerWinInternal* intern = new PlatformCALayerWinInternal(this);
+        CACFLayerSetUserData(m_layer.get(), intern);
+
+        // Set the display callback
+        CACFLayerSetDisplayCallback(m_layer.get(), displayCallback);
+        CACFLayerSetLayoutCallback(m_layer.get(), layoutSublayersProc);    
+    }
+}
+
+PlatformCALayer::~PlatformCALayer()
+{
+    // Toss all the kids
+    removeAllSublayers();
+
+    // Get rid of the user data
+    PlatformCALayerWinInternal* layerIntern = intern(this);
+    CACFLayerSetUserData(m_layer.get(), 0);
+
+    delete layerIntern;
+}
+
+PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)
+{
+    if (!platformLayer)
+        return 0;
+    
+    PlatformCALayerWinInternal* layerIntern = intern(platformLayer);
+    return layerIntern ? layerIntern->owner() : 0;
+}
+
+PlatformLayer* PlatformCALayer::platformLayer() const
+{
+    return m_layer.get();
+}
+
+PlatformCALayer* PlatformCALayer::rootLayer() const
+{
+    WKCACFLayerRenderer* renderer = rendererForLayer(this);
+    return renderer ? renderer->rootLayer() : 0;
+}
+
+void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect)
+{
+    intern(this)->setNeedsDisplay(dirtyRect);
+}
+    
+void PlatformCALayer::setNeedsCommit()
+{
+    WKCACFLayerRenderer* renderer = rendererForLayer(this);
+    if (renderer)
+        renderer->layerTreeDidChange();
+}
+
+void PlatformCALayer::setContentsChanged()
+{
+    // FIXME: There is no equivalent of setContentsChanged in CACF. For now I will
+    // set contents to 0 and then back to its original value to see if that
+    // kicks CACF into redisplaying.
+    RetainPtr<CFTypeRef> contents = CACFLayerGetContents(m_layer.get());
+    CACFLayerSetContents(m_layer.get(), 0);
+    CACFLayerSetContents(m_layer.get(), contents.get());
+    setNeedsCommit();
+}
+
+void PlatformCALayer::setNeedsLayout()
+{
+    if (!m_owner || !m_owner->platformCALayerRespondsToLayoutChanges())
+        return;
+
+    CACFLayerSetNeedsLayout(m_layer.get());
+    setNeedsCommit();
+}
+
+PlatformCALayer* PlatformCALayer::superlayer() const
+{
+    return platformCALayer(CACFLayerGetSuperlayer(m_layer.get()));
+}
+
+void PlatformCALayer::removeFromSuperlayer()
+{
+    CACFLayerRemoveFromSuperlayer(m_layer.get());
+    setNeedsCommit();
+}
+
+void PlatformCALayer::setSublayers(const PlatformCALayerList& list)
+{
+    intern(this)->setSublayers(list);
+}
+
+void PlatformCALayer::removeAllSublayers()
+{
+    intern(this)->removeAllSublayers();
+}
+
+void PlatformCALayer::appendSublayer(PlatformCALayer* layer)
+{
+    // This must be in terms of insertSublayer instead of a direct call so PlatformCALayerInternal can override.
+    insertSublayer(layer, sublayerCount());
+}
+
+void PlatformCALayer::insertSublayer(PlatformCALayer* layer, size_t index)
+{
+    intern(this)->insertSublayer(layer, index);
+}
+
+void PlatformCALayer::replaceSublayer(PlatformCALayer* reference, PlatformCALayer* newLayer)
+{
+    // This must not use direct calls to allow PlatformCALayerInternal to override.
+    ASSERT_ARG(reference, reference);
+    ASSERT_ARG(reference, reference->superlayer() == this);
+
+    if (reference == newLayer)
+        return;
+
+    int referenceIndex = intern(this)->indexOfSublayer(reference);
+    ASSERT(referenceIndex != -1);
+    if (referenceIndex == -1)
+        return;
+
+    reference->removeFromSuperlayer();
+
+    if (newLayer) {
+        newLayer->removeFromSuperlayer();
+        insertSublayer(newLayer, referenceIndex);
+    }
+}
+
+size_t PlatformCALayer::sublayerCount() const
+{
+    return intern(this)->sublayerCount();
+}
+
+void PlatformCALayer::adoptSublayers(PlatformCALayer* source)
+{
+    // Make a list of the sublayers from source
+    PlatformCALayerList sublayers;
+    size_t n = source->sublayerCount();
+    CFArrayRef sourceSublayers = CACFLayerGetSublayers(source->platformLayer());
+
+    for (size_t i = 0; i < n; ++i) {
+        CACFLayerRef layer = static_cast<CACFLayerRef>(const_cast<void*>(CFArrayGetValueAtIndex(sourceSublayers, i)));
+        sublayers.append(platformCALayer(layer));
+    }
+
+    // Use setSublayers() because it properly nulls out the superlayer pointers.
+    setSublayers(sublayers);
+}
+
+void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation* animation)
+{
+    // Add it to the animation list
+    m_animations.add(key, animation);
+
+    RetainPtr<CFStringRef> s(AdoptCF, key.createCFString());
+    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);
+}
+
+void PlatformCALayer::removeAnimationForKey(const String& key)
+{
+    // Remove it from the animation list
+    m_animations.remove(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.
+    // 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.
+
+    setNeedsCommit();
+}
+
+PassRefPtr<PlatformCAAnimation> PlatformCALayer::animationForKey(const String& key)
+{
+    HashMap<String, RefPtr<PlatformCAAnimation> >::iterator it = m_animations.find(key);
+    if (it == m_animations.end())
+        return 0;
+
+    return it->second;
+}
+
+PlatformCALayer* PlatformCALayer::mask() const
+{
+    return platformCALayer(CACFLayerGetMask(m_layer.get()));
+}
+
+void PlatformCALayer::setMask(PlatformCALayer* layer)
+{
+    CACFLayerSetMask(m_layer.get(), layer ? layer->platformLayer() : 0);
+    setNeedsCommit();
+}
+
+bool PlatformCALayer::isOpaque() const
+{
+    return CACFLayerIsOpaque(m_layer.get());
+}
+
+void PlatformCALayer::setOpaque(bool value)
+{
+    CACFLayerSetOpaque(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+FloatRect PlatformCALayer::bounds() const
+{
+    return CACFLayerGetBounds(m_layer.get());
+}
+
+void PlatformCALayer::setBounds(const FloatRect& value)
+{
+    intern(this)->setBounds(value);
+    setNeedsLayout();
+}
+
+FloatPoint3D PlatformCALayer::position() const
+{
+    CGPoint point = CACFLayerGetPosition(m_layer.get());
+    return FloatPoint3D(point.x, point.y, CACFLayerGetZPosition(m_layer.get()));
+}
+
+void PlatformCALayer::setPosition(const FloatPoint3D& value)
+{
+    CACFLayerSetPosition(m_layer.get(), CGPointMake(value.x(), value.y()));
+    CACFLayerSetZPosition(m_layer.get(), value.z());
+    setNeedsCommit();
+}
+
+FloatPoint3D PlatformCALayer::anchorPoint() const
+{
+    CGPoint point = CACFLayerGetAnchorPoint(m_layer.get());
+    float z = CACFLayerGetAnchorPointZ(m_layer.get());
+    return FloatPoint3D(point.x, point.y, z);
+}
+
+void PlatformCALayer::setAnchorPoint(const FloatPoint3D& value)
+{
+    CACFLayerSetAnchorPoint(m_layer.get(), CGPointMake(value.x(), value.y()));
+    CACFLayerSetAnchorPointZ(m_layer.get(), value.z());
+    setNeedsCommit();
+}
+
+TransformationMatrix PlatformCALayer::transform() const
+{
+    return CACFLayerGetTransform(m_layer.get());
+}
+
+void PlatformCALayer::setTransform(const TransformationMatrix& value)
+{
+    CACFLayerSetTransform(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+TransformationMatrix PlatformCALayer::sublayerTransform() const
+{
+    return CACFLayerGetSublayerTransform(m_layer.get());
+}
+
+void PlatformCALayer::setSublayerTransform(const TransformationMatrix& value)
+{
+    CACFLayerSetSublayerTransform(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+TransformationMatrix PlatformCALayer::contentsTransform() const
+{
+    // ContentsTransform is not used
+    return TransformationMatrix();
+}
+
+void PlatformCALayer::setContentsTransform(const TransformationMatrix&)
+{
+    // ContentsTransform is not used
+}
+
+bool PlatformCALayer::isHidden() const
+{
+    return CACFLayerIsHidden(m_layer.get());
+}
+
+void PlatformCALayer::setHidden(bool value)
+{
+    CACFLayerSetHidden(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+bool PlatformCALayer::isGeometryFlipped() const
+{
+    return CACFLayerIsGeometryFlipped(m_layer.get());
+}
+
+void PlatformCALayer::setGeometryFlipped(bool value)
+{
+    CACFLayerSetGeometryFlipped(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+bool PlatformCALayer::isDoubleSided() const
+{
+    return CACFLayerIsDoubleSided(m_layer.get());
+}
+
+void PlatformCALayer::setDoubleSided(bool value)
+{
+    CACFLayerSetDoubleSided(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+bool PlatformCALayer::masksToBounds() const
+{
+    return CACFLayerGetMasksToBounds(m_layer.get());
+}
+
+void PlatformCALayer::setMasksToBounds(bool value)
+{
+    CACFLayerSetMasksToBounds(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+bool PlatformCALayer::acceleratesDrawing() const
+{
+    return false;
+}
+
+void PlatformCALayer::setAcceleratesDrawing(bool)
+{
+}
+
+CFTypeRef PlatformCALayer::contents() const
+{
+    return CACFLayerGetContents(m_layer.get());
+}
+
+void PlatformCALayer::setContents(CFTypeRef value)
+{
+    CACFLayerSetContents(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+FloatRect PlatformCALayer::contentsRect() const
+{
+    return CACFLayerGetContentsRect(m_layer.get());
+}
+
+void PlatformCALayer::setContentsRect(const FloatRect& value)
+{
+    CACFLayerSetContentsRect(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+void PlatformCALayer::setMinificationFilter(FilterType value)
+{
+    CACFLayerSetMinificationFilter(m_layer.get(), toCACFFilterType(value));
+}
+
+void PlatformCALayer::setMagnificationFilter(FilterType value)
+{
+    CACFLayerSetMagnificationFilter(m_layer.get(), toCACFFilterType(value));
+    setNeedsCommit();
+}
+
+Color PlatformCALayer::backgroundColor() const
+{
+    return CACFLayerGetBackgroundColor(m_layer.get());
+}
+
+void PlatformCALayer::setBackgroundColor(const Color& value)
+{
+    CGFloat components[4];
+    value.getRGBA(components[0], components[1], components[2], components[3]);
+
+    RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+    RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
+
+    CACFLayerSetBackgroundColor(m_layer.get(), color.get());
+    setNeedsCommit();
+}
+
+float PlatformCALayer::borderWidth() const
+{
+    return CACFLayerGetBorderWidth(m_layer.get());
+}
+
+void PlatformCALayer::setBorderWidth(float value)
+{
+    CACFLayerSetBorderWidth(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+Color PlatformCALayer::borderColor() const
+{
+    return CACFLayerGetBorderColor(m_layer.get());
+}
+
+void PlatformCALayer::setBorderColor(const Color& value)
+{
+    CGFloat components[4];
+    value.getRGBA(components[0], components[1], components[2], components[3]);
+
+    RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+    RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
+
+    CACFLayerSetBorderColor(m_layer.get(), color.get());
+    setNeedsCommit();
+}
+
+float PlatformCALayer::opacity() const
+{
+    return CACFLayerGetOpacity(m_layer.get());
+}
+
+void PlatformCALayer::setOpacity(float value)
+{
+    CACFLayerSetOpacity(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+String PlatformCALayer::name() const
+{
+    return CACFLayerGetName(m_layer.get());
+}
+
+void PlatformCALayer::setName(const String& value)
+{
+    RetainPtr<CFStringRef> s(AdoptCF, value.createCFString());
+    CACFLayerSetName(m_layer.get(), s.get());
+    setNeedsCommit();
+}
+
+FloatRect PlatformCALayer::frame() const
+{
+    return CACFLayerGetFrame(m_layer.get());
+}
+
+void PlatformCALayer::setFrame(const FloatRect& value)
+{
+    intern(this)->setFrame(value);
+    setNeedsLayout();
+}
+
+float PlatformCALayer::speed() const
+{
+    return CACFLayerGetSpeed(m_layer.get());
+}
+
+void PlatformCALayer::setSpeed(float value)
+{
+    CACFLayerSetSpeed(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+CFTimeInterval PlatformCALayer::timeOffset() const
+{
+    return CACFLayerGetTimeOffset(m_layer.get());
+}
+
+void PlatformCALayer::setTimeOffset(CFTimeInterval value)
+{
+    CACFLayerSetTimeOffset(m_layer.get(), value);
+    setNeedsCommit();
+}
+
+#ifndef NDEBUG
+static void printIndent(int indent)
+{
+    for ( ; indent > 0; --indent)
+        fprintf(stderr, "  ");
+}
+
+static void printTransform(const CATransform3D& transform)
+{
+    fprintf(stderr, "[%g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g]",
+                    transform.m11, transform.m12, transform.m13, transform.m14, 
+                    transform.m21, transform.m22, transform.m23, transform.m24, 
+                    transform.m31, transform.m32, transform.m33, transform.m34, 
+                    transform.m41, transform.m42, transform.m43, transform.m44);
+}
+
+static void printLayer(const PlatformCALayer* layer, int indent)
+{
+    FloatPoint3D layerPosition = layer->position();
+    FloatPoint3D layerAnchorPoint = layer->anchorPoint();
+    FloatRect layerBounds = layer->bounds();
+    printIndent(indent);
+
+    char* layerTypeName = 0;
+    switch (layer->layerType()) {
+    case PlatformCALayer::LayerTypeLayer: layerTypeName = "layer"; break;
+    case PlatformCALayer::LayerTypeWebLayer: layerTypeName = "web-layer"; break;
+    case PlatformCALayer::LayerTypeTransformLayer: layerTypeName = "transform-layer"; break;
+    case PlatformCALayer::LayerTypeWebTiledLayer: layerTypeName = "web-tiled-layer"; break;
+    case PlatformCALayer::LayerTypeRootLayer: layerTypeName = "root-layer"; break;
+    case PlatformCALayer::LayerTypeCustom: layerTypeName = "custom-layer"; break;
+    }
+
+    fprintf(stderr, "(%s [%g %g %g] [%g %g %g %g] [%g %g %g] superlayer=%p\n",
+        layerTypeName,
+        layerPosition.x(), layerPosition.y(), layerPosition.z(), 
+        layerBounds.x(), layerBounds.y(), layerBounds.width(), layerBounds.height(),
+        layerAnchorPoint.x(), layerAnchorPoint.y(), layerAnchorPoint.z(), layer->superlayer());
+
+    // Print name if needed
+    String layerName = layer->name();
+    if (!layerName.isEmpty()) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(name %s)\n", layerName.utf8().data());
+    }
+
+    // Print masksToBounds if needed
+    bool layerMasksToBounds = layer->masksToBounds();
+    if (layerMasksToBounds) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(masksToBounds true)\n");
+    }
+
+    // Print opacity if needed
+    float layerOpacity = layer->opacity();
+    if (layerOpacity != 1) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(opacity %hf)\n", layerOpacity);
+    }
+
+    // Print sublayerTransform if needed
+    TransformationMatrix layerTransform = layer->sublayerTransform();
+    if (!layerTransform.isIdentity()) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(sublayerTransform ");
+        printTransform(layerTransform);
+        fprintf(stderr, ")\n");
+    }
+
+    // Print transform if needed
+    layerTransform = layer->transform();
+    if (!layerTransform.isIdentity()) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(transform ");
+        printTransform(layerTransform);
+        fprintf(stderr, ")\n");
+    }
+
+    // Print contents if needed
+    CFTypeRef layerContents = layer->contents();
+    if (layerContents) {
+        if (CFGetTypeID(layerContents) == CGImageGetTypeID()) {
+            CGImageRef imageContents = static_cast<CGImageRef>(const_cast<void*>(layerContents));
+            printIndent(indent + 1);
+            fprintf(stderr, "(contents (image [%d %d]))\n",
+                CGImageGetWidth(imageContents), CGImageGetHeight(imageContents));
+        }
+    }
+
+    // Print sublayers if needed
+    int n = layer->sublayerCount();
+    if (n > 0) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(sublayers\n");
+
+        CFArrayRef sublayers = CACFLayerGetSublayers(layer->platformLayer());
+        for (int i = 0; i < n; ++i) {
+            PlatformCALayer* sublayer = PlatformCALayer::platformCALayer(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, i)));
+            printLayer(sublayer, indent + 2);
+        }
+
+        printIndent(indent + 1);
+        fprintf(stderr, ")\n");
+    }
+
+    printIndent(indent);
+    fprintf(stderr, ")\n");
+}
+
+void PlatformCALayer::printTree() const
+{
+    // Print heading info
+    CGRect rootBounds = bounds();
+    fprintf(stderr, "\n\n** Render tree at time %g (bounds %g, %g %gx%g) **\n\n", 
+        currentTime(), rootBounds.origin.x, rootBounds.origin.y, rootBounds.size.width, rootBounds.size.height);
+
+    // Print layer tree from the root
+    printLayer(this, 0);
+}
+#endif // #ifndef NDEBUG
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp b/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
new file mode 100644 (file)
index 0000000..0b7eea0
--- /dev/null
@@ -0,0 +1,464 @@
+/*
+ * Copyright (C) 2011 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)
+
+#include "PlatformCALayerWinInternal.h"
+
+#include "Font.h"
+#include "PlatformCALayer.h"
+#include <QuartzCore/CACFLayer.h>
+
+using namespace std;
+using namespace WebCore;
+
+// The width and height of a single tile in a tiled layer. Should be large enough to
+// avoid lots of small tiles (and therefore lots of drawing callbacks), but small enough
+// to keep the overall tile cost low.
+static const int cTiledLayerTileSize = 512;
+
+PlatformCALayerWinInternal::PlatformCALayerWinInternal(PlatformCALayer* owner)
+    : m_tileSize(CGSizeMake(cTiledLayerTileSize, cTiledLayerTileSize))
+    , m_constrainedSize(constrainedSize(owner->bounds().size()))
+    , m_owner(owner)
+{
+    if (m_owner->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // Tiled layers are placed in a child layer that is always the first child of the TiledLayer
+        m_tileParent.adoptCF(CACFLayerCreate(kCACFLayer));
+        CACFLayerInsertSublayer(m_owner->platformLayer(), m_tileParent.get(), 0);
+        updateTiles();
+    }
+}
+
+PlatformCALayerWinInternal::~PlatformCALayerWinInternal()
+{
+}
+
+void PlatformCALayerWinInternal::displayCallback(CACFLayerRef caLayer, CGContextRef context)
+{
+    if (!owner() || !owner()->owner())
+        return;
+
+    CGContextSaveGState(context);
+
+    CGRect layerBounds = owner()->bounds();
+    if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+        CGContextScaleCTM(context, 1, -1);
+        CGContextTranslateCTM(context, 0, -layerBounds.size.height);
+    }
+
+    if (owner()->owner()) {
+        GraphicsContext graphicsContext(context);
+
+        // It's important to get the clip from the context, because it may be significantly
+        // smaller than the layer bounds (e.g. tiled layers)
+        CGRect clipBounds = CGContextGetClipBoundingBox(context);
+        IntRect clip(enclosingIntRect(clipBounds));
+        owner()->owner()->platformCALayerPaintContents(graphicsContext, clip);
+    }
+#ifndef NDEBUG
+    else {
+        ASSERT_NOT_REACHED();
+
+        // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,
+        // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).
+        CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);
+        CGContextFillRect(context, layerBounds);
+    }
+#endif
+
+    if (owner()->owner()->platformCALayerShowRepaintCounter()) {
+        String text = String::number(owner()->owner()->platformCALayerIncrementRepaintCount());
+
+        CGContextSaveGState(context);
+
+        // Make the background of the counter the same as the border color,
+        // unless there is no border, then make it red
+        float borderWidth = CACFLayerGetBorderWidth(caLayer);
+        if (borderWidth > 0) {
+            CGColorRef borderColor = CACFLayerGetBorderColor(caLayer);
+            const CGFloat* colors = CGColorGetComponents(borderColor);
+            CGContextSetRGBFillColor(context, colors[0], colors[1], colors[2], colors[3]);
+        } else
+            CGContextSetRGBFillColor(context, 1.0f, 0.0f, 0.0f, 0.8f);
+        
+        CGRect aBounds = layerBounds;
+
+        aBounds.size.width = 10 + 10 * text.length();
+        aBounds.size.height = 22;
+        CGContextFillRect(context, aBounds);
+        
+        FontDescription desc;
+
+        NONCLIENTMETRICS metrics;
+        metrics.cbSize = sizeof(metrics);
+        SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
+        FontFamily family;
+        family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
+        desc.setFamily(family);
+
+        desc.setComputedSize(18);
+        
+        Font font = Font(desc, 0, 0);
+        font.update(0);
+
+        GraphicsContext cg(context);
+        cg.setFillColor(Color::black, ColorSpaceDeviceRGB);
+        cg.drawText(font, TextRun(text), IntPoint(aBounds.origin.x + 5, aBounds.origin.y + 17));
+
+        CGContextRestoreGState(context);        
+    }
+
+    CGContextRestoreGState(context);
+
+    owner()->owner()->platformCALayerLayerDidDisplay(caLayer);
+}
+
+void PlatformCALayerWinInternal::internalSetNeedsDisplay(const FloatRect* dirtyRect)
+{
+    if (dirtyRect) {
+        CGRect rect = *dirtyRect;
+        CACFLayerSetNeedsDisplay(owner()->platformLayer(), &rect);
+    } else
+        CACFLayerSetNeedsDisplay(owner()->platformLayer(), 0);
+}
+
+void PlatformCALayerWinInternal::setNeedsDisplay(const FloatRect* dirtyRect)
+{
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // FIXME: Only setNeedsDisplay for tiles that are currently visible
+        int numTileLayers = tileCount();
+        CGRect rect;
+        if (dirtyRect)
+            rect = *dirtyRect;
+        for (int i = 0; i < numTileLayers; ++i)
+            CACFLayerSetNeedsDisplay(tileAtIndex(i), dirtyRect ? &rect : 0);
+
+        if (m_owner->owner() && m_owner->owner()->platformCALayerShowRepaintCounter()) {
+            CGRect layerBounds = m_owner->bounds();
+            CGRect indicatorRect = CGRectMake(layerBounds.origin.x, layerBounds.origin.y, 80, 25);
+            CACFLayerSetNeedsDisplay(tileAtIndex(0), &indicatorRect);
+        }
+    } else if (owner()->layerType() == PlatformCALayer::LayerTypeWebLayer) {
+        if (owner() && owner()->owner()) {
+            if (owner()->owner()->platformCALayerShowRepaintCounter()) {
+                FloatRect layerBounds = owner()->bounds();
+                FloatRect repaintCounterRect = layerBounds;
+
+                // We assume a maximum of 4 digits and a font size of 18.
+                repaintCounterRect.setWidth(80);
+                repaintCounterRect.setHeight(22);
+                if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown)
+                    repaintCounterRect.setY(layerBounds.height() - (layerBounds.y() + repaintCounterRect.height()));
+                internalSetNeedsDisplay(&repaintCounterRect);
+            }
+            if (dirtyRect && owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+                FloatRect flippedDirtyRect = *dirtyRect;
+                flippedDirtyRect.setY(owner()->bounds().height() - (flippedDirtyRect.y() + flippedDirtyRect.height()));
+                internalSetNeedsDisplay(&flippedDirtyRect);
+                return;
+            }
+        }
+
+        internalSetNeedsDisplay(dirtyRect);
+    }
+    owner()->setNeedsCommit();
+}
+
+void PlatformCALayerWinInternal::setSublayers(const PlatformCALayerList& list)
+{
+    // Remove all the current sublayers and add the passed layers
+    CACFLayerSetSublayers(owner()->platformLayer(), 0);
+
+    // Perform removeFromSuperLayer in a separate pass. CACF requires superlayer to
+    // be null or CACFLayerInsertSublayer silently fails.
+    for (size_t i = 0; i < list.size(); i++)
+        CACFLayerRemoveFromSuperlayer(list[i]->platformLayer());
+
+    for (size_t i = 0; i < list.size(); i++)
+        CACFLayerInsertSublayer(owner()->platformLayer(), list[i]->platformLayer(), i);
+
+    owner()->setNeedsCommit();
+
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // Preserve the tile parent after set
+        CACFLayerInsertSublayer(owner()->platformLayer(), m_tileParent.get(), 0);
+    }
+}
+
+void PlatformCALayerWinInternal::removeAllSublayers()
+{
+    CACFLayerSetSublayers(owner()->platformLayer(), 0);
+    owner()->setNeedsCommit();
+
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // Restore the tile parent after removal
+        CACFLayerInsertSublayer(owner()->platformLayer(), m_tileParent.get(), 0);
+    }
+}
+
+void PlatformCALayerWinInternal::insertSublayer(PlatformCALayer* layer, size_t index)
+{
+    index = min(index, sublayerCount());
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // Add 1 to account for the tile parent layer
+        index++;
+    }
+
+    layer->removeFromSuperlayer();
+    CACFLayerInsertSublayer(owner()->platformLayer(), layer->platformLayer(), index);
+    owner()->setNeedsCommit();
+}
+
+size_t PlatformCALayerWinInternal::sublayerCount() const
+{
+    CFArrayRef sublayers = CACFLayerGetSublayers(owner()->platformLayer());
+    size_t count = sublayers ? CFArrayGetCount(sublayers) : 0;
+
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // Subtract 1 to account for the tile parent layer
+        ASSERT(count > 0);
+        count--;
+    }
+
+    return count;
+}
+
+int PlatformCALayerWinInternal::indexOfSublayer(const PlatformCALayer* reference)
+{
+    CACFLayerRef ref = reference->platformLayer();
+    if (!ref)
+        return -1;
+
+    CFArrayRef sublayers = CACFLayerGetSublayers(owner()->platformLayer());
+    if (!sublayers)
+        return -1;
+
+    size_t n = CFArrayGetCount(sublayers);
+
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        for (size_t i = 1; i < n; ++i) {
+            if (CFArrayGetValueAtIndex(sublayers, i) == ref)
+                return i - 1;
+        }
+    } else {
+        for (size_t i = 0; i < n; ++i) {
+            if (CFArrayGetValueAtIndex(sublayers, i) == ref)
+                return i;
+        }
+    }
+
+    return -1;
+}
+
+PlatformCALayer* PlatformCALayerWinInternal::sublayerAtIndex(int index) const
+{
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        // Add 1 to account for the tile parent layer
+        index++;
+    }
+
+    CFArrayRef sublayers = CACFLayerGetSublayers(owner()->platformLayer());
+    if (!sublayers || index < 0 || CFArrayGetCount(sublayers) <= index)
+        return 0;
+    
+    return PlatformCALayer::platformCALayer(static_cast<CACFLayerRef>(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, index))));
+}
+
+void PlatformCALayerWinInternal::setBounds(const FloatRect& rect)
+{
+    if (CGRectEqualToRect(rect, owner()->bounds()))
+        return;
+
+    CACFLayerSetBounds(owner()->platformLayer(), rect);
+    owner()->setNeedsCommit();
+
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
+        m_constrainedSize = constrainedSize(rect.size());
+        updateTiles();
+    }
+}
+
+void PlatformCALayerWinInternal::setFrame(const FloatRect& rect)
+{
+    CGRect oldFrame = owner()->frame();
+    if (CGRectEqualToRect(rect, oldFrame))
+        return;
+
+    CACFLayerSetFrame(owner()->platformLayer(), rect);
+    owner()->setNeedsCommit();
+
+    if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer)
+        updateTiles();
+}
+
+CGSize PlatformCALayerWinInternal::constrainedSize(const CGSize& size) const
+{
+    const int cMaxTileCount = 512;
+    const float cSqrtMaxTileCount = sqrtf(cMaxTileCount);
+
+    CGSize constrainedSize = size;
+
+    int tileColumns = ceilf(constrainedSize.width / m_tileSize.width);
+    int tileRows = ceilf(constrainedSize.height / m_tileSize.height);
+    int numTiles = tileColumns * tileRows;
+
+    // If number of tiles vertically or horizontally is < sqrt(cMaxTileCount)
+    // just shorten the longer dimension. Otherwise shorten both dimensions
+    // according to the ratio of width to height
+
+    if (numTiles > cMaxTileCount) {
+        if (tileRows < cSqrtMaxTileCount)
+            tileColumns = floorf(cMaxTileCount / tileRows);
+        else if (tileColumns < cSqrtMaxTileCount)
+            tileRows = floorf(cMaxTileCount / tileColumns);
+        else {
+            tileRows = ceilf(sqrtf(cMaxTileCount * constrainedSize.height / constrainedSize.width));
+            tileColumns = floorf(cMaxTileCount / tileRows);
+        }
+        
+        constrainedSize.width = tileColumns * m_tileSize.width;
+        constrainedSize.height = tileRows * m_tileSize.height;
+    }
+    
+    return constrainedSize;
+}
+
+void PlatformCALayerWinInternal::tileDisplayCallback(CACFLayerRef layer, CGContextRef context)
+{
+    static_cast<PlatformCALayerWinInternal*>(CACFLayerGetUserData(layer))->drawTile(layer, context);
+}
+
+void PlatformCALayerWinInternal::addTile()
+{
+    RetainPtr<CACFLayerRef> newLayer(AdoptCF, CACFLayerCreate(kCACFLayer));
+    CACFLayerSetAnchorPoint(newLayer.get(), CGPointMake(0, 1));
+    CACFLayerSetUserData(newLayer.get(), this);
+    CACFLayerSetDisplayCallback(newLayer.get(), tileDisplayCallback);
+
+    CFArrayRef sublayers = CACFLayerGetSublayers(m_tileParent.get());
+    CACFLayerInsertSublayer(m_tileParent.get(), newLayer.get(), sublayers ? CFArrayGetCount(sublayers) : 0);
+
+    if (owner()->owner()->platformCALayerShowDebugBorders()) {
+        CGColorRef borderColor = CGColorCreateGenericRGB(0.5, 0, 0.5, 0.7);
+        CACFLayerSetBorderColor(newLayer.get(), borderColor);
+        CGColorRelease(borderColor);
+        CACFLayerSetBorderWidth(newLayer.get(), 2);
+    }
+}
+
+void PlatformCALayerWinInternal::removeTile()
+{
+    CACFLayerRemoveFromSuperlayer(tileAtIndex(tileCount() - 1));
+}
+
+CACFLayerRef PlatformCALayerWinInternal::tileAtIndex(int index)
+{
+    CFArrayRef sublayers = CACFLayerGetSublayers(m_tileParent.get());
+    if (!sublayers || index < 0 || index >= tileCount())
+        return 0;
+    
+    return static_cast<CACFLayerRef>(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, index)));
+}
+
+int PlatformCALayerWinInternal::tileCount() const
+{
+    CFArrayRef sublayers = CACFLayerGetSublayers(m_tileParent.get());
+    return sublayers ? CFArrayGetCount(sublayers) : 0;
+}
+
+void PlatformCALayerWinInternal::updateTiles()
+{
+    // FIXME: In addition to redoing the number of tiles, we need to only render and have backing
+    // store for visible layers
+    int numTilesHorizontal = ceil(m_constrainedSize.width / m_tileSize.width);
+    int numTilesVertical = ceil(m_constrainedSize.height / m_tileSize.height);
+    int numTilesTotal = numTilesHorizontal * numTilesVertical;
+
+    int numTilesToChange = numTilesTotal - tileCount();
+    if (numTilesToChange >= 0) {
+        // Add new tiles
+        for (int i = 0; i < numTilesToChange; ++i)
+            addTile();
+    } else {
+        // Remove old tiles
+        numTilesToChange = -numTilesToChange;
+        for (int i = 0; i < numTilesToChange; ++i)
+            removeTile();
+    }
+
+    // Set coordinates for all tiles
+    CFArrayRef tileArray = CACFLayerGetSublayers(m_tileParent.get());
+
+    for (int i = 0; i < numTilesHorizontal; ++i) {
+        for (int j = 0; j < numTilesVertical; ++j) {
+            CACFLayerRef tile = static_cast<CACFLayerRef>(const_cast<void*>(CFArrayGetValueAtIndex(tileArray, i * numTilesVertical + j)));
+            CACFLayerSetPosition(tile, CGPointMake(i * m_tileSize.width, j * m_tileSize.height));
+            int width = min(m_tileSize.width, m_constrainedSize.width - i * m_tileSize.width);
+            int height = min(m_tileSize.height, m_constrainedSize.height - j * m_tileSize.height);
+            CACFLayerSetBounds(tile, CGRectMake(i * m_tileSize.width, j * m_tileSize.height, width, height));
+
+            // Flip Y to compensate for the flipping that happens during render to match the CG context coordinate space
+            CATransform3D transform = CATransform3DMakeScale(1, -1, 1);
+            CATransform3DTranslate(transform, 0, height, 0);
+            CACFLayerSetTransform(tile, transform);
+
+#ifndef NDEBUG
+            String name = "Tile (" + String::number(i) + "," + String::number(j) + ")";
+            CACFLayerSetName(tile, RetainPtr<CFStringRef>(AdoptCF, name.createCFString()).get());
+#endif
+        }
+    }
+}
+
+void PlatformCALayerWinInternal::drawTile(CACFLayerRef tile, CGContextRef context)
+{
+    CGPoint tilePosition = CACFLayerGetPosition(tile);
+    CGRect tileBounds = CACFLayerGetBounds(tile);
+
+    CGContextSaveGState(context);
+
+    // Transform context to be at the origin of the parent layer
+    CGContextTranslateCTM(context, -tilePosition.x, -tilePosition.y);
+
+    // Set the context clipping rectangle to the current tile
+    CGContextClipToRect(context, CGRectMake(tilePosition.x, tilePosition.y, tileBounds.size.width, tileBounds.size.height));
+
+    if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+        // If the layer is rendering top-down, it will flip the coordinates in y. Tiled layers are
+        // already flipping, so we need to undo that here.
+        CGContextTranslateCTM(context, 0, owner()->bounds().height());
+        CGContextScaleCTM(context, 1, -1);
+    }
+
+    // Draw the tile
+    displayCallback(owner()->platformLayer(), context);
+
+    CGContextRestoreGState(context);
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h b/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h
new file mode 100644 (file)
index 0000000..1be9d26
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2011 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 PlatformCALayerWinInternal_h
+#define PlatformCALayerWinInternal_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include <CoreGraphics/CGGeometry.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+
+typedef struct _CACFLayer *CACFLayerRef;
+typedef struct CGContext *CGContextRef;
+
+namespace WebCore {
+
+class FloatRect;
+class PlatformCALayer;
+
+typedef Vector<RefPtr<PlatformCALayer> > PlatformCALayerList;
+
+class PlatformCALayerWinInternal {
+public:
+    PlatformCALayerWinInternal(PlatformCALayer*);
+    ~PlatformCALayerWinInternal();
+
+    void displayCallback(CACFLayerRef, CGContextRef);
+    void setNeedsDisplay(const FloatRect*);
+    PlatformCALayer* owner() const { return m_owner; }
+
+    void setSublayers(const PlatformCALayerList&);
+    void removeAllSublayers();
+    void insertSublayer(PlatformCALayer*, size_t);
+    size_t sublayerCount() const;
+    int indexOfSublayer(const PlatformCALayer* reference);
+
+    void setBounds(const FloatRect&);
+    void setFrame(const FloatRect&);
+
+private:
+    void internalSetNeedsDisplay(const FloatRect*);
+    PlatformCALayer* sublayerAtIndex(int) const;
+
+    static void tileDisplayCallback(CACFLayerRef, CGContextRef);
+
+    void drawTile(CACFLayerRef, CGContextRef);
+    CGSize constrainedSize(const CGSize&) const;
+    void addTile();
+    void removeTile();
+    CACFLayerRef tileAtIndex(int);
+    int tileCount() const;
+    void updateTiles();
+
+    PlatformCALayer* m_owner;
+
+    CGSize m_tileSize;
+    CGSize m_constrainedSize;
+    RetainPtr<CACFLayerRef> m_tileParent;
+};
+
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // PlatformCALayerWinInternal_h
index 12c6f0d..c24181b 100644 (file)
@@ -144,7 +144,7 @@ static void freeData(void *, const void *data, size_t /* size */)
 {
     [super display];
     if (m_layerOwner)
-        m_layerOwner->didDisplay(self);
+        m_layerOwner->layerDidDisplay(self);
 }
 
 @end
index 62d69fc..30bf55b 100644 (file)
@@ -32,6 +32,7 @@
 
 namespace WebCore {
     class GraphicsLayer;
+    class PlatformCALayerClient;
 }
 
 #if defined(BUILDING_ON_LEOPARD)
@@ -47,8 +48,8 @@ namespace WebCore {
 @end
 
 // Functions allows us to share implementation across WebTiledLayer and WebLayer
-void drawLayerContents(CGContextRef, CALayer *, WebCore::GraphicsLayer*);
-void setLayerNeedsDisplayInRect(CALayer *, WebCore::GraphicsLayer*, CGRect);
+void drawLayerContents(CGContextRef, CALayer *, WebCore::PlatformCALayerClient*);
+void setLayerNeedsDisplayInRect(CALayer *, WebCore::PlatformCALayerClient*, CGRect);
 
 #endif // USE(ACCELERATED_COMPOSITING)
 
index 4154c10..06ea9be 100644 (file)
@@ -40,7 +40,7 @@ using namespace WebCore;
 
 @implementation WebLayer
 
-void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::GraphicsLayer* layerContents)
+void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCALayerClient* layerContents)
 {
     if (!layerContents)
         return;
@@ -48,50 +48,38 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::GraphicsLa
     CGContextSaveGState(context);
 
     CGRect layerBounds = [layer bounds];
-    if (layerContents->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {
+    if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {
         CGContextScaleCTM(context, 1, -1);
         CGContextTranslateCTM(context, 0, -layerBounds.size.height);
     }
 
-    if (layerContents->client()) {
-        [NSGraphicsContext saveGraphicsState];
+    [NSGraphicsContext saveGraphicsState];
 
-        // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on
-        // the current NSGraphicsContext (e.g. NSCell drawing) get the right one.
-        NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
-        [NSGraphicsContext setCurrentContext:layerContext];
+    // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on
+    // the current NSGraphicsContext (e.g. NSCell drawing) get the right one.
+    NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
+    [NSGraphicsContext setCurrentContext:layerContext];
 
-        GraphicsContext graphicsContext(context);
+    GraphicsContext graphicsContext(context);
 
-        if (!layerContents->contentsOpaque()) {
-            // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
-            graphicsContext.setShouldSmoothFonts(false);
-        }
-        
-        // It's important to get the clip from the context, because it may be significantly
-        // smaller than the layer bounds (e.g. tiled layers)
-        CGRect clipBounds = CGContextGetClipBoundingBox(context);
-        IntRect clip(enclosingIntRect(clipBounds));
-        layerContents->paintGraphicsLayerContents(graphicsContext, clip);
-
-        [NSGraphicsContext restoreGraphicsState];
+    if (!layerContents->platformCALayerContentsOpaque()) {
+        // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
+        graphicsContext.setShouldSmoothFonts(false);
     }
-#ifndef NDEBUG
-    else {
-        ASSERT_NOT_REACHED();
+    
+    // It's important to get the clip from the context, because it may be significantly
+    // smaller than the layer bounds (e.g. tiled layers)
+    CGRect clipBounds = CGContextGetClipBoundingBox(context);
+    IntRect clip(enclosingIntRect(clipBounds));
+    layerContents->platformCALayerPaintContents(graphicsContext, clip);
 
-        // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,
-        // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).
-        CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);
-        CGContextFillRect(context, layerBounds);
-    }
-#endif
+    [NSGraphicsContext restoreGraphicsState];
 
-    if (layerContents->showRepaintCounter()) {
+    if (layerContents->platformCALayerShowRepaintCounter()) {
         bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];
 
         char text[16]; // that's a lot of repaints
-        snprintf(text, sizeof(text), "%d", layerContents->incrementRepaintCount());
+        snprintf(text, sizeof(text), "%d", layerContents->platformCALayerIncrementRepaintCount());
 
         CGContextSaveGState(context);
         if (isTiledLayer)
@@ -117,26 +105,26 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::GraphicsLa
     CGContextRestoreGState(context);
 }
 
-void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::GraphicsLayer* layerContents, CGRect rect)
+void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::PlatformCALayerClient* layerContents, CGRect rect)
 {
-    if (layerContents && layerContents->client() && layerContents->drawsContent()) {
+    if (layerContents && layerContents->platformCALayerDrawsContent()) {
         struct objc_super layerSuper = { layer, class_getSuperclass(object_getClass(layer)) };
 #if defined(BUILDING_ON_LEOPARD)
         rect = CGRectApplyAffineTransform(rect, [layer contentsTransform]);
 #else
-        if (layerContents->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
+        if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
             rect.origin.y = [layer bounds].size.height - rect.origin.y - rect.size.height;
 #endif
         objc_msgSendSuper(&layerSuper, @selector(setNeedsDisplayInRect:), rect);
 
 #ifndef NDEBUG
-        if (layerContents->showRepaintCounter()) {
+        if (layerContents->platformCALayerShowRepaintCounter()) {
             CGRect bounds = [layer bounds];
             CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25);
 #if defined(BUILDING_ON_LEOPARD)
             indicatorRect = CGRectApplyAffineTransform(indicatorRect, [layer contentsTransform]);
 #else
-            if (layerContents->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
+            if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
                 indicatorRect.origin.y = [layer bounds].size.height - indicatorRect.origin.y - indicatorRect.size.height;
 #endif
             objc_msgSendSuper(&layerSuper, @selector(setNeedsDisplayInRect:), indicatorRect);
@@ -155,7 +143,7 @@ void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::GraphicsLayer* layerCon
 - (void)setNeedsDisplay
 {
     PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
-    if (layer && layer->owner() && layer->owner()->client() && layer->owner()->drawsContent())
+    if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent())
         [super setNeedsDisplay];
 }
 
@@ -171,7 +159,7 @@ void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::GraphicsLayer* layerCon
     [super display];
     PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
     if (layer && layer->owner())
-        layer->owner()->didDisplay(self);
+        layer->owner()->platformCALayerLayerDidDisplay(self);
 }
 
 - (void)drawInContext:(CGContextRef)context
index bf35431..e9fa5b7 100644 (file)
@@ -60,7 +60,7 @@ using namespace WebCore;
 - (void)setNeedsDisplay
 {
     PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
-    if (layer && layer->owner() && layer->owner()->client() && layer->owner()->drawsContent())
+    if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent())
         [super setNeedsDisplay];
 }
 
@@ -76,7 +76,7 @@ using namespace WebCore;
     [super display];
     PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
     if (layer && layer->owner())
-        layer->owner()->didDisplay(self);
+        layer->owner()->platformCALayerLayerDidDisplay(self);
 }
 
 - (void)drawInContext:(CGContextRef)context
index e66aa1a..d3c6b58 100644 (file)
@@ -43,7 +43,15 @@ static CGContextRef CGContextWithHDC(HDC hdc, bool hasAlpha)
     BITMAP info;
 
     GetObject(bitmap, sizeof(info), &info);
-    ASSERT(info.bmBitsPixel == 32);
+
+    // FIXME: We can get here because we asked for a bitmap that is too big
+    // when we have a tiled layer and we're compositing. In that case 
+    // bmBitsPixel will be 0. This seems to be benign, so for now we will
+    // exit gracefully and look at it later:
+    //  https://bugs.webkit.org/show_bug.cgi?id=52041   
+    // ASSERT(info.bmBitsPixel == 32);
+    if (info.bmBitsPixel != 32)
+        return 0;
 
     CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little | (hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst);
     CGContextRef context = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8,
index 4a7e45e..cbe38aa 100644 (file)
@@ -90,7 +90,7 @@ void MediaPlayerPrivateFullscreenWindow::close()
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLayer> rootChild)
+void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCALayer> rootChild)
 {
     if (m_rootChild == rootChild)
         return;
@@ -104,7 +104,7 @@ void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLaye
         return;
 
     m_layerRenderer->setRootChildLayer(m_rootChild.get());
-    WKCACFLayer* rootLayer = m_rootChild->rootLayer();
+    PlatformCALayer* rootLayer = m_rootChild->rootLayer();
     CGRect rootBounds = m_rootChild->rootLayer()->bounds();
     m_rootChild->setFrame(rootBounds);
     m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
@@ -160,7 +160,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA
                 break;
 #if USE(ACCELERATED_COMPOSITING)
             m_layerRenderer->resize();
-            WKCACFLayer* rootLayer = m_rootChild->rootLayer();
+            PlatformCALayer* rootLayer = m_rootChild->rootLayer();
             CGRect rootBounds = m_rootChild->rootLayer()->bounds();
             m_rootChild->setFrame(rootBounds);
             m_rootChild->setNeedsLayout();
index 0a43a69..a18f0cc 100644 (file)
@@ -27,7 +27,7 @@
 #define MediaPlayerPrivateFullscreenWindow_h
 
 #if USE(ACCELERATED_COMPOSITING)
-#include "WKCACFLayer.h"
+#include "PlatformCALayer.h"
 #include "WKCACFLayerRenderer.h"
 #endif
 #include <wtf/OwnPtr.h>
@@ -61,8 +61,8 @@ public:
 #if USE(ACCELERATED_COMPOSITING)
     WKCACFLayerRenderer* layerRenderer() const { return m_layerRenderer.get(); }
 
-    WKCACFLayer* rootChildLayer() const { return m_rootChild.get(); }
-    void setRootChildLayer(PassRefPtr<WKCACFLayer>);
+    PlatformCALayer* rootChildLayer() const { return m_rootChild.get(); }
+    void setRootChildLayer(PassRefPtr<PlatformCALayer>);
 #endif
 
 private:
@@ -72,7 +72,7 @@ private:
     MediaPlayerPrivateFullscreenClient* m_client;
 #if USE(ACCELERATED_COMPOSITING)
     OwnPtr<WKCACFLayerRenderer> m_layerRenderer;
-    RefPtr<WKCACFLayer> m_rootChild;
+    RefPtr<PlatformCALayer> m_rootChild;
 #endif
     HWND m_hwnd;
 };
index 2b24a24..0b91455 100644 (file)
@@ -57,8 +57,7 @@
 #include <wtf/text/StringHash.h>
 
 #if USE(ACCELERATED_COMPOSITING)
-#include "GraphicsLayerCACF.h"
-#include "WKCACFLayer.h"
+#include "PlatformCALayer.h"
 #include "WKCAImageQueue.h"
 #endif
 
@@ -85,48 +84,49 @@ private:
 };
 
 #if USE(ACCELERATED_COMPOSITING)
-// Interface declaration for MediaPlayerPrivateQuickTimeVisualContext's GraphicsLayerClient aggregate
-class MediaPlayerPrivateQuickTimeVisualContext::LayerClient : public GraphicsLayerClient {
+class MediaPlayerPrivateQuickTimeVisualContext::LayerClient : public PlatformCALayerClient {
 public:
     LayerClient(MediaPlayerPrivateQuickTimeVisualContext* parent) : m_parent(parent) {}
     virtual ~LayerClient() { m_parent = 0; }
-    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
-    virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
-    virtual void notifySyncRequired(const GraphicsLayer*) { }
-    virtual bool showDebugBorders() const { return false; }
-    virtual bool showRepaintCounter() const { return false; }
-private:
-    MediaPlayerPrivateQuickTimeVisualContext* m_parent;
-};
 
-class MediaPlayerPrivateQuickTimeVisualContext::LayoutClient : public WKCACFLayerLayoutClient {
-public:
-    LayoutClient(MediaPlayerPrivateQuickTimeVisualContext* parent) : m_parent(parent) {}
-    virtual void layoutSublayersOfLayer(WKCACFLayer*);
 private:
+    virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*);
+    virtual bool platformCALayerRespondsToLayoutChanges() const { return true; }
+
+    virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
+    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
+    virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) { }
+    virtual bool platformCALayerShowDebugBorders() const { return false; }
+    virtual bool platformCALayerShowRepaintCounter() const { return false; }
+    virtual int platformCALayerIncrementRepaintCount() { return 0; }
+
+    virtual bool platformCALayerContentsOpaque() const { return false; }
+    virtual bool platformCALayerDrawsContent() const { return false; }
+    virtual void platformCALayerLayerDidDisplay(PlatformLayer*) { }
+
     MediaPlayerPrivateQuickTimeVisualContext* m_parent;
 };
 
-void MediaPlayerPrivateQuickTimeVisualContext::LayoutClient::layoutSublayersOfLayer(WKCACFLayer* layer)
+void MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerLayoutSublayersOfLayer(PlatformCALayer* layer)
 {
     ASSERT(m_parent);
-    ASSERT(m_parent->m_transformLayer->platformLayer() == layer);
+    ASSERT(m_parent->m_transformLayer == layer);
 
-    CGSize parentSize = layer->bounds().size;
-    CGSize naturalSize = m_parent->naturalSize();
+    FloatSize parentSize = layer->bounds().size();
+    FloatSize naturalSize = m_parent->naturalSize();
 
     // Calculate the ratio of these two sizes and use that ratio to scale the qtVideoLayer:
-    CGSize ratio = CGSizeMake(parentSize.width / naturalSize.width, parentSize.height / naturalSize.height);
+    FloatSize ratio(parentSize.width() / naturalSize.width(), parentSize.height() / naturalSize.height());
 
     int videoWidth = 0;
     int videoHeight = 0;
     m_parent->m_movie->getNaturalSize(videoWidth, videoHeight);
-    CGRect videoBounds = CGRectMake(0, 0, videoWidth * ratio.width, videoHeight * ratio.height);
-    CGPoint videoAnchor = m_parent->m_qtVideoLayer->anchorPoint();
+    FloatRect videoBounds(0, 0, videoWidth * ratio.width(), videoHeight * ratio.height());
+    FloatPoint3D videoAnchor = m_parent->m_qtVideoLayer->anchorPoint();
 
     // Calculate the new position based on the parent's size:
-    CGPoint position = CGPointMake(parentSize.width * 0.5 - videoBounds.size.width * (0.5 - videoAnchor.x),
-        parentSize.height * 0.5 - videoBounds.size.height * (0.5 - videoAnchor.y)); 
+    FloatPoint position(parentSize.width() * 0.5 - videoBounds.width() * (0.5 - videoAnchor.x()),
+        parentSize.height() * 0.5 - videoBounds.height() * (0.5 - videoAnchor.y())); 
 
     m_parent->m_qtVideoLayer->setBounds(videoBounds);
     m_parent->m_qtVideoLayer->setPosition(position);
@@ -171,7 +171,6 @@ MediaPlayerPrivateQuickTimeVisualContext::MediaPlayerPrivateQuickTimeVisualConte
     , m_movieClient(new MediaPlayerPrivateQuickTimeVisualContext::MovieClient(this))
 #if USE(ACCELERATED_COMPOSITING)
     , m_layerClient(new MediaPlayerPrivateQuickTimeVisualContext::LayerClient(this))
-    , m_layoutClient(new MediaPlayerPrivateQuickTimeVisualContext::LayoutClient(this))
     , m_movieTransform(CGAffineTransformIdentity)
 #endif
     , m_visualContextClient(new MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient(this))
@@ -203,8 +202,8 @@ PlatformMedia MediaPlayerPrivateQuickTimeVisualContext::platformMedia() const
     p.media.qtMovieVisualContext = m_visualContext.get();
     return p;
 }
-
 #if USE(ACCELERATED_COMPOSITING)
+
 PlatformLayer* MediaPlayerPrivateQuickTimeVisualContext::platformLayer() const
 {
     return m_transformLayer ? m_transformLayer->platformLayer() : 0;
@@ -866,7 +865,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage()
         if (!buffer.pixelBufferRef())
             return;
 
-        WKCACFLayer* layer = m_qtVideoLayer.get();
+        PlatformCALayer* layer = m_qtVideoLayer.get();
 
         if (!buffer.lockBaseAddress()) {
             if (requiredDllsAvailable()) {
@@ -900,7 +899,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage()
             }
 
             buffer.unlockBaseAddress();
-            layer->rootLayer()->setNeedsRender();
+            layer->setNeedsCommit();
         }
     } else
 #endif
@@ -1179,20 +1178,16 @@ void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie()
     if (!m_movie || m_qtVideoLayer)
         return;
 
-    // Create a GraphicsLayer that won't be inserted directly into the render tree, but will used 
-    // as a wrapper for a WKCACFLayer which gets inserted as the content layer of the video 
-    // renderer's GraphicsLayer.
-    m_transformLayer.set(new GraphicsLayerCACF(m_layerClient.get()));
+    // Create a PlatformCALayer which will transform the contents of the video layer
+    // which is in m_qtVideoLayer.
+    m_transformLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, m_layerClient.get());
     if (!m_transformLayer)
         return;
 
-    // Mark the layer as drawing itself, anchored in the top left, and bottom-up.
-    m_transformLayer->setDrawsContent(false);
+    // Mark the layer as anchored in the top left.
     m_transformLayer->setAnchorPoint(FloatPoint3D());
-    m_transformLayer->setContentsOrientation(GraphicsLayer::CompositingCoordinatesBottomUp);
-    m_transformLayer->platformLayer()->setLayoutClient(m_layoutClient.get());
 
-    m_qtVideoLayer = WKCACFLayer::create(WKCACFLayer::Layer);
+    m_qtVideoLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, 0);
     if (!m_qtVideoLayer)
         return;
 
@@ -1209,8 +1204,8 @@ void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie()
 #ifndef NDEBUG
     m_qtVideoLayer->setName("Video layer");
 #endif
-    m_transformLayer->platformLayer()->addSublayer(m_qtVideoLayer.get());
-    m_transformLayer->platformLayer()->setNeedsLayout();
+    m_transformLayer->appendSublayer(m_qtVideoLayer.get());
+    m_transformLayer->setNeedsLayout();
     // The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration().
 #endif
 
@@ -1238,10 +1233,6 @@ void MediaPlayerPrivateQuickTimeVisualContext::destroyLayerForMovie()
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-void MediaPlayerPrivateQuickTimeVisualContext::LayerClient::paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip)
-{
-}
-
 bool MediaPlayerPrivateQuickTimeVisualContext::supportsAcceleratedRendering() const
 {
     return isReadyForRendering();
index 43d5bd5..a12d79e 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(VIDEO)
 
-#include "GraphicsLayer.h"
 #include "MediaPlayerPrivate.h"
 #include "Timer.h"
 #include <wtf/Forward.h>
@@ -51,7 +50,7 @@ class IntSize;
 class IntRect;
 
 #if USE(ACCELERATED_COMPOSITING)
-class WKCACFLayer;
+class PlatformCALayer;
 class WKCAImageQueue;
 #endif
 
@@ -67,8 +66,9 @@ private:
     virtual bool supportsFullscreen() const;
     virtual PlatformMedia platformMedia() const;
 #if USE(ACCELERATED_COMPOSITING)
-    PlatformLayer* platformLayer() const;
+    virtual PlatformLayer* platformLayer() const;
 #endif
+
     IntSize naturalSize() const;
     bool hasVideo() const;
     bool hasAudio() const;
@@ -161,10 +161,6 @@ private:
     class LayerClient;
     friend class LayerClient;
     OwnPtr<LayerClient> m_layerClient;
-
-    class LayoutClient;
-    friend class LayoutClient;
-    OwnPtr<LayoutClient> m_layoutClient;
 #endif
 
     class VisualContextClient;
@@ -178,8 +174,8 @@ private:
     MediaPlayer* m_player;
     RefPtr<QTMovie> m_movie;
 #if USE(ACCELERATED_COMPOSITING)
-    RefPtr<WKCACFLayer> m_qtVideoLayer;
-    OwnPtr<GraphicsLayer> m_transformLayer;
+    RefPtr<PlatformCALayer> m_qtVideoLayer;
+    RefPtr<PlatformCALayer> m_transformLayer;
     OwnPtr<WKCAImageQueue> m_imageQueue;
     OwnPtr<QTDecompressionSession> m_decompressionSession;
     CGAffineTransform m_movieTransform; 
index 39e8a11..431d624 100644 (file)
@@ -50,7 +50,7 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 #include "GraphicsLayerCACF.h"
-#include "WKCACFLayer.h"
+#include "PlatformCALayer.h"
 #endif
 
 #if DRAW_FRAME_RATE
@@ -760,7 +760,7 @@ void MediaPlayerPrivate::movieNewImageAvailable(QTMovieGWorld* movie)
 
 #if USE(ACCELERATED_COMPOSITING)
     if (m_qtVideoLayer)
-        m_qtVideoLayer->platformLayer()->setNeedsDisplay();
+        m_qtVideoLayer->setNeedsDisplay();
     else
 #endif
         m_player->repaint();
@@ -887,7 +887,7 @@ void MediaPlayerPrivate::createLayerForMovie()
         return;
 
     // Create a GraphicsLayer that won't be inserted directly into the render tree, but will used 
-    // as a wrapper for a WKCACFLayer which gets inserted as the content layer of the video 
+    // as a wrapper for a PlatformCALayer which gets inserted as the content layer of the video 
     // renderer's GraphicsLayer.
     m_qtVideoLayer.set(new GraphicsLayerCACF(this));
     if (!m_qtVideoLayer)
index 870c53a..4c5e61d 100644 (file)
 
 #include "WKCACFLayerRenderer.h"
 
+#include "PlatformCALayer.h"
 #include "WKCACFContextFlusher.h"
-#include "WKCACFLayer.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>
@@ -45,6 +47,8 @@
 #include <d3d9.h>
 #include <d3dx9.h>
 
+using namespace std;
+
 #pragma comment(lib, "d3d9")
 #pragma comment(lib, "d3dx9")
 #ifdef DEBUG_ALL
@@ -79,33 +83,6 @@ inline static CGRect winRectToCGRect(RECT rc, RECT relativeToRect)
 
 namespace WebCore {
 
-// Subclass of WKCACFLayer to allow the root layer to have a back pointer to the layer renderer
-// to fire off a draw
-class WKCACFRootLayer : public WKCACFLayer {
-public:
-    WKCACFRootLayer(WKCACFLayerRenderer* renderer)
-        : WKCACFLayer(WKCACFLayer::Layer)
-    {
-        m_renderer = renderer;
-    }
-
-    static PassRefPtr<WKCACFRootLayer> create(WKCACFLayerRenderer* renderer)
-    {
-        if (!WKCACFLayerRenderer::acceleratedCompositingAvailable())
-            return 0;
-        return adoptRef(new WKCACFRootLayer(renderer));
-    }
-
-    virtual void setNeedsRender() { m_renderer->layerTreeDidChange(); }
-
-    // Overload this to avoid calling setNeedsDisplay on the layer, which would override the contents
-    // we have placed on the root layer.
-    virtual void setNeedsDisplay(const CGRect* dirtyRect) { setNeedsCommit(); }
-
-private:
-    WKCACFLayerRenderer* m_renderer;
-};
-
 static D3DPRESENT_PARAMETERS initialPresentationParameters()
 {
     D3DPRESENT_PARAMETERS parameters = {0};
@@ -206,13 +183,17 @@ PassOwnPtr<WKCACFLayerRenderer> WKCACFLayerRenderer::create(WKCACFLayerRendererC
 WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client)
     : m_client(client)
     , m_mightBeAbleToCreateDeviceLater(true)
-    , m_rootLayer(WKCACFRootLayer::create(this))
+    , m_rootLayer(PlatformCALayer::create(PlatformCALayer::LayerTypeRootLayer, 0))
     , m_context(wkCACFContextCreate())
     , m_hostWindow(0)
     , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired)
     , m_backingStoreDirty(false)
     , m_mustResetLostDeviceBeforeRendering(false)
+    , m_syncLayerChanges(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.
@@ -223,7 +204,7 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client)
     // Scrolling will affect only the position of the scroll layer without affecting the bounds.
 
     m_rootLayer->setName("WKCACFLayerRenderer rootLayer");
-    m_rootLayer->setAnchorPoint(CGPointMake(0, 0));
+    m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
     m_rootLayer->setGeometryFlipped(true);
 
 #ifndef NDEBUG
@@ -233,7 +214,7 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client)
 #endif
 
     if (m_context)
-        m_rootLayer->becomeRootLayerForContext(m_context);
+        wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
 
 #ifndef NDEBUG
     char* printTreeFlag = getenv("CA_PRINT_TREE");
@@ -247,11 +228,16 @@ WKCACFLayerRenderer::~WKCACFLayerRenderer()
     wkCACFContextDestroy(m_context);
 }
 
-WKCACFLayer* WKCACFLayerRenderer::rootLayer() const
+PlatformCALayer* WKCACFLayerRenderer::rootLayer() const
 {
     return m_rootLayer.get();
 }
 
+void WKCACFLayerRenderer::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer)
+{
+    m_pendingAnimatedLayers.add(layer);
+}
+
 void WKCACFLayerRenderer::setRootContents(CGImageRef image)
 {
     ASSERT(m_rootLayer);
@@ -266,12 +252,12 @@ void WKCACFLayerRenderer::setRootContentsAndDisplay(CGImageRef image)
     paint();
 }
 
-void WKCACFLayerRenderer::setRootChildLayer(WKCACFLayer* layer)
+void WKCACFLayerRenderer::setRootChildLayer(PlatformCALayer* layer)
 {
     m_rootLayer->removeAllSublayers();
     m_rootChildLayer = layer;
     if (m_rootChildLayer)
-        m_rootLayer->addSublayer(m_rootChildLayer);
+        m_rootLayer->appendSublayer(m_rootChildLayer.get());
 }
    
 void WKCACFLayerRenderer::layerTreeDidChange()
@@ -280,8 +266,11 @@ void WKCACFLayerRenderer::layerTreeDidChange()
     renderSoon();
 }
 
-void WKCACFLayerRenderer::setNeedsDisplay()
+void WKCACFLayerRenderer::setNeedsDisplay(bool sync)
 {
+    if (!m_syncLayerChanges && sync)
+        m_syncLayerChanges = true;
+
     ASSERT(m_rootLayer);
     m_rootLayer->setNeedsDisplay(0);
     renderSoon();
@@ -361,8 +350,7 @@ bool WKCACFLayerRenderer::createRenderer()
 
 void WKCACFLayerRenderer::destroyRenderer()
 {
-    if (m_context)
-        WKCACFContextFlusher::shared().removeContext(m_context);
+    wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
 
     m_d3dDevice = 0;
     if (s_d3d)
@@ -463,20 +451,40 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects)
         return;
     }
 
+    // Sync the layer if needed
+    if (m_syncLayerChanges) {
+        m_client->syncCompositingState();
+        m_syncLayerChanges = false;
+    }
+
     // Flush the root layer to the render tree.
-    WKCACFContextFlusher::shared().flushAllContexts();
+    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);
+    }
 
-    CGRect bounds = this->bounds();
+    m_pendingAnimatedLayers.clear();
 
-    CFTimeInterval t = CACurrentMediaTime();
+    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), t, bounds, windowDirtyRects.data(), windowDirtyRects.size()))
+    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.
 
@@ -496,6 +504,8 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects)
         }
         wkCACFUpdateRectEnumeratorRelease(e);
 
+        timeToNextRender = wkCACFContextGetNextUpdateTime(m_context);
+
         if (rects.isEmpty())
             break;
 
@@ -523,6 +533,10 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects)
     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()
index fae853c..aff1f83 100644 (file)
 
 #include "COMPtr.h"
 #include "Timer.h"
-#include "WKCACFLayer.h"
 
+#include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
-
+#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.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 WKCACFRootLayer;
+class PlatformCALayer;
 
 class WKCACFLayerRendererClient {
 public:
     virtual ~WKCACFLayerRendererClient() { }
     virtual bool shouldRender() const = 0;
+    virtual void animationsStarted(CFTimeInterval) { }
+    virtual void syncCompositingState() { }
 };
 
 // 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 Noncopyable {
+    friend PlatformCALayer;
+
 public:
     static PassOwnPtr<WKCACFLayerRenderer> create(WKCACFLayerRendererClient*);
     ~WKCACFLayerRenderer();
@@ -65,9 +72,9 @@ public:
 
     void setRootContents(CGImageRef);
     void setRootContentsAndDisplay(CGImageRef);
-    void setRootChildLayer(WKCACFLayer* layer);
+    void setRootChildLayer(PlatformCALayer*);
     void layerTreeDidChange();
-    void setNeedsDisplay();
+    void setNeedsDisplay(bool sync = false);
     void setHostWindow(HWND window) { m_hostWindow = window; }
     void setBackingStoreDirty(bool dirty) { m_backingStoreDirty = dirty; }
     bool createRenderer();
@@ -76,7 +83,8 @@ public:
     void renderSoon();
 
 protected:
-    WKCACFLayer* rootLayer() const;
+    PlatformCALayer* rootLayer() const;
+    void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>);
 
 private:
     WKCACFLayerRenderer(WKCACFLayerRendererClient*);
@@ -99,13 +107,16 @@ private:
     WKCACFLayerRendererClient* m_client;
     bool m_mightBeAbleToCreateDeviceLater;
     COMPtr<IDirect3DDevice9> m_d3dDevice;
-    RefPtr<WKCACFRootLayer> m_rootLayer;
-    RefPtr<WKCACFLayer> m_rootChildLayer;
+    RefPtr<PlatformCALayer> m_rootLayer;
+    RefPtr<PlatformCALayer> m_rootChildLayer;
     WKCACFContext* m_context;
     HWND m_hostWindow;
     Timer<WKCACFLayerRenderer> m_renderTimer;
     bool m_backingStoreDirty;
     bool m_mustResetLostDeviceBeforeRendering;
+    bool m_syncLayerChanges;
+    HashSet<RefPtr<PlatformCALayer> > m_pendingAnimatedLayers;
+
 #ifndef NDEBUG
     bool m_printTree;
 #endif
index bac514d..1649372 100644 (file)
@@ -1101,12 +1101,12 @@ void RenderLayerBacking::paintContents(const GraphicsLayer*, GraphicsContext& co
 
 bool RenderLayerBacking::showDebugBorders() const
 {
-    return compositor() ? compositor()->showDebugBorders() : false;
+    return compositor() ? compositor()->compositorShowDebugBorders() : false;
 }
 
 bool RenderLayerBacking::showRepaintCounter() const
 {
-    return compositor() ? compositor()->showRepaintCounter() : false;
+    return compositor() ? compositor()->compositorShowRepaintCounter() : false;
 }
 
 bool RenderLayerBacking::startAnimation(double timeOffset, const Animation* anim, const KeyframeList& keyframes)
index fa25348..ce2224f 100644 (file)
@@ -1351,13 +1351,13 @@ void RenderLayerCompositor::ensureRootPlatformLayer()
         if (!m_clipLayer) {
             ASSERT(!m_scrollLayer);
             // Create a clipping layer if this is an iframe
-            m_clipLayer = GraphicsLayer::create(0);
+            m_clipLayer = GraphicsLayer::create(this);
 #ifndef NDEBUG
             m_clipLayer->setName("iframe Clipping");
 #endif
             m_clipLayer->setMasksToBounds(true);
             
-            m_scrollLayer = GraphicsLayer::create(0);
+            m_scrollLayer = GraphicsLayer::create(this);
 #ifndef NDEBUG
             m_scrollLayer->setName("iframe scrolling");
 #endif
index 06c0bcd..1409c06 100644 (file)
@@ -54,11 +54,11 @@ enum CompositingUpdateType {
 // 
 // There is one RenderLayerCompositor per RenderView.
 
-class RenderLayerCompositor {
+class RenderLayerCompositor : public GraphicsLayerClient {
 public:
     RenderLayerCompositor(RenderView*);
     ~RenderLayerCompositor();
-    
+
     // Return true if this RenderView is in "compositing mode" (i.e. has one or more
     // composited RenderLayers)
     bool inCompositingMode() const { return m_compositing; }
@@ -71,9 +71,6 @@ public:
 
     bool canRender3DTransforms() const;
 
-    bool showDebugBorders() const { return m_showDebugBorders; }
-    bool showRepaintCounter() const { return m_showRepaintCounter; }
-    
     // Copy the accelerated compositing related flags from Settings
     void cacheAcceleratedCompositingFlags();
 
@@ -172,7 +169,22 @@ public:
 
     String layerTreeAsText();
 
+    // These are named to avoid conflicts with the functions in GraphicsLayerClient
+    // These return the actual internal variables.
+    bool compositorShowDebugBorders() const { return m_showDebugBorders; }
+    bool compositorShowRepaintCounter() const { return m_showRepaintCounter; }
+
 private:
+    // GraphicsLayerClient Implementation
+    virtual void notifyAnimationStarted(const GraphicsLayer*, double) { }
+    virtual void notifySyncRequired(const GraphicsLayer*) { scheduleSync(); }
+    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&) { }
+
+    // These calls return false always. They are saying that the layers associated with this client
+    // (the clipLayer and scrollLayer) should never show debugging info.
+    virtual bool showDebugBorders() const { return false; }
+    virtual bool showRepaintCounter() const { return false; }
+    
     // Whether the given RL needs a compositing layer.
     bool needsToBeComposited(const RenderLayer*) const;
     // Whether the layer has an intrinsic need for compositing layer.
index 10db7b8..8d07352 100644 (file)
@@ -1,3 +1,42 @@
+2011-01-07  Chris Marrin  <cmarrin@apple.com>
+
+        Rubber-stamped by Simon Fraser.
+
+        Share code between Mac (CA) and Windows (CACF) GraphicsLayer implementations
+        https://bugs.webkit.org/show_bug.cgi?id=49388
+
+        Change client API for the fullscreen video controller. It now uses a 
+        PlatformCALayerClient so it can use a PlaformCALayer directly. Also
+        updated how to connect the layer tree to the view to reflect the updated
+        hardware compositing logic.
+
+        * FullscreenVideoController.cpp:
+        (FullscreenVideoController::LayerClient::LayerClient):
+        (FullscreenVideoController::LayerClient::platformCALayerRespondsToLayoutChanges):
+        (FullscreenVideoController::LayerClient::platformCALayerAnimationStarted):
+        (FullscreenVideoController::LayerClient::platformCALayerContentsOrientation):
+        (FullscreenVideoController::LayerClient::platformCALayerPaintContents):
+        (FullscreenVideoController::LayerClient::platformCALayerShowDebugBorders):
+        (FullscreenVideoController::LayerClient::platformCALayerShowRepaintCounter):
+        (FullscreenVideoController::LayerClient::platformCALayerIncrementRepaintCount):
+        (FullscreenVideoController::LayerClient::platformCALayerContentsOpaque):
+        (FullscreenVideoController::LayerClient::platformCALayerDrawsContent):
+        (FullscreenVideoController::LayerClient::platformCALayerLayerDidDisplay):
+        (FullscreenVideoController::LayerClient::platformCALayerLayoutSublayersOfLayer):
+        (FullscreenVideoController::FullscreenVideoController):
+        (FullscreenVideoController::~FullscreenVideoController):
+        (FullscreenVideoController::enterFullscreen):
+        * FullscreenVideoController.h:
+        * WebCoreSupport/WebChromeClient.cpp:
+        (WebChromeClient::attachRootGraphicsLayer):
+        (WebChromeClient::scheduleCompositingLayerSync):
+        * WebView.cpp:
+        (WebView::setRootChildLayer):
+        (WebView::animationsStarted):
+        (WebView::syncCompositingState):
+        * WebView.h:
+        (WebView::setRootLayerNeedsDisplay):
+
 2011-01-05  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Darin Adler.
index 5f9b959..ab954f8 100644 (file)
@@ -38,8 +38,8 @@
 #include <WebCore/FontSelector.h>
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/Page.h>
+#include <WebCore/PlatformCALayer.h>
 #include <WebCore/TextRun.h>
-#include <WebCore/WKCACFLayer.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <windowsx.h>
 #include <wtf/StdLibExtras.h>
@@ -174,20 +174,29 @@ void HUDSlider::drag(const IntPoint& point, bool start)
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-class FullscreenVideoController::LayoutClient : public WKCACFLayerLayoutClient {
+class FullscreenVideoController::LayerClient : public WebCore::PlatformCALayerClient {
 public:
-    LayoutClient(FullscreenVideoController* parent);
-    void layoutSublayersOfLayer(WKCACFLayer* layer);
+    LayerClient(FullscreenVideoController* parent) : m_parent(parent) { }
+
+private:
+    virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*);
+    virtual bool platformCALayerRespondsToLayoutChanges() const { return true; }
+
+    virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
+    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
+    virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) { }
+    virtual bool platformCALayerShowDebugBorders() const { return false; }
+    virtual bool platformCALayerShowRepaintCounter() const { return false; }
+    virtual int platformCALayerIncrementRepaintCount() { return 0; }
+
+    virtual bool platformCALayerContentsOpaque() const { return false; }
+    virtual bool platformCALayerDrawsContent() const { return false; }
+    virtual void platformCALayerLayerDidDisplay(PlatformLayer*) { }
 
     FullscreenVideoController* m_parent;
 };
 
-FullscreenVideoController::LayoutClient::LayoutClient(FullscreenVideoController* parent)
-    : m_parent(parent)
-{
-}
-
-void FullscreenVideoController::LayoutClient::layoutSublayersOfLayer(WKCACFLayer* layer) 
+void FullscreenVideoController::LayerClient::platformCALayerLayoutSublayersOfLayer(PlatformCALayer* layer) 
 {
     ASSERT_ARG(layer, layer == m_parent->m_rootChild);
 
@@ -195,7 +204,8 @@ void FullscreenVideoController::LayoutClient::layoutSublayersOfLayer(WKCACFLayer
     if (!mediaElement)
         return;
 
-    WKCACFLayer* videoLayer = mediaElement->platformLayer();
+
+    PlatformCALayer* videoLayer = PlatformCALayer::platformCALayer(mediaElement->platformLayer());
     if (!videoLayer || videoLayer->superlayer() != layer)
         return;
 
@@ -232,20 +242,17 @@ FullscreenVideoController::FullscreenVideoController()
     , m_movingWindow(false)
     , m_timer(this, &FullscreenVideoController::timerFired)
 #if USE(ACCELERATED_COMPOSITING)
-    , m_rootChild(WKCACFLayer::create(WKCACFLayer::Layer))
-    , m_layoutClient(new LayoutClient(this))
+    , m_layerClient(new LayerClient(this))
+    , m_rootChild(PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, m_layerClient.get()))
 #endif
     , m_fullscreenWindow(new MediaPlayerPrivateFullscreenWindow(this))
 {
-#if USE(ACCELERATED_COMPOSITING)
-    m_rootChild->setLayoutClient(m_layoutClient.get());
-#endif
 }
 
 FullscreenVideoController::~FullscreenVideoController()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    m_rootChild->setLayoutClient(0);
+    m_rootChild->setOwner(0);
 #endif
 }
 
@@ -273,8 +280,8 @@ void FullscreenVideoController::enterFullscreen()
 #if USE(ACCELERATED_COMPOSITING)
     m_fullscreenWindow->setRootChildLayer(m_rootChild);
 
-    WKCACFLayer* videoLayer = m_mediaElement->platformLayer();
-    m_rootChild->addSublayer(videoLayer);
+    PlatformCALayer* videoLayer = PlatformCALayer::platformCALayer(m_mediaElement->platformLayer());
+    m_rootChild->appendSublayer(videoLayer);
     m_rootChild->setNeedsLayout();
     m_rootChild->setGeometryFlipped(1);
 #endif
index 9ac8c69..6b56ab5 100644 (file)
@@ -39,7 +39,7 @@
 namespace WebCore {
 class GraphicsContext;
 #if USE(ACCELERATED_COMPOSITING)
-class WKCACFLayer;
+class PlatformCALayer;
 #endif
 }
 
@@ -157,10 +157,10 @@ private:
     WebCore::IntPoint m_hudPosition;
     OwnPtr<WebCore::MediaPlayerPrivateFullscreenWindow> m_fullscreenWindow;
 #if USE(ACCELERATED_COMPOSITING)
-    RefPtr<WebCore::WKCACFLayer> m_rootChild;
-    class LayoutClient;
-    friend class LayoutClient;
-    OwnPtr<LayoutClient> m_layoutClient;
+    class LayerClient;
+    friend class LayerClient;
+    OwnPtr<LayerClient> m_layerClient;
+    RefPtr<WebCore::PlatformCALayer> m_rootChild;
 #endif
 
     HUDButton m_playPauseButton;
index 9bc4799..9446e15 100644 (file)
@@ -820,12 +820,12 @@ void WebChromeClient::setLastSetCursorToCurrentCursor()
 #if USE(ACCELERATED_COMPOSITING)
 void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
 {
-    m_webView->setRootChildLayer(graphicsLayer ? static_cast<WKCACFLayer*>(graphicsLayer->platformLayer()) : 0);
+    m_webView->setRootChildLayer(graphicsLayer ? PlatformCALayer::platformCALayer(graphicsLayer->platformLayer()) : 0);
 }
 
 void WebChromeClient::scheduleCompositingLayerSync()
 {
-    m_webView->setRootLayerNeedsDisplay();
+    m_webView->setRootLayerNeedsDisplay(true);
 }
 
 #endif
index b3107c3..f0d504e 100644 (file)
@@ -6231,7 +6231,7 @@ void WebView::downloadURL(const KURL& url)
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-void WebView::setRootChildLayer(WebCore::WKCACFLayer* layer)
+void WebView::setRootChildLayer(WebCore::PlatformCALayer* layer)
 {
     setAcceleratedCompositing(layer ? true : false);
     if (m_layerRenderer)
@@ -6469,6 +6469,20 @@ bool WebView::shouldRender() const
 
     return !frameView->layoutPending();
 }
+
+void WebView::animationsStarted(CFTimeInterval t)
+{
+    // Tell the animation controller that its animations have started
+    m_page->mainFrame()->animation()->notifyAnimationStarted(0, t);
+}
+
+void WebView::syncCompositingState()
+{
+    Frame* coreFrame = core(m_mainFrame);
+    if (coreFrame && coreFrame->view())
+        coreFrame->view()->syncCompositingStateRecursive();
+}
+
 #endif
 
 class EnumTextMatches : public IEnumTextMatches
index 424b03a..192c05c 100644 (file)
@@ -40,7 +40,7 @@
 #include <wtf/RefPtr.h>
 
 #if USE(ACCELERATED_COMPOSITING)
-#include <WebCore/WKCACFLayer.h>
+#include <WebCore/PlatformCALayer.h>
 #include <WebCore/WKCACFLayerRenderer.h>
 #endif
 
@@ -904,8 +904,12 @@ public:
     void downloadURL(const WebCore::KURL&);
 
 #if USE(ACCELERATED_COMPOSITING)
-    void setRootLayerNeedsDisplay() { if (m_layerRenderer) m_layerRenderer->setNeedsDisplay(); }
-    void setRootChildLayer(WebCore::WKCACFLayer* layer);
+    void setRootLayerNeedsDisplay(bool sync = false)
+    {
+        if (m_layerRenderer)
+            m_layerRenderer->setNeedsDisplay(sync);
+    }
+    void setRootChildLayer(WebCore::PlatformCALayer*);
 #endif
 
     void enterFullscreenForNode(WebCore::Node*);
@@ -941,6 +945,8 @@ private:
 #if USE(ACCELERATED_COMPOSITING)
     // WKCACFLayerRendererClient
     virtual bool shouldRender() const;
+    virtual void animationsStarted(CFTimeInterval);
+    virtual void syncCompositingState();
 #endif
 
 protected: