Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 #if CPU(BIG_ENDIAN) | 61 #if CPU(BIG_ENDIAN) |
| 62 result = ((result & 0xff) << 24) | ((result & 0xff00) << 8) | ((result & 0xff0000) >> 8) | ((result & 0xff000000) >> 24); | 62 result = ((result & 0xff) << 24) | ((result & 0xff00) << 8) | ((result & 0xff0000) >> 8) | ((result & 0xff000000) >> 24); |
| 63 #endif | 63 #endif |
| 64 return result; | 64 return result; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // |parent| is the decoder that owns us. | 67 // |parent| is the decoder that owns us. |
| 68 // |startOffset| points to the start of the BMP within the file. | 68 // |startOffset| points to the start of the BMP within the file. |
| 69 // |buffer| points at an empty ImageFrame that we'll initialize and | 69 // |buffer| points at an empty ImageFrame that we'll initialize and |
| 70 // fill with decoded data. | 70 // fill with decoded data. |
| 71 BMPImageReader(ImageDecoder* parent, size_t decodedAndHeaderOffset, size_t i mgDataOffset, bool usesAndMask); | 71 BMPImageReader(ImageDecoder* parent, size_t decodedAndHeaderOffset, size_t i mgDataOffset, bool m_isInICO); |
|
Stephen White
2014/05/07 22:38:55
Spurious m_.
Peter Kasting
2014/05/07 22:41:29
Darn! Good catch. Will fix.
| |
| 72 | 72 |
| 73 void setBuffer(ImageFrame* buffer) { m_buffer = buffer; } | 73 void setBuffer(ImageFrame* buffer) { m_buffer = buffer; } |
| 74 void setData(SharedBuffer* data) { m_data = data; } | 74 void setData(SharedBuffer* data) { m_data = data; } |
| 75 | 75 |
| 76 // Does the actual decoding. If |onlySize| is true, decoding only | 76 // Does the actual decoding. If |onlySize| is true, decoding only |
| 77 // progresses as far as necessary to get the image size. Returns | 77 // progresses as far as necessary to get the image size. Returns |
| 78 // whether decoding succeeded. | 78 // whether decoding succeeded. |
| 79 bool decodeBMP(bool onlySize); | 79 bool decodeBMP(bool onlySize); |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // The various BMP compression types. We don't currently decode all | 82 // The various BMP compression types. We don't currently decode all |
| 83 // these. | 83 // these. |
| 84 enum CompressionType { | 84 enum CompressionType { |
| 85 // Universal types | 85 // Universal types |
| 86 RGB = 0, | 86 RGB = 0, |
| 87 RLE8 = 1, | 87 RLE8 = 1, |
| 88 RLE4 = 2, | 88 RLE4 = 2, |
| 89 // Windows V3+ only | 89 // Windows V3+ only |
| 90 BITFIELDS = 3, | 90 BITFIELDS = 3, |
| 91 JPEG = 4, | 91 JPEG = 4, |
| 92 PNG = 5, | 92 PNG = 5, |
| 93 // OS/2 2.x-only | 93 // OS/2 2.x-only |
| 94 HUFFMAN1D, // Stored in file as 3 | 94 HUFFMAN1D, // Stored in file as 3 |
| 95 RLE24, // Stored in file as 4 | 95 RLE24, // Stored in file as 4 |
| 96 }; | 96 }; |
| 97 enum AndMaskState { | |
| 98 None, | |
| 99 NotYetDecoded, | |
| 100 Decoding, | |
| 101 }; | |
| 102 enum ProcessingResult { | 97 enum ProcessingResult { |
| 103 Success, | 98 Success, |
| 104 Failure, | 99 Failure, |
| 105 InsufficientData, | 100 InsufficientData, |
| 106 }; | 101 }; |
| 107 | 102 |
| 108 // These are based on the Windows BITMAPINFOHEADER and RGBTRIPLE | 103 // These are based on the Windows BITMAPINFOHEADER and RGBTRIPLE |
| 109 // structs, but with unnecessary entries removed. | 104 // structs, but with unnecessary entries removed. |
| 110 struct BitmapInfoHeader { | 105 struct BitmapInfoHeader { |
| 111 uint32_t biSize; | 106 uint32_t biSize; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 | 331 |
| 337 // The coordinate to which we've decoded the image. | 332 // The coordinate to which we've decoded the image. |
| 338 IntPoint m_coord; | 333 IntPoint m_coord; |
| 339 | 334 |
| 340 // Variables that track whether we've seen pixels with alpha values != 0 | 335 // Variables that track whether we've seen pixels with alpha values != 0 |
| 341 // and == 0, respectively. See comments in processNonRLEData() on how | 336 // and == 0, respectively. See comments in processNonRLEData() on how |
| 342 // these are used. | 337 // these are used. |
| 343 bool m_seenNonZeroAlphaPixel; | 338 bool m_seenNonZeroAlphaPixel; |
| 344 bool m_seenZeroAlphaPixel; | 339 bool m_seenZeroAlphaPixel; |
| 345 | 340 |
| 341 // BMPs-in-ICOs have a few differences from standalone BMPs, so we need to | |
| 342 // know if we're in an ICO container. | |
| 343 bool m_isInICO; | |
| 344 | |
| 346 // ICOs store a 1bpp "mask" immediately after the main bitmap image data | 345 // ICOs store a 1bpp "mask" immediately after the main bitmap image data |
| 347 // (and, confusingly, add its height to the biHeight value in the info | 346 // (and, confusingly, add its height to the biHeight value in the info |
| 348 // header, thus doubling it). This variable tracks whether we have such | 347 // header, thus doubling it). If |m_isInICO| is true, this variable tracks |
| 349 // a mask and if we've started decoding it yet. | 348 // whether we've begun decoding this mask yet. |
| 350 AndMaskState m_andMaskState; | 349 bool m_decodingAndMask; |
| 351 }; | 350 }; |
| 352 | 351 |
| 353 } // namespace WebCore | 352 } // namespace WebCore |
| 354 | 353 |
| 355 #endif | 354 #endif |
| OLD | NEW |