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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 m_buffer->setPixelsChanged(true); | 159 m_buffer->setPixelsChanged(true); |
160 return (result == Failure) ? m_parent->setFailed() : (result == Success); | 160 return (result == Failure) ? m_parent->setFailed() : (result == Success); |
161 } | 161 } |
162 | 162 |
163 bool BMPImageReader::readInfoHeaderSize() | 163 bool BMPImageReader::readInfoHeaderSize() |
164 { | 164 { |
165 // Get size of info header. | 165 // Get size of info header. |
166 ASSERT(m_decodedOffset == m_headerOffset); | 166 ASSERT(m_decodedOffset == m_headerOffset); |
167 if ((m_decodedOffset > m_data->size()) || ((m_data->size() - m_decodedOffset ) < 4)) | 167 if ((m_decodedOffset > m_data->size()) || ((m_data->size() - m_decodedOffset ) < 4)) |
168 return false; | 168 return false; |
169 m_infoHeader.biSize = readUint32(0); | 169 |
170 FastSharedBufferReader fastReader(m_data); | |
171 m_infoHeader.biSize = readUint32(&fastReader, 0); | |
170 // Don't increment m_decodedOffset here, it just makes the code in | 172 // Don't increment m_decodedOffset here, it just makes the code in |
171 // processInfoHeader() more confusing. | 173 // processInfoHeader() more confusing. |
172 | 174 |
173 // Don't allow the header to overflow (which would be harmless here, but | 175 // Don't allow the header to overflow (which would be harmless here, but |
174 // problematic or at least confusing in other places), or to overrun the | 176 // problematic or at least confusing in other places), or to overrun the |
175 // image data. | 177 // image data. |
176 const size_t headerEnd = m_headerOffset + m_infoHeader.biSize; | 178 const size_t headerEnd = m_headerOffset + m_infoHeader.biSize; |
177 if ((headerEnd < m_headerOffset) || (m_imgDataOffset && (m_imgDataOffset < h eaderEnd))) | 179 if ((headerEnd < m_headerOffset) || (m_imgDataOffset && (m_imgDataOffset < h eaderEnd))) |
178 return m_parent->setFailed(); | 180 return m_parent->setFailed(); |
179 | 181 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 | 236 |
235 return true; | 237 return true; |
236 } | 238 } |
237 | 239 |
238 bool BMPImageReader::readInfoHeader() | 240 bool BMPImageReader::readInfoHeader() |
239 { | 241 { |
240 // Pre-initialize some fields that not all headers set. | 242 // Pre-initialize some fields that not all headers set. |
241 m_infoHeader.biCompression = RGB; | 243 m_infoHeader.biCompression = RGB; |
242 m_infoHeader.biClrUsed = 0; | 244 m_infoHeader.biClrUsed = 0; |
243 | 245 |
246 FastSharedBufferReader fastReader(m_data); | |
247 | |
244 if (m_isOS21x) { | 248 if (m_isOS21x) { |
245 m_infoHeader.biWidth = readUint16(4); | 249 m_infoHeader.biWidth = readUint16(&fastReader, 4); |
246 m_infoHeader.biHeight = readUint16(6); | 250 m_infoHeader.biHeight = readUint16(&fastReader, 6); |
247 ASSERT(!m_isInICO); // ICO is a Windows format, not OS/2! | 251 ASSERT(!m_isInICO); // ICO is a Windows format, not OS/2! |
248 m_infoHeader.biBitCount = readUint16(10); | 252 m_infoHeader.biBitCount = readUint16(&fastReader, 10); |
249 return true; | 253 return true; |
250 } | 254 } |
251 | 255 |
252 m_infoHeader.biWidth = readUint32(4); | 256 m_infoHeader.biWidth = readUint32(&fastReader, 4); |
253 m_infoHeader.biHeight = readUint32(8); | 257 m_infoHeader.biHeight = readUint32(&fastReader, 8); |
254 if (m_isInICO) | 258 if (m_isInICO) |
255 m_infoHeader.biHeight /= 2; | 259 m_infoHeader.biHeight /= 2; |
256 m_infoHeader.biBitCount = readUint16(14); | 260 m_infoHeader.biBitCount = readUint16(&fastReader, 14); |
257 | 261 |
258 // Read compression type, if present. | 262 // Read compression type, if present. |
259 if (m_infoHeader.biSize >= 20) { | 263 if (m_infoHeader.biSize >= 20) { |
260 uint32_t biCompression = readUint32(16); | 264 uint32_t biCompression = readUint32(&fastReader, 16); |
261 | 265 |
262 // Detect OS/2 2.x-specific compression types. | 266 // Detect OS/2 2.x-specific compression types. |
263 if ((biCompression == 3) && (m_infoHeader.biBitCount == 1)) { | 267 if ((biCompression == 3) && (m_infoHeader.biBitCount == 1)) { |
264 m_infoHeader.biCompression = HUFFMAN1D; | 268 m_infoHeader.biCompression = HUFFMAN1D; |
265 m_isOS22x = true; | 269 m_isOS22x = true; |
266 } else if ((biCompression == 4) && (m_infoHeader.biBitCount == 24)) { | 270 } else if ((biCompression == 4) && (m_infoHeader.biBitCount == 24)) { |
267 m_infoHeader.biCompression = RLE24; | 271 m_infoHeader.biCompression = RLE24; |
268 m_isOS22x = true; | 272 m_isOS22x = true; |
269 } else if (biCompression > 5) | 273 } else if (biCompression > 5) |
270 return m_parent->setFailed(); // Some type we don't understand. | 274 return m_parent->setFailed(); // Some type we don't understand. |
271 else | 275 else |
272 m_infoHeader.biCompression = static_cast<CompressionType>(biCompress ion); | 276 m_infoHeader.biCompression = static_cast<CompressionType>(biCompress ion); |
273 } | 277 } |
274 | 278 |
275 // Read colors used, if present. | 279 // Read colors used, if present. |
276 if (m_infoHeader.biSize >= 36) | 280 if (m_infoHeader.biSize >= 36) { |
Peter Kasting
2015/08/31 19:53:42
Nit: No {}
scroggo_chromium
2015/09/01 22:50:30
Done.
| |
277 m_infoHeader.biClrUsed = readUint32(32); | 281 m_infoHeader.biClrUsed = readUint32(&fastReader, 32); |
282 } | |
278 | 283 |
279 // Windows V4+ can safely read the four bitmasks from 40-56 bytes in, so do | 284 // Windows V4+ can safely read the four bitmasks from 40-56 bytes in, so do |
280 // that here. If the bit depth is less than 16, these values will be ignored | 285 // that here. If the bit depth is less than 16, these values will be ignored |
281 // by the image data decoders. If the bit depth is at least 16 but the | 286 // by the image data decoders. If the bit depth is at least 16 but the |
282 // compression format isn't BITFIELDS, the RGB bitmasks will be ignored and | 287 // compression format isn't BITFIELDS, the RGB bitmasks will be ignored and |
283 // overwritten in processBitmasks(). (The alpha bitmask will never be | 288 // overwritten in processBitmasks(). (The alpha bitmask will never be |
284 // overwritten: images that actually want alpha have to specify a valid | 289 // overwritten: images that actually want alpha have to specify a valid |
285 // alpha mask. See comments in processBitmasks().) | 290 // alpha mask. See comments in processBitmasks().) |
286 // | 291 // |
287 // For non-Windows V4+, m_bitMasks[] et. al will be initialized later | 292 // For non-Windows V4+, m_bitMasks[] et. al will be initialized later |
288 // during processBitmasks(). | 293 // during processBitmasks(). |
289 if (isWindowsV4Plus()) { | 294 if (isWindowsV4Plus()) { |
290 m_bitMasks[0] = readUint32(40); | 295 m_bitMasks[0] = readUint32(&fastReader, 40); |
291 m_bitMasks[1] = readUint32(44); | 296 m_bitMasks[1] = readUint32(&fastReader, 44); |
292 m_bitMasks[2] = readUint32(48); | 297 m_bitMasks[2] = readUint32(&fastReader, 48); |
293 m_bitMasks[3] = readUint32(52); | 298 m_bitMasks[3] = readUint32(&fastReader, 52); |
294 } | 299 } |
295 | 300 |
296 // Detect top-down BMPs. | 301 // Detect top-down BMPs. |
297 if (m_infoHeader.biHeight < 0) { | 302 if (m_infoHeader.biHeight < 0) { |
298 m_isTopDown = true; | 303 m_isTopDown = true; |
299 m_infoHeader.biHeight = -m_infoHeader.biHeight; | 304 m_infoHeader.biHeight = -m_infoHeader.biHeight; |
300 } | 305 } |
301 | 306 |
302 return true; | 307 return true; |
303 } | 308 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 // Fail if we don't have enough file space for the bitmasks. | 428 // Fail if we don't have enough file space for the bitmasks. |
424 const size_t headerEnd = m_headerOffset + m_infoHeader.biSize; | 429 const size_t headerEnd = m_headerOffset + m_infoHeader.biSize; |
425 const size_t bitmasksSize = 12; | 430 const size_t bitmasksSize = 12; |
426 const size_t bitmasksEnd = headerEnd + bitmasksSize; | 431 const size_t bitmasksEnd = headerEnd + bitmasksSize; |
427 if ((bitmasksEnd < headerEnd) || (m_imgDataOffset && (m_imgDataOffset < bitmasksEnd))) | 432 if ((bitmasksEnd < headerEnd) || (m_imgDataOffset && (m_imgDataOffset < bitmasksEnd))) |
428 return m_parent->setFailed(); | 433 return m_parent->setFailed(); |
429 | 434 |
430 // Read bitmasks. | 435 // Read bitmasks. |
431 if ((m_data->size() - m_decodedOffset) < bitmasksSize) | 436 if ((m_data->size() - m_decodedOffset) < bitmasksSize) |
432 return false; | 437 return false; |
433 m_bitMasks[0] = readUint32(0); | 438 |
434 m_bitMasks[1] = readUint32(4); | 439 FastSharedBufferReader fastReader(m_data); |
435 m_bitMasks[2] = readUint32(8); | 440 m_bitMasks[0] = readUint32(&fastReader, 0); |
441 m_bitMasks[1] = readUint32(&fastReader, 4); | |
442 m_bitMasks[2] = readUint32(&fastReader, 8); | |
436 | 443 |
437 m_decodedOffset += bitmasksSize; | 444 m_decodedOffset += bitmasksSize; |
438 } | 445 } |
439 | 446 |
440 // Alpha is a poorly-documented and inconsistently-used feature. | 447 // Alpha is a poorly-documented and inconsistently-used feature. |
441 // | 448 // |
442 // Windows V4+ has an alpha bitmask in the info header. Unlike the R/G/B | 449 // Windows V4+ has an alpha bitmask in the info header. Unlike the R/G/B |
443 // bitmasks, the MSDN docs don't indicate that it is only valid for the | 450 // bitmasks, the MSDN docs don't indicate that it is only valid for the |
444 // BITFIELDS compression format, so we respect it at all times. | 451 // BITFIELDS compression format, so we respect it at all times. |
445 // | 452 // |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 const size_t tableSizeInBytes = m_infoHeader.biClrUsed * (m_isOS21x ? 3 : 4) ; | 542 const size_t tableSizeInBytes = m_infoHeader.biClrUsed * (m_isOS21x ? 3 : 4) ; |
536 const size_t tableEnd = headerEnd + tableSizeInBytes; | 543 const size_t tableEnd = headerEnd + tableSizeInBytes; |
537 if ((tableEnd < headerEnd) || (m_imgDataOffset && (m_imgDataOffset < tableEn d))) | 544 if ((tableEnd < headerEnd) || (m_imgDataOffset && (m_imgDataOffset < tableEn d))) |
538 return m_parent->setFailed(); | 545 return m_parent->setFailed(); |
539 | 546 |
540 // Read color table. | 547 // Read color table. |
541 if ((m_decodedOffset > m_data->size()) || ((m_data->size() - m_decodedOffset ) < tableSizeInBytes)) | 548 if ((m_decodedOffset > m_data->size()) || ((m_data->size() - m_decodedOffset ) < tableSizeInBytes)) |
542 return false; | 549 return false; |
543 m_colorTable.resize(m_infoHeader.biClrUsed); | 550 m_colorTable.resize(m_infoHeader.biClrUsed); |
544 for (size_t i = 0; i < m_infoHeader.biClrUsed; ++i) { | 551 for (size_t i = 0; i < m_infoHeader.biClrUsed; ++i) { |
545 m_colorTable[i].rgbBlue = m_data->data()[m_decodedOffset++]; | 552 m_colorTable[i].rgbBlue = getByte(m_decodedOffset++); |
546 m_colorTable[i].rgbGreen = m_data->data()[m_decodedOffset++]; | 553 m_colorTable[i].rgbGreen = getByte(m_decodedOffset++); |
547 m_colorTable[i].rgbRed = m_data->data()[m_decodedOffset++]; | 554 m_colorTable[i].rgbRed = getByte(m_decodedOffset++); |
548 // Skip padding byte (not present on OS/2 1.x). | 555 // Skip padding byte (not present on OS/2 1.x). |
549 if (!m_isOS21x) | 556 if (!m_isOS21x) |
550 ++m_decodedOffset; | 557 ++m_decodedOffset; |
551 } | 558 } |
552 | 559 |
553 // We've now decoded all the non-image data we care about. Skip anything | 560 // We've now decoded all the non-image data we care about. Skip anything |
554 // else before the actual raster data. | 561 // else before the actual raster data. |
555 if (m_imgDataOffset) | 562 if (m_imgDataOffset) |
556 m_decodedOffset = m_imgDataOffset; | 563 m_decodedOffset = m_imgDataOffset; |
557 m_needToProcessColorTable = false; | 564 m_needToProcessColorTable = false; |
(...skipping 29 matching lines...) Expand all Loading... | |
587 // Impossible to decode row-at-a-time, so just do things as a stream of | 594 // Impossible to decode row-at-a-time, so just do things as a stream of |
588 // bytes. | 595 // bytes. |
589 while (true) { | 596 while (true) { |
590 // Every entry takes at least two bytes; bail if there isn't enough | 597 // Every entry takes at least two bytes; bail if there isn't enough |
591 // data. | 598 // data. |
592 if ((m_data->size() - m_decodedOffset) < 2) | 599 if ((m_data->size() - m_decodedOffset) < 2) |
593 return InsufficientData; | 600 return InsufficientData; |
594 | 601 |
595 // For every entry except EOF, we'd better not have reached the end of | 602 // For every entry except EOF, we'd better not have reached the end of |
596 // the image. | 603 // the image. |
597 const uint8_t count = m_data->data()[m_decodedOffset]; | 604 const uint8_t count = getByte(m_decodedOffset); |
598 const uint8_t code = m_data->data()[m_decodedOffset + 1]; | 605 const uint8_t code = getByte(m_decodedOffset + 1); |
599 if ((count || (code != 1)) && pastEndOfImage(0)) | 606 if ((count || (code != 1)) && pastEndOfImage(0)) |
600 return Failure; | 607 return Failure; |
601 | 608 |
602 // Decode. | 609 // Decode. |
603 if (!count) { | 610 if (!count) { |
604 switch (code) { | 611 switch (code) { |
605 case 0: // Magic token: EOL | 612 case 0: // Magic token: EOL |
606 // Skip any remaining pixels in this row. | 613 // Skip any remaining pixels in this row. |
607 if (m_coord.x() < m_parent->size().width()) | 614 if (m_coord.x() < m_parent->size().width()) |
608 m_buffer->setHasAlpha(true); | 615 m_buffer->setHasAlpha(true); |
(...skipping 13 matching lines...) Expand all Loading... | |
622 return Success; | 629 return Success; |
623 | 630 |
624 case 2: { // Magic token: Delta | 631 case 2: { // Magic token: Delta |
625 // The next two bytes specify dx and dy. Bail if there isn't | 632 // The next two bytes specify dx and dy. Bail if there isn't |
626 // enough data. | 633 // enough data. |
627 if ((m_data->size() - m_decodedOffset) < 4) | 634 if ((m_data->size() - m_decodedOffset) < 4) |
628 return InsufficientData; | 635 return InsufficientData; |
629 | 636 |
630 // Fail if this takes us past the end of the desired row or | 637 // Fail if this takes us past the end of the desired row or |
631 // past the end of the image. | 638 // past the end of the image. |
632 const uint8_t dx = m_data->data()[m_decodedOffset + 2]; | 639 const uint8_t dx = getByte(m_decodedOffset + 2); |
633 const uint8_t dy = m_data->data()[m_decodedOffset + 3]; | 640 const uint8_t dy = getByte(m_decodedOffset + 3); |
634 if (dx || dy) | 641 if (dx || dy) |
635 m_buffer->setHasAlpha(true); | 642 m_buffer->setHasAlpha(true); |
636 if (((m_coord.x() + dx) > m_parent->size().width()) || pastEndOf Image(dy)) | 643 if (((m_coord.x() + dx) > m_parent->size().width()) || pastEndOf Image(dy)) |
637 return Failure; | 644 return Failure; |
638 | 645 |
639 // Skip intervening pixels. | 646 // Skip intervening pixels. |
640 m_coord.move(dx, m_isTopDown ? dy : -dy); | 647 m_coord.move(dx, m_isTopDown ? dy : -dy); |
641 | 648 |
642 m_decodedOffset += 4; | 649 m_decodedOffset += 4; |
643 break; | 650 break; |
(...skipping 19 matching lines...) Expand all Loading... | |
663 // Strangely, some BMPs seem to specify excessively large counts | 670 // Strangely, some BMPs seem to specify excessively large counts |
664 // here; ignore pixels past the end of the row. | 671 // here; ignore pixels past the end of the row. |
665 const int endX = std::min(m_coord.x() + count, m_parent->size().widt h()); | 672 const int endX = std::min(m_coord.x() + count, m_parent->size().widt h()); |
666 | 673 |
667 if (m_infoHeader.biCompression == RLE24) { | 674 if (m_infoHeader.biCompression == RLE24) { |
668 // Bail if there isn't enough data. | 675 // Bail if there isn't enough data. |
669 if ((m_data->size() - m_decodedOffset) < 4) | 676 if ((m_data->size() - m_decodedOffset) < 4) |
670 return InsufficientData; | 677 return InsufficientData; |
671 | 678 |
672 // One BGR triple that we copy |count| times. | 679 // One BGR triple that we copy |count| times. |
673 fillRGBA(endX, m_data->data()[m_decodedOffset + 3], m_data->data ()[m_decodedOffset + 2], code, 0xff); | 680 fillRGBA(endX, getByte(m_decodedOffset + 3), getByte(m_decodedOf fset + 2), code, 0xff); |
674 m_decodedOffset += 4; | 681 m_decodedOffset += 4; |
675 } else { | 682 } else { |
676 // RLE8 has one color index that gets repeated; RLE4 has two | 683 // RLE8 has one color index that gets repeated; RLE4 has two |
677 // color indexes in the upper and lower 4 bits of the byte, | 684 // color indexes in the upper and lower 4 bits of the byte, |
678 // which are alternated. | 685 // which are alternated. |
679 size_t colorIndexes[2] = {code, code}; | 686 size_t colorIndexes[2] = {code, code}; |
680 if (m_infoHeader.biCompression == RLE4) { | 687 if (m_infoHeader.biCompression == RLE4) { |
681 colorIndexes[0] = (colorIndexes[0] >> 4) & 0xf; | 688 colorIndexes[0] = (colorIndexes[0] >> 4) & 0xf; |
682 colorIndexes[1] &= 0xf; | 689 colorIndexes[1] &= 0xf; |
683 } | 690 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 // Bail if we don't have enough data for the desired number of pixels. | 733 // Bail if we don't have enough data for the desired number of pixels. |
727 if ((m_data->size() - m_decodedOffset) < paddedNumBytes) | 734 if ((m_data->size() - m_decodedOffset) < paddedNumBytes) |
728 return InsufficientData; | 735 return InsufficientData; |
729 | 736 |
730 if (m_infoHeader.biBitCount < 16) { | 737 if (m_infoHeader.biBitCount < 16) { |
731 // Paletted data. Pixels are stored little-endian within bytes. | 738 // Paletted data. Pixels are stored little-endian within bytes. |
732 // Decode pixels one byte at a time, left to right (so, starting at | 739 // Decode pixels one byte at a time, left to right (so, starting at |
733 // the most significant bits in the byte). | 740 // the most significant bits in the byte). |
734 const uint8_t mask = (1 << m_infoHeader.biBitCount) - 1; | 741 const uint8_t mask = (1 << m_infoHeader.biBitCount) - 1; |
735 for (size_t byte = 0; byte < unpaddedNumBytes; ++byte) { | 742 for (size_t byte = 0; byte < unpaddedNumBytes; ++byte) { |
736 uint8_t pixelData = m_data->data()[m_decodedOffset + byte]; | 743 uint8_t pixelData = getByte(m_decodedOffset + byte); |
737 for (size_t pixel = 0; (pixel < pixelsPerByte) && (m_coord.x() < endX); ++pixel) { | 744 for (size_t pixel = 0; (pixel < pixelsPerByte) && (m_coord.x() < endX); ++pixel) { |
738 const size_t colorIndex = (pixelData >> (8 - m_infoHeader.bi BitCount)) & mask; | 745 const size_t colorIndex = (pixelData >> (8 - m_infoHeader.bi BitCount)) & mask; |
739 if (m_decodingAndMask) { | 746 if (m_decodingAndMask) { |
740 // There's no way to accurately represent an AND + XOR | 747 // There's no way to accurately represent an AND + XOR |
741 // operation as an RGBA image, so where the AND values | 748 // operation as an RGBA image, so where the AND values |
742 // are 1, we simply set the framebuffer pixels to fully | 749 // are 1, we simply set the framebuffer pixels to fully |
743 // transparent, on the assumption that most ICOs on the | 750 // transparent, on the assumption that most ICOs on the |
744 // web will not be doing a lot of inverting. | 751 // web will not be doing a lot of inverting. |
745 if (colorIndex) { | 752 if (colorIndex) { |
746 setRGBA(0, 0, 0, 0); | 753 setRGBA(0, 0, 0, 0); |
747 m_buffer->setHasAlpha(true); | 754 m_buffer->setHasAlpha(true); |
748 } else | 755 } else |
749 m_coord.move(1, 0); | 756 m_coord.move(1, 0); |
750 } else { | 757 } else { |
751 // See comments near the end of processRLEData(). | 758 // See comments near the end of processRLEData(). |
752 if (colorIndex < m_infoHeader.biClrUsed) | 759 if (colorIndex < m_infoHeader.biClrUsed) |
753 setI(colorIndex); | 760 setI(colorIndex); |
754 else | 761 else |
755 setRGBA(0, 0, 0, 255); | 762 setRGBA(0, 0, 0, 255); |
756 } | 763 } |
757 pixelData <<= m_infoHeader.biBitCount; | 764 pixelData <<= m_infoHeader.biBitCount; |
758 } | 765 } |
759 } | 766 } |
760 } else { | 767 } else { |
768 FastSharedBufferReader fastReader(m_data); | |
769 | |
761 // RGB data. Decode pixels one at a time, left to right. | 770 // RGB data. Decode pixels one at a time, left to right. |
762 while (m_coord.x() < endX) { | 771 while (m_coord.x() < endX) { |
763 const uint32_t pixel = readCurrentPixel(bytesPerPixel); | 772 const uint32_t pixel = readCurrentPixel(&fastReader, bytesPerPix el); |
764 | 773 |
765 // Some BMPs specify an alpha channel but don't actually use it | 774 // Some BMPs specify an alpha channel but don't actually use it |
766 // (it contains all 0s). To avoid displaying these images as | 775 // (it contains all 0s). To avoid displaying these images as |
767 // fully-transparent, decode as if images are fully opaque | 776 // fully-transparent, decode as if images are fully opaque |
768 // until we actually see a non-zero alpha value; at that point, | 777 // until we actually see a non-zero alpha value; at that point, |
769 // reset any previously-decoded pixels to fully transparent and | 778 // reset any previously-decoded pixels to fully transparent and |
770 // continue decoding based on the real alpha channel values. | 779 // continue decoding based on the real alpha channel values. |
771 // As an optimization, avoid setting "hasAlpha" to true for | 780 // As an optimization, avoid setting "hasAlpha" to true for |
772 // images where all alpha values are 255; opaque images are | 781 // images where all alpha values are 255; opaque images are |
773 // faster to draw. | 782 // faster to draw. |
(...skipping 25 matching lines...) Expand all Loading... | |
799 // Finished decoding whole image. | 808 // Finished decoding whole image. |
800 return Success; | 809 return Success; |
801 } | 810 } |
802 | 811 |
803 void BMPImageReader::moveBufferToNextRow() | 812 void BMPImageReader::moveBufferToNextRow() |
804 { | 813 { |
805 m_coord.move(-m_coord.x(), m_isTopDown ? 1 : -1); | 814 m_coord.move(-m_coord.x(), m_isTopDown ? 1 : -1); |
806 } | 815 } |
807 | 816 |
808 } // namespace blink | 817 } // namespace blink |
OLD | NEW |