Commit 5225d620 authored by deepak.sa@samsung.com's avatar deepak.sa@samsung.com

Use reference instead of pointer in BMPImageDecoder::processFileHeader

Use reference instead of pointer in BMPImageDecoder::processFileHeader

Review URL: https://codereview.chromium.org/556913002

git-svn-id: svn://svn.chromium.org/blink/trunk@181777 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ab584324
...@@ -110,7 +110,7 @@ void BMPImageDecoder::decode(bool onlySize) ...@@ -110,7 +110,7 @@ void BMPImageDecoder::decode(bool onlySize)
bool BMPImageDecoder::decodeHelper(bool onlySize) bool BMPImageDecoder::decodeHelper(bool onlySize)
{ {
size_t imgDataOffset = 0; size_t imgDataOffset = 0;
if ((m_decodedOffset < sizeOfFileHeader) && !processFileHeader(&imgDataOffset)) if ((m_decodedOffset < sizeOfFileHeader) && !processFileHeader(imgDataOffset))
return false; return false;
if (!m_reader) { if (!m_reader) {
...@@ -124,16 +124,14 @@ bool BMPImageDecoder::decodeHelper(bool onlySize) ...@@ -124,16 +124,14 @@ bool BMPImageDecoder::decodeHelper(bool onlySize)
return m_reader->decodeBMP(onlySize); return m_reader->decodeBMP(onlySize);
} }
bool BMPImageDecoder::processFileHeader(size_t* imgDataOffset) bool BMPImageDecoder::processFileHeader(size_t& imgDataOffset)
{ {
ASSERT(imgDataOffset);
// Read file header. // Read file header.
ASSERT(!m_decodedOffset); ASSERT(!m_decodedOffset);
if (m_data->size() < sizeOfFileHeader) if (m_data->size() < sizeOfFileHeader)
return false; return false;
const uint16_t fileType = (m_data->data()[0] << 8) | static_cast<uint8_t>(m_data->data()[1]); const uint16_t fileType = (m_data->data()[0] << 8) | static_cast<uint8_t>(m_data->data()[1]);
*imgDataOffset = readUint32(10); imgDataOffset = readUint32(10);
m_decodedOffset = sizeOfFileHeader; m_decodedOffset = sizeOfFileHeader;
// See if this is a bitmap filetype we understand. // See if this is a bitmap filetype we understand.
......
...@@ -58,18 +58,18 @@ private: ...@@ -58,18 +58,18 @@ private:
} }
// Decodes the image. If |onlySize| is true, stops decoding after // Decodes the image. If |onlySize| is true, stops decoding after
// calculating the image size. If decoding fails but there is no more // calculating the image size. If decoding fails but there is no more
// data coming, sets the "decode failure" flag. // data coming, sets the "decode failure" flag.
void decode(bool onlySize); void decode(bool onlySize);
// Decodes the image. If |onlySize| is true, stops decoding after // Decodes the image. If |onlySize| is true, stops decoding after
// calculating the image size. Returns whether decoding succeeded. // calculating the image size. Returns whether decoding succeeded.
bool decodeHelper(bool onlySize); bool decodeHelper(bool onlySize);
// Processes the file header at the beginning of the data. Sets // Processes the file header at the beginning of the data. Sets
// |*imgDataOffset| based on the header contents. Returns true if the // |imgDataOffset| based on the header contents. Returns true if the
// file header could be decoded. // file header could be decoded.
bool processFileHeader(size_t* imgDataOffset); bool processFileHeader(size_t& imgDataOffset);
// An index into |m_data| representing how much we've already decoded. // An index into |m_data| representing how much we've already decoded.
// Note that this only tracks data _this_ class decodes; once the // Note that this only tracks data _this_ class decodes; once the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment