[UI-side compositing] Proxy animations to the UI process
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Mar 2014 23:15:58 +0000 (23:15 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Mar 2014 23:15:58 +0000 (23:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130946

Source/WebCore:

Reviewed by Tim Horton.

To proxy CA animations, make PlatformCAAnimation a pure virtual base class
and subclass for Mac, Windows, and Remote (just like PlatformCALayer).

Add coding support for TimingFunctions.

Do some minor #include tidyup.

Minor refactor in GraphicsLayerCA to share some animations code.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* platform/animation/TimingFunction.h: Add setters need for encode/decode.
(WebCore::CubicBezierTimingFunction::setValues):
(WebCore::CubicBezierTimingFunction::setTimingFunctionPreset):
(WebCore::StepsTimingFunction::create):
(WebCore::StepsTimingFunction::setNumberOfSteps):
(WebCore::StepsTimingFunction::setStepAtStart):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::createPlatformCAAnimation):
(WebCore::GraphicsLayerCA::animationCanBeAccelerated): Minor refactor so we can share
code with GraphicsLayerCARemote.
(WebCore::GraphicsLayerCA::addAnimation):
(WebCore::GraphicsLayerCA::createBasicAnimation):
(WebCore::PassRefPtr<PlatformCAAnimation>GraphicsLayerCA::createKeyframeAnimation):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCAAnimation.h:
(WebCore::PlatformCAAnimation::~PlatformCAAnimation):
(WebCore::PlatformCAAnimation::isPlatformCAAnimationMac):
(WebCore::PlatformCAAnimation::isPlatformCAAnimationWin):
(WebCore::PlatformCAAnimation::isPlatformCAAnimationRemote):
(WebCore::PlatformCAAnimation::PlatformCAAnimation):
(WebCore::PlatformCAAnimation::setType):
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/mac/PlatformCAAnimationMac.h: Added.
* platform/graphics/ca/mac/PlatformCAAnimationMac.mm:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayerMac::addAnimationForKey):
(PlatformCALayerMac::animationForKey):
* platform/graphics/ca/mac/TileController.mm:
* platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
* platform/graphics/ca/win/PlatformCAAnimationWin.h: Added.

Source/WebKit2:

Reviewed by Tim Horton.

Add encoding/decoding of TimingFunctions. Add encoding support
for HashSet.

Add PlatformCAAnimationRemote and have PlatformCALayerRemote allow
animations now. PlatformCALayerRemote's properties are defined in the class,
as is the encoding/decoding (much cleaner than having them in the transaction
class I think).

Add support for the "animationDidStart" callback and sending this back to the
web process. This involves a HashMap of layerID->WKAnimationDelegate stored
on the RemoteLayerTreeHost, and a message send via the DrawingArea. On the
other side, RemoteLayerTreeContext stores a HashMap of layerID->PlatformCALayerRemote*
for layers which have just started animations, which is used to get the
PlatformCALayer* to call animationDidStart() on.

This requires that the RemoteLayerTreeHost* be passed down into property application,
and that the RemoteLayerTreeHost have a reference to the drawing area.

To every CALayer in the UI process we -setValue:forKey: to track the PlatformLayerID,
so we can get back to it in order to dispatch "animationDidStart".

Replace some "using namespace WebKit" with "namespace WebKit { }".

* Platform/IPC/ArgumentCoders.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<LinearTimingFunction>::encode):
(IPC::ArgumentCoder<LinearTimingFunction>::decode):
(IPC::ArgumentCoder<CubicBezierTimingFunction>::encode):
(IPC::ArgumentCoder<CubicBezierTimingFunction>::decode):
(IPC::ArgumentCoder<StepsTimingFunction>::encode):
(IPC::ArgumentCoder<StepsTimingFunction>::decode):
* Shared/WebCoreArgumentCoders.h:
* Shared/mac/RemoteLayerBackingStore.mm:
* Shared/mac/RemoteLayerTreePropertyApplier.h:
* Shared/mac/RemoteLayerTreePropertyApplier.mm:
(WebKit::applyPropertiesToLayer):
(WebKit::RemoteLayerTreePropertyApplier::applyProperties):
* Shared/mac/RemoteLayerTreeTransaction.h:
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::dumpChangedLayers):
* UIProcess/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::layerID):
(WebKit::RemoteLayerTreeHost::createLayer):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
(WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
(WebKit::RemoteLayerTreeDrawingAreaProxy::showDebugIndicator):
* UIProcess/mac/RemoteLayerTreeHost.h:
(WebKit::RemoteLayerTreeHost::animationDelegates):
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::RemoteLayerTreeHost):
(WebKit::RemoteLayerTreeHost::updateLayerTree):
(WebKit::RemoteLayerTreeHost::layerWillBeRemoved):
(WebKit::RemoteLayerTreeHost::animationDidStart):
(WebKit::RemoteLayerTreeHost::layerID):
(WebKit::RemoteLayerTreeHost::createLayer):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::acceleratedAnimationDidStart):
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
(WebKit::GraphicsLayerCARemote::createPlatformCAAnimation):
* WebProcess/WebPage/mac/GraphicsLayerCARemote.h:
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.h: Added.
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm: Added.
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
(WebKit::PlatformCALayerRemote::animationStarted):
(WebKit::PlatformCALayerRemote::addAnimationForKey):
(WebKit::PlatformCALayerRemote::removeAnimationForKey):
(WebKit::PlatformCALayerRemote::animationForKey):
(PlatformCALayerRemote::recursiveBuildTransaction): Deleted.
(PlatformCALayerRemote::addAnimationForKey): Deleted.
(PlatformCALayerRemote::removeAnimationForKey): Deleted.
(PlatformCALayerRemote::animationForKey): Deleted.
* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
* WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
(WebKit::RemoteLayerTreeContext::willStartAnimationOnLayer):
(WebKit::RemoteLayerTreeContext::animationDidStart):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):

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

46 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/animation/TimingFunction.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.h [new file with mode: 0644]
Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/platform/graphics/ca/mac/TileController.mm
Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.h [new file with mode: 0644]
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/IPC/ArgumentCoders.h
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h
Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.h
Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index 7e20a53..44432eb 100644 (file)
@@ -1,3 +1,52 @@
+2014-03-31  Simon Fraser  <simon.fraser@apple.com>
+
+        [UI-side compositing] Proxy animations to the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=130946
+
+        Reviewed by Tim Horton.
+        
+        To proxy CA animations, make PlatformCAAnimation a pure virtual base class
+        and subclass for Mac, Windows, and Remote (just like PlatformCALayer).
+        
+        Add coding support for TimingFunctions.
+        
+        Do some minor #include tidyup.
+        
+        Minor refactor in GraphicsLayerCA to share some animations code.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/animation/TimingFunction.h: Add setters need for encode/decode.
+        (WebCore::CubicBezierTimingFunction::setValues):
+        (WebCore::CubicBezierTimingFunction::setTimingFunctionPreset):
+        (WebCore::StepsTimingFunction::create):
+        (WebCore::StepsTimingFunction::setNumberOfSteps):
+        (WebCore::StepsTimingFunction::setStepAtStart):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::createPlatformCAAnimation):
+        (WebCore::GraphicsLayerCA::animationCanBeAccelerated): Minor refactor so we can share
+        code with GraphicsLayerCARemote.
+        (WebCore::GraphicsLayerCA::addAnimation):
+        (WebCore::GraphicsLayerCA::createBasicAnimation):
+        (WebCore::PassRefPtr<PlatformCAAnimation>GraphicsLayerCA::createKeyframeAnimation):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/PlatformCAAnimation.h:
+        (WebCore::PlatformCAAnimation::~PlatformCAAnimation):
+        (WebCore::PlatformCAAnimation::isPlatformCAAnimationMac):
+        (WebCore::PlatformCAAnimation::isPlatformCAAnimationWin):
+        (WebCore::PlatformCAAnimation::isPlatformCAAnimationRemote):
+        (WebCore::PlatformCAAnimation::PlatformCAAnimation):
+        (WebCore::PlatformCAAnimation::setType):
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/mac/PlatformCAAnimationMac.h: Added.
+        * platform/graphics/ca/mac/PlatformCAAnimationMac.mm:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayerMac::addAnimationForKey):
+        (PlatformCALayerMac::animationForKey):
+        * platform/graphics/ca/mac/TileController.mm:
+        * platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
+        * platform/graphics/ca/win/PlatformCAAnimationWin.h: Added.
+
 2014-03-31  Benjamin Poulain  <benjamin@webkit.org>
 
         CSS JIT: compile the first-child pseudo class
index b303ef7..459d08a 100644 (file)
@@ -717,6 +717,7 @@ __ZN7WebCore16nextLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
 __ZN7WebCore16scriptNameToCodeERKN3WTF6StringE
 __ZN7WebCore16startOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
 __ZN7WebCore16threadGlobalDataEv
+__ZN7WebCore16toCAFillModeTypeENS_19PlatformCAAnimation12FillModeTypeE
 __ZN7WebCore17CredentialStorage24getFromPersistentStorageERKNS_15ProtectionSpaceE
 __ZN7WebCore17CredentialStorage3getERKNS_15ProtectionSpaceE
 __ZN7WebCore17DOMImplementation13isXMLMIMETypeERKN3WTF6StringE
@@ -792,9 +793,6 @@ __ZN7WebCore19MediaSessionManager17beginInterruptionEv
 __ZN7WebCore19MediaSessionManager17removeRestrictionENS_12MediaSession9MediaTypeEj
 __ZN7WebCore19MediaSessionManager30didReceiveRemoteControlCommandENS_12MediaSession24RemoteControlCommandTypeE
 __ZN7WebCore19MediaSessionManager9addClientEPNS_25MediaSessionManagerClientE
-__ZN7WebCore19PlatformCAAnimation10setToValueERKNS_20TransformationMatrixE
-__ZN7WebCore19PlatformCAAnimation6createEP19CAPropertyAnimation
-__ZN7WebCore19PlatformCAAnimationD1Ev
 __ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
 __ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
 __ZN7WebCore19ResourceRequestBase18setHTTPHeaderFieldEPKcRKN3WTF6StringE
@@ -901,10 +899,12 @@ __ZN7WebCore21memoryPressureHandlerEv
 __ZN7WebCore21resourceLoadSchedulerEv
 __ZN7WebCore21setGlobalIconDatabaseEPNS_16IconDatabaseBaseE
 __ZN7WebCore21setPlatformStrategiesEPNS_18PlatformStrategiesE
+__ZN7WebCore21toCAValueFunctionTypeENS_19PlatformCAAnimation17ValueFunctionTypeE
 __ZN7WebCore22HTMLPlugInImageElement24restartSnapshottedPlugInEv
 __ZN7WebCore22HTMLPlugInImageElement29setIsPrimarySnapshottedPlugInEb
 __ZN7WebCore22MutableStyleProperties25ensureCSSStyleDeclarationEv
 __ZN7WebCore22MutableStylePropertiesD1Ev
+__ZN7WebCore22PlatformCAAnimationMac6createEP19CAPropertyAnimation
 __ZN7WebCore22RuntimeEnabledFeatures14sharedFeaturesEv
 __ZN7WebCore22ScriptExecutionContext26canSuspendActiveDOMObjectsEv
 __ZN7WebCore22ScriptExecutionContext2vmEv
@@ -940,6 +940,7 @@ __ZN7WebCore23decodeHostNameWithRangeEP8NSString8_NSRange
 __ZN7WebCore23encodeHostNameWithRangeEP8NSString8_NSRange
 __ZN7WebCore23getFileModificationTimeERKN3WTF6StringERl
 __ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
+__ZN7WebCore23toCAMediaTimingFunctionEPKNS_14TimingFunctionEb
 __ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
 __ZN7WebCore24DocumentMarkerController10markersForEPNS_4NodeENS_14DocumentMarker11MarkerTypesE
 __ZN7WebCore24DocumentMarkerController13removeMarkersENS_14DocumentMarker11MarkerTypesE
@@ -1644,6 +1645,7 @@ __ZNK7WebCore15GraphicsLayerCA14primaryLayerIDEv
 __ZNK7WebCore15GraphicsLayerCA18getDebugBorderInfoERNS_5ColorERf
 __ZNK7WebCore15GraphicsLayerCA21canThrottleLayerFlushEv
 __ZNK7WebCore15GraphicsLayerCA24dumpAdditionalPropertiesERNS_10TextStreamEij
+__ZNK7WebCore15GraphicsLayerCA25animationCanBeAcceleratedERKNS_17KeyframeValueListEPKNS_9AnimationE
 __ZNK7WebCore15GraphicsLayerCA25shouldRepaintOnSizeChangeEv
 __ZNK7WebCore15GraphicsLayerCA26backingStoreMemoryEstimateEv
 __ZNK7WebCore15GraphicsLayerCA30visibleRectChangeRequiresFlushERKNS_9FloatRectE
index 15660be..d0f5ea8 100644 (file)
     <ClInclude Include="..\platform\graphics\avfoundation\InbandTextTrackPrivateAVF.h" />
     <ClInclude Include="..\platform\graphics\cairo\TileCairo.h" />
     <ClInclude Include="..\platform\graphics\ca\PlatformCAFilters.h" />
+    <ClInclude Include="..\platform\graphics\ca\win\PlatformCAAnimationWin.h" />
     <ClInclude Include="..\platform\graphics\ca\win\PlatformCALayerWin.h" />
     <ClInclude Include="..\platform\graphics\GLContext.h" />
     <ClInclude Include="..\platform\graphics\GraphicsContext3DPrivate.h" />
index f9f240e..7521973 100644 (file)
                0F580FAF149800D400FB5BD8 /* AnimationUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F580FAE149800D400FB5BD8 /* AnimationUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F5B7A5410F65D7A00376302 /* RenderEmbeddedObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */; };
                0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               0F5E200618E771FC003EC3E5 /* PlatformCAAnimationMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5E200518E771FC003EC3E5 /* PlatformCAAnimationMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F605AEC15F94848004DF0C0 /* ScrollingConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */; };
                0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */; };
                0F580FAE149800D400FB5BD8 /* AnimationUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationUtilities.h; path = animation/AnimationUtilities.h; sourceTree = "<group>"; };
                0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderEmbeddedObject.cpp; sourceTree = "<group>"; };
                0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderEmbeddedObject.h; sourceTree = "<group>"; };
+               0F5E200518E771FC003EC3E5 /* PlatformCAAnimationMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCAAnimationMac.h; path = ca/mac/PlatformCAAnimationMac.h; sourceTree = "<group>"; };
                0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingConstraints.cpp; sourceTree = "<group>"; };
                0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingConstraints.h; sourceTree = "<group>"; };
                0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadedScrollingTree.cpp; sourceTree = "<group>"; };
                                2917B565147349950052C9D0 /* LayerFlushSchedulerMac.cpp */,
                                93F72AF11666EDFC002A02BD /* LayerPool.h */,
                                93F72AF21666EDFC002A02BD /* LayerPool.mm */,
+                               0F5E200518E771FC003EC3E5 /* PlatformCAAnimationMac.h */,
                                4958781F12A57DDF007238AC /* PlatformCAAnimationMac.mm */,
                                D66B2D5B186830050073C4DD /* PlatformCAFiltersMac.h */,
                                0F13163F16ED0CDE0035CC04 /* PlatformCAFiltersMac.mm */,
                                1A85B1900A1B18A200D8C87C /* JSHTMLHtmlElement.h in Headers */,
                                BC4918C90BFEA050009D6316 /* JSHTMLIFrameElement.h in Headers */,
                                1AE2AA980A1CDD2D00B42B25 /* JSHTMLImageElement.h in Headers */,
+                               0F5E200618E771FC003EC3E5 /* PlatformCAAnimationMac.h in Headers */,
                                A80E7E970A1A83E3007FB8C5 /* JSHTMLInputElement.h in Headers */,
                                E1AD14231295EA7F00ACA989 /* JSHTMLInputElementCustom.h in Headers */,
                                A6148A7912E41E3B0044A784 /* JSHTMLKeygenElement.h in Headers */,
