Created
April 1, 2016 15:35
-
-
Save annulen/d6496b314c894c7c6cdf4f72801374d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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