Changeset 44167 in webkit


Ignore:
Timestamp:
May 26, 2009 5:20:04 PM (15 years ago)
Author:
bfulgham@webkit.org
Message:

2009-05-26 Peter Kasting <pkasting@google.com>

Reviewed by Eric Seidel.

https://bugs.webkit.org/show_bug.cgi?id=25709 part two
Mostly cosmetic changes, mainly to get image decoders for Cairo build to
comply with WebKit style guidelines:

  • Fix header guard names
  • Fix initializer list wrapping
  • Fix class/function "{" wrapping
  • Fix wrapping of long boolean expressions
  • Fix whitespace around operators
  • Eliminate whitespace on otherwise-blank lines
  • No {} on single-line conditional arms
  • Use 0 instead of NULL
  • Don't #include "config.h" in headers

Also a few non-cosmetic changes:

  • Remove unneeded #ifdef protecting the contents of these files. The platforms listed don't match who uses these files anymore (even without considering Skia), and platforms which don't use them at all (like CG) aren't harmed by the files, since they don't have equivalently-named classes. It's simpler to just ditch these.
  • Convert a use of Vector<>& into SharedBuffer*, since that's how the data is really stored anyway.
  • Use size() instead of m_size, for consistency with Skia code, and future-proofing (if a particular decoder wants to specialize this).
  • Move an ASSERT that was slightly more aggressive than necessary.
  • Change variable names/types for clarity/accuracy and to match Skia.
  • Remove unnecessary macro magic to work around a problem which no longer exists in the third-party JPEG headers.
  • Stop silencing a portability warning about setjmp (the vcproj/vsprops are the right place for this)
  • In Skia code, don't explicitly check |m_failed| before calling isSizeAvailable(), which itself checks |m_failed|.
  • platform/image-decoders/ImageDecoder.h: Fix header guards, "{" wrapping. (WebCore::RGBA32Buffer::): (WebCore::RGBA32Buffer::RGBA32Buffer): Fix initializer list wrapping. (WebCore::ImageDecoder::ImageDecoder): Fix initializer list wrapping.
  • platform/image-decoders/bmp/BMPImageDecoder.cpp: Remove unneeded #ifdef.
  • platform/image-decoders/bmp/BMPImageDecoder.h: Fix header guards, "{" wrapping.
  • platform/image-decoders/gif/GIFImageDecoder.cpp: Remove unneeded #ifdef, fix "{" wrapping. (WebCore::GIFImageDecoderPrivate::GIFImageDecoderPrivate): Use an initializer instead of a block-level statement. (WebCore::GIFImageDecoderPrivate::decode): Expect a SharedBuffer. (WebCore::GIFImageDecoderPrivate::getColorMap): (WebCore::GIFImageDecoder::GIFImageDecoder): Fix initializer list wrapping. (WebCore::GIFImageDecoder::frameCount): Add comment. (WebCore::GIFImageDecoder::frameBufferAtIndex): Explicitly cast, fix whitespace around operators. (WebCore::GIFImageDecoder::decode): Pass a SharedBuffer. (WebCore::GIFImageDecoder::initFrameBuffer): Use size() instead of m_size, move ASSERT, fix boolean wrapping, fix indenting. (WebCore::GIFImageDecoder::prepEmptyFrameBuffer): Use size() instead of m_size. (WebCore::GIFImageDecoder::haveDecodedRow): Use size() instead of m_size, eliminate unneeded whitespace, change variable name. (WebCore::GIFImageDecoder::frameComplete): Use size() instead of m_size, no {} on single-line conditional arms, fix boolean wrapping.
  • platform/image-decoders/gif/GIFImageDecoder.h: Fix header guards, "{" wrapping.
  • platform/image-decoders/gif/GIFImageReader.cpp: Remove unneeded #ifdef. (GIFImageReader::read):
  • platform/image-decoders/gif/GIFImageReader.h: Fix header guards, change variable type.
  • platform/image-decoders/ico/ICOImageDecoder.cpp: Remove unneeded #ifdef.
  • platform/image-decoders/ico/ICOImageDecoder.h: Fix header guards, "{" wrapping.
  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp: Remove unneeded #ifdef, macro magic, silencing of warning. (WebCore::JPEGImageDecoder::outputScanlines): Use size() instead of m_size, change variable name.
  • platform/image-decoders/jpeg/JPEGImageDecoder.h: Fix header guards, "{" wrapping.
  • platform/image-decoders/png/PNGImageDecoder.cpp: Remove unneeded #ifdef, silencing of warning, change variable type. (WebCore::PNGImageReader::PNGImageReader): Fix initializer list wrapping. (WebCore::PNGImageReader::close): Add comment, zero another member for consistency. (WebCore::PNGImageDecoder::PNGImageDecoder): Fix indenting. (WebCore::PNGImageDecoder::decodingFailed): Define in .cpp, not .h. (WebCore::PNGImageDecoder::rowAvailable):
  • platform/image-decoders/png/PNGImageDecoder.h: Fix header guards, "{" wrapping.
  • platform/image-decoders/skia/GIFImageDecoder.cpp: (WebCore::GIFImageDecoder::isSizeAvailable): Don't check m_failed unnecessarily. (WebCore::GIFImageDecoder::frameBufferAtIndex): Fix whitespace around operators.
  • platform/image-decoders/skia/GIFImageReader.h: "unsigned" is sufficient to convey "unsigned int".
  • platform/image-decoders/skia/ImageDecoder.h: Remove unnecessary #includes. (WebCore::ImageDecoder::ImageDecoder): Fix initializer list wrapping.
  • platform/image-decoders/skia/JPEGImageDecoder.cpp: (WebCore::JPEGImageReader::JPEGImageReader): Use 0 instead of NULL. (WebCore::JPEGImageDecoder::isSizeAvailable): Don't check m_failed unnecessarily.
  • platform/image-decoders/skia/PNGImageDecoder.cpp: (WebCore::PNGImageReader::PNGImageReader): Fix initializer list wrapping. (WebCore::PNGImageDecoder::PNGImageDecoder): Fix indenting. (WebCore::PNGImageDecoder::isSizeAvailable): Don't check m_failed unnecessarily. (WebCore::rowAvailable):
  • platform/image-decoders/skia/XBMImageDecoder.h: Don't #include config.h.
  • platform/image-decoders/xbm/XBMImageDecoder.cpp: Remove unneeded #ifdef.
  • platform/image-decoders/xbm/XBMImageDecoder.h: Fix header guards, "{" wrapping.
