From 310519d6d11da546b23c1cba307f37c24e0a5c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 15 Jul 2011 14:07:12 +0200 Subject: Rename QPixmapData to QPlatformPixmap. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes the API symmetric with the other Lighthouse APIs. Change-Id: I8a399f3c968ea35d4624711b31f2ac5bb94b7893 Reviewed-on: http://codereview.qt.nokia.com/1735 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/gui/image/image.pri | 6 +- src/gui/image/qbitmap.cpp | 12 +- src/gui/image/qbitmap.h | 2 +- src/gui/image/qimage.cpp | 2 +- src/gui/image/qimage.h | 4 +- src/gui/image/qimagepixmapcleanuphooks.cpp | 18 +-- src/gui/image/qimagepixmapcleanuphooks_p.h | 16 +-- src/gui/image/qpixmap.cpp | 60 ++++----- src/gui/image/qpixmap.h | 12 +- src/gui/image/qpixmap_blitter.cpp | 44 +++---- src/gui/image/qpixmap_blitter_p.h | 22 ++-- src/gui/image/qpixmap_raster.cpp | 50 ++++---- src/gui/image/qpixmap_raster_p.h | 13 +- src/gui/image/qpixmapcache_p.h | 6 +- src/gui/image/qpixmapdata.cpp | 189 ----------------------------- src/gui/image/qpixmapdata_p.h | 160 ------------------------ src/gui/image/qpixmapdatafactory.cpp | 100 --------------- src/gui/image/qpixmapdatafactory_p.h | 81 ------------- src/gui/image/qplatformpixmap.cpp | 189 +++++++++++++++++++++++++++++ src/gui/image/qplatformpixmap_qpa.h | 160 ++++++++++++++++++++++++ src/gui/image/qvolatileimage.cpp | 8 +- 21 files changed, 485 insertions(+), 669 deletions(-) delete mode 100644 src/gui/image/qpixmapdata.cpp delete mode 100644 src/gui/image/qpixmapdata_p.h delete mode 100644 src/gui/image/qpixmapdatafactory.cpp delete mode 100644 src/gui/image/qpixmapdatafactory_p.h create mode 100644 src/gui/image/qplatformpixmap.cpp create mode 100644 src/gui/image/qplatformpixmap_qpa.h (limited to 'src/gui/image') diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 27aac41ebe..a2bf90ce39 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -21,8 +21,7 @@ HEADERS += \ image/qpixmap_blitter_p.h \ image/qpixmapcache.h \ image/qpixmapcache_p.h \ - image/qpixmapdata_p.h \ - image/qpixmapdatafactory_p.h \ + image/qplatformpixmap_qpa.h \ image/qimagepixmapcleanuphooks_p.h \ image/qvolatileimage_p.h \ image/qvolatileimagedata_p.h \ @@ -39,8 +38,7 @@ SOURCES += \ image/qpictureformatplugin.cpp \ image/qpixmap.cpp \ image/qpixmapcache.cpp \ - image/qpixmapdata.cpp \ - image/qpixmapdatafactory.cpp \ + image/qplatformpixmap.cpp \ image/qmovie.cpp \ image/qpixmap_raster.cpp \ image/qpixmap_blitter.cpp \ diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp index 59b8bb037e..c614ba1b0a 100644 --- a/src/gui/image/qbitmap.cpp +++ b/src/gui/image/qbitmap.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qbitmap.h" -#include "qpixmapdata_p.h" +#include "qplatformpixmap_qpa.h" #include "qimage.h" #include "qvariant.h" #include @@ -101,7 +101,7 @@ QT_BEGIN_NAMESPACE \sa QPixmap::isNull() */ QBitmap::QBitmap() - : QPixmap(QSize(0, 0), QPixmapData::BitmapType) + : QPixmap(QSize(0, 0), QPlatformPixmap::BitmapType) { } @@ -115,7 +115,7 @@ QBitmap::QBitmap() */ QBitmap::QBitmap(int w, int h) - : QPixmap(QSize(w, h), QPixmapData::BitmapType) + : QPixmap(QSize(w, h), QPlatformPixmap::BitmapType) { } @@ -127,7 +127,7 @@ QBitmap::QBitmap(int w, int h) */ QBitmap::QBitmap(const QSize &size) - : QPixmap(size, QPixmapData::BitmapType) + : QPixmap(size, QPlatformPixmap::BitmapType) { } @@ -172,7 +172,7 @@ QBitmap::QBitmap(const QPixmap &pixmap) */ QBitmap::QBitmap(const QString& fileName, const char *format) - : QPixmap(QSize(0, 0), QPixmapData::BitmapType) + : QPixmap(QSize(0, 0), QPlatformPixmap::BitmapType) { load(fileName, format, Qt::MonoOnly); } @@ -260,7 +260,7 @@ QBitmap QBitmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) img.setColor(1, c0); } - QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::BitmapType)); + QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::BitmapType)); data->fromImage(img, flags | Qt::MonoOnly); return QPixmap(data.take()); diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h index f58e6b5c46..a3104f5083 100644 --- a/src/gui/image/qbitmap.h +++ b/src/gui/image/qbitmap.h @@ -75,7 +75,7 @@ public: QBitmap transformed(const QMatrix &) const; QBitmap transformed(const QTransform &matrix) const; - typedef QExplicitlySharedDataPointer DataPtr; + typedef QExplicitlySharedDataPointer DataPtr; }; Q_DECLARE_SHARED(QBitmap) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 3e251ba705..2dbb2f4b52 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -54,9 +54,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index c5168faaa3..7e8a0a28e8 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -288,8 +288,8 @@ private: friend class QWSOnScreenSurface; QImageData *d; - friend class QRasterPixmapData; - friend class QBlittablePixmapData; + friend class QRasterPlatformPixmap; + friend class QBlittablePlatformPixmap; friend class QPixmapCacheEntry; friend Q_GUI_EXPORT qint64 qt_image_id(const QImage &image); friend const QVector *qt_image_colortable(const QImage &image); diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index aa1bf8059e..7901045593 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qimagepixmapcleanuphooks_p.h" -#include "private/qpixmapdata_p.h" +#include "qplatformpixmap_qpa.h" #include "private/qimage_p.h" @@ -62,12 +62,12 @@ QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() return qt_image_and_pixmap_cleanup_hooks(); } -void QImagePixmapCleanupHooks::addPixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd hook) +void QImagePixmapCleanupHooks::addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd hook) { pixmapModificationHooks.append(hook); } -void QImagePixmapCleanupHooks::addPixmapDataDestructionHook(_qt_pixmap_cleanup_hook_pmd hook) +void QImagePixmapCleanupHooks::addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd hook) { pixmapDestructionHooks.append(hook); } @@ -78,12 +78,12 @@ void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook) imageHooks.append(hook); } -void QImagePixmapCleanupHooks::removePixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd hook) +void QImagePixmapCleanupHooks::removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd hook) { pixmapModificationHooks.removeAll(hook); } -void QImagePixmapCleanupHooks::removePixmapDataDestructionHook(_qt_pixmap_cleanup_hook_pmd hook) +void QImagePixmapCleanupHooks::removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd hook) { pixmapDestructionHooks.removeAll(hook); } @@ -93,7 +93,7 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) imageHooks.removeAll(hook); } -void QImagePixmapCleanupHooks::executePixmapDataModificationHooks(QPixmapData* pmd) +void QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(QPlatformPixmap* pmd) { QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); // the global destructor for the pixmap and image hooks might have @@ -108,7 +108,7 @@ void QImagePixmapCleanupHooks::executePixmapDataModificationHooks(QPixmapData* p qt_pixmap_cleanup_hook_64(pmd->cacheKey()); } -void QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(QPixmapData* pmd) +void QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(QPlatformPixmap* pmd) { QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); // the global destructor for the pixmap and image hooks might have @@ -133,9 +133,9 @@ void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) } -void QImagePixmapCleanupHooks::enableCleanupHooks(QPixmapData *pixmapData) +void QImagePixmapCleanupHooks::enableCleanupHooks(QPlatformPixmap *handle) { - pixmapData->is_cached = true; + handle->is_cached = true; } void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap) diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index fe49ea0c5e..c98da6110a 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE typedef void (*_qt_image_cleanup_hook_64)(qint64); -typedef void (*_qt_pixmap_cleanup_hook_pmd)(QPixmapData*); +typedef void (*_qt_pixmap_cleanup_hook_pmd)(QPlatformPixmap*); class QImagePixmapCleanupHooks; @@ -70,26 +70,26 @@ public: static void enableCleanupHooks(const QImage &image); static void enableCleanupHooks(const QPixmap &pixmap); - static void enableCleanupHooks(QPixmapData *pixmapData); + static void enableCleanupHooks(QPlatformPixmap *handle); static bool isImageCached(const QImage &image); static bool isPixmapCached(const QPixmap &pixmap); // Gets called when a pixmap data is about to be modified: - void addPixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd); + void addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd); // Gets called when a pixmap data is about to be destroyed: - void addPixmapDataDestructionHook(_qt_pixmap_cleanup_hook_pmd); + void addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd); // Gets called when an image is about to be modified or destroyed: void addImageHook(_qt_image_cleanup_hook_64); - void removePixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd); - void removePixmapDataDestructionHook(_qt_pixmap_cleanup_hook_pmd); + void removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd); + void removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd); void removeImageHook(_qt_image_cleanup_hook_64); - static void executePixmapDataModificationHooks(QPixmapData*); - static void executePixmapDataDestructionHooks(QPixmapData*); + static void executePlatformPixmapModificationHooks(QPlatformPixmap*); + static void executePlatformPixmapDestructionHooks(QPlatformPixmap*); static void executeImageHooks(qint64 key); private: diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 97577241ee..af27baea0e 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -42,7 +42,7 @@ #include #include "qpixmap.h" -#include "qpixmapdata_p.h" +#include "qplatformpixmap_qpa.h" #include "qimagepixmapcleanuphooks_p.h" #include "qbitmap.h" @@ -95,8 +95,8 @@ static bool qt_pixmap_thread_test() void QPixmap::init(int w, int h, int type) { - if ((w > 0 && h > 0) || type == QPixmapData::BitmapType) - data = QPixmapData::create(w, h, (QPixmapData::PixelType) type); + if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType) + data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type); else data = 0; } @@ -127,7 +127,7 @@ QPixmap::QPixmap() : QPaintDevice() { (void) qt_pixmap_thread_test(); - init(0, 0, QPixmapData::PixmapType); + init(0, 0, QPlatformPixmap::PixmapType); } /*! @@ -148,9 +148,9 @@ QPixmap::QPixmap(int w, int h) : QPaintDevice() { if (!qt_pixmap_thread_test()) - init(0, 0, QPixmapData::PixmapType); + init(0, 0, QPlatformPixmap::PixmapType); else - init(w, h, QPixmapData::PixmapType); + init(w, h, QPlatformPixmap::PixmapType); } /*! @@ -167,9 +167,9 @@ QPixmap::QPixmap(const QSize &size) : QPaintDevice() { if (!qt_pixmap_thread_test()) - init(0, 0, QPixmapData::PixmapType); + init(0, 0, QPlatformPixmap::PixmapType); else - init(size.width(), size.height(), QPixmapData::PixmapType); + init(size.width(), size.height(), QPlatformPixmap::PixmapType); } /*! @@ -178,15 +178,15 @@ QPixmap::QPixmap(const QSize &size) QPixmap::QPixmap(const QSize &s, int type) { if (!qt_pixmap_thread_test()) - init(0, 0, static_cast(type)); + init(0, 0, static_cast(type)); else - init(s.width(), s.height(), static_cast(type)); + init(s.width(), s.height(), static_cast(type)); } /*! \internal */ -QPixmap::QPixmap(QPixmapData *d) +QPixmap::QPixmap(QPlatformPixmap *d) : QPaintDevice(), data(d) { } @@ -223,7 +223,7 @@ QPixmap::QPixmap(QPixmapData *d) QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversionFlags flags) : QPaintDevice() { - init(0, 0, QPixmapData::PixmapType); + init(0, 0, QPlatformPixmap::PixmapType); if (!qt_pixmap_thread_test()) return; @@ -240,7 +240,7 @@ QPixmap::QPixmap(const QPixmap &pixmap) : QPaintDevice() { if (!qt_pixmap_thread_test()) { - init(0, 0, QPixmapData::PixmapType); + init(0, 0, QPlatformPixmap::PixmapType); return; } if (pixmap.paintingActive()) { // make a deep copy @@ -269,13 +269,13 @@ QPixmap::QPixmap(const QPixmap &pixmap) QPixmap::QPixmap(const char * const xpm[]) : QPaintDevice() { - init(0, 0, QPixmapData::PixmapType); + init(0, 0, QPlatformPixmap::PixmapType); if (!xpm) return; QImage image(xpm); if (!image.isNull()) { - if (data && data->pixelType() == QPixmapData::BitmapType) + if (data && data->pixelType() == QPlatformPixmap::BitmapType) *this = QBitmap::fromImage(image); else *this = fromImage(image); @@ -330,7 +330,7 @@ QPixmap QPixmap::copy(const QRect &rect) const if (!rect.isEmpty()) r = r.intersected(rect); - QPixmapData *d = data->createCompatiblePixmapData(); + QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); d->copy(data.data(), r); return QPixmap(d); } @@ -507,7 +507,7 @@ QMatrix QPixmap::trueMatrix(const QMatrix &m, int w, int h) bool QPixmap::isQBitmap() const { - return data->type == QPixmapData::BitmapType; + return data->type == QPlatformPixmap::BitmapType; } /*! @@ -782,7 +782,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers % info.absoluteFilePath() % HexString(info.lastModified().toTime_t()) % HexString(info.size()) - % HexString(data ? data->pixelType() : QPixmapData::PixmapType); + % HexString(data ? data->pixelType() : QPlatformPixmap::PixmapType); // Note: If no extension is provided, we try to match the // file against known plugin extensions @@ -792,7 +792,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers if (QPixmapCache::find(key, *this)) return true; - QScopedPointer tmp(QPixmapData::create(0, 0, data ? data->type : QPixmapData::PixmapType)); + QScopedPointer tmp(QPlatformPixmap::create(0, 0, data ? data->type : QPlatformPixmap::PixmapType)); if (tmp->fromFile(fileName, format, flags)) { data = tmp.take(); QPixmapCache::insert(key, *this); @@ -827,7 +827,7 @@ bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::I return false; if (!data) - data = QPixmapData::create(0, 0, QPixmapData::PixmapType); + data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); return data->fromData(buf, len, format, flags); } @@ -941,7 +941,7 @@ void QPixmap::fill(const QColor &color) } else { // Don't bother to make a copy of the data object, since // it will be filled with new pixel data anyway. - QPixmapData *d = data->createCompatiblePixmapData(); + QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); d->resize(data->width(), data->height()); data = d; } @@ -1704,17 +1704,17 @@ void QPixmap::detach() if (!data) return; - // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get + // QPixmap.data member may be QRuntimePlatformPixmap so use handle() 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(pd); + QPlatformPixmap *pd = handle(); + QPlatformPixmap::ClassId id = pd->classId(); + if (id == QPlatformPixmap::RasterClass) { + QRasterPlatformPixmap *rasterData = static_cast(pd); rasterData->image.detach(); } if (data->is_cached && data->ref == 1) - QImagePixmapCleanupHooks::executePixmapDataModificationHooks(data.data()); + QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data()); if (data->ref != 1) { *this = copy(); @@ -1742,7 +1742,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) if (image.isNull()) return QPixmap(); - QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::PixmapType)); + QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImage(image, flags); return QPixmap(data.take()); } @@ -1761,7 +1761,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) */ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) { - QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::PixmapType)); + QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImageReader(imageReader, flags); return QPixmap(data.take()); } @@ -1810,7 +1810,7 @@ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionF /*! \internal */ -QPixmapData* QPixmap::pixmapData() const +QPlatformPixmap* QPixmap::handle() const { return data.data(); } diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 084e5d5d33..642556e71b 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -61,13 +61,13 @@ class QImageReader; class QColor; class QVariant; class QX11Info; -class QPixmapData; +class QPlatformPixmap; class Q_GUI_EXPORT QPixmap : public QPaintDevice { public: QPixmap(); - explicit QPixmap(QPixmapData *data); + explicit QPixmap(QPlatformPixmap *data); QPixmap(int w, int h); QPixmap(const QSize &); QPixmap(const QString& fileName, const char *format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); @@ -168,7 +168,7 @@ protected: int metric(PaintDeviceMetric) const; private: - QExplicitlySharedDataPointer data; + QExplicitlySharedDataPointer data; bool doImageIO(QImageWriter *io, int quality) const; @@ -176,7 +176,7 @@ private: void init(int, int, int); void deref(); Q_DUMMY_COMPARISON_OPERATOR(QPixmap) - friend class QPixmapData; + friend class QPlatformPixmap; friend class QBitmap; friend class QPaintDevice; friend class QPainter; @@ -188,10 +188,10 @@ private: #endif public: - QPixmapData* pixmapData() const; + QPlatformPixmap* handle() const; public: - typedef QExplicitlySharedDataPointer DataPtr; + typedef QExplicitlySharedDataPointer DataPtr; inline DataPtr &data_ptr() { return data; } }; diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 465bc40e4c..43876419d4 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -55,8 +55,8 @@ QT_BEGIN_NAMESPACE static int global_ser_no = 0; -QBlittablePixmapData::QBlittablePixmapData() - : QPixmapData(QPixmapData::PixmapType,BlitterClass), m_engine(0), m_blittable(0) +QBlittablePlatformPixmap::QBlittablePlatformPixmap() + : QPlatformPixmap(QPlatformPixmap::PixmapType,BlitterClass), m_engine(0), m_blittable(0) #ifdef QT_BLITTER_RASTEROVERLAY ,m_rasterOverlay(0), m_unmergedCopy(0) #endif //QT_BLITTER_RASTEROVERLAY @@ -64,7 +64,7 @@ QBlittablePixmapData::QBlittablePixmapData() setSerialNumber(++global_ser_no); } -QBlittablePixmapData::~QBlittablePixmapData() +QBlittablePlatformPixmap::~QBlittablePlatformPixmap() { delete m_blittable; delete m_engine; @@ -74,23 +74,23 @@ QBlittablePixmapData::~QBlittablePixmapData() #endif //QT_BLITTER_RASTEROVERLAY } -QBlittable *QBlittablePixmapData::blittable() const +QBlittable *QBlittablePlatformPixmap::blittable() const { if (!m_blittable) { - QBlittablePixmapData *that = const_cast(this); + QBlittablePlatformPixmap *that = const_cast(this); that->m_blittable = this->createBlittable(QSize(w,h)); } return m_blittable; } -void QBlittablePixmapData::setBlittable(QBlittable *blittable) +void QBlittablePlatformPixmap::setBlittable(QBlittable *blittable) { resize(blittable->size().width(),blittable->size().height()); m_blittable = blittable; } -void QBlittablePixmapData::resize(int width, int height) +void QBlittablePlatformPixmap::resize(int width, int height) { delete m_blittable; @@ -105,7 +105,7 @@ void QBlittablePixmapData::resize(int width, int height) is_null = (w <= 0 || h <= 0); } -int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const +int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const { switch (metric) { case QPaintDevice::PdmWidth: @@ -125,14 +125,14 @@ int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmPhysicalDpiY: return qt_defaultDpiY(); default: - qWarning("QRasterPixmapData::metric(): Unhandled metric type %d", metric); + qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; } return 0; } -void QBlittablePixmapData::fill(const QColor &color) +void QBlittablePlatformPixmap::fill(const QColor &color) { //jlind: todo: change when blittables can support non opaque fillRects if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) { @@ -166,22 +166,22 @@ void QBlittablePixmapData::fill(const QColor &color) } -QImage *QBlittablePixmapData::buffer() +QImage *QBlittablePlatformPixmap::buffer() { return blittable()->lock(); } -QImage QBlittablePixmapData::toImage() const +QImage QBlittablePlatformPixmap::toImage() const { return blittable()->lock()->copy(); } -bool QBlittablePixmapData::hasAlphaChannel() const +bool QBlittablePlatformPixmap::hasAlphaChannel() const { return blittable()->lock()->hasAlphaChannel(); } -void QBlittablePixmapData::fromImage(const QImage &image, +void QBlittablePlatformPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) { resize(image.width(),image.height()); @@ -203,10 +203,10 @@ void QBlittablePixmapData::fromImage(const QImage &image, } } -QPaintEngine *QBlittablePixmapData::paintEngine() const +QPaintEngine *QBlittablePlatformPixmap::paintEngine() const { if (!m_engine) { - QBlittablePixmapData *that = const_cast(this); + QBlittablePlatformPixmap *that = const_cast(this); that->m_engine = new QBlitterPaintEngine(that); } return m_engine; @@ -216,7 +216,7 @@ QPaintEngine *QBlittablePixmapData::paintEngine() const static bool showRasterOverlay = !qgetenv("QT_BLITTER_RASTEROVERLAY").isEmpty(); -void QBlittablePixmapData::mergeOverlay() +void QBlittablePlatformPixmap::mergeOverlay() { if (m_unmergedCopy || !showRasterOverlay) return; @@ -227,7 +227,7 @@ void QBlittablePixmapData::mergeOverlay() p.end(); } -void QBlittablePixmapData::unmergeOverlay() +void QBlittablePlatformPixmap::unmergeOverlay() { if (!m_unmergedCopy || !showRasterOverlay) return; @@ -240,7 +240,7 @@ void QBlittablePixmapData::unmergeOverlay() m_unmergedCopy = 0; } -QImage *QBlittablePixmapData::overlay() +QImage *QBlittablePlatformPixmap::overlay() { if (!m_rasterOverlay|| m_rasterOverlay->size() != QSize(w,h)){ @@ -254,7 +254,7 @@ QImage *QBlittablePixmapData::overlay() return m_rasterOverlay; } -void QBlittablePixmapData::markRasterOverlayImpl(const QRectF &rect) +void QBlittablePlatformPixmap::markRasterOverlayImpl(const QRectF &rect) { if (!showRasterOverlay) return; @@ -267,7 +267,7 @@ void QBlittablePixmapData::markRasterOverlayImpl(const QRectF &rect) } } -void QBlittablePixmapData::unmarkRasterOverlayImpl(const QRectF &rect) +void QBlittablePlatformPixmap::unmarkRasterOverlayImpl(const QRectF &rect) { if (!showRasterOverlay) return; @@ -281,7 +281,7 @@ void QBlittablePixmapData::unmarkRasterOverlayImpl(const QRectF &rect) } } -QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const +QRectF QBlittablePlatformPixmap::clipAndTransformRect(const QRectF &rect) const { QRectF transformationRect = rect; paintEngine(); diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 07791e548b..3ab5cb3da3 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -42,18 +42,18 @@ #ifndef QPIXMAP_BLITTER_P_H #define QPIXMAP_BLITTER_P_H -#include +#include #include #ifndef QT_NO_BLITTABLE QT_BEGIN_NAMESPACE -class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData +class Q_GUI_EXPORT QBlittablePlatformPixmap : public QPlatformPixmap { -// Q_DECLARE_PRIVATE(QBlittablePixmapData); +// Q_DECLARE_PRIVATE(QBlittablePlatformPixmap); public: - QBlittablePixmapData(); - ~QBlittablePixmapData(); + QBlittablePlatformPixmap(); + ~QBlittablePlatformPixmap(); virtual QBlittable *createBlittable(const QSize &size) const = 0; QBlittable *blittable() const; @@ -98,7 +98,7 @@ protected: }; -inline void QBlittablePixmapData::markRasterOverlay(const QRectF &rect) +inline void QBlittablePlatformPixmap::markRasterOverlay(const QRectF &rect) { #ifdef QT_BLITTER_RASTEROVERLAY markRasterOverlayImpl(rect); @@ -107,7 +107,7 @@ inline void QBlittablePixmapData::markRasterOverlay(const QRectF &rect) #endif } -inline void QBlittablePixmapData::markRasterOverlay(const QVectorPath &path) +inline void QBlittablePlatformPixmap::markRasterOverlay(const QVectorPath &path) { #ifdef QT_BLITTER_RASTEROVERLAY markRasterOverlayImpl(path.convertToPainterPath().boundingRect()); @@ -116,7 +116,7 @@ inline void QBlittablePixmapData::markRasterOverlay(const QVectorPath &path) #endif } -inline void QBlittablePixmapData::markRasterOverlay(const QPointF &pos, const QTextItem &ti) +inline void QBlittablePlatformPixmap::markRasterOverlay(const QPointF &pos, const QTextItem &ti) { #ifdef QT_BLITTER_RASTEROVERLAY QFontMetricsF fm(ti.font()); @@ -129,7 +129,7 @@ inline void QBlittablePixmapData::markRasterOverlay(const QPointF &pos, const QT #endif } -inline void QBlittablePixmapData::markRasterOverlay(const QRect *rects, int rectCount) +inline void QBlittablePlatformPixmap::markRasterOverlay(const QRect *rects, int rectCount) { #ifdef QT_BLITTER_RASTEROVERLAY for (int i = 0; i < rectCount; i++) { @@ -140,7 +140,7 @@ inline void QBlittablePixmapData::markRasterOverlay(const QRect *rects, int rect Q_UNUSED(rectCount) #endif } -inline void QBlittablePixmapData::markRasterOverlay(const QRectF *rects, int rectCount) +inline void QBlittablePlatformPixmap::markRasterOverlay(const QRectF *rects, int rectCount) { #ifdef QT_BLITTER_RASTEROVERLAY for (int i = 0; i < rectCount; i++) { @@ -152,7 +152,7 @@ inline void QBlittablePixmapData::markRasterOverlay(const QRectF *rects, int rec #endif } -inline void QBlittablePixmapData::unmarkRasterOverlay(const QRectF &rect) +inline void QBlittablePlatformPixmap::unmarkRasterOverlay(const QRectF &rect) { #ifdef QT_BLITTER_RASTEROVERLAY unmarkRasterOverlayImpl(rect); diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index a0ae88dc70..ce7d66043c 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE QPixmap qt_toRasterPixmap(const QImage &image) { - QPixmapData *data = - new QRasterPixmapData(image.depth() == 1 - ? QPixmapData::BitmapType - : QPixmapData::PixmapType); + QPlatformPixmap *data = + new QRasterPlatformPixmap(image.depth() == 1 + ? QPlatformPixmap::BitmapType + : QPlatformPixmap::PixmapType); data->fromImage(image, Qt::AutoColor); @@ -75,27 +75,27 @@ QPixmap qt_toRasterPixmap(const QPixmap &pixmap) if (pixmap.isNull()) return QPixmap(); - if (QPixmap(pixmap).data_ptr()->classId() == QPixmapData::RasterClass) + if (QPixmap(pixmap).data_ptr()->classId() == QPlatformPixmap::RasterClass) return pixmap; return qt_toRasterPixmap(pixmap.toImage()); } -QRasterPixmapData::QRasterPixmapData(PixelType type) - : QPixmapData(type, RasterClass) +QRasterPlatformPixmap::QRasterPlatformPixmap(PixelType type) + : QPlatformPixmap(type, RasterClass) { } -QRasterPixmapData::~QRasterPixmapData() +QRasterPlatformPixmap::~QRasterPlatformPixmap() { } -QPixmapData *QRasterPixmapData::createCompatiblePixmapData() const +QPlatformPixmap *QRasterPlatformPixmap::createCompatiblePlatformPixmap() const { - return new QRasterPixmapData(pixelType()); + return new QRasterPlatformPixmap(pixelType()); } -void QRasterPixmapData::resize(int width, int height) +void QRasterPlatformPixmap::resize(int width, int height) { QImage::Format format; #ifdef Q_WS_QWS @@ -130,7 +130,7 @@ void QRasterPixmapData::resize(int width, int height) setSerialNumber(image.serialNumber()); } -bool QRasterPixmapData::fromData(const uchar *buffer, uint len, const char *format, +bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags) { QByteArray a = QByteArray::fromRawData(reinterpret_cast(buffer), len); @@ -144,7 +144,7 @@ bool QRasterPixmapData::fromData(const uchar *buffer, uint len, const char *form return !isNull(); } -void QRasterPixmapData::fromImage(const QImage &sourceImage, +void QRasterPlatformPixmap::fromImage(const QImage &sourceImage, Qt::ImageConversionFlags flags) { Q_UNUSED(flags); @@ -152,7 +152,7 @@ void QRasterPixmapData::fromImage(const QImage &sourceImage, createPixmapForImage(image, flags, /* inplace = */false); } -void QRasterPixmapData::fromImageReader(QImageReader *imageReader, +void QRasterPlatformPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) { Q_UNUSED(flags); @@ -166,19 +166,19 @@ void QRasterPixmapData::fromImageReader(QImageReader *imageReader, // from qwindowsurface.cpp extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); -void QRasterPixmapData::copy(const QPixmapData *data, const QRect &rect) +void QRasterPlatformPixmap::copy(const QPlatformPixmap *data, const QRect &rect) { fromImage(data->toImage(rect).copy(), Qt::NoOpaqueDetection); } -bool QRasterPixmapData::scroll(int dx, int dy, const QRect &rect) +bool QRasterPlatformPixmap::scroll(int dx, int dy, const QRect &rect) { if (!image.isNull()) qt_scrollRectInImage(image, rect, QPoint(dx, dy)); return true; } -void QRasterPixmapData::fill(const QColor &color) +void QRasterPlatformPixmap::fill(const QColor &color) { uint pixel; @@ -262,12 +262,12 @@ void QRasterPixmapData::fill(const QColor &color) image.fill(pixel); } -bool QRasterPixmapData::hasAlphaChannel() const +bool QRasterPlatformPixmap::hasAlphaChannel() const { return image.hasAlphaChannel(); } -QImage QRasterPixmapData::toImage() const +QImage QRasterPlatformPixmap::toImage() const { if (!image.isNull()) { QImageData *data = const_cast(image).data_ptr(); @@ -281,7 +281,7 @@ QImage QRasterPixmapData::toImage() const return image; } -QImage QRasterPixmapData::toImage(const QRect &rect) const +QImage QRasterPlatformPixmap::toImage(const QRect &rect) const { if (rect.isNull()) return image; @@ -295,12 +295,12 @@ QImage QRasterPixmapData::toImage(const QRect &rect) const return image.copy(clipped); } -QPaintEngine* QRasterPixmapData::paintEngine() const +QPaintEngine* QRasterPlatformPixmap::paintEngine() const { return image.paintEngine(); } -int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const +int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const { QImageData *d = image.d; if (!d) @@ -327,14 +327,14 @@ int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmPhysicalDpiY: return qt_defaultDpiY(); default: - qWarning("QRasterPixmapData::metric(): Unhandled metric type %d", metric); + qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; } return 0; } -void QRasterPixmapData::createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace) +void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace) { QImage::Format format; if (flags & Qt::NoFormatConversion) @@ -436,7 +436,7 @@ void QRasterPixmapData::createPixmapForImage(QImage &sourceImage, Qt::ImageConve setSerialNumber(image.serialNumber()); } -QImage* QRasterPixmapData::buffer() +QImage* QRasterPlatformPixmap::buffer() { return ℑ } diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index e8d1b39b17..c451a94858 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -53,8 +53,7 @@ // We mean it. // -#include -#include +#include #ifdef Q_WS_WIN # include "qt_windows.h" @@ -62,13 +61,13 @@ QT_BEGIN_NAMESPACE -class Q_GUI_EXPORT QRasterPixmapData : public QPixmapData +class Q_GUI_EXPORT QRasterPlatformPixmap : public QPlatformPixmap { public: - QRasterPixmapData(PixelType type); - ~QRasterPixmapData(); + QRasterPlatformPixmap(PixelType type); + ~QRasterPlatformPixmap(); - QPixmapData *createCompatiblePixmapData() const; + QPlatformPixmap *createCompatiblePlatformPixmap() const; void resize(int width, int height); void fromFile(const QString &filename, Qt::ImageConversionFlags flags); @@ -76,7 +75,7 @@ public: void fromImage(const QImage &image, Qt::ImageConversionFlags flags); void fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags); - void copy(const QPixmapData *data, const QRect &rect); + void copy(const QPlatformPixmap *data, const QRect &rect); bool scroll(int dx, int dy, const QRect &rect); void fill(const QColor &color); bool hasAlphaChannel() const; diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 336c0f01d4..7b96f5a2cf 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -81,9 +81,9 @@ class QPixmapCacheEntry : public QPixmap public: QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key) { - QPixmapData *pd = pixmapData(); - if (pd && pd->classId() == QPixmapData::RasterClass) { - QRasterPixmapData *d = static_cast(pd); + QPlatformPixmap *pd = handle(); + if (pd && pd->classId() == QPlatformPixmap::RasterClass) { + QRasterPlatformPixmap *d = static_cast(pd); if (!d->image.isNull() && d->image.d->paintEngine && !d->image.d->paintEngine->isActive()) { diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp deleted file mode 100644 index e63e7aae0f..0000000000 --- a/src/gui/image/qpixmapdata.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qpixmapdata_p.h" -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QPixmapData *QPixmapData::create(int w, int h, PixelType type) -{ - QPixmapData *data = QGuiApplicationPrivate::platformIntegration()->createPixmapData(static_cast(type)); - data->resize(w, h); - return data; -} - - -QPixmapData::QPixmapData(PixelType pixelType, int objectId) - : w(0), - h(0), - d(0), - is_null(true), - ref(0), - detach_no(0), - type(pixelType), - id(objectId), - ser_no(0), - is_cached(false) -{ -} - -QPixmapData::~QPixmapData() -{ - // Sometimes the pixmap cleanup hooks will be called from derrived classes, which will - // then set is_cached to false. For example, on X11 QtOpenGL needs to delete the GLXPixmap - // or EGL Pixmap Surface for a given pixmap _before_ the native X11 pixmap is deleted, - // otherwise some drivers will leak the GL surface. In this case, QX11PixmapData will - // call the cleanup hooks itself before deleting the native pixmap and set is_cached to - // false. - if (is_cached) { - QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(this); - is_cached = false; - } -} - -QPixmapData *QPixmapData::createCompatiblePixmapData() const -{ - QPixmapData *d = QGuiApplicationPrivate::platformIntegration()->createPixmapData(pixelType()); - return d; -} - -static QImage makeBitmapCompliantIfNeeded(QPixmapData *d, const QImage &image, Qt::ImageConversionFlags flags) -{ - if (d->pixelType() == QPixmapData::BitmapType) { - QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags); - - // make sure image.color(0) == Qt::color0 (white) - // and image.color(1) == Qt::color1 (black) - const QRgb c0 = QColor(Qt::black).rgb(); - const QRgb c1 = QColor(Qt::white).rgb(); - if (img.color(0) == c0 && img.color(1) == c1) { - img.invertPixels(); - img.setColor(0, c1); - img.setColor(1, c0); - } - return img; - } - - return image; -} - -void QPixmapData::fromImageReader(QImageReader *imageReader, - Qt::ImageConversionFlags flags) -{ - const QImage image = imageReader->read(); - fromImage(image, flags); -} - -bool QPixmapData::fromFile(const QString &fileName, const char *format, - Qt::ImageConversionFlags flags) -{ - QImage image = QImageReader(fileName, format).read(); - if (image.isNull()) - return false; - fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); - return !isNull(); -} - -bool QPixmapData::fromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) -{ - QByteArray a = QByteArray::fromRawData(reinterpret_cast(buf), len); - QBuffer b(&a); - b.open(QIODevice::ReadOnly); - QImage image = QImageReader(&b, format).read(); - fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); - return !isNull(); -} - -void QPixmapData::copy(const QPixmapData *data, const QRect &rect) -{ - fromImage(data->toImage(rect), Qt::NoOpaqueDetection); -} - -bool QPixmapData::scroll(int dx, int dy, const QRect &rect) -{ - Q_UNUSED(dx); - Q_UNUSED(dy); - Q_UNUSED(rect); - return false; -} - -QPixmap QPixmapData::transformed(const QTransform &matrix, - Qt::TransformationMode mode) const -{ - return QPixmap::fromImage(toImage().transformed(matrix, mode)); -} - -void QPixmapData::setSerialNumber(int serNo) -{ - ser_no = serNo; -} - -QImage QPixmapData::toImage(const QRect &rect) const -{ - if (rect.contains(QRect(0, 0, w, h))) - return toImage(); - else - return toImage().copy(rect); -} - -QImage* QPixmapData::buffer() -{ - return 0; -} - -#if defined(Q_OS_SYMBIAN) -void* QPixmapData::toNativeType(NativeType /* type */) -{ - return 0; -} - -void QPixmapData::fromNativeType(void* /* pixmap */, NativeType /* typre */) -{ - return; -} -#endif - -QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h deleted file mode 100644 index ea3e03b382..0000000000 --- a/src/gui/image/qpixmapdata_p.h +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPIXMAPDATA_P_H -#define QPIXMAPDATA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QImageReader; - -class Q_GUI_EXPORT QPixmapData -{ -public: - enum PixelType { - // WARNING: Do not change the first two - // Must match QPixmap::Type - PixmapType, BitmapType - }; - - enum ClassId { RasterClass, DirectFBClass, - BlitterClass, CustomClass = 1024 }; - - 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; - virtual void fromImageReader(QImageReader *imageReader, - Qt::ImageConversionFlags flags); - - virtual bool fromFile(const QString &filename, const char *format, - Qt::ImageConversionFlags flags); - virtual bool fromData(const uchar *buffer, uint len, const char *format, - Qt::ImageConversionFlags flags); - - virtual void copy(const QPixmapData *data, const QRect &rect); - virtual bool scroll(int dx, int dy, const QRect &rect); - - virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0; - virtual void fill(const QColor &color) = 0; - - virtual bool hasAlphaChannel() const = 0; - virtual QPixmap transformed(const QTransform &matrix, - Qt::TransformationMode mode) const; - - virtual QImage toImage() const = 0; - virtual QImage toImage(const QRect &rect) const; - virtual QPaintEngine* paintEngine() const = 0; - - inline int serialNumber() const { return ser_no; } - - inline PixelType pixelType() const { return type; } - inline ClassId classId() const { return static_cast(id); } - - virtual QImage* buffer(); - - inline int width() const { return w; } - inline int height() const { return h; } - inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } - inline int depth() const { return d; } - inline bool isNull() const { return is_null; } - inline qint64 cacheKey() const { - int classKey = id; - if (classKey >= 1024) - classKey = -(classKey >> 10); - return ((((qint64) classKey) << 56) - | (((qint64) ser_no) << 32) - | ((qint64) detach_no)); - } - - static QPixmapData *create(int w, int h, PixelType type); - -protected: - - void setSerialNumber(int serNo); - int w; - int h; - int d; - bool is_null; - -private: - friend class QPixmap; - friend class QImagePixmapCleanupHooks; // Needs to set is_cached - friend class QGLTextureCache; //Needs to check the reference count - friend class QExplicitlySharedDataPointer; - - QAtomicInt ref; - int detach_no; - - PixelType type; - int id; - int ser_no; - uint is_cached; -}; - -# define QT_XFORM_TYPE_MSBFIRST 0 -# define QT_XFORM_TYPE_LSBFIRST 1 -# if defined(Q_WS_WIN) -# define QT_XFORM_TYPE_WINDOWSPIXMAP 2 -# endif -extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int); - -QT_END_NAMESPACE - -#endif // QPIXMAPDATA_P_H diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp deleted file mode 100644 index ceb7a67064..0000000000 --- a/src/gui/image/qpixmapdatafactory.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qpixmapdatafactory_p.h" - -#ifdef Q_WS_QWS -# include -#endif -#ifdef Q_WS_X11 -# include -#endif -#if defined(Q_WS_WIN) -# include -#endif -#ifdef Q_WS_MAC -# include -#endif -#ifdef Q_WS_QPA -# include -#endif -#ifdef Q_OS_SYMBIAN -# include -#endif - -#include "private/qguiapplication_p.h" - -QT_BEGIN_NAMESPACE - -#if !defined(Q_WS_QWS) - -class QSimplePixmapDataFactory : public QPixmapDataFactory -{ -public: - ~QSimplePixmapDataFactory() {} - QPixmapData* create(QPixmapData::PixelType type); -}; - -QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type) -{ - // ### should we always use Raster instead? - return QGuiApplicationPrivate::platformIntegration()->createPixmapData(type); -} - -Q_GLOBAL_STATIC(QSimplePixmapDataFactory, factory) - -#endif // !defined(Q_WS_QWS) - -QPixmapDataFactory::~QPixmapDataFactory() -{ -} - -QPixmapDataFactory* QPixmapDataFactory::instance(int screen) -{ - Q_UNUSED(screen); -#ifdef Q_WS_QWS - return QScreen::instance()->pixmapDataFactory(); -#else - return factory(); -#endif -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapdatafactory_p.h b/src/gui/image/qpixmapdatafactory_p.h deleted file mode 100644 index a539d672c3..0000000000 --- a/src/gui/image/qpixmapdatafactory_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPIXMAPDATAFACTORY_P_H -#define QPIXMAPDATAFACTORY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QPixmapData; - -class QPixmapDataFactory -{ -public: - static QPixmapDataFactory* instance(int screen = 0); - virtual ~QPixmapDataFactory(); - - virtual QPixmapData* create(QPixmapData::PixelType type) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPIXMAPDATAFACTORY_P_H diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp new file mode 100644 index 0000000000..7fb1bd6530 --- /dev/null +++ b/src/gui/image/qplatformpixmap.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformpixmap_qpa.h" +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QPlatformPixmap *QPlatformPixmap::create(int w, int h, PixelType type) +{ + QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast(type)); + data->resize(w, h); + return data; +} + + +QPlatformPixmap::QPlatformPixmap(PixelType pixelType, int objectId) + : w(0), + h(0), + d(0), + is_null(true), + ref(0), + detach_no(0), + type(pixelType), + id(objectId), + ser_no(0), + is_cached(false) +{ +} + +QPlatformPixmap::~QPlatformPixmap() +{ + // Sometimes the pixmap cleanup hooks will be called from derrived classes, which will + // then set is_cached to false. For example, on X11 QtOpenGL needs to delete the GLXPixmap + // or EGL Pixmap Surface for a given pixmap _before_ the native X11 pixmap is deleted, + // otherwise some drivers will leak the GL surface. In this case, QX11PlatformPixmap will + // call the cleanup hooks itself before deleting the native pixmap and set is_cached to + // false. + if (is_cached) { + QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(this); + is_cached = false; + } +} + +QPlatformPixmap *QPlatformPixmap::createCompatiblePlatformPixmap() const +{ + QPlatformPixmap *d = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(pixelType()); + return d; +} + +static QImage makeBitmapCompliantIfNeeded(QPlatformPixmap *d, const QImage &image, Qt::ImageConversionFlags flags) +{ + if (d->pixelType() == QPlatformPixmap::BitmapType) { + QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags); + + // make sure image.color(0) == Qt::color0 (white) + // and image.color(1) == Qt::color1 (black) + const QRgb c0 = QColor(Qt::black).rgb(); + const QRgb c1 = QColor(Qt::white).rgb(); + if (img.color(0) == c0 && img.color(1) == c1) { + img.invertPixels(); + img.setColor(0, c1); + img.setColor(1, c0); + } + return img; + } + + return image; +} + +void QPlatformPixmap::fromImageReader(QImageReader *imageReader, + Qt::ImageConversionFlags flags) +{ + const QImage image = imageReader->read(); + fromImage(image, flags); +} + +bool QPlatformPixmap::fromFile(const QString &fileName, const char *format, + Qt::ImageConversionFlags flags) +{ + QImage image = QImageReader(fileName, format).read(); + if (image.isNull()) + return false; + fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); + return !isNull(); +} + +bool QPlatformPixmap::fromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) +{ + QByteArray a = QByteArray::fromRawData(reinterpret_cast(buf), len); + QBuffer b(&a); + b.open(QIODevice::ReadOnly); + QImage image = QImageReader(&b, format).read(); + fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); + return !isNull(); +} + +void QPlatformPixmap::copy(const QPlatformPixmap *data, const QRect &rect) +{ + fromImage(data->toImage(rect), Qt::NoOpaqueDetection); +} + +bool QPlatformPixmap::scroll(int dx, int dy, const QRect &rect) +{ + Q_UNUSED(dx); + Q_UNUSED(dy); + Q_UNUSED(rect); + return false; +} + +QPixmap QPlatformPixmap::transformed(const QTransform &matrix, + Qt::TransformationMode mode) const +{ + return QPixmap::fromImage(toImage().transformed(matrix, mode)); +} + +void QPlatformPixmap::setSerialNumber(int serNo) +{ + ser_no = serNo; +} + +QImage QPlatformPixmap::toImage(const QRect &rect) const +{ + if (rect.contains(QRect(0, 0, w, h))) + return toImage(); + else + return toImage().copy(rect); +} + +QImage* QPlatformPixmap::buffer() +{ + return 0; +} + +#if defined(Q_OS_SYMBIAN) +void* QPlatformPixmap::toNativeType(NativeType /* type */) +{ + return 0; +} + +void QPlatformPixmap::fromNativeType(void* /* pixmap */, NativeType /* typre */) +{ + return; +} +#endif + +QT_END_NAMESPACE diff --git a/src/gui/image/qplatformpixmap_qpa.h b/src/gui/image/qplatformpixmap_qpa.h new file mode 100644 index 0000000000..5f5b903962 --- /dev/null +++ b/src/gui/image/qplatformpixmap_qpa.h @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPIXMAPDATA_P_H +#define QPIXMAPDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QImageReader; + +class Q_GUI_EXPORT QPlatformPixmap +{ +public: + enum PixelType { + // WARNING: Do not change the first two + // Must match QPixmap::Type + PixmapType, BitmapType + }; + + enum ClassId { RasterClass, DirectFBClass, + BlitterClass, CustomClass = 1024 }; + + QPlatformPixmap(PixelType pixelType, int classId); + virtual ~QPlatformPixmap(); + + virtual QPlatformPixmap *createCompatiblePlatformPixmap() const; + + virtual void resize(int width, int height) = 0; + virtual void fromImage(const QImage &image, + Qt::ImageConversionFlags flags) = 0; + virtual void fromImageReader(QImageReader *imageReader, + Qt::ImageConversionFlags flags); + + virtual bool fromFile(const QString &filename, const char *format, + Qt::ImageConversionFlags flags); + virtual bool fromData(const uchar *buffer, uint len, const char *format, + Qt::ImageConversionFlags flags); + + virtual void copy(const QPlatformPixmap *data, const QRect &rect); + virtual bool scroll(int dx, int dy, const QRect &rect); + + virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0; + virtual void fill(const QColor &color) = 0; + + virtual bool hasAlphaChannel() const = 0; + virtual QPixmap transformed(const QTransform &matrix, + Qt::TransformationMode mode) const; + + virtual QImage toImage() const = 0; + virtual QImage toImage(const QRect &rect) const; + virtual QPaintEngine* paintEngine() const = 0; + + inline int serialNumber() const { return ser_no; } + + inline PixelType pixelType() const { return type; } + inline ClassId classId() const { return static_cast(id); } + + virtual QImage* buffer(); + + inline int width() const { return w; } + inline int height() const { return h; } + inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } + inline int depth() const { return d; } + inline bool isNull() const { return is_null; } + inline qint64 cacheKey() const { + int classKey = id; + if (classKey >= 1024) + classKey = -(classKey >> 10); + return ((((qint64) classKey) << 56) + | (((qint64) ser_no) << 32) + | ((qint64) detach_no)); + } + + static QPlatformPixmap *create(int w, int h, PixelType type); + +protected: + + void setSerialNumber(int serNo); + int w; + int h; + int d; + bool is_null; + +private: + friend class QPixmap; + friend class QImagePixmapCleanupHooks; // Needs to set is_cached + friend class QGLTextureCache; //Needs to check the reference count + friend class QExplicitlySharedDataPointer; + + QAtomicInt ref; + int detach_no; + + PixelType type; + int id; + int ser_no; + uint is_cached; +}; + +# define QT_XFORM_TYPE_MSBFIRST 0 +# define QT_XFORM_TYPE_LSBFIRST 1 +# if defined(Q_WS_WIN) +# define QT_XFORM_TYPE_WINDOWSPIXMAP 2 +# endif +extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int); + +QT_END_NAMESPACE + +#endif // QPIXMAPDATA_P_H diff --git a/src/gui/image/qvolatileimage.cpp b/src/gui/image/qvolatileimage.cpp index 4f139f844d..f7fe70c496 100644 --- a/src/gui/image/qvolatileimage.cpp +++ b/src/gui/image/qvolatileimage.cpp @@ -42,7 +42,7 @@ #include "qvolatileimage_p.h" #include "qvolatileimagedata_p.h" #include -#include +#include QT_BEGIN_NAMESPACE @@ -236,7 +236,7 @@ void QVolatileImage::copyFrom(QVolatileImage *source, const QRect &rect) } /*! - To be called from the PixmapData's paintEngine(). + To be called from the PlatformPixmap's paintEngine(). */ QPaintEngine *QVolatileImage::paintEngine() { @@ -275,7 +275,7 @@ bool QVolatileImagePaintEngine::end() void QVolatileImagePaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) { #ifdef Q_OS_SYMBIAN - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); + void *nativeData = pm.handle()->toNativeType(QPlatformPixmap::VolatileImage); if (nativeData) { QVolatileImage *img = static_cast(nativeData); img->beginDataAccess(); @@ -292,7 +292,7 @@ void QVolatileImagePaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) void QVolatileImagePaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { #ifdef Q_OS_SYMBIAN - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); + void *nativeData = pm.handle()->toNativeType(QPlatformPixmap::VolatileImage); if (nativeData) { QVolatileImage *img = static_cast(nativeData); img->beginDataAccess(); -- cgit v1.2.3