Changeset 44597 in webkit


Ignore:
Timestamp:
Jun 10, 2009 5:31:20 PM (15 years ago)
Author:
pkasting@chromium.org
Message:

2009-06-10 Peter Kasting <pkasting@google.com>

Reviewed by Eric Seidel.

https://bugs.webkit.org/show_bug.cgi?id=25709 part six
Miscellaneous tiny changes. The important bits here are the ANSI C++
compliance fix in skia/ImageDecoders.h (needed to compile this file on
non-MSVC) and some behavioral fixes for the XBM decoder that Chromium
unit tests partly exposed. Other changes are mostly cosmetic.

  • 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.
  • platform/image-decoders/gif/GIFImageDecoder.cpp: (WebCore::GIFImageDecoder::initFrameBuffer): Use IntPoint() instead of the redundant IntPoint(0, 0). (WebCore::GIFImageDecoder::frameComplete): Use IntPoint() instead of the redundant IntPoint(0, 0).
  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp: (WebCore::JPEGImageDecoder::outputScanlines): Remove obvious comments.
  • platform/image-decoders/png/PNGImageDecoder.cpp: (WebCore::PNGImageDecoder::rowAvailable): Remove obvious comments.
  • platform/image-decoders/skia/BMPImageReader.cpp: (WebCore::BMPImageReader::decodeBMP): Make more in line with other decoders' comments and structure, use a ref to decrease verbosity. (WebCore::BMPImageReader::processRLEData): Use a ref to decrease verbosity. (WebCore::BMPImageReader::processNonRLEData): Use a ref to decrease verbosity.
  • platform/image-decoders/skia/GIFImageDecoder.cpp: Use IntPoint() instead of the redundant IntPoint(0, 0). (WebCore::GIFImageDecoder::initFrameBuffer): Use IntPoint() instead of the redundant IntPoint(0, 0). (WebCore::GIFImageDecoder::frameComplete): Use IntPoint() instead of the redundant IntPoint(0, 0).
  • platform/image-decoders/skia/ImageDecoder.h: (WebCore::RGBA32Buffer::copyRowNTimes): Fix ANSI violation that MSVC let me compile (!).
  • platform/image-decoders/skia/JPEGImageDecoder.cpp: (WebCore::JPEGImageDecoder::outputScanlines): Remove obvious comments.
  • platform/image-decoders/skia/PNGImageDecoder.cpp: (WebCore::PNGImageDecoder::rowAvailable): Remove obvious comments.
  • platform/image-decoders/skia/XBMImageDecoder.cpp: (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.
Location:
trunk/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r44593 r44597  
     12009-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
    1352009-06-10  Ojan Vafai  <ojan@chromium.org>
    236
  • trunk/WebCore/platform/image-decoders/ImageDecoder.h

    r44562 r44597  
    221221        Vector<RGBA32Buffer> m_frameBufferCache;
    222222        mutable bool m_failed;
    223         IntSize m_size;
    224         bool m_sizeAvailable;
    225223
    226224    private:
     
    235233            return total_size > ((1 << 29) - 1);
    236234        }
     235
     236        IntSize m_size;
     237        bool m_sizeAvailable;
    237238    };
    238239
  • trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

    r44553 r44597  
    311311            const IntRect& prevRect = prevBuffer->rect();
    312312            if ((frameIndex == 0)
    313                 || prevRect.contains(IntRect(IntPoint(0, 0), size()))) {
     313                || prevRect.contains(IntRect(IntPoint(), size()))) {
    314314                // Clearing the first frame, or a frame the size of the whole
    315315                // image, results in a completely empty image.
     
    430430        // The whole frame was non-transparent, so it's possible that the entire
    431431        // 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())))
    433433            buffer.setHasAlpha(false);
    434434        else if (frameIndex > 0) {
  • trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r44556 r44597  
    459459        return false;
    460460
    461     // Resize to the width and height of the image.
     461    // Initialize the framebuffer if needed.
    462462    RGBA32Buffer& buffer = m_frameBufferCache[0];
    463463    if (buffer.status() == RGBA32Buffer::FrameEmpty) {
    464         // Let's resize our buffer now to the correct width/height. This will
    465         // also initialize it to transparent.
    466464        if (!buffer.setSize(size().width(), size().height())) {
    467465            m_failed = true;
    468466            return false;
    469467        }
    470 
    471         // Update our status to be partially complete.
    472468        buffer.setStatus(RGBA32Buffer::FramePartial);
    473469        buffer.setHasAlpha(false);
  • trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp

    r44553 r44597  
    318318        return;
    319319
    320     // Resize to the width and height of the image.
     320    // Initialize the framebuffer if needed.
    321321    RGBA32Buffer& buffer = m_frameBufferCache[0];
    322322    if (buffer.status() == RGBA32Buffer::FrameEmpty) {
    323         // Let's resize our buffer now to the correct width/height.
    324323        if (!buffer.setSize(size().width(), size().height())) {
    325             // Error allocating the bitmap. We should not continue.
    326324            static_cast<PNGImageDecoder*>(png_get_progressive_ptr(reader()->pngPtr()))->decodingFailed();
    327325            longjmp(reader()->pngPtr()->jmpbuf, 1);
    328326            return;
    329327        }
    330 
    331         // Update our status to be partially complete.
    332328        buffer.setStatus(RGBA32Buffer::FramePartial);
    333329        buffer.setHasAlpha(false);
  • trunk/WebCore/platform/image-decoders/skia/BMPImageReader.cpp

    r44573 r44597  
    112112        return;
    113113
    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())) {
    120118            // Unable to allocate.
    121119            m_failed = true;
    122120            return;
    123121        }
    124 
     122        buffer.setStatus(RGBA32Buffer::FramePartial);
    125123        // setSize() calls eraseARGB(), which resets the alpha flag, so we force
    126124        // it back to false here.  We'll set it true below in all cases where
    127125        // 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
    129131        if (!m_isTopDown)
    130132            m_coord.setY(size().height() - 1);
     
    144146    // If the image has an AND mask and there was no alpha data, process the
    145147    // mask.
    146     if ((m_andMaskState == NotYetDecoded)
    147         && !m_frameBufferCache.first().hasAlpha()) {
     148    if ((m_andMaskState == NotYetDecoded) && !buffer.hasAlpha()) {
    148149        // Reset decoding coordinates to start of image.
    149150        m_coord.setX(0);
     
    159160
    160161    // Done!
    161     m_frameBufferCache.first().setStatus(RGBA32Buffer::FrameComplete);
     162    buffer.setStatus(RGBA32Buffer::FrameComplete);
    162163}
    163164
     
    606607    // Impossible to decode row-at-a-time, so just do things as a stream of
    607608    // bytes.
     609    RGBA32Buffer& buffer = m_frameBufferCache.first();
    608610    while (true) {
    609611        // Every entry takes at least two bytes; bail if there isn't enough
     
    627629                // Skip any remaining pixels in this row.
    628630                if (m_coord.x() < size().width())
    629                     m_frameBufferCache.first().setHasAlpha(true);
     631                    buffer.setHasAlpha(true);
    630632                moveBufferToNextRow();
    631633
     
    637639                if ((m_coord.x() < size().width())
    638640                    || (m_isTopDown ? (m_coord.y() < (size().height() - 1)) : (m_coord.y() > 0)))
    639                     m_frameBufferCache.first().setHasAlpha(true);
     641                    buffer.setHasAlpha(true);
    640642                return true;
    641643
     
    651653                const uint8_t dy = data->data()[m_decodedOffset + 3];
    652654                if ((dx != 0) || (dy != 0))
    653                     m_frameBufferCache.first().setHasAlpha(true);
     655                    buffer.setHasAlpha(true);
    654656                if (((m_coord.x() + dx) > size().width()) ||
    655657                    pastEndOfImage(dy)) {
     
    747749    // Decode as many rows as we can.  (For RLE, where we only want to decode
    748750    // one row, we've already checked that this condition is true.)
     751    RGBA32Buffer& buffer = m_frameBufferCache.first();
    749752    while (!pastEndOfImage(0)) {
    750753        // Bail if we don't have enough data for the desired number of pixels.
     
    770773                        if (colorIndex) {
    771774                            setRGBA(0, 0, 0, 0);
    772                             m_frameBufferCache.first().setHasAlpha(true);
     775                            buffer.setHasAlpha(true);
    773776                        } else
    774777                            m_coord.move(1, 0);
     
    804807                    m_seenNonZeroAlphaPixel = true;
    805808                    if (m_seenZeroAlphaPixel) {
    806                         m_frameBufferCache.first().zeroFill();
     809                        buffer.zeroFill();
    807810                        m_seenZeroAlphaPixel = false;
    808811                    } else if (alpha != 255)
    809                         m_frameBufferCache.first().setHasAlpha(true);
     812                        buffer.setHasAlpha(true);
    810813                }
    811814
  • trunk/WebCore/platform/image-decoders/skia/GIFImageDecoder.cpp

    r44573 r44597  
    312312            const IntRect& prevRect = prevBuffer->rect();
    313313            if ((frameIndex == 0)
    314                 || prevRect.contains(IntRect(IntPoint(0, 0), size()))) {
     314                || prevRect.contains(IntRect(IntPoint(), size()))) {
    315315                // Clearing the first frame, or a frame the size of the whole
    316316                // image, results in a completely empty image.
     
    412412        // The whole frame was non-transparent, so it's possible that the entire
    413413        // 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())))
    415415            buffer.setHasAlpha(false);
    416416        else if (frameIndex > 0) {
  • trunk/WebCore/platform/image-decoders/skia/ImageDecoder.h

    r44573 r44597  
    134134            ASSERT(startY < m_bitmap.height());
    135135            ASSERT(endY <= m_bitmap.height());
    136             const int rowBytes = (endX - startX) * sizeof uint32_t;
     136            const int rowBytes = (endX - startX) * sizeof(uint32_t);
    137137            const uint32_t* const startAddr = m_bitmap.getAddr32(startX, startY);
    138138            for (int destY = startY + 1; destY < endY; ++destY)
  • trunk/WebCore/platform/image-decoders/skia/JPEGImageDecoder.cpp

    r44553 r44597  
    459459        return false;
    460460
    461     // Resize to the width and height of the image.
     461    // Initialize the framebuffer if needed.
    462462    RGBA32Buffer& buffer = m_frameBufferCache[0];
    463463    if (buffer.status() == RGBA32Buffer::FrameEmpty) {
    464         // Let's resize our buffer now to the correct width/height. This will
    465         // also initialize it to transparent.
    466464        if (!buffer.setSize(size().width(), size().height())) {
    467465            m_failed = true;
    468466            return false;
    469467        }
    470 
    471         // Update our status to be partially complete.
    472468        buffer.setStatus(RGBA32Buffer::FramePartial);
    473469        buffer.setHasAlpha(false);
  • trunk/WebCore/platform/image-decoders/skia/PNGImageDecoder.cpp

    r44553 r44597  
    319319        return;
    320320
    321     // Resize to the width and height of the image.
     321    // Initialize the framebuffer if needed.
    322322    RGBA32Buffer& buffer = m_frameBufferCache[0];
    323323    if (buffer.status() == RGBA32Buffer::FrameEmpty) {
    324         // Let's resize our buffer now to the correct width/height.
    325324        if (!buffer.setSize(size().width(), size().height())) {
    326             // Error allocating the bitmap. We should not continue.
    327325            static_cast<PNGImageDecoder*>(png_get_progressive_ptr(reader()->pngPtr()))->decodingFailed();
    328326            longjmp(reader()->pngPtr()->jmpbuf, 1);
    329327            return;
    330328        }
    331 
    332         // Update our status to be partially complete.
    333329        buffer.setStatus(RGBA32Buffer::FramePartial);
    334330        buffer.setHasAlpha(false);
  • trunk/WebCore/platform/image-decoders/skia/XBMImageDecoder.cpp

    r44545 r44597  
    7171RGBA32Buffer* XBMImageDecoder::frameBufferAtIndex(size_t index)
    7272{
    73     // Allocate a framebuffer if necessary. New framebuffers have their status
    74     // initialized to RGBA32Buffer::FrameEmpty.
     73    if (index)
     74        return 0;
     75
    7576    if (m_frameBufferCache.isEmpty())
    7677        m_frameBufferCache.resize(1);
    77 
    78     RGBA32Buffer& frame = m_frameBufferCache[0];
    7978
    8079    // Attempt to get the size if we don't have it yet.
     
    8281        decodeXBM(true);
    8382   
    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())) {
    8888            m_failed = true;
    8989            return 0;
    9090        }
    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       
    9497    // Keep trying to decode until we've got the entire image.
    95     if (frame.status() != RGBA32Buffer::FrameComplete)
     98    if (buffer.status() == RGBA32Buffer::FramePartial)
    9699        decodeXBM(false);
    97100
    98     return &frame;
     101    return &buffer;
    99102}
    100103
Note: See TracChangeset for help on using the changeset viewer.