Location:
trunk/WebCore
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r44162 r44167  
     12009-05-26  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25709 part two
     6        Mostly cosmetic changes, mainly to get image decoders for Cairo build to
     7        comply with WebKit style guidelines:
     8        * Fix header guard names
     9        * Fix initializer list wrapping
     10        * Fix class/function "{" wrapping
     11        * Fix wrapping of long boolean expressions
     12        * Fix whitespace around operators
     13        * Eliminate whitespace on otherwise-blank lines
     14        * No {} on single-line conditional arms
     15        * Use 0 instead of NULL
     16        * Don't #include "config.h" in headers
     17
     18        Also a few non-cosmetic changes:
     19        * Remove unneeded #ifdef protecting the contents of these files.  The
     20          platforms listed don't match who uses these files anymore (even
     21          without considering Skia), and platforms which don't use them at all
     22          (like CG) aren't harmed by the files, since they don't have
     23          equivalently-named classes.  It's simpler to just ditch these.
     24        * Convert a use of Vector<>& into SharedBuffer*, since that's how the
     25          data is really stored anyway.
     26        * Use size() instead of m_size, for consistency with Skia code, and
     27          future-proofing (if a particular decoder wants to specialize this).
     28        * Move an ASSERT that was slightly more aggressive than necessary.
     29        * Change variable names/types for clarity/accuracy and to match Skia.
     30        * Remove unnecessary macro magic to work around a problem which no
     31          longer exists in the third-party JPEG headers.
     32        * Stop silencing a portability warning about setjmp (the vcproj/vsprops
     33          are the right place for this)
     34        * In Skia code, don't explicitly check |m_failed| before calling
     35          isSizeAvailable(), which itself checks |m_failed|.
     36
     37        * platform/image-decoders/ImageDecoder.h: Fix header guards, "{" wrapping.
     38        (WebCore::RGBA32Buffer::):
     39        (WebCore::RGBA32Buffer::RGBA32Buffer): Fix initializer list wrapping.
     40        (WebCore::ImageDecoder::ImageDecoder): Fix initializer list wrapping.
     41        * platform/image-decoders/bmp/BMPImageDecoder.cpp: Remove unneeded #ifdef.
     42        * platform/image-decoders/bmp/BMPImageDecoder.h: Fix header guards, "{" wrapping.
     43        * platform/image-decoders/gif/GIFImageDecoder.cpp: Remove unneeded #ifdef, fix "{" wrapping.
     44        (WebCore::GIFImageDecoderPrivate::GIFImageDecoderPrivate): Use an initializer instead of a block-level statement.
     45        (WebCore::GIFImageDecoderPrivate::decode): Expect a SharedBuffer.
     46        (WebCore::GIFImageDecoderPrivate::getColorMap):
     47        (WebCore::GIFImageDecoder::GIFImageDecoder): Fix initializer list wrapping.
     48        (WebCore::GIFImageDecoder::frameCount): Add comment.
     49        (WebCore::GIFImageDecoder::frameBufferAtIndex): Explicitly cast, fix whitespace around operators.
     50        (WebCore::GIFImageDecoder::decode): Pass a SharedBuffer.
     51        (WebCore::GIFImageDecoder::initFrameBuffer): Use size() instead of m_size, move ASSERT, fix boolean wrapping, fix indenting.
     52        (WebCore::GIFImageDecoder::prepEmptyFrameBuffer): Use size() instead of m_size.
     53        (WebCore::GIFImageDecoder::haveDecodedRow): Use size() instead of m_size, eliminate unneeded whitespace, change variable name.
     54        (WebCore::GIFImageDecoder::frameComplete): Use size() instead of m_size, no {} on single-line conditional arms, fix boolean wrapping.
     55        * platform/image-decoders/gif/GIFImageDecoder.h: Fix header guards, "{" wrapping.
     56        * platform/image-decoders/gif/GIFImageReader.cpp: Remove unneeded #ifdef.
     57        (GIFImageReader::read):
     58        * platform/image-decoders/gif/GIFImageReader.h: Fix header guards, change variable type.
     59        * platform/image-decoders/ico/ICOImageDecoder.cpp: Remove unneeded #ifdef.
     60        * platform/image-decoders/ico/ICOImageDecoder.h: Fix header guards, "{" wrapping.
     61        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp: Remove unneeded #ifdef, macro magic, silencing of warning.
     62        (WebCore::JPEGImageDecoder::outputScanlines): Use size() instead of m_size, change variable name.
     63        * platform/image-decoders/jpeg/JPEGImageDecoder.h: Fix header guards, "{" wrapping.
     64        * platform/image-decoders/png/PNGImageDecoder.cpp: Remove unneeded #ifdef, silencing of warning, change variable type.
     65        (WebCore::PNGImageReader::PNGImageReader): Fix initializer list wrapping.
     66        (WebCore::PNGImageReader::close): Add comment, zero another member for consistency.
     67        (WebCore::PNGImageDecoder::PNGImageDecoder): Fix indenting.
     68        (WebCore::PNGImageDecoder::decodingFailed): Define in .cpp, not .h.
     69        (WebCore::PNGImageDecoder::rowAvailable):
     70        * platform/image-decoders/png/PNGImageDecoder.h: Fix header guards, "{" wrapping.
     71        * platform/image-decoders/skia/GIFImageDecoder.cpp:
     72        (WebCore::GIFImageDecoder::isSizeAvailable): Don't check m_failed unnecessarily.
     73        (WebCore::GIFImageDecoder::frameBufferAtIndex): Fix whitespace around operators.
     74        * platform/image-decoders/skia/GIFImageReader.h: "unsigned" is sufficient to convey "unsigned int".
     75        * platform/image-decoders/skia/ImageDecoder.h: Remove unnecessary #includes.
     76        (WebCore::ImageDecoder::ImageDecoder): Fix initializer list wrapping.
     77        * platform/image-decoders/skia/JPEGImageDecoder.cpp:
     78        (WebCore::JPEGImageReader::JPEGImageReader): Use 0 instead of NULL.
     79        (WebCore::JPEGImageDecoder::isSizeAvailable): Don't check m_failed unnecessarily.
     80        * platform/image-decoders/skia/PNGImageDecoder.cpp:
     81        (WebCore::PNGImageReader::PNGImageReader): Fix initializer list wrapping.
     82        (WebCore::PNGImageDecoder::PNGImageDecoder): Fix indenting.
     83        (WebCore::PNGImageDecoder::isSizeAvailable): Don't check m_failed unnecessarily.
     84        (WebCore::rowAvailable):
     85        * platform/image-decoders/skia/XBMImageDecoder.h: Don't #include config.h.
     86        * platform/image-decoders/xbm/XBMImageDecoder.cpp: Remove unneeded #ifdef.
     87        * platform/image-decoders/xbm/XBMImageDecoder.h: Fix header guards, "{" wrapping.
     88
    1892009-05-26  Jian Li  <jianli@chromium.org>
    290
  • trunk/WebCore/platform/image-decoders/ImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef IMAGE_DECODER_H_
    27 #define IMAGE_DECODER_H_
     26#ifndef ImageDecoder_h
     27#define ImageDecoder_h
    2828
    2929#include "IntRect.h"
     
    3939    // The RGBA32Buffer object represents the decoded image data in RGBA32 format.  This buffer is what all
    4040    // decoders write a single frame into.  Frames are then instantiated for drawing by being handed this buffer.
    41     class RGBA32Buffer
    42     {
     41    class RGBA32Buffer {
    4342    public:
    4443        enum FrameStatus { FrameEmpty, FramePartial, FrameComplete };
     44
    4545        enum FrameDisposalMethod {
    4646            // If you change the numeric values of these, make sure you audit all
    4747            // users, as some users may cast raw values to/from these constants.
    48             DisposeNotSpecified = 0,       // Leave frame in framebuffer
    49             DisposeKeep = 1,               // Leave frame in framebuffer
    50             DisposeOverwriteBgcolor = 2,   // Clear frame to transparent
    51             DisposeOverwritePrevious = 3,  // Clear frame to previous framebuffer contents
     48            DisposeNotSpecified,       // Leave frame in framebuffer
     49            DisposeKeep,               // Leave frame in framebuffer
     50            DisposeOverwriteBgcolor,   // Clear frame to transparent
     51            DisposeOverwritePrevious,  // Clear frame to previous framebuffer contents
    5252        };
    5353
    54         RGBA32Buffer() : m_height(0), m_status(FrameEmpty), m_duration(0),
    55                          m_disposalMethod(DisposeNotSpecified), m_hasAlpha(false)
    56         {}
     54        RGBA32Buffer()
     55            : m_height(0)
     56            , m_status(FrameEmpty)
     57            , m_duration(0)
     58            , m_disposalMethod(DisposeNotSpecified)
     59            , m_hasAlpha(false)
     60        {
     61        }
    5762
    5863        void clear() {
     
    112117    // (e.g., GIF, JPG, PNG, ICO) to derive from.  All decoders decode into RGBA32 format
    113118    // and the base class manages the RGBA32 frame cache.
    114     class ImageDecoder
    115     {
     119    class ImageDecoder {
    116120    public:
    117         ImageDecoder() :m_sizeAvailable(false), m_failed(false) {}
     121        ImageDecoder()
     122            : m_sizeAvailable(false)
     123            , m_failed(false)
     124        {
     125        }
     126       
    118127        virtual ~ImageDecoder() {}
    119128
     
    165174    };
    166175
    167 }
     176} // namespace WebCore
    168177
    169178#endif
  • trunk/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp

    r29663 r44167  
    2727#include "BMPImageDecoder.h"
    2828
    29 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
    30 
    3129namespace WebCore
    3230{
     
    4240}
    4341
    44 }
    45 
    46 #endif // PLATFORM(CAIRO)
     42} // namespace WebCore
  • trunk/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef BMP_DECODER_H_
    27 #define BMP_DECODER_H_
     26#ifndef BMPImageDecoder_h
     27#define BMPImageDecoder_h
    2828
    2929#include "ImageDecoder.h"
     
    3434
    3535    // This class decodes the BMP image format.
    36     class BMPImageDecoder : public ImageDecoder
    37     {
     36    class BMPImageDecoder : public ImageDecoder {
    3837    public:
    3938        virtual String filenameExtension() const { return "bmp"; }
     
    4544    };
    4645
    47 }
     46} // namespace WebCore
    4847
    4948#endif
  • trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

    r40641 r44167  
    2828#include "GIFImageReader.h"
    2929
    30 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
    31 
    3230namespace WebCore {
    3331
    34 class GIFImageDecoderPrivate
    35 {
     32class GIFImageDecoderPrivate {
    3633public:
    3734    GIFImageDecoderPrivate(GIFImageDecoder* decoder = 0)
    3835        : m_reader(decoder)
     36        , m_readOffset(0)
    3937    {
    40         m_readOffset = 0;
    4138    }
    4239
     
    4643    }
    4744
    48     bool decode(const Vector<char>& data,
     45    bool decode(SharedBuffer* data,
    4946                GIFImageDecoder::GIFQuery query = GIFImageDecoder::GIFFullQuery,
    5047                unsigned int haltFrame = -1)
    5148    {
    52         return m_reader.read((const unsigned char*)data.data() + m_readOffset, data.size() - m_readOffset,
     49        return m_reader.read((const unsigned char*)data->data() + m_readOffset, data->size() - m_readOffset,
    5350                             query,
    5451                             haltFrame);
     
    6259    bool isTransparent() const { return m_reader.frame_reader->is_transparent; }
    6360
    64     void getColorMap(unsigned char*& map, unsigned& size) const {
     61    void getColorMap(unsigned char*& map, unsigned& size) const
     62    {
    6563        if (m_reader.frame_reader->is_local_colormap_defined) {
    6664            map = m_reader.frame_reader->local_colormap;
     
    8785
    8886GIFImageDecoder::GIFImageDecoder()
    89 : m_frameCountValid(true), m_repetitionCount(cAnimationLoopOnce), m_reader(0)
    90 {}
     87    : m_frameCountValid(true)
     88    , m_repetitionCount(cAnimationLoopOnce)
     89    , m_reader(0)
     90{
     91}
    9192
    9293GIFImageDecoder::~GIFImageDecoder()
     
    140141        // ImageIO does on Mac right now (it also crawls all the data again).
    141142        GIFImageDecoderPrivate reader;
    142         reader.decode(m_data->buffer(), GIFFrameCountQuery);
     143        // This function may fail, but we want to keep any partial data it may
     144        // have decoded, so don't mark it is invalid. If there is an overflow
     145        // or some serious error, m_failed will have gotten set for us.
     146        reader.decode(m_data.get(), GIFFrameCountQuery);
    143147        m_frameCountValid = true;
    144148        m_frameBufferCache.resize(reader.frameCount());
     
    174178RGBA32Buffer* GIFImageDecoder::frameBufferAtIndex(size_t index)
    175179{
    176     if (index >= frameCount())
     180    if (index >= static_cast<size_t>(frameCount()))
    177181        return 0;
    178182
    179183    RGBA32Buffer& frame = m_frameBufferCache[index];
    180184    if (frame.status() != RGBA32Buffer::FrameComplete && m_reader)
    181         // Decode this frame.
    182         decode(GIFFullQuery, index+1);
     185        decode(GIFFullQuery, index + 1); // Decode this frame.
    183186    return &frame;
    184187}
     
    240243        return;
    241244
    242     m_failed = !m_reader->decode(m_data->buffer(), query, haltAtFrame);
     245    m_failed = !m_reader->decode(m_data.get(), query, haltAtFrame);
    243246   
    244247    if (m_failed) {
     
    267270
    268271    // Make sure the frameRect doesn't extend past the bottom-right of the buffer.
    269     if (frameRect.right() > m_size.width())
    270         frameRect.setWidth(m_size.width() - m_reader->frameXOffset());
    271     if (frameRect.bottom() > m_size.height())
    272         frameRect.setHeight(m_size.height() - m_reader->frameYOffset());
     272    if (frameRect.right() > size().width())
     273        frameRect.setWidth(size().width() - m_reader->frameXOffset());
     274    if (frameRect.bottom() > size().height())
     275        frameRect.setHeight(size().height() - m_reader->frameYOffset());
    273276
    274277    RGBA32Buffer* const buffer = &m_frameBufferCache[frameIndex];
     
    288291        // DisposeOverwriteBgcolor below and reset to a completely empty image.)
    289292        const RGBA32Buffer* prevBuffer = &m_frameBufferCache[--frameIndex];
    290         ASSERT(prevBuffer->status() == RGBA32Buffer::FrameComplete);
    291293        RGBA32Buffer::FrameDisposalMethod prevMethod =
    292294            prevBuffer->disposalMethod();
    293         while ((frameIndex > 0) &&
    294                 (prevMethod == RGBA32Buffer::DisposeOverwritePrevious)) {
     295        while ((frameIndex > 0)
     296               && (prevMethod == RGBA32Buffer::DisposeOverwritePrevious)) {
    295297            prevBuffer = &m_frameBufferCache[--frameIndex];
    296298            prevMethod = prevBuffer->disposalMethod();
    297299        }
     300        ASSERT(prevBuffer->status() == RGBA32Buffer::FrameComplete);
    298301
    299302        if ((prevMethod == RGBA32Buffer::DisposeNotSpecified) ||
     
    306309            // affecting pixels in the image outside of the frame.
    307310            const IntRect& prevRect = prevBuffer->rect();
    308             if ((frameIndex == 0) ||
    309                     prevRect.contains(IntRect(IntPoint(0, 0), m_size))) {
     311            if ((frameIndex == 0)
     312                || prevRect.contains(IntRect(IntPoint(0, 0), size()))) {
    310313                // Clearing the first frame, or a frame the size of the whole
    311314                // image, results in a completely empty image.
     
    322325              }
    323326              if ((prevRect.width() > 0) && (prevRect.height() > 0))
    324                 buffer->setHasAlpha(true);
     327                  buffer->setHasAlpha(true);
    325328            }
    326329        }
     
    336339void GIFImageDecoder::prepEmptyFrameBuffer(RGBA32Buffer* buffer) const
    337340{
    338     buffer->bytes().resize(m_size.width() * m_size.height());
     341    buffer->bytes().resize(size().width() * size().height());
    339342    buffer->bytes().fill(0);
    340343    buffer->setHasAlpha(true);
     
    354357
    355358    // Do nothing for bogus data.
    356     if (rowBuffer == 0 || static_cast<int>(m_reader->frameYOffset() + rowNumber) >= m_size.height())
    357       return;
     359    if (rowBuffer == 0 || static_cast<int>(m_reader->frameYOffset() + rowNumber) >= size().height())
     360        return;
    358361
    359362    unsigned colorMapSize;
     
    370373    // sub-rectangle.  This means that if the GIF frame's sub-rectangle is (x,y,w,h) then row 0 is really row
    371374    // y, and each row goes from x to x+w.
    372     unsigned dstPos = (m_reader->frameYOffset() + rowNumber) * m_size.width() + m_reader->frameXOffset();
     375    unsigned dstPos = (m_reader->frameYOffset() + rowNumber) * size().width() + m_reader->frameXOffset();
    373376    unsigned* dst = buffer.bytes().data() + dstPos;
    374     unsigned* dstEnd = dst + m_size.width() - m_reader->frameXOffset();
     377    unsigned* dstEnd = dst + size().width() - m_reader->frameXOffset();
    375378    unsigned* currDst = dst;
    376379    unsigned char* currentRowByte = rowBuffer;
    377    
     380
    378381    while (currentRowByte != rowEnd && currDst < dstEnd) {
    379382        if ((!m_reader->isTransparent() || *currentRowByte != m_reader->transparentPixel()) && *currentRowByte < colorMapSize) {
     
    402405        // Copy the row |repeatCount|-1 times.
    403406        unsigned num = currDst - dst;
    404         unsigned size = num * sizeof(unsigned);
    405         unsigned width = m_size.width();
    406         unsigned* end = buffer.bytes().data() + width * m_size.height();
     407        unsigned data_size = num * sizeof(unsigned);
     408        unsigned width = size().width();
     409        unsigned* end = buffer.bytes().data() + width * size().height();
    407410        currDst = dst + width;
    408411        for (unsigned i = 1; i < repeatCount; i++) {
    409412            if (currDst + num > end) // Protect against a buffer overrun from a bogus repeatCount.
    410413                break;
    411             memcpy(currDst, dst, size);
     414            memcpy(currDst, dst, data_size);
    412415            currDst += width;
    413416        }
     
    435438        // The whole frame was non-transparent, so it's possible that the entire
    436439        // resulting buffer was non-transparent, and we can setHasAlpha(false).
    437         if (buffer.rect().contains(IntRect(IntPoint(0, 0), m_size))) {
     440        if (buffer.rect().contains(IntRect(IntPoint(0, 0), size())))
    438441            buffer.setHasAlpha(false);
    439         } else if (frameIndex > 0) {
     442        else if (frameIndex > 0) {
    440443            // Tricky case.  This frame does not have alpha only if everywhere
    441444            // outside its rect doesn't have alpha.  To know whether this is
     
    447450            // initFrameBuffer().
    448451            const RGBA32Buffer* prevBuffer = &m_frameBufferCache[--frameIndex];
    449             while ((frameIndex > 0) &&
    450                     (prevBuffer->disposalMethod() ==
    451                         RGBA32Buffer::DisposeOverwritePrevious))
     452            while ((frameIndex > 0)
     453                   && (prevBuffer->disposalMethod() == RGBA32Buffer::DisposeOverwritePrevious))
    452454                prevBuffer = &m_frameBufferCache[--frameIndex];
    453455
     
    460462            // it had no alpha, and its rect is contained in the current frame's
    461463            // rect, we know the current frame has no alpha.
    462             if ((prevBuffer->disposalMethod() ==
    463                     RGBA32Buffer::DisposeOverwriteBgcolor) &&
    464                     !prevBuffer->hasAlpha() &&
    465                     buffer.rect().contains(prevBuffer->rect()))
     464            if ((prevBuffer->disposalMethod() == RGBA32Buffer::DisposeOverwriteBgcolor)
     465                && !prevBuffer->hasAlpha() && buffer.rect().contains(prevBuffer->rect()))
    466466                buffer.setHasAlpha(false);
    467467        }
     
    477477}
    478478
    479 }
    480 
    481 #endif // PLATFORM(CAIRO)
     479} // namespace WebCore
  • trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef GIF_DECODER_H_
    27 #define GIF_DECODER_H_
     26#ifndef GIFImageDecoder_h
     27#define GIFImageDecoder_h
    2828
    2929#include "ImageDecoder.h"
     
    3434
    3535    // This class decodes the GIF image format.
    36     class GIFImageDecoder : public ImageDecoder
    37     {
     36    class GIFImageDecoder : public ImageDecoder {
    3837    public:
    3938        GIFImageDecoder();
     
    6362        enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery };
    6463
    65         void decode(GIFQuery query, unsigned haltAtFrame) const;
     64        void decode(GIFQuery, unsigned haltAtFrame) const;
    6665
    6766        // Callbacks from the GIF reader.
     
    8079        // A helper for initFrameBuffer(), this sets the size of the buffer, and
    8180        // fills it with transparent pixels.
    82         void prepEmptyFrameBuffer(RGBA32Buffer* buffer) const;
     81        void prepEmptyFrameBuffer(RGBA32Buffer*) const;
    8382
    8483        bool m_frameCountValid;
     
    8887    };
    8988
    90 }
     89} // namespace WebCore
    9190
    9291#endif
  • trunk/WebCore/platform/image-decoders/gif/GIFImageReader.cpp

    r28925 r44167  
    7979#include "GIFImageDecoder.h"
    8080
    81 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
    82 
    8381using WebCore::GIFImageDecoder;
    8482
     
    940938  return true;
    941939}
    942 
    943 #endif // PLATFORM(CAIRO)
  • trunk/WebCore/platform/image-decoders/gif/GIFImageReader.h

    r39309 r44167  
    3636 * ***** END LICENSE BLOCK ***** */
    3737
    38 #ifndef _GIF_H_
    39 #define _GIF_H_
     38#ifndef GIFImageReader_h
     39#define GIFImageReader_h
    4040
    4141// Define ourselves as the clientPtr.  Mozilla just hacked their C++ callback class into this old C decoder,
     
    169169    unsigned screen_height;
    170170    int global_colormap_size;   /* Size of global colormap array. */
    171     int images_decoded;         /* Counts completed frames for animated GIFs */
     171    unsigned images_decoded;    /* Counts completed frames for animated GIFs */
    172172    int images_count;           /* Counted all frames seen so far (including incomplete frames) */
    173173    int loop_count;             /* Netscape specific extension block to control
     
    214214
    215215#endif
    216 
  • trunk/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp

    r29663 r44167  
    2727#include "ICOImageDecoder.h"
    2828
    29 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
    30 
    3129namespace WebCore
    3230{
     
    4240}
    4341
    44 }
    45 
    46 #endif // PLATFORM(CAIRO)
     42} // namespace WebCore
  • trunk/WebCore/platform/image-decoders/ico/ICOImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef ICO_DECODER_H_
    27 #define ICO_DECODER_H_
     26#ifndef ICOImageDecoder_h
     27#define ICOImageDecoder_h
    2828
    2929#include "ImageDecoder.h"
     
    3434
    3535    // This class decodes the ICO and CUR image formats.
    36     class ICOImageDecoder : public ImageDecoder
    37     {
     36    class ICOImageDecoder : public ImageDecoder {
    3837    public:
    3938        virtual String filenameExtension() const { return "ico"; }
     
    4544    };
    4645
    47 }
     46} // namespace WebCore
    4847
    4948#endif
  • trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r35487 r44167  
    3939#include "JPEGImageDecoder.h"
    4040#include <assert.h>
    41 #include <stdio.h>
    42 
    43 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
     41
     42extern "C" {
     43#include "jpeglib.h"
     44}
    4445
    4546#if COMPILER(MSVC)
    4647// Remove warnings from warning level 4.
    4748#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
    48 
    49 // if ADDRESS_TAG_BIT is dfined, INT32 has been declared as a typedef in the PlatformSDK (BaseTsd.h),
    50 // so we need to stop jpeglib.h from trying to #define it
    51 // see here for more info: http://www.cygwin.com/ml/cygwin/2004-07/msg01051.html
    52 # if defined(ADDRESS_TAG_BIT) && !defined(XMD_H)
    53 #  define XMD_H
    54 #  define VTK_JPEG_XMD_H
    55 # endif
    56 #endif // COMPILER(MSVC)
    57 
    58 extern "C" {
    59 #include "jpeglib.h"
    60 }
    61 
    62 #if COMPILER(MSVC)
    63 # if defined(VTK_JPEG_XMD_H)
    64 #  undef VTK_JPEG_XMD_H
    65 #  undef XMD_H
    66 # endif
    6749#endif // COMPILER(MSVC)
    6850
     
    483465        // Let's resize our buffer now to the correct width/height.
    484466        RGBA32Array& bytes = buffer.bytes();
    485         bytes.resize(m_size.width() * m_size.height());
     467        bytes.resize(size().width() * size().height());
    486468
    487469        // Update our status to be partially complete.
     
    504486            return false;
    505487        JSAMPLE *j1 = samples[0];
    506         for (unsigned i = 0; i < info->output_width; ++i) {
     488        for (unsigned x = 0; x < info->output_width; ++x) {
    507489            unsigned r = *j1++;
    508490            unsigned g = *j1++;
     
    528510
    529511}
    530 
    531 #endif // PLATFORM(CAIRO)
  • trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef JPEG_DECODER_H_
    27 #define JPEG_DECODER_H_
     26#ifndef JPEGImageDecoder_h
     27#define JPEGImageDecoder_h
    2828
    2929#include "ImageDecoder.h"
     
    3434
    3535    // This class decodes the JPEG image format.
    36     class JPEGImageDecoder : public ImageDecoder
    37     {
     36    class JPEGImageDecoder : public ImageDecoder {
    3837    public:
    3938        JPEGImageDecoder();
     
    7069    };
    7170
    72 }
     71} // namespace WebCore
    7372
    7473#endif
  • trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp

    r34199 r44167  
    4141#include "assert.h"
    4242
    43 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
    44 
    4543#if COMPILER(MSVC)
    4644// Remove warnings from warning level 4.
    4745#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
    48 #endif
     46#endif // COMPILER(MSVC)
    4947
    5048namespace WebCore {
     
    5654
    5755// Protect against large PNGs. See Mozilla's bug #251381 for more info.
    58 const long cMaxPNGSize = 1000000L;
     56const unsigned long cMaxPNGSize = 1000000UL;
    5957
    6058// Called if the decoding of the image fails.
     
    7977public:
    8078    PNGImageReader(PNGImageDecoder* decoder)
    81     : m_readOffset(0), m_decodingSizeOnly(false), m_interlaceBuffer(0), m_hasAlpha(0)
     79        : m_readOffset(0)
     80        , m_decodingSizeOnly(false)
     81        , m_interlaceBuffer(0)
     82        , m_hasAlpha(0)
    8283    {
    83         m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, decodingFailed, decodingWarning);
     84        m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, decodingFailed, decodingWarning);
    8485        m_info = png_create_info_struct(m_png);
    8586        png_set_progressive_read_fn(m_png, decoder, headerAvailable, rowAvailable, pngComplete);
     
    9394    void close() {
    9495        if (m_png && m_info)
    95             png_destroy_read_struct(&m_png, &m_info, 0);
     96            png_destroy_read_struct(&m_png, &m_info, 0);  // Will zero the pointers.
    9697        delete []m_interlaceBuffer;
     98        m_interlaceBuffer = 0;
    9799        m_readOffset = 0;
    98100    }
     
    140142
    141143PNGImageDecoder::PNGImageDecoder()
    142 : m_reader(0)
     144    : m_reader(0)
    143145{
    144146    m_frameBufferCache.resize(1);
     
    223225{
    224226    static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->headerAvailable();
     227}
     228
     229void PNGImageDecoder::decodingFailed() {
     230    m_failed = true;
    225231}
    226232
     
    313319        // Let's resize our buffer now to the correct width/height.
    314320        RGBA32Array& bytes = buffer.bytes();
    315         bytes.resize(m_size.width() * m_size.height());
     321        bytes.resize(size().width() * size().height());
    316322
    317323        // Update our status to be partially complete.
     
    319325
    320326        // For PNGs, the frame always fills the entire image.
    321         buffer.setRect(IntRect(0, 0, m_size.width(), m_size.height()));
     327        buffer.setRect(IntRect(0, 0, size().width(), size().height()));
    322328
    323329        if (reader()->pngPtr()->interlaced)
    324             reader()->createInterlaceBuffer((reader()->hasAlpha() ? 4 : 3) * m_size.width() * m_size.height());
     330            reader()->createInterlaceBuffer((reader()->hasAlpha() ? 4 : 3) * size().width() * size().height());
    325331    }
    326332
     
    362368    png_bytep interlaceBuffer = reader()->interlaceBuffer();
    363369    if (interlaceBuffer) {
    364         row = interlaceBuffer + (rowIndex * colorChannels * m_size.width());
     370        row = interlaceBuffer + (rowIndex * colorChannels * size().width());
    365371        png_progressive_combine_row(png, row, rowBuffer);
    366372    }
     
    369375
    370376    // Copy the data into our buffer.
    371     int width = m_size.width();
     377    int width = size().width();
    372378    unsigned* dst = buffer.bytes().data() + rowIndex * width;
    373379    bool sawAlpha = false;
    374     for (int i = 0; i < width; i++) {
     380    for (int x = 0; x < width; x++) {
    375381        unsigned red = *row++;
    376382        unsigned green = *row++;
     
    399405}
    400406
    401 }
    402 
    403 #endif // PLATFORM(CAIRO)
     407} // namespace WebCore
  • trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef PNG_DECODER_H_
    27 #define PNG_DECODER_H_
     26#ifndef PNGImageDecoder_h
     27#define PNGImageDecoder_h
    2828
    2929#include "ImageDecoder.h"
     
    3434
    3535    // This class decodes the PNG image format.
    36     class PNGImageDecoder : public ImageDecoder
    37     {
     36    class PNGImageDecoder : public ImageDecoder {
    3837    public:
    3938        PNGImageDecoder();
     
    5554
    5655        // Callbacks from libpng
    57         void decodingFailed() { m_failed = true; }
     56        void decodingFailed();
    5857        void headerAvailable();
    5958        void rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int interlacePass);
     
    6463    };
    6564
    66 }
     65} // namespace WebCore
    6766
    6867#endif
  • trunk/WebCore/platform/image-decoders/skia/GIFImageDecoder.cpp

    r40641 r44167  
    127127    }
    128128
    129     return !m_failed && ImageDecoder::isSizeAvailable();
     129    return ImageDecoder::isSizeAvailable();
    130130}
    131131
     
    184184    RGBA32Buffer& frame = m_frameBufferCache[index];
    185185    if (frame.status() != RGBA32Buffer::FrameComplete && m_reader)
    186         decode(GIFFullQuery, index+1); // Decode this frame.
     186        decode(GIFFullQuery, index + 1); // Decode this frame.
    187187    return &frame;
    188188}
  • trunk/WebCore/platform/image-decoders/skia/GIFImageReader.h

    r40173 r44167  
    168168    unsigned screen_width;       /* Logical screen width & height */
    169169    unsigned screen_height;
    170     int global_colormap_size;    /* Size of global colormap array. */
    171     unsigned int images_decoded; /* Counts completed frames for animated GIFs */
    172     int images_count;            /* Counted all frames seen so far (including incomplete frames) */
    173     int loop_count;              /* Netscape specific extension block to control
    174                                     the number of animation loops a GIF renders. */
     170    int global_colormap_size;   /* Size of global colormap array. */
     171    unsigned images_decoded;    /* Counts completed frames for animated GIFs */
     172    int images_count;           /* Counted all frames seen so far (including incomplete frames) */
     173    int loop_count;             /* Netscape specific extension block to control
     174                                   the number of animation loops a GIF renders. */
    175175   
    176176    // Not really global, but convenient to locate here.
  • trunk/WebCore/platform/image-decoders/skia/ImageDecoder.h

    r43244 r44167  
    3434#include "SharedBuffer.h"
    3535#include <wtf/Assertions.h>
    36 #include <wtf/PassRefPtr.h>
    37 #include <wtf/RefCounted.h>
    3836#include <wtf/RefPtr.h>
    3937#include <wtf/Vector.h>
     
    4341namespace WebCore {
    4442
    45     // The RGBA32Buffer object represents the decoded image data in RGBA32 format.
    46     // This buffer is what all decoders write a single frame into.  Frames are then
    47     // instantiated for drawing by being handed this buffer.
     43    // The RGBA32Buffer object represents the decoded image data in RGBA32 format.  This buffer is what all
     44    // decoders write a single frame into.  Frames are then instantiated for drawing by being handed this buffer.
    4845    class RGBA32Buffer {
    4946    public:
     
    197194    class ImageDecoder {
    198195    public:
    199         ImageDecoder() : m_failed(false), m_sizeAvailable(false)  {}
     196        ImageDecoder()
     197            : m_failed(false)
     198            , m_sizeAvailable(false)
     199        {
     200        }
     201
    200202        virtual ~ImageDecoder() {}
    201203
  • trunk/WebCore/platform/image-decoders/skia/JPEGImageDecoder.cpp

    r40173 r44167  
    100100        jpeg_create_decompress(&m_info);
    101101 
    102         decoder_source_mgr* src = NULL;
     102        decoder_source_mgr* src = 0;
    103103        if (!m_info.src) {
    104104            src = (decoder_source_mgr*)fastCalloc(sizeof(decoder_source_mgr), 1);
     
    422422    }
    423423
    424     return !m_failed && ImageDecoder::isSizeAvailable();
     424    return ImageDecoder::isSizeAvailable();
    425425}
    426426
  • trunk/WebCore/platform/image-decoders/skia/PNGImageDecoder.cpp

    r40173 r44167  
    7373public:
    7474    PNGImageReader(PNGImageDecoder* decoder)
    75     : m_readOffset(0), m_decodingSizeOnly(false), m_interlaceBuffer(0), m_hasAlpha(0)
     75        : m_readOffset(0)
     76        , m_decodingSizeOnly(false)
     77        , m_interlaceBuffer(0)
     78        , m_hasAlpha(0)
    7679    {
    77         m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, decodingFailed, decodingWarning);
     80        m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, decodingFailed, decodingWarning);
    7881        m_info = png_create_info_struct(m_png);
    7982        png_set_progressive_read_fn(m_png, decoder, headerAvailable, rowAvailable, pngComplete);
     
    135138
    136139PNGImageDecoder::PNGImageDecoder()
    137 : m_reader(0)
    138 {}
     140    : m_reader(0)
     141{
     142}
    139143
    140144PNGImageDecoder::~PNGImageDecoder()
     
    170174    }
    171175
    172     return !m_failed && ImageDecoder::isSizeAvailable();
     176    return ImageDecoder::isSizeAvailable();
    173177}
    174178
     
    306310                  png_uint_32 rowIndex, int interlacePass)
    307311{
    308     static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->rowAvailable(
    309         rowBuffer, rowIndex, interlacePass);
     312    static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->rowAvailable(rowBuffer, rowIndex, interlacePass);
    310313}
    311314
  • trunk/WebCore/platform/image-decoders/skia/XBMImageDecoder.h

    r40173 r44167  
    3232#define XBMImageDecoder_h
    3333
    34 #include "config.h"
    3534#include <string>
    3635#include "ImageDecoder.h"
  • trunk/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp

    r29663 r44167  
    2727#include "XBMImageDecoder.h"
    2828 
    29 #if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
    30 
    3129namespace WebCore
    3230{
     
    4240}
    4341
    44 }
    45 
    46 #endif // PLATFORM(CAIRO)
     42} // namespace WebCore
  • trunk/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h

    r44051 r44167  
    2424 */
    2525
    26 #ifndef XBM_DECODER_H_
    27 #define XBM_DECODER_H_
     26#ifndef XBMImageDecoder_h
     27#define XBMImageDecoder_h
    2828
    2929#include "ImageDecoder.h"
     
    3434
    3535    // This class decodes the XBM image format.
    36     class XBMImageDecoder : public ImageDecoder
    37     {
     36    class XBMImageDecoder : public ImageDecoder {
    3837    public:
    3938        virtual String filenameExtension() const { return "xbm"; }
     
    4544    };
    4645
    47 }
     46} // namespace WebCore
    4847
    4948#endif
Note: See TracChangeset for help on using the changeset viewer.