summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap.cpp40
-rw-r--r--src/gui/image/qpixmap.h2
-rw-r--r--src/gui/image/qpixmapcache_p.h5
-rw-r--r--src/gui/image/qpixmapdata_p.h5
4 files changed, 34 insertions, 18 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 474cd2e..21216f8 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -635,17 +635,21 @@ void QPixmap::resize_helper(const QSize &s)
if (size() == s)
return;
+ // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
+ // the actual underlaying runtime pixmap data.
+ QPixmapData *pd = pixmapData();
+
// Create new pixmap
- QPixmap pm(QSize(w, h), data ? data->type : QPixmapData::PixmapType);
+ QPixmap pm(QSize(w, h), pd ? pd->type : QPixmapData::PixmapType);
bool uninit = false;
#if defined(Q_WS_X11)
- QX11PixmapData *x11Data = data && data->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(data.data()) : 0;
+ QX11PixmapData *x11Data = pd && pd->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(pd) : 0;
if (x11Data) {
pm.x11SetScreen(x11Data->xinfo.screen());
uninit = x11Data->flags & QX11PixmapData::Uninitialized;
}
#elif defined(Q_WS_MAC)
- QMacPixmapData *macData = data && data->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data.data()) : 0;
+ QMacPixmapData *macData = pd && pd->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
if (macData)
uninit = macData->uninit;
#endif
@@ -659,7 +663,7 @@ void QPixmap::resize_helper(const QSize &s)
#if defined(Q_WS_X11)
if (x11Data && x11Data->x11_mask) {
- QX11PixmapData *pmData = static_cast<QX11PixmapData*>(pm.data.data());
+ QX11PixmapData *pmData = static_cast<QX11PixmapData*>(pd);
pmData->x11_mask = (Qt::HANDLE)XCreatePixmap(X11->display,
RootWindow(x11Data->xinfo.display(),
x11Data->xinfo.screen()),
@@ -1163,8 +1167,9 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
Qt::HANDLE QPixmap::handle() const
{
#if defined(Q_WS_X11)
- if (data && data->classId() == QPixmapData::X11Class)
- return static_cast<const QX11PixmapData*>(data.constData())->handle();
+ const QPixmapData *pd = pixmapData();
+ if (pd && pd->classId() == QPixmapData::X11Class)
+ return static_cast<const QX11PixmapData*>(pd)->handle();
#endif
return 0;
}
@@ -1944,17 +1949,20 @@ void QPixmap::detach()
if (!data)
return;
- QPixmapData::ClassId id = data->classId();
+ // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
+ // the actual underlaying runtime pixmap data.
+ QPixmapData *pd = pixmapData();
+ QPixmapData::ClassId id = pd->classId();
if (id == QPixmapData::RasterClass) {
- QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data.data());
+ QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(pd);
rasterData->image.detach();
}
if (data->is_cached && data->ref == 1)
- QImagePixmapCleanupHooks::executePixmapDataModificationHooks(data.data());
+ QImagePixmapCleanupHooks::executePixmapDataModificationHooks(pd);
#if defined(Q_WS_MAC)
- QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data.data()) : 0;
+ QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
if (macData) {
if (macData->cg_mask) {
CGImageRelease(macData->cg_mask);
@@ -1969,8 +1977,8 @@ void QPixmap::detach()
++data->detach_no;
#if defined(Q_WS_X11)
- if (data->classId() == QPixmapData::X11Class) {
- QX11PixmapData *d = static_cast<QX11PixmapData*>(data.data());
+ if (pd->classId() == QPixmapData::X11Class) {
+ QX11PixmapData *d = static_cast<QX11PixmapData*>(pd);
d->flags &= ~QX11PixmapData::Uninitialized;
// reset the cache data
@@ -2060,9 +2068,15 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
*/
QPixmapData* QPixmap::pixmapData() const
{
- return data.data();
+ if (data) {
+ QPixmapData* pm = data.data();
+ return pm->runtimeData() ? pm->runtimeData() : pm;
+ }
+
+ return 0;
}
+
/*!
\enum QPixmap::HBitmapFormat
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index 180af3b..82546da 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -271,9 +271,7 @@ private:
friend class QX11PaintEngine;
friend class QCoreGraphicsPaintEngine;
friend class QWidgetPrivate;
- friend class QRasterPaintEngine;
friend class QRasterBuffer;
- friend class QPixmapCacheEntry;
#if !defined(QT_NO_DATASTREAM)
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &);
#endif
diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h
index 825f272..6db3b20 100644
--- a/src/gui/image/qpixmapcache_p.h
+++ b/src/gui/image/qpixmapcache_p.h
@@ -81,8 +81,9 @@ class QPixmapCacheEntry : public QPixmap
public:
QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key)
{
- if (data && data->classId() == QPixmapData::RasterClass) {
- QRasterPixmapData *d = static_cast<QRasterPixmapData*>(data.data());
+ QPixmapData *pd = pixmapData();
+ if (pd && pd->classId() == QPixmapData::RasterClass) {
+ QRasterPixmapData *d = static_cast<QRasterPixmapData*>(pd);
if (!d->image.isNull() && d->image.d->paintEngine
&& !d->image.d->paintEngine->isActive())
{
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index 827fa18..60ed26a 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -73,7 +73,7 @@ public:
};
#endif
enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass,
- OpenGLClass, OpenVGClass, CustomClass = 1024 };
+ OpenGLClass, OpenVGClass, RuntimeClass, CustomClass = 1024 };
QPixmapData(PixelType pixelType, int classId);
virtual ~QPixmapData();
@@ -133,7 +133,10 @@ public:
static QPixmapData *create(int w, int h, PixelType type);
+ virtual QPixmapData *runtimeData() const { return 0; }
+
protected:
+
void setSerialNumber(int serNo);
int w;
int h;