Index: src/codec/SkGifCodec.cpp |
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp |
index cbe87938b1bb15ac9a748dc41f465faa5f84825e..46b8beee163d7c18d5bdbd358fc741377b17f7f5 100644 |
--- a/src/codec/SkGifCodec.cpp |
+++ b/src/codec/SkGifCodec.cpp |
@@ -266,7 +266,7 @@ SkGifCodec::SkGifCodec(int width, int height, const SkEncodedInfo& info, SkStrea |
const SavedImage* image = &gif->SavedImages[i]; |
const GifImageDesc& desc = image->ImageDesc; |
- auto& frame = fFrameInfos.push_back(); |
+ auto& frame = fFrameInfos[i]; |
// FIXME: Probably want to intersect this with the bounds, just in case. |
// But then we'll need to make sure we draw the right thing... |
// i.e. if the top is cut off (desc.Top < 0), we want to start off drawing line -desc.Top |
@@ -307,20 +307,19 @@ SkGifCodec::SkGifCodec(int width, int height, const SkEncodedInfo& info, SkStrea |
} |
} |
-size_t SkGifCodec::onGetRequiredFrame(size_t index) { |
- if ((int) index >= fFrameInfos.count()) { |
- return kIndependentFrame; |
+std::vector<SkCodec::FrameInfo> SkGifCodec::onGetFrameInfo() { |
+ const size_t size = fFrameInfos.size(); |
+ if (1 == size) { |
+ // As with other formats, return empty set for non-animated |
+ // FIXME: But it might be animated, we just haven't received the second frame? |
+ // I suppose we could check the duration? But even that might not be perfect... |
+ return {}; |
} |
- |
- return fFrameInfos[index].fRequiredFrame; |
-} |
- |
-size_t SkGifCodec::onGetFrameDuration(size_t index) { |
- if ((int) index >= fFrameInfos.count()) { |
- return 0; |
+ std::vector<FrameInfo> result(size); |
+ for (size_t i = 0; i < size; i++) { |
+ result[i] = (FrameInfo) fFrameInfos[i]; |
} |
- |
- return fFrameInfos[index].fDuration; |
+ return result; |
} |
bool SkGifCodec::GetDimensions(GifFileType* gif, SkISize* size) { |
@@ -428,7 +427,7 @@ SkCodec::Result SkGifCodec::prepareToDecode(const SkImageInfo& dstInfo, SkPMColo |
kInvalidConversion); |
} |
- if (opts.fFrameOptions && (int) opts.fFrameOptions->fIndex > fFrameInfos.count()) { |
+ if (opts.fFrameOptions && opts.fFrameOptions->fIndex > fFrameInfos.size()) { |
return gif_error("frame index out of range!\n", kInvalidParameters); |
} |
@@ -466,7 +465,7 @@ void SkGifCodec::decodeFrame(const SkImageInfo& dstInfo, void* pixels, size_t ds |
void* dst = pixels; |
const size_t frameIndex = opts.fFrameOptions ? opts.fFrameOptions->fIndex : 0; |
- SkASSERT((int) frameIndex < fFrameInfos.count()); |
+ SkASSERT(frameIndex < fFrameInfos.size()); |
const auto& frameInfo = fFrameInfos[frameIndex]; |
const SkIRect& frameRect = frameInfo.fFrameRect; |
const bool independent = frameInfo.fRequiredFrame == kIndependentFrame; |