Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: Source/platform/image-decoders/bmp/BMPImageDecoder.h

Issue 1337263003: Revert of Do not consolidate data in BMPImageDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@SegmentedBuffer
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
57 // Decodes the image. If |onlySize| is true, stops decoding after 62 // Decodes the image. If |onlySize| is true, stops decoding after
58 // calculating the image size. If decoding fails but there is no more 63 // calculating the image size. If decoding fails but there is no more
59 // data coming, sets the "decode failure" flag. 64 // data coming, sets the "decode failure" flag.
60 void decode(bool onlySize); 65 void decode(bool onlySize);
61 66
62 // Decodes the image. If |onlySize| is true, stops decoding after 67 // Decodes the image. If |onlySize| is true, stops decoding after
63 // calculating the image size. Returns whether decoding succeeded. 68 // calculating the image size. Returns whether decoding succeeded.
64 bool decodeHelper(bool onlySize); 69 bool decodeHelper(bool onlySize);
65 70
66 // Processes the file header at the beginning of the data. Sets 71 // Processes the file header at the beginning of the data. Sets
67 // |imgDataOffset| based on the header contents. Returns true if the 72 // |imgDataOffset| based on the header contents. Returns true if the
68 // file header could be decoded. 73 // file header could be decoded.
69 bool processFileHeader(size_t& imgDataOffset); 74 bool processFileHeader(size_t& imgDataOffset);
70 75
71 // An index into |m_data| representing how much we've already decoded. 76 // An index into |m_data| representing how much we've already decoded.
72 // Note that this only tracks data _this_ class decodes; once the 77 // Note that this only tracks data _this_ class decodes; once the
73 // BMPImageReader takes over this will not be updated further. 78 // BMPImageReader takes over this will not be updated further.
74 size_t m_decodedOffset; 79 size_t m_decodedOffset;
75 80
76 // The reader used to do most of the BMP decoding. 81 // The reader used to do most of the BMP decoding.
77 OwnPtr<BMPImageReader> m_reader; 82 OwnPtr<BMPImageReader> m_reader;
78 }; 83 };
79 84
80 } // namespace blink 85 } // namespace blink
81 86
82 #endif 87 #endif
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/FastSharedBufferReader.cpp ('k') | Source/platform/image-decoders/bmp/BMPImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698