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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 return; | 985 return; |
986 | 986 |
987 frame_buffer_cache_[0].SetHasAlpha(false); | 987 frame_buffer_cache_[0].SetHasAlpha(false); |
988 frame_buffer_cache_[0].SetStatus(ImageFrame::kFrameComplete); | 988 frame_buffer_cache_[0].SetStatus(ImageFrame::kFrameComplete); |
989 } | 989 } |
990 | 990 |
991 inline bool IsComplete(const JPEGImageDecoder* decoder, bool only_size) { | 991 inline bool IsComplete(const JPEGImageDecoder* decoder, bool only_size) { |
992 if (decoder->HasImagePlanes() && !only_size) | 992 if (decoder->HasImagePlanes() && !only_size) |
993 return true; | 993 return true; |
994 | 994 |
995 return decoder->FrameIsCompleteAtIndex(0); | 995 return decoder->FrameIsDecodedAtIndex(0); |
996 } | 996 } |
997 | 997 |
998 void JPEGImageDecoder::Decode(bool only_size) { | 998 void JPEGImageDecoder::Decode(bool only_size) { |
999 if (Failed()) | 999 if (Failed()) |
1000 return; | 1000 return; |
1001 | 1001 |
1002 if (!reader_) { | 1002 if (!reader_) { |
1003 reader_ = WTF::MakeUnique<JPEGImageReader>(this); | 1003 reader_ = WTF::MakeUnique<JPEGImageReader>(this); |
1004 reader_->SetData(data_.Get()); | 1004 reader_->SetData(data_.Get()); |
1005 } | 1005 } |
1006 | 1006 |
1007 // If we couldn't decode the image but have received all the data, decoding | 1007 // If we couldn't decode the image but have received all the data, decoding |
1008 // has failed. | 1008 // has failed. |
1009 if (!reader_->Decode(only_size) && IsAllDataReceived()) | 1009 if (!reader_->Decode(only_size) && IsAllDataReceived()) |
1010 SetFailed(); | 1010 SetFailed(); |
1011 | 1011 |
1012 // If decoding is done or failed, we don't need the JPEGImageReader anymore. | 1012 // If decoding is done or failed, we don't need the JPEGImageReader anymore. |
1013 if (IsComplete(this, only_size) || Failed()) | 1013 if (IsComplete(this, only_size) || Failed()) |
1014 reader_.reset(); | 1014 reader_.reset(); |
1015 } | 1015 } |
1016 | 1016 |
1017 } // namespace blink | 1017 } // namespace blink |
OLD | NEW |