index 6113993..887626a 100644 (file)
@@ -32,6 +32,8 @@ namespace WebCore {
 class TimingFunction : public RefCounted<TimingFunction> {
 public:
 
+    virtual PassRefPtr<TimingFunction> clone() const = 0;
+
     enum TimingFunctionType {
         LinearFunction, CubicBezierFunction, StepsFunction
     };
@@ -68,14 +70,19 @@ public:
     {
         return other.isLinearTimingFunction();
     }
-    
+
 private:
     LinearTimingFunction()
         : TimingFunction(LinearFunction)
     {
     }
+
+    virtual PassRefPtr<TimingFunction> clone() const override
+    {
+        return adoptRef(new LinearTimingFunction);
+    }
 };
-    
+
 class CubicBezierTimingFunction : public TimingFunction {
 public:
     enum TimingFunctionPreset {
@@ -132,7 +139,16 @@ public:
     double x2() const { return m_x2; }
     double y2() const { return m_y2; }
     
+    void setValues(double x1, double y1, double x2, double y2)
+    {
+        m_x1 = x1;
+        m_y1 = y1;
+        m_x2 = x2;
+        m_y2 = y2;
+    }
+    
     TimingFunctionPreset timingFunctionPreset() const { return m_timingFunctionPreset; }
+    void setTimingFunctionPreset(TimingFunctionPreset preset) { m_timingFunctionPreset = preset; }
     
     static const CubicBezierTimingFunction* defaultTimingFunction()
     {
@@ -156,6 +172,11 @@ private:
     {
     }
 
+    virtual PassRefPtr<TimingFunction> clone() const override
+    {
+        return adoptRef(new CubicBezierTimingFunction(m_timingFunctionPreset, m_x1, m_y1, m_x2, m_y2));
+    }
+
     double m_x1;
     double m_y1;
     double m_x2;
@@ -165,10 +186,15 @@ private:
 
 class StepsTimingFunction : public TimingFunction {
 public:
+    
     static PassRefPtr<StepsTimingFunction> create(int steps, bool stepAtStart)
     {
         return adoptRef(new StepsTimingFunction(steps, stepAtStart));
     }
+    static PassRefPtr<StepsTimingFunction> create()
+    {
+        return adoptRef(new StepsTimingFunction(1, true));
+    }
     
     virtual ~StepsTimingFunction() { }
     
@@ -182,7 +208,10 @@ public:
     }
     
     int numberOfSteps() const { return m_steps; }
+    void setNumberOfSteps(int steps) { m_steps = steps; }
+
     bool stepAtStart() const { return m_stepAtStart; }
+    void setStepAtStart(bool stepAtStart) { m_stepAtStart = stepAtStart; }
     
 private:
     StepsTimingFunction(int steps, bool stepAtStart)
@@ -191,11 +220,16 @@ private:
         , m_stepAtStart(stepAtStart)
     {
     }
+
+    virtual PassRefPtr<TimingFunction> clone() const override
+    {
+        return adoptRef(new StepsTimingFunction(m_steps, m_stepAtStart));
+    }
     
     int m_steps;
     bool m_stepAtStart;
 };
-    
+
 } // namespace WebCore
 
 #endif // TimingFunction_h
index 217cbce..4664947 100644 (file)
@@ -31,6 +31,7 @@
 #include "FloatConversion.h"
 #include "FloatRect.h"
 #include "GraphicsLayerFactory.h"
+#include "Image.h"
 #include "PlatformCAFilters.h"
 #include "PlatformCALayer.h"
 #include "RotateTransformOperation.h"
 #endif
 
 #if PLATFORM(COCOA)
+#include "PlatformCAAnimationMac.h"
 #include "PlatformCALayerMac.h"
 #include "WebCoreSystemInterface.h"
 #endif
 
 #if PLATFORM(WIN)
+#include "PlatformCAAnimationWin.h"
 #include "PlatformCALayerWin.h"
 #endif
 
@@ -341,6 +344,15 @@ PassRefPtr<PlatformCALayer> GraphicsLayerCA::createPlatformCALayer(PlatformLayer
 #endif
 }
 
+PassRefPtr<PlatformCAAnimation> GraphicsLayerCA::createPlatformCAAnimation(PlatformCAAnimation::AnimationType type, const String& keyPath)
+{
+#if PLATFORM(COCOA)
+    return PlatformCAAnimationMac::create(type, keyPath);
+#elif PLATFORM(WIN)
+    return PlatformCAAnimationWin::create(type, keyPath);
+#endif
+}
+
 GraphicsLayerCA::GraphicsLayerCA(GraphicsLayerClient* client)
     : GraphicsLayer(client)
     , m_contentsLayerPurpose(NoContentsLayer)
@@ -787,18 +799,24 @@ bool GraphicsLayerCA::shouldRepaintOnSizeChange() const
     return drawsContent() && !tiledBacking();
 }
 
-bool GraphicsLayerCA::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& animationName, double timeOffset)
+bool GraphicsLayerCA::animationCanBeAccelerated(const KeyframeValueList& valueList, const Animation* anim) const
 {
-    ASSERT(!animationName.isEmpty());
-
     if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2)
         return false;
 
-    // CoreAnimation does not handle the steps() timing function. Fall back
-    // to software animation in that case.
     if (animationHasStepsTimingFunction(valueList, anim))
         return false;
 
+    return true;
+}
+
+bool GraphicsLayerCA::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& animationName, double timeOffset)
+{
+    ASSERT(!animationName.isEmpty());
+
+    if (!animationCanBeAccelerated(valueList, anim))
+        return false;
+
     bool createdAnimations = false;
     if (valueList.property() == AnimatedPropertyWebkitTransform)
         createdAnimations = createTransformAnimationsFromKeyframes(valueList, anim, animationName, timeOffset, boxSize);
@@ -2576,14 +2594,14 @@ bool GraphicsLayerCA::createFilterAnimationsFromKeyframes(const KeyframeValueLis
 
 PassRefPtr<PlatformCAAnimation> GraphicsLayerCA::createBasicAnimation(const Animation* anim, const String& keyPath, bool additive)
 {
-    RefPtr<PlatformCAAnimation> basicAnim = PlatformCAAnimation::create(PlatformCAAnimation::Basic, keyPath);
+    RefPtr<PlatformCAAnimation> basicAnim = createPlatformCAAnimation(PlatformCAAnimation::Basic, keyPath);
     setupAnimation(basicAnim.get(), anim, additive);
     return basicAnim;
 }
 
 PassRefPtr<PlatformCAAnimation>GraphicsLayerCA::createKeyframeAnimation(const Animation* anim, const String& keyPath, bool additive)
 {
-    RefPtr<PlatformCAAnimation> keyframeAnim = PlatformCAAnimation::create(PlatformCAAnimation::Keyframe, keyPath);
+    RefPtr<PlatformCAAnimation> keyframeAnim = createPlatformCAAnimation(PlatformCAAnimation::Keyframe, keyPath);
     setupAnimation(keyframeAnim.get(), anim, additive);
     return keyframeAnim;
 }
index fb2aff4..391ad6c 100644 (file)
@@ -27,7 +27,6 @@
 #define GraphicsLayerCA_h
 
 #include "GraphicsLayer.h"
-#include "Image.h"
 #include "PlatformCAAnimation.h"
 #include "PlatformCALayer.h"
 #include "PlatformCALayerClient.h"
@@ -42,6 +41,7 @@
 
 namespace WebCore {
 
+class Image;
 class TransformState;
 
 class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
@@ -170,6 +170,8 @@ public:
 
 protected:
     virtual void setOpacityInternal(float);
+    
+    bool animationCanBeAccelerated(const KeyframeValueList&, const Animation*) const;
 
 private:
     virtual bool isGraphicsLayerCA() const { return true; }
@@ -214,6 +216,7 @@ private:
 
     virtual PassRefPtr<PlatformCALayer> createPlatformCALayer(PlatformCALayer::LayerType, PlatformCALayerClient* owner);
     virtual PassRefPtr<PlatformCALayer> createPlatformCALayer(PlatformLayer*, PlatformCALayerClient* owner);
+    virtual PassRefPtr<PlatformCAAnimation> createPlatformCAAnimation(PlatformCAAnimation::AnimationType, const String& keyPath);
 
     PlatformCALayer* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); }
     PlatformCALayer* hostLayerForSublayers() const;
index 260481c..05b430a 100644 (file)
 #include "FloatPoint3D.h"
 #include "TransformationMatrix.h"
 #include <wtf/RefCounted.h>
-#include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 
-#if PLATFORM(COCOA)
-OBJC_CLASS CAPropertyAnimation;
-typedef CAPropertyAnimation* PlatformAnimationRef;
-#elif PLATFORM(WIN)
-typedef struct _CACFAnimation* CACFAnimationRef;
-typedef CACFAnimationRef PlatformAnimationRef;
-#endif
-
 namespace WebCore {
 
 class FloatRect;
-class PlatformCAAnimation;
 class TimingFunction;
 
 class PlatformCAAnimation : public RefCounted<PlatformCAAnimation> {
 public:
-    friend class PlatformCALayer;
-#if PLATFORM(COCOA)
-    friend class PlatformCALayerMac;
-#elif PLATFORM(WIN)
-    friend class PlatformCALayerWin;
-#endif
-    
     enum AnimationType { Basic, Keyframe };
     enum FillModeType { NoFillMode, Forwards, Backwards, Both };
     enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate };
 
-    static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
-    static PassRefPtr<PlatformCAAnimation> create(PlatformAnimationRef);
+    virtual ~PlatformCAAnimation() { }
 
-    ~PlatformCAAnimation();
+    virtual bool isPlatformCAAnimationMac() const { return false; }
+    virtual bool isPlatformCAAnimationWin() const { return false; }
+    virtual bool isPlatformCAAnimationRemote() const { return false; }
     
-    PassRefPtr<PlatformCAAnimation> copy() const;
-
-    PlatformAnimationRef platformAnimation() const;
+    virtual PassRefPtr<PlatformCAAnimation> copy() const = 0;
     
     AnimationType animationType() const { return m_type; }
-    String keyPath() const;
+    virtual String keyPath() const = 0;
     
-    CFTimeInterval beginTime() const;
-    void setBeginTime(CFTimeInterval);
+    virtual CFTimeInterval beginTime() const = 0;
+    virtual void setBeginTime(CFTimeInterval) = 0;
     
-    CFTimeInterval duration() const;
-    void setDuration(CFTimeInterval);
+    virtual CFTimeInterval duration() const = 0;
+    virtual void setDuration(CFTimeInterval) = 0;
     
-    float speed() const;
-    void setSpeed(float);
+    virtual float speed() const = 0;
+    virtual void setSpeed(float) = 0;
 
-    CFTimeInterval timeOffset() const;
-    void setTimeOffset(CFTimeInterval);
+    virtual CFTimeInterval timeOffset() const = 0;
+    virtual void setTimeOffset(CFTimeInterval) = 0;
 
-    float repeatCount() const;
-    void setRepeatCount(float);
+    virtual float repeatCount() const = 0;
+    virtual void setRepeatCount(float) = 0;
 
-    bool autoreverses() const;
-    void setAutoreverses(bool);
+    virtual bool autoreverses() const = 0;
+    virtual void setAutoreverses(bool) = 0;
 
-    FillModeType fillMode() const;
-    void setFillMode(FillModeType);
+    virtual FillModeType fillMode() const = 0;
+    virtual void setFillMode(FillModeType) = 0;
     
-    void setTimingFunction(const TimingFunction*, bool reverse = false);
-    void copyTimingFunctionFrom(const PlatformCAAnimation*);
+    virtual void setTimingFunction(const TimingFunction*, bool reverse = false) = 0;
+    virtual void copyTimingFunctionFrom(const PlatformCAAnimation*) = 0;
 
-    bool isRemovedOnCompletion() const;
-    void setRemovedOnCompletion(bool);
+    virtual bool isRemovedOnCompletion() const = 0;
+    virtual void setRemovedOnCompletion(bool) = 0;
 
-    bool isAdditive() const;
-    void setAdditive(bool);
+    virtual bool isAdditive() const = 0;
+    virtual void setAdditive(bool) = 0;
 
-    ValueFunctionType valueFunction() const;
-    void setValueFunction(ValueFunctionType);
+    virtual ValueFunctionType valueFunction() const = 0;
+    virtual void setValueFunction(ValueFunctionType) = 0;
 
     // Basic-animation properties.
-    void setFromValue(float);
-    void setFromValue(const WebCore::TransformationMatrix&);
-    void setFromValue(const FloatPoint3D&);
-    void setFromValue(const WebCore::Color&);
+    virtual void setFromValue(float) = 0;
+    virtual void setFromValue(const WebCore::TransformationMatrix&) = 0;
+    virtual void setFromValue(const FloatPoint3D&) = 0;
+    virtual void setFromValue(const WebCore::Color&) = 0;
 #if ENABLE(CSS_FILTERS)
-    void setFromValue(const FilterOperation*, int internalFilterPropertyIndex);
+    virtual void setFromValue(const FilterOperation*, int internalFilterPropertyIndex) = 0;
 #endif
-    void copyFromValueFrom(const PlatformCAAnimation*);
+    virtual void copyFromValueFrom(const PlatformCAAnimation*) = 0;
 
-    void setToValue(float);
-    void setToValue(const WebCore::TransformationMatrix&);
-    void setToValue(const FloatPoint3D&);
-    void setToValue(const WebCore::Color&);
+    virtual void setToValue(float) = 0;
+    virtual void setToValue(const WebCore::TransformationMatrix&) = 0;
+    virtual void setToValue(const FloatPoint3D&) = 0;
+    virtual void setToValue(const WebCore::Color&) = 0;
 #if ENABLE(CSS_FILTERS)
-    void setToValue(const FilterOperation*, int internalFilterPropertyIndex);
+    virtual void setToValue(const FilterOperation*, int internalFilterPropertyIndex) = 0;
 #endif
-    void copyToValueFrom(const PlatformCAAnimation*);
+    virtual void copyToValueFrom(const PlatformCAAnimation*) = 0;
 
     // Keyframe-animation properties.
-    void setValues(const Vector<float>&);
-    void setValues(const Vector<WebCore::TransformationMatrix>&);
-    void setValues(const Vector<FloatPoint3D>&);
-    void setValues(const Vector<WebCore::Color>&);
+    virtual void setValues(const Vector<float>&) = 0;
+    virtual void setValues(const Vector<WebCore::TransformationMatrix>&) = 0;
+    virtual void setValues(const Vector<FloatPoint3D>&) = 0;
+    virtual void setValues(const Vector<WebCore::Color>&) = 0;
 #if ENABLE(CSS_FILTERS)
-    void setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex);
+    virtual void setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex) = 0;
 #endif
-    void copyValuesFrom(const PlatformCAAnimation*);
-
-    void setKeyTimes(const Vector<float>&);
-    void copyKeyTimesFrom(const PlatformCAAnimation*);
+    virtual void copyValuesFrom(const PlatformCAAnimation*) = 0;
 
-    void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false);
-    void copyTimingFunctionsFrom(const PlatformCAAnimation*);
+    virtual void setKeyTimes(const Vector<float>&) = 0;
+    virtual void copyKeyTimesFrom(const PlatformCAAnimation*) = 0;
 
-protected:
-    PlatformCAAnimation(AnimationType, const String& keyPath);
-    PlatformCAAnimation(PlatformAnimationRef);
+    virtual void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false) = 0;
+    virtual void copyTimingFunctionsFrom(const PlatformCAAnimation*) = 0;
 
     void setActualStartTimeIfNeeded(CFTimeInterval t)
     {
         if (beginTime() <= 0)
             setBeginTime(t);
     }
+    
+protected:
+    PlatformCAAnimation(AnimationType type = Basic)
+        : m_type(type)
+    {
+    }
+
+    void setType(AnimationType type) { m_type = type; }
 
 private:
     AnimationType m_type;
-    
-#if PLATFORM(COCOA)
-    RetainPtr<CAPropertyAnimation> m_animation;
-#elif PLATFORM(WIN)
-    RetainPtr<CACFAnimationRef> m_animation;
-#endif
 };
 
+#define PLATFORM_CAANIMATION_TYPE_CASTS(ToValueTypeName, predicate) \
+    TYPE_CASTS_BASE(ToValueTypeName, WebCore::PlatformCAAnimation, object, object->predicate, object.predicate)
+
 }
 
 #endif // PlatformCAAnimation_h
index 81db712..1e00683 100644 (file)
@@ -26,9 +26,7 @@
 #ifndef PlatformCALayer_h
 #define PlatformCALayer_h
 
-#include "GraphicsContext.h"
 #include "GraphicsLayer.h"
-#include "PlatformCAAnimation.h"
 #include "PlatformCALayerClient.h"
 #include <QuartzCore/CABase.h>
 #include <wtf/CurrentTime.h>
 
 OBJC_CLASS AVPlayerLayer;
 
