Add ShareableBitmap::Handle
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Mar 2011 14:40:23 +0000 (14:40 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Mar 2011 14:40:23 +0000 (14:40 +0000)
This object is used for encoding/decoding a ShareableBitmap via CoreIPC. It currently just
encapsulates a SharedMemory::Handle (which is what we were using previously) and the image's
size (which means callers no longer need to deal with the size explicitly), but in the
future could be used to store more information about the bitmap.

This should cause no behavior changes.

Fixes <http://webkit.org/b/57397> ShareableBitmap needs its own Handle type

Reviewed by Anders Carlsson.

* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::geometryDidChange): No longer need to pass a size to create,
since the Handle records the size.
(WebKit::PluginControllerProxy::snapshot): No longer need the bufferSize argument, since the
Handle records the size.

* PluginProcess/PluginControllerProxy.h:
* PluginProcess/PluginControllerProxy.messages.in:
Updated Handle types and removed unnecessary size argument to Snapshot.

* Shared/PlatformPopupMenuData.cpp:
(WebKit::PlatformPopupMenuData::encode):
(WebKit::PlatformPopupMenuData::decode):
* Shared/PlatformPopupMenuData.h:
Changed to use ShareableBitmap::Handle and removed m_backingStoreSize, which is now stored
in the Handles.

* Shared/ShareableBitmap.cpp:
(WebKit::ShareableBitmap::Handle::encode):
(WebKit::ShareableBitmap::Handle::decode):
Simple encode/decode functions.

(WebKit::ShareableBitmap::create): Get the size from the Handle instead of as a separate
argument.
(WebKit::ShareableBitmap::createHandle): Store our size in the Handle.

* Shared/ShareableBitmap.h: Added ShareableBitmap::Handle and made some functions use it.

* Shared/UpdateInfo.h: Changed to use ShareableBitmap::Handle.

* Shared/UserMessageCoders.h:
(WebKit::UserMessageEncoder::baseEncode):
(WebKit::UserMessageDecoder::baseDecode):
* Shared/WebCoreArgumentCoders.cpp:
(CoreIPC::encodeImage):
(CoreIPC::decodeImage):
Use the size stored in the Handle instead of encoding/decoding one separately.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setDragImage):
Removed the unnecessary imageSize argument. We can get it from the image itself.

* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/FindIndicator.cpp:
(WebKit::FindIndicator::create):
No longer need to pass a size when creating a ShareableBitmap from a Handle.

* UIProcess/FindIndicator.h: Changed to use ShareableBitmap::Handle.

* UIProcess/PageClient.h: Removed unnecessary imageSize argument from setDragImage.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setFindIndicator):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::setDragImage):
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::snapshot):
(WebKit::PluginProxy::geometryDidChange):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::startDrag):
Changed to use ShareableBitmap::Handle and removed now-unnecessary size arguments (since we
can get the size from the Handle).

* WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
(WebKit::WebPopupMenu::setUpPlatformData): Don't need to store the backing store size in the
data anymore; the Handles will make sure it reaches the other process.

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindIndicator):
(WebKit::FindController::hideFindIndicator):
Changed to use ShareableBitmap::Handle.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82441 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in
Source/WebKit2/Shared/PlatformPopupMenuData.cpp
Source/WebKit2/Shared/PlatformPopupMenuData.h
Source/WebKit2/Shared/ShareableBitmap.cpp
Source/WebKit2/Shared/ShareableBitmap.h
Source/WebKit2/Shared/UpdateInfo.h
Source/WebKit2/Shared/UserMessageCoders.h
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/BackingStore.cpp
Source/WebKit2/UIProcess/FindIndicator.cpp
Source/WebKit2/UIProcess/FindIndicator.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
Source/WebKit2/WebProcess/WebPage/FindController.cpp

