Title: [107571] trunk/Source/WebKit2
Revision
107571
Author
[email protected]
Date
2012-02-13 07:05:17 -0800 (Mon, 13 Feb 2012)

Log Message

Manage ShareableBitmap object lifecycle properly, when QImage is created
using the shared data.
https://bugs.webkit.org/show_bug.cgi?id=77546

Patch by Zalan Bujtas <[email protected]> on 2012-02-13
Reviewed by Simon Hausmann.

* Shared/ShareableBitmap.h:
(ShareableBitmap):
* Shared/qt/ShareableBitmapQt.cpp:
(WebKit::ShareableBitmap::createQImage):
(WebKit):
(WebKit::ShareableBitmap::releaseSharedMemoryData):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (107570 => 107571)


--- trunk/Source/WebKit2/ChangeLog	2012-02-13 15:02:44 UTC (rev 107570)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-13 15:05:17 UTC (rev 107571)
@@ -1,3 +1,18 @@
+2012-02-13  Zalan Bujtas  <[email protected]>
+
+        Manage ShareableBitmap object lifecycle properly, when QImage is created
+        using the shared data.
+        https://bugs.webkit.org/show_bug.cgi?id=77546
+
+        Reviewed by Simon Hausmann.
+
+        * Shared/ShareableBitmap.h:
+        (ShareableBitmap):
+        * Shared/qt/ShareableBitmapQt.cpp:
+        (WebKit::ShareableBitmap::createQImage):
+        (WebKit):
+        (WebKit::ShareableBitmap::releaseSharedMemoryData):
+
 2012-02-06  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] Drop support for the Curl network backend.

Modified: trunk/Source/WebKit2/Shared/ShareableBitmap.h (107570 => 107571)


--- trunk/Source/WebKit2/Shared/ShareableBitmap.h	2012-02-13 15:02:44 UTC (rev 107570)
+++ trunk/Source/WebKit2/Shared/ShareableBitmap.h	2012-02-13 15:05:17 UTC (rev 107571)
@@ -135,6 +135,7 @@
     // This creates a QImage that directly references the shared bitmap data.
     // This is only safe to use when we know that the contents of the shareable bitmap won't change.
     QImage createQImage();
+    static void releaseSharedMemoryData(void* typelessBitmap);
     void swizzleRGB();
 #endif
 

Modified: trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp (107570 => 107571)


--- trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp	2012-02-13 15:02:44 UTC (rev 107570)
+++ trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp	2012-02-13 15:05:17 UTC (rev 107571)
@@ -38,10 +38,17 @@
 
 QImage ShareableBitmap::createQImage()
 {
+    ref(); // Balanced by deref in releaseSharedMemoryData
     return QImage(reinterpret_cast<uchar*>(data()), m_size.width(), m_size.height(), m_size.width() * 4,
-                  m_flags & SupportsAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
+                  m_flags & SupportsAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32,
+                  releaseSharedMemoryData, this);
 }
 
+void ShareableBitmap::releaseSharedMemoryData(void* typelessBitmap)
+{
+    static_cast<ShareableBitmap*>(typelessBitmap)->deref(); // Balanced by ref in createQImage.
+}
+
 PassRefPtr<Image> ShareableBitmap::createImage()
 {
     QPixmap* pixmap = new QPixmap(QPixmap::fromImage(createQImage()));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to