diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 8 | ||||
-rw-r--r-- | src/gui/image/qpixmap_mac.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qpixmap_mac_p.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster_p.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11_p.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmapdata.cpp | 13 | ||||
-rw-r--r-- | src/gui/image/qpixmapdata_p.h | 4 |
9 files changed, 38 insertions, 8 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 5c8a1f9..c03a364 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -361,13 +361,7 @@ QPixmap QPixmap::copy(const QRect &rect) const const QRect r = rect.isEmpty() ? QRect(0, 0, width(), height()) : rect; - QPixmapData *d; - QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); - if (gs) - d = gs->createPixmapData(data->pixelType()); - else - d = QGraphicsSystem::createDefaultPixmapData(data->pixelType()); - + QPixmapData *d = data->createCompatiblePixmapData(); d->copy(data.data(), r); return QPixmap(d); } diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index de532fd..afa6f83 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -166,6 +166,11 @@ QMacPixmapData::QMacPixmapData(PixelType type) { } +QPixmapData *QMacPixmapData::createCompatiblePixmapData() const +{ + return new QMacPixmapData(pixelType()); +} + #define BEST_BYTE_ALIGNMENT 16 #define COMPTUE_BEST_BYTES_PER_ROW(bpr) \ (((bpr) + (BEST_BYTE_ALIGNMENT - 1)) & ~(BEST_BYTE_ALIGNMENT - 1)) diff --git a/src/gui/image/qpixmap_mac_p.h b/src/gui/image/qpixmap_mac_p.h index 528dd1f..a3fb95f 100644 --- a/src/gui/image/qpixmap_mac_p.h +++ b/src/gui/image/qpixmap_mac_p.h @@ -65,6 +65,8 @@ public: QMacPixmapData(PixelType type); ~QMacPixmapData(); + QPixmapData *createCompatiblePixmapData() const; + void resize(int width, int height); void fromImage(const QImage &image, Qt::ImageConversionFlags flags); void copy(const QPixmapData *data, const QRect &rect); diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index ad68b07..3667e5b 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -64,6 +64,11 @@ QRasterPixmapData::~QRasterPixmapData() { } +QPixmapData *QRasterPixmapData::createCompatiblePixmapData() const +{ + return new QRasterPixmapData(pixelType()); +} + void QRasterPixmapData::resize(int width, int height) { QImage::Format format; diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index da0405e..1553940 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -68,6 +68,8 @@ public: QRasterPixmapData(PixelType type); ~QRasterPixmapData(); + QPixmapData *createCompatiblePixmapData() const; + void resize(int width, int height); void fromFile(const QString &filename, Qt::ImageConversionFlags flags); void fromImage(const QImage &image, Qt::ImageConversionFlags flags); diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 74543a0..ea9eff9 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -319,6 +319,11 @@ QX11PixmapData::QX11PixmapData(PixelType type) { } +QPixmapData *QX11PixmapData::createCompatiblePixmapData() const +{ + return new QX11PixmapData(pixelType()); +} + void QX11PixmapData::resize(int width, int height) { setSerialNumber(++qt_pixmap_serial); diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h index e34e690..2d6672d 100644 --- a/src/gui/image/qpixmap_x11_p.h +++ b/src/gui/image/qpixmap_x11_p.h @@ -71,6 +71,8 @@ public: // Qt::ImageConversionFlags flags); ~QX11PixmapData(); + QPixmapData *createCompatiblePixmapData() const; + void resize(int width, int height); void fromImage(const QImage &image, Qt::ImageConversionFlags flags); void copy(const QPixmapData *data, const QRect &rect); diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 93fc2eb..1ad1f02 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -43,6 +43,8 @@ #include <QtCore/qbuffer.h> #include <QtGui/qbitmap.h> #include <QtGui/qimagereader.h> +#include <private/qgraphicssystem_p.h> +#include <private/qapplication_p.h> QT_BEGIN_NAMESPACE @@ -67,6 +69,17 @@ QPixmapData::~QPixmapData() { } +QPixmapData *QPixmapData::createCompatiblePixmapData() const +{ + QPixmapData *d; + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (gs) + d = gs->createPixmapData(pixelType()); + else + d = QGraphicsSystem::createDefaultPixmapData(pixelType()); + return d; +} + static QImage makeBitmapCompliantIfNeeded(QPixmapData *d, const QImage &image, Qt::ImageConversionFlags flags) { if (d->pixelType() == QPixmapData::BitmapType) { diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index c26fba3..2f4f201 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -75,9 +75,11 @@ public: enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass, OpenGLClass, OpenVGClass, CustomClass = 1024 }; - QPixmapData(PixelType pixelpType, int classId); + QPixmapData(PixelType pixelType, int classId); virtual ~QPixmapData(); + virtual QPixmapData *createCompatiblePixmapData() const; + virtual void resize(int width, int height) = 0; virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags) = 0; |