Skip to content

Instantly share code, notes, and snippets.

@annulen
Created April 1, 2016 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annulen/d6496b314c894c7c6cdf4f72801374d5 to your computer and use it in GitHub Desktop.
Save annulen/d6496b314c894c7c6cdf4f72801374d5 to your computer and use it in GitHub Desktop.
commit 2423ed5689c3ba8423d63548c5905e73e1133fa0
Author: Konstantin Tokarev <annulen@yandex.ru>
Date: Fri Apr 1 18:32:56 2016 +0300
Prevented destruction of QPixmap in ImageBuffer::sinkIntoImage().
ImageBuffer::sinkIntoImage() should transfer ownership of QPixmap
to new StillImage. Use move semantics to avoid uneeded reference
counting of QPixmap.
Change-Id: I2d0dc7bb643a95771a8a50eb03314a952765ecf0
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index 3ca6a25..c25ce49 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -129,8 +129,7 @@ RefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavio
RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, ScaleBehavior scaleBehavior)
{
- // FIXME?
- return imageBuffer->copyImage(DontCopyBackingStore, scaleBehavior);
+ return StillImage::createWithMove(WTFMove(imageBuffer->m_data.m_pixmap));
}
BackingStoreCopy ImageBuffer::fastCopyImageMode()
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
index 7843504..ccd882c 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -46,6 +46,11 @@ StillImage::StillImage(const QPixmap* pixmap)
, m_ownsPixmap(false)
{}
+StillImage::StillImage(QPixmap&& pixmap)
+ : m_pixmap(new QPixmap(pixmap))
+ , m_ownsPixmap(true)
+{ }
+
StillImage::~StillImage()
{
if (m_ownsPixmap)
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.h b/Source/WebCore/platform/graphics/qt/StillImageQt.h
index 5bff3f5..be84462 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.h
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.h
@@ -44,6 +44,11 @@ namespace WebCore {
return adoptRef(new StillImage(pixmap));
}
+ static PassRefPtr<StillImage> createWithMove(QPixmap&& pixmap)
+ {
+ return adoptRef(new StillImage(pixmap));
+ }
+
bool currentFrameKnownToBeOpaque() override;
// FIXME: StillImages are underreporting decoded sizes and will be unable
@@ -57,6 +62,7 @@ namespace WebCore {
private:
StillImage(const QPixmap&);
StillImage(const QPixmap*);
+ StillImage(QPixmap&&);
~StillImage() override;
const QPixmap* m_pixmap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment