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 21 matching lines...) Expand all Loading... |
32 * deletingthe provisions above and replace them with the notice and | 32 * deletingthe provisions above and replace them with the notice and |
33 * other provisions required by the MPL or the GPL, as the case may be. | 33 * other provisions required by the MPL or the GPL, as the case may be. |
34 * If you do not delete the provisions above, a recipient may use your | 34 * If you do not delete the provisions above, a recipient may use your |
35 * version of this file under any of the LGPL, the MPL or the GPL. | 35 * version of this file under any of the LGPL, the MPL or the GPL. |
36 */ | 36 */ |
37 | 37 |
38 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h" | 38 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h" |
39 | 39 |
40 #include "platform/Histogram.h" | 40 #include "platform/Histogram.h" |
41 #include "platform/PlatformInstrumentation.h" | 41 #include "platform/PlatformInstrumentation.h" |
42 #include "wtf/PtrUtil.h" | |
43 #include "wtf/Threading.h" | 42 #include "wtf/Threading.h" |
44 #include <memory> | |
45 | 43 |
46 extern "C" { | 44 extern "C" { |
47 #include <stdio.h> // jpeglib.h needs stdio FILE. | 45 #include <stdio.h> // jpeglib.h needs stdio FILE. |
48 #include "jpeglib.h" | 46 #include "jpeglib.h" |
49 #if USE(ICCJPEG) | 47 #if USE(ICCJPEG) |
50 #include "iccjpeg.h" | 48 #include "iccjpeg.h" |
51 #endif | 49 #endif |
52 #if USE(QCMSLIB) | 50 #if USE(QCMSLIB) |
53 #include "qcms.h" | 51 #include "qcms.h" |
54 #endif | 52 #endif |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 { | 786 { |
789 if (!hasImagePlanes()) | 787 if (!hasImagePlanes()) |
790 return false; | 788 return false; |
791 | 789 |
792 PlatformInstrumentation::willDecodeImage("JPEG"); | 790 PlatformInstrumentation::willDecodeImage("JPEG"); |
793 decode(false); | 791 decode(false); |
794 PlatformInstrumentation::didDecodeImage(); | 792 PlatformInstrumentation::didDecodeImage(); |
795 return !failed(); | 793 return !failed(); |
796 } | 794 } |
797 | 795 |
798 void JPEGImageDecoder::setImagePlanes(std::unique_ptr<ImagePlanes> imagePlanes) | 796 void JPEGImageDecoder::setImagePlanes(PassOwnPtr<ImagePlanes> imagePlanes) |
799 { | 797 { |
800 m_imagePlanes = std::move(imagePlanes); | 798 m_imagePlanes = std::move(imagePlanes); |
801 } | 799 } |
802 | 800 |
803 template <J_COLOR_SPACE colorSpace> void setPixel(ImageFrame& buffer, ImageFrame
::PixelData* pixel, JSAMPARRAY samples, int column) | 801 template <J_COLOR_SPACE colorSpace> void setPixel(ImageFrame& buffer, ImageFrame
::PixelData* pixel, JSAMPARRAY samples, int column) |
804 { | 802 { |
805 ASSERT_NOT_REACHED(); | 803 ASSERT_NOT_REACHED(); |
806 } | 804 } |
807 | 805 |
808 template <> void setPixel<JCS_RGB>(ImageFrame& buffer, ImageFrame::PixelData* pi
xel, JSAMPARRAY samples, int column) | 806 template <> void setPixel<JCS_RGB>(ImageFrame& buffer, ImageFrame::PixelData* pi
xel, JSAMPARRAY samples, int column) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 | 981 |
984 return decoder->frameIsCompleteAtIndex(0); | 982 return decoder->frameIsCompleteAtIndex(0); |
985 } | 983 } |
986 | 984 |
987 void JPEGImageDecoder::decode(bool onlySize) | 985 void JPEGImageDecoder::decode(bool onlySize) |
988 { | 986 { |
989 if (failed()) | 987 if (failed()) |
990 return; | 988 return; |
991 | 989 |
992 if (!m_reader) { | 990 if (!m_reader) { |
993 m_reader = wrapUnique(new JPEGImageReader(this)); | 991 m_reader = adoptPtr(new JPEGImageReader(this)); |
994 m_reader->setData(m_data.get()); | 992 m_reader->setData(m_data.get()); |
995 } | 993 } |
996 | 994 |
997 // If we couldn't decode the image but have received all the data, decoding | 995 // If we couldn't decode the image but have received all the data, decoding |
998 // has failed. | 996 // has failed. |
999 if (!m_reader->decode(onlySize) && isAllDataReceived()) | 997 if (!m_reader->decode(onlySize) && isAllDataReceived()) |
1000 setFailed(); | 998 setFailed(); |
1001 | 999 |
1002 // If decoding is done or failed, we don't need the JPEGImageReader anymore. | 1000 // If decoding is done or failed, we don't need the JPEGImageReader anymore. |
1003 if (isComplete(this, onlySize) || failed()) | 1001 if (isComplete(this, onlySize) || failed()) |
1004 m_reader.reset(); | 1002 m_reader.reset(); |
1005 } | 1003 } |
1006 | 1004 |
1007 } // namespace blink | 1005 } // namespace blink |
OLD | NEW |