未验证 提交 b0370c13 编写于 作者: M Michael Klimushyn 提交者: GitHub

Decode using the last cached required frame (#7715)

`MultiFrameCodec` now uses whatever previously cached required frame is
available instead of panicking if it doesn't have the exact frame
requested by `SkCodec::FrameInfo#fRequiredFrame`.

`SkCodec::FrameInfo#fRequiredFrame` doesn't point to the one and only
frame that's required to decode the given frame. It points to the latest
frame that's disposal method none and filling a greater surface area
than the current frame. The last required frame `MultiFrameCodec` has
actually cached is also valid in these cases and can be supplied as
`fPriorFrame` instead. [flutter/flutter#26757](https://github.com/flutter/flutter/issues/26757#issuecomment-459522530)
has a more detailed explanation.

Fixes flutter/flutter#26757
上级 4f3eb42d
......@@ -408,11 +408,15 @@ sk_sp<SkImage> MultiFrameCodec::GetNextFrameImage(
options.fFrameIndex = nextFrameIndex_;
const int requiredFrameIndex = frameInfos_[nextFrameIndex_].fRequiredFrame;
if (requiredFrameIndex != SkCodec::kNoFrame) {
if (lastRequiredFrame_ == nullptr ||
lastRequiredFrameIndex_ != requiredFrameIndex) {
if (lastRequiredFrame_ == nullptr) {
FML_LOG(ERROR) << "Frame " << nextFrameIndex_ << " depends on frame "
<< requiredFrameIndex << " which has not been cached.";
<< requiredFrameIndex
<< " and no required frames are cached.";
return NULL;
} else if (lastRequiredFrameIndex_ != requiredFrameIndex) {
FML_DLOG(INFO) << "Required frame " << requiredFrameIndex
<< " is not cached. Using " << lastRequiredFrameIndex_
<< " instead";
}
if (lastRequiredFrame_->getPixels() &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册