index 716ab1778d68b22b0dabf989dc88aebcb98d7d8d..838c4931e3ab45b4aec72326219f9475ece9bc18 100644 (file)
@@ -1,3 +1,94 @@
+2011-03-29  Adam Roben  <aroben@apple.com>
+
+        Add ShareableBitmap::Handle
+
+        This object is used for encoding/decoding a ShareableBitmap via CoreIPC. It currently just
+        encapsulates a SharedMemory::Handle (which is what we were using previously) and the image's
+        size (which means callers no longer need to deal with the size explicitly), but in the
+        future could be used to store more information about the bitmap.
+
+        This should cause no behavior changes.
+
+        Fixes <http://webkit.org/b/57397> ShareableBitmap needs its own Handle type
+
+        Reviewed by Anders Carlsson.
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::geometryDidChange): No longer need to pass a size to create,
+        since the Handle records the size.
+        (WebKit::PluginControllerProxy::snapshot): No longer need the bufferSize argument, since the
+        Handle records the size.
+
+        * PluginProcess/PluginControllerProxy.h:
+        * PluginProcess/PluginControllerProxy.messages.in:
+        Updated Handle types and removed unnecessary size argument to Snapshot.
+
+        * Shared/PlatformPopupMenuData.cpp:
+        (WebKit::PlatformPopupMenuData::encode):
+        (WebKit::PlatformPopupMenuData::decode):
+        * Shared/PlatformPopupMenuData.h:
+        Changed to use ShareableBitmap::Handle and removed m_backingStoreSize, which is now stored
+        in the Handles.
+
+        * Shared/ShareableBitmap.cpp:
+        (WebKit::ShareableBitmap::Handle::encode):
+        (WebKit::ShareableBitmap::Handle::decode):
+        Simple encode/decode functions.
+
+        (WebKit::ShareableBitmap::create): Get the size from the Handle instead of as a separate
+        argument.
+        (WebKit::ShareableBitmap::createHandle): Store our size in the Handle.
+
+        * Shared/ShareableBitmap.h: Added ShareableBitmap::Handle and made some functions use it.
+
+        * Shared/UpdateInfo.h: Changed to use ShareableBitmap::Handle.
+
+        * Shared/UserMessageCoders.h:
+        (WebKit::UserMessageEncoder::baseEncode):
+        (WebKit::UserMessageDecoder::baseDecode):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (CoreIPC::encodeImage):
+        (CoreIPC::decodeImage):
+        Use the size stored in the Handle instead of encoding/decoding one separately.
+
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setDragImage):
+        Removed the unnecessary imageSize argument. We can get it from the image itself.
+
+        * UIProcess/BackingStore.cpp:
+        (WebKit::BackingStore::incorporateUpdate):
+        * UIProcess/FindIndicator.cpp:
+        (WebKit::FindIndicator::create):
+        No longer need to pass a size when creating a ShareableBitmap from a Handle.
+
+        * UIProcess/FindIndicator.h: Changed to use ShareableBitmap::Handle.
+
+        * UIProcess/PageClient.h: Removed unnecessary imageSize argument from setDragImage.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setFindIndicator):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::setDragImage):
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::snapshot):
+        (WebKit::PluginProxy::geometryDidChange):
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::startDrag):
+        Changed to use ShareableBitmap::Handle and removed now-unnecessary size arguments (since we
+        can get the size from the Handle).
+
+        * WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
+        (WebKit::WebPopupMenu::setUpPlatformData): Don't need to store the backing store size in the
+        data anymore; the Handles will make sure it reaches the other process.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindIndicator):
+        (WebKit::FindController::hideFindIndicator):
+        Changed to use ShareableBitmap::Handle.
+
 2011-03-30  Alejandro G. Castro  <alex@igalia.com>
 
         Fix GTK build after r81980.
index c48fd65aed242b0135a526e14d44f4192eada3e5..03a8aec1a365e525a103e57ffcf369ecb4b3f1e6 100644 (file)
@@ -340,7 +340,7 @@ void PluginControllerProxy::frameDidFail(uint64_t requestID, bool wasCancelled)
     m_plugin->frameDidFail(requestID, wasCancelled);
 }
 
