Expose more info in SkCodec::FrameInfo
Bug: b/160984428
Add more fields to SkCodec::FrameInfo, which describes the properties of
an individual frame in an animated image. This allows a client that
wishes to seek to determine frame dependencies so that they can decode
an arbitrary frame, which in turn will allow SkCodec to remove
SkCodec::FrameInfo::fRequiredFrame. Currently, SkCodec seeks through the
stream to determine frame dependencies, but this is unnecessary work
(and storage) for a client that does not want to seek.
These fields also support the proposed APIs in go/animated-ndk.
Move SkCodecAnimation::Blend from SkCodecAnimationPriv (and delete that
file) into SkCodecAnimation.h. Rename its values to be more clear.
Merge common code for populating SkCodec::FrameInfo.
Add a test for a GIF with offsets outside the range of the image. Note
that libwebp rejects such an image.
Update libgifcodec.
Change-Id: Ie27e0531e7d62eaae153eccb3105bf2121b5aac4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339857
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Nigel Tao <nigeltao@google.com>
diff --git a/src/codec/SkWuffsCodec.cpp b/src/codec/SkWuffsCodec.cpp
index 4fd2a04..8b828b2 100644
--- a/src/codec/SkWuffsCodec.cpp
+++ b/src/codec/SkWuffsCodec.cpp
@@ -156,7 +156,6 @@
public:
SkWuffsFrame(wuffs_base__frame_config* fc);
- SkCodec::FrameInfo frameInfo(bool fullyReceived) const;
uint64_t ioPosition() const;
// SkFrame overrides.
@@ -332,18 +331,8 @@
this->setXYWH(r.min_incl_x, r.min_incl_y, r.width(), r.height());
this->setDisposalMethod(wuffs_disposal_to_skia_disposal(fc->disposal()));
this->setDuration(fc->duration() / WUFFS_BASE__FLICKS_PER_MILLISECOND);
- this->setBlend(fc->overwrite_instead_of_blend() ? SkCodecAnimation::Blend::kBG
- : SkCodecAnimation::Blend::kPriorFrame);
-}
-
-SkCodec::FrameInfo SkWuffsFrame::frameInfo(bool fullyReceived) const {
- SkCodec::FrameInfo ret;
- ret.fRequiredFrame = getRequiredFrame();
- ret.fDuration = getDuration();
- ret.fFullyReceived = fullyReceived;
- ret.fAlphaType = hasAlpha() ? kUnpremul_SkAlphaType : kOpaque_SkAlphaType;
- ret.fDisposalMethod = getDisposalMethod();
- return ret;
+ this->setBlend(fc->overwrite_instead_of_blend() ? SkCodecAnimation::Blend::kSrc
+ : SkCodecAnimation::Blend::kSrcOver);
}
uint64_t SkWuffsFrame::ioPosition() const {
@@ -854,7 +843,7 @@
return false;
}
if (frameInfo) {
- *frameInfo = f->frameInfo(static_cast<uint64_t>(i) < this->fNumFullyReceivedFrames);
+ f->fillIn(frameInfo, static_cast<uint64_t>(i) < this->fNumFullyReceivedFrames);
}
return true;
}