| 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 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 9 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 10 * | 10 * |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 void skipBytes(long numBytes) | 172 void skipBytes(long numBytes) |
| 173 { | 173 { |
| 174 decoder_source_mgr* src = (decoder_source_mgr*)m_info.src; | 174 decoder_source_mgr* src = (decoder_source_mgr*)m_info.src; |
| 175 long bytesToSkip = std::min(numBytes, (long)src->pub.bytes_in_buffer); | 175 long bytesToSkip = std::min(numBytes, (long)src->pub.bytes_in_buffer); |
| 176 src->pub.bytes_in_buffer -= (size_t)bytesToSkip; | 176 src->pub.bytes_in_buffer -= (size_t)bytesToSkip; |
| 177 src->pub.next_input_byte += bytesToSkip; | 177 src->pub.next_input_byte += bytesToSkip; |
| 178 | 178 |
| 179 m_bytesToSkip = std::max(numBytes - bytesToSkip, static_cast<long>(0)); | 179 m_bytesToSkip = std::max(numBytes - bytesToSkip, static_cast<long>(0)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool decode(const Vector<char>& data, bool onlySize) | 182 bool decode(const SharedBuffer& data, bool onlySize) |
| 183 { | 183 { |
| 184 m_decodingSizeOnly = onlySize; | 184 m_decodingSizeOnly = onlySize; |
| 185 | 185 |
| 186 unsigned newByteCount = data.size() - m_bufferLength; | 186 unsigned newByteCount = data.size() - m_bufferLength; |
| 187 unsigned readOffset = m_bufferLength - m_info.src->bytes_in_buffer; | 187 unsigned readOffset = m_bufferLength - m_info.src->bytes_in_buffer; |
| 188 | 188 |
| 189 m_info.src->bytes_in_buffer += newByteCount; | 189 m_info.src->bytes_in_buffer += newByteCount; |
| 190 m_info.src->next_input_byte = (JOCTET*)(data.data()) + readOffset; | 190 m_info.src->next_input_byte = (JOCTET*)(data.data()) + readOffset; |
| 191 | 191 |
| 192 // If we still have bytes to skip, try to skip those now. | 192 // If we still have bytes to skip, try to skip those now. |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 void JPEGImageDecoder::decode(bool onlySize) | 519 void JPEGImageDecoder::decode(bool onlySize) |
| 520 { | 520 { |
| 521 if (failed()) | 521 if (failed()) |
| 522 return; | 522 return; |
| 523 | 523 |
| 524 if (!m_reader) | 524 if (!m_reader) |
| 525 m_reader.set(new JPEGImageReader(this)); | 525 m_reader.set(new JPEGImageReader(this)); |
| 526 | 526 |
| 527 // If we couldn't decode the image but we've received all the data, decoding | 527 // If we couldn't decode the image but we've received all the data, decoding |
| 528 // has failed. | 528 // has failed. |
| 529 if (!m_reader->decode(m_data->buffer(), onlySize) && isAllDataReceived()) | 529 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) |
| 530 setFailed(); | 530 setFailed(); |
| 531 // If we're done decoding the image, we don't need the JPEGImageReader | 531 // If we're done decoding the image, we don't need the JPEGImageReader |
| 532 // anymore. (If we failed, |m_reader| has already been cleared.) | 532 // anymore. (If we failed, |m_reader| has already been cleared.) |
| 533 else if (!m_frameBufferCache.isEmpty() && (m_frameBufferCache[0].status() ==
ImageFrame::FrameComplete)) | 533 else if (!m_frameBufferCache.isEmpty() && (m_frameBufferCache[0].status() ==
ImageFrame::FrameComplete)) |
| 534 m_reader.clear(); | 534 m_reader.clear(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 } | 537 } |
| OLD | NEW |