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

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

Issue 1309363006: Mark FastSharedBufferReader's methods const (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@noConsolidateBMP
Patch Set: 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
« no previous file with comments | « Source/platform/image-decoders/FastSharedBufferReader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 uint16_t biBitCount; 112 uint16_t biBitCount;
113 CompressionType biCompression; 113 CompressionType biCompression;
114 uint32_t biClrUsed; 114 uint32_t biClrUsed;
115 }; 115 };
116 struct RGBTriple { 116 struct RGBTriple {
117 uint8_t rgbBlue; 117 uint8_t rgbBlue;
118 uint8_t rgbGreen; 118 uint8_t rgbGreen;
119 uint8_t rgbRed; 119 uint8_t rgbRed;
120 }; 120 };
121 121
122 inline uint8_t readUint8(size_t offset) 122 inline uint8_t readUint8(size_t offset) const
123 { 123 {
124 return m_fastReader.getOneByte(m_decodedOffset + offset); 124 return m_fastReader.getOneByte(m_decodedOffset + offset);
125 } 125 }
126 126
127 inline uint16_t readUint16(int offset) 127 inline uint16_t readUint16(int offset) const
128 { 128 {
129 char buffer[2]; 129 char buffer[2];
130 const char* data = m_fastReader.getConsecutiveData(m_decodedOffset + off set, 2, buffer); 130 const char* data = m_fastReader.getConsecutiveData(m_decodedOffset + off set, 2, buffer);
131 return readUint16(data); 131 return readUint16(data);
132 } 132 }
133 133
134 inline uint32_t readUint32(int offset) 134 inline uint32_t readUint32(int offset) const
135 { 135 {
136 char buffer[4]; 136 char buffer[4];
137 const char* data = m_fastReader.getConsecutiveData(m_decodedOffset + off set, 4, buffer); 137 const char* data = m_fastReader.getConsecutiveData(m_decodedOffset + off set, 4, buffer);
138 return readUint32(data); 138 return readUint32(data);
139 } 139 }
140 140
141 // Determines the size of the BMP info header. Returns true if the size 141 // Determines the size of the BMP info header. Returns true if the size
142 // is valid. 142 // is valid.
143 bool readInfoHeaderSize(); 143 bool readInfoHeaderSize();
144 144
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 inline bool pastEndOfImage(int numRows) 193 inline bool pastEndOfImage(int numRows)
194 { 194 {
195 return m_isTopDown ? ((m_coord.y() + numRows) >= m_parent->size().height ()) : ((m_coord.y() - numRows) < 0); 195 return m_isTopDown ? ((m_coord.y() + numRows) >= m_parent->size().height ()) : ((m_coord.y() - numRows) < 0);
196 } 196 }
197 197
198 // Returns the pixel data for the current X coordinate in a uint32_t. 198 // Returns the pixel data for the current X coordinate in a uint32_t.
199 // Assumes m_decodedOffset has been set to the beginning of the current 199 // Assumes m_decodedOffset has been set to the beginning of the current
200 // row. 200 // row.
201 // NOTE: Only as many bytes of the return value as are needed to hold 201 // NOTE: Only as many bytes of the return value as are needed to hold
202 // the pixel data will actually be set. 202 // the pixel data will actually be set.
203 inline uint32_t readCurrentPixel(int bytesPerPixel) 203 inline uint32_t readCurrentPixel(int bytesPerPixel) const
204 { 204 {
205 // We need at most 4 bytes, starting at m_decodedOffset + offset. 205 // We need at most 4 bytes, starting at m_decodedOffset + offset.
206 char buffer[4]; 206 char buffer[4];
207 const int offset = m_coord.x() * bytesPerPixel; 207 const int offset = m_coord.x() * bytesPerPixel;
208 const char* encodedPixel = m_fastReader.getConsecutiveData(m_decodedOffs et + offset, bytesPerPixel, buffer); 208 const char* encodedPixel = m_fastReader.getConsecutiveData(m_decodedOffs et + offset, bytesPerPixel, buffer);
209 switch (bytesPerPixel) { 209 switch (bytesPerPixel) {
210 case 2: 210 case 2:
211 return readUint16(encodedPixel); 211 return readUint16(encodedPixel);
212 212
213 case 3: { 213 case 3: {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // ICOs store a 1bpp "mask" immediately after the main bitmap image data 357 // 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 358 // (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 359 // header, thus doubling it). If |m_isInICO| is true, this variable tracks
360 // whether we've begun decoding this mask yet. 360 // whether we've begun decoding this mask yet.
361 bool m_decodingAndMask; 361 bool m_decodingAndMask;
362 }; 362 };
363 363
364 } // namespace blink 364 } // namespace blink
365 365
366 #endif 366 #endif
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/FastSharedBufferReader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698