-void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect, const SharedMemory::Handle& backingStoreHandle)
+void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle)
 {
     m_frameRect = frameRect;
     m_clipRect = clipRect;
@@ -349,7 +349,7 @@ void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const In
 
     if (!backingStoreHandle.isNull()) {
         // Create a new backing store.
-        m_backingStore = ShareableBitmap::create(frameRect.size(), backingStoreHandle);
+        m_backingStore = ShareableBitmap::create(backingStoreHandle);
     }
 
     m_plugin->geometryDidChange(frameRect, clipRect);
@@ -448,7 +448,7 @@ void PluginControllerProxy::paintEntirePlugin()
     paint();
 }
 
-void PluginControllerProxy::snapshot(WebCore::IntSize& bufferSize, SharedMemory::Handle& backingStoreHandle)
+void PluginControllerProxy::snapshot(ShareableBitmap::Handle& backingStoreHandle)
 {
     ASSERT(m_plugin);
     RefPtr<ShareableBitmap> bitmap = m_plugin->snapshot();
@@ -456,7 +456,6 @@ void PluginControllerProxy::snapshot(WebCore::IntSize& bufferSize, SharedMemory:
         return;
 
     bitmap->createHandle(backingStoreHandle);
-    bufferSize = bitmap->size();
 }
 
 void PluginControllerProxy::setFocus(bool hasFocus)
index e470f85714fbc39489ddf31a49eabc1bc5205dcf..65be39e8f968b2eb05f42272de3f15245f628d1c 100644 (file)
@@ -32,7 +32,7 @@
 #include "Plugin.h"
 #include "PluginController.h"
 #include "RunLoop.h"
-#include "SharedMemory.h"
+#include "ShareableBitmap.h"
 #include <wtf/Noncopyable.h>
 
 #if PLATFORM(MAC)
@@ -105,7 +105,7 @@ private:
     // Message handlers.
     void frameDidFinishLoading(uint64_t requestID);
     void frameDidFail(uint64_t requestID, bool wasCancelled);
-    void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, const SharedMemory::Handle& backingStoreHandle);
+    void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle);
     void didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result);
     void streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers);
     void streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data);
@@ -121,7 +121,7 @@ private:
     void handleMouseLeaveEvent(const WebMouseEvent&, bool& handled);
     void handleKeyboardEvent(const WebKeyboardEvent&, bool& handled);
     void paintEntirePlugin();
-    void snapshot(WebCore::IntSize& bufferSize, SharedMemory::Handle& backingStoreHandle);
+    void snapshot(ShareableBitmap::Handle& backingStoreHandle);
     void setFocus(bool);
     void didUpdate();
     void getPluginScriptableNPObject(uint64_t& pluginScriptableNPObjectID);
index 91cc57f8ce1bfca82a077c84d1ef44e83a24a86b..6e27b36bbab43049b7d464f472dd5ee2d1032d77 100644 (file)
@@ -24,7 +24,7 @@
 
 messages -> PluginControllerProxy {
     # Sent when the plug-in geometry changes.
-    GeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, WebKit::SharedMemory::Handle backingStoreHandle)
+    GeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, WebKit::ShareableBitmap::Handle backingStoreHandle)
 
     # Sent when a frame has finished loading.
     FrameDidFinishLoading(uint64_t requestID)
@@ -101,7 +101,7 @@ messages -> PluginControllerProxy {
 #endif
 
     # Return a snapshot of the plugin
-    Snapshot() -> (WebCore::IntSize size, WebKit::SharedMemory::Handle backingStoreHandle)
+    Snapshot() -> (WebKit::ShareableBitmap::Handle backingStoreHandle)
     
     # Sent when private browsing is enabled or disabled
     PrivateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
index a5ebb45882d4892686cf1ca5faba74e5e7de55f0..1f56daf9be846b3275bee5a072dece4c826a0871 100644 (file)
@@ -51,13 +51,12 @@ void PlatformPopupMenuData::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(m_clientInsetRight);
     encoder->encode(m_popupWidth);
     encoder->encode(m_itemHeight);
-    encoder->encode(m_backingStoreSize);
 
-    SharedMemory::Handle notSelectedBackingStoreHandle;
+    ShareableBitmap::Handle notSelectedBackingStoreHandle;
     m_notSelectedBackingStore->createHandle(notSelectedBackingStoreHandle);
     encoder->encode(notSelectedBackingStoreHandle);
 
-    SharedMemory::Handle selectedBackingStoreHandle;
+    ShareableBitmap::Handle selectedBackingStoreHandle;
     m_selectedBackingStore->createHandle(selectedBackingStoreHandle);
     encoder->encode(selectedBackingStoreHandle);
 #elif PLATFORM(MAC)
@@ -80,18 +79,16 @@ bool PlatformPopupMenuData::decode(CoreIPC::ArgumentDecoder* decoder, PlatformPo
         return false;
     if (!decoder->decode(data.m_itemHeight))
         return false;
-    if (!decoder->decode(data.m_backingStoreSize))
-        return false;
 
-    SharedMemory::Handle notSelectedBackingStoreHandle;
+    ShareableBitmap::Handle notSelectedBackingStoreHandle;
     if (!decoder->decode(notSelectedBackingStoreHandle))
         return false;
-    data.m_notSelectedBackingStore = ShareableBitmap::create(data.m_backingStoreSize, notSelectedBackingStoreHandle);
+    data.m_notSelectedBackingStore = ShareableBitmap::create(notSelectedBackingStoreHandle);
 
-    SharedMemory::Handle selectedBackingStoreHandle;
+    ShareableBitmap::Handle selectedBackingStoreHandle;
     if (!decoder->decode(selectedBackingStoreHandle))
         return false;
-    data.m_selectedBackingStore = ShareableBitmap::create(data.m_backingStoreSize, selectedBackingStoreHandle);
+    data.m_selectedBackingStore = ShareableBitmap::create(selectedBackingStoreHandle);
 #elif PLATFORM(MAC)
     if (!decoder->decode(data.fontInfo))
         return false;
index f79b4b2da7db2e5ab5b4fbf93c3cda43509a4771..5b3f58dcd217a382d08b431592d8aca372dabd18 100644 (file)
@@ -50,7 +50,6 @@ struct PlatformPopupMenuData {
     int m_clientInsetRight;
     int m_popupWidth;
     int m_itemHeight;
-    WebCore::IntSize m_backingStoreSize;
     RefPtr<ShareableBitmap> m_notSelectedBackingStore;
     RefPtr<ShareableBitmap> m_selectedBackingStore;
 #elif PLATFORM(MAC)
index ab1991ffa6352c508c2fbc9aae747bf528532a8d..d21da12d577bd3bdd76f52ce73ea80283f3d4259 100644 (file)
 #include "ShareableBitmap.h"
 
 #include "SharedMemory.h"
+#include "WebCoreArgumentCoders.h"
 #include <WebCore/GraphicsContext.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
+void ShareableBitmap::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(m_handle);
+    encoder->encode(m_size);
+}
+
+bool ShareableBitmap::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& handle)
+{
+    if (!decoder->decode(handle.m_handle))
+        return false;
+    if (!decoder->decode(handle.m_size))
+        return false;
+    return true;
+}
+
 PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size)
 {
     size_t numBytes = numBytesForSize(size);
@@ -65,21 +81,24 @@ PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size
     return adoptRef(new ShareableBitmap(size, sharedMemory));
 }
 
-PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size, const SharedMemory::Handle& handle)
+PassRefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle)
 {
     // Create the shared memory.
-    RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadWrite);
+    RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle.m_handle, SharedMemory::ReadWrite);
     if (!sharedMemory)
         return 0;
 
