Index: Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp |
diff --git a/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp |
index baf4bd09222f76f2f765c980953084c19d8b515b..f4ba504991c6da6878cff5cdfd7b0e96fe96c296 100644 |
--- a/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp |
+++ b/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp |
@@ -392,20 +392,14 @@ public: |
if (m_needsRestart) { |
m_needsRestart = false; |
m_nextReadPosition = m_restartPosition; |
- } else if (m_lastSetByte != m_info.src->next_input_byte) { |
- // next_input_byte was updated by jpeg, meaning that it found a restart position. |
- m_restartPosition = m_nextReadPosition - m_info.src->bytes_in_buffer; |
+ } else { |
+ updateRestartPosition(); |
} |
const char* segment; |
const unsigned bytes = m_data->getSomeData(segment, m_nextReadPosition); |
if (bytes == 0) { |
- // We had to suspend. When we resume, we will need to start from the restart position. |
- m_needsRestart = true; |
- // Let libjpeg know that the buffer needs to be refilled. |
- m_info.src->bytes_in_buffer = 0; |
- m_info.src->next_input_byte = nullptr; |
- m_lastSetByte = nullptr; |
+ suspend(); |
return false; |
} |
@@ -531,6 +525,8 @@ public: |
} |
if (onlySize) { |
+ updateRestartPosition(); |
Peter Kasting
2015/09/19 00:51:34
You should probably have comments here about why y
scroggo_chromium
2015/09/21 18:21:28
Done.
(My instinct is include lots of comments, b
|
+ suspend(); |
return true; |
} |
// FALL THROUGH |
@@ -682,6 +678,24 @@ public: |
#endif |
private: |
+ void updateRestartPosition() |
+ { |
+ if (m_lastSetByte != m_info.src->next_input_byte) { |
+ // next_input_byte was updated by jpeg, meaning that it found a restart position. |
+ m_restartPosition = m_nextReadPosition - m_info.src->bytes_in_buffer; |
+ } |
+ } |
+ |
+ void suspend() |
+ { |
+ // We had to suspend. When we resume, we will need to start from the restart position. |
+ m_needsRestart = true; |
+ // Let libjpeg know that the buffer needs to be refilled. |
+ m_info.src->bytes_in_buffer = 0; |
+ m_info.src->next_input_byte = nullptr; |
+ m_lastSetByte = nullptr; |
+ } |
+ |
RefPtr<SharedBuffer> m_data; |
JPEGImageDecoder* m_decoder; |
// True if we need to back up to m_restartPosition. |