Changeset 12668 in webkit


Ignore:
Timestamp:
Feb 8, 2006 2:46:43 PM (18 years ago)
Author:
hyatt
Message:

Improved Cairo image rendering by only building the surface from the portion of the buffer that has been decoded so far.

Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r12661 r12668  
    5151
    5252        * khtml/xml/Element.idl: Added.
     53
     542006-02-08  Dave Hyatt <hyatt@apple.com>
     55
     56        Make the Cairo image surface only reflect the portion of
     57        the image that has been decoded so far.   That way we don't
     58        have to zero fill our RGBA32 buffers, and we avoid painting
     59        the empty portion.
     60
     61        Reviewed by timo
     62
     63        * Viewer/ImageView.cpp:
     64        * WebCore.vcproj/WebCore/WebCore.vcproj:
     65        * platform/cairo/ImageSourceCairo.cpp:
     66        (WebCore::createDecoder):
     67        (WebCore::ImageSource::createFrameAtIndex):
     68        * platform/image-decoders/ImageDecoder.h:
     69        (WebCore::RGBA32Buffer::RGBA32Buffer):
     70        (WebCore::RGBA32Buffer::height):
     71        (WebCore::RGBA32Buffer::ensureHeight):
     72        (WebCore::RGBA32Buffer::setStatus):
     73        (WebCore::RGBA32Buffer::setDuration):
     74        (WebCore::RGBA32Buffer::setIncludeInNextFrame):
     75        * platform/image-decoders/gif/GIFImageDecoder.cpp:
     76        (WebCore::GIFImageDecoder::haveDecodedRow):
     77        (WebCore::GIFImageDecoder::frameComplete):
     78        * platform/image-decoders/png/PNGImageDecoder.cpp:
     79        (WebCore::PNGImageDecoder::rowAvailable):
     80        (WebCore::PNGImageDecoder::pngComplete):
    5381
    54822006-02-08  Dave Hyatt <hyatt@apple.com>
  • trunk/WebCore/WebCore.vcproj/Image Viewer/ImageView.cpp

    r12625 r12668  
    8585    cairo_t* context = cairo_create(surface);
    8686    cairo_rectangle(context, 0, 0, rect.right, rect.bottom);
    87     cairo_set_source_rgb(context, 1.0, 1.0, 1.0);
     87    cairo_set_source_rgb(context, 1.0, 0.0, 0.0);
    8888    cairo_fill(context);
    8989
    90     // Let's test scaling to double the size.
     90    // Comment in to test scaling (doubles the size).
    9191    float width = image->size().width(); // * 2;
    9292    float height = image->size().height(); // * 2;
  • trunk/WebCore/WebCore.vcproj/WebCore/WebCore.vcproj

    r12661 r12668  
    21042104                                        </File>
    21052105                                </Filter>
     2106                                <Filter
     2107                                        Name="jpeg"
     2108                                        >
     2109                                        <File
     2110                                                RelativePath="..\..\platform\image-decoders\jpeg\jcomapi.c"
     2111                                                >
     2112                                        </File>
     2113                                        <File
     2114                                                RelativePath="..\..\platform\image-decoders\jpeg\jconfig.h"
     2115                                                >
     2116                                        </File>
     2117                                        <File
     2118                                                RelativePath="..\..\platform\image-decoders\jpeg\jdapimin.c"
     2119                                                >
     2120                                        </File>
     2121                                        <File
     2122                                                RelativePath="..\..\platform\image-decoders\jpeg\jdapistd.c"
     2123                                                >
     2124                                        </File>
     2125                                        <File
     2126                                                RelativePath="..\..\platform\image-decoders\jpeg\jdatadst.c"
     2127                                                >
     2128                                        </File>
     2129                                        <File
     2130                                                RelativePath="..\..\platform\image-decoders\jpeg\jdatasrc.c"
     2131                                                >
     2132                                        </File>
     2133                                        <File
     2134                                                RelativePath="..\..\platform\image-decoders\jpeg\jdcoefct.c"
     2135                                                >
     2136                                        </File>
     2137                                        <File
     2138                                                RelativePath="..\..\platform\image-decoders\jpeg\jdcolor.c"
     2139                                                >
     2140                                        </File>
     2141                                        <File
     2142                                                RelativePath="..\..\platform\image-decoders\jpeg\jdct.h"
     2143                                                >
     2144                                        </File>
     2145                                        <File
     2146                                                RelativePath="..\..\platform\image-decoders\jpeg\jddctmgr.c"
     2147                                                >
     2148                                        </File>
     2149                                        <File
     2150                                                RelativePath="..\..\platform\image-decoders\jpeg\jdhuff.c"
     2151                                                >
     2152                                        </File>
     2153                                        <File
     2154                                                RelativePath="..\..\platform\image-decoders\jpeg\jdhuff.h"
     2155                                                >
     2156                                        </File>
     2157                                        <File
     2158                                                RelativePath="..\..\platform\image-decoders\jpeg\jdinput.c"
     2159                                                >
     2160                                        </File>
     2161                                        <File
     2162                                                RelativePath="..\..\platform\image-decoders\jpeg\jdmainct.c"
     2163                                                >
     2164                                        </File>
     2165                                        <File
     2166                                                RelativePath="..\..\platform\image-decoders\jpeg\jdmarker.c"
     2167                                                >
     2168                                        </File>
     2169                                        <File
     2170                                                RelativePath="..\..\platform\image-decoders\jpeg\jdmaster.c"
     2171                                                >
     2172                                        </File>
     2173                                        <File
     2174                                                RelativePath="..\..\platform\image-decoders\jpeg\jdmerge.c"
     2175                                                >
     2176                                        </File>
     2177                                        <File
     2178                                                RelativePath="..\..\platform\image-decoders\jpeg\jdphuff.c"
     2179                                                >
     2180                                        </File>
     2181                                        <File
     2182                                                RelativePath="..\..\platform\image-decoders\jpeg\jdpostct.c"
     2183                                                >
     2184                                        </File>
     2185                                        <File
     2186                                                RelativePath="..\..\platform\image-decoders\jpeg\jdsample.c"
     2187                                                >
     2188                                        </File>
     2189                                        <File
     2190                                                RelativePath="..\..\platform\image-decoders\jpeg\jerror.c"
     2191                                                >
     2192                                        </File>
     2193                                        <File
     2194                                                RelativePath="..\..\platform\image-decoders\jpeg\jerror.h"
     2195                                                >
     2196                                        </File>
     2197                                        <File
     2198                                                RelativePath="..\..\platform\image-decoders\jpeg\jfdctflt.c"
     2199                                                >
     2200                                        </File>
     2201                                        <File
     2202                                                RelativePath="..\..\platform\image-decoders\jpeg\jfdctfst.c"
     2203                                                >
     2204                                        </File>
     2205                                        <File
     2206                                                RelativePath="..\..\platform\image-decoders\jpeg\jfdctint.c"
     2207                                                >
     2208                                        </File>
     2209                                        <File
     2210                                                RelativePath="..\..\platform\image-decoders\jpeg\jidctflt.c"
     2211                                                >
     2212                                        </File>
     2213                                        <File
     2214                                                RelativePath="..\..\platform\image-decoders\jpeg\jidctfst.c"
     2215                                                >
     2216                                        </File>
     2217                                        <File
     2218                                                RelativePath="..\..\platform\image-decoders\jpeg\jidctint.c"
     2219                                                >
     2220                                        </File>
     2221                                        <File
     2222                                                RelativePath="..\..\platform\image-decoders\jpeg\jinclude.h"
     2223                                                >
     2224                                        </File>
     2225                                        <File
     2226                                                RelativePath="..\..\platform\image-decoders\jpeg\jmemmgr.c"
     2227                                                >
     2228                                        </File>
     2229                                        <File
     2230                                                RelativePath="..\..\platform\image-decoders\jpeg\jmemnobs.c"
     2231                                                >
     2232                                        </File>
     2233                                        <File
     2234                                                RelativePath="..\..\platform\image-decoders\jpeg\jmemsys.h"
     2235                                                >
     2236                                        </File>
     2237                                        <File
     2238                                                RelativePath="..\..\platform\image-decoders\jpeg\jmorecfg.h"
     2239                                                >
     2240                                        </File>
     2241                                        <File
     2242                                                RelativePath="..\..\platform\image-decoders\jpeg\jpegint.h"
     2243                                                >
     2244                                        </File>
     2245                                        <File
     2246                                                RelativePath="..\..\platform\image-decoders\jpeg\jpeglib.h"
     2247                                                >
     2248                                        </File>
     2249                                        <File
     2250                                                RelativePath="..\..\platform\image-decoders\jpeg\jquant1.c"
     2251                                                >
     2252                                        </File>
     2253                                        <File
     2254                                                RelativePath="..\..\platform\image-decoders\jpeg\jquant2.c"
     2255                                                >
     2256                                        </File>
     2257                                        <File
     2258                                                RelativePath="..\..\platform\image-decoders\jpeg\jutils.c"
     2259                                                >
     2260                                        </File>
     2261                                        <File
     2262                                                RelativePath="..\..\platform\image-decoders\jpeg\jversion.h"
     2263                                                >
     2264                                        </File>
     2265                                        <File
     2266                                                RelativePath="..\..\platform\image-decoders\jpeg\jwinfig.h"
     2267                                                >
     2268                                        </File>
     2269                                </Filter>
    21062270                        </Filter>
    21072271                        <Filter
  • trunk/WebCore/platform/cairo/ImageSourceCairo.cpp

    r12651 r12668  
    5858    if (uContents[0]==0xFF &&
    5959        uContents[1]==0xD8 &&
    60         uContents[2]==0xFF) {
     60        uContents[2]==0xFF)
    6161        return 0;
    62     }
    6362
    6463    // BMP
     
    145144                                               CAIRO_FORMAT_ARGB32,
    146145                                               size().width(),
    147                                                size().height(),
     146                                               buffer.height(),
    148147                                               size().width()*4);
    149148}
  • trunk/WebCore/platform/image-decoders/ImageDecoder.h

    r12656 r12668  
    4545    enum FrameStatus { FrameEmpty, FramePartial, FrameComplete };
    4646
    47     RGBA32Buffer() : m_status(FrameEmpty), m_duration(0), m_includeInNextFrame(false)
     47    RGBA32Buffer() : m_height(0), m_status(FrameEmpty), m_duration(0), m_includeInNextFrame(false)
    4848    {}
     49
     50    RGBA32Array& bytes() { return m_bytes; }
     51    unsigned height() { return m_height; }
     52    FrameStatus status() const { return m_status; }
     53    unsigned duration() const { return m_duration; }
     54    bool includeInNextFrame() const { return m_includeInNextFrame; }
     55 
     56    void ensureHeight(unsigned rowIndex) { if (rowIndex > m_height) m_height = rowIndex; }
    4957
    5058    void setStatus(FrameStatus s) { m_status = s; }
    5159    void setDuration(unsigned duration) { m_duration = duration; }
    5260    void setIncludeInNextFrame(bool n) { m_includeInNextFrame = n; }
    53 
    54     RGBA32Array& bytes() { return m_bytes; }
    55     FrameStatus status() const { return m_status; }
    56     unsigned duration() const { return m_duration; }
    57     bool includeInNextFrame() const { return m_includeInNextFrame; }
    5861
    5962    static void setRGBA(unsigned& pos, unsigned r, unsigned b, unsigned g, unsigned a)
     
    7578private:
    7679    RGBA32Array m_bytes;
     80    unsigned m_height; // The height (the number of rows we've fully decoded).
    7781    FrameStatus m_status; // Whether or not this frame is completely finished decoding.
    7882    unsigned m_duration; // The animation delay.
  • trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

    r12656 r12668  
    212212        // If the disposal method of the previous frame said to stick around, then we need
    213213        // to copy that frame into our frame.
    214         if (frameIndex > 0 && m_frameBufferCache[frameIndex-1].includeInNextFrame())
     214        if (frameIndex > 0 && m_frameBufferCache[frameIndex-1].includeInNextFrame()) {
    215215            bytes.duplicate(m_frameBufferCache[frameIndex-1].bytes());
    216         else {
     216            buffer.ensureHeight(m_size.height());
     217        }
     218        else
    217219            bytes.resize(m_size.width() * m_size.height());
    218             bytes.fill(0);
    219         }
    220220
    221221        // Update our status to be partially complete.
     
    270270        }
    271271    }
    272 }   
     272
     273    // Our partial height is rowNumber + 1, e.g., row 2 is the 3rd row, so that's a height of 3.
     274    // Adding in repeatCount - 1 to rowNumber + 1 works out to just be rowNumber + repeatCount.
     275    buffer.ensureHeight(rowNumber + repeatCount);
     276}
    273277
    274278void GIFImageDecoder::frameComplete(unsigned frameIndex, unsigned frameDuration, bool includeInNextFrame)
    275279{
    276280    RGBA32Buffer& buffer = m_frameBufferCache[frameIndex];
    277    
    278     // Degenerate GIFS can sometimes result in empty frames.  Ensure we at least have a filled
    279     // frame with the correct width/height.
    280     if (buffer.status() == RGBA32Buffer::FrameEmpty)
    281         haveDecodedRow(frameIndex, 0, 0, 0, 0);
    282 
    283281    buffer.setStatus(RGBA32Buffer::FrameComplete);
    284282    buffer.setDuration(frameDuration);
  • trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp

    r12656 r12668  
    308308}
    309309
    310 void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned int rowIndex, int interlacePass)
     310void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int interlacePass)
    311311{
    312312    if (m_frameBufferCache.isEmpty())
     
    319319        RGBA32Array& bytes = buffer.bytes();
    320320        bytes.resize(m_size.width() * m_size.height());
    321         bytes.fill(0);
    322321
    323322        // Update our status to be partially complete.
     
    381380        RGBA32Buffer::setRGBA(*dst++, red, blue, green, alpha);
    382381    }
     382
     383    buffer.ensureHeight(rowIndex + 1);
    383384}
    384385
     
    395396    // Hand back an appropriately sized buffer, even if the image ended up being empty.
    396397    RGBA32Buffer& buffer = m_frameBufferCache[0];
    397     if (buffer.status() == RGBA32Buffer::FrameEmpty)
    398         rowAvailable(0, 0, 0);
    399398    buffer.setStatus(RGBA32Buffer::FrameComplete);
    400399}
Note: See TracChangeset for help on using the changeset viewer.