-    return create(size, sharedMemory.release());
+    return create(handle.m_size, sharedMemory.release());
 }
 
-bool ShareableBitmap::createHandle(SharedMemory::Handle& handle)
+bool ShareableBitmap::createHandle(Handle& handle)
 {
     ASSERT(isBackedBySharedMemory());
 
-    return m_sharedMemory->createHandle(handle, SharedMemory::ReadWrite);
+    if (!m_sharedMemory->createHandle(handle.m_handle, SharedMemory::ReadWrite))
+        return false;
+    handle.m_size = m_size;
+    return true;
 }
 
 ShareableBitmap::ShareableBitmap(const IntSize& size, void* data)
index 30fc86cb54c856eda28bae7cb2ad062895d20852..d6b71aefa933a3ed6bd289a4198028a7dd530ad6 100644 (file)
@@ -45,6 +45,23 @@ namespace WebKit {
     
 class ShareableBitmap : public RefCounted<ShareableBitmap> {
 public:
+    class Handle {
+        WTF_MAKE_NONCOPYABLE(Handle);
+    public:
+        Handle() { }
+
+        bool isNull() const { return m_handle.isNull(); }
+
+        void encode(CoreIPC::ArgumentEncoder*) const;
+        static bool decode(CoreIPC::ArgumentDecoder*, Handle&);
+
+    private:
+        friend class ShareableBitmap;
+
+        mutable SharedMemory::Handle m_handle;
+        WebCore::IntSize m_size;
+    };
+
     // Create a shareable bitmap that uses malloced memory.
     static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&);
 
@@ -54,11 +71,11 @@ public:
     // Create a shareable bitmap from an already existing shared memory block.
     static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, PassRefPtr<SharedMemory>);
 
-    // Create a shareable bitmap from a shared memory handle.
-    static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, const SharedMemory::Handle&);
+    // Create a shareable bitmap from a handle.
+    static PassRefPtr<ShareableBitmap> create(const Handle&);
 
-    // Create a shared memory handle.
-    bool createHandle(SharedMemory::Handle&);
+    // Create a handle.
+    bool createHandle(Handle&);
 
     ~ShareableBitmap();
 
index 7b5454eb1c16a012e41f2ac7395e72e7fada8ed0..8e08ed02e38276ca80536cf0db2cf129ac5e9770 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef UpdateInfo_h
 #define UpdateInfo_h
 
-#include "SharedMemory.h"
+#include "ShareableBitmap.h"
 #include <WebCore/IntRect.h>
 #include <wtf/Noncopyable.h>
 
@@ -60,7 +60,7 @@ public:
     Vector<WebCore::IntRect> updateRects;
 
     // The handle of the shareable bitmap containing the updates. Will be null if there are no updates.
-    SharedMemory::Handle bitmapHandle;
+    ShareableBitmap::Handle bitmapHandle;
 };
 
 } // namespace WebKit
index 65875fab39eaa3c8089efac86e8ae358b32c3cb1..ad72493e559eb3afbe9c36dbb0e1199f246e8a3e 100644 (file)
@@ -132,13 +132,12 @@ public:
                 return true;
             }
 
-            SharedMemory::Handle handle;
+            ShareableBitmap::Handle handle;
             if (!image->bitmap()->createHandle(handle))
                 return false;
 
             encoder->encode(true);
             
-            encoder->encode(image->size());
             encoder->encode(handle);
             return true;
         }
@@ -293,15 +292,11 @@ public:
             if (!didEncode)
                 break;
 
-            WebCore::IntSize size;
-            if (!decoder->decode(size))
-                return false;
-
-            SharedMemory::Handle handle;
+            ShareableBitmap::Handle handle;
             if (!decoder->decode(handle))
                 return false;
 
