示例#1
0
void ImplicitAnimation::animate(CompositeAnimation*, RenderObject*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle)
{
    // If we get this far and the animation is done, it means we are cleaning up a just finished animation.
    // So just return. Everything is already all cleaned up.
    if (postActive())
        return;

    // Reset to start the transition if we are new
    if (isNew())
        reset(targetStyle);

    // Run a cycle of animation.
    // We know we will need a new render style, so make one if needed
    if (!animatedStyle)
        animatedStyle = RenderStyle::clone(targetStyle);

    bool needsAnim = CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0));
    // FIXME: we also need to detect cases where we have to software animate for other reasons,
    // such as a child using inheriting the transform. https://bugs.webkit.org/show_bug.cgi?id=23902
    if (needsAnim)
        setAnimating();
    else {
#if USE(ACCELERATED_COMPOSITING)
        // If we are running an accelerated animation, set a flag in the style which causes the style
        // to compare as different to any other style. This ensures that changes to the property
        // that is animating are correctly detected during the animation (e.g. when a transition
        // gets interrupted).
        animatedStyle->setIsRunningAcceleratedAnimation();
#endif
    }

    // Fire the start timeout if needed
    fireAnimationEventsIfNeeded();
}
示例#2
0
void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle)
{
    // Fire the start timeout if needed
    fireAnimationEventsIfNeeded();
    
    // If we have not yet started, we will not have a valid start time, so just start the animation if needed.
    if (isNew() && m_animation->playState() == AnimPlayStatePlaying)
        updateStateMachine(AnimationStateInputStartAnimation, -1);

    // If we get this far and the animation is done, it means we are cleaning up a just finished animation.
    // If so, we need to send back the targetStyle.
    if (postActive()) {
        if (!animatedStyle)
            animatedStyle = const_cast<RenderStyle*>(targetStyle);
        return;
    }

    // If we are waiting for the start timer, we don't want to change the style yet.
    // Special case 1 - if the delay time is 0, then we do want to set the first frame of the
    // animation right away. This avoids a flash when the animation starts.
    // Special case 2 - if there is a backwards fill mode, then we want to continue
    // through to the style blend so that we get the fromStyle.
    if (waitingToStart() && m_animation->delay() > 0 && !m_animation->fillsBackwards())
        return;

    // FIXME: we need to be more efficient about determining which keyframes we are animating between.
    // We should cache the last pair or something.
    
    // Get the from/to styles and progress between
    const RenderStyle* fromStyle = 0;
    const RenderStyle* toStyle = 0;
    double progress;
    getKeyframeAnimationInterval(fromStyle, toStyle, progress);

    // If either style is 0 we have an invalid case, just stop the animation.
    if (!fromStyle || !toStyle) {
        updateStateMachine(AnimationStateInputEndAnimation, -1);
        return;
    }

    // Run a cycle of animation.
    // We know we will need a new render style, so make one if needed.
    if (!animatedStyle)
        animatedStyle = RenderStyle::clone(targetStyle);

    HashSet<int>::const_iterator endProperties = m_keyframes.endProperties();
    for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) {
        bool needsAnim = blendProperties(this, *it, animatedStyle.get(), fromStyle, toStyle, progress);
        if (needsAnim)
            setAnimating();
        else {
#if USE(ACCELERATED_COMPOSITING)
            // If we are running an accelerated animation, set a flag in the style
            // to indicate it. This can be used to make sure we get an updated
            // style for hit testing, etc.
            animatedStyle->setIsRunningAcceleratedAnimation();
#endif
        }
    }
}
void cBarracks::think_animation() {
	// a barracks does not animate, so when set, set it back to false
	if (isAnimating()) {
		setAnimating(false);
	}
	cAbstractStructure::think_animation();
	cAbstractStructure::think_flag();
}
示例#4
0
文件: CQSVG.cpp 项目: colinw7/CSVG
void
CQSVG::
stopTimer()
{
  if (isAnimating()) {
    timer_->stop();

    setAnimating(false);
  }
}
示例#5
0
文件: CQSVG.cpp 项目: colinw7/CSVG
void
CQSVG::
startTimer()
{
  if (! isAnimating()) {
    timer_->start(dt_);

    setAnimating(true);
  }
}
示例#6
0
QOgreWindow::QOgreWindow(QWindow *parent)
    : QWindow(parent),
      isUpdatePending(false),
      isAnimating(false),
      oRoot(NULL),
      oWin(NULL),
      oCam(NULL),
      camMan(NULL),
      resConfig("resources/resources.cfg"),
      pluginConfig(Ogre::StringUtil::BLANK)
{
    setAnimating(true);
    installEventFilter(this);
    oBgColor = Ogre::ColourValue(0.8f, 0.4f, 0.5f);
}
// FPS based thing function (every second called)
void cStarPort::think_deploy()
{
	if (frigateDroppedPackage) {
		  TIMER_deploy--;
		  if (TIMER_deploy < 0) {
			  TIMER_deploy = 1;
			  // deploy unit
			  cOrderProcesser * orderProcesser = player[iPlayer].getOrderProcesser();
			  cBuildingListItem * item = orderProcesser->getItemToDeploy();
			  if (item) {
				  cStructureUtils structureUtils;
				  int cellToDeployTo = iFreeAround();
				  orderProcesser->markOrderAsDeployed(item);
				  item->decreaseTimesOrdered();
				  int rallyPoint = getRallyPoint();

				  if (cellToDeployTo >= 0) {
					  int id = UNIT_CREATE(cellToDeployTo, item->getBuildId(), iPlayer, true);
					  if (rallyPoint > -1) {
						  unit[id].move_to(rallyPoint, -1, -1);
					  }
					  play_voice(SOUND_VOICE_05_ATR); // unit deployed
				  } else {
					  // could not find cell to deploy to, reinforce it
					  cCellCalculator * cellCalculator = new cCellCalculator(&map);
					  if (rallyPoint > -1) {
						  cellToDeployTo = rallyPoint;
					  }

					  if (cellToDeployTo < 0) {
						  // in this case, the structure has nothing around it free, but nor a rally point is set
						  // assume that the cell to drop is the location of the structure itself
						  cellToDeployTo = getCell();
					  }
					  int cellAtBorderOfMap = cellCalculator->findCloseMapBorderCellRelativelyToDestinationCel(cellToDeployTo);
					  REINFORCE(iPlayer, item->getBuildId(), cellToDeployTo, cellAtBorderOfMap);
					  delete cellCalculator;
				  }
			  } else {
				  // item is null, no more items to deploy.
				  setAnimating(false);
				  orderProcesser->setOrderHasBeenProcessed();
				  frigateDroppedPackage = false;
			  }
		  }
	}
}
示例#8
0
void ImplicitAnimation::animate(CompositeAnimation*, RenderObject*, RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle)
{
    // If we get this far and the animation is done, it means we are cleaning up a just finished animation.
    // So just return. Everything is already all cleaned up.
    if (postActive())
        return;

    // Reset to start the transition if we are new
    if (isNew())
        reset(targetStyle);

    // Run a cycle of animation.
    // We know we will need a new render style, so make one if needed
    if (!animatedStyle)
        animatedStyle = RenderStyle::clone(targetStyle);

    if (blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0)))
        setAnimating();

    // Fire the start timeout if needed
    fireAnimationEventsIfNeeded();
}
void KeyframeAnimation::animate(CompositeAnimation* animation, RenderObject* renderer, const RenderStyle* currentStyle, 
                                    const RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle)
{
    // If we have not yet started, we will not have a valid start time, so just start the animation if needed.
    if (isNew() && m_animation->playState() == AnimPlayStatePlaying)
        updateStateMachine(AnimationStateInputStartAnimation, -1);

    // If we get this far and the animation is done, it means we are cleaning up a just finished animation.
    // If so, we need to send back the targetStyle.
    if (postActive()) {
        if (!animatedStyle)
            animatedStyle = const_cast<RenderStyle*>(targetStyle);
        return;
    }

    // If we are waiting for the start timer, we don't want to change the style yet.
    // Special case - if the delay time is 0, then we do want to set the first frame of the
    // animation right away. This avoids a flash when the animation starts.
    if (waitingToStart() && m_animation->delay() > 0)
        return;

    // FIXME: we need to be more efficient about determining which keyframes we are animating between.
    // We should cache the last pair or something.

    // Find the first key
    double elapsedTime = (m_startTime > 0) ? ((!paused() ? currentTime() : m_pauseTime) - m_startTime) : 0;
    if (elapsedTime < 0)
        elapsedTime = 0;

    double t = m_animation->duration() ? (elapsedTime / m_animation->duration()) : 1;
    int i = static_cast<int>(t);
    t -= i;
    if (m_animation->direction() && (i & 1))
        t = 1 - t;

    const RenderStyle* fromStyle = 0;
    const RenderStyle* toStyle = 0;
    double scale = 1;
    double offset = 0;
    Vector<KeyframeValue>::const_iterator endKeyframes = m_keyframes.endKeyframes();
    for (Vector<KeyframeValue>::const_iterator it = m_keyframes.beginKeyframes(); it != endKeyframes; ++it) {
        if (t < it->key()) {
            // The first key should always be 0, so we should never succeed on the first key
            if (!fromStyle)
                break;
            scale = 1.0 / (it->key() - offset);
            toStyle = it->style();
            break;
        }

        offset = it->key();
        fromStyle = it->style();
    }

    // If either style is 0 we have an invalid case, just stop the animation.
    if (!fromStyle || !toStyle) {
        updateStateMachine(AnimationStateInputEndAnimation, -1);
        return;
    }

    // Run a cycle of animation.
    // We know we will need a new render style, so make one if needed.
    if (!animatedStyle)
        animatedStyle = RenderStyle::clone(targetStyle);

    const TimingFunction* timingFunction = 0;
    if (fromStyle->animations() && fromStyle->animations()->size() > 0)
        timingFunction = &(fromStyle->animations()->animation(0)->timingFunction());

    double prog = progress(scale, offset, timingFunction);

    HashSet<int>::const_iterator endProperties = m_keyframes.endProperties();
    for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) {
        if (blendProperties(this, *it, animatedStyle.get(), fromStyle, toStyle, prog))
            setAnimating();
    }
}