From f156e578d7f4b05f44a6e84b2173f1e69b856442 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 7 Dec 2012 22:15:49 -0600 Subject: Ensure raster pixmap cache key is the same as that of pixmap.toImage() This is done to support texture uploads in an image provider. It ensures we can load the texture using QImage in the image provider, and when it is later painted as a pixmap, the cacheKey will be identical (assuming no format conversion was required). Change-Id: I54229511ed91ce5430cc478af5aff0d96685a2da Reviewed-by: Gunnar Sletta --- src/gui/image/qpixmap_raster.cpp | 2 ++ src/gui/image/qplatformpixmap.cpp | 5 +++++ src/gui/image/qplatformpixmap.h | 1 + 3 files changed, 8 insertions(+) (limited to 'src/gui') diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 5c188f0362..30463f3c0d 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -353,7 +353,9 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC is_null = (w <= 0 || h <= 0); image.d->devicePixelRatio = sourceImage.devicePixelRatio(); + //ensure the pixmap and the image resulting from toImage() have the same cacheKey(); setSerialNumber(image.cacheKey() >> 32); + setDetachNumber(image.d->detach_no); } QImage* QRasterPlatformPixmap::buffer() diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp index 2e12ae2e91..1d147e3d3c 100644 --- a/src/gui/image/qplatformpixmap.cpp +++ b/src/gui/image/qplatformpixmap.cpp @@ -173,6 +173,11 @@ void QPlatformPixmap::setSerialNumber(int serNo) ser_no = serNo; } +void QPlatformPixmap::setDetachNumber(int detNo) +{ + detach_no = detNo; +} + QImage QPlatformPixmap::toImage(const QRect &rect) const { if (rect.contains(QRect(0, 0, w, h))) diff --git a/src/gui/image/qplatformpixmap.h b/src/gui/image/qplatformpixmap.h index af3abecaf8..d54f31099e 100644 --- a/src/gui/image/qplatformpixmap.h +++ b/src/gui/image/qplatformpixmap.h @@ -132,6 +132,7 @@ public: protected: void setSerialNumber(int serNo); + void setDetachNumber(int detNo); int w; int h; int d; -- cgit v1.2.3