-            coder.m_root = WebImage::create(ShareableBitmap::create(size, handle));
+            coder.m_root = WebImage::create(ShareableBitmap::create(handle));
             return true;
         }
         case APIObject::TypeData: {
index e97c7fdf98234afe30bfa754cb92182824e90169..56c7235195efd45ff5c53719b1ace807bce7a782 100644 (file)
@@ -39,23 +39,19 @@ void encodeImage(ArgumentEncoder* encoder, Image* image)
 {
     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size());
     bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     bitmap->createHandle(handle);
 
-    encoder->encode(image->size());
     encoder->encode(handle);
 }
 
 bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image)
 {
-    IntSize imageSize;
-    if (!decoder->decode(imageSize))
-        return false;
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     if (!decoder->decode(handle))
         return false;
     
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageSize, handle);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
     if (!bitmap)
         return false;
     image = createImage(bitmap.get());
index 07b8f210dc856f0fd5433c039691b57d876bb12a..e217fc5ef8a6fbabf8178bb2b78e98d9819aace0 100644 (file)
@@ -72,7 +72,7 @@ private:
     virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
     virtual void clearAllEditCommands();
     virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines);
-    virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
+    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
 
     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
index 6eb1cfe25b3fb95bd680bcbca0bcced350b59307..7a0d62d16196bf686191509b824fd4c6ca4ef0cc 100644 (file)
@@ -297,10 +297,10 @@ void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vect
     [m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines];
 }
 
-void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
 {
     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
-    RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:imageSize]);
+    RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
 
     [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
 }
index f9a2672c9f2e52c2f3fe7d81ab282fe7cb4d038b..5f024e62851a7a92e01c13fea67451323afbd82b 100644 (file)
@@ -57,9 +57,10 @@ void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo)
 {
 //    ASSERT(m_size == updateInfo.viewSize);
     
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
     if (!bitmap)
         return;
+    ASSERT(bitmap->size() == updateInfo.updateRectBounds.size());
     
     incorporateUpdate(bitmap.get(), updateInfo);
 }
index d6ac461e01a4ae380b4e02b9f9a705e76f426362..d30fb8d0bd32293a07ee647f0ad63b6ab524c516 100644 (file)
@@ -77,11 +77,12 @@ static const int gradientLightAlpha = 255;
 
 namespace WebKit {
 
-PassRefPtr<FindIndicator> FindIndicator::create(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle)
+PassRefPtr<FindIndicator> FindIndicator::create(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle)
 {
-    RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(enclosingIntRect(selectionRectInWindowCoordinates).size(), contentImageHandle);
+    RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(contentImageHandle);
     if (!contentImage)
         return 0;
+    ASSERT(contentImage->size() == enclosingIntRect(selectionRectInWindowCoordinates).size());
 
     return adoptRef(new FindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImage.release()));
 }
index 69088ce3638c51b89e0ee4ea187bfa30623b4fc8..49d07da6cc43f17291efb85c59e616db02d1b62b 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef FindIndicator_h
 #define FindIndicator_h
 
-#include "SharedMemory.h"
+#include "ShareableBitmap.h"
 #include <WebCore/FloatRect.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -38,11 +38,9 @@ namespace WebCore {
 
 namespace WebKit {
 
-class ShareableBitmap;
-
 class FindIndicator : public RefCounted<FindIndicator> {
 public:
-    static PassRefPtr<FindIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle);
+    static PassRefPtr<FindIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle);
     ~FindIndicator();
 
     WebCore::FloatRect selectionRectInWindowCoordinates() const { return m_selectionRectInWindowCoordinates; }
index 391e46672662216f2e07c308083e56fa1303b780..83ce502d35b9d0389d30064c7cc17a4c42bd95c6 100644 (file)
@@ -101,7 +101,7 @@ public:
 #if PLATFORM(MAC)
     virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0;
     virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) = 0;
-    virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
+    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
 #endif
 #if PLATFORM(WIN)
     virtual void compositionSelectionChanged(bool) = 0;
