diff options
author | Leon Scroggins III <scroggo@google.com> | 2017-04-12 10:49:52 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-12 15:22:43 +0000 |
commit | e132e7be5f9108692254c37db592ea7611abbc15 (patch) | |
tree | 44e7973680edc107da087f71d41619dd3aea178e /src/codec/SkCodec.cpp | |
parent | e5efa51b2acc86d1993132348d5b465855a653cc (diff) |
Add SkCodec methods for individual frames
Add a version of getFrameInfo that returns information about a single
frame, allowing a client to skip creating the entire vector.
Add getFrameCount, for determining the number of frames in the image.
Reimplement std::vector<FrameInfo> getFrameInfo with the new methods.
Updates to the test:
- getFrameInfo(size_t, FrameInfo*) fails before parsing
- Test both versions of getFrameInfo
- Recreate the codec between tests, to test parsing
Change-Id: I77c19087f2f8dcf2c536d80167b18ad1ca96ae94
Reviewed-on: https://skia-review.googlesource.com/13190
Reviewed-by: Matt Sarett <msarett@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Chris Blume <cblume@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkCodec.cpp')
-rw-r--r-- | src/codec/SkCodec.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp index 5bdb3e2b59..6a6fdc78c9 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -489,3 +489,24 @@ bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, return true; } + +std::vector<SkCodec::FrameInfo> SkCodec::getFrameInfo() { + const size_t frameCount = this->getFrameCount(); + switch (frameCount) { + case 0: + return std::vector<FrameInfo>{}; + case 1: + if (!this->onGetFrameInfo(0, nullptr)) { + // Not animated. + return std::vector<FrameInfo>{}; + } + // fall through + default: { + std::vector<FrameInfo> result(frameCount); + for (size_t i = 0; i < frameCount; ++i) { + SkAssertResult(this->onGetFrameInfo(i, &result[i])); + } + return result; + } + } +} |