| 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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 | 967 |
| 968 void JPEGImageDecoder::complete() | 968 void JPEGImageDecoder::complete() |
| 969 { | 969 { |
| 970 if (m_frameBufferCache.isEmpty()) | 970 if (m_frameBufferCache.isEmpty()) |
| 971 return; | 971 return; |
| 972 | 972 |
| 973 m_frameBufferCache[0].setHasAlpha(false); | 973 m_frameBufferCache[0].setHasAlpha(false); |
| 974 m_frameBufferCache[0].setStatus(ImageFrame::FrameComplete); | 974 m_frameBufferCache[0].setStatus(ImageFrame::FrameComplete); |
| 975 } | 975 } |
| 976 | 976 |
| 977 inline bool isComplete(const JPEGImageDecoder* decoder, bool onlySize) | |
| 978 { | |
| 979 if (decoder->hasImagePlanes() && !onlySize) | |
| 980 return true; | |
| 981 | |
| 982 return decoder->frameIsCompleteAtIndex(0); | |
| 983 } | |
| 984 | |
| 985 void JPEGImageDecoder::decode(bool onlySize) | 977 void JPEGImageDecoder::decode(bool onlySize) |
| 986 { | 978 { |
| 987 if (failed()) | 979 if (failed()) |
| 988 return; | 980 return; |
| 989 | 981 |
| 990 if (!m_reader) { | 982 if (!m_reader) { |
| 991 m_reader = adoptPtr(new JPEGImageReader(this)); | 983 m_reader = adoptPtr(new JPEGImageReader(this)); |
| 992 m_reader->setData(m_data.get()); | 984 m_reader->setData(m_data.get()); |
| 993 } | 985 } |
| 994 | 986 |
| 995 // If we couldn't decode the image but have received all the data, decoding | 987 // If we couldn't decode the image but have received all the data, decoding |
| 996 // has failed. | 988 // has failed. |
| 997 if (!m_reader->decode(onlySize) && isAllDataReceived()) | 989 if (!m_reader->decode(onlySize) && isAllDataReceived()) |
| 998 setFailed(); | 990 setFailed(); |
| 999 | 991 |
| 1000 // If decoding is done or failed, we don't need the JPEGImageReader anymore. | 992 // If decoding is done or failed, we don't need the JPEGImageReader anymore. |
| 1001 if (isComplete(this, onlySize) || failed()) | 993 if (frameIsCompleteAtIndex(0) || (hasImagePlanes() && !onlySize) || failed()
) |
| 1002 m_reader.reset(); | 994 m_reader.reset(); |
| 1003 } | 995 } |
| 1004 | 996 |
| 1005 } // namespace blink | 997 } // namespace blink |
| OLD | NEW |