Merge "Merge remote-tracking branch 'origin/5.5' into HEAD" into refs/staging/dev

This commit is contained in:
Simon Hausmann 2015-05-04 11:22:55 +00:00 committed by The Qt Project
commit 862cceb6d2
45 changed files with 830 additions and 413 deletions

View File

@ -16,14 +16,12 @@ QMAKE_LINK_SHLIB = $$QMAKE_CXX
CONFIG += clang_pch_style CONFIG += clang_pch_style
QMAKE_PCH_OUTPUT_EXT = .pch QMAKE_PCH_OUTPUT_EXT = .pch
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g
QMAKE_CFLAGS_ISYSTEM = -isystem QMAKE_CFLAGS_ISYSTEM = -isystem
QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT} QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_LTCG = -flto QMAKE_CFLAGS_LTCG = -flto
QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG

View File

@ -15,15 +15,11 @@ QMAKE_CC = gcc
QMAKE_LINK_C = $$QMAKE_CC QMAKE_LINK_C = $$QMAKE_CC
QMAKE_LINK_C_SHLIB = $$QMAKE_CC QMAKE_LINK_C_SHLIB = $$QMAKE_CC
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g
QMAKE_CXX = g++ QMAKE_CXX = g++
QMAKE_LINK = $$QMAKE_CXX QMAKE_LINK = $$QMAKE_CXX
QMAKE_LINK_SHLIB = $$QMAKE_CXX QMAKE_LINK_SHLIB = $$QMAKE_CXX
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_PCH_OUTPUT_EXT = .gch QMAKE_PCH_OUTPUT_EXT = .gch
QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}

View File

@ -39,6 +39,7 @@ QMAKE_CFLAGS_DEPS += -M
QMAKE_CFLAGS_WARN_ON += -Wall -W QMAKE_CFLAGS_WARN_ON += -Wall -W
QMAKE_CFLAGS_WARN_OFF += -w QMAKE_CFLAGS_WARN_OFF += -w
QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g
QMAKE_CFLAGS_DEBUG += -g QMAKE_CFLAGS_DEBUG += -g
QMAKE_CFLAGS_SHLIB += -fPIC QMAKE_CFLAGS_SHLIB += -fPIC
QMAKE_CFLAGS_STATIC_LIB += -fPIC QMAKE_CFLAGS_STATIC_LIB += -fPIC
@ -57,6 +58,7 @@ QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
@ -73,6 +75,7 @@ QMAKE_LFLAGS +=
QMAKE_LFLAGS_DEBUG += QMAKE_LFLAGS_DEBUG +=
QMAKE_LFLAGS_APP += QMAKE_LFLAGS_APP +=
QMAKE_LFLAGS_RELEASE += QMAKE_LFLAGS_RELEASE +=
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO +=
QMAKE_LFLAGS_EXCEPTIONS_OFF += QMAKE_LFLAGS_EXCEPTIONS_OFF +=
QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG -fuse-linker-plugin QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG -fuse-linker-plugin

View File

@ -103,7 +103,14 @@ mac:CONFIG(shared, static|shared):contains(QT_CONFIG, qt_framework) {
# Set the CFBundleIdentifier prefix for Qt frameworks # Set the CFBundleIdentifier prefix for Qt frameworks
QMAKE_TARGET_BUNDLE_PREFIX = org.qt-project QMAKE_TARGET_BUNDLE_PREFIX = org.qt-project
#QMAKE_FRAMEWORK_VERSION = 4.0 #QMAKE_FRAMEWORK_VERSION = 4.0
CONFIG += lib_bundle sliced_bundle qt_framework CONFIG += sliced_bundle qt_framework
qt_no_install_library {
CONFIG += bundle
QMAKE_BUNDLE_EXTENSION = .framework
QMAKE_INFO_PLIST = $$QMAKESPEC/Info.plist.lib
} else {
CONFIG += lib_bundle
}
CONFIG -= qt_install_headers #no need to install these as well CONFIG -= qt_install_headers #no need to install these as well
!debug_and_release|!build_all|CONFIG(release, debug|release) { !debug_and_release|!build_all|CONFIG(release, debug|release) {
FRAMEWORK_HEADERS.version = Versions FRAMEWORK_HEADERS.version = Versions

View File

@ -62,14 +62,14 @@ MODULE_FWD_PRI = $$mod_work_pfx/qt_lib_$${MODULE_ID}.pri
module_rundep = "QT.$${MODULE_ID}.run_depends = $$replace(QT_PRIVATE, -private$, _private)" module_rundep = "QT.$${MODULE_ID}.run_depends = $$replace(QT_PRIVATE, -private$, _private)"
else: \ else: \
module_rundep = module_rundep =
equals(TEMPLATE, aux): \ static: \
module_build_type = no_link
else:static: \
module_build_type = staticlib module_build_type = staticlib
else:mac:contains(QT_CONFIG, qt_framework): \ else:mac:contains(QT_CONFIG, qt_framework): \
module_build_type = lib_bundle module_build_type = lib_bundle
else: \ else: \
module_build_type = module_build_type =
equals(TEMPLATE, aux): \
module_build_type += no_link
internal_module: \ internal_module: \
module_build_type += internal_module module_build_type += internal_module
ltcg: \ ltcg: \

View File

@ -614,9 +614,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "\n\t" << var("QMAKE_POST_LINK"); t << "\n\t" << var("QMAKE_POST_LINK");
t << endl << endl; t << endl << endl;
} else if(!project->isEmpty("QMAKE_BUNDLE")) { } else if(!project->isEmpty("QMAKE_BUNDLE")) {
QString currentLink = destdir_r + "Versions/Current"; bundledFiles << destdir_r + "$(TARGET)";
QString currentLink_f = escapeDependencyPath(currentLink);
bundledFiles << currentLink << destdir_r + "$(TARGET)";
t << "\n\t" t << "\n\t"
<< "-$(DEL_FILE) $(TARGET) $(TARGET0) $(DESTDIR)$(TARGET0)\n\t" << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(DESTDIR)$(TARGET0)\n\t"
<< var("QMAKE_LINK_SHLIB_CMD") << "\n\t" << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"
@ -624,10 +622,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "-$(MOVE) $(TARGET) $(DESTDIR)$(TARGETD)\n\t" << "-$(MOVE) $(TARGET) $(DESTDIR)$(TARGETD)\n\t"
<< mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"", false) << "\n\t" << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"", false) << "\n\t"
<< varGlue("QMAKE_LN_SHLIB", "-", " ", << varGlue("QMAKE_LN_SHLIB", "-", " ",
" Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t" " Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t";
<< "-$(DEL_FILE) " << currentLink_f << "\n\t"
<< varGlue("QMAKE_LN_SHLIB","-"," ", " " + project->first("QMAKE_FRAMEWORK_VERSION") +
' ' + currentLink_f) << "\n\t";
if(!project->isEmpty("QMAKE_POST_LINK")) if(!project->isEmpty("QMAKE_POST_LINK"))
t << "\n\t" << var("QMAKE_POST_LINK"); t << "\n\t" << var("QMAKE_POST_LINK");
t << endl << endl; t << endl << endl;
@ -937,6 +932,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< mkdir_p_asstring(bundle_dir) << "\n\t" << mkdir_p_asstring(bundle_dir) << "\n\t"
<< "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << endl; << "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << endl;
} }
if (!project->first("QMAKE_FRAMEWORK_VERSION").isEmpty()) {
QString currentLink = bundle_dir + "Versions/Current";
QString currentLink_f = escapeDependencyPath(currentLink);
bundledFiles << currentLink;
alldeps << currentLink;
t << currentLink_f << ": $(MAKEFILE)\n\t"
<< mkdir_p_asstring(bundle_dir + "Versions") << "\n\t"
<< "@-$(DEL_FILE) " << currentLink_f << "\n\t"
<< "@$(SYMLINK) " << project->first("QMAKE_FRAMEWORK_VERSION")
<< ' ' << currentLink_f << endl;
}
} }
t << endl << "all: " << deps t << endl << "all: " << deps

View File

@ -989,6 +989,10 @@ QByteArray QIODevice::readAll()
// Size is unknown, read incrementally. // Size is unknown, read incrementally.
qint64 readResult; qint64 readResult;
do { do {
if (quint64(readBytes) + QIODEVICE_BUFFERSIZE > QByteArray::MaxSize) {
// If resize would fail, don't read more, return what we have.
break;
}
result.resize(readBytes + QIODEVICE_BUFFERSIZE); result.resize(readBytes + QIODEVICE_BUFFERSIZE);
readResult = read(result.data() + readBytes, QIODEVICE_BUFFERSIZE); readResult = read(result.data() + readBytes, QIODEVICE_BUFFERSIZE);
if (readResult > 0 || readBytes == 0) if (readResult > 0 || readBytes == 0)

View File

@ -447,6 +447,9 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
bytesRead = device->read(buf, sizeof(buf)); bytesRead = device->read(buf, sizeof(buf));
} }
if (bytesRead <= 0)
return false;
#ifndef QT_NO_TEXTCODEC #ifndef QT_NO_TEXTCODEC
// codec auto detection, explicitly defaults to locale encoding if the // codec auto detection, explicitly defaults to locale encoding if the
// codec has been set to 0. // codec has been set to 0.
@ -470,9 +473,6 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
qt_prettyDebug(buf, qMin(32,int(bytesRead)) , int(bytesRead)).constData(), int(sizeof(buf)), int(bytesRead)); qt_prettyDebug(buf, qMin(32,int(bytesRead)) , int(bytesRead)).constData(), int(sizeof(buf)), int(bytesRead));
#endif #endif
if (bytesRead <= 0)
return false;
int oldReadBufferSize = readBuffer.size(); int oldReadBufferSize = readBuffer.size();
#ifndef QT_NO_TEXTCODEC #ifndef QT_NO_TEXTCODEC
// convert to unicode // convert to unicode

View File

@ -2577,8 +2577,8 @@ void QSortFilterProxyModel::invalidateFilter()
/*! /*!
Returns \c true if the value of the item referred to by the given Returns \c true if the value of the item referred to by the given
index \a left is less than the value of the item referred to by index \a source_left is less than the value of the item referred to by
the given index \a right, otherwise returns \c false. the given index \a source_right, otherwise returns \c false.
This function is used as the < operator when sorting, and handles This function is used as the < operator when sorting, and handles
the following QVariant types: the following QVariant types:
@ -2612,11 +2612,11 @@ void QSortFilterProxyModel::invalidateFilter()
\sa sortRole, sortCaseSensitivity, dynamicSortFilter \sa sortRole, sortCaseSensitivity, dynamicSortFilter
*/ */
bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const bool QSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{ {
Q_D(const QSortFilterProxyModel); Q_D(const QSortFilterProxyModel);
QVariant l = (left.model() ? left.model()->data(left, d->sort_role) : QVariant()); QVariant l = (source_left.model() ? source_left.model()->data(source_left, d->sort_role) : QVariant());
QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant()); QVariant r = (source_right.model() ? source_right.model()->data(source_right, d->sort_role) : QVariant());
switch (l.userType()) { switch (l.userType()) {
case QVariant::Invalid: case QVariant::Invalid:
return (r.type() != QVariant::Invalid); return (r.type() != QVariant::Invalid);

View File

@ -111,7 +111,7 @@ public Q_SLOTS:
protected: protected:
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const; virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
void filterChanged(); void filterChanged();
void invalidateFilter(); void invalidateFilter();

View File

@ -566,7 +566,22 @@ QByteArray QMimeData::data(const QString &mimeType) const
void QMimeData::setData(const QString &mimeType, const QByteArray &data) void QMimeData::setData(const QString &mimeType, const QByteArray &data)
{ {
Q_D(QMimeData); Q_D(QMimeData);
d->setData(mimeType, QVariant(data));
if (mimeType == QLatin1String("text/uri-list")) {
QByteArray ba = data;
if (ba.endsWith('\0'))
ba.chop(1);
QList<QByteArray> urls = ba.split('\n');
QList<QVariant> list;
for (int i = 0; i < urls.size(); ++i) {
QByteArray ba = urls.at(i).trimmed();
if (!ba.isEmpty())
list.append(QUrl::fromEncoded(ba));
}
d->setData(mimeType, list);
} else {
d->setData(mimeType, QVariant(data));
}
} }
/*! /*!

View File

@ -483,6 +483,8 @@ function removeConflictingTransitions(enabledTransitions):
filteredTransitions.add(t1) filteredTransitions.add(t1)
return filteredTransitions return filteredTransitions
Note: the implementation below does not build the transitionsToRemove, but removes them in-place.
*/ */
void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions) void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions)
{ {
@ -492,24 +494,36 @@ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransitio
foreach (QAbstractTransition *t1, enabledTransitions) { foreach (QAbstractTransition *t1, enabledTransitions) {
bool t1Preempted = false; bool t1Preempted = false;
QVarLengthArray<QAbstractTransition *> transitionsToRemove;
QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t1); QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t1);
foreach (QAbstractTransition *t2, filteredTransitions) { QList<QAbstractTransition*>::iterator t2It = filteredTransitions.begin();
while (t2It != filteredTransitions.end()) {
QAbstractTransition *t2 = *t2It;
if (t1 == t2) {
// Special case: someone added the same transition object to a state twice. In this
// case, t2 (which is already in the list) "preempts" t1.
t1Preempted = true;
break;
}
QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t2); QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t2);
if (!exitSetT1.intersect(exitSetT2).isEmpty()) { if (exitSetT1.intersect(exitSetT2).isEmpty()) {
// No conflict, no cry. Next patient please.
++t2It;
} else {
// Houston, we have a conflict. Check which transition can be removed.
if (isDescendant(t1->sourceState(), t2->sourceState())) { if (isDescendant(t1->sourceState(), t2->sourceState())) {
transitionsToRemove.append(t2); // t1 preempts t2, so we can remove t2
t2It = filteredTransitions.erase(t2It);
} else { } else {
// t2 preempts t1, so there's no use in looking further and we don't need to add
// t1 to the list.
t1Preempted = true; t1Preempted = true;
break; break;
} }
} }
} }
if (!t1Preempted) { if (!t1Preempted)
foreach (QAbstractTransition *t3, transitionsToRemove)
filteredTransitions.removeAll(t3);
filteredTransitions.append(t1); filteredTransitions.append(t1);
}
} }
enabledTransitions = filteredTransitions; enabledTransitions = filteredTransitions;

View File

@ -2657,7 +2657,8 @@ static const char *pcreCompileErrorCodes[] =
QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested"), QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested"),
QT_TRANSLATE_NOOP("QRegularExpression", "invalid range in character class"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid range in character class"),
QT_TRANSLATE_NOOP("QRegularExpression", "group name must start with a non-digit"), QT_TRANSLATE_NOOP("QRegularExpression", "group name must start with a non-digit"),
QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested (stack check)") QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested (stack check)"),
QT_TRANSLATE_NOOP("QRegularExpression", "digits missing in \\x{} or \\o{}")
}; };
#endif // #if 0 #endif // #if 0

View File