index 4017d0e2909f3dc5970c8da7268e0e49b465510e..72ca100ffd0aceaf2f96fe90fdef2cc2c7960457 100644 (file)
@@ -2061,7 +2061,7 @@ void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCou
     m_findClient.didCountStringMatches(this, string, matchCount);
 }
 
-void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle, bool fadeOut)
+void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut)
 {
     RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageHandle);
     m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
index b37ed1b7b81164624fd97ea3cca923f0d0409618..e3e62d40c0785e76f82d71179226e9131887e641 100644 (file)
@@ -370,7 +370,7 @@ public:
     void didPerformDragControllerAction(uint64_t resultOperation);
     void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
 #if PLATFORM(MAC)
-    void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag);
+    void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag);
 #endif
 #if PLATFORM(WIN)
     void startDragDrop(const WebCore::IntPoint& imagePoint, const WebCore::IntPoint& dragPoint, uint64_t okEffect, const HashMap<UINT, Vector<String> >& dataMap, const WebCore::IntSize& dragImageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag);
@@ -586,7 +586,7 @@ private:
     
     // Find.
     void didCountStringMatches(const String&, uint32_t matchCount);
-    void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle, bool fadeOut);
+    void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut);
     void didFindString(const String&, uint32_t matchCount);
     void didFailToFindString(const String&);
 
index a02b7b8dbcbd6d1305f06ddb2679f9264a6d8473..e145d82a4b8ea57325f488a32007de57f8d3fd20 100644 (file)
@@ -159,7 +159,7 @@ messages -> WebPageProxy {
 
     # Find messages
     DidCountStringMatches(WTF::String string, uint32_t matchCount)
-    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut)
+    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut)
     DidFindString(WTF::String string, uint32_t matchCount)
     DidFailToFindString(WTF::String string)
 
@@ -203,7 +203,7 @@ messages -> WebPageProxy {
     # Drag and drop messages
     DidPerformDragControllerAction(uint64_t resultOperation)
 #if PLATFORM(MAC)
-    SetDragImage(WebCore::IntPoint clientPosition, WebCore::IntSize imageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag)
+    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag)
 #endif
 #if PLATFORM(WIN)
     StartDragDrop(WebCore::IntPoint imagePoint, WebCore::IntPoint dragPoint, uint64_t okEffect, HashMap<UINT,Vector<String> > dataMap, WebCore::IntSize dragImageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag)
index ae0a8e5b967f0fc73600a1bfcb711baeeaf5ce42..90df81ecb2a1e73828c9d3d15ab7064eebeebc9d 100644 (file)
@@ -169,13 +169,13 @@ bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName)
     return result;
 }
 
-void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag)
+void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag)
 {
-    RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(imageSize, dragImageHandle);
+    RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(dragImageHandle);
     if (!dragImage)
         return;
     
-    m_pageClient->setDragImage(clientPosition, imageSize, dragImage.release(), isLinkDrag);
+    m_pageClient->setDragImage(clientPosition, dragImage.release(), isLinkDrag);
 }
 
 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
index 7285816f5cdaa646ae60e669403c220cf4f701c5..8f02cf5d2764c57f08fe70791f56025bbd340ab3 100644 (file)
@@ -153,11 +153,10 @@ void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRe
 
 PassRefPtr<ShareableBitmap> PluginProxy::snapshot()
 {
-    IntSize bufferSize;
-    SharedMemory::Handle snapshotStoreHandle;
-    m_connection->connection()->sendSync(Messages::PluginControllerProxy::Snapshot(), Messages::PluginControllerProxy::Snapshot::Reply(bufferSize, snapshotStoreHandle), m_pluginInstanceID);
+    ShareableBitmap::Handle snapshotStoreHandle;
+    m_connection->connection()->sendSync(Messages::PluginControllerProxy::Snapshot(), Messages::PluginControllerProxy::Snapshot::Reply(snapshotStoreHandle), m_pluginInstanceID);
 
-    RefPtr<ShareableBitmap> snapshotBuffer = ShareableBitmap::create(bufferSize, snapshotStoreHandle);
+    RefPtr<ShareableBitmap> snapshotBuffer = ShareableBitmap::create(snapshotStoreHandle);
     return snapshotBuffer.release();
 }
 
