diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/image.pri | 7 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 95 | ||||
-rw-r--r-- | src/gui/image/qimage.h | 4 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 34 | ||||
-rw-r--r-- | src/gui/image/qimagewriter.cpp | 16 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 51 | ||||
-rw-r--r-- | src/gui/image/qpixmap.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpixmapcache_p.h | 2 | ||||
-rw-r--r-- | src/gui/image/qvolatileimage.cpp | 285 | ||||
-rw-r--r-- | src/gui/image/qvolatileimage_p.h | 100 | ||||
-rw-r--r-- | src/gui/image/qvolatileimagedata.cpp | 114 | ||||
-rw-r--r-- | src/gui/image/qvolatileimagedata_p.h | 84 |
13 files changed, 99 insertions, 699 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index f83e7e60c9..34a33aa0f0 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -23,8 +23,6 @@ HEADERS += \ image/qpixmapcache_p.h \ image/qplatformpixmap_qpa.h \ image/qimagepixmapcleanuphooks_p.h \ - image/qvolatileimage_p.h \ - image/qvolatileimagedata_p.h SOURCES += \ image/qbitmap.cpp \ @@ -42,13 +40,10 @@ SOURCES += \ image/qpixmap_raster.cpp \ image/qpixmap_blitter.cpp \ image/qnativeimage.cpp \ - image/qimagepixmapcleanuphooks.cpp \ - image/qvolatileimage.cpp + image/qimagepixmapcleanuphooks.cpp win32: SOURCES += image/qpixmap_win.cpp -SOURCES += image/qvolatileimagedata.cpp - # Built-in image format support HEADERS += \ image/qbmphandler_p.h \ diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 5b23dbf4dc..3e53b04728 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -327,17 +327,17 @@ bool QImageData::checkForAlphaPixels() const formats: \table - \header \o Format \o Description \o Qt's support - \row \o BMP \o Windows Bitmap \o Read/write - \row \o GIF \o Graphic Interchange Format (optional) \o Read - \row \o JPG \o Joint Photographic Experts Group \o Read/write - \row \o JPEG \o Joint Photographic Experts Group \o Read/write - \row \o PNG \o Portable Network Graphics \o Read/write - \row \o PBM \o Portable Bitmap \o Read - \row \o PGM \o Portable Graymap \o Read - \row \o PPM \o Portable Pixmap \o Read/write - \row \o XBM \o X11 Bitmap \o Read/write - \row \o XPM \o X11 Pixmap \o Read/write + \header \li Format \li Description \li Qt's support + \row \li BMP \li Windows Bitmap \li Read/write + \row \li GIF \li Graphic Interchange Format (optional) \li Read + \row \li JPG \li Joint Photographic Experts Group \li Read/write + \row \li JPEG \li Joint Photographic Experts Group \li Read/write + \row \li PNG \li Portable Network Graphics \li Read/write + \row \li PBM \li Portable Bitmap \li Read + \row \li PGM \li Portable Graymap \li Read + \row \li PPM \li Portable Pixmap \li Read/write + \row \li XBM \li X11 Bitmap \li Read/write + \row \li XPM \li X11 Pixmap \li Read/write \endtable \section1 Image Information @@ -347,11 +347,11 @@ bool QImageData::checkForAlphaPixels() const \table \header - \o \o Available Functions + \li \li Available Functions \row - \o Geometry - \o + \li Geometry + \li The size(), width(), height(), dotsPerMeterX(), and dotsPerMeterY() functions provide information about the image size @@ -365,8 +365,8 @@ bool QImageData::checkForAlphaPixels() const setOffset() function. \row - \o Colors - \o + \li Colors + \li The color of a pixel can be retrieved by passing its coordinates to the pixel() function. The pixel() function returns the color @@ -392,8 +392,8 @@ bool QImageData::checkForAlphaPixels() const sections. \row - \o Text - \o + \li Text + \li The text() function returns the image text associated with the given text key. An image's text keys can be retrieved using the @@ -401,8 +401,8 @@ bool QImageData::checkForAlphaPixels() const image's text. \row - \o Low-level information - \o + \li Low-level information + \li The depth() function returns the depth of the image. The supported depths are 1 (monochrome), 8, 16, 24 and 32 bits. The @@ -434,10 +434,10 @@ bool QImageData::checkForAlphaPixels() const \table \header - \o {2,1}32-bit + \li {2,1}32-bit \row - \o \inlineimage qimage-32bit_scaled.png - \o + \li \inlineimage qimage-32bit_scaled.png + \li \snippet doc/src/snippets/code/src_gui_image_qimage.cpp 0 \endtable @@ -455,10 +455,10 @@ bool QImageData::checkForAlphaPixels() const \table \header - \o {2,1} 8-bit + \li {2,1} 8-bit \row - \o \inlineimage qimage-8bit_scaled.png - \o + \li \inlineimage qimage-8bit_scaled.png + \li \snippet doc/src/snippets/code/src_gui_image_qimage.cpp 1 \endtable @@ -529,28 +529,28 @@ bool QImageData::checkForAlphaPixels() const in-place: \table - \header \o Function \o Description + \header \li Function \li Description \row - \o setDotsPerMeterX() - \o Defines the aspect ratio by setting the number of pixels that fit + \li setDotsPerMeterX() + \li Defines the aspect ratio by setting the number of pixels that fit horizontally in a physical meter. \row - \o setDotsPerMeterY() - \o Defines the aspect ratio by setting the number of pixels that fit + \li setDotsPerMeterY() + \li Defines the aspect ratio by setting the number of pixels that fit vertically in a physical meter. \row - \o fill() - \o Fills the entire image with the given pixel value. + \li fill() + \li Fills the entire image with the given pixel value. \row - \o invertPixels() - \o Inverts all pixel values in the image using the given InvertMode value. + \li invertPixels() + \li Inverts all pixel values in the image using the given InvertMode value. \row - \o setColorTable() - \o Sets the color table used to translate color indexes. Only + \li setColorTable() + \li Sets the color table used to translate color indexes. Only monochrome and 8-bit formats. \row - \o setColorCount() - \o Resizes the color table. Only monochrome and 8-bit formats. + \li setColorCount() + \li Resizes the color table. Only monochrome and 8-bit formats. \endtable @@ -3794,11 +3794,11 @@ bool QImage::isGrayscale() const \image qimage-scaling.png \list - \i If \a aspectRatioMode is Qt::IgnoreAspectRatio, the image + \li If \a aspectRatioMode is Qt::IgnoreAspectRatio, the image is scaled to \a size. - \i If \a aspectRatioMode is Qt::KeepAspectRatio, the image is + \li If \a aspectRatioMode is Qt::KeepAspectRatio, the image is scaled to a rectangle as large as possible inside \a size, preserving the aspect ratio. - \i If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding, + \li If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding, the image is scaled to a rectangle as small as possible outside \a size, preserving the aspect ratio. \endlist @@ -5132,7 +5132,8 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth #undef IWX_LSB #undef IWX_PIX -/*! \obsolete +/*! \fn int QImage::serialNumber() const + \obsolete Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same serial number if they refer to the same contents (but they don't @@ -5147,14 +5148,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth \sa operator==() */ -int QImage::serialNumber() const -{ - if (!d) - return 0; - else - return d->ser_no; -} - /*! Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same key if they diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 5a3ae8f886..e9192f1031 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -253,7 +253,9 @@ public: inline static QImage fromData(const QByteArray &data, const char *format = 0) { return fromData(reinterpret_cast<const uchar *>(data.constData()), data.size(), format); } - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPaintEngine *paintEngine() const; diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 4a9a9b00f4..870784f638 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -703,22 +703,22 @@ QByteArray QImageReader::format() const \list - \o Image plugins are queried first, based on either the optional format + \li Image plugins are queried first, based on either the optional format string, or the file name suffix (if the source device is a file). No content detection is done at this stage. QImageReader will choose the first plugin that supports reading for this format. - \o If no plugin supports the image format, Qt's built-in handlers are + \li If no plugin supports the image format, Qt's built-in handlers are checked based on either the optional format string, or the file name suffix. - \o If no capable plugins or built-in handlers are found, each plugin is + \li If no capable plugins or built-in handlers are found, each plugin is tested by inspecting the content of the data stream. - \o If no plugins could detect the image format based on data contents, + \li If no plugins could detect the image format based on data contents, each built-in image handler is tested by inspecting the contents. - \o Finally, if all above approaches fail, QImageReader will report failure + \li Finally, if all above approaches fail, QImageReader will report failure when trying to read the image. \endlist @@ -1423,18 +1423,18 @@ QByteArray QImageReader::imageFormat(QIODevice *device) By default, Qt can read the following formats: \table - \header \o Format \o Description - \row \o BMP \o Windows Bitmap - \row \o GIF \o Graphic Interchange Format (optional) - \row \o JPG \o Joint Photographic Experts Group - \row \o JPEG \o Joint Photographic Experts Group - \row \o PNG \o Portable Network Graphics - \row \o PBM \o Portable Bitmap - \row \o PGM \o Portable Graymap - \row \o PPM \o Portable Pixmap - \row \o XBM \o X11 Bitmap - \row \o XPM \o X11 Pixmap - \row \o SVG \o Scalable Vector Graphics + \header \li Format \li Description + \row \li BMP \li Windows Bitmap + \row \li GIF \li Graphic Interchange Format (optional) + \row \li JPG \li Joint Photographic Experts Group + \row \li JPEG \li Joint Photographic Experts Group + \row \li PNG \li Portable Network Graphics + \row \li PBM \li Portable Bitmap + \row \li PGM \li Portable Graymap + \row \li PPM \li Portable Pixmap + \row \li XBM \li X11 Bitmap + \row \li XPM \li X11 Pixmap + \row \li SVG \li Scalable Vector Graphics \endtable Reading and writing SVG files is supported through Qt's diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 966017452c..8395f9d216 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -653,14 +653,14 @@ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const By default, Qt can write the following formats: \table - \header \o Format \o Description - \row \o BMP \o Windows Bitmap - \row \o JPG \o Joint Photographic Experts Group - \row \o JPEG \o Joint Photographic Experts Group - \row \o PNG \o Portable Network Graphics - \row \o PPM \o Portable Pixmap - \row \o XBM \o X11 Bitmap - \row \o XPM \o X11 Pixmap + \header \li Format \li Description + \row \li BMP \li Windows Bitmap + \row \li JPG \li Joint Photographic Experts Group + \row \li JPEG \li Joint Photographic Experts Group + \row \li PNG \li Portable Network Graphics + \row \li PPM \li Portable Pixmap + \row \li XBM \li X11 Bitmap + \row \li XPM \li X11 Pixmap \endtable Reading and writing SVG files is supported through Qt's diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index e8c1304b74..65b9d62dfa 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -885,7 +885,8 @@ void QPixmap::fill(const QColor &color) data->fill(color); } -/*! \obsolete +/*! \fn int QPixmap::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPixmap object. Distinct QPixmap objects can only have the same serial number if they refer to the same contents (but they don't have @@ -898,12 +899,6 @@ void QPixmap::fill(const QColor &color) it as a cache key. For caching pixmaps, we recommend using the QPixmapCache class whenever possible. */ -int QPixmap::serialNumber() const -{ - if (isNull()) - return 0; - return data->serialNumber(); -} /*! Returns a number that identifies this QPixmap. Distinct QPixmap @@ -1052,11 +1047,11 @@ bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags fla \image qimage-scaling.png \list - \i If \a aspectRatioMode is Qt::IgnoreAspectRatio, the pixmap + \li If \a aspectRatioMode is Qt::IgnoreAspectRatio, the pixmap is scaled to \a size. - \i If \a aspectRatioMode is Qt::KeepAspectRatio, the pixmap is + \li If \a aspectRatioMode is Qt::KeepAspectRatio, the pixmap is scaled to a rectangle as large as possible inside \a size, preserving the aspect ratio. - \i If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding, + \li If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding, the pixmap is scaled to a rectangle as small as possible outside \a size, preserving the aspect ratio. \endlist @@ -1273,17 +1268,17 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) formats: \table - \header \o Format \o Description \o Qt's support - \row \o BMP \o Windows Bitmap \o Read/write - \row \o GIF \o Graphic Interchange Format (optional) \o Read - \row \o JPG \o Joint Photographic Experts Group \o Read/write - \row \o JPEG \o Joint Photographic Experts Group \o Read/write - \row \o PNG \o Portable Network Graphics \o Read/write - \row \o PBM \o Portable Bitmap \o Read - \row \o PGM \o Portable Graymap \o Read - \row \o PPM \o Portable Pixmap \o Read/write - \row \o XBM \o X11 Bitmap \o Read/write - \row \o XPM \o X11 Pixmap \o Read/write + \header \li Format \li Description \li Qt's support + \row \li BMP \li Windows Bitmap \li Read/write + \row \li GIF \li Graphic Interchange Format (optional) \li Read + \row \li JPG \li Joint Photographic Experts Group \li Read/write + \row \li JPEG \li Joint Photographic Experts Group \li Read/write + \row \li PNG \li Portable Network Graphics \li Read/write + \row \li PBM \li Portable Bitmap \li Read + \row \li PGM \li Portable Graymap \li Read + \row \li PPM \li Portable Pixmap \li Read/write + \row \li XBM \li X11 Bitmap \li Read/write + \row \li XPM \li X11 Pixmap \li Read/write \endtable \section1 Pixmap Information @@ -1293,17 +1288,17 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) \table \header - \o \o Available Functions + \li \li Available Functions \row - \o Geometry - \o + \li Geometry + \li The size(), width() and height() functions provide information about the pixmap's size. The rect() function returns the image's enclosing rectangle. \row - \o Alpha component - \o + \li Alpha component + \li The hasAlphaChannel() returns true if the pixmap has a format that respects the alpha channel, otherwise returns false. The hasAlpha(), @@ -1318,8 +1313,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) QBitmap) for the pixmap based on a given color. \row - \o Low-level information - \o + \li Low-level information + \li The depth() function returns the depth of the pixmap. The defaultDepth() function returns the default depth, i.e. the depth diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 27bfe15688..3d78a43917 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -146,7 +146,7 @@ public: void scroll(int dx, int dy, const QRect &rect, QRegion *exposed = 0); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED int serialNumber() const; + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } #endif qint64 cacheKey() const; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 8125b1360d..7c7c4652e3 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -115,7 +115,7 @@ void QRasterPlatformPixmap::resize(int width, int height) image.setColor(1, QColor(Qt::color1).rgba()); } - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char *format, @@ -349,7 +349,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC } is_null = (w <= 0 || h <= 0); - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } QImage* QRasterPlatformPixmap::buffer() diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 6ca109b03f..426a6d9954 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -96,8 +96,6 @@ public: QPixmapCache::Key key; }; -inline bool qIsDetached(QPixmapCacheEntry &t) { return t.isDetached(); } - QT_END_NAMESPACE #endif // QPIXMAPCACHE_P_H diff --git a/src/gui/image/qvolatileimage.cpp b/src/gui/image/qvolatileimage.cpp deleted file mode 100644 index 8122c9cfe8..0000000000 --- a/src/gui/image/qvolatileimage.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qvolatileimage_p.h" -#include "qvolatileimagedata_p.h" -#include <QtGui/private/qpaintengine_raster_p.h> -#include <QtGui/qplatformpixmap_qpa.h> - -QT_BEGIN_NAMESPACE - -class QVolatileImagePaintEnginePrivate : public QRasterPaintEnginePrivate -{ -public: - QVolatileImagePaintEnginePrivate() { } - QVolatileImage *img; -}; - -class QVolatileImagePaintEngine : public QRasterPaintEngine -{ - Q_DECLARE_PRIVATE(QVolatileImagePaintEngine) - -public: - QVolatileImagePaintEngine(QPaintDevice *device, QVolatileImage *img); - bool begin(QPaintDevice *device); - bool end(); - void drawPixmap(const QPointF &p, const QPixmap &pm); - void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); -}; - -QVolatileImage::QVolatileImage() - : d(new QVolatileImageData) -{ -} - -QVolatileImage::QVolatileImage(int w, int h, QImage::Format format) - : d(new QVolatileImageData(w, h, format)) -{ -} - -QVolatileImage::QVolatileImage(const QImage &sourceImage) - : d(new QVolatileImageData(sourceImage)) -{ -} - -QVolatileImage::QVolatileImage(void *nativeImage, void *nativeMask) - : d(new QVolatileImageData(nativeImage, nativeMask)) -{ -} - -// Need non-inline, non-autogenerated copy ctor, dtor, op= to keep the -// fwd declared QSharedData working. - -QVolatileImage::QVolatileImage(const QVolatileImage &other) - : d(other.d) -{ -} - -QVolatileImage::~QVolatileImage() -{ -} - -QVolatileImage &QVolatileImage::operator=(const QVolatileImage &rhs) -{ - d = rhs.d; - return *this; -} - -bool QVolatileImage::isNull() const -{ - return d->image.isNull(); -} - -QImage::Format QVolatileImage::format() const -{ - return d->image.format(); -} - -int QVolatileImage::width() const -{ - return d->image.width(); -} - -int QVolatileImage::height() const -{ - return d->image.height(); -} - -int QVolatileImage::bytesPerLine() const -{ - return d->image.bytesPerLine(); -} - -int QVolatileImage::byteCount() const -{ - return d->image.byteCount(); -} - -int QVolatileImage::depth() const -{ - return d->image.depth(); -} - -bool QVolatileImage::hasAlphaChannel() const -{ - return d->image.hasAlphaChannel(); -} - -void QVolatileImage::beginDataAccess() const -{ - d->beginDataAccess(); -} - -void QVolatileImage::endDataAccess(bool readOnly) const -{ - d->endDataAccess(readOnly); -} - -/*! - Access to pixel data via bits() or constBits() should be guarded by - begin/endDataAccess(). - */ -uchar *QVolatileImage::bits() -{ - return d->image.bits(); -} - -const uchar *QVolatileImage::constBits() const -{ - return d->image.constBits(); -} - -bool QVolatileImage::ensureFormat(QImage::Format format) -{ - return d->ensureFormat(format); -} - -/*! - This will always perform a copy of the pixel data. - */ -QImage QVolatileImage::toImage() const -{ - d->beginDataAccess(); - QImage newImage = d->image.copy(); // no sharing allowed - d->endDataAccess(true); - return newImage; -} - -/*! - Returns a reference to the image that is potentially using some native - buffer internally. Access to the image's pixel data should be guarded by - begin/endDataAccess(). Use it when there is a need for QImage APIs not provided - by this class. The returned QImage must never be shared or assigned to. - */ -QImage &QVolatileImage::imageRef() // non-const, in order to cause a detach -{ - d->ensureImage(); - return d->image; -} - -void *QVolatileImage::duplicateNativeImage() const -{ - return d->duplicateNativeImage(); -} - -void QVolatileImage::fill(uint pixelValue) -{ - beginDataAccess(); - imageRef().fill(pixelValue); - endDataAccess(); - d->ensureImage(); -} - -void QVolatileImage::copyFrom(QVolatileImage *source, const QRect &rect) -{ - if (source->isNull()) { - return; - } - QRect r = rect; - if (rect.isNull()) { - r = QRect(0, 0, source->width(), source->height()); - } - source->beginDataAccess(); - QImage &srcImgRef(source->imageRef()); - int srcbpl = srcImgRef.bytesPerLine(); - int srcbpp = srcImgRef.depth() / 8; - const uchar *sptr = srcImgRef.constBits() + r.y() * srcbpl; - beginDataAccess(); - QImage &dstImgRef(imageRef()); - int dstbpl = dstImgRef.bytesPerLine(); - uchar *dptr = dstImgRef.bits(); - for (int y = 0; y < r.height(); ++y) { - qMemCopy(dptr, sptr + r.x() * srcbpp, r.width() * srcbpp); - sptr += srcbpl; - dptr += dstbpl; - } - endDataAccess(); - source->endDataAccess(true); -} - -/*! - To be called from the PlatformPixmap's paintEngine(). - */ -QPaintEngine *QVolatileImage::paintEngine() -{ - if (!d->pengine) { - d->pengine = new QVolatileImagePaintEngine(&imageRef(), this); - } - return d->pengine; -} - -QVolatileImagePaintEngine::QVolatileImagePaintEngine(QPaintDevice *device, - QVolatileImage *img) - : QRasterPaintEngine(*(new QVolatileImagePaintEnginePrivate), device) -{ - Q_D(QVolatileImagePaintEngine); - d->img = img; -} - -bool QVolatileImagePaintEngine::begin(QPaintDevice *device) -{ - Q_D(QVolatileImagePaintEngine); - d->img->beginDataAccess(); - return QRasterPaintEngine::begin(device); -} - -bool QVolatileImagePaintEngine::end() -{ - Q_D(QVolatileImagePaintEngine); - bool ret = QRasterPaintEngine::end(); - d->img->endDataAccess(); - return ret; -} - -// For non-RasterClass pixmaps drawPixmap() would call toImage() which is slow in -// our case. Therefore drawPixmap() is rerouted to drawImage(). - -void QVolatileImagePaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) -{ - QRasterPaintEngine::drawPixmap(p, pm); -} - -void QVolatileImagePaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) -{ - QRasterPaintEngine::drawPixmap(r, pm, sr); -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qvolatileimage_p.h b/src/gui/image/qvolatileimage_p.h deleted file mode 100644 index 808def7c32..0000000000 --- a/src/gui/image/qvolatileimage_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QVOLATILEIMAGE_P_H -#define QVOLATILEIMAGE_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 <QtGui/qimage.h> -#include <QtCore/qshareddata.h> - -QT_BEGIN_NAMESPACE - -class QVolatileImageData; - -class Q_GUI_EXPORT QVolatileImage -{ -public: - QVolatileImage(); - QVolatileImage(int w, int h, QImage::Format format); - explicit QVolatileImage(const QImage &sourceImage); - explicit QVolatileImage(void *nativeImage, void *nativeMask = 0); - QVolatileImage(const QVolatileImage &other); - ~QVolatileImage(); - QVolatileImage &operator=(const QVolatileImage &rhs); - - bool isNull() const; - QImage::Format format() const; - int width() const; - int height() const; - int bytesPerLine() const; - int byteCount() const; - int depth() const; - bool hasAlphaChannel() const; - void beginDataAccess() const; - void endDataAccess(bool readOnly = false) const; - uchar *bits(); - const uchar *constBits() const; - bool ensureFormat(QImage::Format format); - QImage toImage() const; - QImage &imageRef(); - QPaintEngine *paintEngine(); - void fill(uint pixelValue); - void *duplicateNativeImage() const; - void copyFrom(QVolatileImage *source, const QRect &rect); - -private: - QSharedDataPointer<QVolatileImageData> d; -}; - -QT_END_NAMESPACE - -#endif // QVOLATILEIMAGE_P_H diff --git a/src/gui/image/qvolatileimagedata.cpp b/src/gui/image/qvolatileimagedata.cpp deleted file mode 100644 index 3fcf24e187..0000000000 --- a/src/gui/image/qvolatileimagedata.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qvolatileimagedata_p.h" -#include <QtGui/qpaintengine.h> - -QT_BEGIN_NAMESPACE - -QVolatileImageData::QVolatileImageData() - : pengine(0) -{ -} - -QVolatileImageData::QVolatileImageData(int w, int h, QImage::Format format) - : pengine(0) -{ - image = QImage(w, h, format); -} - -QVolatileImageData::QVolatileImageData(const QImage &sourceImage) - : pengine(0) -{ - image = sourceImage; -} - -QVolatileImageData::QVolatileImageData(void *, void *) - : pengine(0) -{ - // Not supported. -} - -QVolatileImageData::QVolatileImageData(const QVolatileImageData &other) - : QSharedData() -{ - image = other.image; - // The detach is not mandatory here but we do it nonetheless in order to - // keep the behavior consistent with other platforms. - image.detach(); - pengine = 0; -} - -QVolatileImageData::~QVolatileImageData() -{ - delete pengine; -} - -void QVolatileImageData::beginDataAccess() const -{ - // nothing to do here -} - -void QVolatileImageData::endDataAccess(bool readOnly) const -{ - Q_UNUSED(readOnly); - // nothing to do here -} - -bool QVolatileImageData::ensureFormat(QImage::Format format) -{ - if (image.format() != format) { - image = image.convertToFormat(format); - } - return true; -} - -void *QVolatileImageData::duplicateNativeImage() const -{ - return 0; -} - -void QVolatileImageData::ensureImage() -{ - // nothing to do here -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qvolatileimagedata_p.h b/src/gui/image/qvolatileimagedata_p.h deleted file mode 100644 index 59e1be12e3..0000000000 --- a/src/gui/image/qvolatileimagedata_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QVOLATILEIMAGEDATA_P_H -#define QVOLATILEIMAGEDATA_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 <QtGui/qimage.h> -#include <QtCore/qshareddata.h> - - -QT_BEGIN_NAMESPACE - -class QVolatileImageData : public QSharedData -{ -public: - QVolatileImageData(); - QVolatileImageData(int w, int h, QImage::Format format); - QVolatileImageData(const QImage &sourceImage); - QVolatileImageData(void *nativeImage, void *nativeMask); - QVolatileImageData(const QVolatileImageData &other); - ~QVolatileImageData(); - - void beginDataAccess() const; - void endDataAccess(bool readOnly = false) const; - bool ensureFormat(QImage::Format format); - void *duplicateNativeImage() const; - void ensureImage(); - - QImage image; - QPaintEngine *pengine; -}; - -QT_END_NAMESPACE - -#endif // QVOLATILEIMAGEDATA_P_H |