diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/image.pri | 3 | ||||
-rw-r--r-- | src/gui/image/qbitmap.cpp | 94 | ||||
-rw-r--r-- | src/gui/image/qbitmap.h | 23 | ||||
-rw-r--r-- | src/gui/image/qicon.cpp | 157 | ||||
-rw-r--r-- | src/gui/image/qicon.h | 19 | ||||
-rw-r--r-- | src/gui/image/qiconloader.cpp | 9 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 553 | ||||
-rw-r--r-- | src/gui/image/qimage.h | 49 | ||||
-rw-r--r-- | src/gui/image/qimage_p.h | 3 | ||||
-rw-r--r-- | src/gui/image/qmovie.h | 20 | ||||
-rw-r--r-- | src/gui/image/qnativeimage.cpp | 110 | ||||
-rw-r--r-- | src/gui/image/qnativeimage_p.h | 12 | ||||
-rw-r--r-- | src/gui/image/qpicture.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qpicture.h | 3 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 252 | ||||
-rw-r--r-- | src/gui/image/qpixmap.h | 36 | ||||
-rw-r--r-- | src/gui/image/qpixmap_blitter.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qpixmap_qpa.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qpixmap_qws.cpp | 160 | ||||
-rw-r--r-- | src/gui/image/qpixmapdata.cpp | 17 | ||||
-rw-r--r-- | src/gui/image/qpixmapdatafactory.cpp | 21 | ||||
-rw-r--r-- | src/gui/image/qpixmapfilter.cpp | 3 |
22 files changed, 92 insertions, 1464 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 72738c9fa8..e970fb05a1 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -62,9 +62,6 @@ SOURCES += \ win32 { SOURCES += image/qpixmap_win.cpp } -else:embedded { - SOURCES += image/qpixmap_qws.cpp -} else:qpa { SOURCES += image/qpixmap_qpa.cpp } diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp index 260b397140..6cd8363374 100644 --- a/src/gui/image/qbitmap.cpp +++ b/src/gui/image/qbitmap.cpp @@ -44,8 +44,7 @@ #include "qimage.h" #include "qvariant.h" #include <qpainter.h> -#include <private/qgraphicssystem_p.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> QT_BEGIN_NAMESPACE @@ -205,20 +204,6 @@ QBitmap &QBitmap::operator=(const QPixmap &pixmap) return *this; } - -#ifdef QT3_SUPPORT -QBitmap::QBitmap(int w, int h, const uchar *bits, bool isXbitmap) -{ - *this = fromData(QSize(w, h), bits, isXbitmap ? QImage::Format_MonoLSB : QImage::Format_Mono); -} - - -QBitmap::QBitmap(const QSize &size, const uchar *bits, bool isXbitmap) -{ - *this = fromData(size, bits, isXbitmap ? QImage::Format_MonoLSB : QImage::Format_Mono); -} -#endif - /*! Destroys the bitmap. */ @@ -275,9 +260,7 @@ QBitmap QBitmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) img.setColor(1, c0); } - QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); - QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::BitmapType) - : QGraphicsSystem::createDefaultPixmapData(QPixmapData::BitmapType)); + QScopedPointer<QPixmapData> data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::BitmapType)); data->fromImage(img, flags | Qt::MonoOnly); return QPixmap(data.take()); @@ -335,77 +318,4 @@ QBitmap QBitmap::transformed(const QMatrix &matrix) const return transformed(QTransform(matrix)); } -#ifdef QT3_SUPPORT -/*! - \fn QBitmap QBitmap::xForm(const QMatrix &matrix) const - - Returns a copy of this bitmap, transformed according to the given - \a matrix. - - Use transformed() instead. -*/ - -/*! - \fn QBitmap::QBitmap(const QSize &size, bool clear) - - Constructs a bitmap with the given \a size. If \a clear is true, - the bits are initialized to Qt::color0. - - Use the corresponding QBitmap() constructor instead, and then call - the clear() function if the \a clear parameter is true. -*/ - -/*! - \fn QBitmap::QBitmap(int width, int height, bool clear) - - Constructs a bitmap with the given \a width and \a height. If \a - clear is true, the bits are initialized to Qt::color0. - - Use the corresponding QBitmap() constructor instead, and then call - the clear() function if the \a clear parameter is true. -*/ - -/*! - \fn QBitmap::QBitmap(int width, int height, const uchar *bits, bool isXbitmap) - - Constructs a bitmap with the given \a width and \a height, and - sets the contents to the \a bits supplied. The \a isXbitmap flag - should be true if \a bits was generated by the X11 bitmap - program. - - Use the static fromData() function instead. If \a isXbitmap is - true, use the default bit order(QImage_FormatMonoLSB) otherwise - use QImage::Format_Mono. - - \omit - The X bitmap bit order is little endian. The QImage - documentation discusses bit order of monochrome images. Opposed to - QImage, the data has to be byte aligned. - - Example (creates an arrow bitmap): - \snippet doc/src/snippets/code/src_gui_image_qbitmap.cpp 0 - \endomit -*/ - - -/*! - \fn QBitmap::QBitmap(const QSize &size, const uchar *bits, bool isXbitmap) - - \overload - - Constructs a bitmap with the given \a size, and sets the contents - to the \a bits supplied. The \a isXbitmap flag should be true if - \a bits was generated by the X11 bitmap program. - - \omit - The X bitmap bit order is little endian. The QImage documentation - discusses bit order of monochrome images. - \endomit - - Use the static fromData() function instead. If \a isXbitmap is - true, use the default bit order(QImage_FormatMonoLSB) otherwise - use QImage::Format_Mono. -*/ -#endif - QT_END_NAMESPACE diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h index f1771e3e43..9dff0816dd 100644 --- a/src/gui/image/qbitmap.h +++ b/src/gui/image/qbitmap.h @@ -74,34 +74,11 @@ public: QBitmap transformed(const QMatrix &) const; QBitmap transformed(const QTransform &matrix) const; -#ifdef QT3_SUPPORT - inline QT3_SUPPORT_CONSTRUCTOR QBitmap(int w, int h, bool clear); - inline QT3_SUPPORT_CONSTRUCTOR QBitmap(const QSize &, bool clear); - QT3_SUPPORT_CONSTRUCTOR QBitmap(int w, int h, const uchar *bits, bool isXbitmap=false); - QT3_SUPPORT_CONSTRUCTOR QBitmap(const QSize &, const uchar *bits, bool isXbitmap=false); - inline QT3_SUPPORT QBitmap xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } - QT3_SUPPORT_CONSTRUCTOR QBitmap(const QImage &image) { *this = fromImage(image); } - QT3_SUPPORT QBitmap &operator=(const QImage &image) { *this = fromImage(image); return *this; } -#endif typedef QExplicitlySharedDataPointer<QPixmapData> DataPtr; }; Q_DECLARE_SHARED(QBitmap) -#ifdef QT3_SUPPORT -inline QBitmap::QBitmap(int w, int h, bool clear) - : QPixmap(QSize(w, h), 1) -{ - if (clear) this->clear(); -} - -inline QBitmap::QBitmap(const QSize &size, bool clear) - : QPixmap(size, 1) -{ - if (clear) this->clear(); -} -#endif - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 7182062e59..59687c709d 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -45,7 +45,6 @@ #include "qiconengineplugin.h" #include "private/qfactoryloader_p.h" #include "private/qiconloader_p.h" -#include "qapplication.h" #include "qstyleoption.h" #include "qpainter.h" #include "qfileinfo.h" @@ -55,6 +54,7 @@ #include "qcache.h" #include "qdebug.h" #include "private/qguiplatformplugin_p.h" +#include "qguiapplication.h" #ifdef Q_WS_MAC #include <private/qt_mac_p.h> @@ -66,7 +66,7 @@ #include "private/qkde_p.h" #endif -#include "private/qstylehelper_p.h" +#include "private/qhexstring_p.h" #ifndef QT_NO_ICON QT_BEGIN_NAMESPACE @@ -263,37 +263,38 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - QString key = QLatin1Literal("qt_") - % HexString<quint64>(pm.cacheKey()) - % HexString<uint>(pe->mode) - % HexString<quint64>(QApplication::palette().cacheKey()) - % HexString<uint>(actualSize.width()) - % HexString<uint>(actualSize.height()); - - if (mode == QIcon::Active) { - if (QPixmapCache::find(key % HexString<uint>(mode), pm)) - return pm; // horray - if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) { - QStyleOption opt(0); - opt.palette = QApplication::palette(); - QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); - if (pm.cacheKey() == active.cacheKey()) - return pm; - } - } - - if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) { + // #### Qt5 no idea what this really does, but we need to remove the QApp and style references +// QString key = QLatin1Literal("qt_") +// % HexString<quint64>(pm.cacheKey()) +// % HexString<uint>(pe->mode) +// % HexString<quint64>(QApplication::palette().cacheKey()) +// % HexString<uint>(actualSize.width()) +// % HexString<uint>(actualSize.height()); + +// if (mode == QIcon::Active) { +// if (QPixmapCache::find(key % HexString<uint>(mode), pm)) +// return pm; // horray +// if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) { +// QStyleOption opt(0); +// opt.palette = QApplication::palette(); +// QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); +// if (pm.cacheKey() == active.cacheKey()) +// return pm; +// } +// } + +// if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - if (pe->mode != mode && mode != QIcon::Normal) { - QStyleOption opt(0); - opt.palette = QApplication::palette(); - QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); - if (!generated.isNull()) - pm = generated; - } - QPixmapCache::insert(key % HexString<uint>(mode), pm); - } +// if (pe->mode != mode && mode != QIcon::Normal) { +// QStyleOption opt(0); +// opt.palette = QApplication::palette(); +// QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); +// if (!generated.isNull()) +// pm = generated; +// } +// QPixmapCache::insert(key % HexString<uint>(mode), pm); +// } return pm; } @@ -1150,100 +1151,6 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon) #endif //QT_NO_DATASTREAM - -#ifdef QT3_SUPPORT - -static int widths[2] = { 22, 32 }; -static int heights[2] = { 22, 32 }; - -static QSize pixmapSizeHelper(QIcon::Size which) -{ - int i = 0; - if (which == QIcon::Large) - i = 1; - return QSize(widths[i], heights[i]); -} - -/*! - \enum QIcon::Size - \compat - - \value Small Use QStyle::pixelMetric(QStyle::PM_SmallIconSize) instead. - \value Large Use QStyle::pixelMetric(QStyle::PM_LargeIconSize) instead. - \value Automatic N/A. -*/ - -/*! - Use pixmap(QSize(...), \a mode, \a state), where the first - argument is an appropriate QSize instead of a \l Size value. - - \sa pixmapSize() -*/ -QPixmap QIcon::pixmap(Size size, Mode mode, State state) const -{ return pixmap(pixmapSizeHelper(size), mode, state); } - -/*! - Use pixmap(QSize(...), mode, \a state), where the first argument - is an appropriate QSize instead of a \l Size value, and the - second argument is QIcon::Normal or QIcon::Disabled, depending on - the value of \a enabled. - - \sa pixmapSize() -*/ -QPixmap QIcon::pixmap(Size size, bool enabled, State state) const -{ return pixmap(pixmapSizeHelper(size), enabled ? Normal : Disabled, state); } - -/*! - Use one of the other pixmap() overloads. -*/ -QPixmap QIcon::pixmap() const -{ return pixmap(pixmapSizeHelper(Small), Normal, Off); } - -/*! - The pixmap() function now takes a QSize instead of a QIcon::Size, - so there is no need for this function in new code. -*/ -void QIcon::setPixmapSize(Size which, const QSize &size) -{ - int i = 0; - if (which == Large) - i = 1; - widths[i] = size.width(); - heights[i] = size.height(); -} - -/*! - Use QStyle::pixelMetric() with QStyle::PM_SmallIconSize or - QStyle::PM_LargeIconSize as the first argument, depending on \a - which. -*/ -QSize QIcon::pixmapSize(Size which) -{ - return pixmapSizeHelper(which); -} - -/*! - \fn void QIcon::reset(const QPixmap &pixmap, Size size) - - Use the constructor that takes a QPixmap and operator=(). -*/ - -/*! - \fn void QIcon::setPixmap(const QPixmap &pixmap, Size size, Mode mode, State state) - - Use addPixmap(\a pixmap, \a mode, \a state) instead. The \a size - parameter is ignored. -*/ - -/*! - \fn void QIcon::setPixmap(const QString &fileName, Size size, Mode mode, State state) - - Use addFile(\a fileName, \a mode, \a state) instead. The \a size - parameter is ignored. -*/ - -#endif // QT3_SUPPORT - /*! \fn DataPtr &QIcon::data_ptr() \internal diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 170559182b..4e3960925e 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -114,21 +114,6 @@ public: static QString themeName(); static void setThemeName(const QString &path); - -#ifdef QT3_SUPPORT - enum Size { Small, Large, Automatic = Small }; - static QT3_SUPPORT void setPixmapSize(Size which, const QSize &size); - static QT3_SUPPORT QSize pixmapSize(Size which); - inline QT3_SUPPORT void reset(const QPixmap &pixmap, Size /*size*/) { *this = QIcon(pixmap); } - inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap, Size, Mode mode = Normal, State state = Off) - { addPixmap(pixmap, mode, state); } - inline QT3_SUPPORT void setPixmap(const QString &fileName, Size, Mode mode = Normal, State state = Off) - { addPixmap(QPixmap(fileName), mode, state); } - QT3_SUPPORT QPixmap pixmap(Size size, Mode mode, State state = Off) const; - QT3_SUPPORT QPixmap pixmap(Size size, bool enabled, State state = Off) const; - QT3_SUPPORT QPixmap pixmap() const; -#endif - Q_DUMMY_COMPARISON_OPERATOR(QIcon) private: @@ -151,10 +136,6 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); #endif -#ifdef QT3_SUPPORT -typedef QIcon QIconSet; -#endif - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 0a42f0af78..19be636e9c 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -41,7 +41,7 @@ #ifndef QT_NO_ICON #include <private/qiconloader_p.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> #include <private/qicon_p.h> #include <private/qguiplatformplugin_p.h> @@ -63,7 +63,7 @@ #include <private/qt_x11_p.h> #endif -#include <private/qstylehelper_p.h> +#include <private/qhexstring_p.h> QT_BEGIN_NAMESPACE @@ -489,8 +489,8 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st if (basePixmap.isNull()) basePixmap.load(filename); +#if 0 // ### Qt5 int actualSize = qMin(size.width(), size.height()); - QString key = QLatin1Literal("$qt_theme_") % HexString<qint64>(basePixmap.cacheKey()) % HexString<int>(mode) @@ -507,6 +507,9 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st QPixmapCache::insert(key, cachedPixmap); } return cachedPixmap; +#else + return basePixmap; +#endif } QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 50b372ea63..448e1b4be0 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -124,9 +124,6 @@ QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1); QImageData::QImageData() : ref(0), width(0), height(0), depth(0), nbytes(0), data(0), -#ifdef QT3_SUPPORT - jumptable(0), -#endif format(QImage::Format_ARGB32), bytes_per_line(0), ser_no(qimage_serial_number.fetchAndAddRelaxed(1)), detach_no(0), @@ -220,11 +217,6 @@ QImageData::~QImageData() delete paintEngine; if (data && own_data) free(data); -#ifdef QT3_SUPPORT - if (jumptable) - free(jumptable); - jumptable = 0; -#endif data = 0; } @@ -757,27 +749,6 @@ const uchar *qt_get_bitflip_array() // called from QPixma return bitflip; } -#if defined(QT3_SUPPORT) -static QImage::Format formatFor(int depth, QImage::Endian bitOrder) -{ - QImage::Format format; - if (depth == 1) { - format = bitOrder == QImage::BigEndian ? QImage::Format_Mono : QImage::Format_MonoLSB; - } else if (depth == 8) { - format = QImage::Format_Indexed8; - } else if (depth == 32) { - format = QImage::Format_RGB32; - } else if (depth == 24) { - format = QImage::Format_RGB888; - } else if (depth == 16) { - format = QImage::Format_RGB16; - } else { - qWarning("QImage: Depth %d not supported", depth); - format = QImage::Format_Invalid; - } - return format; -} -#endif /*! Constructs a null image. @@ -991,42 +962,6 @@ QImage::QImage(const QString &fileName, const char *format) load(fileName, format); } -/*! - Constructs an image and tries to load the image from the file with - the given \a fileName. - - The loader attempts to read the image using the specified \a - format. If the \a format is not specified (which is the default), - the loader probes the file for a header to guess the file format. - - If the loading of the image failed, this object is a null image. - - The file name can either refer to an actual file on disk or to one - of the application's embedded resources. See the - \l{resources.html}{Resource System} overview for details on how to - embed images and other resource files in the application's - executable. - - You can disable this constructor by defining \c - QT_NO_CAST_FROM_ASCII when you compile your applications. This can - be useful, for example, if you want to ensure that all - user-visible strings go through QObject::tr(). - - \sa QString::fromAscii(), isNull(), {QImage#Reading and Writing - Image Files}{Reading and Writing Image Files} -*/ -#ifndef QT_NO_CAST_FROM_ASCII -QImage::QImage(const char *fileName, const char *format) - : QPaintDevice() -{ - // ### Qt 5: if you remove the QImage(const QByteArray &) QT3_SUPPORT - // constructor, remove this constructor as well. The constructor here - // exists so that QImage("foo.png") compiles without ambiguity. - d = 0; - load(QString::fromAscii(fileName), format); -} -#endif - #ifndef QT_NO_IMAGEFORMAT_XPM extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *source, QImage &image); @@ -1097,178 +1032,6 @@ QImage::QImage(const QImage &image) } } -#ifdef QT3_SUPPORT -/*! - \fn QImage::QImage(int width, int height, int depth, int numColors, Endian bitOrder) - - Constructs an image with the given \a width, \a height, \a depth, - \a numColors colors and \a bitOrder. - - Use the constructor that accepts a width, a height and a format - (i.e. specifying the depth and bit order), in combination with the - setColorCount() function, instead. - - \oldcode - QImage image(width, height, depth, numColors); - \newcode - QImage image(width, height, format); - - // For 8 bit images the default number of colors is 256. If - // another number of colors is required it can be specified - // using the setColorCount() function. - image.setColorCount(numColors); - \endcode -*/ - -QImage::QImage(int w, int h, int depth, int colorCount, Endian bitOrder) - : QPaintDevice() -{ - d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), colorCount); -} - -/*! - Constructs an image with the given \a size, \a depth, \a numColors - and \a bitOrder. - - Use the constructor that accepts a size and a format - (i.e. specifying the depth and bit order), in combination with the - setColorCount() function, instead. - - \oldcode - QSize mySize(width, height); - QImage image(mySize, depth, numColors); - \newcode - QSize mySize(width, height); - QImage image(mySize, format); - - // For 8 bit images the default number of colors is 256. If - // another number of colors is required it can be specified - // using the setColorCount() function. - image.setColorCount(numColors); - \endcode -*/ -QImage::QImage(const QSize& size, int depth, int numColors, Endian bitOrder) - : QPaintDevice() -{ - d = QImageData::create(size, formatFor(depth, bitOrder), numColors); -} - -/*! - \fn QImage::QImage(uchar* data, int width, int height, int depth, const QRgb* colortable, int numColors, Endian bitOrder) - - Constructs an image with the given \a width, \a height, depth, \a - colortable, \a numColors and \a bitOrder, that uses an existing - memory buffer, \a data. - - Use the constructor that accepts a uchar pointer, a width, a - height and a format (i.e. specifying the depth and bit order), in - combination with the setColorTable() function, instead. - - \oldcode - uchar *myData; - QRgb *myColorTable; - - QImage image(myData, width, height, depth, - myColorTable, numColors, IgnoreEndian); - \newcode - uchar *myData; - QVector<QRgb> myColorTable; - - QImage image(myData, width, height, format); - image.setColorTable(myColorTable); - \endcode -*/ -QImage::QImage(uchar* data, int w, int h, int depth, const QRgb* colortable, int numColors, Endian bitOrder) - : QPaintDevice() -{ - d = 0; - Format f = formatFor(depth, bitOrder); - if (f == Format_Invalid) - return; - - const int bytes_per_line = ((w*depth+31)/32)*4; // bytes per scanline - if (w <= 0 || h <= 0 || numColors < 0 || !data - || INT_MAX/sizeof(uchar *) < uint(h) - || INT_MAX/uint(depth) < uint(w) - || bytes_per_line <= 0 - || INT_MAX/uint(bytes_per_line) < uint(h)) - return; // invalid parameter(s) - d = new QImageData; - d->ref.ref(); - - d->own_data = false; - d->data = data; - d->width = w; - d->height = h; - d->depth = depth; - d->format = f; - if (depth == 32) - numColors = 0; - - d->bytes_per_line = bytes_per_line; - d->nbytes = d->bytes_per_line * h; - if (colortable) { - d->colortable.resize(numColors); - for (int i = 0; i < numColors; ++i) - d->colortable[i] = colortable[i]; - } else if (numColors) { - setColorCount(numColors); - } -} - -#ifdef Q_WS_QWS - -/*! - \fn QImage::QImage(uchar* data, int width, int height, int depth, int bytesPerLine, const QRgb* colortable, int numColors, Endian bitOrder) - - Constructs an image with the given \a width, \a height, \a depth, - \a bytesPerLine, \a colortable, \a numColors and \a bitOrder, that - uses an existing memory buffer, \a data. The image does not delete - the buffer at destruction. - - \warning This constructor is only available in Qt for Embedded Linux. - - The data has to be 32-bit aligned, and each scanline of data in the image - must also be 32-bit aligned, so it's no longer possible to specify a custom - \a bytesPerLine value. -*/ -QImage::QImage(uchar* data, int w, int h, int depth, int bpl, const QRgb* colortable, int numColors, Endian bitOrder) - : QPaintDevice() -{ - d = 0; - Format f = formatFor(depth, bitOrder); - if (f == Format_Invalid) - return; - if (!data || w <= 0 || h <= 0 || depth <= 0 || numColors < 0 - || INT_MAX/sizeof(uchar *) < uint(h) - || INT_MAX/uint(depth) < uint(w) - || bpl <= 0 - || INT_MAX/uint(bpl) < uint(h)) - return; // invalid parameter(s) - - d = new QImageData; - d->ref.ref(); - d->own_data = false; - d->data = data; - d->width = w; - d->height = h; - d->depth = depth; - d->format = f; - if (depth == 32) - numColors = 0; - d->bytes_per_line = bpl; - d->nbytes = d->bytes_per_line * h; - if (colortable) { - d->colortable.resize(numColors); - for (int i = 0; i < numColors; ++i) - d->colortable[i] = colortable[i]; - } else if (numColors) { - setColorCount(numColors); - } -} -#endif // Q_WS_QWS -#endif // QT3_SUPPORT - /*! Destroys the image and cleans up. */ @@ -1613,75 +1376,6 @@ int QImage::colorCount() const return d ? d->colortable.size() : 0; } - -#ifdef QT3_SUPPORT -/*! - \fn QImage::Endian QImage::bitOrder() const - - Returns the bit order for the image. If it is a 1-bpp image, this - function returns either QImage::BigEndian or - QImage::LittleEndian. Otherwise, this function returns - QImage::IgnoreEndian. - - Use the format() function instead for the monochrome formats. For - non-monochrome formats the bit order is irrelevant. -*/ - -/*! - Returns a pointer to the scanline pointer table. This is the - beginning of the data block for the image. - Returns 0 in case of an error. - - Use the bits() or scanLine() function instead. -*/ -uchar **QImage::jumpTable() -{ - if (!d) - return 0; - detach(); - - // in case detach() ran out of memory.. - if (!d) - return 0; - - if (!d->jumptable) { - d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *)); - if (!d->jumptable) - return 0; - uchar *data = d->data; - int height = d->height; - uchar **p = d->jumptable; - while (height--) { - *p++ = data; - data += d->bytes_per_line; - } - } - return d->jumptable; -} - -/*! - \overload -*/ -const uchar * const *QImage::jumpTable() const -{ - if (!d) - return 0; - if (!d->jumptable) { - d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *)); - if (!d->jumptable) - return 0; - uchar *data = d->data; - int height = d->height; - uchar **p = d->jumptable; - while (height--) { - *p++ = data; - data += d->bytes_per_line; - } - } - return d->jumptable; -} -#endif - /*! Sets the color table used to translate color indexes to QRgb values, to the specified \a colors. @@ -2223,116 +1917,6 @@ QImage::Format QImage::format() const } -#ifdef QT3_SUPPORT -/*! - Returns true if alpha buffer mode is enabled; otherwise returns - false. - - Use the hasAlphaChannel() function instead. - -*/ -bool QImage::hasAlphaBuffer() const -{ - if (!d) - return false; - - switch (d->format) { - case Format_ARGB32: - case Format_ARGB32_Premultiplied: - case Format_ARGB8565_Premultiplied: - case Format_ARGB8555_Premultiplied: - case Format_ARGB6666_Premultiplied: - case Format_ARGB4444_Premultiplied: - return true; - default: - return false; - } -} - -/*! - Enables alpha buffer mode if \a enable is true, otherwise disables - it. The alpha buffer is used to set a mask when a QImage is - translated to a QPixmap. - - If a monochrome or indexed 8-bit image has alpha channels in their - color tables they will automatically detect that they have an - alpha channel, so this function is not required. To force alpha - channels on 32-bit images, use the convertToFormat() function. -*/ - -void QImage::setAlphaBuffer(bool enable) -{ - if (!d - || d->format == Format_Mono - || d->format == Format_MonoLSB - || d->format == Format_Indexed8) - return; - if (enable && (d->format == Format_ARGB32 || - d->format == Format_ARGB32_Premultiplied || - d->format == Format_ARGB8565_Premultiplied || - d->format == Format_ARGB6666_Premultiplied || - d->format == Format_ARGB8555_Premultiplied || - d->format == Format_ARGB4444_Premultiplied)) - { - return; - } - if (!enable && (d->format == Format_RGB32 || - d->format == Format_RGB555 || - d->format == Format_RGB666 || - d->format == Format_RGB888 || - d->format == Format_RGB444)) - { - return; - } - detach(); - d->format = (enable ? Format_ARGB32 : Format_RGB32); -} - - -/*! - \fn bool QImage::create(int width, int height, int depth, int numColors, Endian bitOrder) - - Sets the image \a width, \a height, \a depth, its number of colors - (in \a numColors), and bit order. Returns true if successful, or - false if the parameters are incorrect or if memory cannot be - allocated. - - The \a width and \a height is limited to 32767. \a depth must be - 1, 8, or 32. If \a depth is 1, \a bitOrder must be set to - either QImage::LittleEndian or QImage::BigEndian. For other depths - \a bitOrder must be QImage::IgnoreEndian. - - This function allocates a color table and a buffer for the image - data. The image data is not initialized. The image buffer is - allocated as a single block that consists of a table of scanLine() - pointers (jumpTable()) and the image data (bits()). - - Use a QImage constructor instead. -*/ -bool QImage::create(int width, int height, int depth, int numColors, Endian bitOrder) -{ - if (d && !d->ref.deref()) - delete d; - d = QImageData::create(QSize(width, height), formatFor(depth, bitOrder), numColors); - return true; -} - -/*! - \fn bool QImage::create(const QSize& size, int depth, int numColors, Endian bitOrder) - \overload - - The width and height are specified in the \a size argument. - - Use a QImage constructor instead. -*/ -bool QImage::create(const QSize& size, int depth, int numColors, QImage::Endian bitOrder) -{ - if (d && !d->ref.deref()) - delete d; - d = QImageData::create(size, formatFor(depth, bitOrder), numColors); - return true; -} -#endif // QT3_SUPPORT /***************************************************************************** Internal routines for converting image depth. @@ -4022,30 +3606,6 @@ QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Q return image; } -#ifdef QT3_SUPPORT -/*! - Converts the depth (bpp) of the image to the given \a depth and - returns the converted image. The original image is not changed. - Returns this image if \a depth is equal to the image depth, or a - null image if this image cannot be converted. The \a depth - argument must be 1, 8 or 32. If the image needs to be modified to - fit in a lower-resolution result (e.g. converting from 32-bit to - 8-bit), use the \a flags to specify how you'd prefer this to - happen. - - Use the convertToFormat() function instead. -*/ - -QImage QImage::convertDepth(int depth, Qt::ImageConversionFlags flags) const -{ - if (!d || d->depth == depth) - return *this; - - Format format = formatFor (depth, QImage::LittleEndian); - return convertToFormat(format, flags); -} -#endif - /*! \fn bool QImage::valid(const QPoint &pos) const @@ -4264,41 +3824,6 @@ void QImage::setPixel(int x, int y, uint index_or_rgb) } } -#ifdef QT3_SUPPORT -/*! - Converts the bit order of the image to the given \a bitOrder and - returns the converted image. The original image is not changed. - Returns this image if the given \a bitOrder is equal to the image - current bit order, or a null image if this image cannot be - converted. - - Use convertToFormat() instead. -*/ - -QImage QImage::convertBitOrder(Endian bitOrder) const -{ - if (!d || isNull() || d->depth != 1 || !(bitOrder == BigEndian || bitOrder == LittleEndian)) - return QImage(); - - if ((d->format == Format_Mono && bitOrder == BigEndian) - || (d->format == Format_MonoLSB && bitOrder == LittleEndian)) - return *this; - - QImage image(d->width, d->height, d->format == Format_Mono ? Format_MonoLSB : Format_Mono); - - const uchar *data = d->data; - const uchar *end = data + d->nbytes; - uchar *ndata = image.d->data; - while (data < end) - *ndata++ = bitflip[*data++]; - - image.setDotsPerMeterX(dotsPerMeterX()); - image.setDotsPerMeterY(dotsPerMeterY()); - - image.d->colortable = d->colortable; - return image; -} -#endif /*! Returns true if all the colors in the image are shades of gray (i.e. their red, green and blue components are equal); otherwise @@ -5283,66 +4808,6 @@ QDataStream &operator>>(QDataStream &s, QImage &image) #endif // QT_NO_DATASTREAM -#ifdef QT3_SUPPORT -/*! - \fn QImage QImage::convertDepthWithPalette(int depth, QRgb* palette, int palette_count, Qt::ImageConversionFlags flags) const - - Returns an image with the given \a depth, using the \a - palette_count colors pointed to by \a palette. If \a depth is 1 or - 8, the returned image will have its color table ordered in the - same way as \a palette. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a flags to - specify how you'd prefer this to happen. - - Note: currently no closest-color search is made. If colors are - found that are not in the palette, the palette may not be used at - all. This result should not be considered valid because it may - change in future implementations. - - Currently inefficient for non-32-bit images. - - Use the convertToFormat() function in combination with the - setColorTable() function instead. -*/ -QImage QImage::convertDepthWithPalette(int d, QRgb* palette, int palette_count, Qt::ImageConversionFlags flags) const -{ - Format f = formatFor(d, QImage::LittleEndian); - QVector<QRgb> colortable; - for (int i = 0; i < palette_count; ++i) - colortable.append(palette[i]); - return convertToFormat(f, colortable, flags); -} - -/*! - \relates QImage - - Copies a block of pixels from \a src to \a dst. The pixels - copied from source (src) are converted according to - \a flags if it is incompatible with the destination - (\a dst). - - \a sx, \a sy is the top-left pixel in \a src, \a dx, \a dy is the - top-left position in \a dst and \a sw, \a sh is the size of the - copied block. The copying is clipped if areas outside \a src or \a - dst are specified. If \a sw is -1, it is adjusted to - src->width(). Similarly, if \a sh is -1, it is adjusted to - src->height(). - - Currently inefficient for non 32-bit images. - - Use copy() or QPainter::drawImage() instead. -*/ -void bitBlt(QImage *dst, int dx, int dy, const QImage *src, int sx, int sy, int sw, int sh, - Qt::ImageConversionFlags flags) -{ - if (dst->isNull() || src->isNull()) - return; - QPainter p(dst); - p.drawImage(QPoint(dx, dy), *src, QRect(sx, sy, sw, sh), flags); -} -#endif /*! \fn bool QImage::operator==(const QImage & image) const @@ -6322,24 +5787,6 @@ int QImage::bitPlaneCount() const return bpc; } - -#ifdef QT3_SUPPORT -#if defined(Q_WS_X11) -QT_BEGIN_INCLUDE_NAMESPACE -#include <private/qt_x11_p.h> -QT_END_INCLUDE_NAMESPACE -#endif - -QImage::Endian QImage::systemBitOrder() -{ -#if defined(Q_WS_X11) - return BitmapBitOrder(X11->display) == MSBFirst ? BigEndian : LittleEndian; -#else - return BigEndian; -#endif -} -#endif - /*! \fn QImage QImage::copy(const QRect &rect, Qt::ImageConversionFlags flags) const \compat diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 496fe93c54..849f731f5e 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -283,50 +283,6 @@ public: void setText(const char* key, const char* lang, const QString&); #endif -#ifdef QT3_SUPPORT - enum Endian { BigEndian, LittleEndian, IgnoreEndian }; - QT3_SUPPORT_CONSTRUCTOR QImage(int width, int height, int depth, int numColors=0, Endian bitOrder=IgnoreEndian); - QT3_SUPPORT_CONSTRUCTOR QImage(const QSize&, int depth, int numColors=0, Endian bitOrder=IgnoreEndian); - QT3_SUPPORT_CONSTRUCTOR QImage(uchar *data, int w, int h, int depth, const QRgb *colortable, int numColors, Endian bitOrder); -#ifdef Q_WS_QWS - QT3_SUPPORT_CONSTRUCTOR QImage(uchar *data, int w, int h, int depth, int pbl, const QRgb *colortable, int numColors, Endian bitOrder); -#endif - inline QT3_SUPPORT Endian bitOrder() const { - Format f = format(); - return f == Format_Mono ? BigEndian : (f == Format_MonoLSB ? LittleEndian : IgnoreEndian); - } - QT3_SUPPORT QImage convertDepth(int, Qt::ImageConversionFlags flags = Qt::AutoColor) const; - QT3_SUPPORT QImage convertDepthWithPalette(int, QRgb* p, int pc, Qt::ImageConversionFlags flags = Qt::AutoColor) const; - QT3_SUPPORT QImage convertBitOrder(Endian) const; - QT3_SUPPORT bool hasAlphaBuffer() const; - QT3_SUPPORT void setAlphaBuffer(bool); - QT3_SUPPORT uchar **jumpTable(); - QT3_SUPPORT const uchar * const *jumpTable() const; - inline QT3_SUPPORT void reset() { *this = QImage(); } - static inline QT3_SUPPORT Endian systemByteOrder() - { return QSysInfo::ByteOrder == QSysInfo::BigEndian ? BigEndian : LittleEndian; } - inline QT3_SUPPORT QImage swapRGB() const { return rgbSwapped(); } - inline QT3_SUPPORT QImage mirror(bool horizontally = false, bool vertically = true) const - { return mirrored(horizontally, vertically); } - QT3_SUPPORT bool create(const QSize&, int depth, int numColors=0, Endian bitOrder=IgnoreEndian); - QT3_SUPPORT bool create(int width, int height, int depth, int numColors=0, Endian bitOrder=IgnoreEndian); - inline QT3_SUPPORT QImage xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } - inline QT3_SUPPORT QImage smoothScale(int w, int h, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio) const - { return scaled(QSize(w, h), mode, Qt::SmoothTransformation); } - inline QImage QT3_SUPPORT smoothScale(const QSize &s, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio) const - { return scaled(s, mode, Qt::SmoothTransformation); } - inline QT3_SUPPORT QImage scaleWidth(int w) const { return scaledToWidth(w); } - inline QT3_SUPPORT QImage scaleHeight(int h) const { return scaledToHeight(h); } - inline QT3_SUPPORT void invertPixels(bool invertAlpha) { invertAlpha ? invertPixels(InvertRgba) : invertPixels(InvertRgb); } - inline QT3_SUPPORT QImage copy(int x, int y, int w, int h, Qt::ImageConversionFlags) const - { return copy(QRect(x, y, w, h)); } - inline QT3_SUPPORT QImage copy(const QRect &rect, Qt::ImageConversionFlags) const - { return copy(rect); } - static QT3_SUPPORT Endian systemBitOrder(); - inline QT3_SUPPORT_CONSTRUCTOR QImage(const QByteArray &data) - { d = 0; *this = QImage::fromData(data); } -#endif - protected: virtual int metric(PaintDeviceMetric metric) const; @@ -362,11 +318,6 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QImage &); Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QImage &); #endif -#ifdef QT3_SUPPORT -Q_GUI_EXPORT QT3_SUPPORT void bitBlt(QImage* dst, int dx, int dy, const QImage* src, - int sx=0, int sy=0, int sw=-1, int sh=-1, Qt::ImageConversionFlags flags = Qt::AutoColor); -#endif - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index db6620b39c..93ab8a78ba 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -79,9 +79,6 @@ struct Q_GUI_EXPORT QImageData { // internal image data int nbytes; // number of bytes data QVector<QRgb> colortable; uchar *data; -#ifdef QT3_SUPPORT - uchar **jumptable; -#endif QImage::Format format; int bytes_per_line; int ser_no; // serial number diff --git a/src/gui/image/qmovie.h b/src/gui/image/qmovie.h index b64df29c41..98fcf68ee6 100644 --- a/src/gui/image/qmovie.h +++ b/src/gui/image/qmovie.h @@ -51,11 +51,6 @@ #include <QtCore/qobject.h> #include <QtGui/qimagereader.h> -#ifdef QT3_SUPPORT -#include <QtGui/qimage.h> -#include <QtGui/qpixmap.h> -#endif - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -151,21 +146,6 @@ public Q_SLOTS: private: Q_DISABLE_COPY(QMovie) Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame()) - -#ifdef QT3_SUPPORT -public: - inline QT3_SUPPORT bool isNull() const { return isValid(); } - inline QT3_SUPPORT int frameNumber() const { return currentFrameNumber(); } - inline QT3_SUPPORT bool running() const { return state() == Running; } - inline QT3_SUPPORT bool paused() const { return state() == Paused; } - inline QT3_SUPPORT bool finished() const { return state() == NotRunning; } - inline QT3_SUPPORT void restart() { stop(); start(); } - inline QT3_SUPPORT QImage frameImage() const { return currentImage(); } - inline QT3_SUPPORT QPixmap framePixmap() const { return currentPixmap(); } - inline QT3_SUPPORT void step() { jumpToNextFrame(); } - inline QT3_SUPPORT void pause() { setPaused(true); } - inline QT3_SUPPORT void unpause() { setPaused(false); } -#endif }; QT_END_NAMESPACE diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index 8face87a92..f09cf1b0ef 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -45,8 +45,7 @@ #include "private/qpaintengine_raster_p.h" -#include "private/qapplication_p.h" -#include "private/qgraphicssystem_p.h" +#include "private/qguiapplication_p.h" #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) #include <qx11info_x11.h> @@ -70,7 +69,7 @@ typedef struct { } BITMAPINFO_MASK; -QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer, QWidget *) +QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer, QWindow *) { #ifndef Q_WS_WINCE Q_UNUSED(isTextBuffer); @@ -147,102 +146,9 @@ QImage::Format QNativeImage::systemFormat() return QImage::Format_RGB32; } - -#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM) - -QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget) - : xshmimg(0), xshmpm(0) -{ - if (!X11->use_mitshm) { - image = QImage(width, height, format); - // follow good coding practice and set xshminfo attributes, though values not used in this case - xshminfo.readOnly = true; - xshminfo.shmaddr = 0; - xshminfo.shmid = 0; - xshminfo.shmseg = 0; - return; - } - - QX11Info info = widget->x11Info(); - - int dd = info.depth(); - Visual *vis = (Visual*) info.visual(); - - xshmimg = XShmCreateImage(X11->display, vis, dd, ZPixmap, 0, &xshminfo, width, height); - if (!xshmimg) { - qWarning("QNativeImage: Unable to create shared XImage."); - return; - } - - bool ok; - xshminfo.shmid = shmget(IPC_PRIVATE, xshmimg->bytes_per_line * xshmimg->height, - IPC_CREAT | 0777); - ok = xshminfo.shmid != -1; - if (ok) { - xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0); - xshminfo.shmaddr = xshmimg->data; - ok = (xshminfo.shmaddr != (char*)-1); - if (ok) - image = QImage((uchar *)xshmimg->data, width, height, format); - } - xshminfo.readOnly = false; - if (ok) { - ok = XShmAttach(X11->display, &xshminfo); - XSync(X11->display, False); - if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1) - qWarning() << "Error while marking the shared memory segment to be destroyed"; - } - if (!ok) { - qWarning() << "QNativeImage: Unable to attach to shared memory segment."; - if (xshmimg->data) { - free(xshmimg->data); - xshmimg->data = 0; - } - XDestroyImage(xshmimg); - xshmimg = 0; - if (xshminfo.shmaddr) - shmdt(xshminfo.shmaddr); - if (xshminfo.shmid != -1) - shmctl(xshminfo.shmid, IPC_RMID, 0); - return; - } - if (X11->use_mitshm_pixmaps) { - xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data, - &xshminfo, width, height, dd); - if (!xshmpm) { - qWarning() << "QNativeImage: Unable to create shared Pixmap."; - } - } -} - - -QNativeImage::~QNativeImage() -{ - if (!xshmimg) - return; - - if (xshmpm) { - XFreePixmap(X11->display, xshmpm); - xshmpm = 0; - } - XShmDetach(X11->display, &xshminfo); - xshmimg->data = 0; - XDestroyImage(xshmimg); - xshmimg = 0; - shmdt(xshminfo.shmaddr); - shmctl(xshminfo.shmid, IPC_RMID, 0); -} - -QImage::Format QNativeImage::systemFormat() -{ - if (QX11Info::appDepth() == 16) - return QImage::Format_RGB16; - return QImage::Format_RGB32; -} - #elif defined(Q_WS_MAC) -QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *widget) +QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *) : image(width, height, format) { @@ -267,7 +173,7 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* #endif cg = CGBitmapContextCreate(image.bits(), width, height, 8, image.bytesPerLine(), - QCoreGraphicsPaintEngine::macDisplayColorSpace(widget), cgflags); + QCoreGraphicsPaintEngine::macDisplayColorSpace(0), cgflags); CGContextTranslateCTM(cg, 0, height); CGContextScaleCTM(cg, 1, -1); @@ -289,7 +195,7 @@ QImage::Format QNativeImage::systemFormat() #else // other platforms... -QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *) +QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *) : image(width, height, format) { @@ -302,11 +208,7 @@ QNativeImage::~QNativeImage() QImage::Format QNativeImage::systemFormat() { -#ifdef Q_WS_QPA - return QApplicationPrivate::platformIntegration()->screens().at(0)->format(); -#else - return QImage::Format_RGB32; -#endif + return QGuiApplicationPrivate::platformIntegration()->screens().at(0)->format(); } #endif // platforms diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/image/qnativeimage_p.h index 12aa0f021a..00897d4d54 100644 --- a/src/gui/image/qnativeimage_p.h +++ b/src/gui/image/qnativeimage_p.h @@ -58,9 +58,6 @@ #ifdef Q_WS_WIN #include "qt_windows.h" -#elif defined(Q_WS_X11) -#include <private/qt_x11_p.h> - #elif defined(Q_WS_MAC) #include <private/qt_mac_p.h> @@ -68,12 +65,12 @@ QT_BEGIN_NAMESPACE -class QWidget; +class QWindow; class QNativeImage { public: - QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWidget *widget = 0); + QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWindow *window = 0); ~QNativeImage(); inline int width() const; @@ -88,11 +85,6 @@ public: HBITMAP bitmap; HBITMAP null_bitmap; -#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM) - XImage *xshmimg; - Pixmap xshmpm; - XShmSegmentInfo xshminfo; - #elif defined(Q_WS_MAC) CGContextRef cg; #endif diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 3f38c0ce2a..9fd4fbd59c 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -47,6 +47,7 @@ #include <private/qfactoryloader_p.h> #include <private/qpaintengine_pic_p.h> #include <private/qfont_p.h> +#include <qguiapplication.h> #include "qdatastream.h" #include "qfile.h" @@ -1217,7 +1218,6 @@ QDataStream &operator>>(QDataStream &s, QPicture &r) QT_BEGIN_INCLUDE_NAMESPACE #include "qregexp.h" -#include "qapplication.h" #include "qpictureformatplugin.h" QT_END_INCLUDE_NAMESPACE diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h index c478ed962e..3bcd87e5a0 100644 --- a/src/gui/image/qpicture.h +++ b/src/gui/image/qpicture.h @@ -104,9 +104,6 @@ protected: QPicture(QPicturePrivate &data); int metric(PaintDeviceMetric m) const; -#ifdef QT3_SUPPORT - inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; } -#endif private: bool exec(QPainter *p, QDataStream &ds, int i); diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 34804e5311..a484bd408a 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -52,9 +52,7 @@ #include "qpainter.h" #include "qdatastream.h" #include "qbuffer.h" -#include "qapplication.h" -#include <private/qapplication_p.h> -#include <private/qgraphicssystem_p.h> +#include <private/qguiapplication_p.h> #include <private/qwidget_p.h> #include "qevent.h" #include "qfile.h" @@ -65,6 +63,7 @@ #include "qimagewriter.h" #include "qpaintengine.h" #include "qthread.h" +#include "qdebug.h" #ifdef Q_WS_MAC # include "private/qt_mac_p.h" @@ -86,7 +85,7 @@ #endif #include "qpixmap_raster_p.h" -#include "private/qstylehelper_p.h" +#include "private/qhexstring_p.h" QT_BEGIN_NAMESPACE @@ -98,25 +97,17 @@ Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap) static bool qt_pixmap_thread_test() { - if (!qApp) { + if (!QCoreApplication::instance()) { qFatal("QPixmap: Must construct a QApplication before a QPaintDevice"); return false; } if (qApp->thread() != QThread::currentThread()) { bool fail = false; -#if defined (Q_WS_X11) - if (!QApplication::testAttribute(Qt::AA_X11InitThreads)) - fail = true; -#elif defined (Q_WS_QPA) - if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) { printf("Lighthouse plugin does not support threaded pixmaps!\n"); fail = true; } -#else - if (QApplicationPrivate::graphics_system_name != QLatin1String("raster")) - fail = true; -#endif if (fail) { qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread"); return false; @@ -130,16 +121,8 @@ void QPixmap::init(int w, int h, Type type) init(w, h, int(type)); } -extern QApplication::Type qt_appType; - void QPixmap::init(int w, int h, int type) { - if (qt_appType == QApplication::Tty) { - qWarning("QPixmap: Cannot create a QPixmap when no GUI is being used"); - data = 0; - return; - } - if ((w > 0 && h > 0) || type == QPixmapData::BitmapType) data = QPixmapData::create(w, h, (QPixmapData::PixelType) type); else @@ -657,65 +640,6 @@ int QPixmap::depth() const pixmap = pixmap.copy(QRect(QPoint(0, 0), size)); \endcode */ -#ifdef QT3_SUPPORT -void QPixmap::resize_helper(const QSize &s) -{ - int w = s.width(); - int h = s.height(); - if (w < 1 || h < 1) { - *this = QPixmap(); - return; - } - - 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), pd ? pd->type : QPixmapData::PixmapType); - bool uninit = false; -#if defined(Q_WS_X11) - 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 = pd && pd->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0; - if (macData) - uninit = macData->uninit; -#endif - if (!uninit && !isNull()) { - // Copy old pixmap - if (hasAlphaChannel()) - pm.fill(Qt::transparent); - QPainter p(&pm); - p.drawPixmap(0, 0, *this, 0, 0, qMin(width(), w), qMin(height(), h)); - } - -#if defined(Q_WS_X11) - if (x11Data && x11Data->x11_mask) { - QPixmapData *newPd = pm.pixmapData(); - QX11PixmapData *pmData = (newPd && newPd->classId() == QPixmapData::X11Class) - ? static_cast<QX11PixmapData*>(newPd) : 0; - if (pmData) { - pmData->x11_mask = (Qt::HANDLE)XCreatePixmap(X11->display, - RootWindow(x11Data->xinfo.display(), - x11Data->xinfo.screen()), - w, h, 1); - GC gc = XCreateGC(X11->display, pmData->x11_mask, 0, 0); - XCopyArea(X11->display, x11Data->x11_mask, pmData->x11_mask, gc, 0, 0, - qMin(width(), w), qMin(height(), h), 0, 0); - XFreeGC(X11->display, gc); - } - } -#endif - *this = pm; -} -#endif /*! \fn void QPixmap::resize(int width, int height) @@ -986,21 +910,24 @@ bool QPixmap::doImageIO(QImageWriter *writer, int quality) const return writer->write(toImage()); } - -// The implementation (and documentation) of -// QPixmap::fill(const QWidget *, const QPoint &) -// is in qwidget.cpp - /*! - \fn void QPixmap::fill(const QWidget *widget, int x, int y) + \fn void QPixmap::fill(const QPaintDevice *device, int x, int y) \overload - Fills the pixmap with the \a widget's background color or pixmap. + \obsolete + + Fills the pixmap with the \a device's background color or pixmap. The given point, (\a x, \a y), defines an offset in widget coordinates to which the pixmap's top-left pixel will be mapped to. */ +void QPixmap::fill(const QPaintDevice *, const QPoint &) +{ + qWarning() << "QPixmap::fill(const QPaintDevice *device, const QPoint &offset) is deprecated, ignored"; +} + + /*! Fills the pixmap with the given \a color. @@ -1072,6 +999,7 @@ qint64 QPixmap::cacheKey() const return data->cacheKey(); } +#if 0 static void sendResizeEvents(QWidget *target) { QResizeEvent e(target->size(), QSize()); @@ -1084,9 +1012,10 @@ static void sendResizeEvents(QWidget *target) sendResizeEvents(child); } } +#endif /*! - \fn QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rectangle) + \fn QPixmap QPixmap::grabWidget(QPaintDevice * widget, const QRect &rectangle) Creates a pixmap and paints the given \a widget, restricted by the given \a rectangle, in it. If the \a widget has any children, then @@ -1115,8 +1044,13 @@ static void sendResizeEvents(QWidget *target) \sa grabWindow() */ -QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect) +QPixmap QPixmap::grabWidget(QPaintDevice *, const QRect &) { + // ### Qt5: should we keep or remove this method? + // SC solution would be to install a callback form QtWidgets, but ugly. + qWarning() << "QPixmap::grabWidget is deprecated, use QWidget::render() instead"; + return QPixmap(); +#if 0 if (!widget) return QPixmap(); @@ -1142,6 +1076,7 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect) widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask, true); return res; +#endif } /*! @@ -1217,7 +1152,6 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect) graphics system is explicitly enabled. \sa detach() - \sa QApplication::setGraphicsSystem() */ Qt::HANDLE QPixmap::handle() const @@ -1236,104 +1170,6 @@ Qt::HANDLE QPixmap::handle() const #endif -#ifdef QT3_SUPPORT -static Qt::ImageConversionFlags colorModeToFlags(QPixmap::ColorMode mode) -{ - Qt::ImageConversionFlags flags = Qt::AutoColor; - switch (mode) { - case QPixmap::Color: - flags |= Qt::ColorOnly; - break; - case QPixmap::Mono: - flags |= Qt::MonoOnly; - break; - default: - break;// Nothing. - } - return flags; -} - -/*! - Use the constructor that takes a Qt::ImageConversionFlag instead. -*/ - -QPixmap::QPixmap(const QString& fileName, const char *format, ColorMode mode) - : QPaintDevice() -{ - init(0, 0, QPixmapData::PixmapType); - if (!qt_pixmap_thread_test()) - return; - - load(fileName, format, colorModeToFlags(mode)); -} - -/*! - Constructs a pixmap from the QImage \a image. - - Use the static fromImage() function instead. -*/ -QPixmap::QPixmap(const QImage& image) - : QPaintDevice() -{ - init(0, 0, QPixmapData::PixmapType); - if (!qt_pixmap_thread_test()) - return; - - if (data && data->pixelType() == QPixmapData::BitmapType) - *this = QBitmap::fromImage(image); - else - *this = fromImage(image); -} - -/*! - \overload - - Converts the given \a image to a pixmap that is assigned to this - pixmap. - - Use the static fromImage() function instead. -*/ - -QPixmap &QPixmap::operator=(const QImage &image) -{ - if (data && data->pixelType() == QPixmapData::BitmapType) - *this = QBitmap::fromImage(image); - else - *this = fromImage(image); - return *this; -} - -/*! - Use the load() function that takes a Qt::ImageConversionFlag instead. -*/ - -bool QPixmap::load(const QString &fileName, const char *format, ColorMode mode) -{ - return load(fileName, format, colorModeToFlags(mode)); -} - -/*! - Use the loadFromData() function that takes a Qt::ImageConversionFlag instead. -*/ - -bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, ColorMode mode) -{ - return loadFromData(buf, len, format, colorModeToFlags(mode)); -} - -/*! - Use the static fromImage() function instead. -*/ -bool QPixmap::convertFromImage(const QImage &image, ColorMode mode) -{ - if (data && data->pixelType() == QPixmapData::BitmapType) - *this = QBitmap::fromImage(image, colorModeToFlags(mode)); - else - *this = fromImage(image, colorModeToFlags(mode)); - return !isNull(); -} - -#endif /***************************************************************************** QPixmap stream functions @@ -1379,34 +1215,6 @@ QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap) #endif // QT_NO_DATASTREAM -#ifdef QT3_SUPPORT -Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy, - const QPixmap *src, int sx, int sy, int sw, int sh) -{ - Q_ASSERT_X(dst, "::copyBlt", "Destination pixmap must be non-null"); - Q_ASSERT_X(src, "::copyBlt", "Source pixmap must be non-null"); - - if (src->hasAlphaChannel()) { - if (dst->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) { - QPainter p(dst); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawPixmap(dx, dy, *src, sx, sy, sw, sh); - } else { - QImage image = dst->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); - QPainter p(&image); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawPixmap(dx, dy, *src, sx, sy, sw, sh); - p.end(); - *dst = QPixmap::fromImage(image); - } - } else { - QPainter p(dst); - p.drawPixmap(dx, dy, *src, sx, sy, sw, sh); - } - -} -#endif - /*! \internal */ @@ -1992,7 +1800,7 @@ int QPixmap::defaultDepth() #elif defined(Q_OS_SYMBIAN) return S60->screenDepth; #elif defined(Q_WS_QPA) - return 32; //LITE: use graphicssystem (we should do that in general) + return 32; //LITE: ### use graphicssystem (we should do that in general) #endif } @@ -2084,9 +1892,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) if (image.isNull()) return QPixmap(); - QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); - QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType) - : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType)); + QScopedPointer<QPixmapData> data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::PixmapType)); data->fromImage(image, flags); return QPixmap(data.take()); } @@ -2105,9 +1911,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) */ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType) - : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType)); + QScopedPointer<QPixmapData> data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::PixmapType)); data->fromImageReader(imageReader, flags); return QPixmap(data.take()); } diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index f2e79c14f4..1341ad2b1b 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -103,8 +103,8 @@ public: static int defaultDepth(); void fill(const QColor &fillColor = Qt::white); - void fill(const QWidget *widget, const QPoint &ofs); - inline void fill(const QWidget *widget, int xofs, int yofs) { fill(widget, QPoint(xofs, yofs)); } + void fill(const QPaintDevice *device, const QPoint &ofs); + inline void fill(const QPaintDevice *device, int xofs, int yofs) { fill(device, QPoint(xofs, yofs)); } QBitmap mask() const; void setMask(const QBitmap &); @@ -122,8 +122,8 @@ public: QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const; static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1); - static QPixmap grabWidget(QWidget *widget, const QRect &rect); - static inline QPixmap grabWidget(QWidget *widget, int x=0, int y=0, int w=-1, int h=-1) + static QPixmap grabWidget(QPaintDevice *widget, const QRect &rect); + static inline QPixmap grabWidget(QPaintDevice *widget, int x=0, int y=0, int w=-1, int h=-1) { return grabWidget(widget, QRect(x, y, w, h)); } @@ -224,26 +224,6 @@ public: protected: int metric(PaintDeviceMetric) const; -#ifdef QT3_SUPPORT -public: - enum ColorMode { Auto, Color, Mono }; - QT3_SUPPORT_CONSTRUCTOR QPixmap(const QString& fileName, const char *format, ColorMode mode); - QT3_SUPPORT bool load(const QString& fileName, const char *format, ColorMode mode); - QT3_SUPPORT bool loadFromData(const uchar *buf, uint len, const char* format, ColorMode mode); - QT3_SUPPORT_CONSTRUCTOR QPixmap(const QImage& image); - QT3_SUPPORT QPixmap &operator=(const QImage &); - inline QT3_SUPPORT QImage convertToImage() const { return toImage(); } - QT3_SUPPORT bool convertFromImage(const QImage &, ColorMode mode); - inline QT3_SUPPORT operator QImage() const { return toImage(); } - inline QT3_SUPPORT QPixmap xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } - inline QT3_SUPPORT bool selfMask() const { return false; } -private: - void resize_helper(const QSize &s); -public: - inline QT3_SUPPORT void resize(const QSize &s) { resize_helper(s); } - inline QT3_SUPPORT void resize(int width, int height) { resize_helper(QSize(width, height)); } -#endif - private: QExplicitlySharedDataPointer<QPixmapData> data; @@ -320,14 +300,6 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPixmap &); Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &); #endif -/***************************************************************************** - QPixmap (and QImage) helper functions -*****************************************************************************/ -#ifdef QT3_SUPPORT -QT3_SUPPORT Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy, const QPixmap *src, - int sx=0, int sy=0, int sw=-1, int sh=-1); -#endif // QT3_SUPPORT - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index e2cd745e7c..da1c8e135d 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -44,8 +44,7 @@ #include <qpainter.h> #include <qimage.h> -#include <private/qapplication_p.h> -#include <private/qgraphicssystem_p.h> +#include <private/qguiapplication_p.h> #include <private/qblittable_p.h> #include <private/qdrawhelper_p.h> @@ -99,7 +98,7 @@ void QBlittablePixmapData::resize(int width, int height) delete m_engine; m_engine = 0; #ifdef Q_WS_QPA - d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth(); + d = QGuiApplicationPrivate::platformIntegration()->screens().at(0)->depth(); #endif w = width; h = height; diff --git a/src/gui/image/qpixmap_qpa.cpp b/src/gui/image/qpixmap_qpa.cpp index 61be2169d0..da301baa19 100644 --- a/src/gui/image/qpixmap_qpa.cpp +++ b/src/gui/image/qpixmap_qpa.cpp @@ -40,10 +40,9 @@ ****************************************************************************/ #include <qpixmap.h> -#include <private/qgraphicssystem_p.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) { - return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h); + return QGuiApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h); } diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp deleted file mode 100644 index 3c1907089d..0000000000 --- a/src/gui/image/qpixmap_qws.cpp +++ /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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qpixmap.h> -#include <qapplication.h> -#include <qwidget.h> -#include <qdesktopwidget.h> -#include <qscreen_qws.h> -#include <qwsdisplay_qws.h> -#include <private/qdrawhelper_p.h> -#include <private/qpixmap_raster_p.h> - - -QT_BEGIN_NAMESPACE - -QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) -{ - QWidget *widget = QWidget::find(window); - if (!widget) - return QPixmap(); - - QRect grabRect = widget->frameGeometry(); - if (!widget->isWindow()) - grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint())); - if (w < 0) - w = widget->width() - x; - if (h < 0) - h = widget->height() - y; - grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint())); - - QScreen *screen = qt_screen; - QDesktopWidget *desktop = QApplication::desktop(); - if (!desktop) - return QPixmap(); - if (desktop->numScreens() > 1) { - const int screenNo = desktop->screenNumber(widget); - if (screenNo != -1) - screen = qt_screen->subScreens().at(screenNo); - grabRect = grabRect.translated(-screen->region().boundingRect().topLeft()); - } - - if (screen->pixelFormat() == QImage::Format_Invalid) { - qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer"); - return QPixmap(); - } - - if (screen->isTransformed()) { - const QSize screenSize(screen->width(), screen->height()); - grabRect = screen->mapToDevice(grabRect, screenSize); - } - - QWSDisplay::grab(false); - QPixmap pixmap; - QImage img(screen->base(), - screen->deviceWidth(), screen->deviceHeight(), - screen->linestep(), screen->pixelFormat()); - img = img.copy(grabRect); - QWSDisplay::ungrab(); - - if (screen->isTransformed()) { - QMatrix matrix; - switch (screen->transformOrientation()) { - case 1: matrix.rotate(90); break; - case 2: matrix.rotate(180); break; - case 3: matrix.rotate(270); break; - default: break; - } - img = img.transformed(matrix); - } - - if (screen->pixelType() == QScreen::BGRPixel) - img = img.rgbSwapped(); - - return QPixmap::fromImage(img); -} - -QRgb* QPixmap::clut() const -{ - if (data && data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); - return d->image.colorTable().data(); - } - - return 0; -} - -int QPixmap::numCols() const -{ - return colorCount(); -} - -int QPixmap::colorCount() const -{ - if (data && data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); - return d->image.colorCount(); - } - - return 0; -} - -const uchar* QPixmap::qwsBits() const -{ - if (data && data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); - return d->image.bits(); - } - - return 0; -} - -int QPixmap::qwsBytesPerLine() const -{ - if (data && data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); - return d->image.bytesPerLine(); - } - - return 0; -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 8222d714dc..a56504ed94 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -43,8 +43,7 @@ #include <QtCore/qbuffer.h> #include <QtGui/qbitmap.h> #include <QtGui/qimagereader.h> -#include <private/qgraphicssystem_p.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> #include <private/qimagepixmapcleanuphooks_p.h> QT_BEGIN_NAMESPACE @@ -54,12 +53,7 @@ const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, QPixmapData *QPixmapData::create(int w, int h, PixelType type) { - QPixmapData *data; - QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); - if (gs) - data = gs->createPixmapData(static_cast<QPixmapData::PixelType>(type)); - else - data = QGraphicsSystem::createDefaultPixmapData(static_cast<QPixmapData::PixelType>(type)); + QPixmapData *data = QGuiApplicationPrivate::platformIntegration()->createPixmapData(static_cast<QPixmapData::PixelType>(type)); data->resize(w, h); return data; } @@ -95,12 +89,7 @@ QPixmapData::~QPixmapData() QPixmapData *QPixmapData::createCompatiblePixmapData() const { - QPixmapData *d; - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (gs) - d = gs->createPixmapData(pixelType()); - else - d = QGraphicsSystem::createDefaultPixmapData(pixelType()); + QPixmapData *d = QGuiApplicationPrivate::platformIntegration()->createPixmapData(pixelType()); return d; } diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp index ec53dcb9c1..906d8ddd8e 100644 --- a/src/gui/image/qpixmapdatafactory.cpp +++ b/src/gui/image/qpixmapdatafactory.cpp @@ -60,8 +60,7 @@ # include <private/qpixmap_s60_p.h> #endif -#include "private/qapplication_p.h" -#include "private/qgraphicssystem_p.h" +#include "private/qguiapplication_p.h" QT_BEGIN_NAMESPACE @@ -76,22 +75,8 @@ public: QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type) { - if (QApplicationPrivate::graphicsSystem()) - return QApplicationPrivate::graphicsSystem()->createPixmapData(type); - -#if defined(Q_WS_X11) - return new QX11PixmapData(type); -#elif defined(Q_WS_WIN) - return new QRasterPixmapData(type); -#elif defined(Q_WS_MAC) - return new QMacPixmapData(type); -#elif defined(Q_WS_QPA) - return new QRasterPixmapData(type); -#elif defined(Q_OS_SYMBIAN) - return new QS60PixmapData(type); -#else -#error QSimplePixmapDataFactory::create() not implemented -#endif + // ### should we always use Raster instead? + return QGuiApplicationPrivate::platformIntegration()->createPixmapData(type); } Q_GLOBAL_STATIC(QSimplePixmapDataFactory, factory) diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index c05afb052e..ecab3d7a41 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -48,8 +48,7 @@ #include "qpixmapfilter_p.h" #include "qvarlengtharray.h" -#include "private/qapplication_p.h" -#include "private/qgraphicssystem_p.h" +#include "private/qguiapplication_p.h" #include "private/qpaintengineex_p.h" #include "private/qpaintengine_raster_p.h" #include "qmath.h" |