+#if PLATFORM(COCOA)
+typedef struct CGContext *CGContextRef;
+#endif
+
 namespace WebCore {
 
 class PlatformCALayer;
+class PlatformCAAnimation;
 
 typedef Vector<RefPtr<PlatformCALayer>> PlatformCALayerList;
 
diff --git a/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.h b/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.h
new file mode 100644 (file)
index 0000000..16eb4e8
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2014 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 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 PlatformCAAnimationMac_h
+#define PlatformCAAnimationMac_h
+
+#include "PlatformCAAnimation.h"
+
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS CAMediaTimingFunction;
+OBJC_CLASS CAPropertyAnimation;
+OBJC_CLASS NSString;
+
+typedef CAPropertyAnimation* PlatformAnimationRef;
+
+namespace WebCore {
+
+NSString* toCAFillModeType(PlatformCAAnimation::FillModeType);
+NSString* toCAValueFunctionType(PlatformCAAnimation::ValueFunctionType);
+CAMediaTimingFunction* toCAMediaTimingFunction(const TimingFunction*, bool reverse);
+
+class PlatformCAAnimationMac final : public PlatformCAAnimation {
+public:
+    static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
+    static PassRefPtr<PlatformCAAnimation> create(PlatformAnimationRef);
+
+    virtual ~PlatformCAAnimationMac();
+
+    virtual bool isPlatformCAAnimationMac() const override { return true; }
+
+    virtual PassRefPtr<PlatformCAAnimation> copy() const override;
+
+    PlatformAnimationRef platformAnimation() const;
+    
+    virtual String keyPath() const override;
+    
+    virtual CFTimeInterval beginTime() const override;
+    virtual void setBeginTime(CFTimeInterval) override;
+    
+    virtual CFTimeInterval duration() const override;
+    virtual void setDuration(CFTimeInterval) override;
+    
+    virtual float speed() const override;
+    virtual void setSpeed(float) override;
+
+    virtual CFTimeInterval timeOffset() const override;
+    virtual void setTimeOffset(CFTimeInterval) override;
+
+    virtual float repeatCount() const override;
+    virtual void setRepeatCount(float) override;
+
+    virtual bool autoreverses() const override;
+    virtual void setAutoreverses(bool) override;
+
+    virtual FillModeType fillMode() const override;
+    virtual void setFillMode(FillModeType) override;
+    
+    virtual void setTimingFunction(const TimingFunction*, bool reverse = false) override;
+    void copyTimingFunctionFrom(const PlatformCAAnimation*) override;
+
+    virtual bool isRemovedOnCompletion() const override;
+    virtual void setRemovedOnCompletion(bool) override;
+
+    virtual bool isAdditive() const override;
+    virtual void setAdditive(bool) override;
+
+    virtual ValueFunctionType valueFunction() const override;
+    virtual void setValueFunction(ValueFunctionType) override;
+
+    // Basic-animation properties.
+    virtual void setFromValue(float) override;
+    virtual void setFromValue(const WebCore::TransformationMatrix&) override;
+    virtual void setFromValue(const FloatPoint3D&) override;
+    virtual void setFromValue(const WebCore::Color&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setFromValue(const FilterOperation*, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyFromValueFrom(const PlatformCAAnimation*) override;
+
+    virtual void setToValue(float) override;
+    virtual void setToValue(const WebCore::TransformationMatrix&) override;
+    virtual void setToValue(const FloatPoint3D&) override;
+    virtual void setToValue(const WebCore::Color&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setToValue(const FilterOperation*, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyToValueFrom(const PlatformCAAnimation*) override;
+
+    // Keyframe-animation properties.
+    virtual void setValues(const Vector<float>&) override;
+    virtual void setValues(const Vector<WebCore::TransformationMatrix>&) override;
+    virtual void setValues(const Vector<FloatPoint3D>&) override;
+    virtual void setValues(const Vector<WebCore::Color>&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyValuesFrom(const PlatformCAAnimation*) override;
+
+    virtual void setKeyTimes(const Vector<float>&) override;
+    virtual void copyKeyTimesFrom(const PlatformCAAnimation*) override;
+
+    virtual void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false) override;
+    virtual void copyTimingFunctionsFrom(const PlatformCAAnimation*) override;
+
+protected:
+    PlatformCAAnimationMac(AnimationType, const String& keyPath);
+    PlatformCAAnimationMac(PlatformAnimationRef);
+
+private:
+    RetainPtr<CAPropertyAnimation> m_animation;
+};
+
+PLATFORM_CAANIMATION_TYPE_CASTS(PlatformCAAnimationMac, isPlatformCAAnimationMac())
+
+}
+
+#endif // PlatformCAAnimationMac_h
index c07c7ac..2ea286a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,7 +25,7 @@
 
 #include "config.h"
 
-#import "PlatformCAAnimation.h"
+#import "PlatformCAAnimationMac.h"
 
 #import "FloatConversion.h"
 #import "PlatformCAFilters.h"
@@ -40,15 +40,15 @@ static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroB
 
 static bool hasNonZeroBeginTimeFlag(const PlatformCAAnimation* animation)
 {
-    return [[animation->platformAnimation() valueForKey:WKNonZeroBeginTimeFlag] boolValue];
+    return [[toPlatformCAAnimationMac(animation)->platformAnimation() valueForKey:WKNonZeroBeginTimeFlag] boolValue];
 }
 
 static void setNonZeroBeginTimeFlag(PlatformCAAnimation* animation, bool value)
 {
-    [animation->platformAnimation() setValue:[NSNumber numberWithBool:value] forKey:WKNonZeroBeginTimeFlag];
+    [toPlatformCAAnimationMac(animation)->platformAnimation() setValue:[NSNumber numberWithBool:value] forKey:WKNonZeroBeginTimeFlag];
 }
     
-static NSString* toCAFillModeType(PlatformCAAnimation::FillModeType type)
+NSString* WebCore::toCAFillModeType(PlatformCAAnimation::FillModeType type)
 {
     switch (type) {
     case PlatformCAAnimation::NoFillMode:
@@ -70,7 +70,7 @@ static PlatformCAAnimation::FillModeType fromCAFillModeType(NSString* string)
     return PlatformCAAnimation::Forwards;
 }
 
-static NSString* toCAValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
+NSString* WebCore::toCAValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
 {
     switch (type) {
     case PlatformCAAnimation::NoValueFunction: return @"";
@@ -127,7 +127,7 @@ static PlatformCAAnimation::ValueFunctionType fromCAValueFunctionType(NSString*
     return PlatformCAAnimation::NoValueFunction;
 }
 
-static CAMediaTimingFunction* toCAMediaTimingFunction(const TimingFunction* timingFunction, bool reverse)
+CAMediaTimingFunction* WebCore::toCAMediaTimingFunction(const TimingFunction* timingFunction, bool reverse)
 {
     ASSERT(timingFunction);
     if (timingFunction->isCubicBezierTimingFunction()) {
@@ -146,21 +146,22 @@ static CAMediaTimingFunction* toCAMediaTimingFunction(const TimingFunction* timi
         return [CAMediaTimingFunction functionWithControlPoints: x1 : y1 : x2 : y2];
     }
     
+    ASSERT(timingFunction->type() == TimingFunction::LinearFunction);
     return [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
 }
 
-PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(AnimationType type, const String& keyPath)
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::create(AnimationType type, const String& keyPath)
 {
-    return adoptRef(new PlatformCAAnimation(type, keyPath));
+    return adoptRef(new PlatformCAAnimationMac(type, keyPath));
 }
 
-PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(PlatformAnimationRef animation)
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::create(PlatformAnimationRef animation)
 {
-    return adoptRef(new PlatformCAAnimation(animation));
+    return adoptRef(new PlatformCAAnimationMac(animation));
 }
 
-PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPath)
-    : m_type(type)
+PlatformCAAnimationMac::PlatformCAAnimationMac(AnimationType type, const String& keyPath)
+    : PlatformCAAnimation(type)
 {
     if (type == Basic)
         m_animation = [CABasicAnimation animationWithKeyPath:keyPath];
@@ -168,12 +169,12 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa
         m_animation = [CAKeyframeAnimation animationWithKeyPath:keyPath];
 }
 
-PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
+PlatformCAAnimationMac::PlatformCAAnimationMac(PlatformAnimationRef animation)
 {
     if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CABasicAnimation class]])
-        m_type = Basic;
+        setType(Basic);
     else if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CAKeyframeAnimation class]])
-        m_type = Keyframe;
+        setType(Keyframe);
     else {
         ASSERT(0);
         return;
@@ -182,7 +183,11 @@ PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
     m_animation = static_cast<CAPropertyAnimation*>(animation);
 }
 
-PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::copy() const
+PlatformCAAnimationMac::~PlatformCAAnimationMac()
+{
+}
+
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::copy() const
 {
     RefPtr<PlatformCAAnimation> animation = create(animationType(), keyPath());
     
@@ -212,26 +217,23 @@ PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::copy() const
     
     return animation;
 }
-PlatformCAAnimation::~PlatformCAAnimation()
-{
-}
 
-PlatformAnimationRef PlatformCAAnimation::platformAnimation() const
+PlatformAnimationRef PlatformCAAnimationMac::platformAnimation() const
 {
     return m_animation.get();
 }
 
-String PlatformCAAnimation::keyPath() const
+String PlatformCAAnimationMac::keyPath() const
 {
     return [m_animation.get() keyPath];
 }
 
-CFTimeInterval PlatformCAAnimation::beginTime() const
+CFTimeInterval PlatformCAAnimationMac::beginTime() const
 {
     return [m_animation.get() beginTime];
 }
 
-void PlatformCAAnimation::setBeginTime(CFTimeInterval value)
+void PlatformCAAnimationMac::setBeginTime(CFTimeInterval value)
 {
     [m_animation.get() setBeginTime:value];
     
@@ -243,115 +245,115 @@ void PlatformCAAnimation::setBeginTime(CFTimeInterval value)
         setNonZeroBeginTimeFlag(this, true);
 }
 
-CFTimeInterval PlatformCAAnimation::duration() const
+CFTimeInterval PlatformCAAnimationMac::duration() const
 {
     return [m_animation.get() duration];
 }
 
-void PlatformCAAnimation::setDuration(CFTimeInterval value)
+void PlatformCAAnimationMac::setDuration(CFTimeInterval value)
 {
     [m_animation.get() setDuration:value];
 }
 
-float PlatformCAAnimation::speed() const
+float PlatformCAAnimationMac::speed() const
 {
     return [m_animation.get() speed];
 }
 
-void PlatformCAAnimation::setSpeed(float value)
+void PlatformCAAnimationMac::setSpeed(float value)
 {
     [m_animation.get() setSpeed:value];
 }
 
-CFTimeInterval PlatformCAAnimation::timeOffset() const
+CFTimeInterval PlatformCAAnimationMac::timeOffset() const
 {
     return [m_animation.get() timeOffset];
 }
 
-void PlatformCAAnimation::setTimeOffset(CFTimeInterval value)
+void PlatformCAAnimationMac::setTimeOffset(CFTimeInterval value)
 {
     [m_animation.get() setTimeOffset:value];
 }
 
-float PlatformCAAnimation::repeatCount() const
+float PlatformCAAnimationMac::repeatCount() const
 {
     return [m_animation.get() repeatCount];
 }
 
-void PlatformCAAnimation::setRepeatCount(float value)
+void PlatformCAAnimationMac::setRepeatCount(float value)
 {
     [m_animation.get() setRepeatCount:value];
 }
 
-bool PlatformCAAnimation::autoreverses() const
+bool PlatformCAAnimationMac::autoreverses() const
 {
     return [m_animation.get() autoreverses];
 }
 
-void PlatformCAAnimation::setAutoreverses(bool value)
+void PlatformCAAnimationMac::setAutoreverses(bool value)
 {
     [m_animation.get() setAutoreverses:value];
 }
 
-PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const
+PlatformCAAnimation::FillModeType PlatformCAAnimationMac::fillMode() const
 {
     return fromCAFillModeType([m_animation.get() fillMode]);
 }
 
-void PlatformCAAnimation::setFillMode(FillModeType value)
+void PlatformCAAnimationMac::setFillMode(FillModeType value)
 {
     [m_animation.get() setFillMode:toCAFillModeType(value)];
 }
 
-void PlatformCAAnimation::setTimingFunction(const TimingFunction* value, bool reverse)
+void PlatformCAAnimationMac::setTimingFunction(const TimingFunction* value, bool reverse)
 {
     [m_animation.get() setTimingFunction:toCAMediaTimingFunction(value, reverse)];
 }
 
-void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationMac::copyTimingFunctionFrom(const PlatformCAAnimation* value)
 {
-    [m_animation.get() setTimingFunction:[value->m_animation.get() timingFunction]];
+    [m_animation.get() setTimingFunction:[toPlatformCAAnimationMac(value)->m_animation.get() timingFunction]];
 }
 
-bool PlatformCAAnimation::isRemovedOnCompletion() const
+bool PlatformCAAnimationMac::isRemovedOnCompletion() const
 {
     return [m_animation.get() isRemovedOnCompletion];
 }
 
-void PlatformCAAnimation::setRemovedOnCompletion(bool value)
+void PlatformCAAnimationMac::setRemovedOnCompletion(bool value)
 {
     [m_animation.get() setRemovedOnCompletion:value];
 }
 
-bool PlatformCAAnimation::isAdditive() const
+bool PlatformCAAnimationMac::isAdditive() const
 {
     return [m_animation.get() isAdditive];
 }
 
-void PlatformCAAnimation::setAdditive(bool value)
+void PlatformCAAnimationMac::setAdditive(bool value)
 {
     [m_animation.get() setAdditive:value];
 }
 
-PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() const
+PlatformCAAnimation::ValueFunctionType PlatformCAAnimationMac::valueFunction() const
 {
     CAValueFunction* vf = [m_animation.get() valueFunction];
     return fromCAValueFunctionType([vf name]);
 }
 
-void PlatformCAAnimation::setValueFunction(ValueFunctionType value)
+void PlatformCAAnimationMac::setValueFunction(ValueFunctionType value)
 {
     [m_animation.get() setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(value)]];
 }
 
-void PlatformCAAnimation::setFromValue(float value)
+void PlatformCAAnimationMac::setFromValue(float value)
 {
     if (animationType() != Basic)
         return;
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[NSNumber numberWithDouble:value]];
 }
 
-void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& value)
+void PlatformCAAnimationMac::setFromValue(const WebCore::TransformationMatrix& value)
 {
     if (animationType() != Basic)
         return;
@@ -359,7 +361,7 @@ void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& valu
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[NSValue valueWithCATransform3D:value]];
 }
 
-void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
+void PlatformCAAnimationMac::setFromValue(const FloatPoint3D& value)
 {
     if (animationType() != Basic)
         return;
@@ -372,7 +374,7 @@ void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:array];
 }
 
-void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
+void PlatformCAAnimationMac::setFromValue(const WebCore::Color& value)
 {
     if (animationType() != Basic)
         return;
@@ -387,30 +389,30 @@ void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
 }
 
 #if ENABLE(CSS_FILTERS)
-void PlatformCAAnimation::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
+void PlatformCAAnimationMac::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
 {
     RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:value.get()];
 }
 #endif
 
-void PlatformCAAnimation::copyFromValueFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationMac::copyFromValueFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Basic || value->animationType() != Basic)
         return;
         
-    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(value->m_animation.get());
+    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[otherAnimation fromValue]];
 }
 
-void PlatformCAAnimation::setToValue(float value)
+void PlatformCAAnimationMac::setToValue(float value)
 {
     if (animationType() != Basic)
         return;
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[NSNumber numberWithDouble:value]];
 }
 
-void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
+void PlatformCAAnimationMac::setToValue(const WebCore::TransformationMatrix& value)
 {
     if (animationType() != Basic)
         return;
@@ -418,7 +420,7 @@ void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[NSValue valueWithCATransform3D:value]];
 }
 
-void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
+void PlatformCAAnimationMac::setToValue(const FloatPoint3D& value)
 {
     if (animationType() != Basic)
         return;
@@ -431,7 +433,7 @@ void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:array];
 }
 
-void PlatformCAAnimation::setToValue(const WebCore::Color& value)
+void PlatformCAAnimationMac::setToValue(const WebCore::Color& value)
 {
     if (animationType() != Basic)
         return;
@@ -446,25 +448,25 @@ void PlatformCAAnimation::setToValue(const WebCore::Color& value)
 }
 
 #if ENABLE(CSS_FILTERS)
-void PlatformCAAnimation::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
+void PlatformCAAnimationMac::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
 {
     RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:value.get()];
 }
 #endif
 
-void PlatformCAAnimation::copyToValueFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationMac::copyToValueFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Basic || value->animationType() != Basic)
         return;
         
-    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(value->m_animation.get());
+    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[otherAnimation toValue]];
 }
 
 
 // Keyframe-animation properties.
-void PlatformCAAnimation::setValues(const Vector<float>& value)
+void PlatformCAAnimationMac::setValues(const Vector<float>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -475,7 +477,7 @@ void PlatformCAAnimation::setValues(const Vector<float>& value)
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
-void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>& value)
+void PlatformCAAnimationMac::setValues(const Vector<WebCore::TransformationMatrix>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -488,7 +490,7 @@ void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>&
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
-void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
+void PlatformCAAnimationMac::setValues(const Vector<FloatPoint3D>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -506,7 +508,7 @@ void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
-void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
+void PlatformCAAnimationMac::setValues(const Vector<WebCore::Color>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -526,7 +528,7 @@ void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
 }
 
 #if ENABLE(CSS_FILTERS)
-void PlatformCAAnimation::setValues(const Vector<RefPtr<FilterOperation>>& values, int internalFilterPropertyIndex)
+void PlatformCAAnimationMac::setValues(const Vector<RefPtr<FilterOperation>>& values, int internalFilterPropertyIndex)
 {
     if (animationType() != Keyframe)
         return;
@@ -541,16 +543,16 @@ void PlatformCAAnimation::setValues(const Vector<RefPtr<FilterOperation>>& value
 }
 #endif
 
-void PlatformCAAnimation::copyValuesFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationMac::copyValuesFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Keyframe || value->animationType() != Keyframe)
         return;
         
-    CAKeyframeAnimation* otherAnimation = static_cast<CAKeyframeAnimation*>(value->m_animation.get());
+    CAKeyframeAnimation* otherAnimation = static_cast<CAKeyframeAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:[otherAnimation values]];
 }
 
-void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
+void PlatformCAAnimationMac::setKeyTimes(const Vector<float>& value)
 {
     NSMutableArray* array = [NSMutableArray array];
 
@@ -560,13 +562,13 @@ void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setKeyTimes:array];
 }
 
-void PlatformCAAnimation::copyKeyTimesFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationMac::copyKeyTimesFrom(const PlatformCAAnimation* value)
 {
-    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(value->m_animation.get());
+    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setKeyTimes:[other keyTimes]];
 }
 
-void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
+void PlatformCAAnimationMac::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
 {
     NSMutableArray* array = [NSMutableArray array];
 
@@ -576,8 +578,8 @@ void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:array];
 }
 
-void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationMac::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
 {
-    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(value->m_animation.get());
+    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:[other timingFunctions]];
 }
index 6856a22..cf8e30a 100644 (file)
@@ -32,6 +32,7 @@
 #import "GraphicsContext.h"
 #import "GraphicsLayerCA.h"
 #import "LengthFunctions.h"
+#import "PlatformCAAnimationMac.h"
 #import "PlatformCAFilters.h"
 #import "PlatformCAFiltersMac.h"
 #import "ScrollbarThemeMac.h"
@@ -395,12 +396,12 @@ void PlatformCALayerMac::addAnimationForKey(const String& key, PlatformCAAnimati
         [webAnimationDelegate setOwner:this];
     }
     
-    CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(animation->platformAnimation());
+    CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(toPlatformCAAnimationMac(animation)->platformAnimation());
     if (![propertyAnimation delegate])
         [propertyAnimation setDelegate:static_cast<id>(m_delegate.get())];
      
     BEGIN_BLOCK_OBJC_EXCEPTIONS
