Changeset 113628 in webkit


Ignore:
Timestamp:
Apr 9, 2012 2:59:05 PM (12 years ago)
Author:
noam.rosenthal@nokia.com
Message:

[Qt][WK2] Accelerated and non-accelerated animations need to be synchronized
https://bugs.webkit.org/show_bug.cgi?id=75780

Reviewed by Kenneth Rohde Christiansen.

Remove the ui-side animation code, and return false from addAnimation so that web-side
animations kick in.

  • Shared/WebLayerTreeInfo.cpp:

(WebKit):

  • Shared/WebLayerTreeInfo.h:

(WebLayerInfo):

  • UIProcess/WebLayerTreeRenderer.cpp:

(WebKit::WebLayerTreeRenderer::paintToCurrentGLContext):
(WebKit::WebLayerTreeRenderer::setLayerState):

  • WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:

(WebCore::WebGraphicsLayer::didChangeGeometry):
(WebCore::WebGraphicsLayer::syncLayerState):
(WebCore::WebGraphicsLayer::computeTransformedVisibleRect):

  • WebProcess/WebCoreSupport/WebGraphicsLayer.h:

(WebGraphicsLayer):

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r113615 r113628  
     12012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        [Qt][WK2] Accelerated and non-accelerated animations need to be synchronized
     4        https://bugs.webkit.org/show_bug.cgi?id=75780
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Remove the ui-side animation code, and return false from addAnimation so that web-side
     9        animations kick in.
     10
     11        * Shared/WebLayerTreeInfo.cpp:
     12        (WebKit):
     13        * Shared/WebLayerTreeInfo.h:
     14        (WebLayerInfo):
     15        * UIProcess/WebLayerTreeRenderer.cpp:
     16        (WebKit::WebLayerTreeRenderer::paintToCurrentGLContext):
     17        (WebKit::WebLayerTreeRenderer::setLayerState):
     18        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
     19        (WebCore::WebGraphicsLayer::didChangeGeometry):
     20        (WebCore::WebGraphicsLayer::syncLayerState):
     21        (WebCore::WebGraphicsLayer::computeTransformedVisibleRect):
     22        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
     23        (WebGraphicsLayer):
     24
    1252012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
    226
  • trunk/Source/WebKit2/Shared/WebLayerTreeInfo.cpp

    r109302 r113628  
    3535    // We have to divide it to several lines, because CoreIPC::In/Out takes a maximum of 10 arguments.
    3636    encoder->encode(CoreIPC::In(id, name, parent, children, flags, replica, mask, imageBackingStoreID));
    37     encoder->encode(CoreIPC::In(pos, size, transform, opacity, anchorPoint, childrenTransform, contentsRect, animations));
     37    encoder->encode(CoreIPC::In(pos, size, transform, opacity, anchorPoint, childrenTransform, contentsRect));
    3838}
    3939
     
    4343    if (!decoder->decode(CoreIPC::Out(info.id, info.name, info.parent, info.children, info.flags, info.replica, info.mask, info.imageBackingStoreID)))
    4444        return false;
    45     if (!decoder->decode(CoreIPC::Out(info.pos, info.size, info.transform, info.opacity, info.anchorPoint, info.childrenTransform, info.contentsRect, info.animations)))
     45    if (!decoder->decode(CoreIPC::Out(info.pos, info.size, info.transform, info.opacity, info.anchorPoint, info.childrenTransform, info.contentsRect)))
    4646        return false;
    4747
     
    6868    return decoder->decode(CoreIPC::Out(info.layerID, info.rect, info.bitmapHandle));
    6969}
    70 
    71 void WebLayerAnimation::encode(CoreIPC::ArgumentEncoder* encoder) const
    72 {
    73     encoder->encodeEnum(operation);
    74     encoder->encode(keyframeList);
    75     encoder->encode(CoreIPC::In(name, startTime, boxSize));
    76 
    77     if (operation == WebLayerAnimation::AddAnimation)
    78         encoder->encode(animation);
    79 }
    80 
    81 bool WebLayerAnimation::decode(CoreIPC::ArgumentDecoder* decoder, WebLayerAnimation& info)
    82 {
    83     if (!decoder->decodeEnum(info.operation))
    84         return false;
    85     if (!decoder->decode(info.keyframeList))
    86         return false;
    87     if (!decoder->decode(CoreIPC::Out(info.name, info.startTime, info.boxSize)))
    88         return false;
    89 
    90     if (info.operation == WebLayerAnimation::AddAnimation)
    91         if (!decoder->decode(info.animation))
    92             return false;
    93 
    94     return true;
    95 }
    96 
    9770}
    9871#endif
  • trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h

    r113615 r113628  
    4949};
    5050
    51 struct WebLayerAnimation {
    52     WebLayerAnimation()
    53         : operation(InvalidAnimation)
    54         , keyframeList(WebCore::AnimatedPropertyInvalid)
    55         , startTime(0) { }
    56     WebLayerAnimation(const WebCore::KeyframeValueList& valueList)
    57         : operation(InvalidAnimation)
    58         , keyframeList(valueList)
    59         , startTime(0) { }
    60 
    61     String name;
    62     enum Operation {
    63         AddAnimation,
    64         RemoveAnimation,
    65         PauseAnimation,
    66         InvalidAnimation
    67     } operation;
    68     WebCore::IntSize boxSize;
    69     RefPtr<WebCore::Animation> animation;
    70     WebCore::KeyframeValueList keyframeList;
    71     double startTime;
    72 
    73     void encode(CoreIPC::ArgumentEncoder*) const;
    74     static bool decode(CoreIPC::ArgumentDecoder*, WebLayerAnimation&);
    75 };
    76 
    7751struct WebLayerInfo {
    7852    WebLayerInfo()
     
    11286    };
    11387    Vector<WebLayerID> children;
    114     Vector<WebLayerAnimation> animations;
    11588    RefPtr<ShareableBitmap> imageBackingStore;
    11689
  • trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp

    r113361 r113628  
    122122    m_textureMapper->endClip();
    123123    m_textureMapper->endPainting();
    124 
    125     syncAnimations();
    126 }
    127 
    128 void WebLayerTreeRenderer::syncAnimations()
    129 {
    130     TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
    131     ASSERT(layer);
    132 
    133     layer->syncAnimationsRecursively();
    134     if (layer->descendantsOrSelfHaveRunningAnimations())
    135         callOnMainThread(bind(&WebLayerTreeRenderer::updateViewport, this));
    136124}
    137125
     
    209197    layer->setChildren(children);
    210198
    211     for (size_t i = 0; i < layerInfo.animations.size(); ++i) {
    212         const WebKit::WebLayerAnimation anim = layerInfo.animations[i];
    213 
    214         switch (anim.operation) {
    215         case WebKit::WebLayerAnimation::AddAnimation: {
    216             const IntSize boxSize = anim.boxSize;
    217             layer->addAnimation(anim.keyframeList, boxSize, anim.animation.get(), anim.name, anim.startTime);
    218             break;
    219         }
    220         case WebKit::WebLayerAnimation::RemoveAnimation:
    221             layer->removeAnimation(anim.name);
    222             break;
    223         case WebKit::WebLayerAnimation::PauseAnimation:
    224             double offset = WTF::currentTime() - anim.startTime;
    225             layer->pauseAnimation(anim.name, offset);
    226             break;
    227         }
    228     }
    229 
    230199    if (layerInfo.isRootLayer && m_rootLayerID != id)
    231200        setRootLayerID(id);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp

    r113615 r113628  
    2323#include "WebGraphicsLayer.h"
    2424
    25 #include "Animation.h"
    2625#include "BackingStore.h"
    2726#include "FloatQuad.h"
     
    9190    , m_maskTarget(0)
    9291    , m_modified(true)
    93     , m_hasPendingAnimations(false)
    9492    , m_inUpdateMode(false)
    9593    , m_shouldUpdateVisibleRect(true)
     
    293291
    294292    GraphicsLayer::setContentsRect(r);
    295     notifyChange();
    296 }
    297 
    298 void WebGraphicsLayer::notifyAnimationStarted(double time)
    299 {
    300     if (client())
    301         client()->notifyAnimationStarted(this, time);
    302 }
    303 
    304 bool WebGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset)
    305 {
    306     if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity))
    307         return false;
    308 
    309     WebLayerAnimation webAnimation(valueList);
    310     webAnimation.name = keyframesName;
    311     webAnimation.operation = WebLayerAnimation::AddAnimation;
    312     webAnimation.boxSize = boxSize;
    313     webAnimation.animation = Animation::create(anim);
    314     webAnimation.startTime = timeOffset;
    315     m_layerInfo.animations.append(webAnimation);
    316     if (valueList.property() == AnimatedPropertyWebkitTransform)
    317         m_transformAnimations.add(keyframesName);
    318 
    319     m_hasPendingAnimations = true;
    320     didChangeGeometry();
    321 
    322     return true;
    323 }
    324 
    325 void WebGraphicsLayer::pauseAnimation(const String& animationName, double timeOffset)
    326 {
    327     WebLayerAnimation webAnimation;
    328     webAnimation.name = animationName;
    329     webAnimation.operation = WebLayerAnimation::PauseAnimation;
    330     webAnimation.startTime = WTF::currentTime() - timeOffset;
    331     m_layerInfo.animations.append(webAnimation);
    332     notifyChange();
    333 }
    334 
    335 void WebGraphicsLayer::removeAnimation(const String& animationName)
    336 {
    337     WebLayerAnimation webAnimation;
    338     webAnimation.name = animationName;
    339     webAnimation.operation = WebLayerAnimation::RemoveAnimation;
    340     m_layerInfo.animations.append(webAnimation);
    341     m_transformAnimations.remove(animationName);
    342293    notifyChange();
    343294}
     
    480431
    481432    m_modified = false;
    482     if (m_hasPendingAnimations)
    483         notifyAnimationStarted(WTF::currentTime());
    484     m_layerInfo.animations.clear();
    485     m_hasPendingAnimations = false;
    486433}
    487434
     
    570517IntRect WebGraphicsLayer::tiledBackingStoreVisibleRect()
    571518{
    572     // If this layer is part of an active transform animation, the visible rect might change,
    573     // so we rather render the whole layer until some better optimization is available.
    574519    if (!shouldUseTiledBackingStore())
    575520        return tiledBackingStoreContentsRect();
     
    699644bool WebGraphicsLayer::selfOrAncestorHaveNonAffineTransforms()
    700645{
    701     if (!m_transformAnimations.isEmpty())
    702         return true;
    703 
    704646    if (!m_layerTransform.combined().isAffine())
    705647        return true;
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h

    r113615 r113628  
    9292    void setOpacity(float);
    9393    void setContentsRect(const IntRect&);
    94     bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double);
    95     void pauseAnimation(const String&, double);
    96     void removeAnimation(const String&);
    9794    void setContentsToImage(Image*);
    9895    void setMaskLayer(GraphicsLayer*);
     
    112109    void didSynchronize();
    113110    Image* image() { return m_image.get(); }
    114     void notifyAnimationStarted(double);
    115111
    116112    GraphicsLayer* maskTarget() const { return m_maskTarget; }
     
    148144    LayerTransform m_layerTransform;
    149145    bool m_modified : 1;
    150     bool m_hasPendingAnimations : 1;
    151146    bool m_inUpdateMode : 1;
    152147    bool m_shouldUpdateVisibleRect: 1;
     
    155150    void didChangeGeometry();
    156151    void createBackingStore();
    157     HashSet<String> m_transformAnimations;
    158152
    159153    bool selfOrAncestorHaveNonAffineTransforms();
Note: See TracChangeset for help on using the changeset viewer.