Changeset 44597 in webkit
- Timestamp:
- Jun 10, 2009 5:31:20 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r44593 r44597 1 2009-06-10 Peter Kasting <pkasting@google.com> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=25709 part six 6 Miscellaneous tiny changes. The important bits here are the ANSI C++ 7 compliance fix in skia/ImageDecoders.h (needed to compile this file on 8 non-MSVC) and some behavioral fixes for the XBM decoder that Chromium 9 unit tests partly exposed. Other changes are mostly cosmetic. 10 11 * platform/image-decoders/ImageDecoder.h: Make some variables private again. This will break QTWebKit but those guys have agreed to wait on my finishing the ImageDecoder changes. 12 * platform/image-decoders/gif/GIFImageDecoder.cpp: 13 (WebCore::GIFImageDecoder::initFrameBuffer): Use IntPoint() instead of the redundant IntPoint(0, 0). 14 (WebCore::GIFImageDecoder::frameComplete): Use IntPoint() instead of the redundant IntPoint(0, 0). 15 * platform/image-decoders/jpeg/JPEGImageDecoder.cpp: 16 (WebCore::JPEGImageDecoder::outputScanlines): Remove obvious comments. 17 * platform/image-decoders/png/PNGImageDecoder.cpp: 18 (WebCore::PNGImageDecoder::rowAvailable): Remove obvious comments. 19 * platform/image-decoders/skia/BMPImageReader.cpp: 20 (WebCore::BMPImageReader::decodeBMP): Make more in line with other decoders' comments and structure, use a ref to decrease verbosity. 21 (WebCore::BMPImageReader::processRLEData): Use a ref to decrease verbosity. 22 (WebCore::BMPImageReader::processNonRLEData): Use a ref to decrease verbosity. 23 * platform/image-decoders/skia/GIFImageDecoder.cpp: Use IntPoint() instead of the redundant IntPoint(0, 0). 24 (WebCore::GIFImageDecoder::initFrameBuffer): Use IntPoint() instead of the redundant IntPoint(0, 0). 25 (WebCore::GIFImageDecoder::frameComplete): Use IntPoint() instead of the redundant IntPoint(0, 0). 26 * platform/image-decoders/skia/ImageDecoder.h: 27 (WebCore::RGBA32Buffer::copyRowNTimes): Fix ANSI violation that MSVC let me compile (!). 28 * platform/image-decoders/skia/JPEGImageDecoder.cpp: 29 (WebCore::JPEGImageDecoder::outputScanlines): Remove obvious comments. 30 * platform/image-decoders/skia/PNGImageDecoder.cpp: 31 (WebCore::PNGImageDecoder::rowAvailable): Remove obvious comments. 32 * platform/image-decoders/skia/XBMImageDecoder.cpp: 33 (WebCore::XBMImageDecoder::frameBufferAtIndex): Return 0 for non-zero indexes, don't try to decode unnecessarily after failure or when the size couldn't be computed, make more in line with other decoders' comments and structure, call RGBA32Buffer::setRect() appropriately. 34 1 35 2009-06-10 Ojan Vafai <ojan@chromium.org> 2 36 -
trunk/WebCore/platform/image-decoders/ImageDecoder.h
r44562 r44597 221 221 Vector<RGBA32Buffer> m_frameBufferCache; 222 222 mutable bool m_failed; 223 IntSize m_size;224 bool m_sizeAvailable;225 223 226 224 private: … … 235 233 return total_size > ((1 << 29) - 1); 236 234 } 235 236 IntSize m_size; 237 bool m_sizeAvailable; 237 238 }; 238 239 -
trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
r44553 r44597 311 311 const IntRect& prevRect = prevBuffer->rect(); 312 312 if ((frameIndex == 0) 313 || prevRect.contains(IntRect(IntPoint( 0, 0), size()))) {313 || prevRect.contains(IntRect(IntPoint(), size()))) { 314 314 // Clearing the first frame, or a frame the size of the whole 315 315 // image, results in a completely empty image. … … 430 430 // The whole frame was non-transparent, so it's possible that the entire 431 431 // resulting buffer was non-transparent, and we can setHasAlpha(false). 432 if (buffer.rect().contains(IntRect(IntPoint( 0, 0), size())))432 if (buffer.rect().contains(IntRect(IntPoint(), size()))) 433 433 buffer.setHasAlpha(false); 434 434 else if (frameIndex > 0) { -
trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
r44556 r44597 459 459 return false; 460 460 461 // Resize to the width and height of the image.461 // Initialize the framebuffer if needed. 462 462 RGBA32Buffer& buffer = m_frameBufferCache[0]; 463 463 if (buffer.status() == RGBA32Buffer::FrameEmpty) { 464 // Let's resize our buffer now to the correct width/height. This will465 // also initialize it to transparent.466 464 if (!buffer.setSize(size().width(), size().height())) { 467 465 m_failed = true; 468 466 return false; 469 467 } 470 471 // Update our status to be partially complete.472 468 buffer.setStatus(RGBA32Buffer::FramePartial); 473 469 buffer.setHasAlpha(false); -
trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
r44553 r44597 318 318 return; 319 319 320 // Resize to the width and height of the image.320 // Initialize the framebuffer if needed. 321 321 RGBA32Buffer& buffer = m_frameBufferCache[0]; 322 322 if (buffer.status() == RGBA32Buffer::FrameEmpty) { 323 // Let's resize our buffer now to the correct width/height.324 323 if (!buffer.setSize(size().width(), size().height())) { 325 // Error allocating the bitmap. We should not continue.326 324 static_cast<PNGImageDecoder*>(png_get_progressive_ptr(reader()->pngPtr()))->decodingFailed(); 327 325 longjmp(reader()->pngPtr()->jmpbuf, 1); 328 326 return; 329 327 } 330 331 // Update our status to be partially complete.332 328 buffer.setStatus(RGBA32Buffer::FramePartial); 333 329 buffer.setHasAlpha(false); -
trunk/WebCore/platform/image-decoders/skia/BMPImageReader.cpp
r44573 r44597 112 112 return; 113 113 114 // Initialize frame buffer state, if needed. 115 if (m_frameBufferCache.first().status() == RGBA32Buffer::FrameEmpty) { 116 m_frameBufferCache.first().setRect(IntRect(IntPoint(), size())); 117 m_frameBufferCache.first().setStatus(RGBA32Buffer::FramePartial); 118 if (!m_frameBufferCache.first().setSize(m_infoHeader.biWidth, 119 m_infoHeader.biHeight)) { 114 // Initialize the framebuffer if needed. 115 RGBA32Buffer& buffer = m_frameBufferCache.first(); 116 if (buffer.status() == RGBA32Buffer::FrameEmpty) { 117 if (!buffer.setSize(size().width(), size().height())) { 120 118 // Unable to allocate. 121 119 m_failed = true; 122 120 return; 123 121 } 124 122 buffer.setStatus(RGBA32Buffer::FramePartial); 125 123 // setSize() calls eraseARGB(), which resets the alpha flag, so we force 126 124 // it back to false here. We'll set it true below in all cases where 127 125 // these 0s could actually show through. 128 m_frameBufferCache.first().setHasAlpha(false); 126 buffer.setHasAlpha(false); 127 128 // For BMPs, the frame always fills the entire image. 129 buffer.setRect(IntRect(IntPoint(), size())); 130 129 131 if (!m_isTopDown) 130 132 m_coord.setY(size().height() - 1); … … 144 146 // If the image has an AND mask and there was no alpha data, process the 145 147 // mask. 146 if ((m_andMaskState == NotYetDecoded) 147 && !m_frameBufferCache.first().hasAlpha()) { 148 if ((m_andMaskState == NotYetDecoded) && !buffer.hasAlpha()) { 148 149 // Reset decoding coordinates to start of image. 149 150 m_coord.setX(0); … … 159 160 160 161 // Done! 161 m_frameBufferCache.first().setStatus(RGBA32Buffer::FrameComplete);162 buffer.setStatus(RGBA32Buffer::FrameComplete); 162 163 } 163 164 … … 606 607 // Impossible to decode row-at-a-time, so just do things as a stream of 607 608 // bytes. 609 RGBA32Buffer& buffer = m_frameBufferCache.first(); 608 610 while (true) { 609 611 // Every entry takes at least two bytes; bail if there isn't enough … … 627 629 // Skip any remaining pixels in this row. 628 630 if (m_coord.x() < size().width()) 629 m_frameBufferCache.first().setHasAlpha(true);631 buffer.setHasAlpha(true); 630 632 moveBufferToNextRow(); 631 633 … … 637 639 if ((m_coord.x() < size().width()) 638 640 || (m_isTopDown ? (m_coord.y() < (size().height() - 1)) : (m_coord.y() > 0))) 639 m_frameBufferCache.first().setHasAlpha(true);641 buffer.setHasAlpha(true); 640 642 return true; 641 643 … … 651 653 const uint8_t dy = data->data()[m_decodedOffset + 3]; 652 654 if ((dx != 0) || (dy != 0)) 653 m_frameBufferCache.first().setHasAlpha(true);655 buffer.setHasAlpha(true); 654 656 if (((m_coord.x() + dx) > size().width()) || 655 657 pastEndOfImage(dy)) { … … 747 749 // Decode as many rows as we can. (For RLE, where we only want to decode 748 750 // one row, we've already checked that this condition is true.) 751 RGBA32Buffer& buffer = m_frameBufferCache.first(); 749 752 while (!pastEndOfImage(0)) { 750 753 // Bail if we don't have enough data for the desired number of pixels. … … 770 773 if (colorIndex) { 771 774 setRGBA(0, 0, 0, 0); 772 m_frameBufferCache.first().setHasAlpha(true);775 buffer.setHasAlpha(true); 773 776 } else 774 777 m_coord.move(1, 0); … … 804 807 m_seenNonZeroAlphaPixel = true; 805 808 if (m_seenZeroAlphaPixel) { 806 m_frameBufferCache.first().zeroFill();809 buffer.zeroFill(); 807 810 m_seenZeroAlphaPixel = false; 808 811 } else if (alpha != 255) 809 m_frameBufferCache.first().setHasAlpha(true);812 buffer.setHasAlpha(true); 810 813 } 811 814 -
trunk/WebCore/platform/image-decoders/skia/GIFImageDecoder.cpp
r44573 r44597 312 312 const IntRect& prevRect = prevBuffer->rect(); 313 313 if ((frameIndex == 0) 314 || prevRect.contains(IntRect(IntPoint( 0, 0), size()))) {314 || prevRect.contains(IntRect(IntPoint(), size()))) { 315 315 // Clearing the first frame, or a frame the size of the whole 316 316 // image, results in a completely empty image. … … 412 412 // The whole frame was non-transparent, so it's possible that the entire 413 413 // resulting buffer was non-transparent, and we can setHasAlpha(false). 414 if (buffer.rect().contains(IntRect(IntPoint( 0, 0), size())))414 if (buffer.rect().contains(IntRect(IntPoint(), size()))) 415 415 buffer.setHasAlpha(false); 416 416 else if (frameIndex > 0) { -
trunk/WebCore/platform/image-decoders/skia/ImageDecoder.h
r44573 r44597 134 134 ASSERT(startY < m_bitmap.height()); 135 135 ASSERT(endY <= m_bitmap.height()); 136 const int rowBytes = (endX - startX) * sizeof uint32_t;136 const int rowBytes = (endX - startX) * sizeof(uint32_t); 137 137 const uint32_t* const startAddr = m_bitmap.getAddr32(startX, startY); 138 138 for (int destY = startY + 1; destY < endY; ++destY) -
trunk/WebCore/platform/image-decoders/skia/JPEGImageDecoder.cpp
r44553 r44597 459 459 return false; 460 460 461 // Resize to the width and height of the image.461 // Initialize the framebuffer if needed. 462 462 RGBA32Buffer& buffer = m_frameBufferCache[0]; 463 463 if (buffer.status() == RGBA32Buffer::FrameEmpty) { 464 // Let's resize our buffer now to the correct width/height. This will465 // also initialize it to transparent.466 464 if (!buffer.setSize(size().width(), size().height())) { 467 465 m_failed = true; 468 466 return false; 469 467 } 470 471 // Update our status to be partially complete.472 468 buffer.setStatus(RGBA32Buffer::FramePartial); 473 469 buffer.setHasAlpha(false); -
trunk/WebCore/platform/image-decoders/skia/PNGImageDecoder.cpp
r44553 r44597 319 319 return; 320 320 321 // Resize to the width and height of the image.321 // Initialize the framebuffer if needed. 322 322 RGBA32Buffer& buffer = m_frameBufferCache[0]; 323 323 if (buffer.status() == RGBA32Buffer::FrameEmpty) { 324 // Let's resize our buffer now to the correct width/height.325 324 if (!buffer.setSize(size().width(), size().height())) { 326 // Error allocating the bitmap. We should not continue.327 325 static_cast<PNGImageDecoder*>(png_get_progressive_ptr(reader()->pngPtr()))->decodingFailed(); 328 326 longjmp(reader()->pngPtr()->jmpbuf, 1); 329 327 return; 330 328 } 331 332 // Update our status to be partially complete.333 329 buffer.setStatus(RGBA32Buffer::FramePartial); 334 330 buffer.setHasAlpha(false); -
trunk/WebCore/platform/image-decoders/skia/XBMImageDecoder.cpp
r44545 r44597 71 71 RGBA32Buffer* XBMImageDecoder::frameBufferAtIndex(size_t index) 72 72 { 73 // Allocate a framebuffer if necessary. New framebuffers have their status 74 // initialized to RGBA32Buffer::FrameEmpty. 73 if (index) 74 return 0; 75 75 76 if (m_frameBufferCache.isEmpty()) 76 77 m_frameBufferCache.resize(1); 77 78 RGBA32Buffer& frame = m_frameBufferCache[0];79 78 80 79 // Attempt to get the size if we don't have it yet. … … 82 81 decodeXBM(true); 83 82 84 // Size the framebuffer once we know the right size. 85 if (ImageDecoder::isSizeAvailable() && 86 frame.status() == RGBA32Buffer::FrameEmpty) { 87 if (!frame.setSize(size().width(), size().height())) { 83 // Initialize the framebuffer if needed. 84 RGBA32Buffer& buffer = m_frameBufferCache[0]; 85 if (!failed() && ImageDecoder::isSizeAvailable() 86 && (buffer.status() == RGBA32Buffer::FrameEmpty)) { 87 if (!buffer.setSize(size().width(), size().height())) { 88 88 m_failed = true; 89 89 return 0; 90 90 } 91 frame.setStatus(RGBA32Buffer::FramePartial); 92 } 93 91 buffer.setStatus(RGBA32Buffer::FramePartial); 92 93 // For XBMs, the frame always fills the entire image. 94 buffer.setRect(IntRect(IntPoint(), size())); 95 } 96 94 97 // Keep trying to decode until we've got the entire image. 95 if ( frame.status() != RGBA32Buffer::FrameComplete)98 if (buffer.status() == RGBA32Buffer::FramePartial) 96 99 decodeXBM(false); 97 100 98 return & frame;101 return &buffer; 99 102 } 100 103
Note: See TracChangeset
for help on using the changeset viewer.