Exemplo n.º 1
0
PassRefPtr<RenderStyle> CompositeAnimation::animate(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle)
{
    RefPtr<RenderStyle> resultStyle;

    // We don't do any transitions if we don't have a currentStyle (on startup).
    updateTransitions(renderer, currentStyle, targetStyle);
    updateKeyframeAnimations(renderer, currentStyle, targetStyle);
    m_keyframeAnimations.checkConsistency();

    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.
        if (!m_transitions.isEmpty()) {
            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(this, 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.
    for (Vector<AtomicStringImpl*>::const_iterator it = m_keyframeAnimationOrderMap.begin(); it != m_keyframeAnimationOrderMap.end(); ++it) {
        RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(*it);
        if (keyframeAnim)
            keyframeAnim->animate(this, renderer, currentStyle, targetStyle, resultStyle);
    }

    return resultStyle ? resultStyle.release() : targetStyle;
}
Exemplo n.º 2
0
void Scene::moveMulti( Clip *clip, int clipTrack, double newPos )
{
	QMutexLocker ml( &mutex );
	
	if ( clip->position() == newPos )
		return;
	
	double delta = newPos - clip->position();
	double margin = profile.getVideoFrameDuration() / 4.0;
	Track *t = tracks[clipTrack];
	int count = t->clipCount();
	int clipIndex = 0;
	int k = 0;
	while ( k < count ) {
		Clip *c = t->clipAt( k );
		// find clip
		if ( c == clip ) {
			clipIndex = k;
			break;
		}
		++k;
	}

	removeTransitions( clip, clipTrack, clipTrack, clipIndex, newPos, clip->length(), margin, true );
	clip->setPosition( clip->position() + delta );
	while ( ++k < count ) {
		Clip *c = t->clipAt( k );
		c->setPosition( c->position() + delta );
	}
	updateTransitions( clip, clipTrack, margin );
	clip->setInput( NULL );
	
	update = true;
}
Exemplo n.º 3
0
Ref<RenderStyle> CompositeAnimation::animate(RenderElement& renderer, RenderStyle* currentStyle, RenderStyle& targetStyle)
{
    RefPtr<RenderStyle> resultStyle;

    // We don't do any transitions if we don't have a currentStyle (on startup).
    updateTransitions(&renderer, currentStyle, &targetStyle);
    updateKeyframeAnimations(&renderer, currentStyle, &targetStyle);
    m_keyframeAnimations.checkConsistency();

    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.
        if (!m_transitions.isEmpty()) {
            for (auto& transition : m_transitions.values())
                transition->animate(this, &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.
    for (auto& name : m_keyframeAnimationOrderMap) {
        RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name);
        if (keyframeAnim)
            keyframeAnim->animate(this, &renderer, currentStyle, &targetStyle, resultStyle);
    }

    if (resultStyle)
        return resultStyle.releaseNonNull();

    return targetStyle;
}
Exemplo n.º 4
0
bool CompositeAnimation::animate(RenderElement& renderer, RenderStyle* currentStyle, RenderStyle& targetStyle, Ref<RenderStyle>& blendedStyle)
{
    // We don't do any transitions if we don't have a currentStyle (on startup).
    updateTransitions(&renderer, currentStyle, &targetStyle);
    updateKeyframeAnimations(&renderer, currentStyle, &targetStyle);
    m_keyframeAnimations.checkConsistency();

    RefPtr<RenderStyle> animatedStyle;
    bool animationStateChanged = false;

    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.
        for (auto& transition : m_transitions.values()) {
            if (transition->animate(this, &renderer, currentStyle, &targetStyle, animatedStyle))
                animationStateChanged = true;
        }
    }

    // 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.
    for (auto& name : m_keyframeAnimationOrderMap) {
        RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name);
        if (keyframeAnim && keyframeAnim->animate(this, &renderer, currentStyle, &targetStyle, animatedStyle))
            animationStateChanged = true;
    }

    if (animatedStyle)
        blendedStyle = animatedStyle.releaseNonNull();
    else
        blendedStyle = targetStyle;

    return animationStateChanged;
}
Exemplo n.º 5
0
void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos, F32 duration, bool continuePlay)
{
   // make sure all transforms on all detail levels are accurate
   sortThreads();
   animateNodeSubtrees();

   thread->transitionToSequence(seq,pos,duration,continuePlay);
   setDirty(AllDirtyMask);
   mGroundThread = NULL;

   if (mScaleCurrentlyAnimated && !thread->getSequence()->animatesScale())
      checkScaleCurrentlyAnimated();
   else if (!mScaleCurrentlyAnimated && thread->getSequence()->animatesScale())
      mScaleCurrentlyAnimated=true;

   mTransitionRotationNodes.overlap(thread->transitionData.oldRotationNodes);
   mTransitionRotationNodes.overlap(thread->getSequence()->rotationMatters);

   mTransitionTranslationNodes.overlap(thread->transitionData.oldTranslationNodes);
   mTransitionTranslationNodes.overlap(thread->getSequence()->translationMatters);

   mTransitionScaleNodes.overlap(thread->transitionData.oldScaleNodes);
   mTransitionScaleNodes.overlap(thread->getSequence()->scaleMatters);

   // if we aren't already in the list of transition threads, add us now
   S32 i;
   for (i=0; i<mTransitionThreads.size(); i++)
      if (mTransitionThreads[i]==thread)
         break;
   if (i==mTransitionThreads.size())
      mTransitionThreads.push_back(thread);

   updateTransitions();
}
Exemplo n.º 6
0
void Scene::move( Clip *clip, int clipTrack, double newPos, int newTrack )
{
	QMutexLocker ml( &mutex );
	
	if ( clip->position() == newPos && clipTrack == newTrack )
		return;
	
	double margin = profile.getVideoFrameDuration() / 4.0;
	int insert, self = 0;
	Track *t = tracks[newTrack];
	insert = t->clipCount();
	for ( int i = 0; i < t->clipCount(); ++i ) {
		Clip *c = t->clipAt( i );
		if ( c == clip ) {
			++self;
			continue;
		}
		if ( newPos < c->position() ) {
			insert = i;
			break;
		}
	}
			
	insert -= self;
	removeTransitions( clip, clipTrack, newTrack, insert, newPos, clip->length(), margin );
	tracks[clipTrack]->removeClip( clip );
	t->insertClipAt( clip, insert );
	clip->setPosition( newPos );
	updateTransitions( clip, newTrack, margin );
	clip->setInput( NULL );
	update = true;
}
Exemplo n.º 7
0
void Unit::update()
{

    if (isPaused)
        return;
    auto curTime = the::timer::globalTime();
    dt = curTime - lastTimeUpdated;
    lastTimeUpdated = curTime;
    updateTransitions();
}
Exemplo n.º 8
0
void Scene::addClip( Clip *clip, int track )
{
	QMutexLocker ml( &mutex );
	double margin = profile.getVideoFrameDuration() / 4.0;
	Track *t = tracks[track];
	int i = 0, cc = t->clipCount();
	while ( i < cc ) {
		Clip *c = t->clipAt( i );
		if ( clip->position() < c->position() ) {
			t->insertClipAt( clip, i );
			updateTransitions( clip, track, margin );
			update = true;
			return;
		}
		++i;
	}
	t->insertClipAt( clip, i );
	updateTransitions( clip, track, margin );
}
Exemplo n.º 9
0
void Scene::resize( Clip *clip, double newLength, int track )
{
	QMutexLocker ml( &mutex );
	
	if ( clip->length() == newLength )
		return;
	
	double margin = profile.getVideoFrameDuration() / 4.0;
	removeTransitions( clip, track, track, tracks[track]->indexOf( clip ), clip->position(), newLength, margin );
	double old = clip->position() + clip->length();
	if ( clip->getSource()->getType() == InputBase::FFMPEG && clip->getSpeed() < 0 )
		clip->setStart( clip->start() + ((clip->length() - newLength) * qAbs(clip->getSpeed())) );
	clip->setLength( newLength );
	updateTransitions( clip, track, margin );
	clip->setInput( NULL );
	update = updateCurrentPosition( qMin( old, clip->position() + clip->length() ), qMax( old, clip->position() + clip->length() )  );
}
Exemplo n.º 10
0
void TSShapeInstance::clearTransition(TSThread * thread)
{
   if (!thread->transitionData.inTransition)
      return;

   // if other transitions are still playing,
   // make sure transforms are up to date
   if (mTransitionThreads.size()>1)
      animateNodeSubtrees();

   // turn off transition...
   thread->transitionData.inTransition = false;

   // remove us from transition list
   S32 i;
   if (mTransitionThreads.size() != 0) {
      for (i=0; i<mTransitionThreads.size(); i++)
	 if (mTransitionThreads[i]==thread)
	    break;
      AssertFatal(i!=mTransitionThreads.size(),"TSShapeInstance::clearTransition");
      mTransitionThreads.erase(i);
   }

   // recompute transitionNodes
   mTransitionRotationNodes.clearAll();
   mTransitionTranslationNodes.clearAll();
   mTransitionScaleNodes.clearAll();
   for (i=0; i<mTransitionThreads.size(); i++)
   {
      mTransitionRotationNodes.overlap(mTransitionThreads[i]->transitionData.oldRotationNodes);
      mTransitionRotationNodes.overlap(mTransitionThreads[i]->getSequence()->rotationMatters);

      mTransitionTranslationNodes.overlap(mTransitionThreads[i]->transitionData.oldTranslationNodes);
      mTransitionTranslationNodes.overlap(mTransitionThreads[i]->getSequence()->translationMatters);

      mTransitionScaleNodes.overlap(mTransitionThreads[i]->transitionData.oldScaleNodes);
      mTransitionScaleNodes.overlap(mTransitionThreads[i]->getSequence()->scaleMatters);
   }

   setDirty(ThreadDirty);

   updateTransitions();
}
Exemplo n.º 11
0
void TSShapeInstance::setSequence(TSThread * thread, S32 seq, F32 pos)
{
   if ( (thread->transitionData.inTransition && mTransitionThreads.size()>1) || mTransitionThreads.size()>0)
   {
      // if we have transitions, make sure transforms are up to date...
      sortThreads();
      animateNodeSubtrees();
   }

   thread->setSequence(seq,pos);
   setDirty(AllDirtyMask);
   mGroundThread = NULL;

   if (mScaleCurrentlyAnimated && !thread->getSequence()->animatesScale())
      checkScaleCurrentlyAnimated();
   else if (!mScaleCurrentlyAnimated && thread->getSequence()->animatesScale())
      mScaleCurrentlyAnimated=true;

   updateTransitions();
}
Exemplo n.º 12
0
RenderStyle* CompositeAnimation::animate(RenderObject* renderer, const RenderStyle* currentStyle, RenderStyle* targetStyle)
{
    RenderStyle* resultStyle = 0;
    
    // 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) {
            ImplicitAnimation*  anim = it->second;
            if (anim) {
                anim->animate(this, renderer, currentStyle, targetStyle, resultStyle);
            }
        }
    }

    updateKeyframeAnimations(renderer, currentStyle, targetStyle);

    // 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())[i].get();

            if (anim->isValidAnimation()) {
                AtomicString name(anim->name());
                KeyframeAnimation* keyframeAnim = m_keyframeAnimations.get(name.impl());
                if (keyframeAnim)
                    keyframeAnim->animate(this, renderer, currentStyle, targetStyle, resultStyle);
            }
        }
    }
    
    cleanupFinishedAnimations(renderer);

    return resultStyle ? resultStyle : targetStyle;
}
Exemplo n.º 13
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;
}
Exemplo n.º 14
0
void Scene::resizeStart( Clip *clip, double newPos, double newLength, int track )
{
	QMutexLocker ml( &mutex );
	
	if ( clip->position() == newPos && clip->length() == newLength )
		return;
	
	double margin = profile.getVideoFrameDuration() / 4.0;
	int insert, self = 0;
	Track *t = tracks[track];
	insert = t->clipCount();
	for ( int i = 0; i < t->clipCount(); ++i ) {
		Clip *c = t->clipAt( i );
		if ( c == clip ) {
			++self;
			continue;
		}
		if ( newPos < c->position() ) {
			insert = i;
			break;
		}
	}
				
	insert -= self;
	double old = clip->position();
	removeTransitions( clip, track, track, insert, newPos, newLength, margin );
	t->removeClip( clip );
	t->insertClipAt( clip, insert );
	if ( clip->getSource()->getType() == InputBase::FFMPEG && clip->getSpeed() >= 0 )
		clip->setStart( clip->start() + ((clip->length() - newLength) * qAbs(clip->getSpeed())) );
	clip->setLength( newLength );
	clip->setPosition( newPos );
	updateTransitions( clip, track, margin );
	clip->setInput( NULL );
	update = updateCurrentPosition( qMin( old, clip->position() ), qMax( old, clip->position() )  );
}