@@ -175,7 +174,7 @@ void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& cli
     m_frameRect = frameRect;
 
     if (!needsBackingStore()) {
-        SharedMemory::Handle pluginBackingStoreHandle;
+        ShareableBitmap::Handle pluginBackingStoreHandle;
         m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
         return;
     }
@@ -192,7 +191,7 @@ void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& cli
         didUpdateBackingStore = true;
     }
 
-    SharedMemory::Handle pluginBackingStoreHandle;
+    ShareableBitmap::Handle pluginBackingStoreHandle;
 
     if (didUpdateBackingStore) {
         // Create a new plug-in backing store.
index a11e0c6b0446b04c5afed81c8794de2c1de9d3f0..575e88b86c482137bbdfd5350d78c9f8ce588f1f 100644 (file)
@@ -93,12 +93,12 @@ static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image)
 void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard*, Frame* frame, bool linkDrag)
 {
     RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get());
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     if (!bitmap->createHandle(handle))
         return;
 
     // FIXME: Seems this message should be named StartDrag, not SetDragImage.
-    m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), bitmap->size(), handle, linkDrag));
+    m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), handle, linkDrag));
 }
 
 static CachedImage* cachedImage(Element* element)
index b4db406c9b11d3fed68b4206d9ee150f38059fc5..f791fd9eda0d316eb806716fa3e2f86dfb79ae8f 100644 (file)
@@ -78,9 +78,9 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl
     // The backing stores should be drawn at least as wide as the control on the page to match the width of the popup window we'll create.
     int backingStoreWidth = max(pageCoordinates.width() - m_popupClient->clientInsetLeft() - m_popupClient->clientInsetRight(), popupWidth);
 
-    data.m_backingStoreSize = IntSize(backingStoreWidth, (itemCount * data.m_itemHeight));
-    data.m_notSelectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize);
-    data.m_selectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize);
+    IntSize backingStoreSize(backingStoreWidth, (itemCount * data.m_itemHeight));
+    data.m_notSelectedBackingStore = ShareableBitmap::createShareable(backingStoreSize);
+    data.m_selectedBackingStore = ShareableBitmap::createShareable(backingStoreSize);
 
     OwnPtr<GraphicsContext> notSelectedBackingStoreContext = data.m_notSelectedBackingStore->createGraphicsContext();
     OwnPtr<GraphicsContext> selectedBackingStoreContext = data.m_selectedBackingStore->createGraphicsContext();
@@ -88,7 +88,7 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl
     Color activeOptionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor();
     Color activeOptionTextColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor();
 
-    for (int y = 0; y < data.m_backingStoreSize.height(); y += data.m_itemHeight) {
+    for (int y = 0; y < backingStoreSize.height(); y += data.m_itemHeight) {
         int index = y / data.m_itemHeight;
 
         PopupMenuStyle itemStyle = m_popupClient->itemStyle(index);
index aae8b25ad79ecd74647c7445b01906afeaa7022f..50cf6cbea231748b8284920a28d0c9686be0206c 100644 (file)
@@ -182,7 +182,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
     selectedFrame->view()->paint(graphicsContext.get(), paintRect);
     selectedFrame->view()->setPaintBehavior(PaintBehaviorNormal);
     
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     if (!findIndicatorTextBackingStore->createHandle(handle))
         return false;
 
@@ -207,7 +207,7 @@ void FindController::hideFindIndicator()
     if (!m_isShowingFindIndicator)
         return;
 
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), handle, false));
     m_isShowingFindIndicator = false;
 }