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

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

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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 #include "config.h" 31 #include "config.h"
32 #include "platform/image-decoders/bmp/BMPImageDecoder.h" 32 #include "platform/image-decoders/bmp/BMPImageDecoder.h"
33 33
34 #include "platform/image-decoders/FastSharedBufferReader.h"
35 #include "wtf/PassOwnPtr.h" 34 #include "wtf/PassOwnPtr.h"
36 35
37 namespace blink { 36 namespace blink {
38 37
39 // Number of bits in .BMP used to store the file header (doesn't match 38 // Number of bits in .BMP used to store the file header (doesn't match
40 // "sizeof(BMPImageDecoder::BitmapFileHeader)" since we omit some fields and 39 // "sizeof(BMPImageDecoder::BitmapFileHeader)" since we omit some fields and
41 // don't pack). 40 // don't pack).
42 static const size_t sizeOfFileHeader = 14; 41 static const size_t sizeOfFileHeader = 14;
43 42
44 BMPImageDecoder::BMPImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes) 43 BMPImageDecoder::BMPImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 89
91 return m_reader->decodeBMP(onlySize); 90 return m_reader->decodeBMP(onlySize);
92 } 91 }
93 92
94 bool BMPImageDecoder::processFileHeader(size_t& imgDataOffset) 93 bool BMPImageDecoder::processFileHeader(size_t& imgDataOffset)
95 { 94 {
96 // Read file header. 95 // Read file header.
97 ASSERT(!m_decodedOffset); 96 ASSERT(!m_decodedOffset);
98 if (m_data->size() < sizeOfFileHeader) 97 if (m_data->size() < sizeOfFileHeader)
99 return false; 98 return false;
100 99 const uint16_t fileType = (m_data->data()[0] << 8) | static_cast<uint8_t>(m_ data->data()[1]);
101 char buffer[sizeOfFileHeader]; 100 imgDataOffset = readUint32(10);
102 FastSharedBufferReader fastReader(m_data);
103 const char* fileHeader = fastReader.getConsecutiveData(0, sizeOfFileHeader, buffer);
104 const uint16_t fileType = (fileHeader[0] << 8) | static_cast<uint8_t>(fileHe ader[1]);
105 imgDataOffset = BMPImageReader::readUint32(&fileHeader[10]);
106 m_decodedOffset = sizeOfFileHeader; 101 m_decodedOffset = sizeOfFileHeader;
107 102
108 // See if this is a bitmap filetype we understand. 103 // See if this is a bitmap filetype we understand.
109 enum { 104 enum {
110 BMAP = 0x424D, // "BM" 105 BMAP = 0x424D, // "BM"
111 // The following additional OS/2 2.x header values (see 106 // The following additional OS/2 2.x header values (see
112 // http://www.fileformat.info/format/os2bmp/egff.htm ) aren't widely 107 // http://www.fileformat.info/format/os2bmp/egff.htm ) aren't widely
113 // decoded, and are unlikely to be in much use. 108 // decoded, and are unlikely to be in much use.
114 /* 109 /*
115 ICON = 0x4943, // "IC" 110 ICON = 0x4943, // "IC"
116 POINTER = 0x5054, // "PT" 111 POINTER = 0x5054, // "PT"
117 COLORICON = 0x4349, // "CI" 112 COLORICON = 0x4349, // "CI"
118 COLORPOINTER = 0x4350, // "CP" 113 COLORPOINTER = 0x4350, // "CP"
119 BITMAPARRAY = 0x4241, // "BA" 114 BITMAPARRAY = 0x4241, // "BA"
120 */ 115 */
121 }; 116 };
122 return (fileType == BMAP) || setFailed(); 117 return (fileType == BMAP) || setFailed();
123 } 118 }
124 119
125 } // namespace blink 120 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/bmp/BMPImageDecoder.h ('k') | Source/platform/image-decoders/bmp/BMPImageReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698