aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/gif
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/gif')
-rw-r--r--third_party/gif/SkGifImageReader.cpp30
-rw-r--r--third_party/gif/SkGifImageReader.h4
2 files changed, 14 insertions, 20 deletions
diff --git a/third_party/gif/SkGifImageReader.cpp b/third_party/gif/SkGifImageReader.cpp
index e76028dac9..e3b225dda7 100644
--- a/third_party/gif/SkGifImageReader.cpp
+++ b/third_party/gif/SkGifImageReader.cpp
@@ -420,17 +420,15 @@ bool SkGifImageReader::decode(int frameIndex, bool* frameComplete)
}
// Parse incoming GIF data stream into internal data structures.
-// Return true if parsing has progressed or there is not enough data.
-// Return false if a fatal error is encountered.
-bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
+SkCodec::Result SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
{
if (m_parseCompleted) {
- return true;
+ return SkCodec::kSuccess;
}
if (SkGIFLoopCountQuery == query && m_loopCount != cLoopCountNotSeen) {
// Loop count has already been parsed.
- return true;
+ return SkCodec::kSuccess;
}
// SkGIFSizeQuery and SkGIFFrameCountQuery are negative, so this is only meaningful when >= 0.
@@ -438,13 +436,13 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
if (lastFrameToParse >= 0 && (int) m_frames.size() > lastFrameToParse
&& m_frames[lastFrameToParse]->isComplete()) {
// We have already parsed this frame.
- return true;
+ return SkCodec::kSuccess;
}
while (true) {
if (!m_streamBuffer.buffer(m_bytesToConsume)) {
// The stream does not yet have enough data.
- return true;
+ return SkCodec::kIncompleteInput;
}
switch (m_state) {
@@ -475,7 +473,7 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
else {
// This prevents attempting to continue reading this invalid stream.
GETN(0, SkGIFDone);
- return false;
+ return SkCodec::kInvalidInput;
}
GETN(7, SkGIFGlobalHeader);
break;
@@ -687,7 +685,7 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
if (SkGIFLoopCountQuery == query) {
m_streamBuffer.flush();
- return true;
+ return SkCodec::kSuccess;
}
} else if (netscapeExtension == 2) {
// Wait for specified # of bytes to enter buffer.
@@ -700,7 +698,7 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
// 0,3-7 are yet to be defined netscape extension codes
// This prevents attempting to continue reading this invalid stream.
GETN(0, SkGIFDone);
- return false;
+ return SkCodec::kInvalidInput;
}
break;
}
@@ -748,7 +746,7 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
if (!height || !width) {
// This prevents attempting to continue reading this invalid stream.
GETN(0, SkGIFDone);
- return false;
+ return SkCodec::kInvalidInput;
}
}
@@ -778,7 +776,7 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
// The decoder needs to stop, so we return here, before
// flushing the buffer. Next time through, we'll be in the same
// state, requiring the same amount in the buffer.
- return true;
+ return SkCodec::kSuccess;
}
@@ -830,7 +828,7 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
GETN(1, SkGIFImageStart);
if (lastFrameToParse >= 0 && (int) m_frames.size() > lastFrameToParse) {
m_streamBuffer.flush();
- return true;
+ return SkCodec::kSuccess;
}
}
break;
@@ -838,20 +836,18 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
case SkGIFDone: {
m_parseCompleted = true;
- return true;
+ return SkCodec::kSuccess;
}
default:
// We shouldn't ever get here.
// This prevents attempting to continue reading this invalid stream.
GETN(0, SkGIFDone);
- return false;
+ return SkCodec::kInvalidInput;
break;
} // switch
m_streamBuffer.flush();
}
-
- return true;
}
bool SkGifImageReader::hasTransparency(int transparentPixel, bool isLocalColormapDefined,
diff --git a/third_party/gif/SkGifImageReader.h b/third_party/gif/SkGifImageReader.h
index 49655c23df..0b89b04818 100644
--- a/third_party/gif/SkGifImageReader.h
+++ b/third_party/gif/SkGifImageReader.h
@@ -312,9 +312,7 @@ public:
// Parse incoming GIF data stream into internal data structures.
// Non-negative values are used to indicate to parse through that frame.
- // Return true if parsing has progressed or there is not enough data.
- // Return false if a fatal error is encountered.
- bool parse(SkGIFParseQuery);
+ SkCodec::Result parse(SkGIFParseQuery);
// Decode the frame indicated by frameIndex.
// frameComplete will be set to true if the frame is completely decoded.