Changeset 20183 in webkit


Ignore:
Timestamp:
Mar 14, 2007 1:49:55 AM (17 years ago)
Author:
hyatt
Message:

Make sure to use CFDataCreateWithBytesNoCopy where we can.

Reviewed by andersca

  • platform/graphics/cg/ImageSourceCG.cpp: (WebCore::ImageSource::setData):
  • platform/graphics/cg/PDFDocumentImage.cpp: (WebCore::PDFDocumentImage::dataChanged):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r20182 r20183  
     12007-03-14  David Hyatt  <hyatt@apple.com>
     2
     3        Make sure to use CFDataCreateWithBytesNoCopy where we can.
     4
     5        Reviewed by andersca
     6
     7        * platform/graphics/cg/ImageSourceCG.cpp:
     8        (WebCore::ImageSource::setData):
     9        * platform/graphics/cg/PDFDocumentImage.cpp:
     10        (WebCore::PDFDocumentImage::dataChanged):
     11
    1122007-03-13  David Hyatt  <hyatt@apple.com>
    213
  • trunk/WebCore/platform/graphics/cg/ImageSourceCG.cpp

    r20182 r20183  
    7777    if (!m_decoder)
    7878        m_decoder = CGImageSourceCreateIncremental(NULL);
    79        
     79#if PLATFORM(MAC)
     80    // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.  We use SharedBuffer's ability
     81    // to wrap itself in an NSData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
    8082    CFDataRef cfData = (CFDataRef)data->createNSData();
     83#else
     84    // If no NSData is available, then we know SharedBuffer will always just be a vector.  That means no secret changes can occur to it behind the
     85    // scenes.  We use CFDataCreateWithBytesNoCopy in that case.
     86    CFDataRef cfData = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data->data()), length, kCFAllocatorNull);
     87#endif
    8188    CGImageSourceUpdateData(m_decoder, cfData, allDataReceived);
    8289    CFRelease(cfData);
  • trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp

    r20182 r20183  
    5757{
    5858    if (allDataReceived && !m_document) {
     59#if PLATFORM(MAC)
     60        // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.  We use SharedBuffer's ability
     61        // to wrap itself in an NSData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
    5962        CFDataRef data = (CFDataRef)m_data->createNSData();
     63#else
     64        // If no NSData is available, then we know SharedBuffer will always just be a vector.  That means no secret changes can occur to it behind the
     65        // scenes.  We use CFDataCreateWithBytesNoCopy in that case.
     66        CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data->data()), length, kCFAllocatorNull);
     67#endif
    6068        CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(data);
    6169        CFRelease(data);
Note: See TracChangeset for help on using the changeset viewer.