const QPixmap& Environment::getPixmap( const QString& _objectName, const QString& _skinId ) const { QString animationName( generateAnimationName( _skinId , _objectName , Core::LandscapeModel::ObjectState::Standing , Core::LandscapeModel::Direction::South ) ); if ( m_pluginInstance.getAnimationsCache()->hasAnimation( animationName ) ) { const Framework::GUI::AnimationManager::AnimationInfo& animationInfo = m_pluginInstance.getAnimationsCache()->getAnimation( animationName ); Framework::GUI::ImagesManager::IImagesManager::TransformationData transformationData( animationInfo.m_frames[ 0 ].m_frame ); return m_pluginInstance.getImagesManager()->getPixmap( animationInfo.m_atlasName, transformationData ); } else { return getPixmap( _objectName, IGraphicsInfo::ms_anySkinIdentifier ); } } // Environment::getPixmap
void CompositeAnimationPrivate::updateKeyframeAnimations(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; // Nothing to do if the current and target animations are the same if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) return; // Mark all existing animations as no longer active AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) it->second->setIndex(-1); // Now mark any still active animations as active and add any new animations if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { const Animation* anim = targetStyle->animations()->animation(i); AtomicString animationName(anim->name()); if (!anim->isValidAnimation()) continue; // See if there is a current animation for this name RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // There is one so it is still active // Animations match, but play states may differ. update if needed keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); // Set the saved animation to this new one, just in case the play state has changed keyframeAnim->setAnimation(anim); keyframeAnim->setIndex(i); } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(anim), renderer, i, m_compositeAnimation, currentStyle ? currentStyle : targetStyle); m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } } } // Make a list of animations to be removed Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->second.get(); if (keyframeAnim->index() < 0) animsToBeRemoved.append(keyframeAnim->name().impl()); } // Now remove the animations from the list for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); }
static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 3) return JSValueMakeUndefined(context); JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); double time = JSValueToNumber(context, arguments[1], exception); ASSERT(!*exception); JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get())); }
static int ActorL_SetAnimation(lua_State* luaVM) { int nargs = lua_gettop(luaVM); switch(nargs) { case 2: { Actor* actor = luaW_check<Actor>(luaVM, 1); if (actor) { std::string animationName(lua_tostring(luaVM, 2)); actor->setAnimation(animationName); } break; } } return 0; }
PassRefPtr<RenderStyle> CompositeAnimationPrivate::animate(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { RefPtr<RenderStyle> resultStyle; // Update animations first so we can see if any transitions are overridden updateKeyframeAnimations(renderer, currentStyle, targetStyle); // We don't do any transitions if we don't have a currentStyle (on startup) updateTransitions(renderer, currentStyle, targetStyle); if (currentStyle) { // Now that we have transition objects ready, let them know about the new goal state. We want them // to fill in a RenderStyle*& only if needed. CSSPropertyTransitionsMap::const_iterator end = m_transitions.end(); for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) { if (ImplicitAnimation* anim = it->second.get()) anim->animate(m_compositeAnimation, renderer, currentStyle, targetStyle, resultStyle); } } // Now that we have animation objects ready, let them know about the new goal state. We want them // to fill in a RenderStyle*& only if needed. if (targetStyle->hasAnimations()) { for (size_t i = 0; i < targetStyle->animations()->size(); ++i) { const Animation* anim = targetStyle->animations()->animation(i); if (anim->isValidAnimation()) { AtomicString animationName(anim->name()); RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) keyframeAnim->animate(m_compositeAnimation, renderer, currentStyle, targetStyle, resultStyle); } } } cleanupFinishedAnimations(renderer); return resultStyle ? resultStyle.release() : targetStyle; }
void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate& update, const Element* animatingElement, Element& element, const ComputedStyle& style, ComputedStyle* parentStyle, StyleResolver* resolver) { const ElementAnimations* elementAnimations = animatingElement ? animatingElement->elementAnimations() : nullptr; bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnimationStyleChange(); #if !ENABLE(ASSERT) // If we're in an animation style change, no animations can have started, been cancelled or changed play state. // When ASSERT is enabled, we verify this optimization. if (isAnimationStyleChange) return; #endif const CSSAnimationData* animationData = style.animations(); const CSSAnimations* cssAnimations = elementAnimations ? &elementAnimations->cssAnimations() : nullptr; const Element* elementForScoping = animatingElement ? animatingElement : &element; HashSet<AtomicString> inactive; if (cssAnimations) { for (const auto& entry : cssAnimations->m_animations) inactive.add(entry.key); } if (style.display() != NONE) { for (size_t i = 0; animationData && i < animationData->nameList().size(); ++i) { AtomicString animationName(animationData->nameList()[i]); if (animationName == CSSAnimationData::initialName()) continue; const bool isPaused = CSSTimingData::getRepeated(animationData->playStateList(), i) == AnimPlayStatePaused; Timing timing = animationData->convertToTiming(i); Timing specifiedTiming = timing; RefPtr<TimingFunction> keyframeTimingFunction = timing.timingFunction; timing.timingFunction = Timing::defaults().timingFunction; RefPtrWillBeRawPtr<StyleRuleKeyframes> keyframesRule = resolver->findKeyframesRule(elementForScoping, animationName); if (!keyframesRule) continue; // Cancel the animation if there's no style rule for it. if (cssAnimations) { AnimationMap::const_iterator existing(cssAnimations->m_animations.find(animationName)); if (existing != cssAnimations->m_animations.end()) { inactive.remove(animationName); const RunningAnimation* runningAnimation = existing->value.get(); Animation* animation = runningAnimation->animation.get(); if (keyframesRule != runningAnimation->styleRule || keyframesRule->version() != runningAnimation->styleRuleVersion || runningAnimation->specifiedTiming != specifiedTiming) { ASSERT(!isAnimationStyleChange); update.updateAnimation(animationName, animation, InertEffect::create( createKeyframeEffectModel(resolver, animatingElement, element, &style, parentStyle, animationName, keyframeTimingFunction.get(), i), timing, isPaused, animation->unlimitedCurrentTimeInternal()), specifiedTiming, keyframesRule); } if (isPaused != animation->paused()) { ASSERT(!isAnimationStyleChange); update.toggleAnimationPaused(animationName); } continue; } } ASSERT(!isAnimationStyleChange); update.startAnimation(animationName, InertEffect::create( createKeyframeEffectModel(resolver, animatingElement, element, &style, parentStyle, animationName, keyframeTimingFunction.get(), i), timing, isPaused, 0), specifiedTiming, keyframesRule); } } ASSERT(inactive.isEmpty() || cssAnimations); for (const AtomicString& animationName : inactive) { ASSERT(!isAnimationStyleChange); update.cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName)->animation); } }
void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; m_keyframeAnimations.checkConsistency(); AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { // The current and target animations are the same so we just need to toss any // animation which is finished (postActive). for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { if (it->second->postActive()) it->second->setIndex(-1); } } else { // Mark all existing animations as no longer active. for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) it->second->setIndex(-1); // Toss the animation order map. m_keyframeAnimationOrderMap.clear(); // Now mark any still active animations as active and add any new animations. if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { const Animation* anim = targetStyle->animations()->animation(i); AtomicString animationName(anim->name()); if (!anim->isValidAnimation()) continue; // See if there is a current animation for this name. RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // If this animation is postActive, skip it so it gets removed at the end of this function. if (keyframeAnim->postActive()) continue; // This one is still active. // Animations match, but play states may differ. Update if needed. keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(anim); keyframeAnim->setIndex(i); } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(anim), renderer, i, this, targetStyle); m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } // Add this to the animation order map. if (keyframeAnim) m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } } // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->second.get(); if (keyframeAnim->index() < 0) animsToBeRemoved.append(keyframeAnim->name().impl()); } // Now remove the animations from the list. for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); }
void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; m_keyframeAnimations.checkConsistency(); if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { // The current and target animations are the same so we just need to toss any // animation which is finished (postActive). for (auto& animation : m_keyframeAnimations.values()) { if (animation->postActive()) animation->setIndex(-1); } } else { // Mark all existing animations as no longer active. for (auto& animation : m_keyframeAnimations.values()) animation->setIndex(-1); #if ENABLE(CSS_ANIMATIONS_LEVEL_2) m_hasScrollTriggeredAnimation = false; #endif // Toss the animation order map. m_keyframeAnimationOrderMap.clear(); DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::ConstructFromLiteral)); // Now mark any still active animations as active and add any new animations. if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { Animation& animation = targetStyle->animations()->animation(i); AtomicString animationName(animation.name()); if (!animation.isValidAnimation()) continue; // See if there is a current animation for this name. RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // If this animation is postActive, skip it so it gets removed at the end of this function. if (keyframeAnim->postActive()) continue; #if ENABLE(CSS_ANIMATIONS_LEVEL_2) if (animation.trigger()->isScrollAnimationTrigger()) m_hasScrollTriggeredAnimation = true; #endif // This one is still active. // Animations match, but play states may differ. Update if needed. keyframeAnim->updatePlayState(animation.playState()); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(animation); keyframeAnim->setIndex(i); } else if ((animation.duration() || animation.delay()) && animation.iterationCount() && animationName != none) { keyframeAnim = KeyframeAnimation::create(animation, renderer, i, this, targetStyle); LOG(Animations, "Creating KeyframeAnimation %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount()); if (m_suspended) { keyframeAnim->updatePlayState(AnimPlayStatePaused); LOG(Animations, " (created in suspended/paused state)"); } #if !LOG_DISABLED for (auto propertyID : keyframeAnim->keyframes().properties()) LOG(Animations, " property %s", getPropertyName(propertyID)); #endif #if ENABLE(CSS_ANIMATIONS_LEVEL_2) if (animation.trigger()->isScrollAnimationTrigger()) m_hasScrollTriggeredAnimation = true; #endif m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } // Add this to the animation order map. if (keyframeAnim) m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } } // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; for (auto& animation : m_keyframeAnimations.values()) { if (animation->index() < 0) { animsToBeRemoved.append(animation->name().impl()); animationController().animationWillBeRemoved(animation.get()); animation->clear(); LOG(Animations, "Removing KeyframeAnimation %p", animation.get()); } } // Now remove the animations from the list. for (auto nameForRemoval : animsToBeRemoved) m_keyframeAnimations.remove(nameForRemoval); }
void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; m_keyframeAnimations.checkConsistency(); AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { // The current and target animations are the same so we just need to toss any // animation which is finished (postActive). for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { if (it->value->postActive()) it->value->setIndex(-1); } } else { // Mark all existing animations as no longer active. for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) it->value->setIndex(-1); // Toss the animation order map. m_keyframeAnimationOrderMap.clear(); DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::ConstructFromLiteral)); // Now mark any still active animations as active and add any new animations. if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { const Animation& animation = targetStyle->animations()->animation(i); AtomicString animationName(animation.name()); if (!animation.isValidAnimation()) continue; // See if there is a current animation for this name. RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // If this animation is postActive, skip it so it gets removed at the end of this function. if (keyframeAnim->postActive()) continue; // This one is still active. // Animations match, but play states may differ. Update if needed. keyframeAnim->updatePlayState(animation.playState()); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(&animation); keyframeAnim->setIndex(i); } else if ((animation.duration() || animation.delay()) && animation.iterationCount() && animationName != none) { keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(&animation), renderer, i, this, targetStyle); LOG(Animations, "Creating KeyframeAnimation %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount()); if (m_suspended) { keyframeAnim->updatePlayState(AnimPlayStatePaused); LOG(Animations, " (created in suspended/paused state)"); } #if !LOG_DISABLED HashSet<CSSPropertyID>::const_iterator endProperties = keyframeAnim->keyframes().endProperties(); for (HashSet<CSSPropertyID>::const_iterator it = keyframeAnim->keyframes().beginProperties(); it != endProperties; ++it) LOG(Animations, " property %s", getPropertyName(*it)); #endif m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } // Add this to the animation order map. if (keyframeAnim) m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } } // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->value.get(); if (keyframeAnim->index() < 0) { animsToBeRemoved.append(keyframeAnim->name().impl()); animationController()->animationWillBeRemoved(keyframeAnim); keyframeAnim->clear(); LOG(Animations, "Removing KeyframeAnimation %p", keyframeAnim); } } // Now remove the animations from the list. for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); }
void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const Element* animatingElement, Element& element, const RenderStyle& style, RenderStyle* parentStyle, StyleResolver* resolver) { const ActiveAnimations* activeAnimations = animatingElement ? animatingElement->activeAnimations() : nullptr; #if !ENABLE(ASSERT) // If we're in an animation style change, no animations can have started, been cancelled or changed play state. // When ASSERT is enabled, we verify this optimization. if (activeAnimations && activeAnimations->isAnimationStyleChange()) return; #endif const CSSAnimationData* animationData = style.animations(); const CSSAnimations* cssAnimations = activeAnimations ? &activeAnimations->cssAnimations() : nullptr; HashSet<AtomicString> inactive; if (cssAnimations) { for (const auto& entry : cssAnimations->m_animations) inactive.add(entry.key); } if (style.display() != NONE) { for (size_t i = 0; animationData && i < animationData->nameList().size(); ++i) { AtomicString animationName(animationData->nameList()[i]); if (animationName == CSSAnimationData::initialName()) continue; bool isPaused = CSSTimingData::getRepeated(animationData->playStateList(), i) == AnimPlayStatePaused; // Keyframes and animation properties are snapshotted when the // animation starts, so we don't need to track changes to these, // with the exception of play-state. if (cssAnimations) { AnimationMap::const_iterator existing(cssAnimations->m_animations.find(animationName)); if (existing != cssAnimations->m_animations.end()) { inactive.remove(animationName); AnimationPlayer* player = existing->value.get(); if (isPaused != player->paused()) { ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); update->toggleAnimationPaused(animationName); } continue; } } Timing timing = animationData->convertToTiming(i); RefPtr<TimingFunction> keyframeTimingFunction = timing.timingFunction; timing.timingFunction = Timing::defaults().timingFunction; AnimatableValueKeyframeVector resolvedKeyframes; resolveKeyframes(resolver, animatingElement, element, style, parentStyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes); if (!resolvedKeyframes.isEmpty()) { ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); update->startAnimation(animationName, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), timing, isPaused)); } } } ASSERT(inactive.isEmpty() || cssAnimations); for (const AtomicString& animationName : inactive) { ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); update->cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName)); } }