OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2008-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // This class decodes the JPEG image format. | 42 // This class decodes the JPEG image format. |
43 class JPEGImageDecoder : public ImageDecoder { | 43 class JPEGImageDecoder : public ImageDecoder { |
44 public: | 44 public: |
45 JPEGImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorPro
fileOption); | 45 JPEGImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorPro
fileOption); |
46 virtual ~JPEGImageDecoder(); | 46 virtual ~JPEGImageDecoder(); |
47 | 47 |
48 // ImageDecoder | 48 // ImageDecoder |
49 virtual String filenameExtension() const { return "jpg"; } | 49 virtual String filenameExtension() const { return "jpg"; } |
50 virtual bool isSizeAvailable(); | 50 virtual bool isSizeAvailable(); |
51 virtual bool setSize(unsigned width, unsigned height); | |
52 virtual ImageFrame* frameBufferAtIndex(size_t index); | 51 virtual ImageFrame* frameBufferAtIndex(size_t index); |
53 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid | 52 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid |
54 // accessing deleted memory, especially when calling this from inside | 53 // accessing deleted memory, especially when calling this from inside |
55 // JPEGImageReader! | 54 // JPEGImageReader! |
56 virtual bool setFailed(); | 55 virtual bool setFailed(); |
57 | 56 |
58 bool willDownSample() | |
59 { | |
60 ASSERT(ImageDecoder::isSizeAvailable()); | |
61 return m_scaled; | |
62 } | |
63 | |
64 bool outputScanlines(); | 57 bool outputScanlines(); |
65 void jpegComplete(); | 58 void jpegComplete(); |
66 | 59 |
67 void setOrientation(ImageOrientation orientation) { m_orientation = orie
ntation; } | 60 void setOrientation(ImageOrientation orientation) { m_orientation = orie
ntation; } |
68 | 61 |
69 private: | 62 private: |
70 // Decodes the image. If |onlySize| is true, stops decoding after | 63 // Decodes the image. If |onlySize| is true, stops decoding after |
71 // calculating the image size. If decoding fails but there is no more | 64 // calculating the image size. If decoding fails but there is no more |
72 // data coming, sets the "decode failure" flag. | 65 // data coming, sets the "decode failure" flag. |
73 void decode(bool onlySize); | 66 void decode(bool onlySize); |
74 | 67 |
75 template <J_COLOR_SPACE colorSpace> | 68 template <J_COLOR_SPACE colorSpace> |
76 bool outputScanlines(ImageFrame& buffer); | 69 bool outputScanlines(ImageFrame& buffer); |
77 | 70 |
78 template <J_COLOR_SPACE colorSpace, bool isScaled> | |
79 bool outputScanlines(ImageFrame& buffer); | |
80 | |
81 OwnPtr<JPEGImageReader> m_reader; | 71 OwnPtr<JPEGImageReader> m_reader; |
82 }; | 72 }; |
83 | 73 |
84 } // namespace WebCore | 74 } // namespace WebCore |
85 | 75 |
86 #endif | 76 #endif |
OLD | NEW |