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/SkCodec.cpp b/src/codec/SkCodec.cpp
index 533cef5..98a6846 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -765,6 +765,20 @@
}
}
+void SkFrame::fillIn(SkCodec::FrameInfo* frameInfo, bool fullyReceived) const {
+ SkASSERT(frameInfo);
+
+ frameInfo->fRequiredFrame = fRequiredFrame;
+ frameInfo->fDuration = fDuration;
+ frameInfo->fFullyReceived = fullyReceived;
+ frameInfo->fAlphaType = fHasAlpha ? kUnpremul_SkAlphaType
+ : kOpaque_SkAlphaType;
+ frameInfo->fHasAlphaWithinBounds = this->reportedAlpha() != SkEncodedInfo::kOpaque_Alpha;
+ frameInfo->fDisposalMethod = fDisposalMethod;
+ frameInfo->fBlend = fBlend;
+ frameInfo->fFrameRect = fRect;
+}
+
static bool independent(const SkFrame& frame) {
return frame.getRequiredFrame() == SkCodec::kNoFrame;
}
@@ -828,7 +842,7 @@
}
- const bool blendWithPrevFrame = frame->getBlend() == SkCodecAnimation::Blend::kPriorFrame;
+ const bool blendWithPrevFrame = frame->getBlend() == SkCodecAnimation::Blend::kSrcOver;
if ((!reportsAlpha || !blendWithPrevFrame) && frameRect == screenRect) {
frame->setHasAlpha(reportsAlpha);
frame->setRequiredFrame(SkCodec::kNoFrame); // IND2