-    [m_layer.get() addAnimation:animation->m_animation.get() forKey:key];
+    [m_layer.get() addAnimation:propertyAnimation forKey:key];
     END_BLOCK_OBJC_EXCEPTIONS
 }
 
@@ -416,7 +417,7 @@ PassRefPtr<PlatformCAAnimation> PlatformCALayerMac::animationForKey(const String
     CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer.get() animationForKey:key]);
     if (!propertyAnimation)
         return 0;
-    return PlatformCAAnimation::create(propertyAnimation);
+    return PlatformCAAnimationMac::create(propertyAnimation);
 }
 
 void PlatformCALayerMac::setMask(PlatformCALayer* layer)
index 5d857b5..1a9f555 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "TileController.h"
 
+#import "GraphicsContext.h"
 #import "IntRect.h"
 #import "PlatformCALayer.h"
 #import "Region.h"
index 2a5c3f2..cc1c26e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,7 +25,8 @@
 
 #include "config.h"
 
-#include "PlatformCAAnimation.h"
+#if PLATFORM(WIN)
+#include "PlatformCAAnimationWin.h"
 
 #include "FloatConversion.h"
 #include "TimingFunction.h"
@@ -141,18 +142,18 @@ static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunctio
     return CACFTimingFunctionGetFunctionWithName(kCACFTimingFunctionLinear);
 }
 
-PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(AnimationType type, const String& keyPath)
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationWin::create(AnimationType type, const String& keyPath)
 {
-    return adoptRef(new PlatformCAAnimation(type, keyPath));
+    return adoptRef(new PlatformCAAnimationWin(type, keyPath));
 }
 
-PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(PlatformAnimationRef animation)
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationWin::create(PlatformAnimationRef animation)
 {
-    return adoptRef(new PlatformCAAnimation(animation));
+    return adoptRef(new PlatformCAAnimationWin(animation));
 }
 
-PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPath)
-    : m_type(type)
+PlatformCAAnimationWin::PlatformCAAnimationWin(AnimationType type, const String& keyPath)
+    : PlatformCAAnimation(type)
 {
     if (type == Basic)
         m_animation = adoptCF(CACFAnimationCreate(kCACFBasicAnimation));
@@ -162,12 +163,12 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa
     CACFAnimationSetKeyPath(m_animation.get(), keyPath.createCFString().get());
 }
 
-PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
+PlatformCAAnimationWin::PlatformCAAnimationWin(PlatformAnimationRef animation)
 {
     if (CACFAnimationGetClass(animation) == kCACFBasicAnimation)
-        m_type = Basic;
+        setType(Basic);
     else if (CACFAnimationGetClass(animation) == kCACFKeyframeAnimation)
-        m_type = Keyframe;
+        setType(Keyframe);
     else {
         ASSERT_NOT_REACHED();
         return;
@@ -176,7 +177,7 @@ PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
     m_animation = animation;
 }
 
-PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::copy() const
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationWin::copy() const
 {
     RefPtr<PlatformCAAnimation> animation = create(animationType(), keyPath());
     
@@ -206,136 +207,136 @@ PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::copy() const
     return animation;
 }
 
-PlatformCAAnimation::~PlatformCAAnimation()
+PlatformCAAnimationWin::~PlatformCAAnimationWin()
 {
 }
 
-PlatformAnimationRef PlatformCAAnimation::platformAnimation() const
+PlatformAnimationRef PlatformCAAnimationWin::platformAnimation() const
 {
     return m_animation.get();
 }
 
-String PlatformCAAnimation::keyPath() const
+String PlatformCAAnimationWin::keyPath() const
 {
     return CACFAnimationGetKeyPath(m_animation.get());
 }
 
-CFTimeInterval PlatformCAAnimation::beginTime() const
+CFTimeInterval PlatformCAAnimationWin::beginTime() const
 {
     return CACFAnimationGetBeginTime(m_animation.get());
 }
 
-void PlatformCAAnimation::setBeginTime(CFTimeInterval value)
+void PlatformCAAnimationWin::setBeginTime(CFTimeInterval value)
 {
     CACFAnimationSetBeginTime(m_animation.get(), value);
 }
 
-CFTimeInterval PlatformCAAnimation::duration() const
+CFTimeInterval PlatformCAAnimationWin::duration() const
 {
     return CACFAnimationGetDuration(m_animation.get());
 }
 
-void PlatformCAAnimation::setDuration(CFTimeInterval value)
+void PlatformCAAnimationWin::setDuration(CFTimeInterval value)
 {
     CACFAnimationSetDuration(m_animation.get(), value);
 }
 
-float PlatformCAAnimation::speed() const
+float PlatformCAAnimationWin::speed() const
 {
     return CACFAnimationGetSpeed(m_animation.get());
 }
 
-void PlatformCAAnimation::setSpeed(float value)
+void PlatformCAAnimationWin::setSpeed(float value)
 {
     CACFAnimationSetSpeed(m_animation.get(), value);
 }
 
-CFTimeInterval PlatformCAAnimation::timeOffset() const
+CFTimeInterval PlatformCAAnimationWin::timeOffset() const
 {
     return CACFAnimationGetTimeOffset(m_animation.get());
 }
 
-void PlatformCAAnimation::setTimeOffset(CFTimeInterval value)
+void PlatformCAAnimationWin::setTimeOffset(CFTimeInterval value)
 {
     CACFAnimationSetTimeOffset(m_animation.get(), value);
 }
 
-float PlatformCAAnimation::repeatCount() const
+float PlatformCAAnimationWin::repeatCount() const
 {
     return CACFAnimationGetRepeatCount(m_animation.get());
 }
 
-void PlatformCAAnimation::setRepeatCount(float value)
+void PlatformCAAnimationWin::setRepeatCount(float value)
 {
     CACFAnimationSetRepeatCount(m_animation.get(), value);
 }
 
-bool PlatformCAAnimation::autoreverses() const
+bool PlatformCAAnimationWin::autoreverses() const
 {
     return CACFAnimationGetAutoreverses(m_animation.get());
 }
 
-void PlatformCAAnimation::setAutoreverses(bool value)
+void PlatformCAAnimationWin::setAutoreverses(bool value)
 {
     CACFAnimationSetAutoreverses(m_animation.get(), value);
 }
 
-PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const
+PlatformCAAnimationWin::FillModeType PlatformCAAnimationWin::fillMode() const
 {
     return fromCACFFillModeType(CACFAnimationGetFillMode(m_animation.get()));
 }
 
-void PlatformCAAnimation::setFillMode(FillModeType value)
+void PlatformCAAnimationWin::setFillMode(FillModeType value)
 {
     CACFAnimationSetFillMode(m_animation.get(), toCACFFillModeType(value));
 }
 
-void PlatformCAAnimation::setTimingFunction(const TimingFunction* value, bool reverse)
+void PlatformCAAnimationWin::setTimingFunction(const TimingFunction* value, bool reverse)
 {
     UNUSED_PARAM(reverse);
     CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value, reverse).get());
 }
 
-void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationWin::copyTimingFunctionFrom(const PlatformCAAnimation* value)
 {
-    CACFTimingFunctionRef timingFunc = CACFAnimationGetTimingFunction(value->m_animation.get());
+    CACFTimingFunctionRef timingFunc = CACFAnimationGetTimingFunction(toPlatformCAAnimationWin(value)->m_animation.get());
     if (timingFunc)
         CACFAnimationSetTimingFunction(m_animation.get(), timingFunc);
 }
 
-bool PlatformCAAnimation::isRemovedOnCompletion() const
+bool PlatformCAAnimationWin::isRemovedOnCompletion() const
 {
     return CACFAnimationIsRemovedOnCompletion(m_animation.get());
 }
 
-void PlatformCAAnimation::setRemovedOnCompletion(bool value)
+void PlatformCAAnimationWin::setRemovedOnCompletion(bool value)
 {
     CACFAnimationSetRemovedOnCompletion(m_animation.get(), value);
 }
 
-bool PlatformCAAnimation::isAdditive() const
+bool PlatformCAAnimationWin::isAdditive() const
 {
     return CACFAnimationIsAdditive(m_animation.get());
 }
 
-void PlatformCAAnimation::setAdditive(bool value)
+void PlatformCAAnimationWin::setAdditive(bool value)
 {
     CACFAnimationSetAdditive(m_animation.get(), value);
 }
 
-PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() const
+PlatformCAAnimation::ValueFunctionType PlatformCAAnimationWin::valueFunction() const
 {
     CACFValueFunctionRef func = CACFAnimationGetValueFunction(m_animation.get());
     return func ? fromCACFValueFunctionType(CACFValueFunctionGetName(func)) : NoValueFunction;
 }
 
-void PlatformCAAnimation::setValueFunction(ValueFunctionType value)
+void PlatformCAAnimationWin::setValueFunction(ValueFunctionType value)
 {
     CFStringRef valueString = toCACFValueFunctionType(value);
     CACFAnimationSetValueFunction(m_animation.get(), valueString ? CACFValueFunctionGetFunctionWithName(valueString) : 0);
 }
 
-void PlatformCAAnimation::setFromValue(float value)
+void PlatformCAAnimationWin::setFromValue(float value)
 {
     if (animationType() != Basic)
         return;
@@ -344,7 +345,7 @@ void PlatformCAAnimation::setFromValue(float value)
     CACFAnimationSetFromValue(m_animation.get(), v.get());
 }
 
-void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& value)
+void PlatformCAAnimationWin::setFromValue(const WebCore::TransformationMatrix& value)
 {
     if (animationType() != Basic)
         return;
@@ -353,7 +354,7 @@ void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& valu
     CACFAnimationSetFromValue(m_animation.get(), v.get());
 }
 
-void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
+void PlatformCAAnimationWin::setFromValue(const FloatPoint3D& value)
 {
     if (animationType() != Basic)
         return;
@@ -363,7 +364,7 @@ void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
     CACFAnimationSetFromValue(m_animation.get(), v.get());
 }
 
-void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
+void PlatformCAAnimationWin::setFromValue(const WebCore::Color& value)
 {
     if (animationType() != Basic)
         return;
@@ -374,21 +375,21 @@ void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
 }
 
 #if ENABLE(CSS_FILTERS)
-void PlatformCAAnimation::setFromValue(const FilterOperation*, int)
+void PlatformCAAnimationWin::setFromValue(const FilterOperation*, int)
 {
     // FIXME: Hardware filter animation not implemented on Windows
 }
 #endif
 
-void PlatformCAAnimation::copyFromValueFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationWin::copyFromValueFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Basic || value->animationType() != Basic)
         return;
     
-    CACFAnimationSetFromValue(m_animation.get(), CACFAnimationGetFromValue(value->platformAnimation()));
+    CACFAnimationSetFromValue(m_animation.get(), CACFAnimationGetFromValue(toPlatformCAAnimationWin(value)->platformAnimation()));
 }
 
-void PlatformCAAnimation::setToValue(float value)
+void PlatformCAAnimationWin::setToValue(float value)
 {
     if (animationType() != Basic)
         return;
@@ -397,7 +398,7 @@ void PlatformCAAnimation::setToValue(float value)
     CACFAnimationSetToValue(m_animation.get(), v.get());
 }
 
-void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
+void PlatformCAAnimationWin::setToValue(const WebCore::TransformationMatrix& value)
 {
     if (animationType() != Basic)
         return;
@@ -406,7 +407,7 @@ void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
     CACFAnimationSetToValue(m_animation.get(), v.get());
 }
 
-void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
+void PlatformCAAnimationWin::setToValue(const FloatPoint3D& value)
 {
     if (animationType() != Basic)
         return;
@@ -416,7 +417,7 @@ void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
     CACFAnimationSetToValue(m_animation.get(), v.get());
 }
 
-void PlatformCAAnimation::setToValue(const WebCore::Color& value)
+void PlatformCAAnimationWin::setToValue(const WebCore::Color& value)
 {
     if (animationType() != Basic)
         return;
@@ -427,23 +428,22 @@ void PlatformCAAnimation::setToValue(const WebCore::Color& value)
 }
 
 #if ENABLE(CSS_FILTERS)
-void PlatformCAAnimation::setToValue(const FilterOperation*, int)
+void PlatformCAAnimationWin::setToValue(const FilterOperation*, int)
 {
     // FIXME: Hardware filter animation not implemented on Windows
 }
 #endif
 
-void PlatformCAAnimation::copyToValueFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationWin::copyToValueFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Basic || value->animationType() != Basic)
         return;
         
-    CACFAnimationSetToValue(m_animation.get(), CACFAnimationGetToValue(value->platformAnimation()));
+    CACFAnimationSetToValue(m_animation.get(), CACFAnimationGetToValue(toPlatformCAAnimationWin(value)->platformAnimation()));
 }
 
-
 // Keyframe-animation properties.
-void PlatformCAAnimation::setValues(const Vector<float>& value)
+void PlatformCAAnimationWin::setValues(const Vector<float>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -457,7 +457,7 @@ void PlatformCAAnimation::setValues(const Vector<float>& value)
     CACFAnimationSetValues(m_animation.get(), array.get());
 }
 
-void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>& value)
+void PlatformCAAnimationWin::setValues(const Vector<WebCore::TransformationMatrix>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -471,7 +471,7 @@ void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>&
     CACFAnimationSetValues(m_animation.get(), array.get());
 }
 
-void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
+void PlatformCAAnimationWin::setValues(const Vector<FloatPoint3D>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -486,7 +486,7 @@ void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
     CACFAnimationSetValues(m_animation.get(), array.get());
 }
 
-void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
+void PlatformCAAnimationWin::setValues(const Vector<WebCore::Color>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -502,21 +502,21 @@ void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
 }
 
 #if ENABLE(CSS_FILTERS)
-void PlatformCAAnimation::setValues(const Vector<RefPtr<FilterOperation> >&, int)
+void PlatformCAAnimationWin::setValues(const Vector<RefPtr<FilterOperation> >&, int)
 {
     // FIXME: Hardware filter animation not implemented on Windows
 }
 #endif
 
-void PlatformCAAnimation::copyValuesFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationWin::copyValuesFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Keyframe || value->animationType() != Keyframe)
         return;
     
-    CACFAnimationSetValues(m_animation.get(), CACFAnimationGetValues(value->platformAnimation()));
+    CACFAnimationSetValues(m_animation.get(), CACFAnimationGetValues(toPlatformCAAnimationWin(value)->platformAnimation()));
 }
 
-void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
+void PlatformCAAnimationWin::setKeyTimes(const Vector<float>& value)
 {
     if (animationType() != Keyframe)
         return;
@@ -530,15 +530,15 @@ void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
     CACFAnimationSetKeyTimes(m_animation.get(), array.get());
 }
 
-void PlatformCAAnimation::copyKeyTimesFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationWin::copyKeyTimesFrom(const PlatformCAAnimation* value)
 {
     if (animationType() != Keyframe)
         return;
 
-    CACFAnimationSetKeyTimes(m_animation.get(), CACFAnimationGetKeyTimes(value->platformAnimation()));
+    CACFAnimationSetKeyTimes(m_animation.get(), CACFAnimationGetKeyTimes(toPlatformCAAnimationWin(value)->platformAnimation()));
 }
 
-void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
+void PlatformCAAnimationWin::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
 {
     UNUSED_PARAM(reverse);
     if (animationType() != Keyframe)
@@ -553,7 +553,9 @@ void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>
     CACFAnimationSetTimingFunctions(m_animation.get(), array.get());
 }
 
-void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
+void PlatformCAAnimationWin::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
 {
-    CACFAnimationSetTimingFunctions(m_animation.get(), CACFAnimationGetTimingFunctions(value->platformAnimation()));
+    CACFAnimationSetTimingFunctions(m_animation.get(), CACFAnimationGetTimingFunctions(toPlatformCAAnimationWin(value)->platformAnimation()));
 }
+
+#endif // PLATFORM(WIN)
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.h b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.h
new file mode 100644 (file)
index 0000000..dd2b19f
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2014 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 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 PlatformCAAnimationWin_h
+#define PlatformCAAnimationWin_h
+
+#if PLATFORM(WIN)
+
+#include "PlatformCAAnimation.h"
+#include <wtf/RetainPtr.h>
+
+typedef struct _CACFAnimation* CACFAnimationRef;
+typedef CACFAnimationRef PlatformAnimationRef;
+
+namespace WebCore {
+
+class PlatformCAAnimationWin final : public PlatformCAAnimation {
+public:
+    static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
+    static PassRefPtr<PlatformCAAnimation> create(PlatformAnimationRef);
+
+    virtual ~PlatformCAAnimationWin();
+
+    virtual bool isPlatformCAAnimationWin() const override { return true; }
+    
+    virtual PassRefPtr<PlatformCAAnimation> copy() const override;
+
+    PlatformAnimationRef platformAnimation() const;
+    
+    virtual String keyPath() const override;
+    
+    virtual CFTimeInterval beginTime() const override;
+    virtual void setBeginTime(CFTimeInterval) override;
+    
+    virtual CFTimeInterval duration() const override;
+    virtual void setDuration(CFTimeInterval) override;
+    
+    virtual float speed() const override;
+    virtual void setSpeed(float) override;
+
+    virtual CFTimeInterval timeOffset() const override;
+    virtual void setTimeOffset(CFTimeInterval) override;
+
+    virtual float repeatCount() const override;
+    virtual void setRepeatCount(float) override;
+
+    virtual bool autoreverses() const override;
+    virtual void setAutoreverses(bool) override;
+
+    virtual FillModeType fillMode() const override;
+    virtual void setFillMode(FillModeType) override;
+    
+    virtual void setTimingFunction(const TimingFunction*, bool reverse = false) override;
+    void copyTimingFunctionFrom(const PlatformCAAnimation*) override;
+
+    virtual bool isRemovedOnCompletion() const override;
+    virtual void setRemovedOnCompletion(bool) override;
+
+    virtual bool isAdditive() const override;
+    virtual void setAdditive(bool) override;
+
+    virtual ValueFunctionType valueFunction() const override;
+    virtual void setValueFunction(ValueFunctionType) override;
+
+    // Basic-animation properties.
+    virtual void setFromValue(float) override;
+    virtual void setFromValue(const WebCore::TransformationMatrix&) override;
+    virtual void setFromValue(const FloatPoint3D&) override;
+    virtual void setFromValue(const WebCore::Color&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setFromValue(const FilterOperation*, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyFromValueFrom(const PlatformCAAnimation*) override;
+
+    virtual void setToValue(float) override;
+    virtual void setToValue(const WebCore::TransformationMatrix&) override;
+    virtual void setToValue(const FloatPoint3D&) override;
+    virtual void setToValue(const WebCore::Color&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setToValue(const FilterOperation*, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyToValueFrom(const PlatformCAAnimation*) override;
+
+    // Keyframe-animation properties.
+    virtual void setValues(const Vector<float>&) override;
+    virtual void setValues(const Vector<WebCore::TransformationMatrix>&) override;
+    virtual void setValues(const Vector<FloatPoint3D>&) override;
+    virtual void setValues(const Vector<WebCore::Color>&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyValuesFrom(const PlatformCAAnimation*) override;
+
+    virtual void setKeyTimes(const Vector<float>&) override;
+    virtual void copyKeyTimesFrom(const PlatformCAAnimation*) override;
+
+    virtual void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false) override;
+    virtual void copyTimingFunctionsFrom(const PlatformCAAnimation*) override;
+
+protected:
+    PlatformCAAnimationWin(AnimationType, const String& keyPath);
+    PlatformCAAnimationWin(PlatformAnimationRef);
+
+private:
+    RetainPtr<CACFAnimationRef> m_animation;
+};
+
+PLATFORM_CAANIMATION_TYPE_CASTS(PlatformCAAnimationWin, isPlatformCAAnimationWin())
+
+}
+
+#endif // PLATFORM(WIN)
+
+#endif // PlatformCAAnimationWin_h
index ee0717e..a9415f4 100644 (file)
@@ -30,6 +30,7 @@
 #include "AbstractCACFLayerTreeHost.h"
 #include "Font.h"
 #include "GraphicsContext.h"
+#include "PlatformCAAnimationWin.h"
 #include "PlatformCALayerWinInternal.h"
 #include <QuartzCore/CoreAnimationCF.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
@@ -284,7 +285,7 @@ void PlatformCALayerWin::addAnimationForKey(const String& key, PlatformCAAnimati
     // Add it to the animation list
     m_animations.add(key, animation);
 
-    CACFLayerAddAnimation(m_layer.get(), key.createCFString().get(), animation->platformAnimation());
+    CACFLayerAddAnimation(m_layer.get(), key.createCFString().get(), toPlatformCAAnimationWin(animation)->platformAnimation());
     setNeedsCommit();
 
     // Tell the host about it so we can fire the start animation event
index 3ed8915..39f39fa 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "Font.h"
 #include "FontCache.h"
+#include "GraphicsContext.h"
 #include "PlatformCALayer.h"
 #include "TextRun.h"
 #include <QuartzCore/CACFLayer.h>
index 5caa0e2..8e9a829 100644 (file)
@@ -1,3 +1,102 @@
+2014-03-31  Simon Fraser  <simon.fraser@apple.com>
+
+        [UI-side compositing] Proxy animations to the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=130946
+
+        Reviewed by Tim Horton.
+        
+        Add encoding/decoding of TimingFunctions. Add encoding support
+        for HashSet.
+        
+        Add PlatformCAAnimationRemote and have PlatformCALayerRemote allow
+        animations now. PlatformCALayerRemote's properties are defined in the class,
+        as is the encoding/decoding (much cleaner than having them in the transaction
+        class I think).
+        
+        Add support for the "animationDidStart" callback and sending this back to the
+        web process. This involves a HashMap of layerID->WKAnimationDelegate stored
+        on the RemoteLayerTreeHost, and a message send via the DrawingArea. On the
+        other side, RemoteLayerTreeContext stores a HashMap of layerID->PlatformCALayerRemote*
+        for layers which have just started animations, which is used to get the
+        PlatformCALayer* to call animationDidStart() on.
+        
+        This requires that the RemoteLayerTreeHost* be passed down into property application,
+        and that the RemoteLayerTreeHost have a reference to the drawing area.
+        
+        To every CALayer in the UI process we -setValue:forKey: to track the PlatformLayerID,
+        so we can get back to it in order to dispatch "animationDidStart".
+        
+        Replace some "using namespace WebKit" with "namespace WebKit { }".
+
+        * Platform/IPC/ArgumentCoders.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<LinearTimingFunction>::encode):
+        (IPC::ArgumentCoder<LinearTimingFunction>::decode):
+        (IPC::ArgumentCoder<CubicBezierTimingFunction>::encode):
+        (IPC::ArgumentCoder<CubicBezierTimingFunction>::decode):
+        (IPC::ArgumentCoder<StepsTimingFunction>::encode):
+        (IPC::ArgumentCoder<StepsTimingFunction>::decode):
+        * Shared/WebCoreArgumentCoders.h:
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        * Shared/mac/RemoteLayerTreePropertyApplier.h:
+        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::applyPropertiesToLayer):
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        (WebKit::dumpChangedLayers):
+        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
+        (WebKit::RemoteLayerTreeHost::layerID):
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::showDebugIndicator):
+        * UIProcess/mac/RemoteLayerTreeHost.h:
+        (WebKit::RemoteLayerTreeHost::animationDelegates):
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::RemoteLayerTreeHost):
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        (WebKit::RemoteLayerTreeHost::layerWillBeRemoved):
+        (WebKit::RemoteLayerTreeHost::animationDidStart):
+        (WebKit::RemoteLayerTreeHost::layerID):
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::acceleratedAnimationDidStart):
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
+        (WebKit::GraphicsLayerCARemote::createPlatformCAAnimation):
+        * WebProcess/WebPage/mac/GraphicsLayerCARemote.h:
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.h: Added.
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm: Added.
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
+        (WebKit::PlatformCALayerRemote::animationStarted):
+        (WebKit::PlatformCALayerRemote::addAnimationForKey):
+        (WebKit::PlatformCALayerRemote::removeAnimationForKey):
+        (WebKit::PlatformCALayerRemote::animationForKey):
+        (PlatformCALayerRemote::recursiveBuildTransaction): Deleted.
+        (PlatformCALayerRemote::addAnimationForKey): Deleted.
+        (PlatformCALayerRemote::removeAnimationForKey): Deleted.
+        (PlatformCALayerRemote::animationForKey): Deleted.
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
+        (WebKit::RemoteLayerTreeContext::willStartAnimationOnLayer):
+        (WebKit::RemoteLayerTreeContext::animationDidStart):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
+
 2014-03-31  Tim Horton  <timothy_horton@apple.com>
 
         Double-buffer RemoteLayerBackingStore
index 297413f..ae8c6fb 100644 (file)
@@ -31,6 +31,7 @@
 #include <utility>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
 #include <wtf/Vector.h>
 
 namespace IPC {
@@ -193,6 +194,40 @@ template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTrai
     }
 };
 
+template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct ArgumentCoder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
+    typedef HashSet<KeyArg, HashArg, KeyTraitsArg> HashSetType;
+
+    static void encode(ArgumentEncoder& encoder, const HashSetType& hashSet)
+    {
+        encoder << static_cast<uint64_t>(hashSet.size());
+        for (typename HashSetType::const_iterator it = hashSet.begin(), end = hashSet.end(); it != end; ++it)
+            encoder << *it;
+    }
+
+    static bool decode(ArgumentDecoder& decoder, HashSetType& hashSet)
+    {
+        uint64_t hashSetSize;
+        if (!decoder.decode(hashSetSize))
+            return false;
+
+        HashSetType tempHashSet;
+        for (uint64_t i = 0; i < hashSetSize; ++i) {
+            KeyArg key;
+            if (!decoder.decode(key))
+                return false;
+
+            if (!tempHashSet.add(key).isNewEntry) {
+                // The hash map already has the specified key, bail.
+                decoder.markInvalid();
+                return false;
+            }
+        }
+
+        hashSet.swap(tempHashSet);
+        return true;
+    }
+};
+
 template<> struct ArgumentCoder<AtomicString> {
     static void encode(ArgumentEncoder&, const AtomicString&);
     static bool decode(ArgumentDecoder&, AtomicString&);
index 143fa78..ba9ba9b 100644 (file)
@@ -59,6 +59,7 @@
 #include <WebCore/ScrollingCoordinator.h>
 #include <WebCore/SessionID.h>
 #include <WebCore/TextCheckerClient.h>
+#include <WebCore/TimingFunction.h>
 #include <WebCore/TransformationMatrix.h>
 #include <WebCore/URL.h>
 #include <WebCore/UserScript.h>
@@ -90,7 +91,6 @@ bool ArgumentCoder<AffineTransform>::decode(ArgumentDecoder& decoder, AffineTran
     return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
 }
 
-
 void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix)
 {
     SimpleArgumentCoder<TransformationMatrix>::encode(encoder, transformationMatrix);
@@ -101,6 +101,83 @@ bool ArgumentCoder<TransformationMatrix>::decode(ArgumentDecoder& decoder, Trans
     return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix);
 }
 
