diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/image.pri | 1 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 15 | ||||
-rw-r--r-- | src/gui/image/qimage_avx.cpp | 57 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 29 | ||||
-rw-r--r-- | src/gui/image/qjpeghandler.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 22 | ||||
-rw-r--r-- | src/gui/image/qpixmap.h | 7 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 7 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster_p.h | 1 | ||||
-rw-r--r-- | src/gui/image/qplatformpixmap.h | 6 |
10 files changed, 56 insertions, 95 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index a80ab4a2fe..5b9bc4b56f 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -77,4 +77,3 @@ contains(QT_CONFIG, gif):include($$PWD/qgifhandler.pri) NEON_SOURCES += image/qimage_neon.cpp SSE2_SOURCES += image/qimage_sse2.cpp SSSE3_SOURCES += image/qimage_ssse3.cpp -AVX_SOURCES += image/qimage_avx.cpp diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 12ab5eaffa..61d524841d 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3922,20 +3922,7 @@ static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QIma void qInitImageConversions() { -#ifdef QT_COMPILER_SUPPORTS_AVX - if (qCpuHasFeature(AVX)) { - extern bool convert_ARGB_to_ARGB_PM_inplace_avx(QImageData *data, Qt::ImageConversionFlags); - inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_avx; - - extern void convert_RGB888_to_RGB32_avx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); - converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_avx; - converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_avx; - converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_avx; - return; - } -#endif - -#if defined(QT_COMPILER_SUPPORTS_SSE2) && !defined(__AVX__) +#if defined(QT_COMPILER_SUPPORTS_SSE2) if (qCpuHasFeature(SSE2)) { extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2; diff --git a/src/gui/image/qimage_avx.cpp b/src/gui/image/qimage_avx.cpp deleted file mode 100644 index d04ec5b3de..0000000000 --- a/src/gui/image/qimage_avx.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Intel Corporation -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <private/qsimd_p.h> - -#ifdef QT_COMPILER_SUPPORTS_AVX - -#ifndef __AVX__ -#error "AVX not enabled in this file, cannot proceed" -#endif - -#define convert_ARGB_to_ARGB_PM_inplace_sse2 convert_ARGB_to_ARGB_PM_inplace_avx -#include "qimage_sse2.cpp" - -#define qt_convert_rgb888_to_rgb32_ssse3 qt_convert_rgb888_to_rgb32_avx -#define convert_RGB888_to_RGB32_ssse3 convert_RGB888_to_RGB32_avx -#include "qimage_ssse3.cpp" - -#endif diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 636d86991b..091837b8b4 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -190,37 +190,36 @@ enum _qt_BuiltInFormatType { struct _qt_BuiltInFormatStruct { - _qt_BuiltInFormatType type; const char *extension; const char *mimeType; }; static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = { #ifndef QT_NO_IMAGEFORMAT_PNG - {_qt_PngFormat, "png", "image/png"}, + {"png", "image/png"}, #endif #ifndef QT_NO_IMAGEFORMAT_JPEG - {_qt_JpgFormat, "jpg", "image/jpeg"}, - {_qt_JpegFormat, "jpeg", "image/jpeg"}, + {"jpg", "image/jpeg"}, + {"jpeg", "image/jpeg"}, #endif #ifdef QT_BUILTIN_GIF_READER - {_qt_GifFormat, "gif", "image/gif"}, + {"gif", "image/gif"}, #endif #ifndef QT_NO_IMAGEFORMAT_BMP - {_qt_BmpFormat, "bmp", "image/bmp"}, + {"bmp", "image/bmp"}, #endif #ifndef QT_NO_IMAGEFORMAT_PPM - {_qt_PpmFormat, "ppm", "image/x-portable-pixmap"}, - {_qt_PgmFormat, "pgm", "image/x-portable-graymap"}, - {_qt_PbmFormat, "pbm", "image/x-portable-bitmap"}, + {"ppm", "image/x-portable-pixmap"}, + {"pgm", "image/x-portable-graymap"}, + {"pbm", "image/x-portable-bitmap"}, #endif #ifndef QT_NO_IMAGEFORMAT_XBM - {_qt_XbmFormat, "xbm", "image/x-xbitmap"}, + {"xbm", "image/x-xbitmap"}, #endif #ifndef QT_NO_IMAGEFORMAT_XPM - {_qt_XpmFormat, "xpm", "image/x-xpixmap"}, + {"xpm", "image/x-xpixmap"}, #endif - {_qt_NoFormat, "", ""} + {"", ""} }; static QImageIOHandler *createReadHandlerHelper(QIODevice *device, @@ -423,10 +422,8 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, QByteArray subType; int numFormats = _qt_NumFormats; while (device && numFormats >= 0) { - const _qt_BuiltInFormatStruct *formatStruct = &_qt_BuiltInFormats[currentFormat]; - const qint64 pos = device->pos(); - switch (formatStruct->type) { + switch (currentFormat) { #ifndef QT_NO_IMAGEFORMAT_PNG case _qt_PngFormat: if (QPngHandler::canRead(device)) @@ -482,7 +479,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (handler) { #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << formatStruct->extension + qDebug() << "QImageReader::createReadHandler: the" << _qt_BuiltInFormats[currentFormat].extension << "built-in handler can read this data"; #endif break; diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index 3f90bb42f0..3ca31030c5 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -871,14 +871,8 @@ QJpegHandler::QJpegHandler() // from qimage_ssse3.cpp if (false) { -# if defined(QT_COMPILER_SUPPORTS_AVX) - } else if (qCpuHasFeature(AVX)) { - rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_avx; -# endif -# ifndef __AVX__ } else if (qCpuHasFeature(SSSE3)) { rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_ssse3; -# endif } #endif // QT_COMPILER_SUPPORTS_SSSE3 } diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 6dced54d20..86c4dfbdca 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1617,6 +1617,28 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) } /*! + \fn QPixmap QPixmap::fromImage(QImage &&image, Qt::ImageConversionFlags flags) + \since 5.3 + \overload + + Converts the given \a image to a pixmap without copying if possible. +*/ + + +/*! + \internal +*/ +QPixmap QPixmap::fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags) +{ + if (image.isNull()) + return QPixmap(); + + QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); + data->fromImageInPlace(image, flags); + return QPixmap(data.take()); +} + +/*! \fn QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) Create a QPixmap from an image read directly from an \a imageReader. diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index f1fce03c80..0efd606283 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -131,6 +131,12 @@ public: QImage toImage() const; static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor); static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags = Qt::AutoColor); +#ifdef Q_COMPILER_RVALUE_REFS + static QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags = Qt::AutoColor) + { + return fromImageInPlace(image, flags); + } +#endif bool load(const QString& fileName, const char *format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); bool loadFromData(const uchar *buf, uint len, const char* format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); @@ -167,6 +173,7 @@ public: protected: int metric(PaintDeviceMetric) const; + static QPixmap fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor); private: QExplicitlySharedDataPointer<QPlatformPixmap> data; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index f9a017c281..be63430a78 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -135,11 +135,16 @@ bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char * void QRasterPlatformPixmap::fromImage(const QImage &sourceImage, Qt::ImageConversionFlags flags) { - Q_UNUSED(flags); QImage image = sourceImage; createPixmapForImage(image, flags, /* inplace = */false); } +void QRasterPlatformPixmap::fromImageInPlace(QImage &sourceImage, + Qt::ImageConversionFlags flags) +{ + createPixmapForImage(sourceImage, flags, /* inplace = */true); +} + void QRasterPlatformPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) { diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index cef8821888..b273d65c9f 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -69,6 +69,7 @@ public: void resize(int width, int height); bool fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags); void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + void fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags); void fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags); void copy(const QPlatformPixmap *data, const QRect &rect); diff --git a/src/gui/image/qplatformpixmap.h b/src/gui/image/qplatformpixmap.h index 08e03f10bd..81125bdec4 100644 --- a/src/gui/image/qplatformpixmap.h +++ b/src/gui/image/qplatformpixmap.h @@ -79,6 +79,12 @@ public: virtual void resize(int width, int height) = 0; virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags) = 0; + virtual void fromImageInPlace(QImage &image, + Qt::ImageConversionFlags flags) + { + fromImage(image, flags); + } + virtual void fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags); |