Changeset 166542 in webkit


Ignore:
Timestamp:
Mar 31, 2014 4:15:58 PM (10 years ago)
Author:
Simon Fraser
Message:

[UI-side compositing] Proxy animations to the UI process
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):

Location:
trunk/Source
Files:
4 added
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166537 r166542  
     12014-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] Proxy animations to the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=130946
     5
     6        Reviewed by Tim Horton.
     7       
     8        To proxy CA animations, make PlatformCAAnimation a pure virtual base class
     9        and subclass for Mac, Windows, and Remote (just like PlatformCALayer).
     10       
     11        Add coding support for TimingFunctions.
     12       
     13        Do some minor #include tidyup.
     14       
     15        Minor refactor in GraphicsLayerCA to share some animations code.
     16
     17        * WebCore.exp.in:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * platform/animation/TimingFunction.h: Add setters need for encode/decode.
     20        (WebCore::CubicBezierTimingFunction::setValues):
     21        (WebCore::CubicBezierTimingFunction::setTimingFunctionPreset):
     22        (WebCore::StepsTimingFunction::create):
     23        (WebCore::StepsTimingFunction::setNumberOfSteps):
     24        (WebCore::StepsTimingFunction::setStepAtStart):
     25        * platform/graphics/ca/GraphicsLayerCA.cpp:
     26        (WebCore::GraphicsLayerCA::createPlatformCAAnimation):
     27        (WebCore::GraphicsLayerCA::animationCanBeAccelerated): Minor refactor so we can share
     28        code with GraphicsLayerCARemote.
     29        (WebCore::GraphicsLayerCA::addAnimation):
     30        (WebCore::GraphicsLayerCA::createBasicAnimation):
     31        (WebCore::PassRefPtr<PlatformCAAnimation>GraphicsLayerCA::createKeyframeAnimation):
     32        * platform/graphics/ca/GraphicsLayerCA.h:
     33        * platform/graphics/ca/PlatformCAAnimation.h:
     34        (WebCore::PlatformCAAnimation::~PlatformCAAnimation):
     35        (WebCore::PlatformCAAnimation::isPlatformCAAnimationMac):
     36        (WebCore::PlatformCAAnimation::isPlatformCAAnimationWin):
     37        (WebCore::PlatformCAAnimation::isPlatformCAAnimationRemote):
     38        (WebCore::PlatformCAAnimation::PlatformCAAnimation):
     39        (WebCore::PlatformCAAnimation::setType):
     40        * platform/graphics/ca/PlatformCALayer.h:
     41        * platform/graphics/ca/mac/PlatformCAAnimationMac.h: Added.
     42        * platform/graphics/ca/mac/PlatformCAAnimationMac.mm:
     43        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
     44        (PlatformCALayerMac::addAnimationForKey):
     45        (PlatformCALayerMac::animationForKey):
     46        * platform/graphics/ca/mac/TileController.mm:
     47        * platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
     48        * platform/graphics/ca/win/PlatformCAAnimationWin.h: Added.
     49
    1502014-03-31  Benjamin Poulain  <benjamin@webkit.org>
    251
  • trunk/Source/WebCore/WebCore.exp.in

    r166531 r166542  
    718718__ZN7WebCore16startOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
    719719__ZN7WebCore16threadGlobalDataEv
     720__ZN7WebCore16toCAFillModeTypeENS_19PlatformCAAnimation12FillModeTypeE
    720721__ZN7WebCore17CredentialStorage24getFromPersistentStorageERKNS_15ProtectionSpaceE
    721722__ZN7WebCore17CredentialStorage3getERKNS_15ProtectionSpaceE
     
    793794__ZN7WebCore19MediaSessionManager30didReceiveRemoteControlCommandENS_12MediaSession24RemoteControlCommandTypeE
    794795__ZN7WebCore19MediaSessionManager9addClientEPNS_25MediaSessionManagerClientE
    795 __ZN7WebCore19PlatformCAAnimation10setToValueERKNS_20TransformationMatrixE
    796 __ZN7WebCore19PlatformCAAnimation6createEP19CAPropertyAnimation
    797 __ZN7WebCore19PlatformCAAnimationD1Ev
    798796__ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
    799797__ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
     
    902900__ZN7WebCore21setGlobalIconDatabaseEPNS_16IconDatabaseBaseE
    903901__ZN7WebCore21setPlatformStrategiesEPNS_18PlatformStrategiesE
     902__ZN7WebCore21toCAValueFunctionTypeENS_19PlatformCAAnimation17ValueFunctionTypeE
    904903__ZN7WebCore22HTMLPlugInImageElement24restartSnapshottedPlugInEv
    905904__ZN7WebCore22HTMLPlugInImageElement29setIsPrimarySnapshottedPlugInEb
    906905__ZN7WebCore22MutableStyleProperties25ensureCSSStyleDeclarationEv
    907906__ZN7WebCore22MutableStylePropertiesD1Ev
     907__ZN7WebCore22PlatformCAAnimationMac6createEP19CAPropertyAnimation
    908908__ZN7WebCore22RuntimeEnabledFeatures14sharedFeaturesEv
    909909__ZN7WebCore22ScriptExecutionContext26canSuspendActiveDOMObjectsEv
     
    941941__ZN7WebCore23getFileModificationTimeERKN3WTF6StringERl
    942942__ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
     943__ZN7WebCore23toCAMediaTimingFunctionEPKNS_14TimingFunctionEb
    943944__ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
    944945__ZN7WebCore24DocumentMarkerController10markersForEPNS_4NodeENS_14DocumentMarker11MarkerTypesE
     
    16451646__ZNK7WebCore15GraphicsLayerCA21canThrottleLayerFlushEv
    16461647__ZNK7WebCore15GraphicsLayerCA24dumpAdditionalPropertiesERNS_10TextStreamEij
     1648__ZNK7WebCore15GraphicsLayerCA25animationCanBeAcceleratedERKNS_17KeyframeValueListEPKNS_9AnimationE
    16471649__ZNK7WebCore15GraphicsLayerCA25shouldRepaintOnSizeChangeEv
    16481650__ZNK7WebCore15GraphicsLayerCA26backingStoreMemoryEstimateEv
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r166506 r166542  
    1915319153    <ClInclude Include="..\platform\graphics\cairo\TileCairo.h" />
    1915419154    <ClInclude Include="..\platform\graphics\ca\PlatformCAFilters.h" />
     19155    <ClInclude Include="..\platform\graphics\ca\win\PlatformCAAnimationWin.h" />
    1915519156    <ClInclude Include="..\platform\graphics\ca\win\PlatformCALayerWin.h" />
    1915619157    <ClInclude Include="..\platform\graphics\GLContext.h" />
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r166529 r166542  
    505505                0F5B7A5410F65D7A00376302 /* RenderEmbeddedObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */; };
    506506                0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
     507                0F5E200618E771FC003EC3E5 /* PlatformCAAnimationMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5E200518E771FC003EC3E5 /* PlatformCAAnimationMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    507508                0F605AEC15F94848004DF0C0 /* ScrollingConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */; };
    508509                0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    73267327                0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderEmbeddedObject.cpp; sourceTree = "<group>"; };
    73277328                0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderEmbeddedObject.h; sourceTree = "<group>"; };
     7329                0F5E200518E771FC003EC3E5 /* PlatformCAAnimationMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCAAnimationMac.h; path = ca/mac/PlatformCAAnimationMac.h; sourceTree = "<group>"; };
    73287330                0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingConstraints.cpp; sourceTree = "<group>"; };
    73297331                0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingConstraints.h; sourceTree = "<group>"; };
     
    1559615598                                93F72AF11666EDFC002A02BD /* LayerPool.h */,
    1559715599                                93F72AF21666EDFC002A02BD /* LayerPool.mm */,
     15600                                0F5E200518E771FC003EC3E5 /* PlatformCAAnimationMac.h */,
    1559815601                                4958781F12A57DDF007238AC /* PlatformCAAnimationMac.mm */,
    1559915602                                D66B2D5B186830050073C4DD /* PlatformCAFiltersMac.h */,
     
    2438724390                                BC4918C90BFEA050009D6316 /* JSHTMLIFrameElement.h in Headers */,
    2438824391                                1AE2AA980A1CDD2D00B42B25 /* JSHTMLImageElement.h in Headers */,
     24392                                0F5E200618E771FC003EC3E5 /* PlatformCAAnimationMac.h in Headers */,
    2438924393                                A80E7E970A1A83E3007FB8C5 /* JSHTMLInputElement.h in Headers */,
    2439024394                                E1AD14231295EA7F00ACA989 /* JSHTMLInputElementCustom.h in Headers */,
  • trunk/Source/WebCore/platform/animation/TimingFunction.h

    r162139 r166542  
    3333public:
    3434
     35    virtual PassRefPtr<TimingFunction> clone() const = 0;
     36
    3537    enum TimingFunctionType {
    3638        LinearFunction, CubicBezierFunction, StepsFunction
     
    6971        return other.isLinearTimingFunction();
    7072    }
    71    
     73
    7274private:
    7375    LinearTimingFunction()
     
    7577    {
    7678    }
    77 };
    78    
     79
     80    virtual PassRefPtr<TimingFunction> clone() const override
     81    {
     82        return adoptRef(new LinearTimingFunction);
     83    }
     84};
     85
    7986class CubicBezierTimingFunction : public TimingFunction {
    8087public:
     
    133140    double y2() const { return m_y2; }
    134141   
     142    void setValues(double x1, double y1, double x2, double y2)
     143    {
     144        m_x1 = x1;
     145        m_y1 = y1;
     146        m_x2 = x2;
     147        m_y2 = y2;
     148    }
     149   
    135150    TimingFunctionPreset timingFunctionPreset() const { return m_timingFunctionPreset; }
     151    void setTimingFunctionPreset(TimingFunctionPreset preset) { m_timingFunctionPreset = preset; }
    136152   
    137153    static const CubicBezierTimingFunction* defaultTimingFunction()
     
    157173    }
    158174
     175    virtual PassRefPtr<TimingFunction> clone() const override
     176    {
     177        return adoptRef(new CubicBezierTimingFunction(m_timingFunctionPreset, m_x1, m_y1, m_x2, m_y2));
     178    }
     179
    159180    double m_x1;
    160181    double m_y1;
     
    166187class StepsTimingFunction : public TimingFunction {
    167188public:
     189   
    168190    static PassRefPtr<StepsTimingFunction> create(int steps, bool stepAtStart)
    169191    {
    170192        return adoptRef(new StepsTimingFunction(steps, stepAtStart));
     193    }
     194    static PassRefPtr<StepsTimingFunction> create()
     195    {
     196        return adoptRef(new StepsTimingFunction(1, true));
    171197    }
    172198   
     
    183209   
    184210    int numberOfSteps() const { return m_steps; }
     211    void setNumberOfSteps(int steps) { m_steps = steps; }
     212
    185213    bool stepAtStart() const { return m_stepAtStart; }
     214    void setStepAtStart(bool stepAtStart) { m_stepAtStart = stepAtStart; }
    186215   
    187216private:
     
    192221    {
    193222    }
     223
     224    virtual PassRefPtr<TimingFunction> clone() const override
     225    {
     226        return adoptRef(new StepsTimingFunction(m_steps, m_stepAtStart));
     227    }
    194228   
    195229    int m_steps;
    196230    bool m_stepAtStart;
    197231};
    198    
     232
    199233} // namespace WebCore
    200234
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r166516 r166542  
    3232#include "FloatRect.h"
    3333#include "GraphicsLayerFactory.h"
     34#include "Image.h"
    3435#include "PlatformCAFilters.h"
    3536#include "PlatformCALayer.h"
     
    5253
    5354#if PLATFORM(COCOA)
     55#include "PlatformCAAnimationMac.h"
    5456#include "PlatformCALayerMac.h"
    5557#include "WebCoreSystemInterface.h"
     
    5759
    5860#if PLATFORM(WIN)
     61#include "PlatformCAAnimationWin.h"
    5962#include "PlatformCALayerWin.h"
    6063#endif
     
    342345}
    343346
     347PassRefPtr<PlatformCAAnimation> GraphicsLayerCA::createPlatformCAAnimation(PlatformCAAnimation::AnimationType type, const String& keyPath)
     348{
     349#if PLATFORM(COCOA)
     350    return PlatformCAAnimationMac::create(type, keyPath);
     351#elif PLATFORM(WIN)
     352    return PlatformCAAnimationWin::create(type, keyPath);
     353#endif
     354}
     355
    344356GraphicsLayerCA::GraphicsLayerCA(GraphicsLayerClient* client)
    345357    : GraphicsLayer(client)
     
    788800}
    789801
    790 bool GraphicsLayerCA::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& animationName, double timeOffset)
    791 {
    792     ASSERT(!animationName.isEmpty());
    793 
     802bool GraphicsLayerCA::animationCanBeAccelerated(const KeyframeValueList& valueList, const Animation* anim) const
     803{
    794804    if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2)
    795805        return false;
    796806
    797     // CoreAnimation does not handle the steps() timing function. Fall back
    798     // to software animation in that case.
    799807    if (animationHasStepsTimingFunction(valueList, anim))
     808        return false;
     809
     810    return true;
     811}
     812
     813bool GraphicsLayerCA::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& animationName, double timeOffset)
     814{
     815    ASSERT(!animationName.isEmpty());
     816
     817    if (!animationCanBeAccelerated(valueList, anim))
    800818        return false;
    801819
     
    25772595PassRefPtr<PlatformCAAnimation> GraphicsLayerCA::createBasicAnimation(const Animation* anim, const String& keyPath, bool additive)
    25782596{
    2579     RefPtr<PlatformCAAnimation> basicAnim = PlatformCAAnimation::create(PlatformCAAnimation::Basic, keyPath);
     2597    RefPtr<PlatformCAAnimation> basicAnim = createPlatformCAAnimation(PlatformCAAnimation::Basic, keyPath);
    25802598    setupAnimation(basicAnim.get(), anim, additive);
    25812599    return basicAnim;
     
    25842602PassRefPtr<PlatformCAAnimation>GraphicsLayerCA::createKeyframeAnimation(const Animation* anim, const String& keyPath, bool additive)
    25852603{
    2586     RefPtr<PlatformCAAnimation> keyframeAnim = PlatformCAAnimation::create(PlatformCAAnimation::Keyframe, keyPath);
     2604    RefPtr<PlatformCAAnimation> keyframeAnim = createPlatformCAAnimation(PlatformCAAnimation::Keyframe, keyPath);
    25872605    setupAnimation(keyframeAnim.get(), anim, additive);
    25882606    return keyframeAnim;
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r166516 r166542  
    2828
    2929#include "GraphicsLayer.h"
    30 #include "Image.h"
    3130#include "PlatformCAAnimation.h"
    3231#include "PlatformCALayer.h"
     
    4342namespace WebCore {
    4443
     44class Image;
    4545class TransformState;
    4646
     
    171171protected:
    172172    virtual void setOpacityInternal(float);
     173   
     174    bool animationCanBeAccelerated(const KeyframeValueList&, const Animation*) const;
    173175
    174176private:
     
    215217    virtual PassRefPtr<PlatformCALayer> createPlatformCALayer(PlatformCALayer::LayerType, PlatformCALayerClient* owner);
    216218    virtual PassRefPtr<PlatformCALayer> createPlatformCALayer(PlatformLayer*, PlatformCALayerClient* owner);
     219    virtual PassRefPtr<PlatformCAAnimation> createPlatformCAAnimation(PlatformCAAnimation::AnimationType, const String& keyPath);
    217220
    218221    PlatformCALayer* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); }
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h

    r165676 r166542  
    3232#include "TransformationMatrix.h"
    3333#include <wtf/RefCounted.h>
    34 #include <wtf/RetainPtr.h>
    3534#include <wtf/Vector.h>
    36 
    37 #if PLATFORM(COCOA)
    38 OBJC_CLASS CAPropertyAnimation;
    39 typedef CAPropertyAnimation* PlatformAnimationRef;
    40 #elif PLATFORM(WIN)
    41 typedef struct _CACFAnimation* CACFAnimationRef;
    42 typedef CACFAnimationRef PlatformAnimationRef;
    43 #endif
    4435
    4536namespace WebCore {
    4637
    4738class FloatRect;
    48 class PlatformCAAnimation;
    4939class TimingFunction;
    5040
    5141class PlatformCAAnimation : public RefCounted<PlatformCAAnimation> {
    5242public:
    53     friend class PlatformCALayer;
    54 #if PLATFORM(COCOA)
    55     friend class PlatformCALayerMac;
    56 #elif PLATFORM(WIN)
    57     friend class PlatformCALayerWin;
    58 #endif
    59    
    6043    enum AnimationType { Basic, Keyframe };
    6144    enum FillModeType { NoFillMode, Forwards, Backwards, Both };
    6245    enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate };
    6346
    64     static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
    65     static PassRefPtr<PlatformCAAnimation> create(PlatformAnimationRef);
     47    virtual ~PlatformCAAnimation() { }
    6648
    67     ~PlatformCAAnimation();
     49    virtual bool isPlatformCAAnimationMac() const { return false; }
     50    virtual bool isPlatformCAAnimationWin() const { return false; }
     51    virtual bool isPlatformCAAnimationRemote() const { return false; }
    6852   
    69     PassRefPtr<PlatformCAAnimation> copy() const;
    70 
    71     PlatformAnimationRef platformAnimation() const;
     53    virtual PassRefPtr<PlatformCAAnimation> copy() const = 0;
    7254   
    7355    AnimationType animationType() const { return m_type; }
    74     String keyPath() const;
     56    virtual String keyPath() const = 0;
    7557   
    76     CFTimeInterval beginTime() const;
    77     void setBeginTime(CFTimeInterval);
     58    virtual CFTimeInterval beginTime() const = 0;
     59    virtual void setBeginTime(CFTimeInterval) = 0;
    7860   
    79     CFTimeInterval duration() const;
    80     void setDuration(CFTimeInterval);
     61    virtual CFTimeInterval duration() const = 0;
     62    virtual void setDuration(CFTimeInterval) = 0;
    8163   
    82     float speed() const;
    83     void setSpeed(float);
     64    virtual float speed() const = 0;
     65    virtual void setSpeed(float) = 0;
    8466
    85     CFTimeInterval timeOffset() const;
    86     void setTimeOffset(CFTimeInterval);
     67    virtual CFTimeInterval timeOffset() const = 0;
     68    virtual void setTimeOffset(CFTimeInterval) = 0;
    8769
    88     float repeatCount() const;
    89     void setRepeatCount(float);
     70    virtual float repeatCount() const = 0;
     71    virtual void setRepeatCount(float) = 0;
    9072
    91     bool autoreverses() const;
    92     void setAutoreverses(bool);
     73    virtual bool autoreverses() const = 0;
     74    virtual void setAutoreverses(bool) = 0;
    9375
    94     FillModeType fillMode() const;
    95     void setFillMode(FillModeType);
     76    virtual FillModeType fillMode() const = 0;
     77    virtual void setFillMode(FillModeType) = 0;
    9678   
    97     void setTimingFunction(const TimingFunction*, bool reverse = false);
    98     void copyTimingFunctionFrom(const PlatformCAAnimation*);
     79    virtual void setTimingFunction(const TimingFunction*, bool reverse = false) = 0;
     80    virtual void copyTimingFunctionFrom(const PlatformCAAnimation*) = 0;
    9981
    100     bool isRemovedOnCompletion() const;
    101     void setRemovedOnCompletion(bool);
     82    virtual bool isRemovedOnCompletion() const = 0;
     83    virtual void setRemovedOnCompletion(bool) = 0;
    10284
    103     bool isAdditive() const;
    104     void setAdditive(bool);
     85    virtual bool isAdditive() const = 0;
     86    virtual void setAdditive(bool) = 0;
    10587
    106     ValueFunctionType valueFunction() const;
    107     void setValueFunction(ValueFunctionType);
     88    virtual ValueFunctionType valueFunction() const = 0;
     89    virtual void setValueFunction(ValueFunctionType) = 0;
    10890
    10991    // Basic-animation properties.
    110     void setFromValue(float);
    111     void setFromValue(const WebCore::TransformationMatrix&);
    112     void setFromValue(const FloatPoint3D&);
    113     void setFromValue(const WebCore::Color&);
     92    virtual void setFromValue(float) = 0;
     93    virtual void setFromValue(const WebCore::TransformationMatrix&) = 0;
     94    virtual void setFromValue(const FloatPoint3D&) = 0;
     95    virtual void setFromValue(const WebCore::Color&) = 0;
    11496#if ENABLE(CSS_FILTERS)
    115     void setFromValue(const FilterOperation*, int internalFilterPropertyIndex);
     97    virtual void setFromValue(const FilterOperation*, int internalFilterPropertyIndex) = 0;
    11698#endif
    117     void copyFromValueFrom(const PlatformCAAnimation*);
     99    virtual void copyFromValueFrom(const PlatformCAAnimation*) = 0;
    118100
    119     void setToValue(float);
    120     void setToValue(const WebCore::TransformationMatrix&);
    121     void setToValue(const FloatPoint3D&);
    122     void setToValue(const WebCore::Color&);
     101    virtual void setToValue(float) = 0;
     102    virtual void setToValue(const WebCore::TransformationMatrix&) = 0;
     103    virtual void setToValue(const FloatPoint3D&) = 0;
     104    virtual void setToValue(const WebCore::Color&) = 0;
    123105#if ENABLE(CSS_FILTERS)
    124     void setToValue(const FilterOperation*, int internalFilterPropertyIndex);
     106    virtual void setToValue(const FilterOperation*, int internalFilterPropertyIndex) = 0;
    125107#endif
    126     void copyToValueFrom(const PlatformCAAnimation*);
     108    virtual void copyToValueFrom(const PlatformCAAnimation*) = 0;
    127109
    128110    // Keyframe-animation properties.
    129     void setValues(const Vector<float>&);
    130     void setValues(const Vector<WebCore::TransformationMatrix>&);
    131     void setValues(const Vector<FloatPoint3D>&);
    132     void setValues(const Vector<WebCore::Color>&);
     111    virtual void setValues(const Vector<float>&) = 0;
     112    virtual void setValues(const Vector<WebCore::TransformationMatrix>&) = 0;
     113    virtual void setValues(const Vector<FloatPoint3D>&) = 0;
     114    virtual void setValues(const Vector<WebCore::Color>&) = 0;
    133115#if ENABLE(CSS_FILTERS)
    134     void setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex);
     116    virtual void setValues(const Vector<RefPtr<FilterOperation>>&, int internalFilterPropertyIndex) = 0;
    135117#endif
    136     void copyValuesFrom(const PlatformCAAnimation*);
     118    virtual void copyValuesFrom(const PlatformCAAnimation*) = 0;
    137119
    138     void setKeyTimes(const Vector<float>&);
    139     void copyKeyTimesFrom(const PlatformCAAnimation*);
     120    virtual void setKeyTimes(const Vector<float>&) = 0;
     121    virtual void copyKeyTimesFrom(const PlatformCAAnimation*) = 0;
    140122
    141     void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false);
    142     void copyTimingFunctionsFrom(const PlatformCAAnimation*);
    143 
    144 protected:
    145     PlatformCAAnimation(AnimationType, const String& keyPath);
    146     PlatformCAAnimation(PlatformAnimationRef);
     123    virtual void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false) = 0;
     124    virtual void copyTimingFunctionsFrom(const PlatformCAAnimation*) = 0;
    147125
    148126    void setActualStartTimeIfNeeded(CFTimeInterval t)
     
    151129            setBeginTime(t);
    152130    }
     131   
     132protected:
     133    PlatformCAAnimation(AnimationType type = Basic)
     134        : m_type(type)
     135    {
     136    }
     137
     138    void setType(AnimationType type) { m_type = type; }
    153139
    154140private:
    155141    AnimationType m_type;
    156    
    157 #if PLATFORM(COCOA)
    158     RetainPtr<CAPropertyAnimation> m_animation;
    159 #elif PLATFORM(WIN)
    160     RetainPtr<CACFAnimationRef> m_animation;
    161 #endif
    162142};
     143
     144#define PLATFORM_CAANIMATION_TYPE_CASTS(ToValueTypeName, predicate) \
     145    TYPE_CASTS_BASE(ToValueTypeName, WebCore::PlatformCAAnimation, object, object->predicate, object.predicate)
    163146
    164147}
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r166308 r166542  
    2727#define PlatformCALayer_h
    2828
    29 #include "GraphicsContext.h"
    3029#include "GraphicsLayer.h"
    31 #include "PlatformCAAnimation.h"
    3230#include "PlatformCALayerClient.h"
    3331#include <QuartzCore/CABase.h>
     
    4341OBJC_CLASS AVPlayerLayer;
    4442
     43#if PLATFORM(COCOA)
     44typedef struct CGContext *CGContextRef;
     45#endif
     46
    4547namespace WebCore {
    4648
    4749class PlatformCALayer;
     50class PlatformCAAnimation;
    4851
    4952typedef Vector<RefPtr<PlatformCALayer>> PlatformCALayerList;
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm

    r165676 r166542  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#include "config.h"
    2727
    28 #import "PlatformCAAnimation.h"
     28#import "PlatformCAAnimationMac.h"
    2929
    3030#import "FloatConversion.h"
     
    4141static bool hasNonZeroBeginTimeFlag(const PlatformCAAnimation* animation)
    4242{
    43     return [[animation->platformAnimation() valueForKey:WKNonZeroBeginTimeFlag] boolValue];
     43    return [[toPlatformCAAnimationMac(animation)->platformAnimation() valueForKey:WKNonZeroBeginTimeFlag] boolValue];
    4444}
    4545
    4646static void setNonZeroBeginTimeFlag(PlatformCAAnimation* animation, bool value)
    4747{
    48     [animation->platformAnimation() setValue:[NSNumber numberWithBool:value] forKey:WKNonZeroBeginTimeFlag];
    49 }
    50    
    51 static NSString* toCAFillModeType(PlatformCAAnimation::FillModeType type)
     48    [toPlatformCAAnimationMac(animation)->platformAnimation() setValue:[NSNumber numberWithBool:value] forKey:WKNonZeroBeginTimeFlag];
     49}
     50   
     51NSString* WebCore::toCAFillModeType(PlatformCAAnimation::FillModeType type)
    5252{
    5353    switch (type) {
     
    7171}
    7272
    73 static NSString* toCAValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
     73NSString* WebCore::toCAValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
    7474{
    7575    switch (type) {
     
    128128}
    129129
    130 static CAMediaTimingFunction* toCAMediaTimingFunction(const TimingFunction* timingFunction, bool reverse)
     130CAMediaTimingFunction* WebCore::toCAMediaTimingFunction(const TimingFunction* timingFunction, bool reverse)
    131131{
    132132    ASSERT(timingFunction);
     
    147147    }
    148148   
     149    ASSERT(timingFunction->type() == TimingFunction::LinearFunction);
    149150    return [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    150151}
    151152
    152 PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(AnimationType type, const String& keyPath)
    153 {
    154     return adoptRef(new PlatformCAAnimation(type, keyPath));
    155 }
    156 
    157 PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(PlatformAnimationRef animation)
    158 {
    159     return adoptRef(new PlatformCAAnimation(animation));
    160 }
    161 
    162 PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPath)
    163     : m_type(type)
     153PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::create(AnimationType type, const String& keyPath)
     154{
     155    return adoptRef(new PlatformCAAnimationMac(type, keyPath));
     156}
     157
     158PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::create(PlatformAnimationRef animation)
     159{
     160    return adoptRef(new PlatformCAAnimationMac(animation));
     161}
     162
     163PlatformCAAnimationMac::PlatformCAAnimationMac(AnimationType type, const String& keyPath)
     164    : PlatformCAAnimation(type)
    164165{
    165166    if (type == Basic)
     
    169170}
    170171
    171 PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
     172PlatformCAAnimationMac::PlatformCAAnimationMac(PlatformAnimationRef animation)
    172173{
    173174    if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CABasicAnimation class]])
    174         m_type = Basic;
     175        setType(Basic);
    175176    else if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CAKeyframeAnimation class]])
    176         m_type = Keyframe;
     177        setType(Keyframe);
    177178    else {
    178179        ASSERT(0);
     
    183184}
    184185
    185 PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::copy() const
     186PlatformCAAnimationMac::~PlatformCAAnimationMac()
     187{
     188}
     189
     190PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::copy() const
    186191{
    187192    RefPtr<PlatformCAAnimation> animation = create(animationType(), keyPath());
     
    213218    return animation;
    214219}
    215 PlatformCAAnimation::~PlatformCAAnimation()
    216 {
    217 }
    218 
    219 PlatformAnimationRef PlatformCAAnimation::platformAnimation() const
     220
     221PlatformAnimationRef PlatformCAAnimationMac::platformAnimation() const
    220222{
    221223    return m_animation.get();
    222224}
    223225
    224 String PlatformCAAnimation::keyPath() const
     226String PlatformCAAnimationMac::keyPath() const
    225227{
    226228    return [m_animation.get() keyPath];
    227229}
    228230
    229 CFTimeInterval PlatformCAAnimation::beginTime() const
     231CFTimeInterval PlatformCAAnimationMac::beginTime() const
    230232{
    231233    return [m_animation.get() beginTime];
    232234}
    233235
    234 void PlatformCAAnimation::setBeginTime(CFTimeInterval value)
     236void PlatformCAAnimationMac::setBeginTime(CFTimeInterval value)
    235237{
    236238    [m_animation.get() setBeginTime:value];
     
    244246}
    245247
    246 CFTimeInterval PlatformCAAnimation::duration() const
     248CFTimeInterval PlatformCAAnimationMac::duration() const
    247249{
    248250    return [m_animation.get() duration];
    249251}
    250252
    251 void PlatformCAAnimation::setDuration(CFTimeInterval value)
     253void PlatformCAAnimationMac::setDuration(CFTimeInterval value)
    252254{
    253255    [m_animation.get() setDuration:value];
    254256}
    255257
    256 float PlatformCAAnimation::speed() const
     258float PlatformCAAnimationMac::speed() const
    257259{
    258260    return [m_animation.get() speed];
    259261}
    260262
    261 void PlatformCAAnimation::setSpeed(float value)
     263void PlatformCAAnimationMac::setSpeed(float value)
    262264{
    263265    [m_animation.get() setSpeed:value];
    264266}
    265267
    266 CFTimeInterval PlatformCAAnimation::timeOffset() const
     268CFTimeInterval PlatformCAAnimationMac::timeOffset() const
    267269{
    268270    return [m_animation.get() timeOffset];
    269271}
    270272
    271 void PlatformCAAnimation::setTimeOffset(CFTimeInterval value)
     273void PlatformCAAnimationMac::setTimeOffset(CFTimeInterval value)
    272274{
    273275    [m_animation.get() setTimeOffset:value];
    274276}
    275277
    276 float PlatformCAAnimation::repeatCount() const
     278float PlatformCAAnimationMac::repeatCount() const
    277279{
    278280    return [m_animation.get() repeatCount];
    279281}
    280282
    281 void PlatformCAAnimation::setRepeatCount(float value)
     283void PlatformCAAnimationMac::setRepeatCount(float value)
    282284{
    283285    [m_animation.get() setRepeatCount:value];
    284286}
    285287
    286 bool PlatformCAAnimation::autoreverses() const
     288bool PlatformCAAnimationMac::autoreverses() const
    287289{
    288290    return [m_animation.get() autoreverses];
    289291}
    290292
    291 void PlatformCAAnimation::setAutoreverses(bool value)
     293void PlatformCAAnimationMac::setAutoreverses(bool value)
    292294{
    293295    [m_animation.get() setAutoreverses:value];
    294296}
    295297
    296 PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const
     298PlatformCAAnimation::FillModeType PlatformCAAnimationMac::fillMode() const
    297299{
    298300    return fromCAFillModeType([m_animation.get() fillMode]);
    299301}
    300302
    301 void PlatformCAAnimation::setFillMode(FillModeType value)
     303void PlatformCAAnimationMac::setFillMode(FillModeType value)
    302304{
    303305    [m_animation.get() setFillMode:toCAFillModeType(value)];
    304306}
    305307
    306 void PlatformCAAnimation::setTimingFunction(const TimingFunction* value, bool reverse)
     308void PlatformCAAnimationMac::setTimingFunction(const TimingFunction* value, bool reverse)
    307309{
    308310    [m_animation.get() setTimingFunction:toCAMediaTimingFunction(value, reverse)];
    309311}
    310312
    311 void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value)
    312 {
    313     [m_animation.get() setTimingFunction:[value->m_animation.get() timingFunction]];
    314 }
    315 
    316 bool PlatformCAAnimation::isRemovedOnCompletion() const
     313void PlatformCAAnimationMac::copyTimingFunctionFrom(const PlatformCAAnimation* value)
     314{
     315    [m_animation.get() setTimingFunction:[toPlatformCAAnimationMac(value)->m_animation.get() timingFunction]];
     316}
     317
     318bool PlatformCAAnimationMac::isRemovedOnCompletion() const
    317319{
    318320    return [m_animation.get() isRemovedOnCompletion];
    319321}
    320322
    321 void PlatformCAAnimation::setRemovedOnCompletion(bool value)
     323void PlatformCAAnimationMac::setRemovedOnCompletion(bool value)
    322324{
    323325    [m_animation.get() setRemovedOnCompletion:value];
    324326}
    325327
    326 bool PlatformCAAnimation::isAdditive() const
     328bool PlatformCAAnimationMac::isAdditive() const
    327329{
    328330    return [m_animation.get() isAdditive];
    329331}
    330332
    331 void PlatformCAAnimation::setAdditive(bool value)
     333void PlatformCAAnimationMac::setAdditive(bool value)
    332334{
    333335    [m_animation.get() setAdditive:value];
    334336}
    335337
    336 PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() const
     338PlatformCAAnimation::ValueFunctionType PlatformCAAnimationMac::valueFunction() const
    337339{
    338340    CAValueFunction* vf = [m_animation.get() valueFunction];
     
    340342}
    341343
    342 void PlatformCAAnimation::setValueFunction(ValueFunctionType value)
     344void PlatformCAAnimationMac::setValueFunction(ValueFunctionType value)
    343345{
    344346    [m_animation.get() setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(value)]];
    345347}
    346348
    347 void PlatformCAAnimation::setFromValue(float value)
     349void PlatformCAAnimationMac::setFromValue(float value)
    348350{
    349351    if (animationType() != Basic)
     
    352354}
    353355
    354 void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& value)
     356void PlatformCAAnimationMac::setFromValue(const WebCore::TransformationMatrix& value)
    355357{
    356358    if (animationType() != Basic)
     
    360362}
    361363
    362 void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
     364void PlatformCAAnimationMac::setFromValue(const FloatPoint3D& value)
    363365{
    364366    if (animationType() != Basic)
     
    373375}
    374376
    375 void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
     377void PlatformCAAnimationMac::setFromValue(const WebCore::Color& value)
    376378{
    377379    if (animationType() != Basic)
     
    388390
    389391#if ENABLE(CSS_FILTERS)
    390 void PlatformCAAnimation::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
     392void PlatformCAAnimationMac::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
    391393{
    392394    RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
     
    395397#endif
    396398
    397 void PlatformCAAnimation::copyFromValueFrom(const PlatformCAAnimation* value)
     399void PlatformCAAnimationMac::copyFromValueFrom(const PlatformCAAnimation* value)
    398400{
    399401    if (animationType() != Basic || value->animationType() != Basic)
    400402        return;
    401403       
    402     CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(value->m_animation.get());
     404    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
    403405    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[otherAnimation fromValue]];
    404406}
    405407
    406 void PlatformCAAnimation::setToValue(float value)
     408void PlatformCAAnimationMac::setToValue(float value)
    407409{
    408410    if (animationType() != Basic)
     
    411413}
    412414
    413 void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
     415void PlatformCAAnimationMac::setToValue(const WebCore::TransformationMatrix& value)
    414416{
    415417    if (animationType() != Basic)
     
    419421}
    420422
    421 void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
     423void PlatformCAAnimationMac::setToValue(const FloatPoint3D& value)
    422424{
    423425    if (animationType() != Basic)
     
    432434}
    433435
    434 void PlatformCAAnimation::setToValue(const WebCore::Color& value)
     436void PlatformCAAnimationMac::setToValue(const WebCore::Color& value)
    435437{
    436438    if (animationType() != Basic)
     
    447449
    448450#if ENABLE(CSS_FILTERS)
    449 void PlatformCAAnimation::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
     451void PlatformCAAnimationMac::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
    450452{
    451453    RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
     
    454456#endif
    455457
    456 void PlatformCAAnimation::copyToValueFrom(const PlatformCAAnimation* value)
     458void PlatformCAAnimationMac::copyToValueFrom(const PlatformCAAnimation* value)
    457459{
    458460    if (animationType() != Basic || value->animationType() != Basic)
    459461        return;
    460462       
    461     CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(value->m_animation.get());
     463    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
    462464    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[otherAnimation toValue]];
    463465}
     
    465467
    466468// Keyframe-animation properties.
    467 void PlatformCAAnimation::setValues(const Vector<float>& value)
     469void PlatformCAAnimationMac::setValues(const Vector<float>& value)
    468470{
    469471    if (animationType() != Keyframe)
     
    476478}
    477479
    478 void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>& value)
     480void PlatformCAAnimationMac::setValues(const Vector<WebCore::TransformationMatrix>& value)
    479481{
    480482    if (animationType() != Keyframe)
     
    489491}
    490492
    491 void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
     493void PlatformCAAnimationMac::setValues(const Vector<FloatPoint3D>& value)
    492494{
    493495    if (animationType() != Keyframe)
     
    507509}
    508510
    509 void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
     511void PlatformCAAnimationMac::setValues(const Vector<WebCore::Color>& value)
    510512{
    511513    if (animationType() != Keyframe)
     
    527529
    528530#if ENABLE(CSS_FILTERS)
    529 void PlatformCAAnimation::setValues(const Vector<RefPtr<FilterOperation>>& values, int internalFilterPropertyIndex)
     531void PlatformCAAnimationMac::setValues(const Vector<RefPtr<FilterOperation>>& values, int internalFilterPropertyIndex)
    530532{
    531533    if (animationType() != Keyframe)
     
    542544#endif
    543545
    544 void PlatformCAAnimation::copyValuesFrom(const PlatformCAAnimation* value)
     546void PlatformCAAnimationMac::copyValuesFrom(const PlatformCAAnimation* value)
    545547{
    546548    if (animationType() != Keyframe || value->animationType() != Keyframe)
    547549        return;
    548550       
    549     CAKeyframeAnimation* otherAnimation = static_cast<CAKeyframeAnimation*>(value->m_animation.get());
     551    CAKeyframeAnimation* otherAnimation = static_cast<CAKeyframeAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
    550552    [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:[otherAnimation values]];
    551553}
    552554
    553 void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
     555void PlatformCAAnimationMac::setKeyTimes(const Vector<float>& value)
    554556{
    555557    NSMutableArray* array = [NSMutableArray array];
     
    561563}
    562564
    563 void PlatformCAAnimation::copyKeyTimesFrom(const PlatformCAAnimation* value)
    564 {
    565     CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(value->m_animation.get());
     565void PlatformCAAnimationMac::copyKeyTimesFrom(const PlatformCAAnimation* value)
     566{
     567    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
    566568    [static_cast<CAKeyframeAnimation*>(m_animation.get()) setKeyTimes:[other keyTimes]];
    567569}
    568570
    569 void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
     571void PlatformCAAnimationMac::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
    570572{
    571573    NSMutableArray* array = [NSMutableArray array];
     
    577579}
    578580
    579 void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
    580 {
    581     CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(value->m_animation.get());
     581void PlatformCAAnimationMac::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
     582{
     583    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(toPlatformCAAnimationMac(value)->m_animation.get());
    582584    [static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:[other timingFunctions]];
    583585}
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r166308 r166542  
    3333#import "GraphicsLayerCA.h"
    3434#import "LengthFunctions.h"
     35#import "PlatformCAAnimationMac.h"
    3536#import "PlatformCAFilters.h"
    3637#import "PlatformCAFiltersMac.h"
     
    396397    }
    397398   
    398     CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(animation->platformAnimation());
     399    CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(toPlatformCAAnimationMac(animation)->platformAnimation());
    399400    if (![propertyAnimation delegate])
    400401        [propertyAnimation setDelegate:static_cast<id>(m_delegate.get())];
    401402     
    402403    BEGIN_BLOCK_OBJC_EXCEPTIONS
    403     [m_layer.get() addAnimation:animation->m_animation.get() forKey:key];
     404    [m_layer.get() addAnimation:propertyAnimation forKey:key];
    404405    END_BLOCK_OBJC_EXCEPTIONS
    405406}
     
    417418    if (!propertyAnimation)
    418419        return 0;
    419     return PlatformCAAnimation::create(propertyAnimation);
     420    return PlatformCAAnimationMac::create(propertyAnimation);
    420421}
    421422
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm

    r166516 r166542  
    2727#import "TileController.h"
    2828
     29#import "GraphicsContext.h"
    2930#import "IntRect.h"
    3031#import "PlatformCALayer.h"
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp

    r165676 r166542  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#include "config.h"
    2727
    28 #include "PlatformCAAnimation.h"
     28#if PLATFORM(WIN)
     29#include "PlatformCAAnimationWin.h"
    2930
    3031#include "FloatConversion.h"
     
    142143}
    143144
    144 PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(AnimationType type, const String& keyPath)
    145 {
    146     return adoptRef(new PlatformCAAnimation(type, keyPath));
    147 }
    148 
    149 PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::create(PlatformAnimationRef animation)
    150 {
    151     return adoptRef(new PlatformCAAnimation(animation));
    152 }
    153 
    154 PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPath)
    155     : m_type(type)
     145PassRefPtr<PlatformCAAnimation> PlatformCAAnimationWin::create(AnimationType type, const String& keyPath)
     146{
     147    return adoptRef(new PlatformCAAnimationWin(type, keyPath));
     148}
     149
     150PassRefPtr<PlatformCAAnimation> PlatformCAAnimationWin::create(PlatformAnimationRef animation)
     151{
     152    return adoptRef(new PlatformCAAnimationWin(animation));
     153}
     154
     155PlatformCAAnimationWin::PlatformCAAnimationWin(AnimationType type, const String& keyPath)
     156    : PlatformCAAnimation(type)
    156157{
    157158    if (type == Basic)
     
    163164}
    164165
    165 PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
     166PlatformCAAnimationWin::PlatformCAAnimationWin(PlatformAnimationRef animation)
    166167{
    167168    if (CACFAnimationGetClass(animation) == kCACFBasicAnimation)
    168         m_type = Basic;
     169        setType(Basic);
    169170    else if (CACFAnimationGetClass(animation) == kCACFKeyframeAnimation)
    170         m_type = Keyframe;
     171        setType(Keyframe);
    171172    else {
    172173        ASSERT_NOT_REACHED();
     
    177178}
    178179
    179 PassRefPtr<PlatformCAAnimation> PlatformCAAnimation::copy() const
     180PassRefPtr<PlatformCAAnimation> PlatformCAAnimationWin::copy() const
    180181{
    181182    RefPtr<PlatformCAAnimation> animation = create(animationType(), keyPath());
     
    207208}
    208209
    209 PlatformCAAnimation::~PlatformCAAnimation()
    210 {
    211 }
    212 
    213 PlatformAnimationRef PlatformCAAnimation::platformAnimation() const
     210PlatformCAAnimationWin::~PlatformCAAnimationWin()
     211{
     212}
     213
     214PlatformAnimationRef PlatformCAAnimationWin::platformAnimation() const
    214215{
    215216    return m_animation.get();
    216217}
    217218
    218 String PlatformCAAnimation::keyPath() const
     219String PlatformCAAnimationWin::keyPath() const
    219220{
    220221    return CACFAnimationGetKeyPath(m_animation.get());
    221222}
    222223
    223 CFTimeInterval PlatformCAAnimation::beginTime() const
     224CFTimeInterval PlatformCAAnimationWin::beginTime() const
    224225{
    225226    return CACFAnimationGetBeginTime(m_animation.get());
    226227}
    227228
    228 void PlatformCAAnimation::setBeginTime(CFTimeInterval value)
     229void PlatformCAAnimationWin::setBeginTime(CFTimeInterval value)
    229230{
    230231    CACFAnimationSetBeginTime(m_animation.get(), value);
    231232}
    232233
    233 CFTimeInterval PlatformCAAnimation::duration() const
     234CFTimeInterval PlatformCAAnimationWin::duration() const
    234235{
    235236    return CACFAnimationGetDuration(m_animation.get());
    236237}
    237238
    238 void PlatformCAAnimation::setDuration(CFTimeInterval value)
     239void PlatformCAAnimationWin::setDuration(CFTimeInterval value)
    239240{
    240241    CACFAnimationSetDuration(m_animation.get(), value);
    241242}
    242243
    243 float PlatformCAAnimation::speed() const
     244float PlatformCAAnimationWin::speed() const
    244245{
    245246    return CACFAnimationGetSpeed(m_animation.get());
    246247}
    247248
    248 void PlatformCAAnimation::setSpeed(float value)
     249void PlatformCAAnimationWin::setSpeed(float value)
    249250{
    250251    CACFAnimationSetSpeed(m_animation.get(), value);
    251252}
    252253
    253 CFTimeInterval PlatformCAAnimation::timeOffset() const
     254CFTimeInterval PlatformCAAnimationWin::timeOffset() const
    254255{
    255256    return CACFAnimationGetTimeOffset(m_animation.get());
    256257}
    257258
    258 void PlatformCAAnimation::setTimeOffset(CFTimeInterval value)
     259void PlatformCAAnimationWin::setTimeOffset(CFTimeInterval value)
    259260{
    260261    CACFAnimationSetTimeOffset(m_animation.get(), value);
    261262}
    262263
    263 float PlatformCAAnimation::repeatCount() const
     264float PlatformCAAnimationWin::repeatCount() const
    264265{
    265266    return CACFAnimationGetRepeatCount(m_animation.get());
    266267}
    267268
    268 void PlatformCAAnimation::setRepeatCount(float value)
     269void PlatformCAAnimationWin::setRepeatCount(float value)
    269270{
    270271    CACFAnimationSetRepeatCount(m_animation.get(), value);
    271272}
    272273
    273 bool PlatformCAAnimation::autoreverses() const
     274bool PlatformCAAnimationWin::autoreverses() const
    274275{
    275276    return CACFAnimationGetAutoreverses(m_animation.get());
    276277}
    277278
    278 void PlatformCAAnimation::setAutoreverses(bool value)
     279void PlatformCAAnimationWin::setAutoreverses(bool value)
    279280{
    280281    CACFAnimationSetAutoreverses(m_animation.get(), value);
    281282}
    282283
    283 PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const
     284PlatformCAAnimationWin::FillModeType PlatformCAAnimationWin::fillMode() const
    284285{
    285286    return fromCACFFillModeType(CACFAnimationGetFillMode(m_animation.get()));
    286287}
    287288
    288 void PlatformCAAnimation::setFillMode(FillModeType value)
     289void PlatformCAAnimationWin::setFillMode(FillModeType value)
    289290{
    290291    CACFAnimationSetFillMode(m_animation.get(), toCACFFillModeType(value));
    291292}
    292293
    293 void PlatformCAAnimation::setTimingFunction(const TimingFunction* value, bool reverse)
     294void PlatformCAAnimationWin::setTimingFunction(const TimingFunction* value, bool reverse)
    294295{
    295296    UNUSED_PARAM(reverse);
     
    297298}
    298299
    299 void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value)
    300 {
    301     CACFTimingFunctionRef timingFunc = CACFAnimationGetTimingFunction(value->m_animation.get());
     300void PlatformCAAnimationWin::copyTimingFunctionFrom(const PlatformCAAnimation* value)
     301{
     302    CACFTimingFunctionRef timingFunc = CACFAnimationGetTimingFunction(toPlatformCAAnimationWin(value)->m_animation.get());
    302303    if (timingFunc)
    303304        CACFAnimationSetTimingFunction(m_animation.get(), timingFunc);
    304305}
    305306
    306 bool PlatformCAAnimation::isRemovedOnCompletion() const
     307bool PlatformCAAnimationWin::isRemovedOnCompletion() const
    307308{
    308309    return CACFAnimationIsRemovedOnCompletion(m_animation.get());
    309310}
    310311
    311 void PlatformCAAnimation::setRemovedOnCompletion(bool value)
     312void PlatformCAAnimationWin::setRemovedOnCompletion(bool value)
    312313{
    313314    CACFAnimationSetRemovedOnCompletion(m_animation.get(), value);
    314315}
    315316
    316 bool PlatformCAAnimation::isAdditive() const
     317bool PlatformCAAnimationWin::isAdditive() const
    317318{
    318319    return CACFAnimationIsAdditive(m_animation.get());
    319320}
    320321
    321 void PlatformCAAnimation::setAdditive(bool value)
     322void PlatformCAAnimationWin::setAdditive(bool value)
    322323{
    323324    CACFAnimationSetAdditive(m_animation.get(), value);
    324325}
    325326
    326 PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() const
     327PlatformCAAnimation::ValueFunctionType PlatformCAAnimationWin::valueFunction() const
    327328{
    328329    CACFValueFunctionRef func = CACFAnimationGetValueFunction(m_animation.get());
     
    330331}
    331332
    332 void PlatformCAAnimation::setValueFunction(ValueFunctionType value)
     333void PlatformCAAnimationWin::setValueFunction(ValueFunctionType value)
    333334{
    334335    CFStringRef valueString = toCACFValueFunctionType(value);
     
    336337}
    337338
    338 void PlatformCAAnimation::setFromValue(float value)
     339void PlatformCAAnimationWin::setFromValue(float value)
    339340{
    340341    if (animationType() != Basic)
     
    345346}
    346347
    347 void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& value)
     348void PlatformCAAnimationWin::setFromValue(const WebCore::TransformationMatrix& value)
    348349{
    349350    if (animationType() != Basic)
     
    354355}
    355356
    356 void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
     357void PlatformCAAnimationWin::setFromValue(const FloatPoint3D& value)
    357358{
    358359    if (animationType() != Basic)
     
    364365}
    365366
    366 void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
     367void PlatformCAAnimationWin::setFromValue(const WebCore::Color& value)
    367368{
    368369    if (animationType() != Basic)
     
    375376
    376377#if ENABLE(CSS_FILTERS)
    377 void PlatformCAAnimation::setFromValue(const FilterOperation*, int)
     378void PlatformCAAnimationWin::setFromValue(const FilterOperation*, int)
    378379{
    379380    // FIXME: Hardware filter animation not implemented on Windows
     
    381382#endif
    382383
    383 void PlatformCAAnimation::copyFromValueFrom(const PlatformCAAnimation* value)
     384void PlatformCAAnimationWin::copyFromValueFrom(const PlatformCAAnimation* value)
    384385{
    385386    if (animationType() != Basic || value->animationType() != Basic)
    386387        return;
    387388   
    388     CACFAnimationSetFromValue(m_animation.get(), CACFAnimationGetFromValue(value->platformAnimation()));
    389 }
    390 
    391 void PlatformCAAnimation::setToValue(float value)
     389    CACFAnimationSetFromValue(m_animation.get(), CACFAnimationGetFromValue(toPlatformCAAnimationWin(value)->platformAnimation()));
     390}
     391
     392void PlatformCAAnimationWin::setToValue(float value)
    392393{
    393394    if (animationType() != Basic)
     
    398399}
    399400
    400 void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
     401void PlatformCAAnimationWin::setToValue(const WebCore::TransformationMatrix& value)
    401402{
    402403    if (animationType() != Basic)
     
    407408}
    408409
    409 void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
     410void PlatformCAAnimationWin::setToValue(const FloatPoint3D& value)
    410411{
    411412    if (animationType() != Basic)
     
    417418}
    418419
    419 void PlatformCAAnimation::setToValue(const WebCore::Color& value)
     420void PlatformCAAnimationWin::setToValue(const WebCore::Color& value)
    420421{
    421422    if (animationType() != Basic)
     
    428429
    429430#if ENABLE(CSS_FILTERS)
    430 void PlatformCAAnimation::setToValue(const FilterOperation*, int)
     431void PlatformCAAnimationWin::setToValue(const FilterOperation*, int)
    431432{
    432433    // FIXME: Hardware filter animation not implemented on Windows
     
    434435#endif
    435436
    436 void PlatformCAAnimation::copyToValueFrom(const PlatformCAAnimation* value)
     437void PlatformCAAnimationWin::copyToValueFrom(const PlatformCAAnimation* value)
    437438{
    438439    if (animationType() != Basic || value->animationType() != Basic)
    439440        return;
    440441       
    441     CACFAnimationSetToValue(m_animation.get(), CACFAnimationGetToValue(value->platformAnimation()));
    442 }
    443 
     442    CACFAnimationSetToValue(m_animation.get(), CACFAnimationGetToValue(toPlatformCAAnimationWin(value)->platformAnimation()));
     443}
    444444
    445445// Keyframe-animation properties.
    446 void PlatformCAAnimation::setValues(const Vector<float>& value)
     446void PlatformCAAnimationWin::setValues(const Vector<float>& value)
    447447{
    448448    if (animationType() != Keyframe)
     
    458458}
    459459
    460 void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>& value)
     460void PlatformCAAnimationWin::setValues(const Vector<WebCore::TransformationMatrix>& value)
    461461{
    462462    if (animationType() != Keyframe)
     
    472472}
    473473
    474 void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
     474void PlatformCAAnimationWin::setValues(const Vector<FloatPoint3D>& value)
    475475{
    476476    if (animationType() != Keyframe)
     
    487487}
    488488
    489 void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
     489void PlatformCAAnimationWin::setValues(const Vector<WebCore::Color>& value)
    490490{
    491491    if (animationType() != Keyframe)
     
    503503
    504504#if ENABLE(CSS_FILTERS)
    505 void PlatformCAAnimation::setValues(const Vector<RefPtr<FilterOperation> >&, int)
     505void PlatformCAAnimationWin::setValues(const Vector<RefPtr<FilterOperation> >&, int)
    506506{
    507507    // FIXME: Hardware filter animation not implemented on Windows
     
    509509#endif
    510510
    511 void PlatformCAAnimation::copyValuesFrom(const PlatformCAAnimation* value)
     511void PlatformCAAnimationWin::copyValuesFrom(const PlatformCAAnimation* value)
    512512{
    513513    if (animationType() != Keyframe || value->animationType() != Keyframe)
    514514        return;
    515515   
    516     CACFAnimationSetValues(m_animation.get(), CACFAnimationGetValues(value->platformAnimation()));
    517 }
    518 
    519 void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
     516    CACFAnimationSetValues(m_animation.get(), CACFAnimationGetValues(toPlatformCAAnimationWin(value)->platformAnimation()));
     517}
     518
     519void PlatformCAAnimationWin::setKeyTimes(const Vector<float>& value)
    520520{
    521521    if (animationType() != Keyframe)
     
    531531}
    532532
    533 void PlatformCAAnimation::copyKeyTimesFrom(const PlatformCAAnimation* value)
    534 {
    535     if (animationType() != Keyframe)
    536         return;
    537 
    538     CACFAnimationSetKeyTimes(m_animation.get(), CACFAnimationGetKeyTimes(value->platformAnimation()));
    539 }
    540 
    541 void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
     533void PlatformCAAnimationWin::copyKeyTimesFrom(const PlatformCAAnimation* value)
     534{
     535    if (animationType() != Keyframe)
     536        return;
     537
     538    CACFAnimationSetKeyTimes(m_animation.get(), CACFAnimationGetKeyTimes(toPlatformCAAnimationWin(value)->platformAnimation()));
     539}
     540
     541void PlatformCAAnimationWin::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
    542542{
    543543    UNUSED_PARAM(reverse);
     
    554554}
    555555
    556 void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
    557 {
    558     CACFAnimationSetTimingFunctions(m_animation.get(), CACFAnimationGetTimingFunctions(value->platformAnimation()));
    559 }
     556void PlatformCAAnimationWin::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
     557{
     558    CACFAnimationSetTimingFunctions(m_animation.get(), CACFAnimationGetTimingFunctions(toPlatformCAAnimationWin(value)->platformAnimation()));
     559}
     560
     561#endif // PLATFORM(WIN)
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp

    r166310 r166542  
    3131#include "Font.h"
    3232#include "GraphicsContext.h"
     33#include "PlatformCAAnimationWin.h"
    3334#include "PlatformCALayerWinInternal.h"
    3435#include <QuartzCore/CoreAnimationCF.h>
     
    285286    m_animations.add(key, animation);
    286287
    287     CACFLayerAddAnimation(m_layer.get(), key.createCFString().get(), animation->platformAnimation());
     288    CACFLayerAddAnimation(m_layer.get(), key.createCFString().get(), toPlatformCAAnimationWin(animation)->platformAnimation());
    288289    setNeedsCommit();
    289290
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp

    r165676 r166542  
    3030#include "Font.h"
    3131#include "FontCache.h"
     32#include "GraphicsContext.h"
    3233#include "PlatformCALayer.h"
    3334#include "TextRun.h"
  • trunk/Source/WebKit2/ChangeLog

    r166541 r166542  
     12014-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] Proxy animations to the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=130946
     5
     6        Reviewed by Tim Horton.
     7       
     8        Add encoding/decoding of TimingFunctions. Add encoding support
     9        for HashSet.
     10       
     11        Add PlatformCAAnimationRemote and have PlatformCALayerRemote allow
     12        animations now. PlatformCALayerRemote's properties are defined in the class,
     13        as is the encoding/decoding (much cleaner than having them in the transaction
     14        class I think).
     15       
     16        Add support for the "animationDidStart" callback and sending this back to the
     17        web process. This involves a HashMap of layerID->WKAnimationDelegate stored
     18        on the RemoteLayerTreeHost, and a message send via the DrawingArea. On the
     19        other side, RemoteLayerTreeContext stores a HashMap of layerID->PlatformCALayerRemote*
     20        for layers which have just started animations, which is used to get the
     21        PlatformCALayer* to call animationDidStart() on.
     22       
     23        This requires that the RemoteLayerTreeHost* be passed down into property application,
     24        and that the RemoteLayerTreeHost have a reference to the drawing area.
     25       
     26        To every CALayer in the UI process we -setValue:forKey: to track the PlatformLayerID,
     27        so we can get back to it in order to dispatch "animationDidStart".
     28       
     29        Replace some "using namespace WebKit" with "namespace WebKit { }".
     30
     31        * Platform/IPC/ArgumentCoders.h:
     32        * Shared/WebCoreArgumentCoders.cpp:
     33        (IPC::ArgumentCoder<LinearTimingFunction>::encode):
     34        (IPC::ArgumentCoder<LinearTimingFunction>::decode):
     35        (IPC::ArgumentCoder<CubicBezierTimingFunction>::encode):
     36        (IPC::ArgumentCoder<CubicBezierTimingFunction>::decode):
     37        (IPC::ArgumentCoder<StepsTimingFunction>::encode):
     38        (IPC::ArgumentCoder<StepsTimingFunction>::decode):
     39        * Shared/WebCoreArgumentCoders.h:
     40        * Shared/mac/RemoteLayerBackingStore.mm:
     41        * Shared/mac/RemoteLayerTreePropertyApplier.h:
     42        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
     43        (WebKit::applyPropertiesToLayer):
     44        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
     45        * Shared/mac/RemoteLayerTreeTransaction.h:
     46        * Shared/mac/RemoteLayerTreeTransaction.mm:
     47        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
     48        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
     49        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     50        (WebKit::dumpChangedLayers):
     51        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
     52        (WebKit::RemoteLayerTreeHost::layerID):
     53        (WebKit::RemoteLayerTreeHost::createLayer):
     54        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
     55        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
     56        (WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
     57        (WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
     58        (WebKit::RemoteLayerTreeDrawingAreaProxy::showDebugIndicator):
     59        * UIProcess/mac/RemoteLayerTreeHost.h:
     60        (WebKit::RemoteLayerTreeHost::animationDelegates):
     61        * UIProcess/mac/RemoteLayerTreeHost.mm:
     62        (WebKit::RemoteLayerTreeHost::RemoteLayerTreeHost):
     63        (WebKit::RemoteLayerTreeHost::updateLayerTree):
     64        (WebKit::RemoteLayerTreeHost::layerWillBeRemoved):
     65        (WebKit::RemoteLayerTreeHost::animationDidStart):
     66        (WebKit::RemoteLayerTreeHost::layerID):
     67        (WebKit::RemoteLayerTreeHost::createLayer):
     68        * WebKit2.xcodeproj/project.pbxproj:
     69        * WebProcess/WebPage/DrawingArea.h:
     70        (WebKit::DrawingArea::acceleratedAnimationDidStart):
     71        * WebProcess/WebPage/DrawingArea.messages.in:
     72        * WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
     73        (WebKit::GraphicsLayerCARemote::createPlatformCAAnimation):
     74        * WebProcess/WebPage/mac/GraphicsLayerCARemote.h:
     75        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.h: Added.
     76        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm: Added.
     77        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     78        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
     79        (WebKit::PlatformCALayerRemote::animationStarted):
     80        (WebKit::PlatformCALayerRemote::addAnimationForKey):
     81        (WebKit::PlatformCALayerRemote::removeAnimationForKey):
     82        (WebKit::PlatformCALayerRemote::animationForKey):
     83        (PlatformCALayerRemote::recursiveBuildTransaction): Deleted.
     84        (PlatformCALayerRemote::addAnimationForKey): Deleted.
     85        (PlatformCALayerRemote::removeAnimationForKey): Deleted.
     86        (PlatformCALayerRemote::animationForKey): Deleted.
     87        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
     88        * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
     89        * WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
     90        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
     91        (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
     92        (WebKit::RemoteLayerTreeContext::willStartAnimationOnLayer):
     93        (WebKit::RemoteLayerTreeContext::animationDidStart):
     94        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
     95        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
     96        (WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):
     97        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
     98        (WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
     99
    11002014-03-31  Tim Horton  <timothy_horton@apple.com>
    2101
  • trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.h

    r163509 r166542  
    3232#include <wtf/Forward.h>
    3333#include <wtf/HashMap.h>
     34#include <wtf/HashSet.h>
    3435#include <wtf/Vector.h>
    3536
     
    194195};
    195196
     197template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct ArgumentCoder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
     198    typedef HashSet<KeyArg, HashArg, KeyTraitsArg> HashSetType;
     199
     200    static void encode(ArgumentEncoder& encoder, const HashSetType& hashSet)
     201    {
     202        encoder << static_cast<uint64_t>(hashSet.size());
     203        for (typename HashSetType::const_iterator it = hashSet.begin(), end = hashSet.end(); it != end; ++it)
     204            encoder << *it;
     205    }
     206
     207    static bool decode(ArgumentDecoder& decoder, HashSetType& hashSet)
     208    {
     209        uint64_t hashSetSize;
     210        if (!decoder.decode(hashSetSize))
     211            return false;
     212
     213        HashSetType tempHashSet;
     214        for (uint64_t i = 0; i < hashSetSize; ++i) {
     215            KeyArg key;
     216            if (!decoder.decode(key))
     217                return false;
     218
     219            if (!tempHashSet.add(key).isNewEntry) {
     220                // The hash map already has the specified key, bail.
     221                decoder.markInvalid();
     222                return false;
     223            }
     224        }
     225
     226        hashSet.swap(tempHashSet);
     227        return true;
     228    }
     229};
     230
    196231template<> struct ArgumentCoder<AtomicString> {
    197232    static void encode(ArgumentEncoder&, const AtomicString&);
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r166317 r166542  
    6060#include <WebCore/SessionID.h>
    6161#include <WebCore/TextCheckerClient.h>
     62#include <WebCore/TimingFunction.h>
    6263#include <WebCore/TransformationMatrix.h>
    6364#include <WebCore/URL.h>
     
    9192}
    9293
    93 
    9494void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix)
    9595{
     
    100100{
    101101    return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix);
     102}
     103
     104void ArgumentCoder<LinearTimingFunction>::encode(ArgumentEncoder& encoder, const LinearTimingFunction& timingFunction)
     105{
     106    encoder.encodeEnum(timingFunction.type());
     107}
     108
     109bool ArgumentCoder<LinearTimingFunction>::decode(ArgumentDecoder& decoder, LinearTimingFunction& timingFunction)
     110{
     111    // Type is decoded by the caller. Nothing else to decode.
     112    return true;
     113}
     114
     115void ArgumentCoder<CubicBezierTimingFunction>::encode(ArgumentEncoder& encoder, const CubicBezierTimingFunction& timingFunction)
     116{
     117    encoder.encodeEnum(timingFunction.type());
     118   
     119    encoder << timingFunction.x1();
     120    encoder << timingFunction.y1();
     121    encoder << timingFunction.x2();
     122    encoder << timingFunction.y2();
     123   
     124    encoder.encodeEnum(timingFunction.timingFunctionPreset());
     125}
     126
     127bool ArgumentCoder<CubicBezierTimingFunction>::decode(ArgumentDecoder& decoder, CubicBezierTimingFunction& timingFunction)
     128{
     129    // Type is decoded by the caller.
     130    double x1;
     131    if (!decoder.decode(x1))
     132        return false;
     133
     134    double y1;
     135    if (!decoder.decode(y1))
     136        return false;
     137
     138    double x2;
     139    if (!decoder.decode(x2))
     140        return false;
     141
     142    double y2;
     143    if (!decoder.decode(y2))
     144        return false;
     145
     146    CubicBezierTimingFunction::TimingFunctionPreset preset;
     147    if (!decoder.decodeEnum(preset))
     148        return false;
     149
     150    timingFunction.setValues(x1, y1, x2, y2);
     151    timingFunction.setTimingFunctionPreset(preset);
     152
     153    return true;
     154}
     155
     156void ArgumentCoder<StepsTimingFunction>::encode(ArgumentEncoder& encoder, const StepsTimingFunction& timingFunction)
     157{
     158    encoder.encodeEnum(timingFunction.type());
     159   
     160    encoder << timingFunction.numberOfSteps();
     161    encoder << timingFunction.stepAtStart();
     162}
     163
     164bool ArgumentCoder<StepsTimingFunction>::decode(ArgumentDecoder& decoder, StepsTimingFunction& timingFunction)
     165{
     166    // Type is decoded by the caller.
     167    int numSteps;
     168    if (!decoder.decode(numSteps))
     169        return false;
     170
     171    bool stepAtStart;
     172    if (!decoder.decode(stepAtStart))
     173        return false;
     174
     175    timingFunction.setNumberOfSteps(numSteps);
     176    timingFunction.setStepAtStart(stepAtStart);
     177
     178    return true;
    102179}
    103180
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h

    r164726 r166542  
    3535class Color;
    3636class Credential;
     37class CubicBezierTimingFunction;
    3738class Cursor;
    3839class DatabaseDetails;
     
    4950class IntSize;
    5051class KeyframeValueList;
    51 class URL;
     52class LinearTimingFunction;
    5253class Notification;
    5354class ProtectionSpace;
     
    5758class ResourceResponse;
    5859class SessionID;
     60class StepsTimingFunction;
    5961class StickyPositionViewportConstraints;
    6062class TextCheckingRequestData;
     
    6264class UserStyleSheet;
    6365class UserScript;
     66class URL;
    6467struct CompositionUnderline;
    6568struct Cookie;
     
    113116};
    114117
     118template<> struct ArgumentCoder<WebCore::LinearTimingFunction> {
     119    static void encode(ArgumentEncoder&, const WebCore::LinearTimingFunction&);
     120    static bool decode(ArgumentDecoder&, WebCore::LinearTimingFunction&);
     121};
     122
     123template<> struct ArgumentCoder<WebCore::CubicBezierTimingFunction> {
     124    static void encode(ArgumentEncoder&, const WebCore::CubicBezierTimingFunction&);
     125    static bool decode(ArgumentDecoder&, WebCore::CubicBezierTimingFunction&);
     126};
     127
     128template<> struct ArgumentCoder<WebCore::StepsTimingFunction> {
     129    static void encode(ArgumentEncoder&, const WebCore::StepsTimingFunction&);
     130    static bool decode(ArgumentDecoder&, WebCore::StepsTimingFunction&);
     131};
     132
    115133template<> struct ArgumentCoder<WebCore::CertificateInfo> {
    116134    static void encode(ArgumentEncoder&, const WebCore::CertificateInfo&);
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm

    r166541 r166542  
    5050
    5151using namespace WebCore;
    52 using namespace WebKit;
     52
     53namespace WebKit {
    5354
    5455RemoteLayerBackingStore::RemoteLayerBackingStore()
     
    326327    layer.contents = (id)m_frontBuffer->makeCGImageCopy().get();
    327328}
     329
     330} // namespace WebKit
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h

    r164890 r166542  
    3333namespace WebKit {
    3434
     35class RemoteLayerTreeHost;
     36
    3537class RemoteLayerTreePropertyApplier {
    3638public:
    3739    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerOrView *> RelatedLayerMap;
    38     static void applyProperties(CALayer *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
     40    static void applyProperties(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
    3941#if PLATFORM(IOS)
    40     static void applyProperties(UIView *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
     42    static void applyProperties(UIView *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
    4143#endif
    4244};
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm

    r165863 r166542  
    2727#import "RemoteLayerTreePropertyApplier.h"
    2828
     29#import "PlatformCAAnimationRemote.h"
    2930#import "PlatformCALayerRemote.h"
     31#import "RemoteLayerTreeHost.h"
    3032#import <QuartzCore/CALayer.h>
    3133#import <WebCore/BlockExceptions.h>
     
    112114}
    113115
    114 static void applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransaction::LayerProperties& properties)
     116static void applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties)
    115117{
    116118    if (properties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
     
    129131    if (properties.changedProperties & RemoteLayerTreeTransaction::SizeChanged)
    130132        layer.bounds = FloatRect(FloatPoint(), properties.size);
    131 
     133   
    132134    if (properties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
    133135        layer.backgroundColor = cgColorFromColor(properties.backgroundColor).get();
     
    193195        PlatformCAFilters::setFiltersOnLayer(layer, properties.filters ? *properties.filters : FilterOperations());
    194196
     197    if (properties.changedProperties & RemoteLayerTreeTransaction::AnimationsChanged)
     198        PlatformCAAnimationRemote::updateLayerAnimations(layer, layerTreeHost, properties.addedAnimations, properties.keyPathsOfAnimationsToRemove);
     199
    195200    if (properties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
    196201        layer.edgeAntialiasingMask = properties.edgeAntialiasingMask;
     
    200205}
    201206
    202 void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
     207void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
    203208{
    204209    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    205     applyPropertiesToLayer(layer, properties);
     210    applyPropertiesToLayer(layer, layerTreeHost, properties);
    206211
    207212    if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
     
    237242
    238243#if PLATFORM(IOS)
    239 void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
     244void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
    240245{
    241246    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    242     applyPropertiesToLayer(view.layer, properties);
     247    applyPropertiesToLayer(view.layer, layerTreeHost, properties);
    243248
    244249    if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r166308 r166542  
    2727#define RemoteLayerTreeTransaction_h
    2828
     29#include "PlatformCAAnimationRemote.h"
    2930#include "RemoteLayerBackingStore.h"
    3031#include <WebCore/Color.h>
     
    3536#include <WebCore/TransformationMatrix.h>
    3637#include <wtf/HashMap.h>
     38#include <wtf/HashSet.h>
    3739#include <wtf/text/WTFString.h>
    3840
     
    7577        BackingStoreChanged = 1 << 24,
    7678        FiltersChanged = 1 << 25,
    77         EdgeAntialiasingMaskChanged = 1 << 26,
    78         CustomAppearanceChanged = 1 << 27,
    79         CustomBehaviorChanged = 1 << 28
     79        AnimationsChanged = 1 << 26,
     80        EdgeAntialiasingMaskChanged = 1 << 27,
     81        CustomAppearanceChanged = 1 << 28,
     82        CustomBehaviorChanged = 1 << 29
    8083    };
    8184    typedef unsigned LayerChange;
     
    113116        std::unique_ptr<WebCore::TransformationMatrix> sublayerTransform;
    114117        Vector<WebCore::GraphicsLayer::PlatformLayerID> children;
     118
     119        HashMap<String, PlatformCAAnimationRemote::Properties> addedAnimations;
     120        HashSet<String> keyPathsOfAnimationsToRemove;
     121
    115122        WebCore::FloatPoint3D position;
    116123        WebCore::FloatPoint3D anchorPoint;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r166308 r166542  
    104104    , name(other.name)
    105105    , children(other.children)
     106    , addedAnimations(other.addedAnimations)
     107    , keyPathsOfAnimationsToRemove(other.keyPathsOfAnimationsToRemove)
    106108    , position(other.position)
    107109    , anchorPoint(other.anchorPoint)
     
    150152        encoder << children;
    151153
     154    if (changedProperties & AnimationsChanged) {
     155        encoder << addedAnimations;
     156        encoder << keyPathsOfAnimationsToRemove;
     157    }
     158
    152159    if (changedProperties & PositionChanged)
    153160        encoder << position;
     
    250257                return false;
    251258        }
     259    }
     260
     261    if (result.changedProperties & AnimationsChanged) {
     262        if (!decoder.decode(result.addedAnimations))
     263            return false;
     264
     265        if (!decoder.decode(result.keyPathsOfAnimationsToRemove))
     266            return false;
    252267    }
    253268
     
    736751        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
    737752            dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
     753
     754// FIXME: dump animations
    738755
    739756        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
  • trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm

    r166333 r166542  
    3838using namespace WebCore;
    3939
    40 @interface UIView(WKViewInternals)
    41 - (void)_createLayerWithFrame:(CGRect)frame;
    42 @end
    43 
    4440@interface CALayer(WKLayerInternal)
    4541- (void)setContextId:(uint32_t)contextID;
     
    7773namespace WebKit {
    7874
     75static NSString* const WKLayerIDPropertyKey = @"WKLayerID";
     76
     77WebCore::GraphicsLayer::PlatformLayerID RemoteLayerTreeHost::layerID(LayerOrView* layer)
     78{
     79    return [[layer valueForKey:WKLayerIDPropertyKey] unsignedLongLongValue];
     80}
     81
    7982LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
    8083{
     
    111114    // FIXME: Do through the view.
    112115    [[layerOrView layer] web_disableAllActions];
     116    [[layerOrView layer] setValue:[NSNumber numberWithUnsignedLongLong:properties.layerID] forKey:WKLayerIDPropertyKey];
    113117
    114118    return layerOrView.get();
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h

    r166540 r166542  
    4444
    4545    const RemoteLayerTreeHost& remoteLayerTreeHost() const { return m_remoteLayerTreeHost; }
     46
     47    void acceleratedAnimationDidStart(uint64_t layerID, double startTime);
    4648
    4749    void coreAnimationDidCommitLayers();
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm

    r166540 r166542  
    4444RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy(WebPageProxy* webPageProxy)
    4545    : DrawingAreaProxy(DrawingAreaTypeRemoteLayerTree, webPageProxy)
    46     , m_remoteLayerTreeHost()
     46    , m_remoteLayerTreeHost(*this)
    4747    , m_isWaitingForDidUpdateGeometry(false)
    4848{
     
    140140
    141141    scheduleCoreAnimationLayerCommitObserver();
     142}
     143
     144void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t layerID, double startTime)
     145{
     146    m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, startTime), m_webPageProxy->pageID());
    142147}
    143148
     
    247252    }
    248253   
    249     m_debugIndicatorLayerTreeHost = std::make_unique<RemoteLayerTreeHost>();
     254    m_debugIndicatorLayerTreeHost = std::make_unique<RemoteLayerTreeHost>(*this);
    250255    m_debugIndicatorLayerTreeHost->setIsDebugLayerTreeHost(true);
    251256
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h

    r166333 r166542  
    3333#include <wtf/RetainPtr.h>
    3434
     35OBJC_CLASS WKAnimationDelegate;
     36
    3537namespace WebKit {
    3638
     39class RemoteLayerTreeDrawingAreaProxy;
    3740class WebPageProxy;
    3841
    3942class RemoteLayerTreeHost {
    4043public:
    41     explicit RemoteLayerTreeHost();
     44    explicit RemoteLayerTreeHost(RemoteLayerTreeDrawingAreaProxy&);
    4245    virtual ~RemoteLayerTreeHost();
    4346
    4447    LayerOrView *getLayer(WebCore::GraphicsLayer::PlatformLayerID) const;
    4548    LayerOrView *rootLayer() const { return m_rootLayer; }
     49
     50    static WebCore::GraphicsLayer::PlatformLayerID layerID(LayerOrView*);
    4651
    4752    // Returns true if the root layer changed.
     
    5156    bool isDebugLayerTreeHost() const { return m_isDebugLayerTreeHost; }
    5257
     58    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> LayerAnimationDelegateMap;
     59    LayerAnimationDelegateMap& animationDelegates() { return m_animationDelegates; }
     60
     61    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, double startTime);
     62
    5363private:
    5464    LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
    5565
     66    void layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID);
     67
     68    RemoteLayerTreeDrawingAreaProxy& m_drawingArea;
    5669    LayerOrView *m_rootLayer;
    5770    HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<LayerOrView>> m_layers;
     71    HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> m_animationDelegates;
    5872    bool m_isDebugLayerTreeHost;
    5973};
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

    r166333 r166542  
    2727#import "RemoteLayerTreeHost.h"
    2828
     29#import "RemoteLayerTreeDrawingAreaProxy.h"
    2930#import "RemoteLayerTreePropertyApplier.h"
    3031#import "RemoteLayerTreeTransaction.h"
     
    4243namespace WebKit {
    4344
    44 RemoteLayerTreeHost::RemoteLayerTreeHost()
    45     : m_rootLayer(nullptr)
     45RemoteLayerTreeHost::RemoteLayerTreeHost(RemoteLayerTreeDrawingAreaProxy& drawingArea)
     46    : m_drawingArea(drawingArea)
     47    , m_rootLayer(nullptr)
    4648    , m_isDebugLayerTreeHost(false)
    4749{
     
    8890                propertiesCopy.borderWidth *= 1 / indicatorScaleFactor;
    8991           
    90             RemoteLayerTreePropertyApplier::applyProperties(layer, propertiesCopy, relatedLayers);
     92            RemoteLayerTreePropertyApplier::applyProperties(layer, this, propertiesCopy, relatedLayers);
    9193        } else
    92             RemoteLayerTreePropertyApplier::applyProperties(layer, properties, relatedLayers);
     94            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
    9395    }
    9496
    9597    for (auto& destroyedLayer : transaction.destroyedLayers())
    96         m_layers.remove(destroyedLayer);
     98        layerWillBeRemoved(destroyedLayer);
    9799
    98100    return rootLayerChanged;
     
    107109}
    108110
     111void RemoteLayerTreeHost::layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID layerID)
     112{
     113    m_animationDelegates.remove(layerID);
     114    m_layers.remove(layerID);
     115}
     116
     117void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, double startTime)
     118{
     119    m_drawingArea.acceleratedAnimationDidStart(layerID, startTime);
     120}
     121
    109122#if !PLATFORM(IOS)
     123static NSString* const WKLayerIDPropertyKey = @"WKLayerID";
     124
     125WebCore::GraphicsLayer::PlatformLayerID RemoteLayerTreeHost::layerID(LayerOrView* layer)
     126{
     127    return [[layer valueForKey:WKLayerIDPropertyKey] unsignedLongLongValue];
     128}
     129
    110130LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties*)
    111131{
     
    138158
    139159    [layer web_disableAllActions];
     160    [layer setValue:[NSNumber numberWithUnsignedLongLong:properties.layerID] forKey:WKLayerIDPropertyKey];
    140161
    141162    return layer.get();
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r166385 r166542  
    6464                0F5947A7187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5947A5187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp */; };
    6565                0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5947A6187B517600437857 /* RemoteScrollingCoordinatorMessages.h */; };
     66                0F5E200318E77051003EC3E5 /* PlatformCAAnimationRemote.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */; };
     67                0F5E200418E77051003EC3E5 /* PlatformCAAnimationRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */; };
    6668                0F931C1C18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */; };
    6769                0F931C1D18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */; };
     
    18001802                0F5947A5187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteScrollingCoordinatorMessageReceiver.cpp; sourceTree = "<group>"; };
    18011803                0F5947A6187B517600437857 /* RemoteScrollingCoordinatorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteScrollingCoordinatorMessages.h; sourceTree = "<group>"; };
     1804                0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCAAnimationRemote.mm; sourceTree = "<group>"; };
     1805                0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCAAnimationRemote.h; sourceTree = "<group>"; };
    18021806                0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeOverflowScrollingNodeIOS.h; path = Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h; sourceTree = "<group>"; };
    18031807                0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollingTreeOverflowScrollingNodeIOS.mm; path = Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm; sourceTree = "<group>"; };
     
    60216025                                2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp */,
    60226026                                2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */,
     6027                                0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */,
     6028                                0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */,
    60236029                                2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */,
    60246030                                2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */,
     
    69226928                                BCB9E2431120DACA00A137E0 /* WebContext.h in Headers */,
    69236929                                31A505FA1680025500A930EB /* WebContextClient.h in Headers */,
     6930                                0F5E200418E77051003EC3E5 /* PlatformCAAnimationRemote.h in Headers */,
    69246931                                512A9761180E031D0039A149 /* DatabaseProcessMessages.h in Headers */,
    69256932                                BC09B8F9147460F7005F5625 /* WebContextConnectionClient.h in Headers */,
     
    86638670                                BCD597D1112B56AC00EC8C23 /* WKPreferences.cpp in Sources */,
    86648671                                BCBAACEC145225E30053F82F /* WKProcessGroup.mm in Sources */,
     8672                                0F5E200318E77051003EC3E5 /* PlatformCAAnimationRemote.mm in Sources */,
    86658673                                512F58FB12A88A5400629530 /* WKProtectionSpace.cpp in Sources */,
    86668674                                37948408150C4B9700E52CE9 /* WKRenderLayer.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h

    r165748 r166542  
    9292    virtual void setExposedRect(const WebCore::FloatRect&) = 0;
    9393    virtual WebCore::FloatRect exposedRect() const = 0;
     94    virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, double /*startTime*/) { }
    9495#endif
    9596#if PLATFORM(IOS)
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in

    r165235 r166542  
    3434    AdjustTransientZoom(double scale, WebCore::FloatPoint origin)
    3535    CommitTransientZoom(double scale, WebCore::FloatPoint origin)
     36   
     37    AcceleratedAnimationDidStart(uint64_t layerID, double startTime)
    3638#endif
    3739}
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp

    r165676 r166542  
    2626#include "config.h"
    2727#include "GraphicsLayerCARemote.h"
     28#include "PlatformCAAnimationRemote.h"
    2829#include "PlatformCALayerRemote.h"
    2930
     
    5354}
    5455
     56PassRefPtr<PlatformCAAnimation> GraphicsLayerCARemote::createPlatformCAAnimation(PlatformCAAnimation::AnimationType type, const String& keyPath)
     57{
     58    return PlatformCAAnimationRemote::create(type, keyPath);
    5559}
     60
     61bool GraphicsLayerCARemote::addAnimation(const KeyframeValueList& valueList, const FloatSize&, const Animation* anim, const String&, double)
     62{
     63    if (!animationCanBeAccelerated(valueList, anim))
     64        return false;
     65   
     66#if ENABLE(CSS_FILTERS)
     67    if (valueList.property() == AnimatedPropertyWebkitFilter)
     68        return false;
     69#endif
     70   
     71    return true;
     72}
     73
     74} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.h

    r165676 r166542  
    5353    virtual PassRefPtr<WebCore::PlatformCALayer> createPlatformCALayer(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner) override;
    5454    virtual PassRefPtr<WebCore::PlatformCALayer> createPlatformCALayer(PlatformLayer*, WebCore::PlatformCALayerClient* owner) override;
    55 
    56     // No accelerated animations for now.
    57     virtual bool addAnimation(const WebCore::KeyframeValueList&, const WebCore::FloatSize&, const WebCore::Animation*, const String&, double) override { return false; }
     55    virtual PassRefPtr<WebCore::PlatformCAAnimation> createPlatformCAAnimation(WebCore::PlatformCAAnimation::AnimationType, const String& keyPath) override;
    5856
    5957    // PlatformCALayerRemote can't currently proxy directly composited image contents, so opt out of this optimization.
    6058    virtual bool shouldDirectlyCompositeImage(WebCore::Image*) const override { return false; }
    61 
     59   
     60    virtual bool addAnimation(const WebCore::KeyframeValueList&, const WebCore::FloatSize&, const WebCore::Animation*, const String&, double);
     61   
    6262    RemoteLayerTreeContext* m_context;
    6363};
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r166308 r166542  
    4343
    4444using namespace WebCore;
    45 using namespace WebKit;
     45
     46namespace WebKit {
    4647
    4748PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     
    125126
    126127        if (m_layerType == LayerTypeCustom) {
    127             RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
     128            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
    128129            m_properties.changedProperties = RemoteLayerTreeTransaction::NoChange;
    129130            return;
     
    146147void PlatformCALayerRemote::animationStarted(CFTimeInterval beginTime)
    147148{
     149    if (m_owner)
     150        m_owner->platformCALayerAnimationStarted(beginTime);
    148151}
    149152
     
    268271void PlatformCALayerRemote::addAnimationForKey(const String& key, PlatformCAAnimation* animation)
    269272{
    270     ASSERT_NOT_REACHED();
     273    m_properties.addedAnimations.set(key, toPlatformCAAnimationRemote(animation)->properties());
     274    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
     275   
     276    m_context->willStartAnimationOnLayer(this);
    271277}
    272278
    273279void PlatformCALayerRemote::removeAnimationForKey(const String& key)
    274280{
    275     ASSERT_NOT_REACHED();
     281    // FIXME: remove from m_properties.addedAnimations ?
     282    m_properties.keyPathsOfAnimationsToRemove.add(key);
     283    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
    276284}
    277285
    278286PassRefPtr<PlatformCAAnimation> PlatformCALayerRemote::animationForKey(const String& key)
    279287{
    280     ASSERT_NOT_REACHED();
    281 
     288    // FIXME: implement.
    282289    return nullptr;
    283290}
     
    590597    return 0;
    591598}
     599
     600} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm

    r165676 r166542  
    3838
    3939using namespace WebCore;
    40 using namespace WebKit;
     40
     41namespace WebKit {
    4142
    4243static NSString * const platformCALayerPointer = @"WKPlatformCALayer";
     
    8485        PlatformCALayerRemote::setNeedsDisplay(rect);
    8586}
     87
     88} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp

    r165676 r166542  
    3434
    3535using namespace WebCore;
    36 using namespace WebKit;
     36
     37namespace WebKit {
    3738
    3839PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     
    103104    m_tileController->setTileDebugBorderColor(color);
    104105}
     106
     107} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h

    r162139 r166542  
    5656    void buildTransaction(RemoteLayerTreeTransaction&, WebCore::PlatformCALayer& rootLayer);
    5757
     58    // From the UI process
     59    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, double startTime);
     60
     61    void willStartAnimationOnLayer(PlatformCALayerRemote*);
     62
    5863private:
    5964    // WebCore::GraphicsLayerFactory
     
    6772    Vector<RemoteLayerTreeTransaction::LayerCreationProperties> m_createdLayers;
    6873    Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayers;
     74   
     75    HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_layersAwaitingAnimationStart;
    6976};
    7077
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm

    r164910 r166542  
    6666    ASSERT(!m_destroyedLayers.contains(layer->layerID()));
    6767    m_destroyedLayers.append(layer->layerID());
     68   
     69    m_layersAwaitingAnimationStart.remove(layer->layerID());
    6870}
    6971
     
    103105}
    104106
     107void RemoteLayerTreeContext::willStartAnimationOnLayer(PlatformCALayerRemote* layer)
     108{
     109    m_layersAwaitingAnimationStart.add(layer->layerID(), layer);
     110}
     111
     112void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, double startTime)
     113{
     114    auto it = m_layersAwaitingAnimationStart.find(layerID);
     115    if (it != m_layersAwaitingAnimationStart.end())
     116        it->value->animationStarted(startTime);
     117}
     118
    105119} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h

    r166540 r166542  
    7676    virtual WebCore::FloatRect exposedRect() const override { return m_scrolledExposedRect; }
    7777
     78    virtual void acceleratedAnimationDidStart(uint64_t layerID, double startTime) override;
     79
    7880#if PLATFORM(IOS)
    7981    virtual void setExposedContentRect(const WebCore::FloatRect&) override;
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm

    r166540 r166542  
    243243}
    244244
     245void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID, double startTime)
     246{
     247    m_remoteLayerTreeContext->animationDidStart(layerID, startTime);
     248}
     249
    245250void RemoteLayerTreeDrawingArea::setExposedRect(const FloatRect& exposedRect)
    246251{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

    r166516 r166542  
    4545#import <WebCore/MainFrame.h>
    4646#import <WebCore/Page.h>
     47#import <WebCore/PlatformCAAnimationMac.h>
    4748#import <WebCore/RenderLayerBacking.h>
    4849#import <WebCore/RenderLayerCompositor.h>
     
    755756
    756757    RetainPtr<CABasicAnimation> renderViewAnimationCA = transientZoomSnapAnimationForKeyPath("transform");
    757     RefPtr<PlatformCAAnimation> renderViewAnimation = PlatformCAAnimation::create(renderViewAnimationCA.get());
     758    RefPtr<PlatformCAAnimation> renderViewAnimation = PlatformCAAnimationMac::create(renderViewAnimationCA.get());
    758759    renderViewAnimation->setToValue(transform);
    759760
Note: See TracChangeset for help on using the changeset viewer.