summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/image.pri6
-rw-r--r--src/gui/image/qbitmap.cpp49
-rw-r--r--src/gui/image/qbitmap.h32
-rw-r--r--src/gui/image/qbmphandler.cpp60
-rw-r--r--src/gui/image/qbmphandler_p.h30
-rw-r--r--src/gui/image/qicon.cpp71
-rw-r--r--src/gui/image/qicon.h30
-rw-r--r--src/gui/image/qicon_p.h33
-rw-r--r--src/gui/image/qiconengine.cpp34
-rw-r--r--src/gui/image/qiconengine.h30
-rw-r--r--src/gui/image/qiconengineplugin.cpp30
-rw-r--r--src/gui/image/qiconengineplugin.h30
-rw-r--r--src/gui/image/qiconloader.cpp166
-rw-r--r--src/gui/image/qiconloader_p.h36
-rw-r--r--src/gui/image/qimage.cpp274
-rw-r--r--src/gui/image/qimage.h41
-rw-r--r--src/gui/image/qimage_p.h32
-rw-r--r--src/gui/image/qimageiohandler.cpp31
-rw-r--r--src/gui/image/qimageiohandler.h33
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp97
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks_p.h54
-rw-r--r--src/gui/image/qimagereader.cpp93
-rw-r--r--src/gui/image/qimagereader.h33
-rw-r--r--src/gui/image/qimagewriter.cpp32
-rw-r--r--src/gui/image/qimagewriter.h30
-rw-r--r--src/gui/image/qmovie.cpp36
-rw-r--r--src/gui/image/qmovie.h30
-rw-r--r--src/gui/image/qnativeimage.cpp50
-rw-r--r--src/gui/image/qnativeimage_p.h30
-rw-r--r--src/gui/image/qpaintengine_pic.cpp30
-rw-r--r--src/gui/image/qpaintengine_pic_p.h30
-rw-r--r--src/gui/image/qpicture.cpp110
-rw-r--r--src/gui/image/qpicture.h37
-rw-r--r--src/gui/image/qpicture_p.h38
-rw-r--r--src/gui/image/qpictureformatplugin.cpp30
-rw-r--r--src/gui/image/qpictureformatplugin.h30
-rw-r--r--src/gui/image/qpixmap.cpp292
-rw-r--r--src/gui/image/qpixmap.h57
-rw-r--r--src/gui/image/qpixmap_mac.cpp85
-rw-r--r--src/gui/image/qpixmap_mac_p.h33
-rw-r--r--src/gui/image/qpixmap_qws.cpp58
-rw-r--r--src/gui/image/qpixmap_raster.cpp70
-rw-r--r--src/gui/image/qpixmap_raster_p.h36
-rw-r--r--src/gui/image/qpixmap_s60.cpp985
-rw-r--r--src/gui/image/qpixmap_s60_p.h134
-rw-r--r--src/gui/image/qpixmap_win.cpp158
-rw-r--r--src/gui/image/qpixmap_x11.cpp126
-rw-r--r--src/gui/image/qpixmap_x11_p.h35
-rw-r--r--src/gui/image/qpixmapcache.cpp119
-rw-r--r--src/gui/image/qpixmapcache.h30
-rw-r--r--src/gui/image/qpixmapcache_p.h38
-rw-r--r--src/gui/image/qpixmapdata.cpp109
-rw-r--r--src/gui/image/qpixmapdata_p.h69
-rw-r--r--src/gui/image/qpixmapdatafactory.cpp37
-rw-r--r--src/gui/image/qpixmapdatafactory_p.h30
-rw-r--r--src/gui/image/qpixmapfilter.cpp385
-rw-r--r--src/gui/image/qpixmapfilter_p.h61
-rw-r--r--src/gui/image/qpnghandler.cpp50
-rw-r--r--src/gui/image/qpnghandler_p.h30
-rw-r--r--src/gui/image/qppmhandler.cpp36
-rw-r--r--src/gui/image/qppmhandler_p.h30
-rw-r--r--src/gui/image/qxbmhandler.cpp32
-rw-r--r--src/gui/image/qxbmhandler_p.h30
-rw-r--r--src/gui/image/qxpmhandler.cpp32
-rw-r--r--src/gui/image/qxpmhandler_p.h30
65 files changed, 3465 insertions, 1590 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index 5507d2567..b67be55f3 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -24,7 +24,7 @@ HEADERS += \
image/qpixmap.h \
image/qpixmap_raster_p.h \
image/qpixmapcache.h \
- image/qpixmapcache_p.h \
+ image/qpixmapcache_p.h \
image/qpixmapdata_p.h \
image/qpixmapdatafactory_p.h \
image/qpixmapfilter_p.h \
@@ -69,6 +69,10 @@ mac {
HEADERS += image/qpixmap_mac_p.h
SOURCES += image/qpixmap_mac.cpp
}
+symbian {
+ HEADERS += image/qpixmap_s60_p.h
+ SOURCES += image/qpixmap_s60.cpp
+}
# Built-in image format support
HEADERS += \
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index a1497bc56..4b8d4b889 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
\class QBitmap
\brief The QBitmap class provides monochrome (1-bit depth) pixmaps.
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
The QBitmap class is a monochrome off-screen paint device used
@@ -86,19 +86,21 @@ QT_BEGIN_NAMESPACE
object.
Just like the QPixmap class, QBitmap is optimized by the use of
- implicit data sharing. For more information, see the {Implicit
+ implicit data sharing. For more information, see the \l {Implicit
Data Sharing} documentation.
\sa QPixmap, QImage, QImageReader, QImageWriter
*/
+/*! \typedef QBitmap::DataPtr
+ \internal
+ */
/*!
Constructs a null bitmap.
\sa QPixmap::isNull()
*/
-
QBitmap::QBitmap()
: QPixmap(QSize(0, 0), QPixmapData::BitmapType)
{
@@ -265,15 +267,12 @@ QBitmap QBitmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
img.setColor(1, c0);
}
- QPixmapData *d;
QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- if (gs)
- d = gs->createPixmapData(QPixmapData::BitmapType);
- else
- d = QGraphicsSystem::createDefaultPixmapData(QPixmapData::BitmapType);
+ QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::BitmapType)
+ : QGraphicsSystem::createDefaultPixmapData(QPixmapData::BitmapType));
- d->fromImage(img, flags | Qt::MonoOnly);
- return QPixmap(d);
+ data->fromImage(img, flags | Qt::MonoOnly);
+ return QPixmap(data.take());
}
/*!
diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h
index 8738d6595..0a3e622c5 100644
--- a/src/gui/image/qbitmap.h
+++ b/src/gui/image/qbitmap.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -82,6 +82,8 @@ public:
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)
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index ccf8457db..f3eb7c3fc 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE
static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels
{
int i;
- if (image->depth() == 1 && image->numColors() == 2) {
+ if (image->depth() == 1 && image->colorCount() == 2) {
register uint *p = (uint *)image->bits();
- int nbytes = image->numBytes();
+ int nbytes = image->byteCount();
for (i=0; i<nbytes/4; i++) {
*p = ~*p;
p++;
@@ -81,14 +81,14 @@ static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels
const int BMP_FILEHDR_SIZE = 14; // size of BMP_FILEHDR data
-QDataStream &operator>>(QDataStream &s, BMP_FILEHDR &bf)
+static QDataStream &operator>>(QDataStream &s, BMP_FILEHDR &bf)
{ // read file header
s.readRawData(bf.bfType, 2);
s >> bf.bfSize >> bf.bfReserved1 >> bf.bfReserved2 >> bf.bfOffBits;
return s;
}
-QDataStream &operator<<(QDataStream &s, const BMP_FILEHDR &bf)
+static QDataStream &operator<<(QDataStream &s, const BMP_FILEHDR &bf)
{ // write file header
s.writeRawData(bf.bfType, 2);
s << bf.bfSize << bf.bfReserved1 << bf.bfReserved2 << bf.bfOffBits;
@@ -106,7 +106,7 @@ const int BMP_RLE4 = 2; // run-length encoded, 4
const int BMP_BITFIELDS = 3; // RGB values encoded in data as bit-fields
-QDataStream &operator>>(QDataStream &s, BMP_INFOHDR &bi)
+static QDataStream &operator>>(QDataStream &s, BMP_INFOHDR &bi)
{
s >> bi.biSize;
if (bi.biSize == BMP_WIN || bi.biSize == BMP_OS2) {
@@ -128,7 +128,7 @@ QDataStream &operator>>(QDataStream &s, BMP_INFOHDR &bi)
return s;
}
-QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
{
s << bi.biSize;
s << bi.biWidth << bi.biHeight;
@@ -246,7 +246,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
if (depth != 32) {
ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
- image.setNumColors(ncols);
+ image.setColorCount(ncols);
}
image.setDotsPerMeterX(bi.biXPelsPerMeter);
@@ -526,7 +526,7 @@ bool qt_write_dib(QDataStream &s, QImage image)
if (!d->isWritable())
return false;
- if (image.depth() == 8 && image.numColors() <= 16) {
+ if (image.depth() == 8 && image.colorCount() <= 16) {
bpl_bmp = (((bpl+1)/2+3)/4)*4;
nbits = 4;
} else if (image.depth() == 32) {
@@ -554,23 +554,23 @@ bool qt_write_dib(QDataStream &s, QImage image)
bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX()
: 2834; // 72 dpi default
bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834;
- bi.biClrUsed = image.numColors();
- bi.biClrImportant = image.numColors();
+ bi.biClrUsed = image.colorCount();
+ bi.biClrImportant = image.colorCount();
s << bi; // write info header
if (s.status() != QDataStream::Ok)
return false;
if (image.depth() != 32) { // write color table
- uchar *color_table = new uchar[4*image.numColors()];
+ uchar *color_table = new uchar[4*image.colorCount()];
uchar *rgb = color_table;
QVector<QRgb> c = image.colorTable();
- for (int i=0; i<image.numColors(); i++) {
+ for (int i=0; i<image.colorCount(); i++) {
*rgb++ = qBlue (c[i]);
*rgb++ = qGreen(c[i]);
*rgb++ = qRed (c[i]);
*rgb++ = 0;
}
- if (d->write((char *)color_table, 4*image.numColors()) == -1) {
+ if (d->write((char *)color_table, 4*image.colorCount()) == -1) {
delete [] color_table;
return false;
}
@@ -754,7 +754,7 @@ bool QBmpHandler::write(const QImage &img)
int bpl = image.bytesPerLine();
// Code partially repeated in qt_write_dib
- if (image.depth() == 8 && image.numColors() <= 16) {
+ if (image.depth() == 8 && image.colorCount() <= 16) {
bpl_bmp = (((bpl+1)/2+3)/4)*4;
} else if (image.depth() == 32) {
bpl_bmp = ((image.width()*24+31)/32)*4;
@@ -771,7 +771,7 @@ bool QBmpHandler::write(const QImage &img)
// write file header
bf.bfReserved1 = 0;
bf.bfReserved2 = 0;
- bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.numColors() * 4;
+ bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4;
bf.bfSize = bf.bfOffBits + bpl_bmp*image.height();
s << bf;
diff --git a/src/gui/image/qbmphandler_p.h b/src/gui/image/qbmphandler_p.h
index c15d8cc0a..3f0a832cf 100644
--- a/src/gui/image/qbmphandler_p.h
+++ b/src/gui/image/qbmphandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 677cc4479..cff9cd207 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -54,6 +54,7 @@
#include "qvariant.h"
#include "qcache.h"
#include "qdebug.h"
+#include "private/qguiplatformplugin_p.h"
#ifdef Q_WS_MAC
#include <private/qt_mac_p.h>
@@ -65,6 +66,7 @@
#include "private/qkde_p.h"
#endif
+#ifndef QT_NO_ICON
QT_BEGIN_NAMESPACE
/*!
@@ -445,9 +447,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loaderV2,
\brief The QIcon class provides scalable icons in different modes
and states.
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
- \mainclass
+
A QIcon can generate smaller, larger, active, and disabled pixmaps
from the set of pixmaps it is given. Such pixmaps are used by Qt
@@ -879,21 +881,20 @@ void QIcon::setThemeSearchPaths(const QStringList &paths)
}
/*!
- \since 4.6
-
- Returns the search paths for icon themes.
+ \since 4.6
- The default value will depend on the platform:
+ Returns the search paths for icon themes.
- On X11, the search path will use the XDG_DATA_DIRS environment
- variable if available.
+ The default value will depend on the platform:
- On Windows the search path defaults to [Application Directory]/icons
+ On X11, the search path will use the XDG_DATA_DIRS environment
+ variable if available.
- On Mac the default search path will search in the
- [Contents/Resources/icons] part of the application bundle.
+ By default all platforms will have the resource directory
+ \c{:\icons} as a fallback. You can use "rcc -project" to generate a
+ resource file from your icon theme.
- \sa setThemeSearchPaths(), fromTheme(), setThemeName()
+ \sa setThemeSearchPaths(), fromTheme(), setThemeName()
*/
QStringList QIcon::themeSearchPaths()
{
@@ -906,7 +907,7 @@ QStringList QIcon::themeSearchPaths()
Sets the current icon theme to \a name.
The \a name should correspond to a directory name in the
- current themeSearchPath() containing an index.theme
+ themeSearchPath() containing an index.theme
file describing it's contents.
\sa themeSearchPaths(), themeName()
@@ -939,10 +940,6 @@ QString QIcon::themeName()
icon theme. If no such icon is found in the current theme
\a fallback is return instead.
- To use an icon theme on Windows or Mac, you will need to
- bundle a compliant theme with your application and make sure
- it is located in your themeSarchPaths.
-
The lastest version of the freedesktop icon specification and naming
spesification can be obtained here:
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
@@ -966,19 +963,10 @@ QString QIcon::themeName()
*/
QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
{
-
static QCache <QString, QIcon> iconCache;
QIcon icon;
-#ifdef Q_WS_X11
- if (X11->desktopEnvironment == DE_KDE) {
- icon = QKde::kdeIcon(name);
- if (!icon.isNull())
- return icon;
- }
-#endif
-
if (iconCache.contains(name)) {
icon = *iconCache.object(name);
} else {
@@ -1230,3 +1218,4 @@ QSize QIcon::pixmapSize(Size which)
*/
QT_END_NAMESPACE
+#endif //QT_NO_ICON
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index 7debb02fc..f841ecda7 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h
index 5525ac591..43a59a6c5 100644
--- a/src/gui/image/qicon_p.h
+++ b/src/gui/image/qicon_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -60,6 +60,7 @@
#include <QtGui/qicon.h>
#include <QtGui/qiconengine.h>
+#ifndef QT_NO_ICON
QT_BEGIN_NAMESPACE
class QIconPrivate
@@ -134,5 +135,5 @@ private:
};
QT_END_NAMESPACE
-
+#endif //QT_NO_ICON
#endif // QICON_P_H
diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp
index 8e396076c..d89202754 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/gui/image/qiconengine.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\brief The QIconEngine class provides an abstract base class for QIcon renderers.
- \ingroup multimedia
+ \ingroup painting
\bold {Use QIconEngineV2 instead.}
@@ -144,7 +144,7 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI
\brief The QIconEngineV2 class provides an abstract base class for QIcon renderers.
- \ingroup multimedia
+ \ingroup painting
\since 4.3
An icon engine renders \l{QIcon}s. With icon engines, you can
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index ba9c96da5..6df59b0a5 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qiconengineplugin.cpp b/src/gui/image/qiconengineplugin.cpp
index a24460bbd..7ac346a64 100644
--- a/src/gui/image/qiconengineplugin.cpp
+++ b/src/gui/image/qiconengineplugin.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qiconengineplugin.h b/src/gui/image/qiconengineplugin.h
index b7eabeca2..b64daff7d 100644
--- a/src/gui/image/qiconengineplugin.h
+++ b/src/gui/image/qiconengineplugin.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index e5f0043c2..ad9bdd0d4 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,30 +21,29 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
-
+#ifndef QT_NO_ICON
#include <private/qiconloader_p.h>
#include <private/qapplication_p.h>
#include <private/qicon_p.h>
-#include <private/qkde_p.h>
+#include <private/qguiplatformplugin_p.h>
#include <QtGui/QIconEnginePlugin>
#include <QtGui/QPixmapCache>
@@ -61,59 +61,43 @@
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
-#include <private/gtksymbols_p.h>
#endif
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
-static QString systemThemeName()
+/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
+static QString fallbackTheme()
{
- QString result;
#ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_GNOME) {
-#if defined(QT_NO_STYLE_GTK)
- result = QLatin1String("gnome");
-#else
- result = QGtk::getGConfString(QLatin1String("/desktop/gnome/interface/icon_theme"),
- QLatin1String("gnome"));
-#endif
+ return QLatin1String("gnome");
} else if (X11->desktopEnvironment == DE_KDE) {
- QString kdeDefault = X11->desktopVersion >= 4 ?
- QString::fromLatin1("oxygen") :
- QString::fromLatin1("crystalsvg");
-
- QSettings settings(QKde::kdeHome() +
- QLatin1String("/share/config/kdeglobals"),
- QSettings::IniFormat);
-
- settings.beginGroup(QLatin1String("Icons"));
-
- result = settings.value(QLatin1String("Theme"), kdeDefault).toString();
+ return X11->desktopVersion >= 4
+ ? QString::fromLatin1("oxygen")
+ : QString::fromLatin1("crystalsvg");
+ } else {
+ return QLatin1String("hicolor");
}
#endif
- return result;
-}
-
-static QString fallbackTheme()
-{
- QString defaultTheme = systemThemeName();
- if (defaultTheme.isEmpty())
- defaultTheme = QLatin1String("hicolor");
- return defaultTheme;
+ return QString();
}
QIconLoader::QIconLoader() :
m_themeKey(1), m_supportsSvg(false)
{
- m_systemTheme = systemThemeName();
+ m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
+ if (m_systemTheme.isEmpty())
+ m_systemTheme = fallbackTheme();
+#ifndef QT_NO_LIBRARY
QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
QLatin1String("/iconengines"),
Qt::CaseInsensitive);
if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
m_supportsSvg = true;
+#endif //QT_NO_LIBRARY
}
QIconLoader *QIconLoader::instance()
@@ -127,7 +111,9 @@ void QIconLoader::updateSystemTheme()
{
// Only change if this is not explicitly set by the user
if (m_userTheme.isEmpty()) {
- QString theme = systemThemeName();
+ QString theme = qt_guiPlatformPlugin()->systemIconThemeName();
+ if (theme.isEmpty())
+ theme = fallbackTheme();
if (theme != m_systemTheme) {
m_systemTheme = theme;
invalidateKey();
@@ -151,50 +137,9 @@ void QIconLoader::setThemeSearchPath(const QStringList &searchPaths)
QStringList QIconLoader::themeSearchPaths() const
{
if (m_iconDirs.isEmpty()) {
-
-#if defined(Q_WS_X11)
-
- QString xdgDirString = QFile::decodeName(getenv("XDG_DATA_DIRS"));
- if (xdgDirString.isEmpty())
- xdgDirString = QLatin1String("/usr/local/share/:/usr/share/");
-
- QStringList xdgDirs = xdgDirString.split(QLatin1Char(':'));
-
- for (int i = 0 ; i < xdgDirs.size() ; ++i) {
- QDir dir(xdgDirs[i]);
- if (dir.exists())
- m_iconDirs.append(dir.path() +
- QLatin1String("/icons"));
- }
-
- if (X11->desktopEnvironment == DE_KDE) {
-
- m_iconDirs << QLatin1Char(':') +
- QKde::kdeHome() +
- QLatin1String("/share/icons");
- QStringList kdeDirs =
- QFile::decodeName(getenv("KDEDIRS")).split(QLatin1Char(':'));
-
- for (int i = 0 ; i< kdeDirs.count() ; ++i) {
- QDir dir(QLatin1Char(':') + kdeDirs.at(i) +
- QLatin1String("/share/icons"));
- if (dir.exists())
- m_iconDirs.append(dir.path());
- }
- }
-
- // Add home directory first in search path
- QDir homeDir(QDir::homePath() + QLatin1String("/.icons"));
- if (homeDir.exists())
- m_iconDirs.prepend(homeDir.path());
-
-#elif defined(Q_WS_WIN)
- m_iconDirs.append(qApp->applicationDirPath() +
- QLatin1String("/icons"));
-#elif defined(Q_WS_MAC)
- m_iconDirs.append(qApp->applicationDirPath() +
- QLatin1String("/../Resources/icons"));
-#endif
+ m_iconDirs = qt_guiPlatformPlugin()->iconThemeSearchPaths();
+ // Allways add resource directory as search path
+ m_iconDirs.append(QLatin1String(":/icons"));
}
return m_iconDirs;
}
@@ -216,7 +161,7 @@ QIconTheme::QIconTheme(const QString &themeName)
break;
}
}
-
+#ifndef QT_NO_SETTINGS
if (themeIndex.exists()) {
const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
QStringListIterator keyIterator(indexReader.allKeys());
@@ -266,9 +211,10 @@ QIconTheme::QIconTheme(const QString &themeName)
m_parents.append(fallbackTheme());
// Ensure that all themes fall back to hicolor
- if (!m_parents.isEmpty())
+ if (!m_parents.contains(QLatin1String("hicolor")))
m_parents.append(QLatin1String("hicolor"));
}
+#endif //QT_NO_SETTINGS
}
QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
@@ -287,7 +233,7 @@ QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
if (!theme.isValid()) {
theme = QIconTheme(themeName);
if (!theme.isValid())
- theme = fallbackTheme();
+ theme = QIconTheme(fallbackTheme());
themeList.insert(themeName, theme);
}
@@ -303,21 +249,19 @@ QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
const QIconDirInfo &dirInfo = subDirs.at(i);
QString subdir = dirInfo.path;
QDir currentDir(contentDir + subdir);
-
- if (dirInfo.type == QIconDirInfo::Scalable && m_supportsSvg &&
- currentDir.exists(iconName + svgext)) {
- ScalableEntry *iconEntry = new ScalableEntry;
- iconEntry->dir = dirInfo;
- iconEntry->filename = currentDir.filePath(iconName + svgext);
- entries.append(iconEntry);
-
- } else if (currentDir.exists(iconName + pngext)) {
+ if (currentDir.exists(iconName + pngext)) {
PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + pngext);
// Notice we ensure that pixmap entries allways come before
// scalable to preserve search order afterwards
entries.prepend(iconEntry);
+ } else if (m_supportsSvg &&
+ currentDir.exists(iconName + svgext)) {
+ ScalableEntry *iconEntry = new ScalableEntry;
+ iconEntry->dir = dirInfo;
+ iconEntry->filename = currentDir.filePath(iconName + svgext);
+ entries.append(iconEntry);
}
}
@@ -498,10 +442,8 @@ QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QSize &size)
/*
* Returns the actual icon size. For scalable svg's this is equivalent
- * to the requested size. Otherwise the closest match is returned.
- *
- * todo: the spec is a bit fuzzy in this area, but we should probably
- * allow scaling down pixmap icons as well.
+ * to the requested size. Otherwise the closest match is returned but
+ * we can never return a bigger size than the requested size.
*
*/
QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
@@ -514,8 +456,10 @@ QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
const QIconDirInfo &dir = entry->dir;
if (dir.type == QIconDirInfo::Scalable)
return size;
- else
- return QSize(dir.size, dir.size);
+ else {
+ int result = qMin<int>(dir.size, qMin(size.width(), size.height()));
+ return QSize(result, result);
+ }
}
return QIconEngineV2::actualSize(size, mode, state);
}
@@ -602,3 +546,5 @@ void QIconLoaderEngine::virtual_hook(int id, void *data)
}
QT_END_NAMESPACE
+
+#endif //QT_NO_ICON
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
index b2944ef28..2a330d33c 100644
--- a/src/gui/image/qiconloader_p.h
+++ b/src/gui/image/qiconloader_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,6 +42,7 @@
#ifndef QDESKTOPICON_P_H
#define QDESKTOPICON_P_H
+#ifndef QT_NO_ICON
//
// W A R N I N G
// -------------
@@ -85,6 +86,7 @@ struct QIconDirInfo
class QIconLoaderEngineEntry
{
public:
+ virtual ~QIconLoaderEngineEntry() {}
virtual QPixmap pixmap(const QSize &size,
QIcon::Mode mode,
QIcon::State state) = 0;
@@ -138,7 +140,7 @@ class QIconTheme
{
public:
QIconTheme(const QString &name);
- QIconTheme() : m_valid(false) {};
+ QIconTheme() : m_valid(false) {}
QStringList parents() { return m_parents; }
QList <QIconDirInfo> keyList() { return m_keyList; }
QString contentDir() { return m_contentDir; }
@@ -184,3 +186,5 @@ private:
QT_END_NAMESPACE
#endif // QDESKTOPICON_P_H
+
+#endif //QT_NO_ICON
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 09bc8c808..ec8dd88c9 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -174,6 +174,13 @@ static int depthForFormat(QImage::Format format)
return depth;
}
+/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
+
+ \internal
+
+ Creates a new image data.
+ Returns 0 if invalid parameters are give or anything else failed.
+*/
QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
{
if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid)
@@ -212,7 +219,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
|| INT_MAX/sizeof(uchar *) < uint(height))
return 0;
- QImageData *d = new QImageData;
+ QScopedPointer<QImageData> d(new QImageData);
d->colortable.resize(numColors);
if (depth == 1) {
d->colortable[0] = QColor(Qt::black).rgba();
@@ -235,12 +242,11 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
d->data = (uchar *)malloc(d->nbytes);
if (!d->data) {
- delete d;
return 0;
}
d->ref.ref();
- return d;
+ return d.take();
}
@@ -333,9 +339,9 @@ bool QImageData::checkForAlphaPixels() const
/*!
\class QImage
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
- \mainclass
+
\reentrant
\brief The QImage class provides a hardware-independent image
@@ -371,6 +377,9 @@ bool QImageData::checkForAlphaPixels() const
\note If you would like to load QImage objects in a static build of Qt,
refer to the \l{How To Create Qt Plugins#Static Plugins}{Plugin HowTo}.
+ \warning Painting on a QImage with the format
+ QImage::Format_Indexed8 is not supported.
+
\tableofcontents
\section1 Reading and Writing Image Files
@@ -440,7 +449,7 @@ bool QImageData::checkForAlphaPixels() const
to the pixel() function. The pixel() function returns the color
as a QRgb value indepedent of the image's format.
- In case of monochrome and 8-bit images, the numColors() and
+ In case of monochrome and 8-bit images, the colorCount() and
colorTable() functions provide information about the color
components used to store the image data: The colorTable() function
returns the image's entire color table. To obtain a single entry,
@@ -475,7 +484,7 @@ bool QImageData::checkForAlphaPixels() const
depths are 1 (monochrome), 8 and 32 (for more information see the
\l {QImage#Image Formats}{Image Formats} section).
- The format(), bytesPerLine(), and numBytes() functions provide
+ The format(), bytesPerLine(), and byteCount() functions provide
low-level information about the data stored in the image.
The cacheKey() function returns a number that uniquely
@@ -537,11 +546,7 @@ bool QImageData::checkForAlphaPixels() const
Each pixel stored in a QImage is represented by an integer. The
size of the integer varies depending on the format. QImage
supports several image formats described by the \l Format
- enum. The monochrome (1-bit), 8-bit and 32-bit images are
- available in all versions of Qt. In addition Qt for Embedded Linux
- also supports 2-bit, 4-bit, and 16-bit images. For more information
- about the Qt Extended specific formats, see the documentation of the \l
- Format enum.
+ enum.
Monochrome images are stored using 1-bit indexes into a color table
with at most two colors. There are two different types of
@@ -618,7 +623,7 @@ bool QImageData::checkForAlphaPixels() const
\o Sets the color table used to translate color indexes. Only
monochrome and 8-bit formats.
\row
- \o setNumColors()
+ \o setColorCount()
\o Resizes the color table. Only monochrome and 8-bit formats.
\endtable
@@ -698,9 +703,20 @@ bool QImageData::checkForAlphaPixels() const
packed with the most significant bit (MSB) first.
\value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are
packed with the less significant bit (LSB) first.
- \value Format_Indexed8 The image is stored using 8-bit indexes into a colormap.
+
+ \value Format_Indexed8 The image is stored using 8-bit indexes
+ into a colormap. \warning Drawing into a
+ QImage with Indexed8 format is not
+ supported.
+
\value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB).
- \value Format_ARGB32 The image is stored using a 32-bit ARGB format (0xAARRGGBB).
+
+ \value Format_ARGB32 The image is stored using a 32-bit ARGB
+ format (0xAARRGGBB). \warning Do not
+ render into ARGB32 images using
+ QPainter. Format_ARGB32_Premultiplied is
+ significantly faster.
+
\value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit
ARGB format (0xAARRGGBB), i.e. the red,
green, and blue channels are multiplied
@@ -709,7 +725,9 @@ bool QImageData::checkForAlphaPixels() const
undefined.) Certain operations (such as image composition
using alpha blending) are faster using premultiplied ARGB32
than with plain ARGB32.
+
\value Format_RGB16 The image is stored using a 16-bit RGB format (5-6-5).
+
\value Format_ARGB8565_Premultiplied The image is stored using a
premultiplied 24-bit ARGB format (8-5-6-5).
\value Format_RGB666 The image is stored using a 24-bit RGB format (6-6-6).
@@ -888,7 +906,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
*/
QImage::QImage(uchar* data, int width, int height, Format format)
: QPaintDevice()
@@ -910,7 +928,7 @@ QImage::QImage(uchar* data, int width, int height, Format format)
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
Unlike the similar QImage constructor that takes a non-const data buffer,
this version will never alter the contents of the buffer. For example,
@@ -936,7 +954,7 @@ QImage::QImage(const uchar* data, int width, int height, Format format)
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
*/
QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format)
:QPaintDevice()
@@ -956,7 +974,7 @@ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format form
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
Unlike the similar QImage constructor that takes a non-const data buffer,
this version will never alter the contents of the buffer. For example,
@@ -1108,7 +1126,7 @@ QImage::QImage(const QImage &image)
Use the constructor that accepts a width, a height and a format
(i.e. specifying the depth and bit order), in combination with the
- setNumColors() function, instead.
+ setColorCount() function, instead.
\oldcode
QImage image(width, height, depth, numColors);
@@ -1117,15 +1135,15 @@ QImage::QImage(const QImage &image)
// For 8 bit images the default number of colors is 256. If
// another number of colors is required it can be specified
- // using the setNumColors() function.
- image.setNumColors(numColors);
+ // using the setColorCount() function.
+ image.setColorCount(numColors);
\endcode
*/
-QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
+QImage::QImage(int w, int h, int depth, int colorCount, Endian bitOrder)
: QPaintDevice()
{
- d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), numColors);
+ d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), colorCount);
}
/*!
@@ -1134,7 +1152,7 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
Use the constructor that accepts a size and a format
(i.e. specifying the depth and bit order), in combination with the
- setNumColors() function, instead.
+ setColorCount() function, instead.
\oldcode
QSize mySize(width, height);
@@ -1145,8 +1163,8 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
// For 8 bit images the default number of colors is 256. If
// another number of colors is required it can be specified
- // using the setNumColors() function.
- image.setNumColors(numColors);
+ // using the setColorCount() function.
+ image.setColorCount(numColors);
\endcode
*/
QImage::QImage(const QSize& size, int depth, int numColors, Endian bitOrder)
@@ -1214,7 +1232,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, const QRgb* colortable, int
for (int i = 0; i < numColors; ++i)
d->colortable[i] = colortable[i];
} else if (numColors) {
- setNumColors(numColors);
+ setColorCount(numColors);
}
}
@@ -1265,7 +1283,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, int bpl, const QRgb* colort
for (int i = 0; i < numColors; ++i)
d->colortable[i] = colortable[i];
} else if (numColors) {
- setNumColors(numColors);
+ setColorCount(numColors);
}
}
#endif // Q_WS_QWS
@@ -1574,17 +1592,31 @@ int QImage::depth() const
}
/*!
+ \obsolete
\fn int QImage::numColors() const
Returns the size of the color table for the image.
- Notice that numColors() returns 0 for 32-bpp images because these
+ \sa setColorCount()
+*/
+int QImage::numColors() const
+{
+ return d ? d->colortable.size() : 0;
+}
+
+/*!
+ \since 4.6
+ \fn int QImage::colorCount() const
+
+ Returns the size of the color table for the image.
+
+ Notice that colorCount() returns 0 for 32-bpp images because these
images do not use color tables, but instead encode pixel values as
ARGB quadruplets.
- \sa setNumColors(), {QImage#Image Information}{Image Information}
+ \sa setColorCount(), {QImage#Image Information}{Image Information}
*/
-int QImage::numColors() const
+int QImage::colorCount() const
{
return d ? d->colortable.size() : 0;
}
@@ -1606,6 +1638,7 @@ int QImage::numColors() const
/*!
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.
*/
@@ -1621,6 +1654,8 @@ uchar **QImage::jumpTable()
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;
@@ -1641,6 +1676,8 @@ const uchar * const *QImage::jumpTable() const
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;
@@ -1688,7 +1725,7 @@ void QImage::setColorTable(const QVector<QRgb> colors)
Returns a list of the colors contained in the image's color table,
or an empty list if the image does not have a color table
- \sa setColorTable(), numColors(), color()
+ \sa setColorTable(), colorCount(), color()
*/
QVector<QRgb> QImage::colorTable() const
{
@@ -1697,12 +1734,24 @@ QVector<QRgb> QImage::colorTable() const
/*!
+ \obsolete
+ Returns the number of bytes occupied by the image data.
+
+ \sa byteCount()
+*/
+int QImage::numBytes() const
+{
+ return d ? d->nbytes : 0;
+}
+
+/*!
+ \since 4.6
Returns the number of bytes occupied by the image data.
\sa bytesPerLine(), bits(), {QImage#Image Information}{Image
Information}
*/
-int QImage::numBytes() const
+int QImage::byteCount() const
{
return d ? d->nbytes : 0;
}
@@ -1710,7 +1759,7 @@ int QImage::numBytes() const
/*!
Returns the number of bytes per image scanline.
- This is equivalent to numBytes()/ height().
+ This is equivalent to byteCount() / height().
\sa scanLine()
*/
@@ -1733,7 +1782,7 @@ int QImage::bytesPerLine() const
*/
QRgb QImage::color(int i) const
{
- Q_ASSERT(i < numColors());
+ Q_ASSERT(i < colorCount());
return d ? d->colortable.at(i) : QRgb(uint(-1));
}
@@ -1744,9 +1793,9 @@ QRgb QImage::color(int i) const
given to \a colorValue. The color value is an ARGB quadruplet.
If \a index is outside the current size of the color table, it is
- expanded with setNumColors().
+ expanded with setColorCount().
- \sa color(), numColors(), setColorTable(), {QImage#Pixel Manipulation}{Pixel
+ \sa color(), colorCount(), setColorTable(), {QImage#Pixel Manipulation}{Pixel
Manipulation}
*/
void QImage::setColor(int i, QRgb c)
@@ -1764,7 +1813,7 @@ void QImage::setColor(int i, QRgb c)
return;
if (i >= d->colortable.size())
- setNumColors(i+1);
+ setColorCount(i+1);
d->colortable[i] = c;
d->has_alpha_clut |= (qAlpha(c) != 255);
}
@@ -1821,7 +1870,7 @@ const uchar *QImage::scanLine(int i) const
data, thus ensuring that this QImage is the only one using the
current return value.
- \sa scanLine(), numBytes()
+ \sa scanLine(), byteCount()
*/
uchar *QImage::bits()
{
@@ -2002,8 +2051,21 @@ void QImage::invertPixels(InvertMode mode)
#endif
/*!
+ \obsolete
Resizes the color table to contain \a numColors entries.
+ \sa setColorCount()
+*/
+
+void QImage::setNumColors(int numColors)
+{
+ setColorCount(numColors);
+}
+
+/*!
+ \since 4.6
+ Resizes the color table to contain \a colorCount entries.
+
If the color table is expanded, all the extra colors will be set to
transparent (i.e qRgba(0, 0, 0, 0)).
@@ -2011,14 +2073,14 @@ void QImage::invertPixels(InvertMode mode)
have entries for all the pixel/index values present in the image,
otherwise the results are undefined.
- \sa numColors(), colorTable(), setColor(), {QImage#Image
+ \sa colorCount(), colorTable(), setColor(), {QImage#Image
Transformations}{Image Transformations}
*/
-void QImage::setNumColors(int numColors)
+void QImage::setColorCount(int colorCount)
{
if (!d) {
- qWarning("QImage::setNumColors: null image");
+ qWarning("QImage::setColorCount: null image");
return;
}
@@ -2028,17 +2090,16 @@ void QImage::setNumColors(int numColors)
if (!d)
return;
- if (numColors == d->colortable.size())
+ if (colorCount == d->colortable.size())
return;
- if (numColors <= 0) { // use no color table
+ if (colorCount <= 0) { // use no color table
d->colortable = QVector<QRgb>();
return;
}
int nc = d->colortable.size();
- d->colortable.resize(numColors);
- for (int i = nc; i < numColors; ++i)
+ d->colortable.resize(colorCount);
+ for (int i = nc; i < colorCount; ++i)
d->colortable[i] = 0;
-
}
/*!
@@ -2359,8 +2420,9 @@ static void dither_to_Mono(QImageData *dst, const QImageData *src,
switch (dithermode) {
case Diffuse: {
- int *line1 = new int[w];
- int *line2 = new int[w];
+ QScopedArrayPointer<int> lineBuffer(new int[w * 2]);
+ int *line1 = lineBuffer.data();
+ int *line2 = lineBuffer.data() + w;
int bmwidth = (w+7)/8;
int *b1, *b2;
@@ -2440,8 +2502,6 @@ static void dither_to_Mono(QImageData *dst, const QImageData *src,
b2++;
}
}
- delete [] line1;
- delete [] line2;
} break;
case Ordered: {
@@ -2582,10 +2642,9 @@ static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageC
static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
{
- QImageData *tmp = QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32);
- convert_ARGB_PM_to_ARGB(tmp, src, flags);
- dither_to_Mono(dst, tmp, flags, false);
- delete tmp;
+ QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32));
+ convert_ARGB_PM_to_ARGB(tmp.data(), src, flags);
+ dither_to_Mono(dst, tmp.data(), flags, false);
}
//
@@ -2734,15 +2793,16 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::
int* line1[3];
int* line2[3];
int* pv[3];
- line1[0] = new int[src->width];
- line2[0] = new int[src->width];
- line1[1] = new int[src->width];
- line2[1] = new int[src->width];
- line1[2] = new int[src->width];
- line2[2] = new int[src->width];
- pv[0] = new int[src->width];
- pv[1] = new int[src->width];
- pv[2] = new int[src->width];
+ QScopedArrayPointer<int> lineBuffer(new int[src->width * 9]);
+ line1[0] = lineBuffer.data();
+ line2[0] = lineBuffer.data() + src->width;
+ line1[1] = lineBuffer.data() + src->width * 2;
+ line2[1] = lineBuffer.data() + src->width * 3;
+ line1[2] = lineBuffer.data() + src->width * 4;
+ line2[2] = lineBuffer.data() + src->width * 5;
+ pv[0] = lineBuffer.data() + src->width * 6;
+ pv[1] = lineBuffer.data() + src->width * 7;
+ pv[2] = lineBuffer.data() + src->width * 8;
int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
for (int y = 0; y < src->height; y++) {
@@ -2805,15 +2865,6 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::
src_data += src->bytes_per_line;
dest_data += dst->bytes_per_line;
}
- delete [] line1[0];
- delete [] line2[0];
- delete [] line1[1];
- delete [] line2[1];
- delete [] line1[2];
- delete [] line2[2];
- delete [] pv[0];
- delete [] pv[1];
- delete [] pv[2];
} else { // OrderedDither
for (int y = 0; y < src->height; y++) {
const QRgb *p = (const QRgb *)src_data;
@@ -2846,8 +2897,8 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::
const int trans = 216;
Q_ASSERT(dst->colortable.size() > trans);
dst->colortable[trans] = 0;
- QImageData *mask = QImageData::create(QSize(src->width, src->height), QImage::Format_Mono);
- dither_to_Mono(mask, src, flags, true);
+ QScopedPointer<QImageData> mask(QImageData::create(QSize(src->width, src->height), QImage::Format_Mono));
+ dither_to_Mono(mask.data(), src, flags, true);
uchar *dst_data = dst->data;
const uchar *mask_data = mask->data;
for (int y = 0; y < src->height; y++) {
@@ -2859,7 +2910,6 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::
dst_data += dst->bytes_per_line;
}
dst->has_alpha_clut = true;
- delete mask;
}
#undef MAX_R
@@ -2872,10 +2922,9 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::
static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
{
- QImageData *tmp = QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32);
- convert_ARGB_PM_to_ARGB(tmp, src, flags);
- convert_RGB_to_Indexed8(dst, tmp, flags);
- delete tmp;
+ QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32));
+ convert_ARGB_PM_to_ARGB(tmp.data(), src, flags);
+ convert_RGB_to_Indexed8(dst, tmp.data(), flags);
}
static void convert_ARGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
@@ -2893,6 +2942,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt:
Q_ASSERT(src->height == dest->height);
QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format);
+ if (colorTable.size() == 0) {
+ colorTable.resize(256);
+ for (int i=0; i<256; ++i)
+ colorTable[i] = qRgb(i, i, i);
+
+ }
int w = src->width;
const uchar *src_data = src->data;
@@ -3657,7 +3712,7 @@ QRgb QImage::pixel(int x, int y) const
otherwise the parameter must be a QRgb value.
If \a position is not a valid coordinate pair in the image, or if
- \a index_or_rgb >= numColors() in the case of monochrome and
+ \a index_or_rgb >= colorCount() in the case of monochrome and
8-bit images, the result is undefined.
\warning This function is expensive due to the call of the internal
@@ -3818,7 +3873,7 @@ bool QImage::allGray() const
} else {
if (d->colortable.isEmpty())
return true;
- for (int i = 0; i < numColors(); i++)
+ for (int i = 0; i < colorCount(); i++)
if (!qIsGray(d->colortable.at(i)))
return false;
}
@@ -3845,7 +3900,7 @@ bool QImage::isGrayscale() const
case 16:
return allGray();
case 8: {
- for (int i = 0; i < numColors(); i++)
+ for (int i = 0; i < colorCount(); i++)
if (d->colortable.at(i) != qRgb(i,i,i))
return false;
return true;
@@ -4066,7 +4121,8 @@ QImage QImage::createAlphaMask(Qt::ImageConversionFlags flags) const
}
QImage mask(d->width, d->height, Format_MonoLSB);
- dither_to_Mono(mask.d, d, flags, true);
+ if (!mask.isNull())
+ dither_to_Mono(mask.d, d, flags, true);
return mask;
}
@@ -4110,7 +4166,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const
int w = width();
int h = height();
QImage m(w, h, Format_MonoLSB);
- m.setNumColors(2);
+ m.setColorCount(2);
m.setColor(0, QColor(Qt::color0).rgba());
m.setColor(1, QColor(Qt::color1).rgba());
m.fill(0xff);
@@ -5685,7 +5741,7 @@ QImage QImage::alphaChannel() const
int h = d->height;
QImage image(w, h, Format_Indexed8);
- image.setNumColors(256);
+ image.setColorCount(256);
// set up gray scale table.
for (int i=0; i<256; ++i)
@@ -5815,7 +5871,7 @@ static QImage smoothScaled(const QImage &source, int w, int h) {
static QImage rotated90(const QImage &image) {
QImage out(image.height(), image.width(), image.format());
- if (image.numColors() > 0)
+ if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
int h = image.height();
@@ -5854,7 +5910,7 @@ static QImage rotated90(const QImage &image) {
break;
default:
for (int y=0; y<h; ++y) {
- if (image.numColors())
+ if (image.colorCount())
for (int x=0; x<w; ++x)
out.setPixel(h-y-1, x, image.pixelIndex(x, y));
else
@@ -5874,7 +5930,7 @@ static QImage rotated180(const QImage &image) {
static QImage rotated270(const QImage &image) {
QImage out(image.height(), image.width(), image.format());
- if (image.numColors() > 0)
+ if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
int h = image.height();
@@ -5913,7 +5969,7 @@ static QImage rotated270(const QImage &image) {
break;
default:
for (int y=0; y<h; ++y) {
- if (image.numColors())
+ if (image.colorCount())
for (int x=0; x<w; ++x)
out.setPixel(y, w-x-1, image.pixelIndex(x, y));
else
@@ -6053,16 +6109,16 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
if (dImage.d->colortable.size() < 256) {
// colors are left in the color table, so pick that one as transparent
dImage.d->colortable.append(0x0);
- memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.numBytes());
+ memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount());
} else {
- memset(dImage.bits(), 0, dImage.numBytes());
+ memset(dImage.bits(), 0, dImage.byteCount());
}
break;
case 1:
case 16:
case 24:
case 32:
- memset(dImage.bits(), 0x00, dImage.numBytes());
+ memset(dImage.bits(), 0x00, dImage.byteCount());
break;
}
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 84e97dc28..d8809ef11 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -165,18 +165,21 @@ public:
QRect rect() const;
int depth() const;
- int numColors() const;
+ QT_DEPRECATED int numColors() const;
+ int colorCount() const;
QRgb color(int i) const;
void setColor(int i, QRgb c);
- void setNumColors(int);
+ QT_DEPRECATED void setNumColors(int);
+ void setColorCount(int);
bool allGray() const;
bool isGrayscale() const;
uchar *bits();
const uchar *bits() const;
- int numBytes() const;
+ QT_DEPRECATED int numBytes() const;
+ int byteCount() const;
uchar *scanLine(int);
const uchar *scanLine(int) const;
@@ -314,7 +317,7 @@ private:
QImageData *d;
friend class QRasterPixmapData;
- friend class QDetachedPixmap;
+ friend class QPixmapCacheEntry;
friend Q_GUI_EXPORT qint64 qt_image_id(const QImage &image);
friend const QVector<QRgb> *qt_image_colortable(const QImage &image);
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 80dd519a7..bea1e8d2a 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,7 +63,7 @@
QT_BEGIN_NAMESPACE
-struct QImageData { // internal image data
+struct Q_GUI_EXPORT QImageData { // internal image data
QImageData();
~QImageData();
static QImageData *create(const QSize &size, QImage::Format format, int numColors = 0);
diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp
index cae692208..99a5ad486 100644
--- a/src/gui/image/qimageiohandler.cpp
+++ b/src/gui/image/qimageiohandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -272,7 +272,6 @@ QImageIOHandler::QImageIOHandler(QImageIOHandlerPrivate &dd)
*/
QImageIOHandler::~QImageIOHandler()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index 02afbb836..980c1777e 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -44,6 +44,7 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -109,7 +110,7 @@ public:
protected:
QImageIOHandler(QImageIOHandlerPrivate &dd);
- QImageIOHandlerPrivate *d_ptr;
+ QScopedPointer<QImageIOHandlerPrivate> d_ptr;
private:
Q_DISABLE_COPY(QImageIOHandler)
};
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index 10573fd14..e411cd17c 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,27 +21,27 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qimagepixmapcleanuphooks_p.h"
-#include "qpixmapdata_p.h"
+#include "private/qpixmapdata_p.h"
+#include "private/qimage_p.h"
QT_BEGIN_NAMESPACE
@@ -54,35 +55,37 @@ Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0;
Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0;
Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0;
+Q_GLOBAL_STATIC(QImagePixmapCleanupHooks, qt_image_and_pixmap_cleanup_hooks)
-QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks = 0;
-
-
-QImagePixmapCleanupHooks::QImagePixmapCleanupHooks()
+QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance()
{
- qt_image_and_pixmap_cleanup_hooks = this;
+ return qt_image_and_pixmap_cleanup_hooks();
}
-QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance()
+void QImagePixmapCleanupHooks::addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook)
{
- if (!qt_image_and_pixmap_cleanup_hooks)
- qt_image_and_pixmap_cleanup_hooks = new QImagePixmapCleanupHooks;
- return qt_image_and_pixmap_cleanup_hooks;
+ pixmapModificationHooks.append(hook);
}
-void QImagePixmapCleanupHooks::addPixmapHook(_qt_pixmap_cleanup_hook_pm hook)
+void QImagePixmapCleanupHooks::addPixmapDestructionHook(_qt_pixmap_cleanup_hook_pm hook)
{
- pixmapHooks.append(hook);
+ pixmapDestructionHooks.append(hook);
}
+
void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook)
{
imageHooks.append(hook);
}
-void QImagePixmapCleanupHooks::removePixmapHook(_qt_pixmap_cleanup_hook_pm hook)
+void QImagePixmapCleanupHooks::removePixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook)
+{
+ pixmapModificationHooks.removeAll(hook);
+}
+
+void QImagePixmapCleanupHooks::removePixmapDestructionHook(_qt_pixmap_cleanup_hook_pm hook)
{
- pixmapHooks.removeAll(hook);
+ pixmapDestructionHooks.removeAll(hook);
}
void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
@@ -90,24 +93,48 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
imageHooks.removeAll(hook);
}
-
-void QImagePixmapCleanupHooks::executePixmapHooks(QPixmap* pm)
+void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm)
{
- for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapHooks.count(); ++i)
- qt_image_and_pixmap_cleanup_hooks->pixmapHooks[i](pm);
+ QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ for (int i = 0; i < h->pixmapModificationHooks.count(); ++i)
+ h->pixmapModificationHooks[i](pm);
if (qt_pixmap_cleanup_hook_64)
qt_pixmap_cleanup_hook_64(pm->cacheKey());
}
+void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm)
+{
+ QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ for (int i = 0; i < h->pixmapModificationHooks.count(); ++i)
+ qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks[i](pm);
+
+ if (qt_pixmap_cleanup_hook_64)
+ qt_pixmap_cleanup_hook_64(pm->cacheKey());
+}
void QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
{
- for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i)
- qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key);
+ for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->imageHooks.count(); ++i)
+ qt_image_and_pixmap_cleanup_hooks()->imageHooks[i](key);
if (qt_image_cleanup_hook_64)
qt_image_cleanup_hook_64(key);
}
+void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap)
+{
+ enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data());
+}
+
+void QImagePixmapCleanupHooks::enableCleanupHooks(QPixmapData *pixmapData)
+{
+ pixmapData->is_cached = true;
+}
+
+void QImagePixmapCleanupHooks::enableCleanupHooks(const QImage &image)
+{
+ const_cast<QImage &>(image).data_ptr()->is_cached = true;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h
index 1eaee38e3..dfc5f2837 100644
--- a/src/gui/image/qimagepixmapcleanuphooks_p.h
+++ b/src/gui/image/qimagepixmapcleanuphooks_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,27 +61,37 @@ typedef void (*_qt_image_cleanup_hook_64)(qint64);
typedef void (*_qt_pixmap_cleanup_hook_pm)(QPixmap*);
class QImagePixmapCleanupHooks;
-extern QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks;
class Q_GUI_EXPORT QImagePixmapCleanupHooks
{
public:
- QImagePixmapCleanupHooks();
-
static QImagePixmapCleanupHooks *instance();
- void addPixmapHook(_qt_pixmap_cleanup_hook_pm);
+ static void enableCleanupHooks(const QImage &image);
+ static void enableCleanupHooks(const QPixmap &pixmap);
+ static void enableCleanupHooks(QPixmapData *pixmapData);
+
+ // Gets called when a pixmap is about to be modified:
+ void addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm);
+
+ // Gets called when a pixmap is about to be destroyed:
+ void addPixmapDestructionHook(_qt_pixmap_cleanup_hook_pm);
+
+ // Gets called when an image is about to be modified or destroyed:
void addImageHook(_qt_image_cleanup_hook_64);
- void removePixmapHook(_qt_pixmap_cleanup_hook_pm);
+ void removePixmapModificationHook(_qt_pixmap_cleanup_hook_pm);
+ void removePixmapDestructionHook(_qt_pixmap_cleanup_hook_pm);
void removeImageHook(_qt_image_cleanup_hook_64);
- static void executePixmapHooks(QPixmap*);
+ static void executePixmapModificationHooks(QPixmap*);
+ static void executePixmapDestructionHooks(QPixmap*);
static void executeImageHooks(qint64 key);
private:
QList<_qt_image_cleanup_hook_64> imageHooks;
- QList<_qt_pixmap_cleanup_hook_pm> pixmapHooks;
+ QList<_qt_pixmap_cleanup_hook_pm> pixmapModificationHooks;
+ QList<_qt_pixmap_cleanup_hook_pm> pixmapDestructionHooks;
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 06c8f21e9..074f3eb56 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,7 +47,7 @@
for reading images from files or other devices.
\reentrant
- \ingroup multimedia
+ \ingroup painting
\ingroup io
The most common way to read images is through QImage and QPixmap's
@@ -195,7 +195,9 @@ static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = {
};
static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
- const QByteArray &format, bool autoDetectImageFormat)
+ const QByteArray &format,
+ bool autoDetectImageFormat,
+ bool ignoresFormatAndExtension)
{
if (!autoDetectImageFormat && format.isEmpty())
return 0;
@@ -217,7 +219,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
int suffixPluginIndex = -1;
- if (device && format.isEmpty() && autoDetectImageFormat) {
+ if (device && format.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) {
// if there's no format, see if \a device is a file, and if so, find
// the file suffix and find support for that format among our plugins.
// this allows plugins to override our built-in handlers.
@@ -241,6 +243,9 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
QByteArray testFormat = !form.isEmpty() ? form : suffix;
+ if (ignoresFormatAndExtension)
+ testFormat = QByteArray();
+
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
if (suffixPluginIndex != -1) {
// check if the plugin that claims support for this format can load
@@ -258,7 +263,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
device->seek(pos);
}
- if (!handler && !testFormat.isEmpty() && autoDetectImageFormat) {
+ if (!handler && !testFormat.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) {
// check if any plugin supports the format (they are not allowed to
// read from the device yet).
const qint64 pos = device ? device->pos() : 0;
@@ -315,7 +320,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
}
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- if (!handler && autoDetectImageFormat) {
+ if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) {
// check if any of our plugins recognize the file from its contents.
const qint64 pos = device ? device->pos() : 0;
for (int i = 0; i < keys.size(); ++i) {
@@ -335,7 +340,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
}
#endif
- if (!handler && autoDetectImageFormat) {
+ if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) {
// check if any of our built-in handlers recognize the file from its
// contents.
int currentFormat = 0;
@@ -434,6 +439,7 @@ public:
// device
QByteArray format;
bool autoDetectImageFormat;
+ bool ignoresFormatAndExtension;
QIODevice *device;
bool deleteDevice;
QImageIOHandler *handler;
@@ -458,7 +464,7 @@ public:
\internal
*/
QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq)
- : autoDetectImageFormat(true)
+ : autoDetectImageFormat(true), ignoresFormatAndExtension(false)
{
device = 0;
deleteDevice = false;
@@ -522,7 +528,7 @@ bool QImageReaderPrivate::initHandler()
}
// assign a handler
- if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat)) == 0) {
+ if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == 0) {
imageReaderError = QImageReader::UnsupportedFormatError;
errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unsupported image format"));
return false;
@@ -664,7 +670,7 @@ QByteArray QImageReader::format() const
\o Finally, if all above approaches fail, QImageReader will report failure
when trying to read the image.
- \endlist
+ \endlist
By disabling image format autodetection, QImageReader will only query the
plugins and built-in handlers based on the format string (i.e., no file
@@ -681,13 +687,48 @@ void QImageReader::setAutoDetectImageFormat(bool enabled)
Returns true if image format autodetection is enabled on this image
reader; otherwise returns false. By default, autodetection is enabled.
- \sa setAutoDetectImageFormat()
+ \sa setAutoDetectImageFormat()
*/
bool QImageReader::autoDetectImageFormat() const
{
return d->autoDetectImageFormat;
}
+
+/*!
+ If \a ignored is set to true, then the image reader will ignore
+ specified formats or file extensions and decide which plugin to
+ use only based on the contents in the datastream.
+
+ Setting this flag means that all image plugins gets loaded. Each
+ plugin will read the first bytes in the image data and decide if
+ the plugin is compatible or not.
+
+ This also disables auto detecting the image format.
+
+ \sa decideFormatFromContent()
+*/
+
+void QImageReader::setDecideFormatFromContent(bool ignored)
+{
+ d->ignoresFormatAndExtension = ignored;
+}
+
+
+/*!
+ Returns whether the image reader should decide which plugin to use
+ only based on the contents of the datastream rather than on the file
+ extension.
+
+ \sa setDecideFormatFromContent()
+*/
+
+bool QImageReader::decideFormatFromContent() const
+{
+ return d->ignoresFormatAndExtension;
+}
+
+
/*!
Sets QImageReader's device to \a device. If a device has already
been set, the old device is removed from QImageReader and is
@@ -1309,7 +1350,7 @@ QByteArray QImageReader::imageFormat(const QString &fileName)
QByteArray QImageReader::imageFormat(QIODevice *device)
{
QByteArray format;
- QImageIOHandler *handler = createReadHandlerHelper(device, format, /* autoDetectImageFormat = */ true);
+ QImageIOHandler *handler = createReadHandlerHelper(device, format, /* autoDetectImageFormat = */ true, false);
if (handler) {
if (handler->canRead())
format = handler->format();
diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h
index 33f654a68..11affb8a9 100644
--- a/src/gui/image/qimagereader.h
+++ b/src/gui/image/qimagereader.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -81,6 +81,9 @@ public:
void setAutoDetectImageFormat(bool enabled);
bool autoDetectImageFormat() const;
+ void setDecideFormatFromContent(bool ignored);
+ bool decideFormatFromContent() const;
+
void setDevice(QIODevice *device);
QIODevice *device() const;
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index c73416975..a0d8eb793 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -45,7 +45,7 @@
for writing images to files or other devices.
\reentrant
- \ingroup multimedia
+ \ingroup painting
\ingroup io
QImageWriter supports setting format specific options, such as the
diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h
index 7dcd6d0d4..6a7c2715b 100644
--- a/src/gui/image/qimagewriter.h
+++ b/src/gui/image/qimagewriter.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp
index c341e5e9b..42b8dea10 100644
--- a/src/gui/image/qmovie.cpp
+++ b/src/gui/image/qmovie.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -45,7 +45,11 @@
\brief The QMovie class is a convenience class for playing movies
with QImageReader.
- \ingroup multimedia
+ \ingroup painting
+
+ This class is used to show simple animations without sound. If you want
+ to display video and media content, use the \l{Phonon Module}{Phonon}
+ multimedia framework instead.
First, create a QMovie object by passing either the name of a file or a
pointer to a QIODevice containing an animated image format to QMovie's
diff --git a/src/gui/image/qmovie.h b/src/gui/image/qmovie.h
index d012b0102..b11f3324e 100644
--- a/src/gui/image/qmovie.h
+++ b/src/gui/image/qmovie.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 1e1c7fddf..3b43ab604 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -148,11 +148,15 @@ QImage::Format QNativeImage::systemFormat()
#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) {
- xshmimg = 0;
- xshmpm = 0;
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;
}
@@ -174,6 +178,8 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
if (ok) {
xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
xshminfo.shmaddr = xshmimg->data;
+ if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
+ qWarning() << "Error while marking the shared memory segment to be destroyed";
ok = (xshminfo.shmaddr != (char*)-1);
if (ok)
image = QImage((uchar *)xshmimg->data, width, height, systemFormat());
@@ -195,10 +201,12 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
shmctl(xshminfo.shmid, IPC_RMID, 0);
return;
}
- xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data,
- &xshminfo, width, height, dd);
- if (!xshmpm) {
- qWarning() << "QNativeImage: Unable to create shared Pixmap.";
+ 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.";
+ }
}
}
diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/image/qnativeimage_p.h
index ab181f30b..5b32c285b 100644
--- a/src/gui/image/qnativeimage_p.h
+++ b/src/gui/image/qnativeimage_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp
index ee88bec2d..80b16cf6d 100644
--- a/src/gui/image/qpaintengine_pic.cpp
+++ b/src/gui/image/qpaintengine_pic.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpaintengine_pic_p.h b/src/gui/image/qpaintengine_pic_p.h
index b8134ef99..fae96499c 100644
--- a/src/gui/image/qpaintengine_pic_p.h
+++ b/src/gui/image/qpaintengine_pic_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index fbc2a5d6a..f502827bb 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -69,9 +69,9 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
\brief The QPicture class is a paint device that records and
replays QPainter commands.
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
- \mainclass
+
A picture serializes painter commands to an IO device in a
platform-independent format. They are sometimes referred to as meta-files.
@@ -131,8 +131,6 @@ QPicture::QPicture(int formatVersion)
d_ptr(new QPicturePrivate)
{
Q_D(QPicture);
- d_ptr->q_ptr = this;
- d->paintEngine = 0;
if (formatVersion == 0)
qWarning("QPicture: invalid format version 0");
@@ -142,8 +140,7 @@ QPicture::QPicture(int formatVersion)
d->formatMajor = formatVersion;
d->formatMinor = 0;
d->formatOk = false;
- }
- else {
+ } else {
d->resetFormat();
}
}
@@ -157,7 +154,6 @@ QPicture::QPicture(int formatVersion)
QPicture::QPicture(const QPicture &pic)
: QPaintDevice(), d_ptr(pic.d_ptr)
{
- d_func()->ref.ref();
}
/*! \internal */
@@ -165,7 +161,6 @@ QPicture::QPicture(QPicturePrivate &dptr)
: QPaintDevice(),
d_ptr(&dptr)
{
- d_ptr->q_ptr = this;
}
/*!
@@ -173,10 +168,6 @@ QPicture::QPicture(QPicturePrivate &dptr)
*/
QPicture::~QPicture()
{
- if (!d_func()->ref.deref()) {
- delete d_func()->paintEngine;
- delete d_func();
- }
}
/*!
@@ -230,8 +221,7 @@ const char* QPicture::data() const
void QPicture::detach()
{
- if (d_func()->ref != 1)
- detach_helper();
+ d_ptr.detach();
}
bool QPicture::isDetached() const
@@ -1017,24 +1007,16 @@ int QPicture::metric(PaintDeviceMetric m) const
/*! \fn bool QPicture::isDetached() const
\internal
*/
+
+/*! \internal
+### Qt 5 - remove me
+ */
void QPicture::detach_helper()
{
- Q_D(QPicture);
- QPicturePrivate *x = new QPicturePrivate;
- int pictsize = size();
- x->pictb.setData(data(), pictsize);
- if (d->pictb.isOpen()) {
- x->pictb.open(d->pictb.openMode());
- x->pictb.seek(d->pictb.pos());
- }
- x->trecs = d->trecs;
- x->formatOk = d->formatOk;
- x->formatMinor = d->formatMinor;
- x->brect = d->brect;
- x->override_rect = d->override_rect;
- if (!d->ref.deref())
- delete d;
- d_ptr = x;
+ // QExplicitelySharedDataPointer takes care of cloning using
+ // QPicturePrivate's copy constructor. Do not call detach_helper() anymore
+ // and remove in Qt 5, please.
+ Q_ASSERT_X(false, "QPicture::detach_helper()", "Do not call this function");
}
/*!
@@ -1043,13 +1025,43 @@ void QPicture::detach_helper()
*/
QPicture& QPicture::operator=(const QPicture &p)
{
- qAtomicAssign<QPicturePrivate>(d_ptr, p.d_ptr);
+ d_ptr = p.d_ptr;
return *this;
}
/*!
\internal
+ Constructs a QPicturePrivate
+*/
+QPicturePrivate::QPicturePrivate()
+ : in_memory_only(false)
+{
+}
+
+/*!
+ \internal
+
+ Copy-Constructs a QPicturePrivate. Needed when detaching.
+*/
+QPicturePrivate::QPicturePrivate(const QPicturePrivate &other)
+ : trecs(other.trecs),
+ formatOk(other.formatOk),
+ formatMinor(other.formatMinor),
+ brect(other.brect),
+ override_rect(other.override_rect),
+ in_memory_only(false)
+{
+ pictb.setData(other.pictb.data(), other.pictb.size());
+ if (other.pictb.isOpen()) {
+ pictb.open(other.pictb.openMode());
+ pictb.seek(other.pictb.pos());
+ }
+}
+
+/*!
+ \internal
+
Sets formatOk to false and resets the format version numbers to default
*/
@@ -1137,8 +1149,8 @@ bool QPicturePrivate::checkFormat()
QPaintEngine *QPicture::paintEngine() const
{
if (!d_func()->paintEngine)
- const_cast<QPicture*>(this)->d_func()->paintEngine = new QPicturePaintEngine;
- return d_func()->paintEngine;
+ const_cast<QPicture*>(this)->d_func()->paintEngine.reset(new QPicturePaintEngine);
+ return d_func()->paintEngine.data();
}
/*****************************************************************************
@@ -1298,7 +1310,7 @@ QList<QByteArray> QPicture::outputFormats()
\brief The QPictureIO class contains parameters for loading and
saving pictures.
- \ingroup multimedia
+ \ingroup painting
\ingroup io
QPictureIO contains a QIODevice object that is used for picture data
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index fa770e06b..d88f37fe5 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,8 +42,9 @@
#ifndef QPICTURE_H
#define QPICTURE_H
-#include <QtGui/qpaintdevice.h>
#include <QtCore/qstringlist.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtGui/qpaintdevice.h>
QT_BEGIN_HEADER
@@ -106,14 +107,14 @@ private:
bool exec(QPainter *p, QDataStream &ds, int i);
void detach_helper();
- QPicturePrivate *d_ptr;
+ QExplicitlySharedDataPointer<QPicturePrivate> d_ptr;
friend class QPicturePaintEngine;
friend class Q3Picture;
friend class QAlphaPaintEngine;
friend class QPreviewPaintEngine;
public:
- typedef QPicturePrivate* DataPtr;
+ typedef QExplicitlySharedDataPointer<QPicturePrivate> DataPtr;
inline DataPtr &data_ptr() { return d_ptr; }
};
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index 0d08e65cf..c1dd129cc 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -71,7 +71,6 @@ extern const char *qt_mfhdr_tag;
class QPicturePrivate
{
- Q_DECLARE_PUBLIC(QPicture)
friend class QPicturePaintEngine;
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPicture &r);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &s, QPicture &r);
@@ -143,7 +142,8 @@ public:
PdcReservedStop = 199 // for Qt
};
- inline QPicturePrivate() : in_memory_only(false), q_ptr(0) { ref = 1; }
+ QPicturePrivate();
+ QPicturePrivate(const QPicturePrivate &other);
QAtomicInt ref;
bool checkFormat();
@@ -156,14 +156,12 @@ public:
int formatMinor;
QRect brect;
QRect override_rect;
- QPaintEngine *paintEngine;
+ QScopedPointer<QPaintEngine> paintEngine;
bool in_memory_only;
QList<QImage> image_list;
QList<QPixmap> pixmap_list;
QList<QBrush> brush_list;
QList<QPen> pen_list;
-
- QPicture *q_ptr;
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qpictureformatplugin.cpp b/src/gui/image/qpictureformatplugin.cpp
index 529403b95..af4e3b5dc 100644
--- a/src/gui/image/qpictureformatplugin.cpp
+++ b/src/gui/image/qpictureformatplugin.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpictureformatplugin.h b/src/gui/image/qpictureformatplugin.h
index 7bdc270c7..88bf5f4ce 100644
--- a/src/gui/image/qpictureformatplugin.h
+++ b/src/gui/image/qpictureformatplugin.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 81440b314..406dc0b4f 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -77,6 +77,10 @@
# include <private/qpixmap_x11_p.h>
#endif
+#if defined(Q_OS_SYMBIAN)
+# include <private/qt_s60_p.h>
+#endif
+
#include "qpixmap_raster_p.h"
QT_BEGIN_NAMESPACE
@@ -109,14 +113,10 @@ void QPixmap::init(int w, int h, Type type)
void QPixmap::init(int w, int h, int type)
{
- QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- if (gs)
- data = gs->createPixmapData(static_cast<QPixmapData::PixelType>(type));
+ if ((w > 0 && h > 0) || type == QPixmapData::BitmapType)
+ data = QPixmapData::create(w, h, (QPixmapData::PixelType) type);
else
- data = QGraphicsSystem::createDefaultPixmapData(static_cast<QPixmapData::PixelType>(type));
-
- data->resize(w, h);
- data->ref.ref();
+ data = 0;
}
/*!
@@ -218,7 +218,6 @@ QPixmap::QPixmap(const QSize &s, int type)
QPixmap::QPixmap(QPixmapData *d)
: QPaintDevice(), data(d)
{
- data->ref.ref();
}
/*!
@@ -274,11 +273,9 @@ QPixmap::QPixmap(const QPixmap &pixmap)
return;
}
if (pixmap.paintingActive()) { // make a deep copy
- data = 0;
operator=(pixmap.copy());
} else {
data = pixmap.data;
- data->ref.ref();
}
}
@@ -307,7 +304,7 @@ QPixmap::QPixmap(const char * const xpm[])
QImage image(xpm);
if (!image.isNull()) {
- if (data->pixelType() == QPixmapData::BitmapType)
+ if (data && data->pixelType() == QPixmapData::BitmapType)
*this = QBitmap::fromImage(image);
else
*this = fromImage(image);
@@ -322,7 +319,9 @@ QPixmap::QPixmap(const char * const xpm[])
QPixmap::~QPixmap()
{
- deref();
+ Q_ASSERT(!data || data->ref >= 1); // Catch if ref-counting changes again
+ if (data && data->is_cached && data->ref == 1) // ref will be decrememnted after destructor returns
+ QImagePixmapCleanupHooks::executePixmapDestructionHooks(this);
}
/*!
@@ -360,14 +359,8 @@ QPixmap QPixmap::copy(const QRect &rect) const
const QRect r = rect.isEmpty() ? QRect(0, 0, width(), height()) : rect;
- QPixmapData *d;
- QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- if (gs)
- d = gs->createPixmapData(data->pixelType());
- else
- d = QGraphicsSystem::createDefaultPixmapData(data->pixelType());
-
- d->copy(data, r);
+ QPixmapData *d = data->createCompatiblePixmapData();
+ d->copy(data.data(), r);
return QPixmap(d);
}
@@ -440,8 +433,6 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap)
if (pixmap.paintingActive()) { // make a deep copy
*this = pixmap.copy();
} else {
- pixmap.data->ref.ref(); // avoid 'x = x'
- deref();
data = pixmap.data;
}
return *this;
@@ -476,9 +467,11 @@ QPixmap::operator QVariant() const
conversion fails.
If the pixmap has 1-bit depth, the returned image will also be 1
- bit deep. If the pixmap has 2- to 8-bit depth, the returned image
- has 8-bit depth. If the pixmap has greater than 8-bit depth, the
- returned image has 32-bit depth.
+ bit deep. Images with more bits will be returned in a format
+ closely represents the underlying system. Usually this will be
+ QImage::Format_ARGB32_Premultiplied for pixmaps with an alpha and
+ QImage::Format_RGB32 or QImage::Format_RGB16 for pixmaps without
+ alpha.
Note that for the moment, alpha masks on monochrome images are
ignored.
@@ -548,7 +541,7 @@ bool QPixmap::isQBitmap() const
*/
bool QPixmap::isNull() const
{
- return data->isNull();
+ return !data || data->isNull();
}
/*!
@@ -560,7 +553,7 @@ bool QPixmap::isNull() const
*/
int QPixmap::width() const
{
- return data->width();
+ return data ? data->width() : 0;
}
/*!
@@ -572,7 +565,7 @@ int QPixmap::width() const
*/
int QPixmap::height() const
{
- return data->height();
+ return data ? data->height() : 0;
}
/*!
@@ -585,7 +578,7 @@ int QPixmap::height() const
*/
QSize QPixmap::size() const
{
- return QSize(data->width(), data->height());
+ return data ? QSize(data->width(), data->height()) : QSize();
}
/*!
@@ -597,7 +590,7 @@ QSize QPixmap::size() const
*/
QRect QPixmap::rect() const
{
- return QRect(0, 0, data->width(), data->height());
+ return data ? QRect(0, 0, data->width(), data->height()) : QRect();
}
/*!
@@ -613,7 +606,7 @@ QRect QPixmap::rect() const
*/
int QPixmap::depth() const
{
- return data->depth();
+ return data ? data->depth() : 0;
}
/*!
@@ -643,16 +636,16 @@ void QPixmap::resize_helper(const QSize &s)
return;
// Create new pixmap
- QPixmap pm(QSize(w, h), data->type);
+ QPixmap pm(QSize(w, h), data ? data->type : QPixmapData::PixmapType);
bool uninit = false;
#if defined(Q_WS_X11)
- QX11PixmapData *x11Data = data->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(data) : 0;
+ QX11PixmapData *x11Data = data && data->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(data.data()) : 0;
if (x11Data) {
pm.x11SetScreen(x11Data->xinfo.screen());
uninit = x11Data->flags & QX11PixmapData::Uninitialized;
}
#elif defined(Q_WS_MAC)
- QMacPixmapData *macData = data->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data) : 0;
+ QMacPixmapData *macData = data && data->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data.data()) : 0;
if (macData)
uninit = macData->uninit;
#endif
@@ -666,7 +659,7 @@ void QPixmap::resize_helper(const QSize &s)
#if defined(Q_WS_X11)
if (x11Data && x11Data->x11_mask) {
- QX11PixmapData *pmData = static_cast<QX11PixmapData*>(pm.data);
+ QX11PixmapData *pmData = static_cast<QX11PixmapData*>(pm.data.data());
pmData->x11_mask = (Qt::HANDLE)XCreatePixmap(X11->display,
RootWindow(x11Data->xinfo.display(),
x11Data->xinfo.screen()),
@@ -732,6 +725,9 @@ void QPixmap::setMask(const QBitmap &mask)
return;
}
+ if (isNull())
+ return;
+
if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask
return;
@@ -830,24 +826,19 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
QFileInfo info(fileName);
QString key = QLatin1String("qt_pixmap_") + info.absoluteFilePath() + QLatin1Char('_') + QString::number(info.lastModified().toTime_t()) + QLatin1Char('_') +
- QString::number(info.size()) + QLatin1Char('_') + QString::number(data->pixelType());
+ QString::number(info.size()) + QLatin1Char('_') + QString::number(data ? data->pixelType() : QPixmapData::PixmapType);
if (QPixmapCache::find(key, *this))
return true;
- QImage image = QImageReader(fileName, format).read();
- if (image.isNull())
- return false;
- QPixmap pm;
- if (data->pixelType() == QPixmapData::BitmapType)
- pm = QBitmap::fromImage(image, flags);
- else
- pm = fromImage(image, flags);
- if (!pm.isNull()) {
- *this = pm;
+ if (!data)
+ data = QPixmapData::create(0, 0, QPixmapData::PixmapType);
+
+ if (data->fromFile(fileName, format, flags)) {
QPixmapCache::insert(key, *this);
return true;
}
+
return false;
}
@@ -872,21 +863,13 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
{
- QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buf), len);
- QBuffer b(&a);
- b.open(QIODevice::ReadOnly);
+ if (len == 0 || buf == 0)
+ return false;
- QImage image = QImageReader(&b, format).read();
- QPixmap pm;
- if (data->pixelType() == QPixmapData::BitmapType)
- pm = QBitmap::fromImage(image, flags);
- else
- pm = fromImage(image, flags);
- if (!pm.isNull()) {
- *this = pm;
- return true;
- }
- return false;
+ if (!data)
+ data = QPixmapData::create(0, 0, QPixmapData::PixmapType);
+
+ return data->fromData(buf, len, format, flags);
}
/*!
@@ -970,6 +953,9 @@ bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
/*!
Fills the pixmap with the given \a color.
+ The effect of this function is undefined when the pixmap is
+ being painted on.
+
\sa {QPixmap#Pixmap Transformations}{Pixmap Transformations}
*/
@@ -978,7 +964,24 @@ void QPixmap::fill(const QColor &color)
if (isNull())
return;
- detach();
+ // Some people are probably already calling fill while a painter is active, so to not break
+ // their programs, only print a warning and return when the fill operation could cause a crash.
+ if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
+ qWarning("QPixmap::fill: Cannot fill while pixmap is being painted on");
+ return;
+ }
+
+ if (data->ref == 1) {
+ // detach() will also remove this pixmap from caches, so
+ // it has to be called even when ref == 1.
+ detach();
+ } else {
+ // Don't bother to make a copy of the data object, since
+ // it will be filled with new pixel data anyway.
+ QPixmapData *d = data->createCompatiblePixmapData();
+ d->resize(data->width(), data->height());
+ data = d;
+ }
data->fill(color);
}
@@ -1011,6 +1014,9 @@ int QPixmap::serialNumber() const
*/
qint64 QPixmap::cacheKey() const
{
+ if (isNull())
+ return 0;
+
int classKey = data->classId();
if (classKey >= 1024)
classKey = -(classKey >> 10);
@@ -1070,6 +1076,9 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
if (widget->testAttribute(Qt::WA_PendingResizeEvent) || !widget->testAttribute(Qt::WA_WState_Created))
sendResizeEvents(widget);
+ widget->d_func()->prepareToRender(QRegion(),
+ QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
+
QRect r(rect);
if (r.width() < 0)
r.setWidth(widget->width() - rect.x());
@@ -1080,8 +1089,8 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
return QPixmap();
QPixmap res(r.size());
- widget->render(&res, QPoint(), r,
- QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
+ widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground
+ | QWidget::DrawChildren | QWidget::IgnoreMask, true);
return res;
}
@@ -1159,8 +1168,8 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
Qt::HANDLE QPixmap::handle() const
{
#if defined(Q_WS_X11)
- if (data->classId() == QPixmapData::X11Class)
- return static_cast<QX11PixmapData*>(data)->handle();
+ if (data && data->classId() == QPixmapData::X11Class)
+ return static_cast<const QX11PixmapData*>(data.constData())->handle();
#endif
return 0;
}
@@ -1210,7 +1219,7 @@ QPixmap::QPixmap(const QImage& image)
if (!qt_pixmap_thread_test())
return;
- if (data->pixelType() == QPixmapData::BitmapType)
+ if (data && data->pixelType() == QPixmapData::BitmapType)
*this = QBitmap::fromImage(image);
else
*this = fromImage(image);
@@ -1227,7 +1236,7 @@ QPixmap::QPixmap(const QImage& image)
QPixmap &QPixmap::operator=(const QImage &image)
{
- if (data->pixelType() == QPixmapData::BitmapType)
+ if (data && data->pixelType() == QPixmapData::BitmapType)
*this = QBitmap::fromImage(image);
else
*this = fromImage(image);
@@ -1257,7 +1266,7 @@ bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Color
*/
bool QPixmap::convertFromImage(const QImage &image, ColorMode mode)
{
- if (data->pixelType() == QPixmapData::BitmapType)
+ if (data && data->pixelType() == QPixmapData::BitmapType)
*this = QBitmap::fromImage(image, colorModeToFlags(mode));
else
*this = fromImage(image, colorModeToFlags(mode));
@@ -1344,17 +1353,15 @@ Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy,
bool QPixmap::isDetached() const
{
- return data->ref == 1;
+ return data && data->ref == 1;
}
+/*! \internal
+ ### Qt5 - remove me.
+*/
void QPixmap::deref()
{
- if (data && !data->ref.deref()) { // Destroy image if last ref
- if (data->is_cached)
- QImagePixmapCleanupHooks::executePixmapHooks(this);
- delete data;
- data = 0;
- }
+ Q_ASSERT_X(false, "QPixmap::deref()", "Do not call this function anymore!");
}
/*!
@@ -1550,9 +1557,9 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
\brief The QPixmap class is an off-screen image representation
that can be used as a paint device.
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
- \mainclass
+
Qt provides four classes for handling image data: QImage, QPixmap,
QBitmap and QPicture. QImage is designed and optimized for I/O,
@@ -1582,8 +1589,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
premultiplied alpha format. If the image has an alpha channel, and
if the system allows, the preferred format is premultiplied alpha.
Note also that QPixmap, unlike QImage, may be hardware dependent.
- On X11 and Mac, a QPixmap is stored on the server side while a
- QImage is stored on the client side (on Windows, these two classes
+ On X11, Mac and Symbian, a QPixmap is stored on the server side while
+ a QImage is stored on the client side (on Windows, these two classes
have an equivalent internal representation, i.e. both QImage and
QPixmap are stored on the client side and don't use any GDI
resources).
@@ -1602,7 +1609,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
screen. Alternatively, if no manipulation is desired, the image
file can be loaded directly into a QPixmap. On Windows, the
QPixmap class also supports conversion between \c HBITMAP and
- QPixmap.
+ QPixmap. On Symbian, the QPixmap class also supports conversion
+ between CFbsBitmap and QPixmap.
QPixmap provides a collection of functions that can be used to
obtain a variety of information about the pixmap. In addition,
@@ -1687,10 +1695,10 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
identifies the contents of the QPixmap object.
The x11Info() function returns information about the configuration
- of the X display used to display the widget. The
- x11PictureHandle() function returns the X11 Picture handle of the
- pixmap for XRender support. Note that the two latter functions are
- only available on x11.
+ of the X display used by the screen to which the pixmap currently
+ belongs. The x11PictureHandle() function returns the X11 Picture
+ handle of the pixmap for XRender support. Note that the two latter
+ functions are only available on x11.
\endtable
@@ -1702,11 +1710,20 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
operation, you can use QBitmap::fromImage() instead.
In addition, on Windows, the QPixmap class supports conversion to
- and from HBitmap: the toWinHBITMAP() function creates a HBITMAP
+ and from HBITMAP: the toWinHBITMAP() function creates a HBITMAP
equivalent to the QPixmap, based on the given HBitmapFormat, and
returns the HBITMAP handle. The fromWinHBITMAP() function returns
a QPixmap that is equivalent to the given bitmap which has the
- specified format.
+ specified format. The QPixmap class also supports conversion to
+ and from HICON: the toWinHICON() function creates a HICON equivalent
+ to the QPixmap, and returns the HICON handle. The fromWinHICON()
+ function returns a QPixmap that is equivalent to the given icon.
+
+ In addition, on Symbian, the QPixmap class supports conversion to
+ and from CFbsBitmap: the toSymbianCFbsBitmap() function creates
+ CFbsBitmap equivalent to the QPixmap, based on given mode and returns
+ a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a
+ QPixmap that is equivalent to the given bitmap and given mode.
\section1 Pixmap Transformations
@@ -1748,7 +1765,7 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
*/
bool QPixmap::hasAlpha() const
{
- return (data->hasAlphaChannel() || !data->mask().isNull());
+ return data && (data->hasAlphaChannel() || !data->mask().isNull());
}
/*!
@@ -1759,7 +1776,7 @@ bool QPixmap::hasAlpha() const
*/
bool QPixmap::hasAlphaChannel() const
{
- return data->hasAlphaChannel();
+ return data && data->hasAlphaChannel();
}
/*!
@@ -1767,7 +1784,7 @@ bool QPixmap::hasAlphaChannel() const
*/
int QPixmap::metric(PaintDeviceMetric metric) const
{
- return data->metric(metric);
+ return data ? data->metric(metric) : 0;
}
/*!
@@ -1839,7 +1856,7 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
*/
QPixmap QPixmap::alphaChannel() const
{
- return data->alphaChannel();
+ return data ? data->alphaChannel() : QPixmap();
}
/*!
@@ -1847,7 +1864,7 @@ QPixmap QPixmap::alphaChannel() const
*/
QPaintEngine *QPixmap::paintEngine() const
{
- return data->paintEngine();
+ return data ? data->paintEngine() : 0;
}
/*!
@@ -1862,7 +1879,7 @@ QPaintEngine *QPixmap::paintEngine() const
*/
QBitmap QPixmap::mask() const
{
- return data->mask();
+ return data ? data->mask() : QBitmap();
}
/*!
@@ -1887,6 +1904,8 @@ int QPixmap::defaultDepth()
return 32; // XXX
#elif defined(Q_WS_MAC)
return 32;
+#elif defined(Q_OS_SYMBIAN)
+ return S60->screenDepth;
#endif
}
@@ -1909,17 +1928,20 @@ int QPixmap::defaultDepth()
*/
void QPixmap::detach()
{
+ if (!data)
+ return;
+
QPixmapData::ClassId id = data->classId();
if (id == QPixmapData::RasterClass) {
- QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data);
+ QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data.data());
rasterData->image.detach();
}
if (data->is_cached && data->ref == 1)
- QImagePixmapCleanupHooks::executePixmapHooks(this);
+ QImagePixmapCleanupHooks::executePixmapModificationHooks(this);
#if defined(Q_WS_MAC)
- QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data) : 0;
+ QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data.data()) : 0;
if (macData) {
if (macData->cg_mask) {
CGImageRelease(macData->cg_mask);
@@ -1935,7 +1957,7 @@ void QPixmap::detach()
#if defined(Q_WS_X11)
if (data->classId() == QPixmapData::X11Class) {
- QX11PixmapData *d = static_cast<QX11PixmapData*>(data);
+ QX11PixmapData *d = static_cast<QX11PixmapData*>(data.data());
d->flags &= ~QX11PixmapData::Uninitialized;
// reset the cache data
@@ -1972,15 +1994,11 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
if (image.isNull())
return QPixmap();
- QPixmapData *data;
QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- if (gs)
- data = gs->createPixmapData(QPixmapData::PixmapType);
- else
- data = QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType);
-
+ QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType)
+ : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType));
data->fromImage(image, flags);
- return QPixmap(data);
+ return QPixmap(data.take());
}
/*!
@@ -2025,7 +2043,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
*/
QPixmapData* QPixmap::pixmapData() const
{
- return data;
+ return data.data();
}
/*!
@@ -2060,7 +2078,7 @@ QPixmapData* QPixmap::pixmapData() const
\warning This function is only available on Windows.
- \sa fromWinHBITMAP()
+ \sa fromWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
*/
/*! \fn QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
@@ -2074,9 +2092,34 @@ QPixmapData* QPixmap::pixmapData() const
*/
+/*! \fn HICON QPixmap::toWinHICON() const
+ \since 4.6
+
+ \bold{Win32 only:} Creates a \c HICON equivalent to the QPixmap.
+ Returns the \c HICON handle.
+
+ It is the caller's responsibility to free the \c HICON data after use.
+
+ \warning This function is only available on Windows.
+
+ \sa fromWinHICON(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+*/
+
+/*! \fn QPixmap QPixmap::fromWinHICON(HICON icon)
+ \since 4.6
+
+ \bold{Win32 only:} Returns a QPixmap that is equivalent to the given
+ \a icon.
+
+ \warning This function is only available on Windows.
+
+ \sa toWinHICON(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+
+*/
+
/*! \fn const QX11Info &QPixmap::x11Info() const
\bold{X11 only:} Returns information about the configuration of
- the X display used to display the widget.
+ the X display used by the screen to which the pixmap currently belongs.
\warning This function is only available on X11.
@@ -2110,6 +2153,13 @@ QPixmapData* QPixmap::pixmapData() const
*/
/*! \fn int QPixmap::numCols() const
+ \obsolete
+ \internal
+ \sa colorCount()
+*/
+
+/*! \fn int QPixmap::colorCount() const
+ \since 4.6
\internal
*/
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index db50ffdb0..d95b4eead 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -46,11 +46,17 @@
#include <QtGui/qcolor.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h> // char*->QString conversion
+#include <QtCore/qsharedpointer.h>
#include <QtGui/qimage.h>
#include <QtGui/qtransform.h>
QT_BEGIN_HEADER
+#if defined(Q_OS_SYMBIAN)
+class CFbsBitmap;
+class RSgImage;
+#endif
+
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
@@ -59,7 +65,6 @@ class QImageWriter;
class QColor;
class QVariant;
class QX11Info;
-
class QPixmapData;
class Q_GUI_EXPORT QPixmap : public QPaintDevice
@@ -144,7 +149,10 @@ public:
};
HBITMAP toWinHBITMAP(HBitmapFormat format = NoAlpha) const;
+ HICON toWinHICON() const;
+
static QPixmap fromWinHBITMAP(HBITMAP hbitmap, HBitmapFormat format = NoAlpha);
+ static QPixmap fromWinHICON(HICON hicon);
#endif
#if defined(Q_WS_MAC)
@@ -152,6 +160,13 @@ public:
static QPixmap fromMacCGImageRef(CGImageRef image);
#endif
+#if defined(Q_OS_SYMBIAN)
+ CFbsBitmap *toSymbianCFbsBitmap() const;
+ static QPixmap fromSymbianCFbsBitmap(CFbsBitmap *bitmap);
+ RSgImage* toSymbianRSgImage() const;
+ static QPixmap fromSymbianRSgImage(RSgImage *sgImage);
+#endif
+
inline QPixmap copy(int x, int y, int width, int height) const;
QPixmap copy(const QRect &rect = QRect()) const;
@@ -170,7 +185,8 @@ public:
const uchar *qwsBits() const;
int qwsBytesPerLine() const;
QRgb *clut() const;
- int numCols() const;
+ QT_DEPRECATED int numCols() const;
+ int colorCount() const;
#elif defined(Q_WS_MAC)
Qt::HANDLE macQDHandle() const;
Qt::HANDLE macQDAlphaHandle() const;
@@ -219,7 +235,7 @@ public:
#endif
private:
- QPixmapData *data;
+ QExplicitlySharedDataPointer<QPixmapData> data;
bool doImageIO(QImageWriter *io, int quality) const;
@@ -245,6 +261,7 @@ private:
friend class QPixmapData;
friend class QX11PixmapData;
friend class QMacPixmapData;
+ friend class QS60PixmapData;
friend class QBitmap;
friend class QPaintDevice;
friend class QPainter;
@@ -254,7 +271,7 @@ private:
friend class QWidgetPrivate;
friend class QRasterPaintEngine;
friend class QRasterBuffer;
- friend class QDetachedPixmap;
+ friend class QPixmapCacheEntry;
#if !defined(QT_NO_DATASTREAM)
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &);
#endif
@@ -264,7 +281,7 @@ public:
QPixmapData* pixmapData() const;
public:
- typedef QPixmapData * DataPtr;
+ typedef QExplicitlySharedDataPointer<QPixmapData> DataPtr;
inline DataPtr &data_ptr() { return data; }
};
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 5959da121..365c2715e 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -73,12 +73,12 @@ static int qt_pixmap_serial = 0;
Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix)
{
- return static_cast<QMacPixmapData*>(pix->data)->pixels;
+ return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
}
Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix)
{
- return static_cast<QMacPixmapData*>(pix->data)->bytesPerRow;
+ return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
}
void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t)
@@ -160,12 +160,17 @@ QSet<QMacPixmapData*> QMacPixmapData::validDataPointers;
QMacPixmapData::QMacPixmapData(PixelType type)
: QPixmapData(type, MacClass), has_alpha(0), has_mask(0),
- uninit(true), pixels(0), pixelsToFree(0), bytesPerRow(0),
- cg_data(0), cg_dataBeingReleased(0), cg_mask(0),
+ uninit(true), pixels(0), pixelsSize(0), pixelsToFree(0),
+ bytesPerRow(0), cg_data(0), cg_dataBeingReleased(0), cg_mask(0),
pengine(0)
{
}
+QPixmapData *QMacPixmapData::createCompatiblePixmapData() const
+{
+ return new QMacPixmapData(pixelType());
+}
+
#define BEST_BYTE_ALIGNMENT 16
#define COMPTUE_BEST_BYTES_PER_ROW(bpr) \
(((bpr) + (BEST_BYTE_ALIGNMENT - 1)) & ~(BEST_BYTE_ALIGNMENT - 1))
@@ -243,7 +248,7 @@ void QMacPixmapData::fromImage(const QImage &img,
} else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) {
conv8 = d == 1; // native depth wanted
} else if (d == 1) {
- if (image.numColors() == 2) {
+ if (image.colorCount() == 2) {
QRgb c0 = image.color(0); // Auto: convert to best
QRgb c1 = image.color(1);
conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255);
@@ -300,11 +305,15 @@ void QMacPixmapData::fromImage(const QImage &img,
}
break;
}
- case QImage::Format_Indexed8:
- for (int x = 0; x < w; ++x) {
- *(drow+x) = PREMUL(image.color(*(srow + x)));
+ case QImage::Format_Indexed8: {
+ int numColors = image.numColors();
+ if (numColors > 0) {
+ for (int x = 0; x < w; ++x) {
+ int index = *(srow + x);
+ *(drow+x) = PREMUL(image.color(qMin(index, numColors)));
+ }
}
- break;
+ } break;
case QImage::Format_RGB32:
for (int x = 0; x < w; ++x)
*(drow+x) = *(((quint32*)srow) + x) | 0xFF000000;
@@ -330,7 +339,7 @@ void QMacPixmapData::fromImage(const QImage &img,
bool alphamap = image.depth() == 32;
if (sfmt == QImage::Format_Indexed8) {
const QVector<QRgb> rgb = image.colorTable();
- for (int i = 0, count = image.numColors(); i < count; ++i) {
+ for (int i = 0, count = image.colorCount(); i < count; ++i) {
const int alpha = qAlpha(rgb[i]);
if (alpha != 0xff) {
alphamap = true;
@@ -346,13 +355,13 @@ void QMacPixmapData::fromImage(const QImage &img,
int get_index(QImage * qi,QRgb mycol)
{
int loopc;
- for(loopc=0;loopc<qi->numColors();loopc++) {
+ for(loopc=0;loopc<qi->colorCount();loopc++) {
if(qi->color(loopc)==mycol)
return loopc;
}
- qi->setNumColors(qi->numColors()+1);
- qi->setColor(qi->numColors(),mycol);
- return qi->numColors();
+ qi->setColorCount(qi->colorCount()+1);
+ qi->setColor(qi->colorCount(),mycol);
+ return qi->colorCount();
}
QImage QMacPixmapData::toImage() const
@@ -367,7 +376,7 @@ QImage QMacPixmapData::toImage() const
const uint sbpr = bytesPerRow;
if (format == QImage::Format_MonoLSB) {
image.fill(0);
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
for (int y = 0; y < h; ++y) {
@@ -421,7 +430,7 @@ QPixmap QMacPixmapData::alphaChannel() const
void QMacPixmapData::setAlphaChannel(const QPixmap &alpha)
{
has_mask = true;
- QMacPixmapData *alphaData = static_cast<QMacPixmapData*>(alpha.data);
+ QMacPixmapData *alphaData = static_cast<QMacPixmapData*>(alpha.data.data());
macSetAlphaChannel(alphaData, false);
}
@@ -449,7 +458,7 @@ void QMacPixmapData::setMask(const QBitmap &mask)
has_alpha = false;
has_mask = true;
- QMacPixmapData *maskData = static_cast<QMacPixmapData*>(mask.data);
+ QMacPixmapData *maskData = static_cast<QMacPixmapData*>(mask.data.data());
macSetAlphaChannel(maskData, true);
}
@@ -628,8 +637,9 @@ void QMacPixmapData::macCreatePixels()
}
if (pixels)
- memcpy(base_pixels, pixels, numBytes);
+ memcpy(base_pixels, pixels, pixelsSize);
pixels = base_pixels;
+ pixelsSize = numBytes;
}
#if 0
@@ -960,15 +970,18 @@ Qt::HANDLE QPixmap::macQDAlphaHandle() const
Qt::HANDLE QPixmap::macCGHandle() const
{
+ if (isNull())
+ return 0;
+
if (data->classId() == QPixmapData::MacClass) {
- QMacPixmapData *d = static_cast<QMacPixmapData *>(data);
+ QMacPixmapData *d = static_cast<QMacPixmapData *>(data.data());
if (!d->cg_data)
d->macCreateCGImageRef();
CGImageRef ret = d->cg_data;
CGImageRetain(ret);
return ret;
} else if (data->classId() == QPixmapData::RasterClass) {
- return qt_mac_image_to_cgimage(static_cast<QRasterPixmapData *>(data)->image);
+ return qt_mac_image_to_cgimage(static_cast<QRasterPixmapData *>(data.data())->image);
}
return 0;
}
@@ -980,7 +993,7 @@ bool QMacPixmapData::hasAlphaChannel() const
CGImageRef qt_mac_create_imagemask(const QPixmap &pixmap, const QRectF &sr)
{
- QMacPixmapData *px = static_cast<QMacPixmapData*>(pixmap.data);
+ QMacPixmapData *px = static_cast<QMacPixmapData*>(pixmap.data.data());
if (px->cg_mask) {
if (px->cg_mask_rect == sr) {
CGImageRetain(px->cg_mask); //reference for the caller
diff --git a/src/gui/image/qpixmap_mac_p.h b/src/gui/image/qpixmap_mac_p.h
index e37c05e82..45ab8e214 100644
--- a/src/gui/image/qpixmap_mac_p.h
+++ b/src/gui/image/qpixmap_mac_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -65,6 +65,8 @@ public:
QMacPixmapData(PixelType type);
~QMacPixmapData();
+ QPixmapData *createCompatiblePixmapData() const;
+
void resize(int width, int height);
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
void copy(const QPixmapData *data, const QRect &rect);
@@ -105,6 +107,7 @@ private:
pixelsToFree later on instead of malloc'ing memory.
*/
quint32 *pixels;
+ uint pixelsSize;
quint32 *pixelsToFree;
uint bytesPerRow;
QRectF cg_mask_rect;
diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp
index b106610a5..69626edb8 100644
--- a/src/gui/image/qpixmap_qws.cpp
+++ b/src/gui/image/qpixmap_qws.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,6 +48,9 @@
#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);
@@ -111,8 +114,8 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
QRgb* QPixmap::clut() const
{
- if (data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data);
+ if (data && data->classId() == QPixmapData::RasterClass) {
+ const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
return d->image.colorTable().data();
}
@@ -121,9 +124,14 @@ QRgb* QPixmap::clut() const
int QPixmap::numCols() const
{
- if (data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data);
- return d->image.numColors();
+ 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;
@@ -131,8 +139,8 @@ int QPixmap::numCols() const
const uchar* QPixmap::qwsBits() const
{
- if (data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data);
+ if (data && data->classId() == QPixmapData::RasterClass) {
+ const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
return d->image.bits();
}
@@ -141,10 +149,12 @@ const uchar* QPixmap::qwsBits() const
int QPixmap::qwsBytesPerLine() const
{
- if (data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data);
+ 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/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index f6049be19..1b01e6f3b 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,6 +55,29 @@ QT_BEGIN_NAMESPACE
const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80 };
+QPixmap qt_toRasterPixmap(const QImage &image)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(image.depth() == 1
+ ? QPixmapData::BitmapType
+ : QPixmapData::PixmapType);
+
+ data->fromImage(image, Qt::AutoColor);
+
+ return QPixmap(data);
+}
+
+QPixmap qt_toRasterPixmap(const QPixmap &pixmap)
+{
+ if (pixmap.isNull())
+ return QPixmap();
+
+ if (QPixmap(pixmap).data_ptr()->classId() == QPixmapData::RasterClass)
+ return pixmap;
+
+ return qt_toRasterPixmap(pixmap.toImage());
+}
+
QRasterPixmapData::QRasterPixmapData(PixelType type)
: QPixmapData(type, RasterClass)
{
@@ -64,6 +87,11 @@ QRasterPixmapData::~QRasterPixmapData()
{
}
+QPixmapData *QRasterPixmapData::createCompatiblePixmapData() const
+{
+ return new QRasterPixmapData(pixelType());
+}
+
void QRasterPixmapData::resize(int width, int height)
{
QImage::Format format;
@@ -91,7 +119,7 @@ void QRasterPixmapData::resize(int width, int height)
is_null = (w <= 0 || h <= 0);
if (pixelType() == BitmapType && !image.isNull()) {
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
}
@@ -172,9 +200,13 @@ void QRasterPixmapData::fromImage(const QImage &sourceImage,
}
}
#endif
- w = image.d->width;
- h = image.d->height;
- d = image.d->depth;
+ if (image.d) {
+ w = image.d->width;
+ h = image.d->height;
+ d = image.d->depth;
+ } else {
+ w = h = d = 0;
+ }
is_null = (w <= 0 || h <= 0);
setSerialNumber(image.serialNumber());
diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h
index 7436143bc..1553940cd 100644
--- a/src/gui/image/qpixmap_raster_p.h
+++ b/src/gui/image/qpixmap_raster_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -68,6 +68,8 @@ public:
QRasterPixmapData(PixelType type);
~QRasterPixmapData();
+ QPixmapData *createCompatiblePixmapData() const;
+
void resize(int width, int height);
void fromFile(const QString &filename, Qt::ImageConversionFlags flags);
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
@@ -83,13 +85,13 @@ public:
protected:
int metric(QPaintDevice::PaintDeviceMetric metric) const;
+ QImage image;
private:
friend class QPixmap;
friend class QBitmap;
- friend class QDetachedPixmap;
+ friend class QPixmapCacheEntry;
friend class QRasterPaintEngine;
- QImage image;
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
new file mode 100644
index 000000000..dc33adedc
--- /dev/null
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -0,0 +1,985 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 <exception>
+#include <w32std.h>
+#include <fbs.h>
+
+#include <private/qapplication_p.h>
+#include <private/qgraphicssystem_p.h>
+#include <private/qt_s60_p.h>
+#include <private/qpaintengine_s60_p.h>
+
+#include "qpixmap.h"
+#include "qpixmap_raster_p.h"
+#include <qwidget.h>
+#include "qpixmap_s60_p.h"
+#include "qnativeimage_p.h"
+#include "qbitmap.h"
+#include "qimage.h"
+#include "qimage_p.h"
+
+#include <fbs.h>
+
+QT_BEGIN_NAMESPACE
+
+const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
+ 0x10, 0x20, 0x40, 0x80 };
+
+
+/*
+ \class QSymbianFbsClient
+ \since 4.6
+ \internal
+
+ Symbian Font And Bitmap server client that is
+ used to lock the global bitmap heap. Only used in
+ S60 v3.1 and S60 v3.2.
+*/
+_LIT(KFBSERVLargeBitmapAccessName,"FbsLargeBitmapAccess");
+class QSymbianFbsClient
+{
+public:
+
+ QSymbianFbsClient() : heapLocked(false)
+ {
+ heapLock.OpenGlobal(KFBSERVLargeBitmapAccessName);
+ }
+
+ ~QSymbianFbsClient()
+ {
+ heapLock.Close();
+ }
+
+ bool lockHeap()
+ {
+ bool wasLocked = heapLocked;
+
+ if (heapLock.Handle() && !heapLocked) {
+ heapLock.Wait();
+ heapLocked = true;
+ }
+
+ return wasLocked;
+ }
+
+ bool unlockHeap()
+ {
+ bool wasLocked = heapLocked;
+
+ if (heapLock.Handle() && heapLocked) {
+ heapLock.Signal();
+ heapLocked = false;
+ }
+
+ return wasLocked;
+ }
+
+
+private:
+
+ RMutex heapLock;
+ bool heapLocked;
+};
+
+Q_GLOBAL_STATIC(QSymbianFbsClient, qt_symbianFbsClient);
+
+
+
+// QSymbianFbsHeapLock
+
+QSymbianFbsHeapLock::QSymbianFbsHeapLock(LockAction a)
+: action(a), wasLocked(false)
+{
+ QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();
+ if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3)
+ wasLocked = qt_symbianFbsClient()->unlockHeap();
+}
+
+QSymbianFbsHeapLock::~QSymbianFbsHeapLock()
+{
+ // Do nothing
+}
+
+void QSymbianFbsHeapLock::relock()
+{
+ QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();
+ if (wasLocked && (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3))
+ qt_symbianFbsClient()->lockHeap();
+}
+
+/*
+ \class QSymbianBitmapDataAccess
+ \since 4.6
+ \internal
+
+ Data access class that is used to locks/unlocks pixel data
+ when drawing or modifying CFbsBitmap pixel data.
+*/
+class QSymbianBitmapDataAccess
+{
+public:
+
+ bool heapWasLocked;
+ QSysInfo::SymbianVersion symbianVersion;
+
+ explicit QSymbianBitmapDataAccess() : heapWasLocked(false)
+ {
+ symbianVersion = QSysInfo::symbianVersion();
+ };
+
+ ~QSymbianBitmapDataAccess() {};
+
+ inline void beginDataAccess(CFbsBitmap *bitmap)
+ {
+ if (symbianVersion == QSysInfo::SV_9_2)
+ heapWasLocked = qt_symbianFbsClient()->lockHeap();
+ else
+ bitmap->LockHeap(ETrue);
+ }
+
+ inline void endDataAccess(CFbsBitmap *bitmap)
+ {
+ if (symbianVersion == QSysInfo::SV_9_2) {
+ if (!heapWasLocked)
+ qt_symbianFbsClient()->unlockHeap();
+ } else {
+ bitmap->UnlockHeap(ETrue);
+ }
+ }
+};
+
+
+#define UPDATE_BUFFER() \
+ { \
+ beginDataAccess(); \
+ endDataAccess(); \
+}
+
+
+static CFbsBitmap* createSymbianCFbsBitmap(const TSize& size, TDisplayMode mode)
+{
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+
+ CFbsBitmap* bitmap = 0;
+ QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap);
+
+ if (bitmap->Create(size, mode) != KErrNone) {
+ delete bitmap;
+ bitmap = 0;
+ }
+
+ lock.relock();
+
+ return bitmap;
+}
+
+static CFbsBitmap* uncompress(CFbsBitmap* bitmap)
+{
+ if(bitmap->IsCompressedInRAM()) {
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+
+ CFbsBitmap *uncompressed = 0;
+ QT_TRAP_THROWING(uncompressed = new (ELeave) CFbsBitmap);
+
+ if (uncompressed->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) {
+ delete bitmap;
+ bitmap = 0;
+ lock.relock();
+
+ return bitmap;
+ }
+
+ lock.relock();
+
+ CFbsBitmapDevice* bitmapDevice = 0;
+ CFbsBitGc *bitmapGc = 0;
+ QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(uncompressed));
+ QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
+ bitmapGc->Activate(bitmapDevice);
+
+ bitmapGc->DrawBitmap(TPoint(), bitmap);
+
+ delete bitmapGc;
+ delete bitmapDevice;
+
+ return uncompressed;
+ } else {
+ return bitmap;
+ }
+}
+
+QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h)
+{
+ CWsScreenDevice* screenDevice = S60->screenDevice();
+ TSize screenSize = screenDevice->SizeInPixels();
+
+ TSize srcSize;
+ // Find out if this is one of our windows.
+ QSymbianControl *sControl;
+ sControl = winId->MopGetObject(sControl);
+ if (sControl && sControl->widget()->windowType() == Qt::Desktop) {
+ // Grabbing desktop widget
+ srcSize = screenSize;
+ } else {
+ TPoint relativePos = winId->PositionRelativeToScreen();
+ x += relativePos.iX;
+ y += relativePos.iY;
+ srcSize = winId->Size();
+ }
+
+ TRect srcRect(TPoint(x, y), srcSize);
+ // Clip to the screen
+ srcRect.Intersection(TRect(screenSize));
+
+ if (w > 0 && h > 0) {
+ TRect subRect(TPoint(x, y), TSize(w, h));
+ // Clip to the subRect
+ srcRect.Intersection(subRect);
+ }
+
+ if (srcRect.IsEmpty())
+ return QPixmap();
+
+ CFbsBitmap* temporary = createSymbianCFbsBitmap(srcRect.Size(), screenDevice->DisplayMode());
+
+ QPixmap pix;
+
+ if (temporary && screenDevice->CopyScreenToBitmap(temporary, srcRect) == KErrNone) {
+ pix = QPixmap::fromSymbianCFbsBitmap(temporary);
+ }
+
+ delete temporary;
+ return pix;
+}
+
+/*!
+ \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const
+ \since 4.6
+
+ Creates a \c CFbsBitmap that is equivalent to the QPixmap. Internally this
+ function will try to duplicate the handle instead of copying the data,
+ however in scenarios where this is not possible the data will be copied.
+ If the creation fails or the pixmap is null, then this function returns 0.
+
+ It is the caller's responsibility to release the \c CFbsBitmap data
+ after use either by deleting the bitmap or calling \c Reset().
+
+ \warning On S60 3.1 and S60 3.2, semi-transparent pixmaps are always copied
+ and not duplicated.
+ \warning This function is only available on Symbian OS.
+
+ \sa fromSymbianCFbsBitmap()
+*/
+CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const
+{
+ QPixmapData *data = pixmapData();
+ if (!data || data->isNull())
+ return 0;
+
+ return reinterpret_cast<CFbsBitmap*>(data->toNativeType(QPixmapData::FbsBitmap));
+}
+
+/*!
+ \fn QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap)
+ \since 4.6
+
+ Creates a QPixmap from a \c CFbsBitmap \a bitmap. Internally this function
+ will try to duplicate the bitmap handle instead of copying the data, however
+ in scenarios where this is not possible the data will be copied.
+ To be sure that QPixmap does not modify your original instance, you should
+ make a copy of your \c CFbsBitmap before calling this function.
+ If the CFbsBitmap is not valid this function will return a null QPixmap.
+
+ \warning This function is only available on Symbian OS.
+
+ \sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+*/
+QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap)
+{
+ if (!bitmap)
+ return QPixmap();
+
+ QScopedPointer<QS60PixmapData> data(new QS60PixmapData(QPixmapData::PixmapType));
+ data->fromNativeType(reinterpret_cast<void*>(bitmap), QPixmapData::FbsBitmap);
+ QPixmap pixmap(data.take());
+ return pixmap;
+}
+
+QS60PixmapData::QS60PixmapData(PixelType type) : QRasterPixmapData(type),
+ symbianBitmapDataAccess(new QSymbianBitmapDataAccess),
+ cfbsBitmap(0),
+ bitmapDevice(0),
+ bitmapGc(0),
+ pengine(0),
+ bytes(0),
+ formatLocked(false)
+{
+
+}
+
+QS60PixmapData::~QS60PixmapData()
+{
+ release();
+ delete symbianBitmapDataAccess;
+}
+
+void QS60PixmapData::resize(int width, int height)
+{
+ if (width <= 0 || height <= 0) {
+ w = width;
+ h = height;
+ is_null = true;
+
+ release();
+ return;
+ } else if (!cfbsBitmap) {
+ TDisplayMode mode;
+ if (pixelType() == BitmapType)
+ mode = EGray2;
+ else
+ mode = EColor16MU;
+
+ CFbsBitmap* bitmap = createSymbianCFbsBitmap(TSize(width, height), mode);
+ fromSymbianBitmap(bitmap);
+ } else {
+
+ TSize newSize(width, height);
+
+ if(cfbsBitmap->SizeInPixels() != newSize) {
+ cfbsBitmap->Resize(TSize(width, height));
+ bitmapDevice->Resize(TSize(width, height));
+ bitmapGc->Resized();
+ if(pengine) {
+ delete pengine;
+ pengine = 0;
+ }
+ }
+
+ UPDATE_BUFFER();
+ }
+}
+
+bool QS60PixmapData::initSymbianBitmapContext()
+{
+ QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(cfbsBitmap));
+ QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
+ bitmapGc->Activate(bitmapDevice);
+
+ return true;
+}
+
+void QS60PixmapData::release()
+{
+ if (cfbsBitmap) {
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+ delete bitmapGc;
+ delete bitmapDevice;
+ delete cfbsBitmap;
+ lock.relock();
+ }
+
+ delete pengine;
+ image = QImage();
+ cfbsBitmap = 0;
+ bitmapGc = 0;
+ bitmapDevice = 0;
+ pengine = 0;
+ bytes = 0;
+}
+
+/*!
+ * Takes ownership of bitmap. Used by window surface
+ */
+void QS60PixmapData::fromSymbianBitmap(CFbsBitmap* bitmap)
+{
+ cfbsBitmap = bitmap;
+ formatLocked = true;
+
+ if(!initSymbianBitmapContext()) {
+ qWarning("Could not create CBitmapContext");
+ release();
+ return;
+ }
+
+ setSerialNumber(cfbsBitmap->Handle());
+
+ UPDATE_BUFFER();
+
+ // Create default palette if needed
+ if (cfbsBitmap->DisplayMode() == EGray2) {
+ image.setColorCount(2);
+ image.setColor(0, QColor(Qt::color0).rgba());
+ image.setColor(1, QColor(Qt::color1).rgba());
+
+ //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
+ //So invert mono bitmaps so that masks work correctly.
+ image.invertPixels();
+ } else if (cfbsBitmap->DisplayMode() == EGray256) {
+ for (int i=0; i < 256; ++i)
+ image.setColor(i, qRgb(i, i, i));
+ }else if (cfbsBitmap->DisplayMode() == EColor256) {
+ const TColor256Util *palette = TColor256Util::Default();
+ for (int i=0; i < 256; ++i)
+ image.setColor(i, (QRgb)(palette->Color256(i).Value()));
+ }
+}
+
+void QS60PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags)
+{
+ QImage sourceImage;
+
+ if (pixelType() == BitmapType) {
+ sourceImage = img.convertToFormat(QImage::Format_MonoLSB);
+ } else {
+ if (img.depth() == 1) {
+ sourceImage = img.hasAlphaChannel()
+ ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied)
+ : img.convertToFormat(QImage::Format_RGB32);
+ } else {
+
+ QImage::Format opaqueFormat = QNativeImage::systemFormat();
+ QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
+
+ if (!img.hasAlphaChannel()
+ || ((flags & Qt::NoOpaqueDetection) == 0
+ && !const_cast<QImage &>(img).data_ptr()->checkForAlphaPixels())) {
+ sourceImage = img.convertToFormat(opaqueFormat);
+ } else {
+ sourceImage = img.convertToFormat(alphaFormat);
+ }
+ }
+ }
+
+
+ QImage::Format destFormat = sourceImage.format();
+ TDisplayMode mode;
+ switch (destFormat) {
+ case QImage::Format_MonoLSB:
+ mode = EGray2;
+ break;
+ case QImage::Format_RGB32:
+ mode = EColor16MU;
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ if (S60->supportsPremultipliedAlpha) {
+ mode = Q_SYMBIAN_ECOLOR16MAP;
+ break;
+ } else {
+ destFormat = QImage::Format_ARGB32;
+ }
+ // Fall through intended
+ case QImage::Format_ARGB32:
+ mode = EColor16MA;
+ break;
+ case QImage::Format_Invalid:
+ return;
+ default:
+ qWarning("Image format not supported: %d", image.format());
+ return;
+ }
+
+ cfbsBitmap = createSymbianCFbsBitmap(TSize(sourceImage.width(), sourceImage.height()), mode);
+ if (!(cfbsBitmap && initSymbianBitmapContext())) {
+ qWarning("Could not create CFbsBitmap and/or CBitmapContext");
+ release();
+ return;
+ }
+
+ setSerialNumber(cfbsBitmap->Handle());
+
+ const uchar *sptr = const_cast<const QImage &>(sourceImage).bits();
+ symbianBitmapDataAccess->beginDataAccess(cfbsBitmap);
+ uchar *dptr = (uchar*)cfbsBitmap->DataAddress();
+ Mem::Copy(dptr, sptr, sourceImage.byteCount());
+ symbianBitmapDataAccess->endDataAccess(cfbsBitmap);
+
+ UPDATE_BUFFER();
+
+ if (destFormat == QImage::Format_MonoLSB) {
+ image.setColorCount(2);
+ image.setColor(0, QColor(Qt::color0).rgba());
+ image.setColor(1, QColor(Qt::color1).rgba());
+ } else {
+ image.setColorTable(sourceImage.colorTable());
+ }
+}
+
+void QS60PixmapData::copy(const QPixmapData *data, const QRect &rect)
+{
+ if (data->pixelType() == BitmapType) {
+ QBitmap::fromImage(data->toImage().copy(rect));
+ return;
+ }
+
+ const QS60PixmapData *s60Data = static_cast<const QS60PixmapData*>(data);
+
+ resize(rect.width(), rect.height());
+ cfbsBitmap->SetDisplayMode(s60Data->cfbsBitmap->DisplayMode());
+
+ bitmapGc->BitBlt(TPoint(0, 0), s60Data->cfbsBitmap, qt_QRect2TRect(rect));
+}
+
+bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect)
+{
+ beginDataAccess();
+ bool res = QRasterPixmapData::scroll(dx, dy, rect);
+ endDataAccess();
+ return res;
+}
+
+int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
+{
+ if (!cfbsBitmap)
+ return 0;
+
+ switch (metric) {
+ case QPaintDevice::PdmWidth:
+ return cfbsBitmap->SizeInPixels().iWidth;
+ case QPaintDevice::PdmHeight:
+ return cfbsBitmap->SizeInPixels().iHeight;
+ case QPaintDevice::PdmWidthMM: {
+ TInt twips = cfbsBitmap->SizeInTwips().iWidth;
+ return (int)(twips * (25.4/KTwipsPerInch));
+ }
+ case QPaintDevice::PdmHeightMM: {
+ TInt twips = cfbsBitmap->SizeInTwips().iHeight;
+ return (int)(twips * (25.4/KTwipsPerInch));
+ }
+ case QPaintDevice::PdmNumColors:
+ return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode());
+ case QPaintDevice::PdmDpiX:
+ case QPaintDevice::PdmPhysicalDpiX: {
+ TReal inches = cfbsBitmap->SizeInTwips().iWidth / (TReal)KTwipsPerInch;
+ TInt pixels = cfbsBitmap->SizeInPixels().iWidth;
+ return pixels / inches;
+ }
+ case QPaintDevice::PdmDpiY:
+ case QPaintDevice::PdmPhysicalDpiY: {
+ TReal inches = cfbsBitmap->SizeInTwips().iHeight / (TReal)KTwipsPerInch;
+ TInt pixels = cfbsBitmap->SizeInPixels().iHeight;
+ return pixels / inches;
+ }
+ case QPaintDevice::PdmDepth:
+ return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode());
+ default:
+ qWarning("QPixmap::metric: Invalid metric command");
+ }
+ return 0;
+
+}
+
+void QS60PixmapData::fill(const QColor &color)
+{
+ if (color.alpha() != 255) {
+ QImage im(width(), height(), QImage::Format_ARGB32_Premultiplied);
+ im.fill(PREMUL(color.rgba()));
+ release();
+ fromImage(im, Qt::AutoColor | Qt::OrderedAlphaDither);
+ } else {
+ beginDataAccess();
+ QRasterPixmapData::fill(color);
+ endDataAccess();
+ }
+}
+
+void QS60PixmapData::setMask(const QBitmap &mask)
+{
+ if (mask.size().isEmpty()) {
+ if (image.depth() != 1) {
+ QImage newImage = image.convertToFormat(QImage::Format_RGB32);
+ release();
+ fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither);
+ }
+ } else if (image.depth() == 1) {
+ beginDataAccess();
+ QRasterPixmapData::setMask(mask);
+ endDataAccess();
+ } else {
+ const int w = image.width();
+ const int h = image.height();
+
+ const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB);
+ QImage newImage = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ for (int y = 0; y < h; ++y) {
+ const uchar *mscan = imageMask.scanLine(y);
+ QRgb *tscan = (QRgb *)newImage.scanLine(y);
+ for (int x = 0; x < w; ++x) {
+ if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7]))
+ tscan[x] = 0;
+ }
+ }
+ release();
+ fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither);
+ }
+}
+
+void QS60PixmapData::setAlphaChannel(const QPixmap &alphaChannel)
+{
+ QImage img(toImage());
+ img.setAlphaChannel(alphaChannel.toImage());
+ release();
+ fromImage(img, Qt::OrderedDither | Qt::OrderedAlphaDither);
+}
+
+QImage QS60PixmapData::toImage() const
+{
+ QS60PixmapData *that = const_cast<QS60PixmapData*>(this);
+ that->beginDataAccess();
+ QImage copy = that->image.copy();
+ that->endDataAccess();
+
+ return copy;
+}
+
+QPaintEngine* QS60PixmapData::paintEngine() const
+{
+ if (!pengine) {
+ QS60PixmapData *that = const_cast<QS60PixmapData*>(this);
+ that->pengine = new QS60PaintEngine(&that->image, that);
+ }
+ return pengine;
+}
+
+void QS60PixmapData::beginDataAccess()
+{
+ if(!cfbsBitmap)
+ return;
+
+ symbianBitmapDataAccess->beginDataAccess(cfbsBitmap);
+
+ uchar* newBytes = (uchar*)cfbsBitmap->DataAddress();
+
+ TSize size = cfbsBitmap->SizeInPixels();
+
+ if (newBytes == bytes && image.width() == size.iWidth && image.height() == size.iHeight)
+ return;
+
+ bytes = newBytes;
+ TDisplayMode mode = cfbsBitmap->DisplayMode();
+ QImage::Format format = qt_TDisplayMode2Format(mode);
+ // On S60 3.1, premultiplied alpha pixels are stored in a bitmap with 16MA type.
+ // S60 window surface needs backing store pixmap for transparent window in ARGB32 format.
+ // In that case formatLocked is true.
+ if (!formatLocked && format == QImage::Format_ARGB32)
+ format = QImage::Format_ARGB32_Premultiplied; // pixel data is actually in premultiplied format
+
+ QVector<QRgb> savedColorTable;
+ if (!image.isNull())
+ savedColorTable = image.colorTable();
+
+ image = QImage(bytes, size.iWidth, size.iHeight, format);
+
+ // Restore the palette or create a default
+ if (!savedColorTable.isEmpty()) {
+ image.setColorTable(savedColorTable);
+ }
+
+ w = size.iWidth;
+ h = size.iHeight;
+ d = image.depth();
+ is_null = (w <= 0 || h <= 0);
+
+ if (pengine) {
+ QS60PaintEngine *engine = static_cast<QS60PaintEngine *>(pengine);
+ engine->prepare(&image);
+ }
+}
+
+void QS60PixmapData::endDataAccess(bool readOnly) const
+{
+ Q_UNUSED(readOnly);
+
+ if(!cfbsBitmap)
+ return;
+
+ symbianBitmapDataAccess->endDataAccess(cfbsBitmap);
+}
+
+/*!
+ \since 4.6
+
+ Returns a QPixmap that wraps given \a sgImage graphics resource.
+ The data should be valid even when original RSgImage handle has been
+ closed.
+
+ \warning This function is only available on Symbian OS.
+
+ \sa toSymbianRSgImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+*/
+
+QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage)
+{
+ // It is expected that RSgImage will
+ // CURRENTLY be used in conjuction with
+ // OpenVG graphics system
+ //
+ // Surely things might change in future
+
+ if (!sgImage)
+ return QPixmap();
+
+ QScopedPointer<QS60PixmapData> data(new QS60PixmapData(QPixmapData::PixmapType));
+ data->fromNativeType(reinterpret_cast<void*>(sgImage), QPixmapData::SgImage);
+ QPixmap pixmap(data.take());
+ return pixmap;
+}
+
+/*!
+\since 4.6
+
+Returns a \c RSgImage that is equivalent to the QPixmap by copying the data.
+
+It is the caller's responsibility to close/delete the \c RSgImage after use.
+
+\warning This function is only available on Symbian OS.
+
+\sa fromSymbianRSgImage()
+*/
+
+RSgImage *QPixmap::toSymbianRSgImage() const
+{
+ // It is expected that RSgImage will
+ // CURRENTLY be used in conjuction with
+ // OpenVG graphics system
+ //
+ // Surely things might change in future
+
+ if (isNull())
+ return 0;
+
+ RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmapData()->toNativeType(QPixmapData::SgImage));
+
+ return sgImage;
+}
+
+void* QS60PixmapData::toNativeType(NativeType type)
+{
+ if (type == QPixmapData::SgImage) {
+ return 0;
+ } else if (type == QPixmapData::FbsBitmap) {
+
+ if (isNull() || !cfbsBitmap)
+ return 0;
+
+ bool convertToArgb32 = false;
+ bool needsCopy = false;
+
+ QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();
+ if (!(S60->supportsPremultipliedAlpha)) {
+ // Convert argb32_premultiplied to argb32 since Symbian 9.2 does
+ // not support premultipied format.
+
+ if (image.format() == QImage::Format_ARGB32_Premultiplied) {
+ needsCopy = true;
+ convertToArgb32 = true;
+ }
+ }
+
+ CFbsBitmap *bitmap = 0;
+
+ TDisplayMode displayMode = cfbsBitmap->DisplayMode();
+
+ if(displayMode == EGray2) {
+ //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
+ //So invert mono bitmaps so that masks work correctly.
+ image.invertPixels();
+ needsCopy = true;
+ }
+
+ if (needsCopy) {
+ QImage source;
+
+ if (convertToArgb32) {
+ source = image.convertToFormat(QImage::Format_ARGB32);
+ displayMode = EColor16MA;
+ } else {
+ source = image;
+ }
+
+ CFbsBitmap *newBitmap = createSymbianCFbsBitmap(TSize(source.width(), source.height()), displayMode);
+ const uchar *sptr = source.bits();
+ symbianBitmapDataAccess->beginDataAccess(newBitmap);
+
+ uchar *dptr = (uchar*)newBitmap->DataAddress();
+ Mem::Copy(dptr, sptr, source.byteCount());
+
+ symbianBitmapDataAccess->endDataAccess(newBitmap);
+
+ bitmap = newBitmap;
+ } else {
+
+ QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap);
+
+ TInt err = bitmap->Duplicate(cfbsBitmap->Handle());
+ if (err != KErrNone) {
+ qWarning("Could not duplicate CFbsBitmap");
+ delete bitmap;
+ bitmap = 0;
+ }
+ }
+
+ if(displayMode == EGray2) {
+ // restore pixels
+ image.invertPixels();
+ }
+
+ return reinterpret_cast<void*>(bitmap);
+
+ }
+
+ return 0;
+}
+
+void QS60PixmapData::fromNativeType(void* pixmap, NativeType nativeType)
+{
+ if (nativeType == QPixmapData::SgImage) {
+ return;
+ } else if (nativeType == QPixmapData::FbsBitmap && pixmap) {
+
+ CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap);
+
+ bool deleteSourceBitmap = false;
+ bool needsCopy = false;
+
+#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
+
+ // Rasterize extended bitmaps
+
+ TUid extendedBitmapType = bitmap->ExtendedBitmapType();
+ if (extendedBitmapType != KNullUid) {
+ CFbsBitmap *rasterBitmap = createSymbianCFbsBitmap(bitmap->SizeInPixels(), EColor16MA);
+
+ CFbsBitmapDevice *rasterBitmapDev = 0;
+ QT_TRAP_THROWING(rasterBitmapDev = CFbsBitmapDevice::NewL(rasterBitmap));
+
+ CFbsBitGc *rasterBitmapGc = 0;
+ TInt err = rasterBitmapDev->CreateContext(rasterBitmapGc);
+ if (err != KErrNone) {
+ delete rasterBitmap;
+ delete rasterBitmapDev;
+ rasterBitmapDev = 0;
+ return;
+ }
+
+ rasterBitmapGc->BitBlt(TPoint( 0, 0), bitmap);
+
+ bitmap = rasterBitmap;
+
+ delete rasterBitmapDev;
+ delete rasterBitmapGc;
+
+ rasterBitmapDev = 0;
+ rasterBitmapGc = 0;
+
+ deleteSourceBitmap = true;
+ }
+#endif
+
+
+ deleteSourceBitmap = bitmap->IsCompressedInRAM();
+ CFbsBitmap *sourceBitmap = uncompress(bitmap);
+
+ TDisplayMode displayMode = sourceBitmap->DisplayMode();
+ QImage::Format format = qt_TDisplayMode2Format(displayMode);
+
+ QImage::Format opaqueFormat = QNativeImage::systemFormat();
+ QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
+
+ if (format != opaqueFormat && format != alphaFormat && format != QImage::Format_MonoLSB)
+ needsCopy = true;
+
+
+ type = (format != QImage::Format_MonoLSB)
+ ? QPixmapData::PixmapType
+ : QPixmapData::BitmapType;
+
+ if (needsCopy) {
+
+ TSize size = sourceBitmap->SizeInPixels();
+
+ QSymbianBitmapDataAccess da;
+ da.beginDataAccess(sourceBitmap);
+ uchar *bytes = (uchar*)sourceBitmap->DataAddress();
+ QImage img = QImage(bytes, size.iWidth, size.iHeight, format);
+ img = img.copy();
+ da.endDataAccess(sourceBitmap);
+
+ if(displayMode == EGray2) {
+ //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
+ //So invert mono bitmaps so that masks work correctly.
+ img.invertPixels();
+ } else if(displayMode == EColor16M) {
+ img = img.rgbSwapped(); // EColor16M is BGR
+ }
+
+ fromImage(img, Qt::AutoColor);
+
+ if(deleteSourceBitmap)
+ delete sourceBitmap;
+ } else {
+ CFbsBitmap* duplicate = 0;
+ QT_TRAP_THROWING(duplicate = new (ELeave) CFbsBitmap);
+
+ TInt err = duplicate->Duplicate(sourceBitmap->Handle());
+ if (err != KErrNone) {
+ qWarning("Could not duplicate CFbsBitmap");
+
+ if(deleteSourceBitmap)
+ delete sourceBitmap;
+
+ delete duplicate;
+ return;
+ }
+
+ fromSymbianBitmap(duplicate);
+
+ if(deleteSourceBitmap)
+ delete sourceBitmap;
+ }
+ }
+}
+
+QPixmapData *QS60PixmapData::createCompatiblePixmapData() const
+{
+ return new QS60PixmapData(pixelType());
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_s60_p.h b/src/gui/image/qpixmap_s60_p.h
new file mode 100644
index 000000000..8631ebd29
--- /dev/null
+++ b/src/gui/image/qpixmap_s60_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+**
+****************************************************************************/
+
+#ifndef QPIXMAPDATA_S60_P_H
+#define QPIXMAPDATA_S60_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/private/qpixmap_raster_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class CFbsBitmap;
+class CFbsBitmapDevice;
+class CFbsBitGc;
+
+class QSymbianBitmapDataAccess;
+
+class QSymbianFbsHeapLock
+{
+public:
+
+ enum LockAction {
+ Unlock
+ };
+
+ explicit QSymbianFbsHeapLock(LockAction a);
+ ~QSymbianFbsHeapLock();
+ void relock();
+
+private:
+
+ LockAction action;
+ bool wasLocked;
+};
+
+class QS60PixmapData : public QRasterPixmapData
+{
+public:
+ QS60PixmapData(PixelType type);
+ ~QS60PixmapData();
+
+ QPixmapData *createCompatiblePixmapData() const;
+
+ void resize(int width, int height);
+ void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
+ void copy(const QPixmapData *data, const QRect &rect);
+ bool scroll(int dx, int dy, const QRect &rect);
+
+ int metric(QPaintDevice::PaintDeviceMetric metric) const;
+ void fill(const QColor &color);
+ void setMask(const QBitmap &mask);
+ void setAlphaChannel(const QPixmap &alphaChannel);
+ QImage toImage() const;
+ QPaintEngine* paintEngine() const;
+
+ void beginDataAccess();
+ void endDataAccess(bool readOnly=false) const;
+
+ void* toNativeType(NativeType type);
+ void fromNativeType(void* pixmap, NativeType type);
+
+private:
+ void release();
+ void fromSymbianBitmap(CFbsBitmap* bitmap);
+ bool initSymbianBitmapContext();
+
+ QSymbianBitmapDataAccess *symbianBitmapDataAccess;
+
+ CFbsBitmap *cfbsBitmap;
+ CFbsBitmapDevice *bitmapDevice;
+ CFbsBitGc *bitmapGc;
+ QPaintEngine *pengine;
+ uchar* bytes;
+
+ bool formatLocked;
+
+ friend class QPixmap;
+ friend class QS60WindowSurface;
+ friend class QS60PaintEngine;
+ friend class QS60Data;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPIXMAPDATA_S60_P_H
+
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index b0f17ba7f..04027c156 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -121,9 +121,12 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
{
+ if (isNull())
+ return 0;
+
HBITMAP bitmap = 0;
if (data->classId() == QPixmapData::RasterClass) {
- QRasterPixmapData* d = static_cast<QRasterPixmapData*>(data);
+ QRasterPixmapData* d = static_cast<QRasterPixmapData*>(data.data());
int w = d->image.width();
int h = d->image.height();
@@ -236,6 +239,44 @@ QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
return fromImage(result);
}
+HBITMAP qt_createIconMask(const QBitmap &bitmap)
+{
+ QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
+ int w = bm.width();
+ int h = bm.height();
+ int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
+ uchar *bits = new uchar[bpl*h];
+ bm.invertPixels();
+ for (int y=0; y<h; y++)
+ memcpy(bits+y*bpl, bm.scanLine(y), bpl);
+ HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
+ delete [] bits;
+ return hbm;
+}
+
+HICON QPixmap::toWinHICON() const
+{
+ QBitmap maskBitmap = mask();
+ if (maskBitmap.isNull()) {
+ maskBitmap= QBitmap(size());
+ maskBitmap.fill(Qt::color1);
+ }
+
+ ICONINFO ii;
+ ii.fIcon = true;
+ ii.hbmMask = qt_createIconMask(maskBitmap);
+ ii.hbmColor = toWinHBITMAP(QPixmap::Alpha);
+ ii.xHotspot = 0;
+ ii.yHotspot = 0;
+
+ HICON hIcon = CreateIconIndirect(&ii);
+
+ DeleteObject(ii.hbmColor);
+ DeleteObject(ii.hbmMask);
+
+ return hIcon;
+}
+
#ifdef Q_WS_WIN
#ifndef Q_WS_WINCE
@@ -273,7 +314,7 @@ static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
return image;
}
-QPixmap convertHIconToPixmap( const HICON icon)
+QPixmap QPixmap::fromWinHICON(HICON icon)
{
bool foundAlpha = false;
HDC screenDevice = GetDC(0);
@@ -283,7 +324,7 @@ QPixmap convertHIconToPixmap( const HICON icon)
ICONINFO iconinfo;
bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
if (!result)
- qWarning("convertHIconToPixmap(), failed to GetIconInfo()");
+ qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
int w = iconinfo.xHotspot * 2;
int h = iconinfo.yHotspot * 2;
@@ -342,60 +383,84 @@ QPixmap convertHIconToPixmap( const HICON icon)
return QPixmap::fromImage(image);
}
#else //ifndef Q_WS_WINCE
-QPixmap convertHIconToPixmap( const HICON icon, bool large)
+QPixmap QPixmap::fromWinHICON(HICON icon)
{
HDC screenDevice = GetDC(0);
HDC hdc = CreateCompatibleDC(screenDevice);
ReleaseDC(0, screenDevice);
- int size = large ? 64 : 32;
+ ICONINFO iconinfo;
+ bool result = GetIconInfo(icon, &iconinfo);
+ if (!result)
+ qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
+
+ int w = 0;
+ int h = 0;
+ if (!iconinfo.xHotspot || !iconinfo.yHotspot) {
+ // We could not retrieve the icon size via GetIconInfo,
+ // so we try again using the icon bitmap.
+ BITMAP bm;
+ int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm);
+ if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm);
+ if (!result) {
+ qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size");
+ return QPixmap();
+ }
+ w = bm.bmWidth;
+ h = bm.bmHeight;
+ } else {
+ // x and y Hotspot describes the icon center
+ w = iconinfo.xHotspot * 2;
+ h = iconinfo.yHotspot * 2;
+ }
+ const DWORD dwImageSize = w * h * 4;
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
- bmi.bmiHeader.biWidth = size;
- bmi.bmiHeader.biHeight = -size;
+ bmi.bmiHeader.biWidth = w;
+ bmi.bmiHeader.biHeight = -h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = size*size*4;
+ bmi.bmiHeader.biSizeImage = dwImageSize;
uchar* bits;
HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0);
if (winBitmap )
- memset(bits, 0xff, size*size*4);
+ memset(bits, 0xff, dwImageSize);
if (!winBitmap) {
- qWarning("convertHIconToPixmap(), failed to CreateDIBSection()");
+ qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()");
return QPixmap();
}
HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
- if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_NORMAL))
- qWarning("convertHIconToPixmap(), failed to DrawIcon()");
+ if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL))
+ qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
uint mask = 0xff000000;
// Create image and copy data into image.
- QImage image(size, size, QImage::Format_ARGB32);
+ QImage image(w, h, QImage::Format_ARGB32);
if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = size * sizeof(QRgb);
- for (int y=0; y<size; ++y) {
+ int bytes_per_line = w * sizeof(QRgb);
+ for (int y=0; y < h; ++y) {
QRgb *dest = (QRgb *) image.scanLine(y);
const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x<size; ++x) {
+ for (int x=0; x < w; ++x) {
dest[x] = src[x];
}
}
}
- if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_MASK))
- qWarning("convertHIconToPixmap(), failed to DrawIcon()");
+ if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK))
+ qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = size * sizeof(QRgb);
- for (int y=0; y<size; ++y) {
+ int bytes_per_line = w * sizeof(QRgb);
+ for (int y=0; y < h; ++y) {
QRgb *dest = (QRgb *) image.scanLine(y);
const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x<size; ++x) {
+ for (int x=0; x < w; ++x) {
if (!src[x])
dest[x] = dest[x] | mask;
}
@@ -407,25 +472,6 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large)
return QPixmap::fromImage(image);
}
#endif //ifndef Q_WS_WINCE
-
-QPixmap loadIconFromShell32( int resourceId, int size )
-{
-#ifdef Q_OS_WINCE
- HMODULE hmod = LoadLibrary(L"ceshell.dll");
-#else
- HMODULE hmod = LoadLibrary(L"shell32.dll");
-#endif
- if( hmod ) {
- HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
- if( iconHandle ) {
- QPixmap iconpixmap = convertHIconToPixmap( iconHandle );
- DestroyIcon(iconHandle);
- return iconpixmap;
- }
- }
- return QPixmap();
-}
-
-#endif
+#endif //ifdef Q_WS_WIN
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 047bd332e..7008fbd4a 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -67,6 +67,7 @@
#include <private/qt_x11_p.h>
#include "qx11info_x11.h"
#include <private/qdrawhelper_p.h>
+#include <private/qimage_p.h>
#include <stdlib.h>
@@ -318,6 +319,11 @@ QX11PixmapData::QX11PixmapData(PixelType type)
{
}
+QPixmapData *QX11PixmapData::createCompatiblePixmapData() const
+{
+ return new QX11PixmapData(pixelType());
+}
+
void QX11PixmapData::resize(int width, int height)
{
setSerialNumber(++qt_pixmap_serial);
@@ -369,6 +375,37 @@ void QX11PixmapData::resize(int width, int height)
#endif // QT_NO_XRENDER
}
+struct QX11AlphaDetector
+{
+ bool hasAlpha() const {
+ if (checked)
+ return has;
+ // Will implicitly also check format and return quickly for opaque types...
+ checked = true;
+ has = const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels();
+ return has;
+ }
+
+ bool hasXRenderAndAlpha() const {
+ if (!X11->use_xrender)
+ return false;
+ return hasAlpha();
+ }
+
+ QX11AlphaDetector(const QImage *i, Qt::ImageConversionFlags flags)
+ : image(i), checked(false), has(false)
+ {
+ if (flags & Qt::NoOpaqueDetection) {
+ checked = true;
+ has = image->hasAlphaChannel();
+ }
+ }
+
+ const QImage *image;
+ mutable bool checked;
+ mutable bool has;
+};
+
void QX11PixmapData::fromImage(const QImage &img,
Qt::ImageConversionFlags flags)
{
@@ -379,6 +416,11 @@ void QX11PixmapData::fromImage(const QImage &img,
d = img.depth();
is_null = (w <= 0 || h <= 0);
+ if (is_null) {
+ w = h = 0;
+ return;
+ }
+
if (defaultScreen >= 0 && defaultScreen != xinfo.screen()) {
QX11InfoData* xd = xinfo.getX11Data(true);
xd->screen = defaultScreen;
@@ -402,7 +444,9 @@ void QX11PixmapData::fromImage(const QImage &img,
return;
}
- int dd = X11->use_xrender && img.hasAlphaChannel() ? 32 : xinfo.depth();
+ QX11AlphaDetector alphaCheck(&img, flags);
+ int dd = alphaCheck.hasXRenderAndAlpha() ? 32 : xinfo.depth();
+
if (qt_x11_preferred_pixmap_depth)
dd = qt_x11_preferred_pixmap_depth;
@@ -425,7 +469,7 @@ void QX11PixmapData::fromImage(const QImage &img,
} else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) {
conv8 = (d == 1); // native depth wanted
} else if (d == 1) {
- if (image.numColors() == 2) {
+ if (image.colorCount() == 2) {
QRgb c0 = image.color(0); // Auto: convert to best
QRgb c1 = image.color(1);
conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255);
@@ -450,11 +494,11 @@ void QX11PixmapData::fromImage(const QImage &img,
Visual *visual = (Visual *)xinfo.visual();
XImage *xi = 0;
bool trucol = (visual->c_class >= TrueColor);
- int nbytes = image.numBytes();
+ int nbytes = image.byteCount();
uchar *newbits= 0;
#ifndef QT_NO_XRENDER
- if (X11->use_xrender && image.hasAlphaChannel()) {
+ if (alphaCheck.hasXRenderAndAlpha()) {
const QImage &cimage = image;
d = 32;
@@ -592,7 +636,7 @@ void QX11PixmapData::fromImage(const QImage &img,
if (d8) { // setup pixel translation
QVector<QRgb> ctable = cimage.colorTable();
- for (int i=0; i < cimage.numColors(); i++) {
+ for (int i=0; i < cimage.colorCount(); i++) {
int r = qRed (ctable[i]);
int g = qGreen(ctable[i]);
int b = qBlue (ctable[i]);
@@ -918,8 +962,8 @@ void QX11PixmapData::fromImage(const QImage &img,
if (d == 8 && !trucol) { // 8 bit pixmap
int pop[256]; // pixel popularity
- if (image.numColors() == 0)
- image.setNumColors(1);
+ if (image.colorCount() == 0)
+ image.setColorCount(1);
const QImage &cimage = image;
memset(pop, 0, sizeof(int)*256); // reset popularity array
@@ -949,11 +993,11 @@ void QX11PixmapData::fromImage(const QImage &img,
int mindist;
};
int ncols = 0;
- for (int i=0; i< cimage.numColors(); i++) { // compute number of colors
+ for (int i=0; i< cimage.colorCount(); i++) { // compute number of colors
if (pop[i] > 0)
ncols++;
}
- for (int i = cimage.numColors(); i < 256; i++) // ignore out-of-range pixels
+ for (int i = cimage.colorCount(); i < 256; i++) // ignore out-of-range pixels
pop[i] = 0;
// works since we make sure above to have at least
@@ -1091,7 +1135,7 @@ void QX11PixmapData::fromImage(const QImage &img,
}
#endif
- if (image.hasAlphaChannel()) {
+ if (alphaCheck.hasAlpha()) {
QBitmap m = QBitmap::fromImage(image.createAlphaMask(flags));
setMask(m);
}
@@ -1225,8 +1269,11 @@ void QX11PixmapData::release()
QPixmap QX11PixmapData::alphaChannel() const
{
- if (!hasAlphaChannel())
- return QPixmap();
+ if (!hasAlphaChannel()) {
+ QPixmap pm(w, h);
+ pm.fill(Qt::white);
+ return pm;
+ }
QImage im(toImage());
return QPixmap::fromImage(im.alphaChannel(), Qt::OrderedDither);
}
@@ -1609,7 +1656,7 @@ QImage QX11PixmapData::toImage() const
}
if (d == 1) { // bitmap
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, qRgb(255,255,255));
image.setColor(1, qRgb(0,0,0));
} else if (!trucol) { // pixmap with colormap
@@ -1665,10 +1712,10 @@ QImage QX11PixmapData::toImage() const
int trans;
if (ncols < 256) {
trans = ncols++;
- image.setNumColors(ncols); // create color table
+ image.setColorCount(ncols); // create color table
image.setColor(trans, 0x00000000);
} else {
- image.setNumColors(ncols); // create color table
+ image.setColorCount(ncols); // create color table
// oh dear... no spare "transparent" pixel.
// use first pixel in image (as good as any).
trans = image.scanLine(0)[0];
@@ -1691,7 +1738,7 @@ QImage QX11PixmapData::toImage() const
}
}
} else {
- image.setNumColors(ncols); // create color table
+ image.setColorCount(ncols); // create color table
}
QVector<QColor> colors = QColormap::instance(xinfo.screen()).colormap();
int j = 0;
@@ -1874,8 +1921,8 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
free(dptr);
return bm;
} else { // color pixmap
- QPixmap pm;
- QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(pm.data);
+ QX11PixmapData *x11Data = new QX11PixmapData(QPixmapData::PixmapType);
+ QPixmap pm(x11Data);
x11Data->flags &= ~QX11PixmapData::Uninitialized;
x11Data->xinfo = xinfo;
x11Data->d = d;
@@ -1934,13 +1981,16 @@ void QPixmap::x11SetScreen(int screen)
return;
}
+ if (isNull())
+ return;
+
if (data->classId() != QPixmapData::X11Class)
return;
if (screen < 0)
screen = QX11Info::appScreen();
- QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(data);
+ QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(data.data());
if (screen == x11Data->xinfo.screen())
return; // nothing to do
@@ -2036,8 +2086,8 @@ bool QX11PixmapData::hasAlphaChannel() const
const QX11Info &QPixmap::x11Info() const
{
- if (data->classId() == QPixmapData::X11Class)
- return static_cast<QX11PixmapData*>(data)->xinfo;
+ if (data && data->classId() == QPixmapData::X11Class)
+ return static_cast<QX11PixmapData*>(data.data())->xinfo;
else {
static QX11Info nullX11Info;
return nullX11Info;
@@ -2093,8 +2143,8 @@ QPaintEngine* QX11PixmapData::paintEngine() const
Qt::HANDLE QPixmap::x11PictureHandle() const
{
#ifndef QT_NO_XRENDER
- if (data->classId() == QPixmapData::X11Class)
- return static_cast<QX11PixmapData*>(data)->picture;
+ if (data && data->classId() == QPixmapData::X11Class)
+ return static_cast<const QX11PixmapData*>(data.data())->picture;
else
return 0;
#else
diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h
index 033179b16..8ce7c0d05 100644
--- a/src/gui/image/qpixmap_x11_p.h
+++ b/src/gui/image/qpixmap_x11_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -71,6 +71,8 @@ public:
// Qt::ImageConversionFlags flags);
~QX11PixmapData();
+ QPixmapData *createCompatiblePixmapData() const;
+
void resize(int width, int height);
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
void copy(const QPixmapData *data, const QRect &rect);
@@ -100,6 +102,9 @@ private:
friend class QX11WindowSurface;
friend class QRasterWindowSurface;
friend class QGLContextPrivate; // Needs to access xinfo, gl_surface & flags
+ friend class QEglContext; // Needs gl_surface
+ friend class QX11GLPixmapData; // Needs gl_surface
+ friend bool qt_createEGLSurfaceForPixmap(QPixmapData*, bool); // Needs gl_surface
void release();
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 762c98fa1..b0b7d728f 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,8 +51,7 @@ QT_BEGIN_NAMESPACE
\brief The QPixmapCache class provides an application-wide cache for pixmaps.
- \ingroup environment
- \ingroup multimedia
+ \ingroup painting
This class is a tool for optimized drawing with QPixmap. You can
use it to store temporary pixmaps that are expensive to generate
@@ -83,10 +82,17 @@ QT_BEGIN_NAMESPACE
A pixmap takes roughly (\e{width} * \e{height} * \e{depth})/8 bytes of
memory.
+ The \e{Qt Quarterly} article
+ \l{http://qt.nokia.com/doc/qq/qq12-qpixmapcache.html}{Optimizing
+ with QPixmapCache} explains how to use QPixmapCache to speed up
+ applications by caching the results of painting.
+
\sa QCache, QPixmap
*/
-#if defined(Q_WS_QWS) || defined(Q_WS_WINCE)
+#if defined(Q_OS_SYMBIAN)
+static int cache_limit = 1024; // 1048 KB cache limit for symbian
+#elif defined(Q_WS_QWS) || defined(Q_WS_WINCE)
static int cache_limit = 2048; // 2048 KB cache limit for embedded
#else
static int cache_limit = 10240; // 10 MB cache limit for desktop
@@ -161,7 +167,7 @@ QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other)
return *this;
}
-class QPMCache : public QObject, public QCache<QPixmapCache::Key, QDetachedPixmap>
+class QPMCache : public QObject, public QCache<QPixmapCache::Key, QPixmapCacheEntry>
{
Q_OBJECT
public:
@@ -209,12 +215,13 @@ uint qHash(const QPixmapCache::Key &k)
QPMCache::QPMCache()
: QObject(0),
- QCache<QPixmapCache::Key, QDetachedPixmap>(cache_limit * 1024),
+ QCache<QPixmapCache::Key, QPixmapCacheEntry>(cache_limit * 1024),
keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false)
{
}
QPMCache::~QPMCache()
{
+ clear();
free(keyArray);
}
@@ -232,7 +239,6 @@ void QPMCache::timerEvent(QTimerEvent *)
{
int mc = maxCost();
bool nt = totalCost() == ps;
- QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QDetachedPixmap>::keys();
setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1);
setMaxCost(mc);
ps = totalCost();
@@ -246,10 +252,6 @@ void QPMCache::timerEvent(QTimerEvent *)
++it;
}
}
- for (int i = 0; i < keys.size(); ++i) {
- if (!contains(keys.at(i)))
- releaseKey(keys.at(i));
- }
if (!size()) {
killTimer(theid);
@@ -268,11 +270,10 @@ QPixmap *QPMCache::object(const QString &key) const
const_cast<QPMCache *>(this)->cacheKeys.remove(key);
return 0;
}
- QPixmap *ptr = QCache<QPixmapCache::Key, QDetachedPixmap>::object(cacheKey);
+ QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(cacheKey);
//We didn't find the pixmap in the cache, the key is not valid anymore
if (!ptr) {
const_cast<QPMCache *>(this)->cacheKeys.remove(key);
- const_cast<QPMCache *>(this)->releaseKey(cacheKey);
}
return ptr;
}
@@ -280,7 +281,7 @@ QPixmap *QPMCache::object(const QString &key) const
QPixmap *QPMCache::object(const QPixmapCache::Key &key) const
{
Q_ASSERT(key.d->isValid);
- QPixmap *ptr = QCache<QPixmapCache::Key, QDetachedPixmap>::object(key);
+ QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(key);
//We didn't find the pixmap in the cache, the key is not valid anymore
if (!ptr)
const_cast<QPMCache *>(this)->releaseKey(key);
@@ -293,13 +294,14 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost)
QPixmapCache::Key oldCacheKey = cacheKeys.value(key);
//If for the same key we add already a pixmap we should delete it
if (oldCacheKey.d) {
- QCache<QPixmapCache::Key, QDetachedPixmap>::remove(oldCacheKey);
- cacheKey = oldCacheKey;
- } else {
- cacheKey = createKey();
- }
+ QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(oldCacheKey);
+ cacheKeys.remove(key);
+ }
+
+ //we create a new key the old one has been removed
+ cacheKey = createKey();
- bool success = QCache<QPixmapCache::Key, QDetachedPixmap>::insert(cacheKey, new QDetachedPixmap(pixmap), cost);
+ bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost);
if (success) {
cacheKeys.insert(key, cacheKey);
if (!theid) {
@@ -316,7 +318,7 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost)
QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost)
{
QPixmapCache::Key cacheKey = createKey();
- bool success = QCache<QPixmapCache::Key, QDetachedPixmap>::insert(cacheKey, new QDetachedPixmap(pixmap), cost);
+ bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost);
if (success) {
if (!theid) {
theid = startTimer(30000);
@@ -332,13 +334,21 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost)
bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost)
{
Q_ASSERT(key.d->isValid);
- //If for the same key we add already a pixmap we should delete it
- QCache<QPixmapCache::Key, QDetachedPixmap>::remove(key);
+ //If for the same key we had already an entry so we should delete the pixmap and use the new one
+ QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key);
+
+ QPixmapCache::Key cacheKey = createKey();
- bool success = QCache<QPixmapCache::Key, QDetachedPixmap>::insert(key, new QDetachedPixmap(pixmap), cost);
- if (success && !theid) {
- theid = startTimer(30000);
- t = false;
+ bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost);
+ if (success) {
+ if(!theid) {
+ theid = startTimer(30000);
+ t = false;
+ }
+ const_cast<QPixmapCache::Key&>(key) = cacheKey;
+ } else {
+ //Insertion failed we released the key
+ releaseKey(cacheKey);
}
return success;
}
@@ -350,23 +360,20 @@ bool QPMCache::remove(const QString &key)
if (!cacheKey.d)
return false;
cacheKeys.remove(key);
- releaseKey(cacheKey);
- return QCache<QPixmapCache::Key, QDetachedPixmap>::remove(cacheKey);
+ return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);
}
bool QPMCache::remove(const QPixmapCache::Key &key)
{
- bool result = QCache<QPixmapCache::Key, QDetachedPixmap>::remove(key);
- //We release the key after we removed it from the cache
- releaseKey(key);
- return result;
+ return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key);
}
void QPMCache::resizeKeyArray(int size)
{
if (size <= keyArraySize || size == 0)
return;
- keyArray = reinterpret_cast<int *>(realloc(keyArray, size * sizeof(int)));
+ keyArray = q_check_ptr(reinterpret_cast<int *>(realloc(keyArray,
+ size * sizeof(int))));
for (int i = keyArraySize; i != size; ++i)
keyArray[i] = i + 1;
keyArraySize = size;
@@ -402,10 +409,10 @@ void QPMCache::clear()
freeKey = 0;
keyArraySize = 0;
//Mark all keys as invalid
- QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QDetachedPixmap>::keys();
+ QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QPixmapCacheEntry>::keys();
for (int i = 0; i < keys.size(); ++i)
keys.at(i).d->isValid = false;
- QCache<QPixmapCache::Key, QDetachedPixmap>::clear();
+ QCache<QPixmapCache::Key, QPixmapCacheEntry>::clear();
}
QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key)
@@ -417,6 +424,11 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key)
Q_GLOBAL_STATIC(QPMCache, pm_cache)
+QPixmapCacheEntry::~QPixmapCacheEntry()
+{
+ pm_cache()->releaseKey(key);
+}
+
/*!
\obsolete
\overload
@@ -608,7 +620,12 @@ void QPixmapCache::remove(const Key &key)
void QPixmapCache::clear()
{
- pm_cache()->clear();
+ QT_TRY {
+ pm_cache()->clear();
+ } QT_CATCH(const std::bad_alloc &) {
+ // if we ran out of memory during pm_cache(), it's no leak,
+ // so just ignore it.
+ }
}
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index 8e65aaf43..8e6e78a16 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h
index cbfc3e891..84e4a0349 100644
--- a/src/gui/image/qpixmapcache_p.h
+++ b/src/gui/image/qpixmapcache_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -76,13 +76,13 @@ public:
};
// XXX: hw: is this a general concept we need to abstract?
-class QDetachedPixmap : public QPixmap
+class QPixmapCacheEntry : public QPixmap
{
public:
- QDetachedPixmap(const QPixmap &pix) : QPixmap(pix)
+ QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key)
{
if (data && data->classId() == QPixmapData::RasterClass) {
- QRasterPixmapData *d = static_cast<QRasterPixmapData*>(data);
+ QRasterPixmapData *d = static_cast<QRasterPixmapData*>(data.data());
if (!d->image.isNull() && d->image.d->paintEngine
&& !d->image.d->paintEngine->isActive())
{
@@ -91,6 +91,8 @@ public:
}
}
}
+ ~QPixmapCacheEntry();
+ QPixmapCache::Key key;
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp
index 001a93027..38f6b5d55 100644
--- a/src/gui/image/qpixmapdata.cpp
+++ b/src/gui/image/qpixmapdata.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,34 +21,49 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qpixmapdata_p.h"
+#include <QtCore/qbuffer.h>
#include <QtGui/qbitmap.h>
#include <QtGui/qimagereader.h>
+#include <private/qgraphicssystem_p.h>
+#include <private/qapplication_p.h>
QT_BEGIN_NAMESPACE
const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80 };
+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));
+ data->resize(w, h);
+ return data;
+}
+
+
QPixmapData::QPixmapData(PixelType pixelType, int objectId)
: w(0),
h(0),
@@ -66,14 +82,55 @@ QPixmapData::~QPixmapData()
{
}
-void QPixmapData::fromFile(const QString &fileName, const char *format,
+QPixmapData *QPixmapData::createCompatiblePixmapData() const
+{
+ QPixmapData *d;
+ QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem();
+ if (gs)
+ d = gs->createPixmapData(pixelType());
+ else
+ d = QGraphicsSystem::createDefaultPixmapData(pixelType());
+ return d;
+}
+
+static QImage makeBitmapCompliantIfNeeded(QPixmapData *d, const QImage &image, Qt::ImageConversionFlags flags)
+{
+ if (d->pixelType() == QPixmapData::BitmapType) {
+ QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags);
+
+ // make sure image.color(0) == Qt::color0 (white)
+ // and image.color(1) == Qt::color1 (black)
+ const QRgb c0 = QColor(Qt::black).rgb();
+ const QRgb c1 = QColor(Qt::white).rgb();
+ if (img.color(0) == c0 && img.color(1) == c1) {
+ img.invertPixels();
+ img.setColor(0, c1);
+ img.setColor(1, c0);
+ }
+ return img;
+ }
+
+ return image;
+}
+
+bool QPixmapData::fromFile(const QString &fileName, const char *format,
Qt::ImageConversionFlags flags)
{
- const QImage image = QImageReader(fileName, format).read();
+ QImage image = QImageReader(fileName, format).read();
if (image.isNull())
- return;
+ return false;
+ fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags);
+ return !isNull();
+}
- fromImage(image, flags);
+bool QPixmapData::fromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
+{
+ QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buf), len);
+ QBuffer b(&a);
+ b.open(QIODevice::ReadOnly);
+ QImage image = QImageReader(&b, format).read();
+ fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags);
+ return !isNull();
}
void QPixmapData::copy(const QPixmapData *data, const QRect &rect)
@@ -144,7 +201,7 @@ QBitmap QPixmapData::mask() const
if (mask.isNull()) // allocation failed
return QBitmap();
- mask.setNumColors(2);
+ mask.setColorCount(2);
mask.setColor(0, QColor(Qt::color0).rgba());
mask.setColor(1, QColor(Qt::color1).rgba());
@@ -192,4 +249,16 @@ QImage* QPixmapData::buffer()
return 0;
}
+#if defined(Q_OS_SYMBIAN)
+void* QPixmapData::toNativeType(NativeType /* type */)
+{
+ return 0;
+}
+
+void QPixmapData::fromNativeType(void* /* pixmap */, NativeType /* typre */)
+{
+ return;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index 1c3e42259..41e29230f 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,17 +66,29 @@ public:
// Must match QPixmap::Type
PixmapType, BitmapType
};
+#if defined(Q_OS_SYMBIAN)
+ enum NativeType {
+ FbsBitmap,
+ SgImage
+ };
+#endif
enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass,
OpenGLClass, OpenVGClass, CustomClass = 1024 };
- QPixmapData(PixelType pixelpType, int classId);
+ QPixmapData(PixelType pixelType, int classId);
virtual ~QPixmapData();
+ virtual QPixmapData *createCompatiblePixmapData() const;
+
virtual void resize(int width, int height) = 0;
virtual void fromImage(const QImage &image,
Qt::ImageConversionFlags flags) = 0;
- virtual void fromFile(const QString &filename, const char *format,
+
+ virtual bool fromFile(const QString &filename, const char *format,
+ Qt::ImageConversionFlags flags);
+ virtual bool fromData(const uchar *buffer, uint len, const char *format,
Qt::ImageConversionFlags flags);
+
virtual void copy(const QPixmapData *data, const QRect &rect);
virtual bool scroll(int dx, int dy, const QRect &rect);
@@ -101,10 +113,18 @@ public:
inline int width() const { return w; }
inline int height() const { return h; }
- inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
+ QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
+ inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
inline int depth() const { return d; }
inline bool isNull() const { return is_null; }
+#if defined(Q_OS_SYMBIAN)
+ virtual void* toNativeType(NativeType type);
+ virtual void fromNativeType(void* pixmap, NativeType type);
+#endif
+
+ static QPixmapData *create(int w, int h, PixelType type);
+
protected:
void setSerialNumber(int serNo);
int w;
@@ -114,9 +134,11 @@ protected:
private:
friend class QPixmap;
- friend class QGLContextPrivate;
friend class QX11PixmapData;
+ friend class QS60PixmapData;
+ friend class QImagePixmapCleanupHooks; // Needs to set is_cached
friend class QGLTextureCache; //Needs to check the reference count
+ friend class QExplicitlySharedDataPointer<QPixmapData>;
QAtomicInt ref;
int detach_no;
@@ -127,15 +149,6 @@ private:
uint is_cached;
};
-#ifdef Q_WS_WIN
-#ifndef Q_WS_WINCE
-QPixmap convertHIconToPixmap( const HICON icon);
-#else
-QPixmap convertHIconToPixmap( const HICON icon, bool large = false);
-#endif
-QPixmap loadIconFromShell32( int resourceId, int size );
-#endif
-
# define QT_XFORM_TYPE_MSBFIRST 0
# define QT_XFORM_TYPE_LSBFIRST 1
# if defined(Q_WS_WIN)
diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp
index 2af68c27d..806883d94 100644
--- a/src/gui/image/qpixmapdatafactory.cpp
+++ b/src/gui/image/qpixmapdatafactory.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,12 +47,15 @@
#ifdef Q_WS_X11
# include <private/qpixmap_x11_p.h>
#endif
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN)
# include <private/qpixmap_raster_p.h>
#endif
#ifdef Q_WS_MAC
# include <private/qpixmap_mac_p.h>
#endif
+#ifdef Q_WS_S60
+# include <private/qpixmap_s60_p.h>
+#endif
#include "private/qapplication_p.h"
#include "private/qgraphicssystem_p.h"
@@ -79,6 +82,8 @@ QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type)
return new QRasterPixmapData(type);
#elif defined(Q_WS_MAC)
return new QMacPixmapData(type);
+#elif defined(Q_WS_S60)
+ return new QS60PixmapData(type);
#else
#error QSimplePixmapDataFactory::create() not implemented
#endif
diff --git a/src/gui/image/qpixmapdatafactory_p.h b/src/gui/image/qpixmapdatafactory_p.h
index c7f69a20e..b2fac68db 100644
--- a/src/gui/image/qpixmapdatafactory_p.h
+++ b/src/gui/image/qpixmapdatafactory_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index cd80b1083..3723500cd 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,6 +53,7 @@
#include "private/qpaintengineex_p.h"
#include "private/qpaintengine_raster_p.h"
+#ifndef QT_NO_GRAPHICSEFFECT
QT_BEGIN_NAMESPACE
class QPixmapFilterPrivate : public QObjectPrivate
@@ -65,7 +66,7 @@ public:
/*!
\class QPixmapFilter
\since 4.5
- \ingroup multimedia
+ \ingroup painting
\brief The QPixmapFilter class provides the basic functionality for
pixmap filter classes. Pixmap filter can be for example colorize or blur.
@@ -93,6 +94,9 @@ public:
\value DropShadowFilter A filter that is used to add a drop shadow to an
image. See QPixmapDropShadowFilter for more
information.
+ \value BlurFilter A filter that is used to blur an image using
+ a simple blur radius. See QPixmapBlurFilter
+ for more information.
\value UserFilter The first filter type that can be used for
application-specific purposes.
@@ -172,7 +176,7 @@ QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const
/*!
\class QPixmapConvolutionFilter
\since 4.5
- \ingroup multimedia
+ \ingroup painting
\brief The QPixmapConvolutionFilter class provides convolution
filtering for pixmaps.
@@ -415,13 +419,12 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q
return;
QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
- static_cast<QPaintEngineEx *>(painter->paintEngine())->createPixmapFilter(type()) : 0;
+ static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter);
if (convolutionFilter) {
convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight);
convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha;
convolutionFilter->draw(painter, p, src, srcRect);
- delete convolutionFilter;
return;
}
@@ -475,6 +478,234 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q
}
}
+/*!
+ \class QPixmapBlurFilter
+ \since 4.6
+ \ingroup multimedia
+
+ \brief The QPixmapBlurFilter class provides blur filtering
+ for pixmaps.
+
+ QPixmapBlurFilter implements a blur pixmap filter,
+ which is applied when \l{QPixmapFilter::}{draw()} is called.
+
+ The filter lets you specialize the radius of the blur as well
+ as hints as to whether to prefer performance or quality.
+
+ By default, the blur effect is produced by applying an exponential
+ filter generated from the specified blurRadius(). Paint engines
+ may override this with a custom blur that is faster on the
+ underlying hardware.
+
+ \sa {Pixmap Filters Example}, QPixmapConvolutionFilter, QPixmapDropShadowFilter
+
+ \internal
+*/
+
+class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate
+{
+public:
+ QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {}
+
+ qreal radius;
+ QGraphicsBlurEffect::BlurHints hints;
+};
+
+
+/*!
+ Constructs a pixmap blur filter.
+
+ \internal
+*/
+QPixmapBlurFilter::QPixmapBlurFilter(QObject *parent)
+ : QPixmapFilter(*new QPixmapBlurFilterPrivate, BlurFilter, parent)
+{
+}
+
+/*!
+ Destructor of pixmap blur filter.
+
+ \internal
+*/
+QPixmapBlurFilter::~QPixmapBlurFilter()
+{
+}
+
+/*!
+ Sets the radius of the blur filter. Higher radius produces increased blurriness.
+
+ \internal
+*/
+void QPixmapBlurFilter::setRadius(qreal radius)
+{
+ Q_D(QPixmapBlurFilter);
+ d->radius = radius;
+}
+
+/*!
+ Gets the radius of the blur filter.
+
+ \internal
+*/
+qreal QPixmapBlurFilter::radius() const
+{
+ Q_D(const QPixmapBlurFilter);
+ return d->radius;
+}
+
+/*!
+ Setting the blur hints to PerformanceHint causes the implementation
+ to trade off visual quality to blur the image faster. Setting the
+ blur hints to QualityHint causes the implementation to improve
+ visual quality at the expense of speed.
+
+ AnimationHint causes the implementation to optimize for animating
+ the blur radius, possibly by caching blurred versions of the source
+ pixmap.
+
+ The implementation is free to ignore this value if it only has a single
+ blur algorithm.
+
+ \internal
+*/
+void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
+{
+ Q_D(QPixmapBlurFilter);
+ d->hints = hints;
+}
+
+/*!
+ Gets the blur hints of the blur filter.
+
+ \internal
+*/
+QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const
+{
+ Q_D(const QPixmapBlurFilter);
+ return d->hints;
+}
+
+/*!
+ \internal
+*/
+QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const
+{
+ Q_D(const QPixmapBlurFilter);
+ const qreal delta = d->radius + 1;
+ return rect.adjusted(-delta, -delta, delta, delta);
+}
+
+// Blur the image according to the blur radius
+// Based on exponential blur algorithm by Jani Huhtanen
+// (maximum radius is set to 16)
+static QImage blurred(const QImage& image, const QRect& rect, int radius, bool alphaOnly = false)
+{
+ int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
+ int alpha = (radius < 1) ? 16 : (radius > 17) ? 1 : tab[radius-1];
+
+ QImage result = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ int r1 = rect.top();
+ int r2 = rect.bottom();
+ int c1 = rect.left();
+ int c2 = rect.right();
+
+ int bpl = result.bytesPerLine();
+ int rgba[4];
+ unsigned char* p;
+
+ int i1 = 0;
+ int i2 = 3;
+
+ if (alphaOnly)
+ i1 = i2 = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3);
+
+ for (int col = c1; col <= c2; col++) {
+ p = result.scanLine(r1) + col * 4;
+ for (int i = i1; i <= i2; i++)
+ rgba[i] = p[i] << 4;
+
+ p += bpl;
+ for (int j = r1; j < r2; j++, p += bpl)
+ for (int i = i1; i <= i2; i++)
+ p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
+ }
+
+ for (int row = r1; row <= r2; row++) {
+ p = result.scanLine(row) + c1 * 4;
+ for (int i = i1; i <= i2; i++)
+ rgba[i] = p[i] << 4;
+
+ p += 4;
+ for (int j = c1; j < c2; j++, p += 4)
+ for (int i = i1; i <= i2; i++)
+ p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
+ }
+
+ for (int col = c1; col <= c2; col++) {
+ p = result.scanLine(r2) + col * 4;
+ for (int i = i1; i <= i2; i++)
+ rgba[i] = p[i] << 4;
+
+ p -= bpl;
+ for (int j = r1; j < r2; j++, p -= bpl)
+ for (int i = i1; i <= i2; i++)
+ p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
+ }
+
+ for (int row = r1; row <= r2; row++) {
+ p = result.scanLine(row) + c2 * 4;
+ for (int i = i1; i <= i2; i++)
+ rgba[i] = p[i] << 4;
+
+ p -= 4;
+ for (int j = c1; j < c2; j++, p -= 4)
+ for (int i = i1; i <= i2; i++)
+ p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
+ }
+
+ return result;
+}
+
+/*!
+ \internal
+*/
+void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect) const
+{
+ Q_D(const QPixmapBlurFilter);
+ if (!painter->isActive())
+ return;
+
+ if (d->radius <= 0) {
+ painter->drawPixmap(srcRect.translated(p), src, srcRect);
+ return;
+ }
+
+ QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
+ static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
+ QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter);
+ if (blurFilter) {
+ blurFilter->setRadius(d->radius);
+ blurFilter->setBlurHints(d->hints);
+ blurFilter->draw(painter, p, src, srcRect);
+ return;
+ }
+
+ QImage srcImage;
+ QImage destImage;
+
+ if (srcRect.isNull()) {
+ srcImage = src.toImage();
+ destImage = blurred(srcImage, srcImage.rect(), qRound(d->radius));
+ } else {
+ QRect rect = srcRect.toAlignedRect().intersected(src.rect());
+
+ srcImage = src.copy(rect).toImage();
+ destImage = blurred(srcImage, srcImage.rect(), qRound(d->radius));
+ }
+
+ painter->drawImage(p, destImage);
+}
+
// grayscales the image to dest (could be same). If rect isn't defined
// destination image size is used to determine the dimension of grayscaling
// process.
@@ -517,7 +748,7 @@ static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRe
/*!
\class QPixmapColorizeFilter
\since 4.5
- \ingroup multimedia
+ \ingroup painting
\brief The QPixmapColorizeFilter class provides colorizing
filtering for pixmaps.
@@ -539,6 +770,10 @@ class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate
Q_DECLARE_PUBLIC(QPixmapColorizeFilter)
public:
QColor color;
+ qreal strength;
+ quint32 opaque : 1;
+ quint32 alphaBlend : 1;
+ quint32 padding : 30;
};
/*!
@@ -551,7 +786,11 @@ public:
QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent)
: QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent)
{
- d_func()->color = QColor(0, 0, 192);
+ Q_D(QPixmapColorizeFilter);
+ d->color = QColor(0, 0, 192);
+ d->strength = qreal(1);
+ d->opaque = true;
+ d->alphaBlend = false;
}
/*!
@@ -577,23 +816,53 @@ void QPixmapColorizeFilter::setColor(const QColor &color)
}
/*!
+ Gets the strength of the colorize filter, 1.0 means full colorized while
+ 0.0 equals to no filtering at all.
+
+ \internal
+*/
+qreal QPixmapColorizeFilter::strength() const
+{
+ Q_D(const QPixmapColorizeFilter);
+ return d->strength;
+}
+
+/*!
+ Sets the strength of the colorize filter to \a strength.
+
+ \internal
+*/
+void QPixmapColorizeFilter::setStrength(qreal strength)
+{
+ Q_D(QPixmapColorizeFilter);
+ d->strength = qBound(qreal(0), strength, qreal(1));
+ d->opaque = !qFuzzyIsNull(d->strength);
+ d->alphaBlend = !qFuzzyIsNull(d->strength - 1);
+}
+
+/*!
\internal
*/
void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
{
Q_D(const QPixmapColorizeFilter);
QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
- static_cast<QPaintEngineEx *>(painter->paintEngine())->createPixmapFilter(type()) : 0;
+ static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter);
if (colorizeFilter) {
colorizeFilter->setColor(d->color);
+ colorizeFilter->setStrength(d->strength);
colorizeFilter->draw(painter, dest, src, srcRect);
- delete colorizeFilter;
return;
}
// falling back to raster implementation
+ if (!d->opaque) {
+ painter->drawPixmap(dest, src, srcRect);
+ return;
+ }
+
QImage srcImage;
QImage destImage;
@@ -616,6 +885,16 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
destPainter.fillRect(srcImage.rect(), d->color);
destPainter.end();
+ if (d->alphaBlend) {
+ // alpha blending srcImage and destImage
+ QImage buffer = srcImage;
+ QPainter bufPainter(&buffer);
+ bufPainter.setOpacity(d->strength);
+ bufPainter.drawImage(0, 0, destImage);
+ bufPainter.end();
+ destImage = buffer;
+ }
+
if (srcImage.hasAlphaChannel())
destImage.setAlphaChannel(srcImage.alphaChannel());
@@ -626,22 +905,17 @@ class QPixmapDropShadowFilterPrivate : public QPixmapFilterPrivate
{
public:
QPixmapDropShadowFilterPrivate()
- : offset(8, 8),
- radius(1),
- color(63, 63, 63, 255) {
- }
+ : offset(8, 8), color(63, 63, 63, 180), radius(1) {}
QPointF offset;
- qreal radius;
QColor color;
-
- QPixmapConvolutionFilter *convolution;
+ qreal radius;
};
/*!
\class QPixmapDropShadowFilter
\since 4.5
- \ingroup multimedia
+ \ingroup painting
\brief The QPixmapDropShadowFilter class is a convenience class
for drawing pixmaps with drop shadows.
@@ -679,10 +953,6 @@ public:
QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent)
: QPixmapFilter(*new QPixmapDropShadowFilterPrivate, DropShadowFilter, parent)
{
- Q_D(QPixmapDropShadowFilter);
- d->convolution = new QPixmapConvolutionFilter;
-
- setBlurRadius(1);
}
/*!
@@ -692,8 +962,6 @@ QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent)
*/
QPixmapDropShadowFilter::~QPixmapDropShadowFilter()
{
- Q_D(QPixmapDropShadowFilter);
- delete d->convolution;
}
/*!
@@ -723,15 +991,7 @@ qreal QPixmapDropShadowFilter::blurRadius() const
void QPixmapDropShadowFilter::setBlurRadius(qreal radius)
{
Q_D(QPixmapDropShadowFilter);
-
d->radius = radius;
-
- int dim = 2 * qRound(radius) + 1;
- QVarLengthArray<qreal> arr(dim * dim);
- qreal f = 1 / qreal(dim * dim);
- for (int i = 0; i < dim * dim; ++i)
- arr[i] = f;
- d->convolution->setConvolutionKernel(arr.data(), dim, dim);
}
/*!
@@ -804,13 +1064,7 @@ void QPixmapDropShadowFilter::setOffset(const QPointF &offset)
QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const
{
Q_D(const QPixmapDropShadowFilter);
-
- qreal x1 = qMin(rect.left(), rect.left() + d->offset.x() - d->radius);
- qreal y1 = qMin(rect.top(), rect.top() + d->offset.y() - d->radius);
- qreal x2 = qMax(rect.right(), rect.right() + d->offset.x() + d->radius);
- qreal y2 = qMax(rect.bottom(), rect.bottom() + d->offset.y() + d->radius);
-
- return QRectF(x1, y1, x2 - x1, y2 - y1);
+ return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius));
}
/*!
@@ -822,19 +1076,40 @@ void QPixmapDropShadowFilter::draw(QPainter *p,
const QRectF &src) const
{
Q_D(const QPixmapDropShadowFilter);
+ QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ?
+ static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0;
+ QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter);
+ if (dropShadowFilter) {
+ dropShadowFilter->setColor(d->color);
+ dropShadowFilter->setBlurRadius(d->radius);
+ dropShadowFilter->setOffset(d->offset);
+ dropShadowFilter->draw(p, pos, px, src);
+ return;
+ }
- QPixmap tmp = src.isNull() ? px : px.copy(src.toRect());
+ QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied);
+ tmp.fill(0);
QPainter tmpPainter(&tmp);
+ tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ tmpPainter.drawPixmap(d->offset, px);
+ tmpPainter.end();
+
+ // blur the alpha channel
+ tmp = blurred(tmp, tmp.rect(), qRound(d->radius), true);
// blacken the image...
+ tmpPainter.begin(&tmp);
tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
- tmpPainter.fillRect(0, 0, tmp.width(), tmp.height(), d->color);
+ tmpPainter.fillRect(tmp.rect(), d->color);
tmpPainter.end();
// draw the blurred drop shadow...
- d->convolution->draw(p, pos + d->offset, tmp);
+ p->drawImage(pos, tmp);
// Draw the actual pixmap...
p->drawPixmap(pos, px, src);
}
+
QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSEFFECT
diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h
index b8588bd52..46e744e72 100644
--- a/src/gui/image/qpixmapfilter_p.h
+++ b/src/gui/image/qpixmapfilter_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,7 +55,9 @@
#include <QtCore/qnamespace.h>
#include <QtGui/qpixmap.h>
+#include <QtGui/qgraphicseffect.h>
+#ifndef QT_NO_GRAPHICSEFFECT
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -78,6 +80,7 @@ public:
ConvolutionFilter,
ColorizeFilter,
DropShadowFilter,
+ BlurFilter,
UserFilter = 1024
};
@@ -117,6 +120,30 @@ private:
int columns() const;
};
+class QPixmapBlurFilterPrivate;
+
+class Q_GUI_EXPORT QPixmapBlurFilter : public QPixmapFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPixmapBlurFilter)
+
+public:
+ QPixmapBlurFilter(QObject *parent = 0);
+ ~QPixmapBlurFilter();
+
+ void setRadius(qreal radius);
+ void setBlurHints(QGraphicsBlurEffect::BlurHints hints);
+
+ qreal radius() const;
+ QGraphicsBlurEffect::BlurHints blurHints() const;
+
+ QRectF boundingRectFor(const QRectF &rect) const;
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
+
+private:
+ friend class QGLPixmapBlurFilter;
+};
+
class QPixmapColorizeFilterPrivate;
class Q_GUI_EXPORT QPixmapColorizeFilter : public QPixmapFilter
@@ -130,6 +157,9 @@ public:
void setColor(const QColor& color);
QColor color() const;
+ void setStrength(qreal strength);
+ qreal strength() const;
+
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
};
@@ -162,4 +192,5 @@ QT_END_NAMESPACE
QT_END_HEADER
+#endif //QT_NO_GRAPHICSEFFECT
#endif // QPIXMAPFILTER_H
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 64bc5d320..14c863b2e 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -171,7 +171,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
if (image.isNull())
return;
}
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(1, qRgb(0,0,0));
image.setColor(0, qRgb(255,255,255));
} else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
@@ -199,13 +199,17 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
if (image.isNull())
return;
}
- image.setNumColors(ncols);
+ image.setColorCount(ncols);
for (int i=0; i<ncols; i++) {
int c = i*255/(ncols-1);
image.setColor(i, qRgba(c,c,c,0xff));
}
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4)
const int g = info_ptr->trans_values.gray;
+#else
+ const int g = info_ptr->trans_color.gray;
+#endif
if (g < ncols) {
image.setColor(g, 0);
}
@@ -226,7 +230,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
if (image.isNull())
return;
}
- image.setNumColors(info_ptr->num_palette);
+ image.setColorCount(info_ptr->num_palette);
int i = 0;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
while (i < info_ptr->num_trans) {
@@ -234,7 +238,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
info_ptr->palette[i].red,
info_ptr->palette[i].green,
info_ptr->palette[i].blue,
+#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4)
info_ptr->trans[i]
+#else
+ info_ptr->trans_alpha[i]
+#endif
)
);
i++;
@@ -500,7 +508,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
// sanity check palette entries
if (color_type == PNG_COLOR_TYPE_PALETTE
&& outImage->format() == QImage::Format_Indexed8) {
- int color_table_size = outImage->numColors();
+ int color_table_size = outImage->colorCount();
for (int y=0; y<(int)height; ++y) {
uchar *p = outImage->scanLine(y);
uchar *end = p + width;
@@ -754,9 +762,9 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in,
png_colorp palette = 0;
png_bytep copy_trans = 0;
- if (image.numColors()) {
+ if (image.colorCount()) {
// Paletted
- int num_palette = image.numColors();
+ int num_palette = image.colorCount();
palette = new png_color[num_palette];
png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
int* trans = new int[num_palette];
diff --git a/src/gui/image/qpnghandler_p.h b/src/gui/image/qpnghandler_p.h
index 62035755c..39b7248ed 100644
--- a/src/gui/image/qpnghandler_p.h
+++ b/src/gui/image/qpnghandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index ed8f4c13a..8ec9efbe0 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -242,11 +242,11 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
}
if (nbits == 1) { // bitmap
- outImage->setNumColors(2);
+ outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
} else if (nbits == 8) { // graymap
- outImage->setNumColors(maxc+1);
+ outImage->setColorCount(maxc+1);
for (int i=0; i<=maxc; i++)
outImage->setColor(i, qRgb(i*255/maxc,i*255/maxc,i*255/maxc));
}
@@ -287,7 +287,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
}
}
- if (image.depth() == 1 && image.numColors() == 2) {
+ if (image.depth() == 1 && image.colorCount() == 2) {
if (qGray(image.color(0)) < qGray(image.color(1))) {
// 0=dark/black, 1=light/white - invert
image.detach();
diff --git a/src/gui/image/qppmhandler_p.h b/src/gui/image/qppmhandler_p.h
index 1543391b7..de74a7f5a 100644
--- a/src/gui/image/qppmhandler_p.h
+++ b/src/gui/image/qppmhandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp
index bfbbc3422..0d76ea091 100644
--- a/src/gui/image/qxbmhandler.cpp
+++ b/src/gui/image/qxbmhandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -135,7 +135,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage)
return false;
}
- outImage->setNumColors(2);
+ outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
diff --git a/src/gui/image/qxbmhandler_p.h b/src/gui/image/qxbmhandler_p.h
index 7d5d34c36..bdb6f2d6d 100644
--- a/src/gui/image/qxbmhandler_p.h
+++ b/src/gui/image/qxbmhandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index cb5d125df..ac4711a66 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -895,7 +895,7 @@ static bool read_xpm_body(
if (image.isNull())
return false;
}
- image.setNumColors(ncols);
+ image.setColorCount(ncols);
}
QMap<quint64, int> colorMap;
diff --git a/src/gui/image/qxpmhandler_p.h b/src/gui/image/qxpmhandler_p.h
index 0e4c55ee7..925f39f83 100644
--- a/src/gui/image/qxpmhandler_p.h
+++ b/src/gui/image/qxpmhandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -9,8 +10,8 @@
** 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** 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
@@ -20,21 +21,20 @@
** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
+**
+**
+**
+**
+**
+**
**
-** 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.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/