Changeset 70846 in webkit


Ignore:
Timestamp:
Oct 28, 2010 11:55:48 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-10-28 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
(Eric reviewed the CoreGraphics interactions, Peter reviewed the image
decoder interaction, and Darin Fisher SGTMed the policy decision.)

[chromium] Chromium Mac should use WebKit's image decoders
https://bugs.webkit.org/show_bug.cgi?id=47974

Enable WebKit's image decoders.

  • features.gypi:

2010-10-28 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
(Eric reviewed the CoreGraphics interactions, Peter reviewed the image
decoder interaction, and Darin Fisher SGTMed the policy decision.)

[chromium] Chromium Mac should use WebKit's image decoders
https://bugs.webkit.org/show_bug.cgi?id=47974

This patch teaches WebKit's image decoders how to talk to CoreGraphics.
This patch doesn't handle color profiles, but that will come in a
subsequent patch.

  • WebCore.gyp/WebCore.gyp:
  • WebCore.gypi:
  • loader/CachedImage.cpp: (WebCore::CachedImage::createImage):
  • platform/graphics/ImageSource.h:
  • platform/image-decoders/ImageDecoder.cpp: (WebCore::RGBA32Buffer::clear): (WebCore::RGBA32Buffer::zeroFill): (WebCore::RGBA32Buffer::copyBitmapData): (WebCore::RGBA32Buffer::setSize):
  • platform/image-decoders/ImageDecoder.h: (WebCore::RGBA32Buffer::getAddr):
  • platform/image-decoders/cg: Added.
  • platform/image-decoders/cg/ImageDecoderCG.cpp: Added. (WebCore::RGBA32Buffer::copyBitmapData): (WebCore::RGBA32Buffer::setSize): (WebCore::RGBA32Buffer::asNewNativeImage):
Location:
trunk
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70844 r70846  
     12010-10-28  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
     4        (Eric reviewed the CoreGraphics interactions, Peter reviewed the image
     5        decoder interaction, and Darin Fisher SGTMed the policy decision.)
     6
     7        [chromium] Chromium Mac should use WebKit's image decoders
     8        https://bugs.webkit.org/show_bug.cgi?id=47974
     9
     10        This patch teaches WebKit's image decoders how to talk to CoreGraphics.
     11        This patch doesn't handle color profiles, but that will come in a
     12        subsequent patch.
     13
     14        * WebCore.gyp/WebCore.gyp:
     15        * WebCore.gypi:
     16        * loader/CachedImage.cpp:
     17        (WebCore::CachedImage::createImage):
     18        * platform/graphics/ImageSource.h:
     19        * platform/image-decoders/ImageDecoder.cpp:
     20        (WebCore::RGBA32Buffer::clear):
     21        (WebCore::RGBA32Buffer::zeroFill):
     22        (WebCore::RGBA32Buffer::copyBitmapData):
     23        (WebCore::RGBA32Buffer::setSize):
     24        * platform/image-decoders/ImageDecoder.h:
     25        (WebCore::RGBA32Buffer::getAddr):
     26        * platform/image-decoders/cg: Added.
     27        * platform/image-decoders/cg/ImageDecoderCG.cpp: Added.
     28        (WebCore::RGBA32Buffer::copyBitmapData):
     29        (WebCore::RGBA32Buffer::setSize):
     30        (WebCore::RGBA32Buffer::asNewNativeImage):
     31
    1322010-10-28  Sergio Villar Senin  <svillar@igalia.com>
    233
  • trunk/WebCore/WebCore.gyp/WebCore.gyp

    r70394 r70846  
    11651165            ['exclude', 'platform/graphics/chromium/ImageChromium\\.cpp$'],
    11661166
    1167             # The Mac uses ImageSourceCG.cpp from platform/graphics/cg, included
    1168             # by regex above, instead.
    1169             ['exclude', 'platform/graphics/ImageSource\\.cpp$'],
    1170 
    1171             # Skia image-decoders are also not used on mac.  CoreGraphics
    1172             # is used directly instead.
    1173             ['exclude', 'platform/image-decoders/ImageDecoder\\.h$'],
    1174             ['exclude', 'platform/image-decoders/bmp/BMPImageDecoder\\.(cpp|h)$'],
    1175             ['exclude', 'platform/image-decoders/bmp/BMPImageReader\\.(cpp|h)$'],
    1176             ['exclude', 'platform/image-decoders/gif/GIFImageDecoder\\.(cpp|h)$'],
    1177             ['exclude', 'platform/image-decoders/gif/GIFImageReader\\.(cpp|h)$'],
    1178             ['exclude', 'platform/image-decoders/ico/ICOImageDecoder\\.(cpp|h)$'],
    1179             ['exclude', 'platform/image-decoders/jpeg/JPEGImageDecoder\\.(cpp|h)$'],
    1180             ['exclude', 'platform/image-decoders/webp/WEBPImageDecoder\\.(cpp|h)$'],
    1181             ['exclude', 'platform/image-decoders/png/PNGImageDecoder\\.(cpp|h)$'],
     1167            # The Mac does not use ImageSourceCG.cpp from platform/graphics/cg
     1168            # even though it is included by regex above.
     1169            ['exclude', 'platform/graphics/cg/ImageSourceCG\\.cpp$'],
     1170            ['exclude', 'platform/graphics/cg/PDFDocumentImage\\.cpp$'],
     1171
     1172            # ImageDecoderSkia is not used on mac.  ImageDecoderCG is used instead.
    11821173            ['exclude', 'platform/image-decoders/skia/ImageDecoderSkia\\.cpp$'],
    1183             ['exclude', 'platform/image-decoders/xbm/XBMImageDecoder\\.(cpp|h)$'],
     1174            ['include', 'platform/image-decoders/cg/ImageDecoderCG\\.cpp$'],
    11841175
    11851176            # Again, Skia is not used on Mac.
  • trunk/WebCore/WebCore.gypi

    r70745 r70846  
    28522852            'platform/image-decoders/bmp/BMPImageReader.h',
    28532853            'platform/image-decoders/cairo/ImageDecoderCairo.cpp',
     2854            'platform/image-decoders/cg/ImageDecoderCG.cpp',
    28542855            'platform/image-decoders/gif/GIFImageDecoder.cpp',
    28552856            'platform/image-decoders/gif/GIFImageDecoder.h',
  • trunk/WebCore/loader/CachedImage.cpp

    r70394 r70846  
    238238    if (m_image)
    239239        return;
    240 #if PLATFORM(CG)
     240#if PLATFORM(CG) && !USE(WEBKIT_IMAGE_DECODERS)
    241241    if (m_response.mimeType() == "application/pdf") {
    242242        m_image = PDFDocumentImage::create();
  • trunk/WebCore/platform/graphics/ImageSource.h

    r70394 r70846  
    6464
    6565#if PLATFORM(CG)
     66#if USE(WEBKIT_IMAGE_DECODERS)
     67class ImageDecoder;
     68typedef ImageDecoder* NativeImageSourcePtr;
     69#else
    6670typedef CGImageSourceRef NativeImageSourcePtr;
     71#endif
    6772typedef CGImageRef NativeImagePtr;
    6873#elif PLATFORM(OPENVG)
  • trunk/WebCore/platform/image-decoders/ImageDecoder.cpp

    r70394 r70846  
    118118        return *this;
    119119
    120     copyBitmapData(other);
     120    copyReferenceToBitmapData(other);
    121121    setRect(other.rect());
    122122    setStatus(other.status());
     
    129129void RGBA32Buffer::clear()
    130130{
    131     m_bytes.clear();
     131    m_backingStore.clear();
     132    m_bytes = 0;
    132133    m_status = FrameEmpty;
    133134    // NOTE: Do not reset other members here; clearFrameBufferCache() calls this
     
    139140void RGBA32Buffer::zeroFill()
    140141{
    141     m_bytes.fill(0);
     142    memset(m_bytes, 0, m_size.width() * m_size.height() * sizeof(PixelData));
    142143    m_hasAlpha = true;
     144}
     145
     146#if !PLATFORM(CF)
     147
     148void RGBA32Buffer::copyReferenceToBitmapData(const RGBA32Buffer& other)
     149{
     150    ASSERT(this != &other);
     151    copyBitmapData(other);
    143152}
    144153
     
    148157        return true;
    149158
    150     m_bytes = other.m_bytes;
     159    m_backingStore = other.m_backingStore;
     160    m_bytes = m_backingStore.data();
    151161    m_size = other.m_size;
    152162    setHasAlpha(other.m_hasAlpha);
     
    158168    // NOTE: This has no way to check for allocation failure if the requested
    159169    // size was too big...
    160     m_bytes.resize(newWidth * newHeight);
     170    m_backingStore.resize(newWidth * newHeight);
     171    m_bytes = m_backingStore.data();
    161172    m_size = IntSize(newWidth, newHeight);
    162173
     
    166177    return true;
    167178}
     179
     180#endif
    168181
    169182bool RGBA32Buffer::hasAlpha() const
  • trunk/WebCore/platform/image-decoders/ImageDecoder.h

    r70394 r70846  
    8686        // Creates a new copy of the image data in |other|, so the two images
    8787        // can be modified independently.  Returns whether the copy succeeded.
    88         bool copyBitmapData(const RGBA32Buffer& other);
     88        bool copyBitmapData(const RGBA32Buffer&);
     89
     90        // Creates a new reference to the image data in |other|.  The two images
     91        // share a common backing store.
     92        void copyReferenceToBitmapData(const RGBA32Buffer&);
    8993
    9094        // Copies the pixel data at [(startX, startY), (endX, startY)) to the
     
    138142
    139143    private:
     144#if PLATFORM(CF)
     145        typedef RetainPtr<CFMutableDataRef> NativeBackingStore;
     146#else
     147        typedef Vector<PixelData> NativeBackingStore;
     148#endif
     149
    140150        int width() const;
    141151        int height() const;
     
    150160            return reinterpret_cast_ptr<QRgb*>(m_image.scanLine(y)) + x;
    151161#else
    152             return m_bytes.data() + (y * width()) + x;
     162            return m_bytes + (y * width()) + x;
    153163#endif
    154164        }
     
    177187        IntSize m_size;
    178188#else
    179         Vector<PixelData> m_bytes;
    180         IntSize m_size;       // The size of the buffer.  This should be the
    181                               // same as ImageDecoder::m_size.
    182         bool m_hasAlpha;      // Whether or not any of the pixels in the buffer
    183                               // have transparency.
    184 #endif
    185         IntRect m_rect;       // The rect of the original specified frame within
    186                               // the overall buffer.  This will always just be
    187                               // the entire buffer except for GIF frames whose
    188                               // original rect was smaller than the overall
    189                               // image size.
     189        NativeBackingStore m_backingStore;
     190        PixelData* m_bytes; // The memory is backed by m_backingStore.
     191        IntSize m_size; // The size of the buffer.  This should be the
     192                        // same as ImageDecoder::m_size.
     193        bool m_hasAlpha; // Whether or not any of the pixels in the buffer
     194                         // have transparency.
     195#endif
     196        IntRect m_rect; // The rect of the original specified frame within
     197                        // the overall buffer.  This will always just be
     198                        // the entire buffer except for GIF frames whose
     199                        // original rect was smaller than the overall
     200                        // image size.
    190201        FrameStatus m_status; // Whether or not this frame is completely
    191202                              // finished decoding.
    192         unsigned m_duration;  // The animation delay.
    193         FrameDisposalMethod m_disposalMethod;
    194                               // What to do with this frame's data when
    195                               // initializing the next frame.
    196         bool m_premultiplyAlpha;
    197                               // Whether to premultiply alpha into R, G, B
    198                               // channels; by default it's true.
     203        unsigned m_duration; // The animation delay.
     204        FrameDisposalMethod m_disposalMethod; // What to do with this frame's data when
     205                                              // initializing the next frame.
     206        bool m_premultiplyAlpha; // Whether to premultiply alpha into R, G, B
     207                                 // channels; by default it's true.
    199208    };
    200209
  • trunk/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp

    r70394 r70846  
    3535    return cairo_image_surface_create_for_data(
    3636        reinterpret_cast<unsigned char*>(const_cast<PixelData*>(
    37             m_bytes.data())), CAIRO_FORMAT_ARGB32, width(), height(),
     37            m_bytes)), CAIRO_FORMAT_ARGB32, width(), height(),
    3838        width() * sizeof(PixelData));
    3939}
  • trunk/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp

    r70394 r70846  
    3737    OwnPtr<BBitmap> bitmap(new BBitmap(BRect(0, 0, width() - 1, height() - 1), 0, B_RGBA32, bytesPerRow));
    3838
    39     const uint8* source = reinterpret_cast<const uint8*>(m_bytes.data());
     39    const uint8* source = reinterpret_cast<const uint8*>(m_bytes);
    4040    uint8* destination = reinterpret_cast<uint8*>(bitmap->Bits());
    4141    int h = height();
  • trunk/WebCore/platform/image-decoders/openvg/ImageDecoderOpenVG.cpp

    r70394 r70846  
    6060            ASSERT_VG_NO_ERROR();
    6161
    62             PixelData* pixelData = const_cast<PixelData*>(m_bytes.data());
     62            PixelData* pixelData = const_cast<PixelData*>(m_bytes);
    6363            pixelData += (tileRect.y() * width()) + tileRect.x();
    6464
  • trunk/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp

    r70394 r70846  
    4949        // This code works properly on both ppc and intel, meaning the issue is
    5050        // likely not an issue of byte order getting mixed up on different archs.
    51         const unsigned char* bytes = (const unsigned char*)m_bytes.data();
     51        const unsigned char* bytes = (const unsigned char*)m_bytes;
    5252        int rowCounter = 0;
    5353        long pixelCounter = 0;
    5454        WxPixelData::Iterator p(data);
    5555        WxPixelData::Iterator rowStart = p;
    56         for (size_t i = 0; i < m_bytes.size() * sizeof(PixelData); i += sizeof(PixelData)) {
     56        for (size_t i = 0; i < m_size.width() * m_size.height() * sizeof(PixelData); i += sizeof(PixelData)) {
    5757                p.Red() = bytes[i + 2];
    5858                p.Green() = bytes[i + 1];
  • trunk/WebKit/chromium/ChangeLog

    r70823 r70846  
     12010-10-28  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
     4        (Eric reviewed the CoreGraphics interactions, Peter reviewed the image
     5        decoder interaction, and Darin Fisher SGTMed the policy decision.)
     6
     7        [chromium] Chromium Mac should use WebKit's image decoders
     8        https://bugs.webkit.org/show_bug.cgi?id=47974
     9
     10        Enable WebKit's image decoders.
     11
     12        * features.gypi:
     13
    1142010-10-28  Mihai Parparita  <mihaip@chromium.org>
    215
  • trunk/WebKit/chromium/features.gypi

    r70712 r70846  
    9090        'WTF_USE_ACCELERATED_COMPOSITING=1',
    9191        'WTF_USE_WEBP=1',
     92        'WTF_USE_WEBKIT_IMAGE_DECODERS=1',
    9293      ],
    9394
Note: See TracChangeset for help on using the changeset viewer.