+void ArgumentCoder<LinearTimingFunction>::encode(ArgumentEncoder& encoder, const LinearTimingFunction& timingFunction)
+{
+    encoder.encodeEnum(timingFunction.type());
+}
+
+bool ArgumentCoder<LinearTimingFunction>::decode(ArgumentDecoder& decoder, LinearTimingFunction& timingFunction)
+{
+    // Type is decoded by the caller. Nothing else to decode.
+    return true;
+}
+
+void ArgumentCoder<CubicBezierTimingFunction>::encode(ArgumentEncoder& encoder, const CubicBezierTimingFunction& timingFunction)
+{
+    encoder.encodeEnum(timingFunction.type());
+    
+    encoder << timingFunction.x1();
+    encoder << timingFunction.y1();
+    encoder << timingFunction.x2();
+    encoder << timingFunction.y2();
+    
+    encoder.encodeEnum(timingFunction.timingFunctionPreset());
+}
+
+bool ArgumentCoder<CubicBezierTimingFunction>::decode(ArgumentDecoder& decoder, CubicBezierTimingFunction& timingFunction)
+{
+    // Type is decoded by the caller.
+    double x1;
+    if (!decoder.decode(x1))
+        return false;
+
+    double y1;
+    if (!decoder.decode(y1))
+        return false;
+
+    double x2;
+    if (!decoder.decode(x2))
+        return false;
+
+    double y2;
+    if (!decoder.decode(y2))
+        return false;
+
+    CubicBezierTimingFunction::TimingFunctionPreset preset;
+    if (!decoder.decodeEnum(preset))
+        return false;
+
+    timingFunction.setValues(x1, y1, x2, y2);
+    timingFunction.setTimingFunctionPreset(preset);
+
+    return true;
+}
+
+void ArgumentCoder<StepsTimingFunction>::encode(ArgumentEncoder& encoder, const StepsTimingFunction& timingFunction)
+{
+    encoder.encodeEnum(timingFunction.type());
+    
+    encoder << timingFunction.numberOfSteps();
+    encoder << timingFunction.stepAtStart();
+}
+
+bool ArgumentCoder<StepsTimingFunction>::decode(ArgumentDecoder& decoder, StepsTimingFunction& timingFunction)
+{
+    // Type is decoded by the caller.
+    int numSteps;
+    if (!decoder.decode(numSteps))
+        return false;
+
+    bool stepAtStart;
+    if (!decoder.decode(stepAtStart))
+        return false;
+
+    timingFunction.setNumberOfSteps(numSteps);
+    timingFunction.setStepAtStart(stepAtStart);
+
+    return true;
+}
+
 void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint)
 {
     SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
index f59fd31..ba3e7b5 100644 (file)
@@ -34,6 +34,7 @@ class AuthenticationChallenge;
 class CertificateInfo;
 class Color;
 class Credential;
+class CubicBezierTimingFunction;
 class Cursor;
 class DatabaseDetails;
 class FilterOperations;
@@ -48,7 +49,7 @@ class IntPoint;
 class IntRect;
 class IntSize;
 class KeyframeValueList;
-class URL;
+class LinearTimingFunction;
 class Notification;
 class ProtectionSpace;
 class Region;
@@ -56,11 +57,13 @@ class ResourceError;
 class ResourceRequest;
 class ResourceResponse;
 class SessionID;
+class StepsTimingFunction;
 class StickyPositionViewportConstraints;
 class TextCheckingRequestData;
 class TransformationMatrix;
 class UserStyleSheet;
 class UserScript;
+class URL;
 struct CompositionUnderline;
 struct Cookie;
 struct DictationAlternative;
@@ -112,6 +115,21 @@ template<> struct ArgumentCoder<WebCore::TransformationMatrix> {
     static bool decode(ArgumentDecoder&, WebCore::TransformationMatrix&);
 };
 
+template<> struct ArgumentCoder<WebCore::LinearTimingFunction> {
+    static void encode(ArgumentEncoder&, const WebCore::LinearTimingFunction&);
+    static bool decode(ArgumentDecoder&, WebCore::LinearTimingFunction&);
+};
+
+template<> struct ArgumentCoder<WebCore::CubicBezierTimingFunction> {
+    static void encode(ArgumentEncoder&, const WebCore::CubicBezierTimingFunction&);
+    static bool decode(ArgumentDecoder&, WebCore::CubicBezierTimingFunction&);
+};
+
+template<> struct ArgumentCoder<WebCore::StepsTimingFunction> {
+    static void encode(ArgumentEncoder&, const WebCore::StepsTimingFunction&);
+    static bool decode(ArgumentDecoder&, WebCore::StepsTimingFunction&);
+};
+
 template<> struct ArgumentCoder<WebCore::CertificateInfo> {
     static void encode(ArgumentEncoder&, const WebCore::CertificateInfo&);
     static bool decode(ArgumentDecoder&, WebCore::CertificateInfo&);
index 56e5944..48b4a3f 100644 (file)
@@ -49,7 +49,8 @@
 @end
 
 using namespace WebCore;
-using namespace WebKit;
+
+namespace WebKit {
 
 RemoteLayerBackingStore::RemoteLayerBackingStore()
     : m_layer(nullptr)
@@ -325,3 +326,5 @@ void RemoteLayerBackingStore::applyBackingStoreToLayer(CALayer *layer)
     ASSERT(!acceleratesDrawing());
     layer.contents = (id)m_frontBuffer->makeCGImageCopy().get();
 }
+
+} // namespace WebKit
index e7c0268..37eaf5d 100644 (file)
 
 namespace WebKit {
 
+class RemoteLayerTreeHost;
+
 class RemoteLayerTreePropertyApplier {
 public:
     typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerOrView *> RelatedLayerMap;
-    static void applyProperties(CALayer *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
+    static void applyProperties(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
 #if PLATFORM(IOS)
-    static void applyProperties(UIView *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
+    static void applyProperties(UIView *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
 #endif
 };
 
index dd2e722..8b08315 100644 (file)
@@ -26,7 +26,9 @@
 #import "config.h"
 #import "RemoteLayerTreePropertyApplier.h"
 
+#import "PlatformCAAnimationRemote.h"
 #import "PlatformCALayerRemote.h"
+#import "RemoteLayerTreeHost.h"
 #import <QuartzCore/CALayer.h>
 #import <WebCore/BlockExceptions.h>
 #import <WebCore/PlatformCAFilters.h>
@@ -111,7 +113,7 @@ static void updateCustomAppearance(CALayer *layer, GraphicsLayer::CustomAppearan
 #endif
 }
 
-static void applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransaction::LayerProperties& properties)
+static void applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties)
 {
     if (properties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
         layer.name = properties.name;
@@ -128,7 +130,7 @@ static void applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransact
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::SizeChanged)
         layer.bounds = FloatRect(FloatPoint(), properties.size);
-
+    
     if (properties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
         layer.backgroundColor = cgColorFromColor(properties.backgroundColor).get();
 
@@ -192,6 +194,9 @@ static void applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransact
     if (properties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
         PlatformCAFilters::setFiltersOnLayer(layer, properties.filters ? *properties.filters : FilterOperations());
 
+    if (properties.changedProperties & RemoteLayerTreeTransaction::AnimationsChanged)
+        PlatformCAAnimationRemote::updateLayerAnimations(layer, layerTreeHost, properties.addedAnimations, properties.keyPathsOfAnimationsToRemove);
+
     if (properties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
         layer.edgeAntialiasingMask = properties.edgeAntialiasingMask;
 
@@ -199,10 +204,10 @@ static void applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransact
         updateCustomAppearance(layer, properties.customAppearance);
 }
 
-void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
+void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    applyPropertiesToLayer(layer, properties);
+    applyPropertiesToLayer(layer, layerTreeHost, properties);
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
@@ -236,10 +241,10 @@ void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, const Remot
 }
 
 #if PLATFORM(IOS)
-void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
+void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    applyPropertiesToLayer(view.layer, properties);
+    applyPropertiesToLayer(view.layer, layerTreeHost, properties);
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
index 218b8d0..6d09310 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef RemoteLayerTreeTransaction_h
 #define RemoteLayerTreeTransaction_h
 
+#include "PlatformCAAnimationRemote.h"
 #include "RemoteLayerBackingStore.h"
 #include <WebCore/Color.h>
 #include <WebCore/FilterOperations.h>
@@ -34,6 +35,7 @@
 #include <WebCore/PlatformCALayer.h>
 #include <WebCore/TransformationMatrix.h>
 #include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
 #include <wtf/text/WTFString.h>
 
 namespace IPC {
@@ -74,9 +76,10 @@ public:
         TimeOffsetChanged = 1 << 23,
         BackingStoreChanged = 1 << 24,
         FiltersChanged = 1 << 25,
-        EdgeAntialiasingMaskChanged = 1 << 26,
-        CustomAppearanceChanged = 1 << 27,
-        CustomBehaviorChanged = 1 << 28
+        AnimationsChanged = 1 << 26,
+        EdgeAntialiasingMaskChanged = 1 << 27,
+        CustomAppearanceChanged = 1 << 28,
+        CustomBehaviorChanged = 1 << 29
     };
     typedef unsigned LayerChange;
 
@@ -112,6 +115,10 @@ public:
         std::unique_ptr<WebCore::TransformationMatrix> transform;
         std::unique_ptr<WebCore::TransformationMatrix> sublayerTransform;
         Vector<WebCore::GraphicsLayer::PlatformLayerID> children;
+
+        HashMap<String, PlatformCAAnimationRemote::Properties> addedAnimations;
+        HashSet<String> keyPathsOfAnimationsToRemove;
+
         WebCore::FloatPoint3D position;
         WebCore::FloatPoint3D anchorPoint;
         WebCore::FloatSize size;
index 907a387..b8caf6c 100644 (file)
@@ -103,6 +103,8 @@ RemoteLayerTreeTransaction::LayerProperties::LayerProperties(const LayerProperti
     , everChangedProperties(other.everChangedProperties)
     , name(other.name)
     , children(other.children)
+    , addedAnimations(other.addedAnimations)
+    , keyPathsOfAnimationsToRemove(other.keyPathsOfAnimationsToRemove)
     , position(other.position)
     , anchorPoint(other.anchorPoint)
     , size(other.size)
@@ -149,6 +151,11 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& e
     if (changedProperties & ChildrenChanged)
         encoder << children;
 
+    if (changedProperties & AnimationsChanged) {
+        encoder << addedAnimations;
+        encoder << keyPathsOfAnimationsToRemove;
+    }
+
     if (changedProperties & PositionChanged)
         encoder << position;
 
@@ -251,6 +258,14 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& d
         }
     }
 
+    if (result.changedProperties & AnimationsChanged) {
+        if (!decoder.decode(result.addedAnimations))
+            return false;
+
+        if (!decoder.decode(result.keyPathsOfAnimationsToRemove))
+            return false;
+    }
+
     if (result.changedProperties & PositionChanged) {
         if (!decoder.decode(result.position))
             return false;
@@ -736,6 +751,8 @@ static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTr
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
             dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
 
+// FIXME: dump animations
+
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
             dumpProperty<FloatPoint3D>(ts, "position", layerProperties.position);
 
index 9eda954..a06bbb0 100644 (file)
 
 using namespace WebCore;
 
-@interface UIView(WKViewInternals)
-- (void)_createLayerWithFrame:(CGRect)frame;
-@end
-
 @interface CALayer(WKLayerInternal)
 - (void)setContextId:(uint32_t)contextID;
 @end
@@ -76,6 +72,13 @@ using namespace WebCore;
 
 namespace WebKit {
 
+static NSString* const WKLayerIDPropertyKey = @"WKLayerID";
+
+WebCore::GraphicsLayer::PlatformLayerID RemoteLayerTreeHost::layerID(LayerOrView* layer)
+{
+    return [[layer valueForKey:WKLayerIDPropertyKey] unsignedLongLongValue];
+}
+
 LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
 {
     RetainPtr<LayerOrView>& layerOrView = m_layers.add(properties.layerID, nullptr).iterator->value;
@@ -110,6 +113,7 @@ LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::
 
     // FIXME: Do through the view.
     [[layerOrView layer] web_disableAllActions];
+    [[layerOrView layer] setValue:[NSNumber numberWithUnsignedLongLong:properties.layerID] forKey:WKLayerIDPropertyKey];
 
     return layerOrView.get();
 }
index 9e8b23d..acc5311 100644 (file)
@@ -44,6 +44,8 @@ public:
 
     const RemoteLayerTreeHost& remoteLayerTreeHost() const { return m_remoteLayerTreeHost; }
 
+    void acceleratedAnimationDidStart(uint64_t layerID, double startTime);
+
     void coreAnimationDidCommitLayers();
 
 private:
index 54da95b..24786a5 100644 (file)
@@ -43,7 +43,7 @@ namespace WebKit {
 
 RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy(WebPageProxy* webPageProxy)
     : DrawingAreaProxy(DrawingAreaTypeRemoteLayerTree, webPageProxy)
-    , m_remoteLayerTreeHost()
+    , m_remoteLayerTreeHost(*this)
     , m_isWaitingForDidUpdateGeometry(false)
 {
     m_webPageProxy->process().addMessageReceiver(Messages::RemoteLayerTreeDrawingAreaProxy::messageReceiverName(), m_webPageProxy->pageID(), *this);
@@ -141,6 +141,11 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
     scheduleCoreAnimationLayerCommitObserver();
 }
 
+void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t layerID, double startTime)
+{
+    m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, startTime), m_webPageProxy->pageID());
+}
+
 static const float indicatorInset = 10;
 
 #if PLATFORM(MAC)
@@ -246,7 +251,7 @@ void RemoteLayerTreeDrawingAreaProxy::showDebugIndicator(bool show)
         return;
     }
     
-    m_debugIndicatorLayerTreeHost = std::make_unique<RemoteLayerTreeHost>();
+    m_debugIndicatorLayerTreeHost = std::make_unique<RemoteLayerTreeHost>(*this);
     m_debugIndicatorLayerTreeHost->setIsDebugLayerTreeHost(true);
 
     m_tileMapHostLayer = adoptNS([[CALayer alloc] init]);
index f9d6b34..15e36de 100644 (file)
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
 
+OBJC_CLASS WKAnimationDelegate;
+
 namespace WebKit {
 
+class RemoteLayerTreeDrawingAreaProxy;
 class WebPageProxy;
 
 class RemoteLayerTreeHost {
 public:
-    explicit RemoteLayerTreeHost();
+    explicit RemoteLayerTreeHost(RemoteLayerTreeDrawingAreaProxy&);
     virtual ~RemoteLayerTreeHost();
 
     LayerOrView *getLayer(WebCore::GraphicsLayer::PlatformLayerID) const;
     LayerOrView *rootLayer() const { return m_rootLayer; }
 
+    static WebCore::GraphicsLayer::PlatformLayerID layerID(LayerOrView*);
+
     // Returns true if the root layer changed.
     bool updateLayerTree(const RemoteLayerTreeTransaction&, float indicatorScaleFactor  = 1);
 
     void setIsDebugLayerTreeHost(bool flag) { m_isDebugLayerTreeHost = flag; }
     bool isDebugLayerTreeHost() const { return m_isDebugLayerTreeHost; }
 
+    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> LayerAnimationDelegateMap;
+    LayerAnimationDelegateMap& animationDelegates() { return m_animationDelegates; }
+
+    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, double startTime);
+
 private:
     LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
 
+    void layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID);
+
+    RemoteLayerTreeDrawingAreaProxy& m_drawingArea;
     LayerOrView *m_rootLayer;
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<LayerOrView>> m_layers;
+    HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> m_animationDelegates;
     bool m_isDebugLayerTreeHost;
 };
 
index 5bc71a1..af46b8f 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "RemoteLayerTreeHost.h"
 
+#import "RemoteLayerTreeDrawingAreaProxy.h"
 #import "RemoteLayerTreePropertyApplier.h"
 #import "RemoteLayerTreeTransaction.h"
 #import "ShareableBitmap.h"
@@ -41,8 +42,9 @@ using namespace WebCore;
 
 namespace WebKit {
 
-RemoteLayerTreeHost::RemoteLayerTreeHost()
-    : m_rootLayer(nullptr)
+RemoteLayerTreeHost::RemoteLayerTreeHost(RemoteLayerTreeDrawingAreaProxy& drawingArea)
+    : m_drawingArea(drawingArea)
+    , m_rootLayer(nullptr)
     , m_isDebugLayerTreeHost(false)
 {
 }
@@ -87,13 +89,13 @@ bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& tran
             if (propertiesCopy.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
                 propertiesCopy.borderWidth *= 1 / indicatorScaleFactor;
             
-            RemoteLayerTreePropertyApplier::applyProperties(layer, propertiesCopy, relatedLayers);
+            RemoteLayerTreePropertyApplier::applyProperties(layer, this, propertiesCopy, relatedLayers);
         } else
-            RemoteLayerTreePropertyApplier::applyProperties(layer, properties, relatedLayers);
+            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
     }
 
     for (auto& destroyedLayer : transaction.destroyedLayers())
-        m_layers.remove(destroyedLayer);
+        layerWillBeRemoved(destroyedLayer);
 
     return rootLayerChanged;
 }
@@ -106,7 +108,25 @@ LayerOrView *RemoteLayerTreeHost::getLayer(GraphicsLayer::PlatformLayerID layerI
     return m_layers.get(layerID).get();
 }
 
+void RemoteLayerTreeHost::layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID layerID)
+{
+    m_animationDelegates.remove(layerID);
+    m_layers.remove(layerID);
+}
+
+void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, double startTime)
+{
+    m_drawingArea.acceleratedAnimationDidStart(layerID, startTime);
+}
+
 #if !PLATFORM(IOS)
+static NSString* const WKLayerIDPropertyKey = @"WKLayerID";
+
+WebCore::GraphicsLayer::PlatformLayerID RemoteLayerTreeHost::layerID(LayerOrView* layer)
+{
+    return [[layer valueForKey:WKLayerIDPropertyKey] unsignedLongLongValue];
+}
+
 LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties*)
 {
     RetainPtr<CALayer>& layer = m_layers.add(properties.layerID, nullptr).iterator->value;
@@ -137,6 +157,7 @@ LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::
     }
 
     [layer web_disableAllActions];
+    [layer setValue:[NSNumber numberWithUnsignedLongLong:properties.layerID] forKey:WKLayerIDPropertyKey];
 
     return layer.get();
 }
index a2fe2b8..44a4682 100644 (file)
@@ -63,6 +63,8 @@
                0F5947A4187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5947A2187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.h */; };
                0F5947A7187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5947A5187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp */; };
                0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5947A6187B517600437857 /* RemoteScrollingCoordinatorMessages.h */; };
+               0F5E200318E77051003EC3E5 /* PlatformCAAnimationRemote.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */; };
+               0F5E200418E77051003EC3E5 /* PlatformCAAnimationRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */; };
                0F931C1C18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */; };
                0F931C1D18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */; };
                0FB659231208B4DB0044816C /* DrawingAreaInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB659221208B4DB0044816C /* DrawingAreaInfo.h */; };
                0F5947A2187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteScrollingCoordinatorTransaction.h; path = Scrolling/RemoteScrollingCoordinatorTransaction.h; sourceTree = "<group>"; };
                0F5947A5187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteScrollingCoordinatorMessageReceiver.cpp; sourceTree = "<group>"; };
                0F5947A6187B517600437857 /* RemoteScrollingCoordinatorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteScrollingCoordinatorMessages.h; sourceTree = "<group>"; };
+               0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCAAnimationRemote.mm; sourceTree = "<group>"; };
+               0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCAAnimationRemote.h; sourceTree = "<group>"; };
                0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeOverflowScrollingNodeIOS.h; path = Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h; sourceTree = "<group>"; };
                0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollingTreeOverflowScrollingNodeIOS.mm; path = Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm; sourceTree = "<group>"; };
                0FB659221208B4DB0044816C /* DrawingAreaInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingAreaInfo.h; sourceTree = "<group>"; };
                                7C6D37FA172F555F009D2847 /* PageBannerMac.mm */,
                                2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp */,
                                2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */,
+                               0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */,
+                               0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */,
                                2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */,
                                2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */,
                                2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.mm */,
                                BC4A62A814744EC7006C681A /* WebConnectionToWebProcess.h in Headers */,
                                BCB9E2431120DACA00A137E0 /* WebContext.h in Headers */,
                                31A505FA1680025500A930EB /* WebContextClient.h in Headers */,
+                               0F5E200418E77051003EC3E5 /* PlatformCAAnimationRemote.h in Headers */,
                                512A9761180E031D0039A149 /* DatabaseProcessMessages.h in Headers */,
                                BC09B8F9147460F7005F5625 /* WebContextConnectionClient.h in Headers */,
                                BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */,
                                1AC86FF3130B46D3002C1257 /* WKPluginSiteDataManager.cpp in Sources */,
                                BCD597D1112B56AC00EC8C23 /* WKPreferences.cpp in Sources */,
                                BCBAACEC145225E30053F82F /* WKProcessGroup.mm in Sources */,
+                               0F5E200318E77051003EC3E5 /* PlatformCAAnimationRemote.mm in Sources */,
                                512F58FB12A88A5400629530 /* WKProtectionSpace.cpp in Sources */,
                                37948408150C4B9700E52CE9 /* WKRenderLayer.cpp in Sources */,
                                2D1B5D5D185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp in Sources */,
index 47ec55b..e417c26 100644 (file)
@@ -91,6 +91,7 @@ public:
 #if PLATFORM(COCOA)
     virtual void setExposedRect(const WebCore::FloatRect&) = 0;
     virtual WebCore::FloatRect exposedRect() const = 0;
+    virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, double /*startTime*/) { }
 #endif
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) = 0;
index 91bcaf4..ccae2aa 100644 (file)
@@ -33,5 +33,7 @@ messages -> DrawingArea LegacyReceiver {
 
     AdjustTransientZoom(double scale, WebCore::FloatPoint origin)
     CommitTransientZoom(double scale, WebCore::FloatPoint origin)
+    
+    AcceleratedAnimationDidStart(uint64_t layerID, double startTime)
 #endif
 }
index c95f85f..d5f7971 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "GraphicsLayerCARemote.h"
+#include "PlatformCAAnimationRemote.h"
 #include "PlatformCALayerRemote.h"
 
 using namespace WebCore;
@@ -52,4 +53,22 @@ PassRefPtr<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(Platfor
     return PlatformCALayerRemote::create(platformLayer, owner, m_context);
 }
 
+PassRefPtr<PlatformCAAnimation> GraphicsLayerCARemote::createPlatformCAAnimation(PlatformCAAnimation::AnimationType type, const String& keyPath)
+{
+    return PlatformCAAnimationRemote::create(type, keyPath);
 }
+
+bool GraphicsLayerCARemote::addAnimation(const KeyframeValueList& valueList, const FloatSize&, const Animation* anim, const String&, double)
+{
+    if (!animationCanBeAccelerated(valueList, anim))
+        return false;
+    
+#if ENABLE(CSS_FILTERS)
+    if (valueList.property() == AnimatedPropertyWebkitFilter)
+        return false;
+#endif
+    
+    return true;
+}
+
+} // namespace WebKit
index cf53976..6c9c448 100644 (file)
@@ -52,13 +52,13 @@ private:
 
     virtual PassRefPtr<WebCore::PlatformCALayer> createPlatformCALayer(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner) override;
     virtual PassRefPtr<WebCore::PlatformCALayer> createPlatformCALayer(PlatformLayer*, WebCore::PlatformCALayerClient* owner) override;
-
-    // No accelerated animations for now.
-    virtual bool addAnimation(const WebCore::KeyframeValueList&, const WebCore::FloatSize&, const WebCore::Animation*, const String&, double) override { return false; }
+    virtual PassRefPtr<WebCore::PlatformCAAnimation> createPlatformCAAnimation(WebCore::PlatformCAAnimation::AnimationType, const String& keyPath) override;
 
     // PlatformCALayerRemote can't currently proxy directly composited image contents, so opt out of this optimization.
     virtual bool shouldDirectlyCompositeImage(WebCore::Image*) const override { return false; }
