OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
3 * | 3 * |
4 * Portions are Copyright (C) 2001-6 mozilla.org | 4 * Portions are Copyright (C) 2001-6 mozilla.org |
5 * | 5 * |
6 * Other contributors: | 6 * Other contributors: |
7 * Stuart Parmenter <stuart@mozilla.com> | 7 * Stuart Parmenter <stuart@mozilla.com> |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 bool fillBuffer() | 371 bool fillBuffer() |
372 { | 372 { |
373 if (m_needsRestart) { | 373 if (m_needsRestart) { |
374 m_needsRestart = false; | 374 m_needsRestart = false; |
375 m_nextReadPosition = m_restartPosition; | 375 m_nextReadPosition = m_restartPosition; |
376 } else { | 376 } else { |
377 updateRestartPosition(); | 377 updateRestartPosition(); |
378 } | 378 } |
379 | 379 |
380 const char* segment; | 380 const char* segment; |
381 const unsigned bytes = m_data->getSomeData(segment, m_nextReadPosition); | 381 const size_t bytes = m_data->getSomeData(segment, m_nextReadPosition); |
382 if (bytes == 0) { | 382 if (bytes == 0) { |
383 // We had to suspend. When we resume, we will need to start from the
restart position. | 383 // We had to suspend. When we resume, we will need to start from the
restart position. |
384 m_needsRestart = true; | 384 m_needsRestart = true; |
385 clearBuffer(); | 385 clearBuffer(); |
386 return false; | 386 return false; |
387 } | 387 } |
388 | 388 |
389 m_nextReadPosition += bytes; | 389 m_nextReadPosition += bytes; |
390 m_info.src->bytes_in_buffer = bytes; | 390 m_info.src->bytes_in_buffer = bytes; |
391 const JOCTET* nextByte = reinterpret_cast_ptr<const JOCTET*>(segment); | 391 const JOCTET* nextByte = reinterpret_cast_ptr<const JOCTET*>(segment); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 m_info.src->next_input_byte = nullptr; | 699 m_info.src->next_input_byte = nullptr; |
700 m_lastSetByte = nullptr; | 700 m_lastSetByte = nullptr; |
701 } | 701 } |
702 | 702 |
703 RefPtr<SharedBuffer> m_data; | 703 RefPtr<SharedBuffer> m_data; |
704 JPEGImageDecoder* m_decoder; | 704 JPEGImageDecoder* m_decoder; |
705 | 705 |
706 // Input reading: True if we need to back up to m_restartPosition. | 706 // Input reading: True if we need to back up to m_restartPosition. |
707 bool m_needsRestart; | 707 bool m_needsRestart; |
708 // If libjpeg needed to restart, this is the position to restart from. | 708 // If libjpeg needed to restart, this is the position to restart from. |
709 unsigned m_restartPosition; | 709 size_t m_restartPosition; |
710 // This is the position where we will read from, unless there is a restart. | 710 // This is the position where we will read from, unless there is a restart. |
711 unsigned m_nextReadPosition; | 711 size_t m_nextReadPosition; |
712 // This is how we know to update the restart position. It is the last value | 712 // This is how we know to update the restart position. It is the last value |
713 // we set to next_input_byte. libjpeg will update next_input_byte when it | 713 // we set to next_input_byte. libjpeg will update next_input_byte when it |
714 // has found the next restart position, so if it no longer matches this | 714 // has found the next restart position, so if it no longer matches this |
715 // value, we know we've reached the next restart position. | 715 // value, we know we've reached the next restart position. |
716 const JOCTET* m_lastSetByte; | 716 const JOCTET* m_lastSetByte; |
717 | 717 |
718 jpeg_decompress_struct m_info; | 718 jpeg_decompress_struct m_info; |
719 decoder_error_mgr m_err; | 719 decoder_error_mgr m_err; |
720 decoder_source_mgr m_src; | 720 decoder_source_mgr m_src; |
721 jstate m_state; | 721 jstate m_state; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 // has failed. | 1070 // has failed. |
1071 if (!m_reader->decode(onlySize) && isAllDataReceived()) | 1071 if (!m_reader->decode(onlySize) && isAllDataReceived()) |
1072 setFailed(); | 1072 setFailed(); |
1073 | 1073 |
1074 // If decoding is done or failed, we don't need the JPEGImageReader anymore. | 1074 // If decoding is done or failed, we don't need the JPEGImageReader anymore. |
1075 if (isComplete(this, onlySize) || failed()) | 1075 if (isComplete(this, onlySize) || failed()) |
1076 m_reader.clear(); | 1076 m_reader.clear(); |
1077 } | 1077 } |
1078 | 1078 |
1079 } | 1079 } |
OLD | NEW |