Changeset 82442 in webkit
- Timestamp:
- Mar 30, 2011 7:42:13 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r82441 r82442 1 2011-03-29 Adam Roben <aroben@apple.com> 2 3 Add a way to specify that a ShareableBitmap has no alpha channel 4 5 Before this patch, all ShareableBitmaps had an alpha channel. With this patch, all 6 ShareableBitmaps *still* have an alpha channel. But now there's a way to specify you don't 7 want one (which will be used in the future)! 8 9 Fixes <http://webkit.org/b/57388> Need a way to specify that a ShareableBitmap has no alpha 10 channel 11 12 Reviewed by Anders Carlsson. 13 14 * Shared/ShareableBitmap.cpp: 15 (WebKit::ShareableBitmap::Handle::Handle): Moved here from the header file, and added 16 initialization of m_flags. 17 18 (WebKit::ShareableBitmap::Handle::encode): 19 (WebKit::ShareableBitmap::Handle::decode): 20 Encode/decode m_flags. 21 22 (WebKit::ShareableBitmap::create): 23 (WebKit::ShareableBitmap::createShareable): 24 Pass along the new Flags argument. 25 26 (WebKit::ShareableBitmap::createHandle): Store our Flags on the Handle. 27 (WebKit::ShareableBitmap::ShareableBitmap): Store the Flags in m_flags. 28 29 * Shared/ShareableBitmap.h: Added Flag, Flags, and m_flags, and added a Flags argument to 30 some create functions. 31 32 * Shared/WebCoreArgumentCoders.cpp: 33 (CoreIPC::encodeImage): 34 * Shared/WebImage.cpp: 35 (WebKit::WebImage::create): 36 Specify that we want a bitmap that supports alpha to maintain current behavior. 37 38 * Shared/cg/ShareableBitmapCG.cpp: 39 (WebKit::bitmapInfo): New helper function. Includes an alpha channel only if specified in 40 the flags. 41 42 (WebKit::ShareableBitmap::createGraphicsContext): 43 (WebKit::ShareableBitmap::makeCGImage): 44 Use the new helper function. 45 46 * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: 47 (WebKit::NetscapePlugin::snapshot): 48 * WebProcess/Plugins/PluginProxy.cpp: 49 (WebKit::PluginProxy::geometryDidChange): 50 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 51 (WebKit::convertImageToBitmap): 52 * WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp: 53 (WebKit::WebPopupMenu::setUpPlatformData): 54 * WebProcess/WebPage/DrawingAreaImpl.cpp: 55 (WebKit::DrawingAreaImpl::display): 56 * WebProcess/WebPage/FindController.cpp: 57 (WebKit::FindController::updateFindIndicator): 58 Specify that we want a bitmap that supports alpha to maintain current behavior. 59 1 60 2011-03-29 Adam Roben <aroben@apple.com> 2 61 -
trunk/Source/WebKit2/Shared/ShareableBitmap.cpp
r82441 r82442 35 35 namespace WebKit { 36 36 37 ShareableBitmap::Handle::Handle() 38 : m_flags(0) 39 { 40 } 41 37 42 void ShareableBitmap::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const 38 43 { 39 44 encoder->encode(m_handle); 40 45 encoder->encode(m_size); 46 encoder->encode(m_flags); 41 47 } 42 48 … … 47 53 if (!decoder->decode(handle.m_size)) 48 54 return false; 55 if (!decoder->decode(handle.m_flags)) 56 return false; 49 57 return true; 50 58 } 51 59 52 PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size)60 PassRefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags) 53 61 { 54 62 size_t numBytes = numBytesForSize(size); … … 58 66 return 0; 59 67 60 return adoptRef(new ShareableBitmap(size, data));68 return adoptRef(new ShareableBitmap(size, flags, data)); 61 69 } 62 70 63 PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size )71 PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags) 64 72 { 65 73 size_t numBytes = numBytesForSize(size); … … 69 77 return 0; 70 78 71 return adoptRef(new ShareableBitmap(size, sharedMemory));79 return adoptRef(new ShareableBitmap(size, flags, sharedMemory)); 72 80 } 73 81 74 PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size, PassRefPtr<SharedMemory> sharedMemory)82 PassRefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags, PassRefPtr<SharedMemory> sharedMemory) 75 83 { 76 84 ASSERT(sharedMemory); … … 79 87 ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes); 80 88 81 return adoptRef(new ShareableBitmap(size, sharedMemory));89 return adoptRef(new ShareableBitmap(size, flags, sharedMemory)); 82 90 } 83 91 … … 89 97 return 0; 90 98 91 return create(handle.m_size, sharedMemory.release());99 return create(handle.m_size, handle.m_flags, sharedMemory.release()); 92 100 } 93 101 … … 99 107 return false; 100 108 handle.m_size = m_size; 109 handle.m_flags = m_flags; 101 110 return true; 102 111 } 103 112 104 ShareableBitmap::ShareableBitmap(const IntSize& size, void* data)113 ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, void* data) 105 114 : m_size(size) 115 , m_flags(flags) 106 116 , m_data(data) 107 117 { 108 118 } 109 119 110 ShareableBitmap::ShareableBitmap(const IntSize& size, PassRefPtr<SharedMemory> sharedMemory)120 ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, PassRefPtr<SharedMemory> sharedMemory) 111 121 : m_size(size) 122 , m_flags(flags) 112 123 , m_sharedMemory(sharedMemory) 113 124 , m_data(0) -
trunk/Source/WebKit2/Shared/ShareableBitmap.h
r82441 r82442 46 46 class ShareableBitmap : public RefCounted<ShareableBitmap> { 47 47 public: 48 enum Flag { 49 SupportsAlpha = 1 << 0, 50 }; 51 typedef unsigned Flags; 52 48 53 class Handle { 49 54 WTF_MAKE_NONCOPYABLE(Handle); 50 55 public: 51 Handle() { }56 Handle(); 52 57 53 58 bool isNull() const { return m_handle.isNull(); } … … 61 66 mutable SharedMemory::Handle m_handle; 62 67 WebCore::IntSize m_size; 68 Flags m_flags; 63 69 }; 64 70 65 71 // Create a shareable bitmap that uses malloced memory. 66 static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize& );72 static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags); 67 73 68 74 // Create a shareable bitmap whose backing memory can be shared with another process. 69 static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize& );75 static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Flags); 70 76 71 77 // Create a shareable bitmap from an already existing shared memory block. 72 static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, PassRefPtr<SharedMemory>);78 static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags, PassRefPtr<SharedMemory>); 73 79 74 80 // Create a shareable bitmap from a handle. … … 103 109 104 110 private: 105 ShareableBitmap(const WebCore::IntSize&, void*);106 ShareableBitmap(const WebCore::IntSize&, PassRefPtr<SharedMemory>);111 ShareableBitmap(const WebCore::IntSize&, Flags, void*); 112 ShareableBitmap(const WebCore::IntSize&, Flags, PassRefPtr<SharedMemory>); 107 113 108 114 static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; } … … 117 123 118 124 WebCore::IntSize m_size; 125 Flags m_flags; 119 126 120 127 // If the shareable bitmap is backed by shared memory, this points to the shared memory object. -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r82441 r82442 38 38 void encodeImage(ArgumentEncoder* encoder, Image* image) 39 39 { 40 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size() );40 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha); 41 41 bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint()); 42 42 ShareableBitmap::Handle handle; -
trunk/Source/WebKit2/Shared/WebImage.cpp
r76916 r82442 36 36 { 37 37 if (options & ImageOptionsShareable) 38 return WebImage::create(ShareableBitmap::createShareable(size ));39 return WebImage::create(ShareableBitmap::create(size ));38 return WebImage::create(ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha)); 39 return WebImage::create(ShareableBitmap::create(size, ShareableBitmap::SupportsAlpha)); 40 40 } 41 41 -
trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp
r82151 r82442 35 35 namespace WebKit { 36 36 37 static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags) 38 { 39 CGBitmapInfo info = kCGBitmapByteOrder32Host; 40 if (flags & ShareableBitmap::SupportsAlpha) 41 info |= kCGImageAlphaPremultipliedFirst; 42 else 43 info |= kCGImageAlphaNoneSkipFirst; 44 45 return info; 46 } 47 37 48 PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext() 38 49 { 39 50 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); 40 51 52 41 53 ref(); // Balanced by deref in releaseBitmapContextData. 42 54 RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreateWithData(data(), 43 55 m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), 44 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, releaseBitmapContextData, this));56 bitmapInfo(m_flags), releaseBitmapContextData, this)); 45 57 46 58 // We want the origin to be in the top left corner so we flip the backing store context. … … 69 81 70 82 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); 71 RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(m_size.width(), m_size.height(), 8, 32, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, dataProvider.get(), 0, false, kCGRenderingIntentDefault));83 RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(m_size.width(), m_size.height(), 8, 32, m_size.width() * 4, colorSpace.get(), bitmapInfo(m_flags), dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 72 84 return image; 73 85 } -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
r81705 r82442 514 514 ASSERT(m_isStarted); 515 515 516 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_frameRect.size() );516 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_frameRect.size(), ShareableBitmap::SupportsAlpha); 517 517 OwnPtr<GraphicsContext> context = bitmap->createGraphicsContext(); 518 518 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
r82441 r82442 196 196 if (didUpdateBackingStore) { 197 197 // Create a new plug-in backing store. 198 m_pluginBackingStore = ShareableBitmap::createShareable(frameRect.size() );198 m_pluginBackingStore = ShareableBitmap::createShareable(frameRect.size(), ShareableBitmap::SupportsAlpha); 199 199 if (!m_pluginBackingStore) 200 200 return; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r82441 r82442 78 78 static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image) 79 79 { 80 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize([image size]) );80 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize([image size]), ShareableBitmap::SupportsAlpha); 81 81 OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); 82 82 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
r82441 r82442 80 80 81 81 IntSize backingStoreSize(backingStoreWidth, (itemCount * data.m_itemHeight)); 82 data.m_notSelectedBackingStore = ShareableBitmap::createShareable(backingStoreSize );83 data.m_selectedBackingStore = ShareableBitmap::createShareable(backingStoreSize );82 data.m_notSelectedBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); 83 data.m_selectedBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); 84 84 85 85 OwnPtr<GraphicsContext> notSelectedBackingStoreContext = data.m_notSelectedBackingStore->createGraphicsContext(); -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
r80917 r82442 516 516 ASSERT(m_webPage->bounds().contains(bounds)); 517 517 518 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size() );518 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha); 519 519 if (!bitmap->createHandle(updateInfo.bitmapHandle)) 520 520 return; -
trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp
r82441 r82442 166 166 167 167 // Create a backing store and paint the find indicator text into it. 168 RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(selectionRect.size() );168 RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(selectionRect.size(), ShareableBitmap::SupportsAlpha); 169 169 if (!findIndicatorTextBackingStore) 170 170 return false;
Note: See TracChangeset
for help on using the changeset viewer.