-
+    
+    virtual bool addAnimation(const WebCore::KeyframeValueList&, const WebCore::FloatSize&, const WebCore::Animation*, const String&, double);
+    
     RemoteLayerTreeContext* m_context;
 };
 
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.h b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.h
new file mode 100644 (file)
index 0000000..227f0f7
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2014 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 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 PlatformCAAnimationRemote_h
+#define PlatformCAAnimationRemote_h
+
+#include <WebCore/PlatformCAAnimation.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+
+namespace IPC {
+class ArgumentEncoder;
+class ArgumentDecoder;
+};
+
+OBJC_CLASS CALayer;
+
+namespace WebKit {
+
+class RemoteLayerTreeHost;
+
+class PlatformCAAnimationRemote final : public WebCore::PlatformCAAnimation {
+public:
+    static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
+
+    virtual ~PlatformCAAnimationRemote() { }
+
+    virtual bool isPlatformCAAnimationRemote() const override { return true; }
+
+    virtual PassRefPtr<PlatformCAAnimation> copy() const override;
+    
+    virtual String keyPath() const override;
+    
+    virtual CFTimeInterval beginTime() const override;
+    virtual void setBeginTime(CFTimeInterval) override;
+    
+    virtual CFTimeInterval duration() const override;
+    virtual void setDuration(CFTimeInterval) override;
+    
+    virtual float speed() const override;
+    virtual void setSpeed(float) override;
+
+    virtual CFTimeInterval timeOffset() const override;
+    virtual void setTimeOffset(CFTimeInterval) override;
+
+    virtual float repeatCount() const override;
+    virtual void setRepeatCount(float) override;
+
+    virtual bool autoreverses() const override;
+    virtual void setAutoreverses(bool) override;
+
+    virtual FillModeType fillMode() const override;
+    virtual void setFillMode(FillModeType) override;
+    
+    virtual void setTimingFunction(const WebCore::TimingFunction*, bool reverse = false) override;
+    void copyTimingFunctionFrom(const WebCore::PlatformCAAnimation*) override;
+
+    virtual bool isRemovedOnCompletion() const override;
+    virtual void setRemovedOnCompletion(bool) override;
+
+    virtual bool isAdditive() const override;
+    virtual void setAdditive(bool) override;
+
+    virtual ValueFunctionType valueFunction() const override;
+    virtual void setValueFunction(ValueFunctionType) override;
+
+    // Basic-animation properties.
+    virtual void setFromValue(float) override;
+    virtual void setFromValue(const WebCore::TransformationMatrix&) override;
+    virtual void setFromValue(const WebCore::FloatPoint3D&) override;
+    virtual void setFromValue(const WebCore::Color&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setFromValue(const WebCore::FilterOperation*, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyFromValueFrom(const WebCore::PlatformCAAnimation*) override;
+
+    virtual void setToValue(float) override;
+    virtual void setToValue(const WebCore::TransformationMatrix&) override;
+    virtual void setToValue(const WebCore::FloatPoint3D&) override;
+    virtual void setToValue(const WebCore::Color&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setToValue(const WebCore::FilterOperation*, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyToValueFrom(const WebCore::PlatformCAAnimation*) override;
+
+    // Keyframe-animation properties.
+    virtual void setValues(const Vector<float>&) override;
+    virtual void setValues(const Vector<WebCore::TransformationMatrix>&) override;
+    virtual void setValues(const Vector<WebCore::FloatPoint3D>&) override;
+    virtual void setValues(const Vector<WebCore::Color>&) override;
+#if ENABLE(CSS_FILTERS)
+    virtual void setValues(const Vector<RefPtr<WebCore::FilterOperation>>&, int internalFilterPropertyIndex) override;
+#endif
+    virtual void copyValuesFrom(const WebCore::PlatformCAAnimation*) override;
+
+    virtual void setKeyTimes(const Vector<float>&) override;
+    virtual void copyKeyTimesFrom(const WebCore::PlatformCAAnimation*) override;
+
+    virtual void setTimingFunctions(const Vector<const WebCore::TimingFunction*>&, bool reverse = false) override;
+    virtual void copyTimingFunctionsFrom(const WebCore::PlatformCAAnimation*) override;
+
+    class KeyframeValue {
+    public:
+        enum KeyframeType {
+            NumberKeyType,
+            ColorKeyType,
+            PointKeyType,
+            TransformKeyType,
+        };
+
+        KeyframeValue(float value = 0)
+            : keyType(NumberKeyType)
+            , number(value)
+        {
+        }
+
+        KeyframeValue(WebCore::Color value)
+            : keyType(ColorKeyType)
+            , color(value)
+        {
+        }
+
+        KeyframeValue(const WebCore::FloatPoint3D& value)
+            : keyType(PointKeyType)
+            , point(value)
+        {
+        }
+
+        KeyframeValue(const WebCore::TransformationMatrix& value)
+            : keyType(TransformKeyType)
+            , transform(value)
+        {
+        }
+        
+        KeyframeValue(const KeyframeValue& other)
+        {
+            *this = other;
+        }
+
+        KeyframeValue& operator=(const KeyframeValue& other)
+        {
+            keyType = other.keyType;
+            switch (keyType) {
+            case NumberKeyType:
+                number = other.number;
+                break;
+            case ColorKeyType:
+                color = other.color;
+                break;
+            case PointKeyType:
+                point = other.point;
+                break;
+            case TransformKeyType:
+                transform = other.transform;
+                break;
+            }
+            
+            return *this;
+        }
+        
+        KeyframeType keyframeType() const { return keyType; }
+
+        float numberValue() const
+        {
+            ASSERT(keyType == NumberKeyType);
+            return number;
+        }
+
+        WebCore::Color colorValue() const
+        {
+            ASSERT(keyType == ColorKeyType);
+            return color;
+        }
+
+        const WebCore::FloatPoint3D& pointValue() const
+        {
+            ASSERT(keyType == PointKeyType);
+            return point;
+        }
+
+        const WebCore::TransformationMatrix& transformValue() const
+        {
+            ASSERT(keyType == TransformKeyType);
+            return transform;
+        }
+
+        void encode(IPC::ArgumentEncoder&) const;
+        static bool decode(IPC::ArgumentDecoder&, KeyframeValue&);
+
+    private:
+        KeyframeType keyType;
+        union {
+            float number;
+            WebCore::Color color;
+            WebCore::FloatPoint3D point;
+            WebCore::TransformationMatrix transform;
+        };
+    };
+
+    struct Properties {
+        Properties()
+            : animationType(Basic)
+            , beginTime(0)
+            , duration(0)
+            , timeOffset(0)
+            , repeatCount(1)
+            , speed(1)
+            , fillMode(NoFillMode)
+            , valueFunction(NoValueFunction)
+            , autoReverses(false)
+            , removedOnCompletion(true)
+            , additive(false)
+            , reverseTimingFunctions(false)
+            , hasNonZeroBeginTime(false)
+        
+        {
+        }
+        
+        void encode(IPC::ArgumentEncoder&) const;
+        static bool decode(IPC::ArgumentDecoder&, Properties&);
+
+        String keyPath;
+        PlatformCAAnimation::AnimationType animationType;
+
+        double beginTime;
+        double duration;
+        double timeOffset;
+        float repeatCount;
+        float speed;
+        
+        PlatformCAAnimation::FillModeType fillMode;
+        PlatformCAAnimation::ValueFunctionType valueFunction;
+        
+        bool autoReverses;
+        bool removedOnCompletion;
+        bool additive;
+        bool reverseTimingFunctions;
+        bool hasNonZeroBeginTime;
+
+        // For basic animations, these vectors have two entries. For keyframe animations, two or more.
+        // timingFunctions has n-1 entries.
+        Vector<KeyframeValue> keyValues;
+        Vector<float> keyTimes;
+        Vector<RefPtr<WebCore::TimingFunction>> timingFunctions;
+    };
+
+    const Properties& properties() const { return m_properties; }
+
+    typedef HashMap<String, Properties> AnimationsMap;
+    static void updateLayerAnimations(CALayer *, RemoteLayerTreeHost*, const AnimationsMap& animationsToAdd, const HashSet<String>& animationsToRemove);
+
+private:
+    PlatformCAAnimationRemote(AnimationType, const String& keyPath);
+
+    Properties m_properties;
+};
+
+PLATFORM_CAANIMATION_TYPE_CASTS(PlatformCAAnimationRemote, isPlatformCAAnimationRemote())
+
+} // namespace WebKit
+
+#endif // PlatformCAAnimationRemote_h
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm
new file mode 100644 (file)
index 0000000..b533bdf
--- /dev/null
@@ -0,0 +1,719 @@
+/*
+ * Copyright (C) 2014 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 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"
+#import "PlatformCAAnimationRemote.h"
+
+#import "ArgumentCoders.h"
+#import "RemoteLayerTreeHost.h"
+#import "WebCoreArgumentCoders.h"
+#import <WebCore/BlockExceptions.h>
+#import <WebCore/GraphicsLayer.h>
+#import <WebCore/PlatformCAAnimationMac.h>
+#import <WebCore/TimingFunction.h>
+#import <wtf/CurrentTime.h>
+#import <wtf/RetainPtr.h>
+#import <QuartzCore/QuartzCore.h>
+
+using namespace WTF;
+using namespace WebCore;
+
+static double mediaTimeToCurrentTime(CFTimeInterval t)
+{
+    return monotonicallyIncreasingTime() + t - CACurrentMediaTime();
+}
+
+static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroBeginTimeFlag";
+
+@interface WKAnimationDelegate : NSObject {
+    GraphicsLayer::PlatformLayerID _layerID;
+    WebKit::RemoteLayerTreeHost* _layerTreeHost;
+}
+
+- (instancetype)initWithLayerID:(GraphicsLayer::PlatformLayerID)layerID layerTreeHost:(WebKit::RemoteLayerTreeHost*)layerTreeHost;
+@end
+
+@implementation WKAnimationDelegate
+
+- (instancetype)initWithLayerID:(GraphicsLayer::PlatformLayerID)layerID layerTreeHost:(WebKit::RemoteLayerTreeHost*)layerTreeHost
+{
+    if ((self = [super init])) {
+        _layerID = layerID;
+        _layerTreeHost = layerTreeHost;
+    }
+    return self;
+}
+
+- (void)animationDidStart:(CAAnimation *)animation
+{
+    bool hasNonZeroBeginTime = [[animation valueForKey:WKNonZeroBeginTimeFlag] boolValue];
+    CFTimeInterval startTime;
+
+    if (hasNonZeroBeginTime) {
+        // We don't know what time CA used to commit the animation, so just use the current time
+        // (even though this will be slightly off).
+        startTime = mediaTimeToCurrentTime(CACurrentMediaTime());
+    } else
+        startTime = mediaTimeToCurrentTime([animation beginTime]);
+
+    _layerTreeHost->animationDidStart(_layerID, startTime);
+}
+@end
+
+namespace WebKit {
+
+void PlatformCAAnimationRemote::KeyframeValue::encode(IPC::ArgumentEncoder& encoder) const
+{
+    encoder.encodeEnum(keyType);
+
+    switch (keyType) {
+    case NumberKeyType:
+        encoder << number;
+        break;
+    case ColorKeyType:
+        encoder << color;
+        break;
+    case PointKeyType:
+        encoder << point;
+        break;
+    case TransformKeyType:
+        encoder << transform;
+        break;
+    }
+}
+
+bool PlatformCAAnimationRemote::KeyframeValue::decode(IPC::ArgumentDecoder& decoder, PlatformCAAnimationRemote::KeyframeValue& value)
+{
+    if (!decoder.decodeEnum(value.keyType))
+        return false;
+
+    switch (value.keyType) {
+    case NumberKeyType:
+        if (!decoder.decode(value.number))
+            return false;
+        break;
+    case ColorKeyType:
+        if (!decoder.decode(value.color))
+            return false;
+        break;
+    case PointKeyType:
+        if (!decoder.decode(value.point))
+            return false;
+        break;
+    case TransformKeyType:
+        if (!decoder.decode(value.transform))
+            return false;
+        break;
+    }
+
+    return true;
+}
+
+void PlatformCAAnimationRemote::Properties::encode(IPC::ArgumentEncoder& encoder) const
+{
+    encoder << keyPath;
+    encoder.encodeEnum(animationType);
+
+    encoder << beginTime;
+    encoder << duration;
+    encoder << timeOffset;
+    encoder << repeatCount;
+    encoder << speed;
+
+    encoder.encodeEnum(fillMode);
+    encoder.encodeEnum(valueFunction);
+
+    encoder << autoReverses;
+    encoder << removedOnCompletion;
+    encoder << additive;
+    encoder << reverseTimingFunctions;
+    encoder << hasNonZeroBeginTime;
+    
+    encoder << keyValues;
+    encoder << keyTimes;
+    
+    encoder << static_cast<uint64_t>(timingFunctions.size());
+    for (const auto& timingFunction : timingFunctions) {
+        switch (timingFunction->type()) {
+        case TimingFunction::LinearFunction:
+            encoder << *static_cast<LinearTimingFunction*>(timingFunction.get());
+            break;
+            
+        case TimingFunction::CubicBezierFunction:
+            encoder << *static_cast<CubicBezierTimingFunction*>(timingFunction.get());
+            break;
+        
+        case TimingFunction::StepsFunction:
+            encoder << *static_cast<StepsTimingFunction*>(timingFunction.get());
+            break;
+        }
+    }
+}
+
+bool PlatformCAAnimationRemote::Properties::decode(IPC::ArgumentDecoder& decoder, PlatformCAAnimationRemote::Properties& properties)
+{
+    if (!decoder.decode(properties.keyPath))
+        return false;
+
+    if (!decoder.decodeEnum(properties.animationType))
+        return false;
+
+    if (!decoder.decode(properties.beginTime))
+        return false;
+
+    if (!decoder.decode(properties.duration))
+        return false;
+
+    if (!decoder.decode(properties.timeOffset))
+        return false;
+
+    if (!decoder.decode(properties.repeatCount))
+        return false;
+
+    if (!decoder.decode(properties.speed))
+        return false;
+
+    if (!decoder.decodeEnum(properties.fillMode))
+        return false;
+
+    if (!decoder.decodeEnum(properties.valueFunction))
+        return false;
+
+    if (!decoder.decode(properties.autoReverses))
+        return false;
+
+    if (!decoder.decode(properties.removedOnCompletion))
+        return false;
+
+    if (!decoder.decode(properties.additive))
+        return false;
+
+    if (!decoder.decode(properties.reverseTimingFunctions))
+        return false;
+
+    if (!decoder.decode(properties.hasNonZeroBeginTime))
+        return false;
+
+    if (!decoder.decode(properties.keyValues))
+        return false;
+
+    if (!decoder.decode(properties.keyTimes))
+        return false;
+
+    uint64_t numTimingFunctions;
+    if (!decoder.decode(numTimingFunctions))
+        return false;
+    
+    if (numTimingFunctions) {
+        properties.timingFunctions.reserveInitialCapacity(numTimingFunctions);
+
+        for (size_t i = 0; i < numTimingFunctions; ++i) {
+        
+            TimingFunction::TimingFunctionType type;
+            if (!decoder.decodeEnum(type))
+                return false;
+
+            RefPtr<TimingFunction> timingFunction;
+            switch (type) {
+            case TimingFunction::LinearFunction:
+                timingFunction = LinearTimingFunction::create();
+                if (!decoder.decode(*static_cast<LinearTimingFunction*>(timingFunction.get())))
+                    return false;
+                break;
+                
+            case TimingFunction::CubicBezierFunction:
+                timingFunction = CubicBezierTimingFunction::create();
+                if (!decoder.decode(*static_cast<CubicBezierTimingFunction*>(timingFunction.get())))
+                    return false;
+                break;
+            
+            case TimingFunction::StepsFunction:
+                timingFunction = StepsTimingFunction::create();
+                if (!decoder.decode(*static_cast<StepsTimingFunction*>(timingFunction.get())))
+                    return false;
+                break;
+            }
+            
+            properties.timingFunctions.uncheckedAppend(timingFunction.release());
+        }
+    }
+
+    return true;
+}
+    
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationRemote::create(PlatformCAAnimation::AnimationType type, const String& keyPath)
+{
+    return adoptRef(new PlatformCAAnimationRemote(type, keyPath));
+}
+
+PassRefPtr<PlatformCAAnimation> PlatformCAAnimationRemote::copy() const
+{
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
+PlatformCAAnimationRemote::PlatformCAAnimationRemote(AnimationType type, const String& keyPath)
+    : PlatformCAAnimation(type)
+{
+    m_properties.keyPath = keyPath;
+    m_properties.animationType = type;
+}
+
+String PlatformCAAnimationRemote::keyPath() const
+{
+    return m_properties.keyPath;
+}
+
+CFTimeInterval PlatformCAAnimationRemote::beginTime() const
+{
+    return m_properties.beginTime;
+}
+
+void PlatformCAAnimationRemote::setBeginTime(CFTimeInterval value)
+{
+    m_properties.beginTime = value;
+    
+    // Also set a flag to tell us if we've passed in a 0 value. 
+    // The flag is needed because later beginTime will get changed
+    // to the time at which it fired and we need to know whether
+    // or not it was 0 to begin with.
+    if (value)
+        m_properties.hasNonZeroBeginTime = value;
+}
+
+CFTimeInterval PlatformCAAnimationRemote::duration() const
+{
+    return m_properties.duration;
+}
+
+void PlatformCAAnimationRemote::setDuration(CFTimeInterval value)
+{
+    m_properties.duration = value;
+}
+
+float PlatformCAAnimationRemote::speed() const
+{
+    return m_properties.speed;
+}
+
+void PlatformCAAnimationRemote::setSpeed(float value)
+{
+    m_properties.speed = value;
+}
+
+CFTimeInterval PlatformCAAnimationRemote::timeOffset() const
+{
+    return m_properties.timeOffset;
+}
+
+void PlatformCAAnimationRemote::setTimeOffset(CFTimeInterval value)
+{
+    m_properties.timeOffset = value;
+}
+
+float PlatformCAAnimationRemote::repeatCount() const
+{
+    return m_properties.repeatCount;
+}
+
+void PlatformCAAnimationRemote::setRepeatCount(float value)
+{
+    m_properties.repeatCount = value;
+}
+
+bool PlatformCAAnimationRemote::autoreverses() const
+{
+    return m_properties.autoReverses;
+}
+
+void PlatformCAAnimationRemote::setAutoreverses(bool value)
+{
+    m_properties.autoReverses = value;
+}
+
+PlatformCAAnimation::FillModeType PlatformCAAnimationRemote::fillMode() const
+{
+    return m_properties.fillMode;
+}
+
+void PlatformCAAnimationRemote::setFillMode(FillModeType value)
+{
+    m_properties.fillMode = value;
+}
+
+void PlatformCAAnimationRemote::setTimingFunction(const TimingFunction* value, bool reverse)
+{
+    Vector<RefPtr<TimingFunction>> timingFunctions;
+    timingFunctions.append(value->clone());
+
+    m_properties.timingFunctions = std::move(timingFunctions);
+    m_properties.reverseTimingFunctions = reverse;
+}
+
+void PlatformCAAnimationRemote::copyTimingFunctionFrom(const PlatformCAAnimation* value)
+{
+    ASSERT_NOT_REACHED();
+}
+
+bool PlatformCAAnimationRemote::isRemovedOnCompletion() const
+{
+    return m_properties.removedOnCompletion;
+}
+
+void PlatformCAAnimationRemote::setRemovedOnCompletion(bool value)
+{
+    m_properties.removedOnCompletion = value;
+}
+
+bool PlatformCAAnimationRemote::isAdditive() const
+{
+    return m_properties.additive;
+}
+
+void PlatformCAAnimationRemote::setAdditive(bool value)
+{
+    m_properties.additive = value;
+}
+
+PlatformCAAnimation::ValueFunctionType PlatformCAAnimationRemote::valueFunction() const
+{
+    return m_properties.valueFunction;
+}
+
+void PlatformCAAnimationRemote::setValueFunction(ValueFunctionType value)
+{
+    m_properties.valueFunction = value;
+}
+
+void PlatformCAAnimationRemote::setFromValue(float value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[0] = KeyframeValue(value);
+}
+
+void PlatformCAAnimationRemote::setFromValue(const TransformationMatrix& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[0] = KeyframeValue(value);
+}
+
+void PlatformCAAnimationRemote::setFromValue(const FloatPoint3D& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[0] = KeyframeValue(value);
+}
+
+void PlatformCAAnimationRemote::setFromValue(const Color& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[0] = KeyframeValue(value);
+}
+
+#if ENABLE(CSS_FILTERS)
+void PlatformCAAnimationRemote::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
+{
+    ASSERT_NOT_REACHED();
+}
+#endif
+
+void PlatformCAAnimationRemote::copyFromValueFrom(const PlatformCAAnimation* value)
+{
+    ASSERT_NOT_REACHED();
+}
+
+void PlatformCAAnimationRemote::setToValue(float value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[1] = KeyframeValue(value);
+}
+
+void PlatformCAAnimationRemote::setToValue(const TransformationMatrix& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[1] = KeyframeValue(value);
+}
+
+void PlatformCAAnimationRemote::setToValue(const FloatPoint3D& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[1] = KeyframeValue(value);
+}
+
+void PlatformCAAnimationRemote::setToValue(const Color& value)
+{
+    if (animationType() != Basic)
+        return;
+
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[1] = KeyframeValue(value);
+}
+
+#if ENABLE(CSS_FILTERS)
+void PlatformCAAnimationRemote::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
+{
+    ASSERT_NOT_REACHED();
+}
+#endif
+
+void PlatformCAAnimationRemote::copyToValueFrom(const PlatformCAAnimation* value)
+{
+    ASSERT_NOT_REACHED();
+}
+
+// Keyframe-animation properties.
+void PlatformCAAnimationRemote::setValues(const Vector<float>& values)
+{
+    if (animationType() != Keyframe)
+        return;
+
+    Vector<KeyframeValue> keyframes;
+    keyframes.reserveInitialCapacity(values.size());
+    
+    for (size_t i = 0; i < values.size(); ++i)
+        keyframes.uncheckedAppend(KeyframeValue(values[i]));
+    
+    m_properties.keyValues = std::move(keyframes);
+}
+
+void PlatformCAAnimationRemote::setValues(const Vector<TransformationMatrix>& values)
+{
+    if (animationType() != Keyframe)
+        return;
+        
+    Vector<KeyframeValue> keyframes;
+    keyframes.reserveInitialCapacity(values.size());
+    
+    for (size_t i = 0; i < values.size(); ++i)
+        keyframes.uncheckedAppend(KeyframeValue(values[i]));
+    
+    m_properties.keyValues = std::move(keyframes);
+}
+
+void PlatformCAAnimationRemote::setValues(const Vector<FloatPoint3D>& values)
+{
+    if (animationType() != Keyframe)
+        return;
+        
+    Vector<KeyframeValue> keyframes;
+    keyframes.reserveInitialCapacity(values.size());
+    
+    for (size_t i = 0; i < values.size(); ++i)
+        keyframes.uncheckedAppend(KeyframeValue(values[i]));
+    
+    m_properties.keyValues = std::move(keyframes);
+}
+
+void PlatformCAAnimationRemote::setValues(const Vector<Color>& values)
+{
+    if (animationType() != Keyframe)
+        return;
+        
+    Vector<KeyframeValue> keyframes;
+    keyframes.reserveInitialCapacity(values.size());
+    
+    for (size_t i = 0; i < values.size(); ++i)
+        keyframes.uncheckedAppend(KeyframeValue(values[i]));
+    
+    m_properties.keyValues = std::move(keyframes);
+}
+
+#if ENABLE(CSS_FILTERS)
+void PlatformCAAnimationRemote::setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex)
+{
+    UNUSED_PARAM(internalFilterPropertyIndex);
+    ASSERT_NOT_REACHED();
+}
+#endif
+
+void PlatformCAAnimationRemote::copyValuesFrom(const PlatformCAAnimation* value)
+{
+    ASSERT_NOT_REACHED();
+}
+
+void PlatformCAAnimationRemote::setKeyTimes(const Vector<float>& keyTimes)
+{
+    m_properties.keyTimes = keyTimes;
+}
+
+void PlatformCAAnimationRemote::copyKeyTimesFrom(const PlatformCAAnimation* value)
+{
+    ASSERT_NOT_REACHED();
+}
+
+void PlatformCAAnimationRemote::setTimingFunctions(const Vector<const TimingFunction*>& values, bool reverse)
+{
+    Vector<RefPtr<WebCore::TimingFunction>> timingFunctions;
+    timingFunctions.reserveInitialCapacity(values.size());
+    
+    for (size_t i = 0; i < values.size(); ++i)
+        timingFunctions.uncheckedAppend(values[i]->clone());
+    
+    m_properties.timingFunctions = std::move(timingFunctions);
+    m_properties.reverseTimingFunctions = reverse;
+}
+
+void PlatformCAAnimationRemote::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
+{
+    ASSERT_NOT_REACHED();
+}
+
+static NSObject* animationValueFromKeyframeValue(const PlatformCAAnimationRemote::KeyframeValue& keyframeValue)
+{
+    switch (keyframeValue.keyframeType()) {
+    case PlatformCAAnimationRemote::KeyframeValue::NumberKeyType:
+        return @(keyframeValue.numberValue());
+            
+    case PlatformCAAnimationRemote::KeyframeValue::ColorKeyType: {
+        Color color = keyframeValue.colorValue();
+        return @[ @(color.red()), @(color.green()), @(color.blue()), @(color.alpha()) ];
+    }
+
+    case PlatformCAAnimationRemote::KeyframeValue::PointKeyType: {
+        FloatPoint3D point = keyframeValue.pointValue();
+        return @[ @(point.x()), @(point.y()), @(point.z()) ];
+    }
+    case PlatformCAAnimationRemote::KeyframeValue::TransformKeyType:
+        return [NSValue valueWithCATransform3D:keyframeValue.transformValue()];
+    }
+}
+
+static void addAnimationToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const String& key, const PlatformCAAnimationRemote::Properties& properties)
+{
+    RetainPtr<CAPropertyAnimation> caAnimation;
+    switch (properties.animationType) {
+    case PlatformCAAnimation::Basic: {
+        RetainPtr<CABasicAnimation> basicAnimation;
+        basicAnimation = [CABasicAnimation animationWithKeyPath:properties.keyPath];
+        
+        if (properties.keyValues.size() > 1) {
+            [basicAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0])];
+            [basicAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1])];
+        }
+        
+        if (properties.timingFunctions.size())
+            [basicAnimation setTimingFunction:toCAMediaTimingFunction(properties.timingFunctions[0].get(), properties.reverseTimingFunctions)];
+        
+        caAnimation = basicAnimation;
+        break;
+    }
+    case PlatformCAAnimation::Keyframe: {
+        RetainPtr<CAKeyframeAnimation> keyframeAnimation;
+        keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:properties.keyPath];
+
+        if (properties.keyValues.size()) {
+            RetainPtr<NSMutableArray> keyframes = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.keyValues.size()]);
+            for (const auto& value : properties.keyValues)
+                [keyframes addObject:animationValueFromKeyframeValue(value)];
+            
+            [keyframeAnimation setValues:keyframes.get()];
+        }
+
+        if (properties.keyTimes.size()) {
+            RetainPtr<NSMutableArray> keyTimes = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.keyTimes.size()]);
+            for (auto keyTime : properties.keyTimes)
+                [keyTimes addObject:@(keyTime)];
+            
+            [keyframeAnimation setKeyTimes:keyTimes.get()];
+        }
+
+        if (properties.timingFunctions.size()) {
+            RetainPtr<NSMutableArray> timingFunctions = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.timingFunctions.size()]);
+            for (const auto& timingFunction : properties.timingFunctions)
+                [timingFunctions addObject:toCAMediaTimingFunction(timingFunction.get(), properties.reverseTimingFunctions)];
+            
+            [keyframeAnimation setTimingFunctions:timingFunctions.get()];
+        }
+        
+        caAnimation = keyframeAnimation;
+        break;
+    }
+    }
+    
+    [caAnimation setBeginTime:properties.beginTime];
+    [caAnimation setDuration:properties.duration];
+    [caAnimation setTimeOffset:properties.timeOffset];
+    [caAnimation setRepeatCount:properties.repeatCount];
+    [caAnimation setSpeed:properties.speed];
+    [caAnimation setAutoreverses:properties.autoReverses];
+    [caAnimation setRemovedOnCompletion:properties.removedOnCompletion];
+    [caAnimation setAdditive:properties.additive];
+    
+    if (properties.fillMode != PlatformCAAnimation::NoFillMode)
+        [caAnimation setFillMode:toCAFillModeType(properties.fillMode)];
+
+    if (properties.valueFunction != PlatformCAAnimation::NoValueFunction)
+        [caAnimation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(properties.valueFunction)]];
+    
+    if (properties.hasNonZeroBeginTime)
+        [caAnimation.get()  setValue:@YES forKey:WKNonZeroBeginTimeFlag];
+    
+    if (layerTreeHost) {
+        GraphicsLayer::PlatformLayerID layerID = RemoteLayerTreeHost::layerID(layer);
+    
+        RetainPtr<WKAnimationDelegate>& delegate = layerTreeHost->animationDelegates().add(layerID, nullptr).iterator->value;
+        if (!delegate)
+            delegate = adoptNS([[WKAnimationDelegate alloc] initWithLayerID:layerID layerTreeHost:layerTreeHost]);
+
+        [caAnimation setDelegate:delegate.get()];
+    }
+    
+    [layer addAnimation:caAnimation.get() forKey:key];
+}
+
+void PlatformCAAnimationRemote::updateLayerAnimations(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const AnimationsMap& animationsToAdd, const HashSet<String>& animationsToRemove)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+    for (const auto& value : animationsToRemove)
+        [layer removeAnimationForKey:value];
+
+    for (const auto& keyValuePair : animationsToAdd)
+        addAnimationToLayer(layer, layerTreeHost, keyValuePair.key, keyValuePair.value);
+
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+} // namespace WebKit
index 7659665..4d4f568 100644 (file)
@@ -42,7 +42,8 @@
 #import <wtf/RetainPtr.h>
 
 using namespace WebCore;
-using namespace WebKit;
+
+namespace WebKit {
 
 PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
 {
@@ -124,7 +125,7 @@ void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction
         }
 
         if (m_layerType == LayerTypeCustom) {
-            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
+            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
             m_properties.changedProperties = RemoteLayerTreeTransaction::NoChange;
             return;
         }
@@ -145,6 +146,8 @@ void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction
 
 void PlatformCALayerRemote::animationStarted(CFTimeInterval beginTime)
 {
+    if (m_owner)
+        m_owner->platformCALayerAnimationStarted(beginTime);
 }
 
 void PlatformCALayerRemote::ensureBackingStore()
@@ -267,18 +270,22 @@ void PlatformCALayerRemote::adoptSublayers(PlatformCALayer* source)
 
 void PlatformCALayerRemote::addAnimationForKey(const String& key, PlatformCAAnimation* animation)
 {
-    ASSERT_NOT_REACHED();
+    m_properties.addedAnimations.set(key, toPlatformCAAnimationRemote(animation)->properties());
+    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
+    
+    m_context->willStartAnimationOnLayer(this);
 }
 
 void PlatformCALayerRemote::removeAnimationForKey(const String& key)
 {
-    ASSERT_NOT_REACHED();
+    // FIXME: remove from m_properties.addedAnimations ?
+    m_properties.keyPathsOfAnimationsToRemove.add(key);
+    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
 }
 
 PassRefPtr<PlatformCAAnimation> PlatformCALayerRemote::animationForKey(const String& key)
 {
-    ASSERT_NOT_REACHED();
-
+    // FIXME: implement.
     return nullptr;
 }
 
@@ -589,3 +596,5 @@ uint32_t PlatformCALayerRemote::hostingContextID()
     ASSERT_NOT_REACHED();
     return 0;
 }
+
+} // namespace WebKit
index 43429ed..a202d65 100644 (file)
@@ -37,7 +37,8 @@
 #import <wtf/RetainPtr.h>
 
 using namespace WebCore;
-using namespace WebKit;
+
+namespace WebKit {
 
 static NSString * const platformCALayerPointer = @"WKPlatformCALayer";
 PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(PlatformLayer* customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
@@ -83,3 +84,5 @@ void PlatformCALayerRemoteCustom::setNeedsDisplay(const FloatRect* rect)
     } else
         PlatformCALayerRemote::setNeedsDisplay(rect);
 }
+
+} // namespace WebKit
index ffa3c5b..9f40c5c 100644 (file)
@@ -33,7 +33,8 @@
 #import <wtf/RetainPtr.h>
 
 using namespace WebCore;
-using namespace WebKit;
+
+namespace WebKit {
 
 PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     : PlatformCALayerRemote(layerType, owner, context)
@@ -102,3 +103,5 @@ void PlatformCALayerRemoteTiledBacking::setBorderColor(const WebCore::Color& col
 {
     m_tileController->setTileDebugBorderColor(color);
 }
+
+} // namespace WebKit
index aa010e5..9ac45ff 100644 (file)
@@ -55,6 +55,11 @@ public:
     void flushOutOfTreeLayers();
     void buildTransaction(RemoteLayerTreeTransaction&, WebCore::PlatformCALayer& rootLayer);
 
+    // From the UI process
+    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, double startTime);
+
+    void willStartAnimationOnLayer(PlatformCALayerRemote*);
+
 private:
     // WebCore::GraphicsLayerFactory
     virtual std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) override;
@@ -66,6 +71,8 @@ private:
 
     Vector<RemoteLayerTreeTransaction::LayerCreationProperties> m_createdLayers;
     Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayers;
+    
+    HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_layersAwaitingAnimationStart;
 };
 
 } // namespace WebKit
index d880635..b382ebc 100644 (file)
@@ -65,6 +65,8 @@ void RemoteLayerTreeContext::layerWillBeDestroyed(PlatformCALayerRemote* layer)
 {
     ASSERT(!m_destroyedLayers.contains(layer->layerID()));
     m_destroyedLayers.append(layer->layerID());
+    
+    m_layersAwaitingAnimationStart.remove(layer->layerID());
 }
 
 void RemoteLayerTreeContext::outOfTreeLayerWasAdded(GraphicsLayer* layer)
@@ -102,4 +104,16 @@ void RemoteLayerTreeContext::buildTransaction(RemoteLayerTreeTransaction& transa
     transaction.setDestroyedLayerIDs(std::move(m_destroyedLayers));
 }
 
+void RemoteLayerTreeContext::willStartAnimationOnLayer(PlatformCALayerRemote* layer)
+{
+    m_layersAwaitingAnimationStart.add(layer->layerID(), layer);
+}
+
+void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, double startTime)
+{
+    auto it = m_layersAwaitingAnimationStart.find(layerID);
+    if (it != m_layersAwaitingAnimationStart.end())
+        it->value->animationStarted(startTime);
+}
+
 } // namespace WebKit
index 3e67459..484666c 100644 (file)
@@ -75,6 +75,8 @@ private:
     virtual void setExposedRect(const WebCore::FloatRect&) override;
     virtual WebCore::FloatRect exposedRect() const override { return m_scrolledExposedRect; }
 
+    virtual void acceleratedAnimationDidStart(uint64_t layerID, double startTime) override;
+
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) override;
 #endif
index f781696..6832376 100644 (file)
@@ -242,6 +242,11 @@ void RemoteLayerTreeDrawingArea::forceRepaint()
     flushLayers();
 }
 
+void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID, double startTime)
+{
+    m_remoteLayerTreeContext->animationDidStart(layerID, startTime);
+}
+
 void RemoteLayerTreeDrawingArea::setExposedRect(const FloatRect& exposedRect)
 {
     m_exposedRect = exposedRect;
index 8386f2d..8b250ee 100644 (file)
@@ -44,6 +44,7 @@
 #import <WebCore/GraphicsLayerCA.h>
 #import <WebCore/MainFrame.h>
 #import <WebCore/Page.h>
+#import <WebCore/PlatformCAAnimationMac.h>
 #import <WebCore/RenderLayerBacking.h>
 #import <WebCore/RenderLayerCompositor.h>
 #import <WebCore/RenderView.h>
@@ -754,7 +755,7 @@ void TiledCoreAnimationDrawingArea::commitTransientZoom(double scale, FloatPoint
     transform.scale(scale);
 
     RetainPtr<CABasicAnimation> renderViewAnimationCA = transientZoomSnapAnimationForKeyPath("transform");
-    RefPtr<PlatformCAAnimation> renderViewAnimation = PlatformCAAnimation::create(renderViewAnimationCA.get());
+    RefPtr<PlatformCAAnimation> renderViewAnimation = PlatformCAAnimationMac::create(renderViewAnimationCA.get());
     renderViewAnimation->setToValue(transform);
 
     RetainPtr<CALayer> shadowLayer;