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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid | 47 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid |
48 // accessing deleted memory, especially when calling this from inside | 48 // accessing deleted memory, especially when calling this from inside |
49 // BMPImageReader! | 49 // BMPImageReader! |
50 bool setFailed() override; | 50 bool setFailed() override; |
51 | 51 |
52 private: | 52 private: |
53 // ImageDecoder: | 53 // ImageDecoder: |
54 void decodeSize() override { decode(true); } | 54 void decodeSize() override { decode(true); } |
55 void decode(size_t) override { decode(false); } | 55 void decode(size_t) override { decode(false); } |
56 | 56 |
57 inline uint32_t readUint32(int offset) const | |
58 { | |
59 return BMPImageReader::readUint32(m_data.get(), m_decodedOffset + offset
); | |
60 } | |
61 | |
62 // Decodes the image. If |onlySize| is true, stops decoding after | 57 // Decodes the image. If |onlySize| is true, stops decoding after |
63 // calculating the image size. If decoding fails but there is no more | 58 // calculating the image size. If decoding fails but there is no more |
64 // data coming, sets the "decode failure" flag. | 59 // data coming, sets the "decode failure" flag. |
65 void decode(bool onlySize); | 60 void decode(bool onlySize); |
66 | 61 |
67 // Decodes the image. If |onlySize| is true, stops decoding after | 62 // Decodes the image. If |onlySize| is true, stops decoding after |
68 // calculating the image size. Returns whether decoding succeeded. | 63 // calculating the image size. Returns whether decoding succeeded. |
69 bool decodeHelper(bool onlySize); | 64 bool decodeHelper(bool onlySize); |
70 | 65 |
71 // Processes the file header at the beginning of the data. Sets | 66 // Processes the file header at the beginning of the data. Sets |
72 // |imgDataOffset| based on the header contents. Returns true if the | 67 // |imgDataOffset| based on the header contents. Returns true if the |
73 // file header could be decoded. | 68 // file header could be decoded. |
74 bool processFileHeader(size_t& imgDataOffset); | 69 bool processFileHeader(size_t& imgDataOffset); |
75 | 70 |
76 // An index into |m_data| representing how much we've already decoded. | 71 // An index into |m_data| representing how much we've already decoded. |
77 // Note that this only tracks data _this_ class decodes; once the | 72 // Note that this only tracks data _this_ class decodes; once the |
78 // BMPImageReader takes over this will not be updated further. | 73 // BMPImageReader takes over this will not be updated further. |
79 size_t m_decodedOffset; | 74 size_t m_decodedOffset; |
80 | 75 |
81 // The reader used to do most of the BMP decoding. | 76 // The reader used to do most of the BMP decoding. |
82 OwnPtr<BMPImageReader> m_reader; | 77 OwnPtr<BMPImageReader> m_reader; |
83 }; | 78 }; |
84 | 79 |
85 } // namespace blink | 80 } // namespace blink |
86 | 81 |
87 #endif | 82 #endif |
OLD | NEW |