Esempio n. 1
0
void
AnimationDecodingTask::Run()
{
  while (true) {
    LexerResult result = mDecoder->Decode(WrapNotNull(this));

    if (result.is<TerminalState>()) {
      NotifyDecodeComplete(mDecoder->GetImage(), mDecoder);
      return;  // We're done.
    }

    MOZ_ASSERT(result.is<Yield>());

    // Notify for the progress we've made so far.
    if (mDecoder->HasProgress()) {
      NotifyProgress(mDecoder->GetImage(), mDecoder);
    }

    if (result == LexerResult(Yield::NEED_MORE_DATA)) {
      // We can't make any more progress right now. The decoder itself will
      // ensure that we get reenqueued when more data is available; just return
      // for now.
      return;
    }

    // Right now we don't do anything special for other kinds of yields, so just
    // keep working.
  }
}
Esempio n. 2
0
void
MetadataDecodingTask::Run()
{
  nsresult rv = mDecoder->Decode(WrapNotNull(this));

  if (NS_SUCCEEDED(rv) && !mDecoder->GetDecodeDone()) {
    // It's important that metadata decode results are delivered atomically, so
    // we'll wait until NotifyDecodeComplete() to report any progress.  We don't
    // need to do anything else for this case. The decoder itself will ensure
    // that we get reenqueued when more data is available.
    return;
  }

  NotifyDecodeComplete(mDecoder);
}
Esempio n. 3
0
void
DecodingTask::Run()
{
  nsresult rv = mDecoder->Decode(WrapNotNull(this));

  if (NS_SUCCEEDED(rv) && !mDecoder->GetDecodeDone()) {
    // Notify for the progress we've made so far.
    if (mDecoder->HasProgress()) {
      NotifyProgress(mDecoder);
    }

    // We don't need to do anything else for this case. The decoder itself will
    // ensure that we get reenqueued when more data is available.
    return;
  }

  NotifyDecodeComplete(mDecoder);
}
Esempio n. 4
0
void
MetadataDecodingTask::Run()
{
  LexerResult result = mDecoder->Decode(WrapNotNull(this));

  if (result.is<TerminalState>()) {
    NotifyDecodeComplete(mDecoder->GetImage(), mDecoder);
    return;  // We're done.
  }

  if (result == LexerResult(Yield::NEED_MORE_DATA)) {
    // We can't make any more progress right now. We also don't want to report
    // any progress, because it's important that metadata decode results are
    // delivered atomically. The decoder itself will ensure that we get
    // reenqueued when more data is available; just return for now.
    return;
  }

  MOZ_ASSERT_UNREACHABLE("Metadata decode yielded for an unexpected reason");
}
void
AnimationSurfaceProvider::FinishDecoding()
{
  mDecodingMutex.AssertCurrentThreadOwns();
  MOZ_ASSERT(mImage);
  MOZ_ASSERT(mDecoder);

  // Send notifications.
  NotifyDecodeComplete(WrapNotNull(mImage), WrapNotNull(mDecoder));

  // Destroy our decoder; we don't need it anymore.
  mDecoder = nullptr;

  // We don't need a reference to our image anymore, either, and we don't want
  // one. We may be stored in the surface cache for a long time after decoding
  // finishes. If we don't drop our reference to the image, we'll end up
  // keeping it alive as long as we remain in the surface cache, which could
  // greatly extend the image's lifetime - in fact, if the image isn't
  // discardable, it'd result in a leak!
  DropImageReference();
}