Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Unified Diff: gm/animatedGif.cpp

Issue 2045293002: Add support for multiple frames in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Return metadata in a vector Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/codec/SkCodec.h » ('j') | include/codec/SkCodec.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/animatedGif.cpp
diff --git a/gm/animatedGif.cpp b/gm/animatedGif.cpp
index 4ec70255628853e9a6c0fa7e55ee9959f407e108..3ee00a5fc4f7b749297564e3c9dfe23e9e625994 100644
--- a/gm/animatedGif.cpp
+++ b/gm/animatedGif.cpp
@@ -33,11 +33,12 @@ namespace {
class AnimatedGifGM : public skiagm::GM {
private:
- std::unique_ptr<SkCodec> fCodec;
- size_t fFrame;
- double fNextUpdate;
- size_t fTotalFrames;
- std::vector<SkBitmap> fFrames;
+ std::unique_ptr<SkCodec> fCodec;
+ size_t fFrame;
+ double fNextUpdate;
+ size_t fTotalFrames;
+ std::vector<SkCodec::FrameInfo> fFrameInfos;
+ std::vector<SkBitmap> fFrames;
void drawBounds(SkCanvas* canvas) {
if (!fCodec) {
@@ -62,7 +63,7 @@ private:
SkCodec::MultiFrameOptions multiOpts;
multiOpts.fIndex = frameIndex;
multiOpts.fHasPriorFrame = false;
- const size_t requiredFrame = fCodec->getRequiredFrame(frameIndex);
+ const size_t requiredFrame = fFrameInfos[frameIndex].fRequiredFrame;
if (requiredFrame != SkCodec::kIndependentFrame) {
SkASSERT(requiredFrame < fFrames.size());
SkBitmap& requiredBitmap = fFrames[requiredFrame];
@@ -100,7 +101,7 @@ private:
if (this->initCodec()) {
SkISize dim = fCodec->getInfo().dimensions();
// Wide enough to display all the frames.
- dim.fWidth *= fCodec->getFrameCount();
+ dim.fWidth *= fTotalFrames;
// Tall enough to show the row of frames plus an animating version.
dim.fHeight *= 2;
return dim;
@@ -142,7 +143,8 @@ private:
}
fFrame = 0;
- fTotalFrames = fCodec->getFrameCount();
+ fFrameInfos = fCodec->getFrameInfo();
+ fTotalFrames = fFrameInfos.size();
return true;
}
@@ -171,7 +173,7 @@ private:
// I'm assuming this gets called *after* onOnceBeforeDraw, so our first frame should
// already have been retrieved.
SkASSERT(fFrame == 0);
- fNextUpdate = secs + fCodec->getFrameDuration(fFrame);
+ fNextUpdate = secs + fFrameInfos[fFrame].fDuration;
return true;
}
@@ -189,7 +191,7 @@ private:
// Note that we loop here. This is not safe if we need to draw the intermediate frame
// in order to draw correctly.
- fNextUpdate += fCodec->getFrameDuration(fFrame);
+ fNextUpdate += fFrameInfos[fFrame].fDuration;
}
return true;
« no previous file with comments | « no previous file | include/codec/SkCodec.h » ('j') | include/codec/SkCodec.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698