Changeset 51207 in webkit
- Timestamp:
- Nov 19, 2009 3:12:56 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r51205 r51207 1 2009-11-19 Avi Drissman <avi@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Properly create a CGImageRef on non-PLATFORM(MAC). 6 https://bugs.webkit.org/show_bug.cgi?id=27777 7 8 * platform/graphics/cg/ImageSourceCG.cpp: 9 (WebCore::sharedBufferGetBytesAtPosition): 10 (WebCore::sharedBufferRelease): 11 (WebCore::ImageSource::setData): 12 * platform/graphics/cg/ImageSourceCG.h: 13 * platform/graphics/cg/PDFDocumentImage.cpp: 14 (WebCore::PDFDocumentImage::dataChanged): 15 1 16 2009-11-19 Oliver Hunt <oliver@apple.com> 2 17 -
trunk/WebCore/platform/graphics/cg/ImageSourceCG.cpp
r47585 r51207 36 36 #include <wtf/UnusedParam.h> 37 37 38 using namespace std; 39 38 40 namespace WebCore { 39 41 … … 41 43 42 44 #if !PLATFORM(MAC) 43 static void sharedBufferDerefCallback(void*, void* info) 45 size_t sharedBufferGetBytesAtPosition(void* info, void* buffer, off_t position, size_t count) 46 { 47 SharedBuffer* sharedBuffer = static_cast<SharedBuffer*>(info); 48 size_t sourceSize = sharedBuffer->size(); 49 if (position >= sourceSize) 50 return 0; 51 52 const char* source = sharedBuffer->data() + position; 53 size_t amount = min<size_t>(count, sourceSize - position); 54 memcpy(buffer, source, amount); 55 return amount; 56 } 57 58 void sharedBufferRelease(void* info) 44 59 { 45 60 SharedBuffer* sharedBuffer = static_cast<SharedBuffer*>(info); … … 111 126 // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer. 112 127 RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData()); 128 CGImageSourceUpdateData(m_decoder, cfData.get(), allDataReceived); 113 129 #else 114 // 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 115 // scenes. We use CFDataCreateWithBytesNoCopy in that case. Ensure that the SharedBuffer lives as long as the CFDataRef. 130 // Create a CGDataProvider to wrap the SharedBuffer. 116 131 data->ref(); 117 CFAllocatorContext context = {0, data, 0, 0, 0, 0, 0, &sharedBufferDerefCallback, 0}; 118 RetainPtr<CFAllocatorRef> derefAllocator(AdoptCF, CFAllocatorCreate(kCFAllocatorDefault, &context)); 119 RetainPtr<CFDataRef> cfData(AdoptCF, CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data->data()), data->size(), derefAllocator.get())); 132 // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer 133 // does not provide a way to lock down the byte pointer and guarantee that it won't move, which 134 // is a requirement for using the GetBytePointer callback. 135 CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, sharedBufferRelease }; 136 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateDirect(data, data->size(), &providerCallbacks)); 137 CGImageSourceUpdateDataProvider(m_decoder, dataProvider.get(), allDataReceived); 120 138 #endif 121 CGImageSourceUpdateData(m_decoder, cfData.get(), allDataReceived);122 139 } 123 140 -
trunk/WebCore/platform/graphics/cg/ImageSourceCG.h
r39185 r51207 37 37 String MIMETypeForImageSourceType(const String& type); 38 38 39 #if !PLATFORM(MAC) 40 size_t sharedBufferGetBytesAtPosition(void* info, void* buffer, off_t position, size_t count); 41 #endif 42 39 43 } 40 44 -
trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
r47585 r51207 32 32 #include "GraphicsContext.h" 33 33 #include "ImageObserver.h" 34 #if !PLATFORM(MAC) 35 #include "ImageSourceCG.h" 36 #endif 34 37 #include <wtf/MathExtras.h> 35 38 … … 70 73 // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer. 71 74 RetainPtr<CFDataRef> data(AdoptCF, this->data()->createCFData()); 75 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get())); 72 76 #else 73 // 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 74 // scenes. We use CFDataCreateWithBytesNoCopy in that case. 75 RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(this->data()->data()), this->data()->size(), kCFAllocatorNull)); 77 // Create a CGDataProvider to wrap the SharedBuffer. 78 // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer 79 // does not provide a way to lock down the byte pointer and guarantee that it won't move, which 80 // is a requirement for using the GetBytePointer callback. 81 CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, 0 }; 82 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateDirect(this->data(), this->data()->size(), &providerCallbacks)); 76 83 #endif 77 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get()));78 84 m_document = CGPDFDocumentCreateWithProvider(dataProvider.get()); 79 85 setCurrentPage(0);
Note: See TracChangeset
for help on using the changeset viewer.