Changeset 73318 in webkit
- Timestamp:
- Dec 3, 2010 4:04:49 PM (13 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r73313 r73318 1 2010-12-03 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig and Dan Bernstein. 4 5 Clean up the BackingStore implementation 6 https://bugs.webkit.org/show_bug.cgi?id=50498 7 8 * Shared/BackingStore.cpp: 9 (WebKit::BackingStore::create): 10 (WebKit::BackingStore::createSharable): 11 (WebKit::BackingStore::resize): 12 Use new numBytesForSize helper function. 13 14 (WebKit::BackingStore::createFlippedGraphicsContext): 15 Make this function platform independent. 16 17 * Shared/BackingStore.h: 18 (WebKit::BackingStore::numBytesForSize): 19 Given a size, return the number of bytes needed for it. 20 21 (WebKit::BackingStore::sizeInBytes): 22 Implement. 23 24 * Shared/cg/BackingStoreCG.cpp: 25 (WebKit::BackingStore::paint): 26 Don't use CGBitmapContextCreateImage; it creates an extra copy of the image data. 27 28 * Shared/qt/BackingStoreQt.cpp: 29 Remove createFlippedGraphicsContext. 30 1 31 2010-12-03 Siddharth Mathur <siddharth.mathur@nokia.com> 2 32 -
trunk/WebKit2/Shared/BackingStore.cpp
r68351 r73318 27 27 28 28 #include "SharedMemory.h" 29 #include <WebCore/GraphicsContext.h> 29 30 30 31 using namespace WebCore; … … 34 35 PassRefPtr<BackingStore> BackingStore::create(const WebCore::IntSize& size) 35 36 { 36 size_t numBytes = size.width() * size.height() * 4;37 size_t numBytes = numBytesForSize(size); 37 38 38 39 void* data = 0; … … 45 46 PassRefPtr<BackingStore> BackingStore::createSharable(const IntSize& size) 46 47 { 47 size_t numBytes = size.width() * size.height() * 4;48 size_t numBytes = numBytesForSize(size); 48 49 49 50 RefPtr<SharedMemory> sharedMemory = SharedMemory::create(numBytes); … … 61 62 return 0; 62 63 63 size_t numBytes = size.width() * size.height() * 4;64 size_t numBytes = numBytesForSize(size); 64 65 ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes); 65 66 … … 101 102 return true; 102 103 103 size_t newNumBytes = size.width() * size.height() * 4;104 size_t newNumBytes = numBytesForSize(size); 104 105 105 106 // Try to resize. … … 125 126 } 126 127 128 PassOwnPtr<GraphicsContext> BackingStore::createFlippedGraphicsContext() 129 { 130 OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(); 131 132 // Flip the coordinate system. 133 graphicsContext->translate(0, m_size.height()); 134 graphicsContext->scale(FloatSize(1, -1)); 135 136 return graphicsContext.release(); 137 } 138 127 139 } // namespace WebKit -
trunk/WebKit2/Shared/BackingStore.h
r71640 r73318 73 73 74 74 bool isBackedBySharedMemory() const { return m_sharedMemory; } 75 static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; } 76 75 77 void* data() const; 78 size_t sizeInBytes() const { return numBytesForSize(m_size); } 76 79 77 80 WebCore::IntSize m_size; -
trunk/WebKit2/Shared/cg/BackingStoreCG.cpp
r73310 r73318 46 46 } 47 47 48 PassOwnPtr<GraphicsContext> BackingStore::createFlippedGraphicsContext()49 {50 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());51 RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(data(), m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(),52 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));53 54 return adoptPtr(new GraphicsContext(bitmapContext.get()));55 }56 57 48 void BackingStore::paint(WebCore::GraphicsContext& context, const WebCore::IntPoint& dstPoint, const WebCore::IntRect& srcRect) 58 49 { 59 50 OwnPtr<GraphicsContext> sourceContext(createGraphicsContext()); 60 51 61 // FIXME: This creates an extra copy. 62 RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(sourceContext->platformContext())); 52 CGContextRef sourceCGContext = sourceContext->platformContext(); 53 54 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithData(0, data(), sizeInBytes(), 0)); 55 RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(CGBitmapContextGetWidth(sourceCGContext), 56 CGBitmapContextGetHeight(sourceCGContext), 57 CGBitmapContextGetBitsPerComponent(sourceCGContext), 58 CGBitmapContextGetBitsPerPixel(sourceCGContext), 59 CGBitmapContextGetBytesPerRow(sourceCGContext), 60 CGBitmapContextGetColorSpace(sourceCGContext), 61 CGBitmapContextGetBitmapInfo(sourceCGContext), 62 dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 63 63 64 64 CGContextRef cgContext = context.platformContext(); -
trunk/WebKit2/Shared/qt/BackingStoreQt.cpp
r71821 r73318 47 47 } 48 48 49 PassOwnPtr<GraphicsContext> BackingStore::createFlippedGraphicsContext()50 {51 // This is CG specific so we should not use it.52 ASSERT_NOT_REACHED();53 return 0;54 }55 56 49 void BackingStore::paint(GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect) 57 50 {
Note: See TracChangeset
for help on using the changeset viewer.