| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef BMPImageReader_h | 31 #ifndef BMPImageReader_h |
| 32 #define BMPImageReader_h | 32 #define BMPImageReader_h |
| 33 | 33 |
| 34 #include "platform/image-decoders/FastSharedBufferReader.h" | 34 #include "platform/image-decoders/FastSharedBufferReader.h" |
| 35 #include "platform/image-decoders/ImageDecoder.h" | 35 #include "platform/image-decoders/ImageDecoder.h" |
| 36 #include "wtf/Allocator.h" |
| 36 #include "wtf/CPU.h" | 37 #include "wtf/CPU.h" |
| 38 #include "wtf/Noncopyable.h" |
| 37 #include <stdint.h> | 39 #include <stdint.h> |
| 38 | 40 |
| 39 namespace blink { | 41 namespace blink { |
| 40 | 42 |
| 41 // This class decodes a BMP image. It is used in the BMP and ICO decoders, | 43 // This class decodes a BMP image. It is used in the BMP and ICO decoders, |
| 42 // which wrap it in the appropriate code to read file headers, etc. | 44 // which wrap it in the appropriate code to read file headers, etc. |
| 43 class PLATFORM_EXPORT BMPImageReader { | 45 class PLATFORM_EXPORT BMPImageReader final { |
| 44 USING_FAST_MALLOC(BMPImageReader); | 46 USING_FAST_MALLOC(BMPImageReader); |
| 47 WTF_MAKE_NONCOPYABLE(BMPImageReader); |
| 45 public: | 48 public: |
| 46 // Read a value from |buffer|, converting to an int assuming little | 49 // Read a value from |buffer|, converting to an int assuming little |
| 47 // endianness | 50 // endianness |
| 48 static inline uint16_t readUint16(const char* buffer) | 51 static inline uint16_t readUint16(const char* buffer) |
| 49 { | 52 { |
| 50 return *reinterpret_cast<const uint16_t*>(buffer); | 53 return *reinterpret_cast<const uint16_t*>(buffer); |
| 51 } | 54 } |
| 52 | 55 |
| 53 static inline uint32_t readUint32(const char* buffer) | 56 static inline uint32_t readUint32(const char* buffer) |
| 54 { | 57 { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 }; | 102 }; |
| 100 enum ProcessingResult { | 103 enum ProcessingResult { |
| 101 Success, | 104 Success, |
| 102 Failure, | 105 Failure, |
| 103 InsufficientData, | 106 InsufficientData, |
| 104 }; | 107 }; |
| 105 | 108 |
| 106 // These are based on the Windows BITMAPINFOHEADER and RGBTRIPLE | 109 // These are based on the Windows BITMAPINFOHEADER and RGBTRIPLE |
| 107 // structs, but with unnecessary entries removed. | 110 // structs, but with unnecessary entries removed. |
| 108 struct BitmapInfoHeader { | 111 struct BitmapInfoHeader { |
| 112 DISALLOW_NEW(); |
| 109 uint32_t biSize; | 113 uint32_t biSize; |
| 110 int32_t biWidth; | 114 int32_t biWidth; |
| 111 int32_t biHeight; | 115 int32_t biHeight; |
| 112 uint16_t biBitCount; | 116 uint16_t biBitCount; |
| 113 CompressionType biCompression; | 117 CompressionType biCompression; |
| 114 uint32_t biClrUsed; | 118 uint32_t biClrUsed; |
| 115 }; | 119 }; |
| 116 struct RGBTriple { | 120 struct RGBTriple { |
| 121 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 117 uint8_t rgbBlue; | 122 uint8_t rgbBlue; |
| 118 uint8_t rgbGreen; | 123 uint8_t rgbGreen; |
| 119 uint8_t rgbRed; | 124 uint8_t rgbRed; |
| 120 }; | 125 }; |
| 121 | 126 |
| 122 inline uint8_t readUint8(size_t offset) const | 127 inline uint8_t readUint8(size_t offset) const |
| 123 { | 128 { |
| 124 return m_fastReader.getOneByte(m_decodedOffset + offset); | 129 return m_fastReader.getOneByte(m_decodedOffset + offset); |
| 125 } | 130 } |
| 126 | 131 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // ICOs store a 1bpp "mask" immediately after the main bitmap image data | 362 // ICOs store a 1bpp "mask" immediately after the main bitmap image data |
| 358 // (and, confusingly, add its height to the biHeight value in the info | 363 // (and, confusingly, add its height to the biHeight value in the info |
| 359 // header, thus doubling it). If |m_isInICO| is true, this variable tracks | 364 // header, thus doubling it). If |m_isInICO| is true, this variable tracks |
| 360 // whether we've begun decoding this mask yet. | 365 // whether we've begun decoding this mask yet. |
| 361 bool m_decodingAndMask; | 366 bool m_decodingAndMask; |
| 362 }; | 367 }; |
| 363 | 368 |
| 364 } // namespace blink | 369 } // namespace blink |
| 365 | 370 |
| 366 #endif | 371 #endif |
| OLD | NEW |