bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset) { ASSERT(!keyframesName.isEmpty()); if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity)) return false; bool listsMatch = false; bool hasBigRotation; if (valueList.property() == AnimatedPropertyWebkitTransform) listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0; m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, WTF::currentTime() - timeOffset, listsMatch)); notifyChange(TextureMapperLayer::AnimationChange); m_animationStartedTimer.startOneShot(0); return true; }
bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& keyframesName, double delayAsNegativeTimeOffset) { ASSERT(!keyframesName.isEmpty()); if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity && valueList.property() != AnimatedPropertyWebkitFilter)) return false; bool listsMatch = false; bool ignoredHasBigRotation; if (valueList.property() == AnimatedPropertyWebkitTransform) listsMatch = validateTransformOperations(valueList, ignoredHasBigRotation) >= 0; m_lastAnimationStartTime = monotonicallyIncreasingTime() - delayAsNegativeTimeOffset; m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, m_lastAnimationStartTime, listsMatch)); m_animationStartedTimer.startOneShot(0); didChangeAnimations(); return true; }
bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset) { ASSERT(!keyframesName.isEmpty()); if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity)) return false; bool listsMatch = false; bool hasBigRotation; if (valueList.property() == AnimatedPropertyWebkitTransform) listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0; const double currentTime = WTF::currentTime(); m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, currentTime - timeOffset, listsMatch)); // m_animationStartTime is the time of the first real frame of animation, now or delayed by a negative offset. if (timeOffset > 0) m_animationStartTime = currentTime; else m_animationStartTime = currentTime - timeOffset; notifyChange(AnimationChange); notifyChange(AnimationStarted); return true; }
bool ArgumentCoder<GraphicsLayerAnimation>::decode(ArgumentDecoder* decoder, GraphicsLayerAnimation& animation) { String name; IntSize boxSize; GraphicsLayerAnimation::AnimationState state; double startTime; double pauseTime; bool listsMatch; Animation::AnimationDirection direction; unsigned fillMode; double duration; double iterationCount; RefPtr<TimingFunction> timingFunction; RefPtr<Animation> animationObject; if (!decoder->decode(name)) return false; if (!decoder->decode(boxSize)) return false; if (!decoder->decodeEnum(state)) return false; if (!decoder->decodeDouble(startTime)) return false; if (!decoder->decodeDouble(pauseTime)) return false; if (!decoder->decodeBool(listsMatch)) return false; if (!decoder->decodeEnum(direction)) return false; if (!decoder->decodeUInt32(fillMode)) return false; if (!decoder->decodeDouble(duration)) return false; if (!decoder->decodeDouble(iterationCount)) return false; if (!decodeTimingFunction(decoder, timingFunction)) return false; animationObject = Animation::create(); animationObject->setDirection(direction); animationObject->setFillMode(fillMode); animationObject->setDuration(duration); animationObject->setIterationCount(iterationCount); if (timingFunction) animationObject->setTimingFunction(timingFunction); AnimatedPropertyID property; if (!decoder->decodeEnum(property)) return false; KeyframeValueList keyframes(property); unsigned keyframesSize; if (!decoder->decodeUInt32(keyframesSize)) return false; for (unsigned i = 0; i < keyframesSize; ++i) { float keyTime; RefPtr<TimingFunction> timingFunction; if (!decoder->decode(keyTime)) return false; if (!decodeTimingFunction(decoder, timingFunction)) return false; switch (property) { case AnimatedPropertyOpacity: { float value; if (!decoder->decodeFloat(value)) return false; keyframes.insert(new FloatAnimationValue(keyTime, value, timingFunction)); break; } case AnimatedPropertyWebkitTransform: { TransformOperations transform; if (!decoder->decode(transform)) return false; keyframes.insert(new TransformAnimationValue(keyTime, &transform, timingFunction)); break; } #if ENABLE(CSS_FILTERS) case AnimatedPropertyWebkitFilter: { FilterOperations filter; if (!decoder->decode(filter)) return false; keyframes.insert(new FilterAnimationValue(keyTime, &filter, timingFunction)); break; } #endif default: break; } } animation = GraphicsLayerAnimation(name, keyframes, boxSize, animationObject.get(), startTime, listsMatch); animation.setState(state, pauseTime); return true; }