| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef JPEGImageDecoder_h | |
| 27 #define JPEGImageDecoder_h | |
| 28 | |
| 29 #include "platform/image-decoders/ImageDecoder.h" | |
| 30 #include <memory> | |
| 31 | |
| 32 namespace blink { | |
| 33 | |
| 34 class JPEGImageReader; | |
| 35 | |
| 36 class PLATFORM_EXPORT JPEGImageDecoder final : public ImageDecoder { | |
| 37 WTF_MAKE_NONCOPYABLE(JPEGImageDecoder); | |
| 38 | |
| 39 public: | |
| 40 JPEGImageDecoder(AlphaOption, const ColorBehavior&, size_t max_decoded_bytes); | |
| 41 ~JPEGImageDecoder() override; | |
| 42 | |
| 43 // ImageDecoder: | |
| 44 String FilenameExtension() const override { return "jpg"; } | |
| 45 void OnSetData(SegmentReader* data) override; | |
| 46 IntSize DecodedSize() const override { return decoded_size_; } | |
| 47 bool SetSize(unsigned width, unsigned height) override; | |
| 48 IntSize DecodedYUVSize(int component) const override; | |
| 49 size_t DecodedYUVWidthBytes(int component) const override; | |
| 50 bool CanDecodeToYUV() override; | |
| 51 bool DecodeToYUV() override; | |
| 52 void SetImagePlanes(std::unique_ptr<ImagePlanes>) override; | |
| 53 bool HasImagePlanes() const { return image_planes_.get(); } | |
| 54 | |
| 55 bool OutputScanlines(); | |
| 56 unsigned DesiredScaleNumerator() const; | |
| 57 void Complete(); | |
| 58 | |
| 59 void SetOrientation(ImageOrientation orientation) { | |
| 60 orientation_ = orientation; | |
| 61 } | |
| 62 void SetDecodedSize(unsigned width, unsigned height); | |
| 63 | |
| 64 private: | |
| 65 // ImageDecoder: | |
| 66 void DecodeSize() override { Decode(true); } | |
| 67 void Decode(size_t) override { Decode(false); } | |
| 68 | |
| 69 // Decodes the image. If |only_size| is true, stops decoding after | |
| 70 // calculating the image size. If decoding fails but there is no more | |
| 71 // data coming, sets the "decode failure" flag. | |
| 72 void Decode(bool only_size); | |
| 73 | |
| 74 std::unique_ptr<JPEGImageReader> reader_; | |
| 75 std::unique_ptr<ImagePlanes> image_planes_; | |
| 76 IntSize decoded_size_; | |
| 77 }; | |
| 78 | |
| 79 } // namespace blink | |
| 80 | |
| 81 #endif | |
| OLD | NEW |