@ -1091,6 +1091,15 @@ void QImage::detach()
} }
static void copyMetadata(QImageData *dst, const QImageData *src)
{
// Doesn't copy colortable and alpha_clut, or offset.
dst->dpmx = src->dpmx;
dst->dpmy = src->dpmy;
dst->devicePixelRatio = src->devicePixelRatio;
dst->text = src->text;
}
/*! /*!
\fn QImage QImage::copy(int x, int y, int width, int height) const \fn QImage QImage::copy(int x, int y, int width, int height) const
\overload \overload
@ -1140,12 +1149,9 @@ QImage QImage::copy(const QRect& r) const
} else } else
memcpy(image.bits(), bits(), d->nbytes); memcpy(image.bits(), bits(), d->nbytes);
image.d->colortable = d->colortable; image.d->colortable = d->colortable;
image.d->dpmx = d->dpmx;
image.d->dpmy = d->dpmy;
image.d->devicePixelRatio = d->devicePixelRatio;
image.d->offset = d->offset; image.d->offset = d->offset;
image.d->has_alpha_clut = d->has_alpha_clut; image.d->has_alpha_clut = d->has_alpha_clut;
image.d->text = d->text; copyMetadata(image.d, d);
return image; return image;
} }
@ -1231,12 +1237,9 @@ QImage QImage::copy(const QRect& r) const
} }
} }
image.d->dpmx = dotsPerMeterX(); copyMetadata(image.d, d);
image.d->dpmy = dotsPerMeterY();
image.d->devicePixelRatio = devicePixelRatio();
image.d->offset = offset(); image.d->offset = offset();
image.d->has_alpha_clut = d->has_alpha_clut; image.d->has_alpha_clut = d->has_alpha_clut;
image.d->text = d->text;
return image; return image;
} }
@ -1987,19 +1990,19 @@ QImage QImage::convertToFormat_helper(Format format, Qt::ImageConversionFlags fl
QIMAGE_SANITYCHECK_MEMORY(image); QIMAGE_SANITYCHECK_MEMORY(image);
image.setDotsPerMeterY(dotsPerMeterY()); image.d->offset = offset();
image.setDotsPerMeterX(dotsPerMeterX()); copyMetadata(image.d, d);
image.setDevicePixelRatio(devicePixelRatio());
image.d->text = d->text;
converter(image.d, d, flags); converter(image.d, d, flags);
return image; return image;
} }
// Convert indexed formats over ARGB32 to the final format. // Convert indexed formats over ARGB32 or RGB32 to the final format.
Q_ASSERT(format != QImage::Format_ARGB32); Q_ASSERT(format != QImage::Format_ARGB32 && format != QImage::Format_RGB32);
Q_ASSERT(d->format != QImage::Format_ARGB32); Q_ASSERT(d->format != QImage::Format_ARGB32 && d->format != QImage::Format_RGB32);
if (!hasAlphaChannel())
return convertToFormat(Format_RGB32, flags).convertToFormat(format, flags);
return convertToFormat(Format_ARGB32, flags).convertToFormat(format, flags); return convertToFormat(Format_ARGB32, flags).convertToFormat(format, flags);
} }
@ -2116,9 +2119,9 @@ QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Q
QImage image(d->width, d->height, format); QImage image(d->width, d->height, format);
QIMAGE_SANITYCHECK_MEMORY(image); QIMAGE_SANITYCHECK_MEMORY(image);
image.setDevicePixelRatio(devicePixelRatio());
image.d->text = d->text; image.d->offset = offset();
copyMetadata(image.d, d);
converter(image.d, d, flags); converter(image.d, d, flags);
return image; return image;
@ -3051,9 +3054,7 @@ QImage QImage::mirrored_helper(bool horizontal, bool vertical) const
result.d->colortable = d->colortable; result.d->colortable = d->colortable;
result.d->has_alpha_clut = d->has_alpha_clut; result.d->has_alpha_clut = d->has_alpha_clut;
result.d->devicePixelRatio = d->devicePixelRatio; copyMetadata(result.d, d);
result.d->dpmx = d->dpmx;
result.d->dpmy = d->dpmy;
do_mirror(result.d, d, horizontal, vertical); do_mirror(result.d, d, horizontal, vertical);
@ -3202,6 +3203,7 @@ QImage QImage::rgbSwapped_helper() const
rgbSwapped_generic(d->width, d->height, this, &res, &qPixelLayouts[d->format]); rgbSwapped_generic(d->width, d->height, this, &res, &qPixelLayouts[d->format]);
break; break;
} }
copyMetadata(res.d, d);
return res; return res;
} }
@ -4353,8 +4355,8 @@ int QImage::bitPlaneCount() const
return bpc; return bpc;
} }
static QImage smoothScaled(const QImage &source, int w, int h) { QImage QImage::smoothScaled(int w, int h) const {
QImage src = source; QImage src = *this;
switch (src.format()) { switch (src.format()) {
case QImage::Format_RGB32: case QImage::Format_RGB32:
case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32_Premultiplied:
@ -4369,11 +4371,11 @@ static QImage smoothScaled(const QImage &source, int w, int h) {
else else
src = src.convertToFormat(QImage::Format_RGB32); src = src.convertToFormat(QImage::Format_RGB32);
} }
src = qSmoothScaleImage(src, w, h);
return qSmoothScaleImage(src, w, h); copyMetadata(src.d, d);
return src;
} }
static QImage rotated90(const QImage &image) { static QImage rotated90(const QImage &image) {
QImage out(image.height(), image.width(), image.format()); QImage out(image.height(), image.width(), image.format());
if (image.colorCount() > 0) if (image.colorCount() > 0)
@ -4574,13 +4576,13 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
// Make use of the optimized algorithm when we're scaling // Make use of the optimized algorithm when we're scaling
if (scale_xform && mode == Qt::SmoothTransformation) { if (scale_xform && mode == Qt::SmoothTransformation) {
if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip
return smoothScaled(mirrored(true, true), wd, hd); return smoothScaled(wd, hd).mirrored(true, true);
} else if (mat.m11() < 0.0F) { // horizontal flip } else if (mat.m11() < 0.0F) { // horizontal flip
return smoothScaled(mirrored(true, false), wd, hd); return smoothScaled(wd, hd).mirrored(true, false);
} else if (mat.m22() < 0.0F) { // vertical flip } else if (mat.m22() < 0.0F) { // vertical flip
return smoothScaled(mirrored(false, true), wd, hd); return smoothScaled(wd, hd).mirrored(false, true);
} else { // no flipping } else { // no flipping
return smoothScaled(*this, wd, hd); return smoothScaled(wd, hd);
} }
} }
@ -4632,9 +4634,6 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
dImage.d->has_alpha_clut = d->has_alpha_clut | complex_xform; dImage.d->has_alpha_clut = d->has_alpha_clut | complex_xform;
} }
dImage.d->dpmx = dotsPerMeterX();
dImage.d->dpmy = dotsPerMeterY();
// initizialize the data // initizialize the data
if (d->format == QImage::Format_Indexed8) { if (d->format == QImage::Format_Indexed8) {
if (dImage.d->colortable.size() < 256) { if (dImage.d->colortable.size() < 256) {
@ -4672,8 +4671,8 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
int dbpl = dImage.bytesPerLine(); int dbpl = dImage.bytesPerLine();
qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs); qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs);
} }
copyMetadata(dImage.d, d);
dImage.d->devicePixelRatio = devicePixelRatio();
return dImage; return dImage;
} }
@ -4715,8 +4714,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla
if (ref.load() > 1 || ro_data) if (ref.load() > 1 || ro_data)
return false; return false;
const InPlace_Image_Converter *const converterPtr = &qimage_inplace_converter_map[format][newFormat]; InPlace_Image_Converter converter = qimage_inplace_converter_map[format][newFormat];
InPlace_Image_Converter converter = *converterPtr;
if (converter) if (converter)
return converter(this, flags); return converter(this, flags);
else if (format > QImage::Format_Indexed8 && newFormat > QImage::Format_Indexed8 && !qimage_converter_map[format][newFormat]) else if (format > QImage::Format_Indexed8 && newFormat > QImage::Format_Indexed8 && !qimage_converter_map[format][newFormat])

View File

@ -335,6 +335,7 @@ protected:
void rgbSwapped_inplace(); void rgbSwapped_inplace();
QImage convertToFormat_helper(Format format, Qt::ImageConversionFlags flags) const; QImage convertToFormat_helper(Format format, Qt::ImageConversionFlags flags) const;
bool convertToFormat_inplace(Format format, Qt::ImageConversionFlags flags); bool convertToFormat_inplace(Format format, Qt::ImageConversionFlags flags);
QImage smoothScaled(int w, int h) const;
private: private:
friend class QWSOnScreenSurface; friend class QWSOnScreenSurface;

View File

@ -425,25 +425,25 @@ static void convert_ARGB_to_RGBA(QImageData *dest, const QImageData *src, Qt::Im
} }
} }
template<QImage::Format DestFormat>
static bool convert_ARGB_to_RGBA_inplace(QImageData *data, Qt::ImageConversionFlags) static bool convert_ARGB_to_RGBA_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_ARGB32_Premultiplied); Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_ARGB32_Premultiplied);
const int pad = (data->bytes_per_line >> 2) - data->width; const int pad = (data->bytes_per_line >> 2) - data->width;
quint32 *rgb_data = (quint32 *) data->data; quint32 *rgb_data = (quint32 *) data->data;
Q_CONSTEXPR uint mask = (DestFormat == QImage::Format_RGBX8888) ? 0xff000000 : 0;
for (int i = 0; i < data->height; ++i) { for (int i = 0; i < data->height; ++i) {
const quint32 *end = rgb_data + data->width; const quint32 *end = rgb_data + data->width;
while (rgb_data < end) { while (rgb_data < end) {
*rgb_data = ARGB2RGBA(*rgb_data); *rgb_data = ARGB2RGBA(*rgb_data | mask);
++rgb_data; ++rgb_data;
} }
rgb_data += pad; rgb_data += pad;
} }
if (data->format == QImage::Format_ARGB32)
data->format = QImage::Format_RGBA8888; data->format = DestFormat;
else
data->format = QImage::Format_RGBA8888_Premultiplied;
return true; return true;
} }
@ -497,8 +497,7 @@ static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::Im
{ {
Q_ASSERT(src->format == QImage::Format_RGB32 || src->format == QImage::Format_ARGB32); Q_ASSERT(src->format == QImage::Format_RGB32 || src->format == QImage::Format_ARGB32);
Q_ASSERT(dest->format == QImage::Format_BGR30 || dest->format == QImage::Format_A2BGR30_Premultiplied Q_ASSERT(dest->format == QImage::Format_BGR30 || dest->format == QImage::Format_RGB30);
|| dest->format == QImage::Format_RGB30 || dest->format == QImage::Format_A2RGB30_Premultiplied);
Q_ASSERT(src->width == dest->width); Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height); Q_ASSERT(src->height == dest->height);
@ -520,28 +519,24 @@ static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::Im
} }
template<QtPixelOrder PixelOrder> template<QtPixelOrder PixelOrder>
static void convert_RGB30_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) static bool convert_RGB_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(src->format == QImage::Format_BGR30 || src->format == QImage::Format_RGB30); Q_ASSERT(data->format == QImage::Format_RGB32 || data->format == QImage::Format_ARGB32);
Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied);
Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height);
const int src_pad = (src->bytes_per_line >> 2) - src->width; const int pad = (data->bytes_per_line >> 2) - data->width;
const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; QRgb *rgb_data = (QRgb *) data->data;
const quint32 *src_data = (quint32 *) src->data;
quint32 *dest_data = (quint32 *) dest->data;
for (int i = 0; i < src->height; ++i) { for (int i = 0; i < data->height; ++i) {
const quint32 *end = src_data + src->width; const QRgb *end = rgb_data + data->width;
while (src_data < end) { while (rgb_data < end) {
*dest_data = qConvertA2rgb30ToArgb32<PixelOrder>(*src_data); *rgb_data = qConvertRgb32ToRgb30<PixelOrder>(*rgb_data);
++src_data; ++rgb_data;
++dest_data;
} }
src_data += src_pad; rgb_data += pad;
dest_data += dest_pad;
} }
data->format = (PixelOrder == PixelOrderRGB) ? QImage::Format_RGB30 : QImage::Format_BGR30;
return true;
} }
static inline uint qUnpremultiplyRgb30(uint rgb30) static inline uint qUnpremultiplyRgb30(uint rgb30)
@ -557,7 +552,7 @@ static inline uint qUnpremultiplyRgb30(uint rgb30)
} }
case 2: { case 2: {
uint rgb = rgb30 & 0x3fffffff; uint rgb = rgb30 & 0x3fffffff;
rgb += rgb >> 1; rgb += (rgb >> 1) & 0x5ff7fdff;
return (a << 30) | rgb; return (a << 30) | rgb;
} }
case 3: case 3:
@ -567,6 +562,7 @@ static inline uint qUnpremultiplyRgb30(uint rgb30)
return 0; return 0;
} }
template<bool rgbswap>
static void convert_A2RGB30_PM_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) static void convert_A2RGB30_PM_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{ {
Q_ASSERT(src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied); Q_ASSERT(src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied);
@ -582,7 +578,8 @@ static void convert_A2RGB30_PM_to_RGB30(QImageData *dest, const QImageData *src,
for (int i = 0; i < src->height; ++i) { for (int i = 0; i < src->height; ++i) {
const quint32 *end = src_data + src->width; const quint32 *end = src_data + src->width;
while (src_data < end) { while (src_data < end) {
*dest_data = 0xc0000000 | qUnpremultiplyRgb30(*src_data); const uint p = 0xc0000000 | qUnpremultiplyRgb30(*src_data);
*dest_data = (rgbswap) ? qRgbSwapRgb30(p) : p;
++src_data; ++src_data;
++dest_data; ++dest_data;
} }
@ -591,6 +588,7 @@ static void convert_A2RGB30_PM_to_RGB30(QImageData *dest, const QImageData *src,
} }
} }
template<bool rgbswap>
static bool convert_A2RGB30_PM_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags) static bool convert_A2RGB30_PM_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied); Q_ASSERT(data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied);
@ -601,16 +599,17 @@ static bool convert_A2RGB30_PM_to_RGB30_inplace(QImageData *data, Qt::ImageConve
for (int i = 0; i < data->height; ++i) { for (int i = 0; i < data->height; ++i) {
const uint *end = rgb_data + data->width; const uint *end = rgb_data + data->width;
while (rgb_data < end) { while (rgb_data < end) {
*rgb_data = 0xc0000000 | qUnpremultiplyRgb30(*rgb_data); const uint p = 0xc0000000 | qUnpremultiplyRgb30(*rgb_data);
*rgb_data = (rgbswap) ? qRgbSwapRgb30(p) : p;
++rgb_data; ++rgb_data;
} }
rgb_data += pad; rgb_data += pad;
} }
if (data->format == QImage::Format_A2RGB30_Premultiplied) if (data->format == QImage::Format_A2RGB30_Premultiplied)
data->format = QImage::Format_RGB30; data->format = (rgbswap) ? QImage::Format_BGR30 : QImage::Format_RGB30;
else else
data->format = QImage::Format_BGR30; data->format = (rgbswap) ? QImage::Format_RGB30 : QImage::Format_BGR30;
return true; return true;
} }
@ -678,6 +677,64 @@ static bool convert_BGR30_to_RGB30_inplace(QImageData *data, Qt::ImageConversion
return true; return true;
} }
static bool convert_BGR30_to_A2RGB30_inplace(QImageData *data, Qt::ImageConversionFlags flags)
{
Q_ASSERT(data->format == QImage::Format_RGB30 || data->format == QImage::Format_BGR30);
if (!convert_BGR30_to_RGB30_inplace(data, flags))
return false;
if (data->format == QImage::Format_RGB30)
data->format = QImage::Format_A2RGB30_Premultiplied;
else
data->format = QImage::Format_A2BGR30_Premultiplied;
return true;
}
template<QtPixelOrder PixelOrder>
static void convert_A2RGB30_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
Q_ASSERT(src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied);
Q_ASSERT(dest->format == QImage::Format_ARGB32);
Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height);
const int src_pad = (src->bytes_per_line >> 2) - src->width;
const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
const quint32 *src_data = (quint32 *) src->data;
quint32 *dest_data = (quint32 *) dest->data;
for (int i = 0; i < src->height; ++i) {
const quint32 *end = src_data + src->width;
while (src_data < end) {
*dest_data = qConvertA2rgb30ToArgb32<PixelOrder>(qUnpremultiplyRgb30(*src_data));
++src_data;
++dest_data;
}
src_data += src_pad;
dest_data += dest_pad;
}
}
template<QtPixelOrder PixelOrder>
static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied);
const int pad = (data->bytes_per_line >> 2) - data->width;
uint *rgb_data = (uint *) data->data;
for (int i = 0; i < data->height; ++i) {
const uint *end = rgb_data + data->width;
while (rgb_data < end) {
*rgb_data = qConvertA2rgb30ToArgb32<PixelOrder>(qUnpremultiplyRgb30(*rgb_data));
++rgb_data;
}
rgb_data += pad;
}
data->format = QImage::Format_ARGB32;
return true;
}
static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(data->format == QImage::Format_Indexed8); Q_ASSERT(data->format == QImage::Format_Indexed8);
@ -732,7 +789,7 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve
return true; return true;
} }
static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags) static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(data->format == QImage::Format_Indexed8); Q_ASSERT(data->format == QImage::Format_Indexed8);
if (!data->own_data) if (!data->own_data)
@ -775,7 +832,7 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio
} }
data->colortable = QVector<QRgb>(); data->colortable = QVector<QRgb>();
data->format = QImage::Format_RGB32; data->format = QImage::Format_ARGB32;
data->bytes_per_line = dst_bytes_per_line; data->bytes_per_line = dst_bytes_per_line;
data->depth = depth; data->depth = depth;
data->nbytes = nbytes; data->nbytes = nbytes;
@ -783,6 +840,24 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio
return true; return true;
} }
static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags)
{
Q_ASSERT(data->format == QImage::Format_Indexed8);
if (!data->own_data)
return false;
if (data->has_alpha_clut) {
for (int i = 0; i < data->colortable.size(); ++i)
data->colortable[i] |= 0xff000000;
}
if (!convert_indexed8_to_ARGB_inplace(data, flags))
return false;
data->format = QImage::Format_RGB32;
return true;
}
static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(data->format == QImage::Format_Indexed8); Q_ASSERT(data->format == QImage::Format_Indexed8);
@ -965,8 +1040,9 @@ static void mask_alpha_converter(QImageData *dest, const QImageData *src, Qt::Im
template<QImage::Format DestFormat> template<QImage::Format DestFormat>
static bool mask_alpha_converter_inplace(QImageData *data, Qt::ImageConversionFlags) static bool mask_alpha_converter_inplace(QImageData *data, Qt::ImageConversionFlags)
{ {
Q_ASSERT(data->format == QImage::Format_RGB32 || DestFormat == QImage::Format_RGB32); Q_ASSERT(data->format == QImage::Format_RGB32
|| DestFormat == QImage::Format_RGB32
|| DestFormat == QImage::Format_RGBX8888);
const int pad = (data->bytes_per_line >> 2) - data->width; const int pad = (data->bytes_per_line >> 2) - data->width;
QRgb *rgb_data = (QRgb *) data->data; QRgb *rgb_data = (QRgb *) data->data;
@ -1009,6 +1085,29 @@ static void mask_alpha_converter_RGBx(QImageData *dest, const QImageData *src, Q
#endif #endif
} }
static bool mask_alpha_converter_rgbx_inplace(QImageData *data, Qt::ImageConversionFlags flags)
{
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
return mask_alpha_converter_inplace<QImage::Format_RGBX8888>(data, flags);
#else
Q_UNUSED(flags);
const int pad = (data->bytes_per_line >> 2) - data->width;
QRgb *rgb_data = (QRgb *) data->data;
for (int i = 0; i < data->height; ++i) {
const QRgb *end = rgb_data + data->width;
while (rgb_data < end) {
*rgb_data = *rgb_data | 0x000000fff;
++rgb_data;
}
rgb_data += pad;
}
data->format = DestFormat;
return true;
#endif
}
static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format) static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format)
{ {
QVector<QRgb> colorTable = ctbl; QVector<QRgb> colorTable = ctbl;
@ -1948,9 +2047,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
convert_RGB_to_RGB30<PixelOrderBGR>, convert_RGB_to_RGB30<PixelOrderBGR>,
convert_RGB_to_RGB30<PixelOrderBGR>, 0,
convert_RGB_to_RGB30<PixelOrderRGB>,
convert_RGB_to_RGB30<PixelOrderRGB>, convert_RGB_to_RGB30<PixelOrderRGB>,
0,
0, 0 0, 0
}, // Format_RGB32 }, // Format_RGB32
@ -2282,9 +2381,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
0, 0,
convert_RGB30_to_RGB<PixelOrderBGR>, 0,
convert_RGB30_to_RGB<PixelOrderBGR>, 0,
convert_RGB30_to_RGB<PixelOrderBGR>, 0,
0, 0,
0, 0,
0, 0,
@ -2309,6 +2408,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
0, 0,
convert_A2RGB30_PM_to_ARGB<PixelOrderBGR>,
0, 0,
0, 0,
0, 0,
@ -2322,10 +2422,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
0, 0,
convert_A2RGB30_PM_to_RGB30<false>,
0, 0,
convert_A2RGB30_PM_to_RGB30, convert_A2RGB30_PM_to_RGB30<true>,
0,
0,
convert_BGR30_to_RGB30, convert_BGR30_to_RGB30,
0, 0 0, 0
}, // Format_BGR30A2_Premultiplied }, // Format_BGR30A2_Premultiplied
@ -2334,9 +2433,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
0, 0,
convert_RGB30_to_RGB<PixelOrderRGB>, 0,
convert_RGB30_to_RGB<PixelOrderRGB>, 0,
convert_RGB30_to_RGB<PixelOrderRGB>, 0,
0,
0, 0,
0, 0,
0, 0,
@ -2351,7 +2451,6 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_BGR30_to_RGB30, convert_BGR30_to_RGB30,
convert_BGR30_to_RGB30, convert_BGR30_to_RGB30,
0, 0,
0,
convert_passthrough, convert_passthrough,
0, 0 0, 0
}, // Format_RGB30 }, // Format_RGB30
@ -2361,6 +2460,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
0, 0,
convert_A2RGB30_PM_to_ARGB<PixelOrderRGB>,
0, 0,
0, 0,
0, 0,
@ -2374,13 +2474,11 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0, 0,
0, 0,
0, 0,
0, convert_A2RGB30_PM_to_RGB30<true>,
0,
convert_BGR30_to_RGB30, convert_BGR30_to_RGB30,
convert_A2RGB30_PM_to_RGB30, convert_A2RGB30_PM_to_RGB30<false>,
0,
0,
0, 0,
0, 0
}, // Format_RGB30A2_Premultiplied }, // Format_RGB30A2_Premultiplied
{ {
0, 0,
@ -2440,8 +2538,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
0,
convert_indexed8_to_RGB_inplace, convert_indexed8_to_RGB_inplace,
convert_indexed8_to_ARGB_inplace,
convert_indexed8_to_ARGB_PM_inplace, convert_indexed8_to_ARGB_PM_inplace,
convert_indexed8_to_RGB16_inplace, convert_indexed8_to_RGB16_inplace,
0, 0,
@ -2478,7 +2576,11 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
0, 0, 0, 0, 0, 0 convert_RGB_to_RGB30_inplace<PixelOrderBGR>,
0,
convert_RGB_to_RGB30_inplace<PixelOrderRGB>,
0,
0, 0
}, // Format_RGB32 }, // Format_RGB32
{ {
0, 0,
@ -2501,10 +2603,14 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
convert_ARGB_to_RGBA_inplace<QImage::Format_RGBX8888>,
convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888>,
0, 0,
convert_ARGB_to_RGBA_inplace, convert_RGB_to_RGB30_inplace<PixelOrderBGR>,
0, 0,
0, 0, 0, 0, 0, 0 convert_RGB_to_RGB30_inplace<PixelOrderRGB>,
0,
0, 0
}, // Format_ARGB32 }, // Format_ARGB32
{ {
0, 0,
@ -2525,8 +2631,12 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
convert_ARGB_to_RGBA_inplace, convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888_Premultiplied>,
0, 0, 0, 0, 0, 0 0,
0,
0,
0,
0, 0
}, // Format_ARGB32_Premultiplied }, // Format_ARGB32_Premultiplied
{ {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ -2594,7 +2704,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
0, mask_alpha_converter_rgbx_inplace,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN && __SSE2__ #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN && __SSE2__
0, 0,
convert_ARGB_to_ARGB_PM_inplace_sse2, convert_ARGB_to_ARGB_PM_inplace_sse2,
@ -2646,10 +2756,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
0, 0, // self
convert_passthrough_inplace<QImage::Format_A2BGR30_Premultiplied>, convert_passthrough_inplace<QImage::Format_A2BGR30_Premultiplied>,
convert_BGR30_to_RGB30_inplace, convert_BGR30_to_RGB30_inplace,
convert_BGR30_to_RGB30_inplace, convert_BGR30_to_A2RGB30_inplace,
0, 0 0, 0
}, // Format_BGR30 }, // Format_BGR30
{ {
@ -2658,6 +2768,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderBGR>,
0, 0,
0, 0,
0, 0,
@ -2671,10 +2782,9 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
0, convert_A2RGB30_PM_to_RGB30_inplace<false>,
convert_A2RGB30_PM_to_RGB30_inplace, 0, // self
0, convert_A2RGB30_PM_to_RGB30_inplace<true>,
0,
convert_BGR30_to_RGB30_inplace, convert_BGR30_to_RGB30_inplace,
0, 0 0, 0
}, // Format_BGR30A2_Premultiplied }, // Format_BGR30A2_Premultiplied
@ -2699,8 +2809,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
convert_BGR30_to_RGB30_inplace, convert_BGR30_to_RGB30_inplace,
convert_BGR30_to_RGB30_inplace, convert_BGR30_to_A2RGB30_inplace,
0, 0, // self
convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>, convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>,
0, 0 0, 0
}, // Format_RGB30 }, // Format_RGB30
@ -2710,6 +2820,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderRGB>,
0, 0,
0, 0,
0, 0,
@ -2723,11 +2834,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0, 0,
0, 0,
0, 0,
0, convert_A2RGB30_PM_to_RGB30_inplace<true>,
0,
convert_BGR30_to_RGB30_inplace, convert_BGR30_to_RGB30_inplace,
convert_A2RGB30_PM_to_RGB30_inplace, convert_A2RGB30_PM_to_RGB30_inplace<false>,
0, 0, // self
0, 0 0, 0
}, // Format_RGB30A2_Premultiplied }, // Format_RGB30A2_Premultiplied
{ {

View File

@ -221,7 +221,7 @@ typedef unsigned long long int uint64_t;
typedef long int int32_t; typedef long int int32_t;
typedef long long int int64_t; typedef long long int int64_t;
typedef unsigned long long int uint64_t; typedef unsigned long long int uint64_t;
#elif defined(_WIN32) && defined(__GNUC__) #elif defined(_WIN32) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600))
#include <stdint.h> #include <stdint.h>
#elif defined(_WIN32) #elif defined(_WIN32)
typedef __int32 int32_t; typedef __int32 int32_t;

View File

@ -1399,7 +1399,7 @@ typedef unsigned long long int uint64_t;
typedef long int int32_t; typedef long int int32_t;
typedef long long int int64_t; typedef long long int int64_t;
typedef unsigned long long int uint64_t; typedef unsigned long long int uint64_t;
#elif defined(_WIN32) && defined(__GNUC__) #elif defined(_WIN32) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600))
#include <stdint.h> #include <stdint.h>
#elif defined(_WIN32) #elif defined(_WIN32)
typedef __int32 int32_t; typedef __int32 int32_t;

View File

@ -1724,10 +1724,8 @@ bool QFont::rawMode() const
*/ */
QFont QFont::resolve(const QFont &other) const QFont QFont::resolve(const QFont &other) const
{ {
if (*this == other if (resolve_mask == 0 || (resolve_mask == other.resolve_mask && *this == other)) {
&& (resolve_mask == other.resolve_mask || resolve_mask == 0) QFont o(other);
&& d->dpi == other.d->dpi) {
QFont o = other;
o.resolve_mask = resolve_mask; o.resolve_mask = resolve_mask;
return o; return o;
} }

View File

@ -172,16 +172,6 @@ static int getFontWeight(const QString &weightString)
return QFont::Normal; return QFont::Normal;
} }
struct QtFontEncoding
{
signed int encoding : 16;
uint xpoint : 16;
uint xres : 8;
uint yres : 8;
uint avgwidth : 16;
uchar pitch : 8;
};
struct QtFontSize struct QtFontSize
{ {
@ -617,19 +607,13 @@ static void parseFontName(const QString &name, QString &foundry, QString &family
struct QtFontDesc struct QtFontDesc
{ {
inline QtFontDesc() : family(0), foundry(0), style(0), size(0), encoding(0), familyIndex(-1) {} inline QtFontDesc() : family(0), foundry(0), style(0), size(0) {}
QtFontFamily *family; QtFontFamily *family;
QtFontFoundry *foundry; QtFontFoundry *foundry;
QtFontStyle *style; QtFontStyle *style;
QtFontSize *size; QtFontSize *size;
QtFontEncoding *encoding;
int familyIndex;
}; };
static int match(int script, const QFontDef &request,
const QString &family_name, const QString &foundry_name, int force_encoding_id,
QtFontDesc *desc, const QList<int> &blacklisted);
static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi) static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi)
{ {
fontDef->family = desc.family->name; fontDef->family = desc.family->name;
@ -981,16 +965,14 @@ static
unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
const QtFontFamily *family, const QString &foundry_name, const QtFontFamily *family, const QString &foundry_name,
QtFontStyle::Key styleKey, int pixelSize, char pitch, QtFontStyle::Key styleKey, int pixelSize, char pitch,
QtFontDesc *desc, int force_encoding_id, const QString &styleName = QString()) QtFontDesc *desc, const QString &styleName = QString())
{ {
Q_UNUSED(force_encoding_id);
Q_UNUSED(script); Q_UNUSED(script);
Q_UNUSED(pitch); Q_UNUSED(pitch);
desc->foundry = 0; desc->foundry = 0;
desc->style = 0; desc->style = 0;
desc->size = 0; desc->size = 0;
desc->encoding = 0;
FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count); FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
@ -1084,8 +1066,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
enum { enum {
PitchMismatch = 0x4000, PitchMismatch = 0x4000,
StyleMismatch = 0x2000, StyleMismatch = 0x2000,
BitmapScaledPenalty = 0x1000, BitmapScaledPenalty = 0x1000
EncodingMismatch = 0x0002
}; };
if (pitch != '*') { if (pitch != '*') {
if ((pitch == 'm' && !family->fixedPitch) if ((pitch == 'm' && !family->fixedPitch)
@ -1128,10 +1109,9 @@ static bool matchFamilyName(const QString &familyName, QtFontFamily *f)
Tries to find the best match for a given request and family/foundry Tries to find the best match for a given request and family/foundry
*/ */
static int match(int script, const QFontDef &request, static int match(int script, const QFontDef &request,
const QString &family_name, const QString &foundry_name, int force_encoding_id, const QString &family_name, const QString &foundry_name,
QtFontDesc *desc, const QList<int> &blacklistedFamilies) QtFontDesc *desc, const QList<int> &blacklistedFamilies)
{ {
Q_UNUSED(force_encoding_id);
int result = -1; int result = -1;
QtFontStyle::Key styleKey; QtFontStyle::Key styleKey;
@ -1156,8 +1136,6 @@ static int match(int script, const QFontDef &request,
desc->foundry = 0; desc->foundry = 0;
desc->style = 0; desc->style = 0;
desc->size = 0; desc->size = 0;
desc->encoding = 0;
desc->familyIndex = -1;
unsigned int score = ~0u; unsigned int score = ~0u;
@ -1174,16 +1152,12 @@ static int match(int script, const QFontDef &request,
continue; continue;
QtFontDesc test; QtFontDesc test;
test.family = db->families[x]; test.family = db->families[x];
test.familyIndex = x;
if (!matchFamilyName(family_name, test.family)) if (!matchFamilyName(family_name, test.family))
continue; continue;
test.family->ensurePopulated(); test.family->ensurePopulated();
if (family_name.isEmpty())
load(test.family->name, script);
// Check if family is supported in the script we want // Check if family is supported in the script we want
if (writingSystem != QFontDatabase::Any && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported)) if (writingSystem != QFontDatabase::Any && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported))
continue; continue;
@ -1193,13 +1167,13 @@ static int match(int script, const QFontDef &request,
unsigned int newscore = unsigned int newscore =
bestFoundry(script, score, request.styleStrategy, bestFoundry(script, score, request.styleStrategy,
test.family, foundry_name, styleKey, request.pixelSize, pitch, test.family, foundry_name, styleKey, request.pixelSize, pitch,
&test, force_encoding_id, request.styleName); &test, request.styleName);
if (test.foundry == 0 && !foundry_name.isEmpty()) { if (test.foundry == 0 && !foundry_name.isEmpty()) {
// the specific foundry was not found, so look for // the specific foundry was not found, so look for
// any foundry matching our requirements // any foundry matching our requirements
newscore = bestFoundry(script, score, request.styleStrategy, test.family, newscore = bestFoundry(script, score, request.styleStrategy, test.family,
QString(), styleKey, request.pixelSize, QString(), styleKey, request.pixelSize,
pitch, &test, force_encoding_id, request.styleName); pitch, &test, request.styleName);
} }
if (newscore < score) { if (newscore < score) {
@ -2537,8 +2511,6 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
{ {
QMutexLocker locker(fontDatabaseMutex()); QMutexLocker locker(fontDatabaseMutex());
const int force_encoding_id = -1;
if (!privateDb()->count) if (!privateDb()->count)
initializeDb(); initializeDb();
@ -2561,7 +2533,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
QtFontDesc desc; QtFontDesc desc;
QList<int> blackListed; QList<int> blackListed;
int index = match(script, request, family_name, foundry_name, force_encoding_id, &desc, blackListed); int index = match(script, request, family_name, foundry_name, &desc, blackListed);
if (index >= 0) { if (index >= 0) {
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size); engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
if (!engine) if (!engine)
@ -2604,7 +2576,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
if (!engine) { if (!engine) {
QtFontDesc desc; QtFontDesc desc;
do { do {
index = match(script, def, def.family, QLatin1String(""), 0, &desc, blackListed); index = match(script, def, def.family, QLatin1String(""), &desc, blackListed);
if (index >= 0) { if (index >= 0) {
QFontDef loadDef = def; QFontDef loadDef = def;
if (loadDef.family.isEmpty()) if (loadDef.family.isEmpty())

View File

@ -611,7 +611,7 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
hasScript = true; hasScript = true;
//qDebug("font %s supports Korean", familyName.latin1()); //qDebug("font %s supports Korean", familyName.latin1());
} }
if (codePageRange[0] & (1 << SymbolCsbBit)) { if (codePageRange[0] & (1U << SymbolCsbBit)) {
writingSystems = QSupportedWritingSystems(); writingSystems = QSupportedWritingSystems();
hasScript = false; hasScript = false;
} }

View File

@ -71,22 +71,23 @@ static const char formatTextHtmlC[] = "text/html";
QDebug operator<<(QDebug d, const QMimeData &m) QDebug operator<<(QDebug d, const QMimeData &m)
{ {
QDebug nospace = d.nospace(); QDebugStateSaver saver(d);
d.nospace();
const QStringList formats = m.formats(); const QStringList formats = m.formats();
nospace << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n' d << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n'
<< " Text=" << m.hasText() << " HTML=" << m.hasHtml() << " Text=" << m.hasText() << " HTML=" << m.hasHtml()
<< " Color=" << m.hasColor() << " Image=" << m.hasImage() << " Color=" << m.hasColor() << " Image=" << m.hasImage()
<< " URLs=" << m.hasUrls() << '\n'; << " URLs=" << m.hasUrls() << '\n';
if (m.hasText()) if (m.hasText())
nospace << " Text: '" << m.text() << "'\n"; d << " Text: '" << m.text() << "'\n";
if (m.hasHtml()) if (m.hasHtml())
nospace << " HTML: '" << m.html() << "'\n"; d << " HTML: '" << m.html() << "'\n";
if (m.hasColor()) if (m.hasColor())
nospace << " Color: " << qvariant_cast<QColor>(m.colorData()) << '\n'; d << " Color: " << qvariant_cast<QColor>(m.colorData()) << '\n';
if (m.hasImage()) if (m.hasImage())
nospace << " Image: " << qvariant_cast<QImage>(m.imageData()).size() << '\n'; d << " Image: " << qvariant_cast<QImage>(m.imageData()).size() << '\n';
if (m.hasUrls()) if (m.hasUrls())
nospace << " URLs: " << m.urls() << '\n'; d << " URLs: " << m.urls() << '\n';
return d; return d;
} }

View File

@ -566,8 +566,8 @@ QString QWindowsContext::registerWindowClass(QString cname,
d->m_registeredWindowClassNames.insert(cname); d->m_registeredWindowClassNames.insert(cname);
qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << cname qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << cname
<< " style=0x" << QString::number(style, 16) << " style=0x" << hex << style << dec
<< " brush=" << brush << " icon=" << icon << " atom=" << atom; << " brush=" << brush << " icon=" << icon << " atom=" << atom;
return cname; return cname;
} }

View File

@ -379,7 +379,12 @@ static inline QString guidToString(const GUID &g)
} }
inline QDebug operator<<(QDebug d, const GUID &g) inline QDebug operator<<(QDebug d, const GUID &g)
{ d.nospace() << guidToString(g); return d; } {
QDebugStateSaver saver(d);
d.nospace();
d << guidToString(g);
return d;
}
// Return an allocated wchar_t array from a QString, reserve more memory if desired. // Return an allocated wchar_t array from a QString, reserve more memory if desired.
static wchar_t *qStringToWCharArray(const QString &s, size_t reserveSize = 0) static wchar_t *qStringToWCharArray(const QString &s, size_t reserveSize = 0)

View File

@ -608,11 +608,13 @@ static inline bool initDirectWrite(QWindowsFontEngineData *d)
QDebug operator<<(QDebug d, const QFontDef &def) QDebug operator<<(QDebug d, const QFontDef &def)
{ {
d.nospace() << "Family=" << def.family << " Stylename=" << def.styleName QDebugStateSaver saver(d);
<< " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize d.nospace();
<< " styleHint=" << def.styleHint << " weight=" << def.weight d << "Family=" << def.family << " Stylename=" << def.styleName
<< " stretch=" << def.stretch << " hintingPreference=" << " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize
<< def.hintingPreference << ' '; << " styleHint=" << def.styleHint << " weight=" << def.weight
<< " stretch=" << def.stretch << " hintingPreference="
<< def.hintingPreference;
return d; return d;
} }

View File

@ -286,40 +286,41 @@ static inline void initPixelFormatDescriptor(PIXELFORMATDESCRIPTOR *d)
QDebug operator<<(QDebug d, const PIXELFORMATDESCRIPTOR &pd) QDebug operator<<(QDebug d, const PIXELFORMATDESCRIPTOR &pd)
{ {
QDebug nsp = d.nospace(); QDebugStateSaver saver(d);
nsp << "PIXELFORMATDESCRIPTOR " d.nospace();
d << "PIXELFORMATDESCRIPTOR "
<< "dwFlags=" << hex << showbase << pd.dwFlags << dec << noshowbase; << "dwFlags=" << hex << showbase << pd.dwFlags << dec << noshowbase;
if (pd.dwFlags & PFD_DRAW_TO_WINDOW) nsp << " PFD_DRAW_TO_WINDOW"; if (pd.dwFlags & PFD_DRAW_TO_WINDOW) d << " PFD_DRAW_TO_WINDOW";
if (pd.dwFlags & PFD_DRAW_TO_BITMAP) nsp << " PFD_DRAW_TO_BITMAP"; if (pd.dwFlags & PFD_DRAW_TO_BITMAP) d << " PFD_DRAW_TO_BITMAP";
if (pd.dwFlags & PFD_SUPPORT_GDI) nsp << " PFD_SUPPORT_GDI"; if (pd.dwFlags & PFD_SUPPORT_GDI) d << " PFD_SUPPORT_GDI";
if (pd.dwFlags & PFD_SUPPORT_OPENGL) nsp << " PFD_SUPPORT_OPENGL"; if (pd.dwFlags & PFD_SUPPORT_OPENGL) d << " PFD_SUPPORT_OPENGL";
if (pd.dwFlags & PFD_GENERIC_ACCELERATED) nsp << " PFD_GENERIC_ACCELERATED"; if (pd.dwFlags & PFD_GENERIC_ACCELERATED) d << " PFD_GENERIC_ACCELERATED";
if (pd.dwFlags & PFD_SUPPORT_DIRECTDRAW) nsp << " PFD_SUPPORT_DIRECTDRAW"; if (pd.dwFlags & PFD_SUPPORT_DIRECTDRAW) d << " PFD_SUPPORT_DIRECTDRAW";
if (pd.dwFlags & PFD_DIRECT3D_ACCELERATED) nsp << " PFD_DIRECT3D_ACCELERATED"; if (pd.dwFlags & PFD_DIRECT3D_ACCELERATED) d << " PFD_DIRECT3D_ACCELERATED";
if (pd.dwFlags & PFD_SUPPORT_COMPOSITION) nsp << " PFD_SUPPORT_COMPOSITION"; if (pd.dwFlags & PFD_SUPPORT_COMPOSITION) d << " PFD_SUPPORT_COMPOSITION";
if (pd.dwFlags & PFD_GENERIC_FORMAT) nsp << " PFD_GENERIC_FORMAT"; if (pd.dwFlags & PFD_GENERIC_FORMAT) d << " PFD_GENERIC_FORMAT";
if (pd.dwFlags & PFD_NEED_PALETTE) nsp << " PFD_NEED_PALETTE"; if (pd.dwFlags & PFD_NEED_PALETTE) d << " PFD_NEED_PALETTE";
if (pd.dwFlags & PFD_NEED_SYSTEM_PALETTE) nsp << " PFD_NEED_SYSTEM_PALETTE"; if (pd.dwFlags & PFD_NEED_SYSTEM_PALETTE) d << " PFD_NEED_SYSTEM_PALETTE";
if (pd.dwFlags & PFD_DOUBLEBUFFER) nsp << " PFD_DOUBLEBUFFER"; if (pd.dwFlags & PFD_DOUBLEBUFFER) d << " PFD_DOUBLEBUFFER";
if (pd.dwFlags & PFD_STEREO) nsp << " PFD_STEREO"; if (pd.dwFlags & PFD_STEREO) d << " PFD_STEREO";
if (pd.dwFlags & PFD_SWAP_LAYER_BUFFERS) nsp << " PFD_SWAP_LAYER_BUFFERS"; if (pd.dwFlags & PFD_SWAP_LAYER_BUFFERS) d << " PFD_SWAP_LAYER_BUFFERS";
if (hasGLOverlay(pd)) nsp << " overlay"; if (hasGLOverlay(pd)) d << " overlay";
nsp << " iPixelType=" << pd.iPixelType << " cColorBits=" << pd.cColorBits d << " iPixelType=" << pd.iPixelType << " cColorBits=" << pd.cColorBits
<< " cRedBits=" << pd.cRedBits << " cRedShift=" << pd.cRedShift << " cRedBits=" << pd.cRedBits << " cRedShift=" << pd.cRedShift
<< " cGreenBits=" << pd.cGreenBits << " cGreenShift=" << pd.cGreenShift << " cGreenBits=" << pd.cGreenBits << " cGreenShift=" << pd.cGreenShift
<< " cBlueBits=" << pd.cBlueBits << " cBlueShift=" << pd.cBlueShift; << " cBlueBits=" << pd.cBlueBits << " cBlueShift=" << pd.cBlueShift;
nsp << " cDepthBits=" << pd.cDepthBits; d << " cDepthBits=" << pd.cDepthBits;
if (pd.cStencilBits) if (pd.cStencilBits)
nsp << " cStencilBits=" << pd.cStencilBits; d << " cStencilBits=" << pd.cStencilBits;
if (pd.cAuxBuffers) if (pd.cAuxBuffers)
nsp << " cAuxBuffers=" << pd.cAuxBuffers; d << " cAuxBuffers=" << pd.cAuxBuffers;
nsp << " iLayerType=" << pd.iLayerType; d << " iLayerType=" << pd.iLayerType;
if (pd.dwVisibleMask) if (pd.dwVisibleMask)
nsp << " dwVisibleMask=" << pd.dwVisibleMask; d << " dwVisibleMask=" << pd.dwVisibleMask;
if (pd.cAlphaBits) if (pd.cAlphaBits)
nsp << " cAlphaBits=" << pd.cAlphaBits << " cAlphaShift=" << pd.cAlphaShift; d << " cAlphaBits=" << pd.cAlphaBits << " cAlphaShift=" << pd.cAlphaShift;
if (pd.cAccumBits) if (pd.cAccumBits)
nsp << " cAccumBits=" << pd.cAccumBits << " cAccumRedBits=" << pd.cAccumRedBits d << " cAccumBits=" << pd.cAccumBits << " cAccumRedBits=" << pd.cAccumRedBits
<< " cAccumGreenBits=" << pd.cAccumGreenBits << " cAccumBlueBits=" << pd.cAccumBlueBits << " cAccumGreenBits=" << pd.cAccumGreenBits << " cAccumBlueBits=" << pd.cAccumBlueBits
<< " cAccumAlphaBits=" << pd.cAccumAlphaBits; << " cAccumAlphaBits=" << pd.cAccumAlphaBits;
return d; return d;
@ -906,9 +907,10 @@ void QWindowsOpenGLContextFormat::apply(QSurfaceFormat *format) const
QDebug operator<<(QDebug d, const QWindowsOpenGLContextFormat &f) QDebug operator<<(QDebug d, const QWindowsOpenGLContextFormat &f)
{ {
d.nospace() << "ContextFormat: v" << (f.version >> 8) << '.' QDebugStateSaver saver(d);
<< (f.version & 0xFF) << " profile: " << f.profile d.nospace();
<< " options: " << f.options; d << "ContextFormat: v" << (f.version >> 8) << '.' << (f.version & 0xFF)
<< " profile: " << f.profile << " options: " << f.options;
return d; return d;
} }
@ -1018,16 +1020,17 @@ QOpenGLStaticContext *QOpenGLStaticContext::create(bool softwareRendering)
QDebug operator<<(QDebug d, const QOpenGLStaticContext &s) QDebug operator<<(QDebug d, const QOpenGLStaticContext &s)
{ {
QDebug nsp = d.nospace(); QDebugStateSaver saver(d);
nsp << "OpenGL: " << s.vendor << ',' << s.renderer << " default " d.nospace();
d << "OpenGL: " << s.vendor << ',' << s.renderer << " default "
<< s.defaultFormat; << s.defaultFormat;
if (s.extensions & QOpenGLStaticContext::SampleBuffers) if (s.extensions & QOpenGLStaticContext::SampleBuffers)
nsp << ",SampleBuffers"; d << ",SampleBuffers";
if (s.hasExtensions()) if (s.hasExtensions())
nsp << ", Extension-API present"; d << ", Extension-API present";
nsp << "\nExtensions: " << (s.extensionNames.count(' ') + 1); d << "\nExtensions: " << (s.extensionNames.count(' ') + 1);
if (QWindowsContext::verbose > 1) if (QWindowsContext::verbose > 1)
nsp << s.extensionNames; d << s.extensionNames;
return d; return d;
} }

View File

@ -315,13 +315,12 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const
QWindowsWindowData obtained = QWindowsWindowData::create(window, requested, window->title()); QWindowsWindowData obtained = QWindowsWindowData::create(window, requested, window->title());
qCDebug(lcQpaWindows).nospace() qCDebug(lcQpaWindows).nospace()
<< __FUNCTION__ << '<' << window << __FUNCTION__ << ' ' << window
<< "\n Requested: " << requested.geometry << "frame incl.: " << "\n Requested: " << requested.geometry << " frame incl.="
<< QWindowsGeometryHint::positionIncludesFrame(window) << QWindowsGeometryHint::positionIncludesFrame(window)
<< " Flags=" << requested.flags << ' ' << requested.flags
<< "\n Obtained : " << obtained.geometry << " Margins "<< obtained.frame << "\n Obtained : " << obtained.geometry << " margins=" << obtained.frame
<< " Flags=" << obtained.flags << " handle=" << obtained.hwnd << ' ' << obtained.flags << '\n';
<< " Handle=" << obtained.hwnd << '\n';
if (obtained.hwnd) { if (obtained.hwnd) {
if (requested.flags != obtained.flags) if (requested.flags != obtained.flags)

View File

@ -173,20 +173,22 @@ static inline WindowsScreenDataList monitorData()
static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d) static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d)
{ {
QDebug nospace = dbg.nospace(); QDebugStateSaver saver(dbg);
nospace << "Screen " << d.name << ' ' dbg.nospace();
<< d.geometry.width() << 'x' << d.geometry.height() << '+' << d.geometry.x() << '+' << d.geometry.y() dbg.noquote();
<< " avail: " dbg << "Screen \"" << d.name << "\" "
<< d.availableGeometry.width() << 'x' << d.availableGeometry.height() << '+' << d.availableGeometry.x() << '+' << d.availableGeometry.y() << d.geometry.width() << 'x' << d.geometry.height() << '+' << d.geometry.x() << '+' << d.geometry.y()
<< " physical: " << d.physicalSizeMM.width() << 'x' << d.physicalSizeMM.height() << " avail: "
<< " DPI: " << d.dpi.first << 'x' << d.dpi.second << " Depth: " << d.depth << d.availableGeometry.width() << 'x' << d.availableGeometry.height() << '+' << d.availableGeometry.x() << '+' << d.availableGeometry.y()
<< " Format: " << d.format; << " physical: " << d.physicalSizeMM.width() << 'x' << d.physicalSizeMM.height()
<< " DPI: " << d.dpi.first << 'x' << d.dpi.second << " Depth: " << d.depth
<< " Format: " << d.format;
if (d.flags & QWindowsScreenData::PrimaryScreen) if (d.flags & QWindowsScreenData::PrimaryScreen)
nospace << " primary"; dbg << " primary";
if (d.flags & QWindowsScreenData::VirtualDesktop) if (d.flags & QWindowsScreenData::VirtualDesktop)
nospace << " virtual desktop"; dbg << " virtual desktop";
if (d.flags & QWindowsScreenData::LockScreen) if (d.flags & QWindowsScreenData::LockScreen)
nospace << " lock screen"; dbg << " lock screen";
return dbg; return dbg;
} }

View File

@ -109,12 +109,13 @@ static QByteArray debugWinExStyle(DWORD exStyle)
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO #ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
QDebug operator<<(QDebug d, const MINMAXINFO &i) QDebug operator<<(QDebug d, const MINMAXINFO &i)
{ {
d.nospace() << "MINMAXINFO maxSize=" << i.ptMaxSize.x << ',' QDebugStateSaver saver(d);
<< i.ptMaxSize.y << " maxpos=" << i.ptMaxPosition.x d.nospace();
<< ',' << i.ptMaxPosition.y << " mintrack=" d << "MINMAXINFO maxSize=" << i.ptMaxSize.x << ','
<< i.ptMinTrackSize.x << ',' << i.ptMinTrackSize.y << i.ptMaxSize.y << " maxpos=" << i.ptMaxPosition.x
<< " maxtrack=" << i.ptMaxTrackSize.x << ',' << ',' << i.ptMaxPosition.y << " mintrack="
<< i.ptMaxTrackSize.y; << i.ptMinTrackSize.x << ',' << i.ptMinTrackSize.y
<< " maxtrack=" << i.ptMaxTrackSize.x << ',' << i.ptMaxTrackSize.y;
return d; return d;
} }
#endif // !Q_OS_WINCE #endif // !Q_OS_WINCE
@ -139,18 +140,20 @@ static inline RECT RECTfromQRect(const QRect &rect)
QDebug operator<<(QDebug d, const RECT &r) QDebug operator<<(QDebug d, const RECT &r)
{ {
d.nospace() << "RECT: left/top=" << r.left << ',' << r.top QDebugStateSaver saver(d);
<< " right/bottom=" << r.right << ',' << r.bottom; d.nospace();
d << "RECT: left/top=" << r.left << ',' << r.top
<< " right/bottom=" << r.right << ',' << r.bottom;
return d; return d;
} }
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_NCCALCSIZE #ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_NCCALCSIZE
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p) QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p)
{ {
qDebug().nospace() << "NCCALCSIZE_PARAMS " QDebugStateSaver saver(d);
<< qrectFromRECT(p.rgrc[0]) d.nospace();
<< ' ' << qrectFromRECT(p.rgrc[1]) << ' ' d << "NCCALCSIZE_PARAMS " << qrectFromRECT(p.rgrc[0])
<< qrectFromRECT(p.rgrc[2]); << ' ' << qrectFromRECT(p.rgrc[1]) << ' ' << qrectFromRECT(p.rgrc[2]);
return d; return d;
} }
#endif // !Q_OS_WINCE #endif // !Q_OS_WINCE
@ -417,13 +420,18 @@ struct WindowCreationData
QDebug operator<<(QDebug debug, const WindowCreationData &d) QDebug operator<<(QDebug debug, const WindowCreationData &d)
{ {
debug.nospace() << d.flags QDebugStateSaver saver(debug);
<< " topLevel=" << d.topLevel << " popup=" debug.nospace();
<< d.popup << " dialog=" << d.dialog << " desktop=" << d.desktop debug.noquote();
<< " embedded=" << d.embedded debug << "WindowCreationData: " << d.flags
<< " tool=" << d.tool << " style=" << debugWinStyle(d.style) << "\n topLevel=" << d.topLevel;
<< " exStyle=" << debugWinExStyle(d.exStyle) if (d.parentHandle)
<< " parent=" << d.parentHandle; debug << " parent=" << d.parentHandle;
debug << " popup=" << d.popup << " dialog=" << d.dialog << " desktop=" << d.desktop
<< " embedded=" << d.embedded << " tool=" << d.tool
<< "\n style=" << debugWinStyle(d.style);
if (d.exStyle)
debug << "\n exStyle=" << debugWinExStyle(d.exStyle);
return debug; return debug;
} }
@ -614,8 +622,8 @@ QWindowsWindowData
QWindowsContext::instance()->setWindowCreationContext(context); QWindowsContext::instance()->setWindowCreationContext(context);
qCDebug(lcQpaWindows).nospace() qCDebug(lcQpaWindows).nospace()
<< "CreateWindowEx: " << w << *this << " class=" <<windowClassName << " title=" << title << "CreateWindowEx: " << w << " class=" << windowClassName << " title=" << title
<< "\nrequested: " << rect << ": " << '\n' << *this << "\nrequested: " << rect << ": "
<< context->frameWidth << 'x' << context->frameHeight << context->frameWidth << 'x' << context->frameHeight
<< '+' << context->frameX << '+' << context->frameY << '+' << context->frameX << '+' << context->frameY
<< " custom margins: " << context->customMargins; << " custom margins: " << context->customMargins;
@ -631,7 +639,7 @@ QWindowsWindowData
#endif #endif
qCDebug(lcQpaWindows).nospace() qCDebug(lcQpaWindows).nospace()
<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: " << "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "
<< context->obtainedGeometry << context->margins; << context->obtainedGeometry << ' ' << context->margins;
if (!result.hwnd) { if (!result.hwnd) {
qErrnoWarning("%s: CreateWindowEx failed", __FUNCTION__); qErrnoWarning("%s: CreateWindowEx failed", __FUNCTION__);
@ -732,9 +740,9 @@ QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
qErrnoWarning("%s: AdjustWindowRectEx failed", __FUNCTION__); qErrnoWarning("%s: AdjustWindowRectEx failed", __FUNCTION__);
const QMargins result(qAbs(rect.left), qAbs(rect.top), const QMargins result(qAbs(rect.left), qAbs(rect.top),
qAbs(rect.right), qAbs(rect.bottom)); qAbs(rect.right), qAbs(rect.bottom));
qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << " style= 0x" qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << " style="
<< QString::number(style, 16) << " exStyle=0x" << QString::number(exStyle, 16) << ' ' << rect << ' ' << result; << showbase << hex << style << " exStyle=" << exStyle << dec << noshowbase
<< ' ' << rect << ' ' << result;
return result; return result;
} }
@ -853,12 +861,12 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
} }
qCDebug(lcQpaWindows).nospace() qCDebug(lcQpaWindows).nospace()
<< __FUNCTION__ << ' ' << w << geometry << __FUNCTION__ << ' ' << w << ' ' << geometry
<< " pos incl. frame" << QWindowsGeometryHint::positionIncludesFrame(w) << " pos incl. frame=" << QWindowsGeometryHint::positionIncludesFrame(w)
<< " frame: " << frameWidth << 'x' << frameHeight << '+' << " frame=" << frameWidth << 'x' << frameHeight << '+'
<< frameX << '+' << frameY << frameX << '+' << frameY
<< " min" << geometryHint.minimumSize << " max" << geometryHint.maximumSize << " min=" << geometryHint.minimumSize << " max=" << geometryHint.maximumSize
<< " custom margins " << customMargins; << " custom margins=" << customMargins;
} }
/*! /*!
@ -1422,10 +1430,10 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const
const QMargins margins = frameMarginsDp(); const QMargins margins = frameMarginsDp();
const QRect frameGeometry = rect + margins; const QRect frameGeometry = rect + margins;
qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << this << window() qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << window()
<< " \n from " << geometry_sys() << " frame: " << "\n from " << geometry_sys() << " frame: "
<< margins << " to " <<rect << margins << " to " <<rect
<< " new frame: " << frameGeometry; << " new frame: " << frameGeometry;
bool result = false; bool result = false;
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
@ -1446,8 +1454,8 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const
result = MoveWindow(m_data.hwnd, frameGeometry.x(), frameGeometry.y(), result = MoveWindow(m_data.hwnd, frameGeometry.x(), frameGeometry.y(),
frameGeometry.width(), frameGeometry.height(), true); frameGeometry.width(), frameGeometry.height(), true);
} }
qCDebug(lcQpaWindows) << '<' << __FUNCTION__ << this << window() qCDebug(lcQpaWindows) << '<' << __FUNCTION__ << window()
<< " \n resulting " << result << geometry_sys(); << "\n resulting " << result << geometry_sys();
} }
QRect QWindowsWindow::frameGeometry_sys() const QRect QWindowsWindow::frameGeometry_sys() const
@ -2131,8 +2139,8 @@ void QWindowsWindow::setCursor(const QWindowsWindowCursor &c)
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
if (c.handle() != m_cursor.handle()) { if (c.handle() != m_cursor.handle()) {
const bool apply = applyNewCursor(window()); const bool apply = applyNewCursor(window());
qCDebug(lcQpaWindows) <<window() << __FUNCTION__ qCDebug(lcQpaWindows) << window() << __FUNCTION__
<< "Shape=" << c.cursor().shape() << " doApply=" << apply; << c.cursor().shape() << " doApply=" << apply;
m_cursor = c; m_cursor = c;
if (apply) if (apply)
applyCursor(); applyCursor();

View File

@ -108,10 +108,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
} }
const int dpr = int(devicePixelRatio()); const int dpr = int(devicePixelRatio());
// On VNC, it can be that physical size is unknown while
// virtual size is known (probably back-calculated from DPI and resolution)
if (m_sizeMillimeters.isEmpty())
m_sizeMillimeters = m_virtualSizeMillimeters;
if (m_geometry.isEmpty()) { if (m_geometry.isEmpty()) {
m_geometry = QRect(QPoint(), m_virtualSize/dpr); m_geometry = QRect(QPoint(), m_virtualSize/dpr);
m_nativeGeometry = QRect(QPoint(), m_virtualSize); m_nativeGeometry = QRect(QPoint(), m_virtualSize);
@ -353,6 +349,12 @@ QImage::Format QXcbScreen::format() const
return QImage::Format_RGB32; return QImage::Format_RGB32;
} }
QDpi QXcbScreen::virtualDpi() const
{
return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width(),
Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height());
}
QDpi QXcbScreen::logicalDpi() const QDpi QXcbScreen::logicalDpi() const
{ {
static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI"); static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI");
@ -363,8 +365,7 @@ QDpi QXcbScreen::logicalDpi() const
int primaryDpr = int(connection()->screens().at(0)->devicePixelRatio()); int primaryDpr = int(connection()->screens().at(0)->devicePixelRatio());
return QDpi(m_forcedDpi/primaryDpr, m_forcedDpi/primaryDpr); return QDpi(m_forcedDpi/primaryDpr, m_forcedDpi/primaryDpr);
} }
return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width(), return virtualDpi();
Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height());
} }
@ -415,7 +416,6 @@ void QXcbScreen::handleScreenChange(xcb_randr_screen_change_notify_event_t *chan
return; return;
m_rotation = change_event->rotation; m_rotation = change_event->rotation;
updateGeometry(change_event->timestamp);
switch (m_rotation) { switch (m_rotation) {
case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal
m_orientation = Qt::LandscapeOrientation; m_orientation = Qt::LandscapeOrientation;
@ -451,6 +451,8 @@ void QXcbScreen::handleScreenChange(xcb_randr_screen_change_notify_event_t *chan
case XCB_RANDR_ROTATION_REFLECT_Y: break; case XCB_RANDR_ROTATION_REFLECT_Y: break;
} }
updateGeometry(change_event->timestamp);
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), availableGeometry()); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), availableGeometry());
QWindowSystemInterface::handleScreenOrientationChange(QPlatformScreen::screen(), m_orientation); QWindowSystemInterface::handleScreenOrientationChange(QPlatformScreen::screen(), m_orientation);
@ -504,6 +506,15 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation)
break; break;
} }
// It can be that physical size is unknown while virtual size
// is known (probably back-calculated from DPI and resolution),
// e.g. on VNC or with some hardware.
if (m_sizeMillimeters.isEmpty()) {
QDpi dpi = virtualDpi();
m_sizeMillimeters = QSizeF(Q_MM_PER_INCH * xGeometry.width() / dpi.first,
Q_MM_PER_INCH * xGeometry.width() / dpi.second);
}
xcb_get_property_reply_t * workArea = xcb_get_property_reply_t * workArea =
xcb_get_property_reply(xcb_connection(), xcb_get_property_reply(xcb_connection(),
xcb_get_property_unchecked(xcb_connection(), false, screen()->root, xcb_get_property_unchecked(xcb_connection(), false, screen()->root,

View File

@ -94,6 +94,7 @@ public:
QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_sizeMillimeters; } QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_sizeMillimeters; }
QSize virtualSize() const { return m_virtualSize; } QSize virtualSize() const { return m_virtualSize; }
QSizeF physicalVirtualSize() const { return m_virtualSizeMillimeters; } QSizeF physicalVirtualSize() const { return m_virtualSizeMillimeters; }
QDpi virtualDpi() const;
QDpi logicalDpi() const Q_DECL_OVERRIDE; QDpi logicalDpi() const Q_DECL_OVERRIDE;
qreal devicePixelRatio() const Q_DECL_OVERRIDE; qreal devicePixelRatio() const Q_DECL_OVERRIDE;
QPlatformCursor *cursor() const Q_DECL_OVERRIDE; QPlatformCursor *cursor() const Q_DECL_OVERRIDE;

View File

@ -906,7 +906,7 @@ void QFileDialog::setDirectory(const QString &directory)
return; return;
QUrl newDirUrl = QUrl::fromLocalFile(newDirectory); QUrl newDirUrl = QUrl::fromLocalFile(newDirectory);
d->setLastVisitedDirectory(newDirUrl); QFileDialogPrivate::setLastVisitedDirectory(newDirUrl);
d->options->setInitialDirectory(QUrl::fromLocalFile(directory)); d->options->setInitialDirectory(QUrl::fromLocalFile(directory));
if (!d->usingWidgets()) { if (!d->usingWidgets()) {
@ -967,7 +967,7 @@ void QFileDialog::setDirectoryUrl(const QUrl &directory)
if (!directory.isValid()) if (!directory.isValid())
return; return;
d->setLastVisitedDirectory(directory); QFileDialogPrivate::setLastVisitedDirectory(directory);
d->options->setInitialDirectory(directory); d->options->setInitialDirectory(directory);
if (d->nativeDialogInUse) if (d->nativeDialogInUse)

View File

@ -187,7 +187,7 @@ public:
#endif #endif
bool restoreWidgetState(QStringList &history, int splitterPosition); bool restoreWidgetState(QStringList &history, int splitterPosition);
void setLastVisitedDirectory(const QUrl &dir); static void setLastVisitedDirectory(const QUrl &dir);
void retranslateWindowTitle(); void retranslateWindowTitle();
void retranslateStrings(); void retranslateStrings();
void emitFilesSelected(const QStringList &files); void emitFilesSelected(const QStringList &files);

View File

@ -1913,7 +1913,7 @@ void QTreeView::mouseReleaseEvent(QMouseEvent *event)
if (d->itemDecorationAt(event->pos()) == -1) { if (d->itemDecorationAt(event->pos()) == -1) {
QAbstractItemView::mouseReleaseEvent(event); QAbstractItemView::mouseReleaseEvent(event);
} else { } else {
if (state() == QAbstractItemView::DragSelectingState) if (state() == QAbstractItemView::DragSelectingState || state() == QAbstractItemView::DraggingState)
setState(QAbstractItemView::NoState); setState(QAbstractItemView::NoState);
if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease) if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease)
d->expandOrCollapseItemAtPos(event->pos()); d->expandOrCollapseItemAtPos(event->pos());

View File

@ -358,7 +358,7 @@ public:
void updateFont(const QFont &); void updateFont(const QFont &);
inline void setFont_helper(const QFont &font) { inline void setFont_helper(const QFont &font) {
if (data.fnt == font && data.fnt.resolve() == font.resolve()) if (data.fnt.resolve() == font.resolve() && data.fnt == font)
return; return;
updateFont(font); updateFont(font);
} }

View File

@ -354,7 +354,7 @@ void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString
} }
if (!sys) if (!sys)
return; return;
QBalloonTip::showBalloon(icon, message, title, sys->systemTrayIcon(), QBalloonTip::showBalloon(icon, title, message, sys->systemTrayIcon(),
sys->globalGeometry().center(), sys->globalGeometry().center(),
msecs); msecs);
} }

View File

@ -0,0 +1,8 @@
# QTBUG-33574 QTBUG-30943
[signalsEmittedAfterFileMoved]
windows 32bit msvc-2010
windows 64bit msvc
[watchFileAndItsDirectory:native backend-testfile]
osx
[watchFileAndItsDirectory:native backend-specialchars]
osx

View File

@ -3,5 +3,3 @@ TARGET = tst_qfilesystemwatcher
QT = core testlib QT = core testlib
SOURCES = tst_qfilesystemwatcher.cpp SOURCES = tst_qfilesystemwatcher.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
CONFIG += insignificant_test # QTBUG-33574

View File

@ -297,9 +297,16 @@ void tst_QMimeData::setText() const
QVERIFY(mimeData.hasText() == false); QVERIFY(mimeData.hasText() == false);
} }
// Publish retrieveData for verifying content validity
class TstMetaData : public QMimeData
{
public:
using QMimeData::retrieveData;
};
void tst_QMimeData::setUrls() const void tst_QMimeData::setUrls() const
{ {
QMimeData mimeData; TstMetaData mimeData;
QList<QUrl> shortUrlList; QList<QUrl> shortUrlList;
QList<QUrl> longUrlList; QList<QUrl> longUrlList;
@ -321,6 +328,14 @@ void tst_QMimeData::setUrls() const
QCOMPARE(mimeData.urls(), longUrlList); QCOMPARE(mimeData.urls(), longUrlList);
QCOMPARE(mimeData.text(), QString("http://qt-project.org\nhttp://www.google.com\n")); QCOMPARE(mimeData.text(), QString("http://qt-project.org\nhttp://www.google.com\n"));
// test and verify that setData doesn't corrupt url content
foreach (const QString &format, mimeData.formats()) {
QVariant before = mimeData.retrieveData(format, QVariant::ByteArray);
mimeData.setData(format, mimeData.data(format));
QVariant after = mimeData.retrieveData(format, QVariant::ByteArray);
QCOMPARE(after, before);
}
// clear, verify // clear, verify
mimeData.clear(); mimeData.clear();
QCOMPARE(mimeData.hasUrls(), false); QCOMPARE(mimeData.hasUrls(), false);

View File

@ -5,7 +5,7 @@ SUBDIRS = lib \
theplugin \ theplugin \
tst tst
!android: !win32: !mac: SUBDIRS += almostplugin !android: !win32: !mac: SUBDIRS += almostplugin
macx-*: SUBDIRS += machtest macx-*: contains(QT_CONFIG, private_tests): SUBDIRS += machtest
TARGET = tst_qpluginloader TARGET = tst_qpluginloader
# no special install rule for subdir # no special install rule for subdir

View File

@ -41,6 +41,7 @@
#include <stdio.h> #include <stdio.h>
#include <qpainter.h> #include <qpainter.h>
#include <private/qimage_p.h>
#include <private/qdrawhelper_p.h> #include <private/qdrawhelper_p.h>
Q_DECLARE_METATYPE(QImage::Format) Q_DECLARE_METATYPE(QImage::Format)
@ -160,8 +161,11 @@ private slots:
void inplaceRgbMirrored(); void inplaceRgbMirrored();
void inplaceConversion_data(); void genericRgbConversion_data();
void inplaceConversion(); void genericRgbConversion();
void inplaceRgbConversion_data();
void inplaceRgbConversion();
void deepCopyWhenPaintingActive(); void deepCopyWhenPaintingActive();
void scaled_QTBUG19157(); void scaled_QTBUG19157();
@ -183,11 +187,75 @@ private slots:
void cleanupFunctions(); void cleanupFunctions();
void devicePixelRatio(); void devicePixelRatio();
void rgb30Unpremul();
void metadataPassthrough();
private: private:
const QString m_prefix; const QString m_prefix;
}; };
static QString formatToString(QImage::Format format)
{
switch (format) {
case QImage::Format_Invalid:
return QStringLiteral("Invalid");
case QImage::Format_Mono:
return QStringLiteral("Mono");
case QImage::Format_MonoLSB:
return QStringLiteral("MonoLSB");
case QImage::Format_Indexed8:
return QStringLiteral("Indexed8");
case QImage::Format_RGB32:
return QStringLiteral("RGB32");
case QImage::Format_ARGB32:
return QStringLiteral("ARGB32");
case QImage::Format_ARGB32_Premultiplied:
return QStringLiteral("ARGB32pm");
case QImage::Format_RGB16:
return QStringLiteral("RGB16");
case QImage::Format_ARGB8565_Premultiplied:
return QStringLiteral("ARGB8565pm");
case QImage::Format_RGB666:
return QStringLiteral("RGB666");
case QImage::Format_ARGB6666_Premultiplied:
return QStringLiteral("ARGB6666pm");
case QImage::Format_RGB555:
return QStringLiteral("RGB555");
case QImage::Format_ARGB8555_Premultiplied:
return QStringLiteral("ARGB8555pm");
case QImage::Format_RGB888:
return QStringLiteral("RGB888");
case QImage::Format_RGB444:
return QStringLiteral("RGB444");
case QImage::Format_ARGB4444_Premultiplied:
return QStringLiteral("ARGB4444pm");
case QImage::Format_RGBX8888:
return QStringLiteral("RGBx88888");
case QImage::Format_RGBA8888:
return QStringLiteral("RGBA88888");
case QImage::Format_RGBA8888_Premultiplied:
return QStringLiteral("RGBA88888pm");
case QImage::Format_BGR30:
return QStringLiteral("BGR30");
case QImage::Format_A2BGR30_Premultiplied:
return QStringLiteral("A2BGR30pm");
case QImage::Format_RGB30:
return QStringLiteral("RGB30");
case QImage::Format_A2RGB30_Premultiplied:
return QStringLiteral("A2RGB30pm");
case QImage::Format_Alpha8:
return QStringLiteral("Alpha8");
case QImage::Format_Grayscale8:
return QStringLiteral("Grayscale8");
default:
break;
};
Q_UNREACHABLE();
qWarning("Unhandled image format");
return QStringLiteral("unknown");
}
tst_QImage::tst_QImage() tst_QImage::tst_QImage()
: m_prefix(QFINDTESTDATA("images/")) : m_prefix(QFINDTESTDATA("images/"))
{ {
@ -2159,23 +2227,9 @@ void tst_QImage::rgbSwapped_data()
{ {
QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("format");
QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; for (int i = QImage::Format_Indexed8; i < QImage::Format_Alpha8; ++i) {
QTest::newRow("Format_RGB32") << QImage::Format_RGB32; QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) << QImage::Format(i);
QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32; }
QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
QTest::newRow("Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied;
QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied;
QTest::newRow("Format_RGB666") << QImage::Format_RGB666;
QTest::newRow("Format_RGB555") << QImage::Format_RGB555;
QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied;
QTest::newRow("Format_RGB888") << QImage::Format_RGB888;
QTest::newRow("Format_RGB444") << QImage::Format_RGB444;
QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888;
QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("Format_A2BGR30_Premultiplied") << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("Format_RGB30") << QImage::Format_RGB30;
} }
void tst_QImage::rgbSwapped() void tst_QImage::rgbSwapped()
@ -2395,23 +2449,18 @@ void tst_QImage::inplaceMirrored_data()
QTest::addColumn<bool>("swap_vertical"); QTest::addColumn<bool>("swap_vertical");
QTest::addColumn<bool>("swap_horizontal"); QTest::addColumn<bool>("swap_horizontal");
QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false; for (int i = QImage::Format_Mono; i < QImage::NImageFormats; ++i) {
QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false; if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8)
QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false; continue;
QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false; if (i == QImage::Format_RGB444 || i == QImage::Format_ARGB4444_Premultiplied)
QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false; continue;
QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", vertical")))
QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << false << true; << QImage::Format(i) << true << false;
QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true; QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", horizontal")))
QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true; << QImage::Format(i) << false << true;
QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true; QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", horizontal+vertical")))
QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true; << QImage::Format(i) << true << true;
}
QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << true << true;
QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true;
QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true;
} }
void tst_QImage::inplaceMirrored() void tst_QImage::inplaceMirrored()
@ -2425,6 +2474,7 @@ void tst_QImage::inplaceMirrored()
switch (format) { switch (format) {
case QImage::Format_Mono: case QImage::Format_Mono:
case QImage::Format_MonoLSB:
for (int i = 0; i < image.height(); ++i) { for (int i = 0; i < image.height(); ++i) {
ushort* scanLine = (ushort*)image.scanLine(i); ushort* scanLine = (ushort*)image.scanLine(i);
*scanLine = (i % 2) ? 0x0fffU : 0xf000U; *scanLine = (i % 2) ? 0x0fffU : 0xf000U;
@ -2447,7 +2497,7 @@ void tst_QImage::inplaceMirrored()
const uchar* originalPtr = image.constScanLine(0); const uchar* originalPtr = image.constScanLine(0);
QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical); QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical);
if (format != QImage::Format_Mono) { if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB) {
for (int i = 0; i < imageMirrored.height(); ++i) { for (int i = 0; i < imageMirrored.height(); ++i) {
int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i; int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
for (int j = 0; j < imageMirrored.width(); ++j) { for (int j = 0; j < imageMirrored.width(); ++j) {
@ -2537,23 +2587,60 @@ void tst_QImage::inplaceRgbMirrored()
#endif #endif
} }
void tst_QImage::inplaceConversion_data() void tst_QImage::genericRgbConversion_data()
{ {
QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("format");
QTest::addColumn<QImage::Format>("dest_format"); QTest::addColumn<QImage::Format>("dest_format");
QTest::newRow("Format_RGB32 -> RGB16") << QImage::Format_RGB32 << QImage::Format_RGB16; for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) {
QTest::newRow("Format_ARGB32 -> Format_RGBA8888") << QImage::Format_ARGB32 << QImage::Format_RGBA8888; for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) {
QTest::newRow("Format_RGB888 -> Format_ARGB6666_Premultiplied") << QImage::Format_RGB888 << QImage::Format_ARGB6666_Premultiplied; if (i == j)
QTest::newRow("Format_RGB16 -> Format_RGB555") << QImage::Format_RGB16 << QImage::Format_RGB555; continue;
QTest::newRow("Format_RGB666 -> Format_RGB888") << QImage::Format_RGB666 << QImage::Format_RGB888; QString test = QString::fromLatin1("%1 -> %2").arg(formatToString(QImage::Format(i))).arg(formatToString(QImage::Format(j)));
QTest::newRow("Format_ARGB8565_Premultiplied, Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8565_Premultiplied << QImage::Format_ARGB8555_Premultiplied; QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j);
QTest::newRow("Format_ARGB4444_Premultiplied, Format_RGB444") << QImage::Format_ARGB4444_Premultiplied << QImage::Format_RGB444; }
QTest::newRow("Format_RGBA8888 -> RGB16") << QImage::Format_RGBA8888 << QImage::Format_RGB16; }
QTest::newRow("Format_RGBA8888_Premultiplied -> RGB16") << QImage::Format_RGBA8888_Premultiplied << QImage::Format_RGB16;
} }
void tst_QImage::inplaceConversion() void tst_QImage::genericRgbConversion()
{
// Test that all RGB conversions work and maintain at least 4bit of color accuracy.
QFETCH(QImage::Format, format);
QFETCH(QImage::Format, dest_format);
QImage image(16, 16, format);
for (int i = 0; i < image.height(); ++i)
for (int j = 0; j < image.width(); ++j)
image.setPixel(j, i, qRgb(j*16, i*16, 0));
QImage imageConverted = image.convertToFormat(dest_format);
QCOMPARE(imageConverted.format(), dest_format);
for (int i = 0; i < imageConverted.height(); ++i) {
for (int j = 0; j < imageConverted.width(); ++j) {
QRgb convertedColor = imageConverted.pixel(j,i);
QCOMPARE(qRed(convertedColor) & 0xF0, j * 16);
QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16);
}
}
}
void tst_QImage::inplaceRgbConversion_data()
{
QTest::addColumn<QImage::Format>("format");
QTest::addColumn<QImage::Format>("dest_format");
for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) {
for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) {
if (i == j)
continue;
QString test = QString::fromLatin1("%1 -> %2").arg(formatToString(QImage::Format(i))).arg(formatToString(QImage::Format(j)));
QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j);
}
}
}
void tst_QImage::inplaceRgbConversion()
{ {
// Test that conversions between RGB formats of the same bitwidth can be done inplace. // Test that conversions between RGB formats of the same bitwidth can be done inplace.
#if defined(Q_COMPILER_REF_QUALIFIERS) #if defined(Q_COMPILER_REF_QUALIFIERS)
@ -2582,8 +2669,8 @@ void tst_QImage::inplaceConversion()
{ {
// Test attempted inplace conversion of images created on existing buffer // Test attempted inplace conversion of images created on existing buffer
static const quint32 readOnlyData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U }; static const quint32 readOnlyData[] = { 0xff0102ffU, 0xff0506ffU, 0xff0910ffU, 0xff1314ffU };
quint32 readWriteData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U }; quint32 readWriteData[] = { 0xff0102ffU, 0xff0506ffU, 0xff0910ffU, 0xff1314ffU };
QImage roImage((const uchar *)readOnlyData, 2, 2, format); QImage roImage((const uchar *)readOnlyData, 2, 2, format);
QImage roInplaceConverted = std::move(roImage).convertToFormat(dest_format); QImage roInplaceConverted = std::move(roImage).convertToFormat(dest_format);
@ -2705,18 +2792,9 @@ void tst_QImage::invertPixelsRGB_data()
{ {
QTest::addColumn<QImage::Format>("image_format"); QTest::addColumn<QImage::Format>("image_format");
QTest::newRow("invertPixels RGB16") << QImage::Format_RGB16; for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) {
QTest::newRow("invertPixels RGB32") << QImage::Format_RGB32; QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) << QImage::Format(i);
QTest::newRow("invertPixels BGR30") << QImage::Format_BGR30; }
QTest::newRow("invertPixels RGB444") << QImage::Format_RGB444;
QTest::newRow("invertPixels RGB555") << QImage::Format_RGB555;
QTest::newRow("invertPixels RGB888") << QImage::Format_RGB888;
QTest::newRow("invertPixels ARGB32") << QImage::Format_ARGB32;
QTest::newRow("invertPixels ARGB32pm") << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("invertPixels RGBA8888") << QImage::Format_RGBA8888;
QTest::newRow("invertPixels RGBA8888pm") << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("invertPixels RGBA4444pm") << QImage::Format_ARGB4444_Premultiplied;
} }
void tst_QImage::invertPixelsRGB() void tst_QImage::invertPixelsRGB()
@ -2827,5 +2905,53 @@ void tst_QImage::devicePixelRatio()
QCOMPARE(b.devicePixelRatio(), qreal(1.0)); QCOMPARE(b.devicePixelRatio(), qreal(1.0));
} }
void tst_QImage::rgb30Unpremul()
{
QImage a(3, 1, QImage::Format_A2RGB30_Premultiplied);
((uint*)a.bits())[0] = (3U << 30) | (128 << 20) | (256 << 10) | 512;
((uint*)a.bits())[1] = (2U << 30) | (131 << 20) | (259 << 10) | 515;
((uint*)a.bits())[2] = (1U << 30) | ( 67 << 20) | (131 << 10) | 259;
QImage b = a.convertToFormat(QImage::Format_RGB30);
const uint* bbits = (const uint*)b.bits();
QCOMPARE(bbits[0], (3U << 30) | (128 << 20) | (256 << 10) | 512);
QCOMPARE(bbits[1], (3U << 30) | (196 << 20) | (388 << 10) | 772);
QCOMPARE(bbits[2], (3U << 30) | (201 << 20) | (393 << 10) | 777);
}
void tst_QImage::metadataPassthrough()
{
QImage a(64, 64, QImage::Format_ARGB32);
a.fill(Qt::white);
a.setText(QStringLiteral("Test"), QStringLiteral("Text"));
a.setDotsPerMeterX(100);
a.setDotsPerMeterY(80);
a.setDevicePixelRatio(2.0);
QImage scaled = a.scaled(QSize(32, 32), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX());
QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
scaled = a.scaled(QSize(128, 128), Qt::IgnoreAspectRatio, Qt::FastTransformation);
QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX());
QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
QImage mirrored = a.mirrored();
QCOMPARE(mirrored.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
QCOMPARE(mirrored.dotsPerMeterX(), a.dotsPerMeterX());
QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(mirrored.devicePixelRatio(), a.devicePixelRatio());
QImage swapped = a.rgbSwapped();
QCOMPARE(swapped.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
QCOMPARE(swapped.dotsPerMeterX(), a.dotsPerMeterX());
QCOMPARE(swapped.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio());
}
QTEST_GUILESS_MAIN(tst_QImage) QTEST_GUILESS_MAIN(tst_QImage)
#include "tst_qimage.moc" #include "tst_qimage.moc"

View File

@ -54,10 +54,10 @@
#include <qsortfilterproxymodel.h> #include <qsortfilterproxymodel.h>
#include <qlineedit.h> #include <qlineedit.h>
#include <qlayout.h> #include <qlayout.h>
#include <private/qfiledialog_p.h>
#if defined QT_BUILD_INTERNAL #if defined QT_BUILD_INTERNAL
#include <private/qsidebar_p.h> #include <private/qsidebar_p.h>
#include <private/qfilesystemmodel_p.h> #include <private/qfilesystemmodel_p.h>
#include <private/qfiledialog_p.h>
#endif #endif
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme.h>
@ -108,6 +108,7 @@ public:
public slots: public slots:
void initTestCase(); void initTestCase();
void init(); void init();
void cleanup();
private slots: private slots:
void currentChangedSignal(); void currentChangedSignal();
@ -166,7 +167,7 @@ private slots:
void rejectModalDialogs(); void rejectModalDialogs();
private: private:
QByteArray userSettings; void cleanupSettingsFile();
}; };
tst_QFiledialog::tst_QFiledialog() tst_QFiledialog::tst_QFiledialog()
@ -177,18 +178,27 @@ tst_QFiledialog::~tst_QFiledialog()
{ {
} }
void tst_QFiledialog::cleanupSettingsFile()
{
// clean up the sidebar between each test
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
settings.beginGroup(QLatin1String("FileDialog"));
settings.remove(QString());
settings.endGroup();
settings.beginGroup(QLatin1String("Qt")); // Compatibility settings
settings.remove(QLatin1String("filedialog"));
settings.endGroup();
}
void tst_QFiledialog::initTestCase() void tst_QFiledialog::initTestCase()
{ {
QStandardPaths::setTestModeEnabled(true); QStandardPaths::setTestModeEnabled(true);
cleanupSettingsFile();
} }
void tst_QFiledialog::init() void tst_QFiledialog::init()
{ {
// clean up the sidebar between each test QFileDialogPrivate::setLastVisitedDirectory(QUrl());
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
settings.beginGroup(QLatin1String("Qt"));
settings.remove(QLatin1String("filedialog"));
// populate the sidebar with some default settings // populate the sidebar with some default settings
QNonNativeFileDialog fd; QNonNativeFileDialog fd;
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
@ -196,6 +206,11 @@ void tst_QFiledialog::init()
#endif #endif
} }
void tst_QFiledialog::cleanup()
{
cleanupSettingsFile();
}
class MyAbstractItemDelegate : public QAbstractItemDelegate class MyAbstractItemDelegate : public QAbstractItemDelegate
{ {
public: public:

View File

@ -88,6 +88,7 @@ public:
virtual ~tst_QFileDialog2(); virtual ~tst_QFileDialog2();
public slots: public slots:
void initTestCase();
void init(); void init();
void cleanup(); void cleanup();
@ -135,13 +136,13 @@ private slots:
void dontShowCompleterOnRoot(); void dontShowCompleterOnRoot();
private: private:
QByteArray userSettings; void cleanupSettingsFile();
QTemporaryDir tempDir; QTemporaryDir tempDir;
}; };
tst_QFileDialog2::tst_QFileDialog2() tst_QFileDialog2::tst_QFileDialog2()
: userSettings() : tempDir(QDir::tempPath() + "/tst_qfiledialog2.XXXXXX")
, tempDir(QDir::tempPath() + "/tst_qfiledialog2.XXXXXX")
{ {
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
qApp->setAutoMaximizeThreshold(-1); qApp->setAutoMaximizeThreshold(-1);
@ -152,17 +153,29 @@ tst_QFileDialog2::~tst_QFileDialog2()
{ {
} }
void tst_QFileDialog2::init() void tst_QFileDialog2::cleanupSettingsFile()
{
// clean up the sidebar between each test
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
settings.beginGroup(QLatin1String("FileDialog"));
settings.remove(QString());
settings.endGroup();
settings.beginGroup(QLatin1String("Qt")); // Compatibility settings
settings.remove(QLatin1String("filedialog"));
settings.endGroup();
}
void tst_QFileDialog2::initTestCase()
{ {
QVERIFY(tempDir.isValid()); QVERIFY(tempDir.isValid());
QStandardPaths::setTestModeEnabled(true);
cleanupSettingsFile();
}
// Save the developers settings so they don't get mad when their sidebar folders are gone. void tst_QFileDialog2::init()
QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); {
settings.beginGroup(QLatin1String("Qt")); QFileDialogPrivate::setLastVisitedDirectory(QUrl());
userSettings = settings.value(QLatin1String("filedialog")).toByteArray(); // populate the sidebar with some default settings
settings.remove(QLatin1String("filedialog"));
// populate it with some default settings
QNonNativeFileDialog fd; QNonNativeFileDialog fd;
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
QTest::qWait(1000); QTest::qWait(1000);
@ -171,9 +184,7 @@ void tst_QFileDialog2::init()
void tst_QFileDialog2::cleanup() void tst_QFileDialog2::cleanup()
{ {
QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); cleanupSettingsFile();
settings.beginGroup(QLatin1String("Qt"));
settings.setValue(QLatin1String("filedialog"), userSettings);
} }
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL

View File

@ -49,6 +49,12 @@ private slots:
void convertRgb32ToRgb888_data(); void convertRgb32ToRgb888_data();
void convertRgb32ToRgb888(); void convertRgb32ToRgb888();
void convertRgb16_data();
void convertRgb16();
void convertRgb32_data();
void convertRgb32();
void convertGeneric_data(); void convertGeneric_data();
void convertGeneric(); void convertGeneric();
@ -146,55 +152,96 @@ void tst_QImageConversion::convertRgb32ToRgb888()
} }
} }
void tst_QImageConversion::convertRgb16_data()
void tst_QImageConversion::convertGeneric_data()
{ {
QTest::addColumn<QImage>("inputImage"); QTest::addColumn<QImage>("inputImage");
QTest::addColumn<QImage::Format>("outputFormat"); QTest::addColumn<QImage::Format>("outputFormat");
QImage rgb16 = generateImageRgb16(1000, 1000); QImage rgb16 = generateImageRgb16(1000, 1000);
QTest::newRow("rgb32") << rgb16 << QImage::Format_RGB32;
QTest::newRow("rgb888") << rgb16 << QImage::Format_RGB888;
QTest::newRow("rgb666") << rgb16 << QImage::Format_RGB666;
QTest::newRow("rgb555") << rgb16 << QImage::Format_RGB555;
}
void tst_QImageConversion::convertRgb16()
{
QFETCH(QImage, inputImage);
QFETCH(QImage::Format, outputFormat);
QBENCHMARK {
QImage output = inputImage.convertToFormat(outputFormat);
output.constBits();
}
}
void tst_QImageConversion::convertRgb32_data()
{
QTest::addColumn<QImage>("inputImage");
QTest::addColumn<QImage::Format>("outputFormat");
QImage rgb32 = generateImageRgb32(1000, 1000); QImage rgb32 = generateImageRgb32(1000, 1000);
QImage argb32 = generateImageArgb32(1000, 1000); QImage argb32 = generateImageArgb32(1000, 1000);
QImage argb32pm = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied); QImage argb32pm = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied);
QImage rgba32 = argb32.convertToFormat(QImage::Format_RGBA8888);
QImage a2rgb30 = argb32.convertToFormat(QImage::Format_A2RGB30_Premultiplied);
QTest::newRow("rgb16 -> rgb32") << rgb16 << QImage::Format_RGB32;
QTest::newRow("rgb16 -> rgb888") << rgb16 << QImage::Format_RGB888;
QTest::newRow("rgb16 -> rgb666") << rgb16 << QImage::Format_RGB666;
QTest::newRow("rgb16 -> rgb555") << rgb16 << QImage::Format_RGB555;
QTest::newRow("rgb32 -> rgb16") << rgb32 << QImage::Format_RGB16; QTest::newRow("rgb32 -> rgb16") << rgb32 << QImage::Format_RGB16;
QTest::newRow("rgb32 -> rgb888") << rgb32 << QImage::Format_RGB888;
QTest::newRow("rgb32 -> rgb666") << rgb32 << QImage::Format_RGB666;
QTest::newRow("rgb32 -> rgb555") << rgb32 << QImage::Format_RGB555;
QTest::newRow("rgb32 -> argb32") << rgb32 << QImage::Format_ARGB32; QTest::newRow("rgb32 -> argb32") << rgb32 << QImage::Format_ARGB32;
QTest::newRow("rgb32 -> argb32pm") << rgb32 << QImage::Format_ARGB32_Premultiplied; QTest::newRow("rgb32 -> argb32pm") << rgb32 << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("rgb32 -> rgbx8888") << rgb32 << QImage::Format_RGBX8888; QTest::newRow("rgb32 -> rgbx8888") << rgb32 << QImage::Format_RGBX8888;
QTest::newRow("rgb32 -> rgba8888") << rgb32 << QImage::Format_RGBA8888; QTest::newRow("rgb32 -> rgba8888") << rgb32 << QImage::Format_RGBA8888;
QTest::newRow("rgb32 -> rgba8888pm") << rgb32 << QImage::Format_RGBA8888_Premultiplied; QTest::newRow("rgb32 -> rgba8888pm") << rgb32 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("rgb32 -> rgb30") << rgb32 << QImage::Format_RGB30; QTest::newRow("rgb32 -> rgb30") << rgb32 << QImage::Format_RGB30;
QTest::newRow("rgb32 -> bgr30") << rgb32 << QImage::Format_BGR30; QTest::newRow("rgb32 -> a2bgr30") << rgb32 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("rgb32 -> rgb888") << rgb32 << QImage::Format_RGB888;
QTest::newRow("rgb32 -> rgb666") << rgb32 << QImage::Format_RGB666;
QTest::newRow("rgb32 -> rgb555") << rgb32 << QImage::Format_RGB555;
QTest::newRow("argb32 -> rgb888") << argb32 << QImage::Format_RGB888; QTest::newRow("argb32 -> rgb16") << argb32 << QImage::Format_RGB16;
QTest::newRow("argb32 -> rgb666") << argb32 << QImage::Format_RGB666;
QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
QTest::newRow("argb32 -> rgb32") << argb32 << QImage::Format_RGB32; QTest::newRow("argb32 -> rgb32") << argb32 << QImage::Format_RGB32;
QTest::newRow("argb32 -> argb32pm") << argb32 << QImage::Format_ARGB32_Premultiplied; QTest::newRow("argb32 -> argb32pm") << argb32 << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("argb32 -> rgbx8888") << argb32 << QImage::Format_RGBX8888; QTest::newRow("argb32 -> rgbx8888") << argb32 << QImage::Format_RGBX8888;
QTest::newRow("argb32 -> rgba8888") << argb32 << QImage::Format_RGBA8888; QTest::newRow("argb32 -> rgba8888") << argb32 << QImage::Format_RGBA8888;
QTest::newRow("argb32 -> rgba8888pm") << argb32 << QImage::Format_RGBA8888_Premultiplied; QTest::newRow("argb32 -> rgba8888pm") << argb32 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("argb32 -> rgb30") << argb32 << QImage::Format_RGB30; QTest::newRow("argb32 -> rgb30") << argb32 << QImage::Format_RGB30;
QTest::newRow("argb32 -> a2rgb30") << argb32 << QImage::Format_A2RGB30_Premultiplied; QTest::newRow("argb32 -> a2bgr30") << argb32 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("argb32 -> rgb888") << argb32 << QImage::Format_RGB888;
QTest::newRow("argb32 -> rgb666") << argb32 << QImage::Format_RGB666;
QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
QTest::newRow("argb32pm -> argb4444pm") << argb32pm << QImage::Format_ARGB4444_Premultiplied; QTest::newRow("argb32pm -> rgb16") << argb32pm << QImage::Format_RGB16;
QTest::newRow("argb32pm -> rgb32") << argb32pm << QImage::Format_RGB32; QTest::newRow("argb32pm -> rgb32") << argb32pm << QImage::Format_RGB32;
QTest::newRow("argb32pm -> argb32") << argb32pm << QImage::Format_ARGB32; QTest::newRow("argb32pm -> argb32") << argb32pm << QImage::Format_ARGB32;
QTest::newRow("argb32pm -> rgbx8888") << argb32pm << QImage::Format_RGBX8888; QTest::newRow("argb32pm -> rgbx8888") << argb32pm << QImage::Format_RGBX8888;
QTest::newRow("argb32pm -> rgba8888") << argb32pm << QImage::Format_RGBA8888; QTest::newRow("argb32pm -> rgba8888") << argb32pm << QImage::Format_RGBA8888;
QTest::newRow("argb32pm -> rgba8888pm") << argb32pm << QImage::Format_RGBA8888_Premultiplied; QTest::newRow("argb32pm -> rgba8888pm") << argb32pm << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("argb32pm -> rgb30") << argb32pm << QImage::Format_RGB30; QTest::newRow("argb32pm -> rgb30") << argb32pm << QImage::Format_RGB30;
QTest::newRow("argb32pm -> a2rgb30") << argb32pm << QImage::Format_A2RGB30_Premultiplied; QTest::newRow("argb32pm -> a2bgr30") << argb32pm << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("argb32pm -> rgb888") << argb32pm << QImage::Format_RGB888;
QTest::newRow("argb32pm -> rgb666") << argb32pm << QImage::Format_RGB666;
QTest::newRow("argb32pm -> argb8565pm") << argb32pm << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("argb32pm -> argb4444pm") << argb32pm << QImage::Format_ARGB4444_Premultiplied;
}
void tst_QImageConversion::convertRgb32()
{
QFETCH(QImage, inputImage);
QFETCH(QImage::Format, outputFormat);
QBENCHMARK {
QImage output = inputImage.convertToFormat(outputFormat);
output.constBits();
}
}
void tst_QImageConversion::convertGeneric_data()
{
QTest::addColumn<QImage>("inputImage");
QTest::addColumn<QImage::Format>("outputFormat");
QImage rgb32 = generateImageRgb32(1000, 1000);
QImage argb32 = generateImageArgb32(1000, 1000);
QImage rgba32 = argb32.convertToFormat(QImage::Format_RGBA8888);
QImage bgr30 = rgb32.convertToFormat(QImage::Format_BGR30);
QImage a2rgb30 = argb32.convertToFormat(QImage::Format_A2RGB30_Premultiplied);
QTest::newRow("rgba8888 -> rgb32") << rgba32 << QImage::Format_RGB32; QTest::newRow("rgba8888 -> rgb32") << rgba32 << QImage::Format_RGB32;
QTest::newRow("rgba8888 -> argb32") << rgba32 << QImage::Format_ARGB32; QTest::newRow("rgba8888 -> argb32") << rgba32 << QImage::Format_ARGB32;
@ -202,7 +249,16 @@ void tst_QImageConversion::convertGeneric_data()
QTest::newRow("rgba8888 -> rgbx8888") << rgba32 << QImage::Format_RGBX8888; QTest::newRow("rgba8888 -> rgbx8888") << rgba32 << QImage::Format_RGBX8888;
QTest::newRow("rgba8888 -> rgba8888pm") << rgba32 << QImage::Format_RGBA8888_Premultiplied; QTest::newRow("rgba8888 -> rgba8888pm") << rgba32 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("rgba8888 -> rgb30") << rgba32 << QImage::Format_RGB30; QTest::newRow("rgba8888 -> rgb30") << rgba32 << QImage::Format_RGB30;
QTest::newRow("rgba8888 -> a2rgb30") << rgba32 << QImage::Format_A2RGB30_Premultiplied; QTest::newRow("rgba8888 -> a2bgr30") << rgba32 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("bgr30 -> rgb32") << bgr30 << QImage::Format_RGB32;
QTest::newRow("bgr30 -> argb32") << bgr30 << QImage::Format_ARGB32;
QTest::newRow("bgr30 -> argb32pm") << bgr30 << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("bgr30 -> rgbx8888") << bgr30 << QImage::Format_RGBX8888;
QTest::newRow("bgr30 -> rgba8888") << bgr30 << QImage::Format_RGBA8888;
QTest::newRow("bgr30 -> rgba8888pm") << bgr30 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("bgr30 -> rgb30") << bgr30 << QImage::Format_RGB30;
QTest::newRow("bgr30 -> a2bgr30") << bgr30 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("a2rgb30 -> rgb32") << a2rgb30 << QImage::Format_RGB32; QTest::newRow("a2rgb30 -> rgb32") << a2rgb30 << QImage::Format_RGB32;
QTest::newRow("a2rgb30 -> argb32") << a2rgb30 << QImage::Format_ARGB32; QTest::newRow("a2rgb30 -> argb32") << a2rgb30 << QImage::Format_ARGB32;
@ -210,7 +266,9 @@ void tst_QImageConversion::convertGeneric_data()
QTest::newRow("a2rgb30 -> rgbx8888") << a2rgb30 << QImage::Format_RGBX8888; QTest::newRow("a2rgb30 -> rgbx8888") << a2rgb30 << QImage::Format_RGBX8888;
QTest::newRow("a2rgb30 -> rgba8888") << a2rgb30 << QImage::Format_RGBA8888; QTest::newRow("a2rgb30 -> rgba8888") << a2rgb30 << QImage::Format_RGBA8888;
QTest::newRow("a2rgb30 -> rgba8888pm") << a2rgb30 << QImage::Format_RGBA8888_Premultiplied; QTest::newRow("a2rgb30 -> rgba8888pm") << a2rgb30 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("a2rgb30 -> rgb30") << a2rgb30 << QImage::Format_RGB30;
QTest::newRow("a2rgb30 -> bgr30") << a2rgb30 << QImage::Format_BGR30; QTest::newRow("a2rgb30 -> bgr30") << a2rgb30 << QImage::Format_BGR30;
QTest::newRow("a2rgb30 -> a2bgr30") << a2rgb30 << QImage::Format_A2BGR30_Premultiplied;
} }
void tst_QImageConversion::convertGeneric() void tst_QImageConversion::convertGeneric()
@ -316,12 +374,14 @@ QImage tst_QImageConversion::generateImageRgb32(int width, int height)
QImage tst_QImageConversion::generateImageArgb32(int width, int height) QImage tst_QImageConversion::generateImageArgb32(int width, int height)
{ {
QImage image(width, height, QImage::Format_ARGB32); QImage image(width, height, QImage::Format_ARGB32);
const int byteWidth = width * 4;
for (int y = 0; y < image.height(); ++y) { for (int y = 0; y < image.height(); ++y) {
uchar *scanline = image.scanLine(y); QRgb *scanline = (QRgb*)image.scanLine(y);
for (int x = 0; x < byteWidth; ++x) for (int x = 0; x < width; ++x) {
scanline[x] = x ^ y; int alpha = (x ^ y) & 0x1ff;
alpha = qMax(0, qMin(alpha - 128, 255));
scanline[x] = qRgba(x, y, x ^ y, alpha);
}
} }
return image; return image;
} }

View File

@ -222,6 +222,32 @@ static const EnumLookup scriptEnumLookup[] =
{QChar::Script_Sharada, "Script_Sharada"}, {QChar::Script_Sharada, "Script_Sharada"},
{QChar::Script_SoraSompeng, "Script_SoraSompeng"}, {QChar::Script_SoraSompeng, "Script_SoraSompeng"},
{QChar::Script_Takri, "Script_Takri"}, {QChar::Script_Takri, "Script_Takri"},
#if QT_VERSION >= 0x050500
{QChar::Script_CaucasianAlbanian, "Script_CaucasianAlbanian"},
{QChar::Script_BassaVah, "Script_BassaVah"},
{QChar::Script_Duployan, "Script_Duployan"},
{QChar::Script_Elbasan, "Script_Elbasan"},
{QChar::Script_Grantha, "Script_Grantha"},
{QChar::Script_PahawhHmong, "Script_PahawhHmong"},
{QChar::Script_Khojki, "Script_Khojki"},
{QChar::Script_LinearA, "Script_LinearA"},
{QChar::Script_Mahajani, "Script_Mahajani"},
{QChar::Script_Manichaean, "Script_Manichaean"},
{QChar::Script_MendeKikakui, "Script_MendeKikakui"},
{QChar::Script_Modi, "Script_Modi"},
{QChar::Script_Mro, "Script_Mro"},
{QChar::Script_OldNorthArabian, "Script_OldNorthArabian"},
{QChar::Script_Nabataean, "Script_Nabataean"},
{QChar::Script_Palmyrene, "Script_Palmyrene"},
{QChar::Script_PauCinHau, "Script_PauCinHau"},
{QChar::Script_OldPermic, "Script_OldPermic"},
{QChar::Script_PsalterPahlavi, "Script_PsalterPahlavi"},
{QChar::Script_Siddham, "Script_Siddham"},
{QChar::Script_Khudawadi, "Script_Khudawadi"},
{QChar::Script_Tirhuta, "Script_Tirhuta"},
{QChar::Script_WarangCiti, "Script_WarangCiti"},
#endif // Qt 5.5
}; };
#endif // Qt 5.1 #endif // Qt 5.1
@ -335,6 +361,9 @@ static const EnumLookup unicodeVersionEnumLookup[] =
{QChar::Unicode_6_1, "Unicode_6_1"}, {QChar::Unicode_6_1, "Unicode_6_1"},
{QChar::Unicode_6_2, "Unicode_6_2"}, {QChar::Unicode_6_2, "Unicode_6_2"},
{QChar::Unicode_6_3, "Unicode_6_3"}, {QChar::Unicode_6_3, "Unicode_6_3"},
#if QT_VERSION >= 0x050500
{QChar::Unicode_7_0, "Unicode_7_0"},
#endif // Qt 5.5
#endif // Qt 5 #endif // Qt 5
}; };