2011-02-23 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Feb 2011 21:55:55 +0000 (21:55 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Feb 2011 21:55:55 +0000 (21:55 +0000)
        Reviewed by Sam Weinig.

        Add a ShareableBitmap::create overload that takes an existing SharedMemory object
        https://bugs.webkit.org/show_bug.cgi?id=55081

        * Shared/ShareableBitmap.cpp:
        (WebKit::ShareableBitmap::createShareable):
        (WebKit::ShareableBitmap::create):
        * Shared/ShareableBitmap.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/ShareableBitmap.cpp
Source/WebKit2/Shared/ShareableBitmap.h

index 843e3f0..48f55e3 100644 (file)
@@ -1,5 +1,17 @@
 2011-02-23  Anders Carlsson  <andersca@apple.com>
 
 2011-02-23  Anders Carlsson  <andersca@apple.com>
 
+        Reviewed by Sam Weinig.
+
+        Add a ShareableBitmap::create overload that takes an existing SharedMemory object
+        https://bugs.webkit.org/show_bug.cgi?id=55081
+
+        * Shared/ShareableBitmap.cpp:
+        (WebKit::ShareableBitmap::createShareable):
+        (WebKit::ShareableBitmap::create):
+        * Shared/ShareableBitmap.h:
+
+2011-02-23  Anders Carlsson  <andersca@apple.com>
+
         Reviewed by Dan Bernstein.
 
         Web Inspector toolbar looks bad in WebKit2
         Reviewed by Dan Bernstein.
 
         Web Inspector toolbar looks bad in WebKit2
index e89cdb7..ab1991f 100644 (file)
@@ -47,10 +47,20 @@ PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size
 PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size)
 {
     size_t numBytes = numBytesForSize(size);
 PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size)
 {
     size_t numBytes = numBytesForSize(size);
-    
+
     RefPtr<SharedMemory> sharedMemory = SharedMemory::create(numBytes);
     if (!sharedMemory)
         return 0;
     RefPtr<SharedMemory> sharedMemory = SharedMemory::create(numBytes);
     if (!sharedMemory)
         return 0;
+
+    return adoptRef(new ShareableBitmap(size, sharedMemory));
+}
+
+PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size, PassRefPtr<SharedMemory> sharedMemory)
+{
+    ASSERT(sharedMemory);
+
+    size_t numBytes = numBytesForSize(size);
+    ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes);
     
     return adoptRef(new ShareableBitmap(size, sharedMemory));
 }
     
     return adoptRef(new ShareableBitmap(size, sharedMemory));
 }
@@ -62,10 +72,7 @@ PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size
     if (!sharedMemory)
         return 0;
 
     if (!sharedMemory)
         return 0;
 
-    size_t numBytes = numBytesForSize(size);
-    ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes);
-
-    return adoptRef(new ShareableBitmap(size, sharedMemory));
+    return create(size, sharedMemory.release());
 }
 
 bool ShareableBitmap::createHandle(SharedMemory::Handle& handle)
 }
 
 bool ShareableBitmap::createHandle(SharedMemory::Handle& handle)
index e44f4ad..6eca156 100644 (file)
@@ -47,6 +47,9 @@ public:
     // Create a shareable bitmap whose backing memory can be shared with another process.
     static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&);
 
     // Create a shareable bitmap whose backing memory can be shared with another process.
     static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&);
 
+    // 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 shared memory handle.
     static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, const SharedMemory::Handle&);