aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/gif
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-06-07 12:31:51 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-07 20:15:17 +0000
commit33deb7ed4d583c88187ba240efb749e9a1fd6843 (patch)
treecf70e6f7dbd360853b84e16d586f5b8811b68c8f /third_party/gif
parent9982c4eb76af58e18df2cd3dd81913439f1b6157 (diff)
Make SkCodec more flexible about its required frame
SkCodec sets fRequiredFrame to be the earliest possible frame that a given frame can depend on. e.g. - Frame A fills the screen, Keep - Frame B does not cover A, Keep - Frame C covers B but not A, and is opaque Frame C can depend on either A or B. SkCodec already reports that C depends on A. This CL allows a client of SkCodec to use either A or B to create C. Also expose the DisposalMethod. Since any frame between A and C can be used to create C except for DisposePrevious frames, the client needs to be able to know the disposal method so they do not try to use such a frame to create C. Further, the disposal method can be used to give the client a better idea whether they will continue to need a frame. (e.g. if frame i is DisposePrevious and depends on i-1, the client may not want to steal i-1 to create i, since i+1 may also depend on i-1.) TODO: Share code for decoding prior frames between GIF and WEBP Change-Id: I91a5ae22ba3d8dfbe0bde833fa67ae3da0d81ed6 Reviewed-on: https://skia-review.googlesource.com/13722 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'third_party/gif')
-rw-r--r--third_party/gif/SkGifImageReader.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/third_party/gif/SkGifImageReader.cpp b/third_party/gif/SkGifImageReader.cpp
index 0666fedbc8..76f3edcef0 100644
--- a/third_party/gif/SkGifImageReader.cpp
+++ b/third_party/gif/SkGifImageReader.cpp
@@ -616,11 +616,11 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
case 4:
// Some specs say that disposal method 3 is "overwrite previous", others that setting
// the third bit of the field (i.e. method 4) is. We map both to the same value.
- currentFrame->setDisposalMethod(SkCodecAnimation::RestorePrevious_DisposalMethod);
+ currentFrame->setDisposalMethod(SkCodecAnimation::DisposalMethod::kRestorePrevious);
break;
default:
// Other values use the default.
- currentFrame->setDisposalMethod(SkCodecAnimation::Keep_DisposalMethod);
+ currentFrame->setDisposalMethod(SkCodecAnimation::DisposalMethod::kKeep);
break;
}
currentFrame->setDuration(GETINT16(currentComponent + 1) * 10);
@@ -903,7 +903,7 @@ static bool independent(const SkFrame& frame) {
}
static bool restore_bg(const SkFrame& frame) {
- return frame.getDisposalMethod() == SkCodecAnimation::RestoreBGColor_DisposalMethod;
+ return frame.getDisposalMethod() == SkCodecAnimation::DisposalMethod::kRestoreBGColor;
}
bool SkGIFFrameContext::onReportsAlpha() const {
@@ -935,7 +935,7 @@ void SkFrameHolder::setAlphaAndRequiredFrame(SkFrame* frame) {
}
const SkFrame* prevFrame = this->getFrame(i-1);
- while (prevFrame->getDisposalMethod() == SkCodecAnimation::RestorePrevious_DisposalMethod) {
+ while (prevFrame->getDisposalMethod() == SkCodecAnimation::DisposalMethod::kRestorePrevious) {
const int prevId = prevFrame->frameId();
if (0 == prevId) {
frame->setHasAlpha(true);
@@ -992,7 +992,7 @@ void SkFrameHolder::setAlphaAndRequiredFrame(SkFrame* frame) {
return;
}
- SkASSERT(prevFrame->getDisposalMethod() == SkCodecAnimation::Keep_DisposalMethod);
+ SkASSERT(prevFrame->getDisposalMethod() == SkCodecAnimation::DisposalMethod::kKeep);
frame->setRequiredFrame(prevFrame->frameId());
frame->setHasAlpha(prevFrame->hasAlpha() || (reportsAlpha && !blendWithPrevFrame));
}