예제 #1
0
void InterpolationEffect::getActiveInterpolations(
    double fraction,
    double iterationDuration,
    Vector<RefPtr<Interpolation>>& result) const {
  size_t existingSize = result.size();
  size_t resultIndex = 0;

  for (const auto& record : m_interpolations) {
    if (fraction >= record.m_applyFrom && fraction < record.m_applyTo) {
      RefPtr<Interpolation> interpolation = record.m_interpolation;
      double recordLength = record.m_end - record.m_start;
      double localFraction =
          recordLength ? (fraction - record.m_start) / recordLength : 0.0;
      if (record.m_easing)
        localFraction = record.m_easing->evaluate(
            localFraction, accuracyForDuration(iterationDuration));
      interpolation->interpolate(0, localFraction);
      if (resultIndex < existingSize)
        result[resultIndex++] = interpolation;
      else
        result.append(interpolation);
    }
  }
  if (resultIndex < existingSize)
    result.shrink(resultIndex);
}
예제 #2
0
double AnimationBase::progress(double scale, double offset, const TimingFunction* timingFunction) const
{
    if (preActive())
        return 0;

    double dur = m_animation->duration();
    if (m_animation->iterationCount() > 0)
        dur *= m_animation->iterationCount();

    if (postActive() || !m_animation->duration())
        return 1.0;

    double elapsedTime = getElapsedTime();
    if (m_animation->iterationCount() > 0 && elapsedTime >= dur) {
        const int integralIterationCount = static_cast<int>(m_animation->iterationCount());
        const bool iterationCountHasFractional = m_animation->iterationCount() - integralIterationCount;
        return (integralIterationCount % 2 || iterationCountHasFractional) ? 1.0 : 0.0;
    }

    const double fractionalTime = this->fractionalTime(scale, elapsedTime, offset);

    if (!timingFunction)
        timingFunction = m_animation->timingFunction();

    return timingFunction->evaluate(fractionalTime, accuracyForDuration(m_animation->duration()));
}
예제 #3
0
PassOwnPtr<Vector<RefPtr<Interpolation> > > InterpolationEffect::getActiveInterpolations(double fraction, double iterationDuration) const
{

    Vector<RefPtr<Interpolation> >* result = new Vector<RefPtr<Interpolation> >();

    for (size_t i = 0; i < m_interpolations.size(); ++i) {
        const InterpolationRecord* record = m_interpolations[i].get();
        if (fraction >= record->m_applyFrom && fraction < record->m_applyTo) {
            RefPtr<Interpolation> interpolation = record->m_interpolation;
            double localFraction = (fraction - record->m_start) / (record->m_end - record->m_start);
            if (record->m_easing)
                localFraction = record->m_easing->evaluate(localFraction, accuracyForDuration(iterationDuration));
            interpolation->interpolate(0, localFraction);
            result->append(interpolation);
        }
    }

    return adoptPtr(result);
}
void InterpolationEffect::getActiveInterpolations(double fraction, double iterationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>& result) const
{
    if (!result)
        result = adoptPtrWillBeNoop(new WillBeHeapVector<RefPtrWillBeMember<Interpolation>>());

    size_t existingSize = result->size();
    size_t resultIndex = 0;

    for (const auto& record : m_interpolations) {
        if (fraction >= record->m_applyFrom && fraction < record->m_applyTo) {
            RefPtrWillBeRawPtr<Interpolation> interpolation = record->m_interpolation;
            double localFraction = (fraction - record->m_start) / (record->m_end - record->m_start);
            if (record->m_easing)
                localFraction = record->m_easing->evaluate(localFraction, accuracyForDuration(iterationDuration));
            interpolation->interpolate(0, localFraction);
            if (resultIndex < existingSize)
                (*result)[resultIndex++] = interpolation;
            else
                result->append(interpolation);
        }
    }
    if (resultIndex < existingSize)
        result->shrink(resultIndex);
}