summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-11 08:24:34 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-11 08:25:04 +0100
commitd456f87ece0323982b7601047712545ab95426ad (patch)
tree46b90468b01144615f280620d73763fc189d25ac /src/gui
parentcc2938b5b6aa07210b04bd48ad8a2830701a06e5 (diff)
parent4fc070a4192d5b914b6f814a8dcab3f552d9abac (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/io/qfilesystemwatcher_win.cpp src/corelib/plugin/plugin.pri src/plugins/platforms/cocoa/qcocoaaccessibility.mm tests/auto/corelib/tools/qlocale/tst_qlocale.cpp Change-Id: Id6824631252609a75eff8b68792e4d10095c8fc1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimagereader.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp8
-rw-r--r--src/gui/kernel/qkeysequence.cpp30
-rw-r--r--src/gui/kernel/qkeysequence_p.h2
-rw-r--r--src/gui/kernel/qwindow.cpp2
-rw-r--r--src/gui/painting/qdrawhelper.cpp6
-rw-r--r--src/gui/painting/qpdf.cpp8
-rw-r--r--src/gui/text/qfontdatabase.cpp5
-rw-r--r--src/gui/text/qfontsubset.cpp10
-rw-r--r--src/gui/text/qtexthtmlparser.cpp8
10 files changed, 51 insertions, 30 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 2ccee3dcd6..db5fb00361 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -1629,6 +1629,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader,
QList<QByteArray> QImageReader::supportedImageFormats()
{
QList<QByteArray> formats;
+ formats.reserve(_qt_NumFormats);
for (int i = 0; i < _qt_NumFormats; ++i)
formats << _qt_BuiltInFormats[i].extension;
@@ -1653,6 +1654,7 @@ QList<QByteArray> QImageReader::supportedImageFormats()
QList<QByteArray> QImageReader::supportedMimeTypes()
{
QList<QByteArray> mimeTypes;
+ mimeTypes.reserve(_qt_NumFormats);
for (int i = 0; i < _qt_NumFormats; ++i)
mimeTypes << _qt_BuiltInFormats[i].mimeType;
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index f98b4236fe..53599a3a37 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -244,11 +244,13 @@ static inline void clearFontUnlocked()
QGuiApplicationPrivate::app_font = 0;
}
+// Using aggregate initialization instead of ctor so we can have a POD global static
+#define Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER { Qt::TopLeftCorner, -1, -1, -1, -1 }
+
// Geometry specification for top level windows following the convention of the
// -geometry command line arguments in X11 (see XParseGeometry).
struct QWindowGeometrySpecification
{
- QWindowGeometrySpecification() : corner(Qt::TopLeftCorner), xOffset(-1), yOffset(-1), width(-1), height(-1) {}
static QWindowGeometrySpecification fromArgument(const QByteArray &a);
void applyTo(QWindow *window) const;
@@ -285,7 +287,7 @@ static inline int nextGeometryToken(const QByteArray &a, int &pos, char *op)
QWindowGeometrySpecification QWindowGeometrySpecification::fromArgument(const QByteArray &a)
{
- QWindowGeometrySpecification result;
+ QWindowGeometrySpecification result = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER;
int pos = 0;
for (int i = 0; i < 4; ++i) {
char op;
@@ -342,7 +344,7 @@ void QWindowGeometrySpecification::applyTo(QWindow *window) const
}
}
-static QWindowGeometrySpecification windowGeometrySpecification;
+static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER;
/*!
\class QGuiApplication
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 38cc9506ee..c23dbbb3be 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1267,7 +1267,28 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
if ((key & Qt::KeypadModifier) == Qt::KeypadModifier)
addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format);
+ QString p = keyName(key, format);
+#if defined(Q_OS_OSX)
+ if (nativeText)
+ s += p;
+ else
+#endif
+ addKey(s, p, format);
+ return s;
+}
+
+/*!
+ \internal
+ Returns the text representation of the key \a key, which can be used i.e.
+ when the sequence is serialized. This does not take modifiers into account
+ (see encodeString() for a version that does).
+
+ This static method is used by encodeString() and by the D-Bus menu exporter.
+*/
+QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat format)
+{
+ bool nativeText = (format == QKeySequence::NativeText);
key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier);
QString p;
@@ -1318,14 +1339,7 @@ NonSymbol:
}
}
}
-
-#if defined(Q_OS_MACX)
- if (nativeText)
- s += p;
- else
-#endif
- addKey(s, p, format);
- return s;
+ return p;
}
/*!
Matches the sequence with \a seq. Returns ExactMatch if
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index 492546616b..eeea0f5772 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -81,6 +81,8 @@ public:
QAtomicInt ref;
int key[MaxKeyCount];
static QString encodeString(int key, QKeySequence::SequenceFormat format);
+ // used in dbusmenu
+ Q_GUI_EXPORT static QString keyName(int key, QKeySequence::SequenceFormat format);
static int decodeString(const QString &keyStr, QKeySequence::SequenceFormat format);
};
#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index e7f7f230f1..c8cf7ddb91 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -983,7 +983,7 @@ void QWindow::setMask(const QRegion &region)
Q_D(QWindow);
if (!d->platformWindow)
return;
- d->platformWindow->setMask(region);
+ d->platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, this));
d->mask = region;
}
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 0915fb763a..dcfa3f0647 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -1945,9 +1945,10 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
// intermediate_buffer[0] is a buffer of red-blue component of the pixel, in the form 0x00RR00BB
// intermediate_buffer[1] is the alpha-green component of the pixel, in the form 0x00AA00GG
+ // +1 for the last pixel to interpolate with, and +1 for rounding errors.
quint32 intermediate_buffer[2][buffer_size + 2];
// count is the size used in the intermediate_buffer.
- int count = qCeil(length * data->m11) + 2; //+1 for the last pixel to interpolate with, and +1 for rounding errors.
+ int count = (qint64(length) * fdx + fixed_scale - 1) / fixed_scale + 2;
Q_ASSERT(count <= buffer_size + 2); //length is supposed to be <= buffer_size and data->m11 < 1 in this case
int f = 0;
int lim = count;
@@ -2455,12 +2456,13 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
// The idea is first to do the interpolation between the row s1 and the row s2
// into an intermediate buffer, then we interpolate between two pixel of this buffer.
FetchPixelsFunc fetch = qFetchPixels[layout->bpp];
+ // +1 for the last pixel to interpolate with, and +1 for rounding errors.
uint buf1[buffer_size + 2];
uint buf2[buffer_size + 2];
const uint *ptr1;
const uint *ptr2;
- int count = qCeil(length * data->m11) + 2; //+1 for the last pixel to interpolate with, and +1 for rounding errors.
+ int count = (qint64(length) * fdx + fixed_scale - 1) / fixed_scale + 2;
Q_ASSERT(count <= buffer_size + 2); //length is supposed to be <= buffer_size and data->m11 < 1 in this case
if (blendType == BlendTransformedBilinearTiled) {
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index dbae48a7ee..52bf44c64a 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1009,7 +1009,8 @@ void QPdfEngine::drawHyperlink(const QRectF &r, const QUrl &url)
const uint annot = d->addXrefEntry(-1);
const QByteArray urlascii = url.toEncoded();
int len = urlascii.size();
- QVarLengthArray<char> url_esc(0);
+ QVarLengthArray<char> url_esc;
+ url_esc.reserve(len + 1);
for (int j = 0; j < len; j++) {
if (urlascii[j] == '(' || urlascii[j] == ')' || urlascii[j] == '\\')
url_esc.append('\\');
@@ -2013,10 +2014,11 @@ int QPdfEnginePrivate::createShadingFunction(const QGradient *gradient, int from
}
QVector<QGradientBound> gradientBounds;
+ gradientBounds.reserve((to - from) * (numStops - 1));
for (int step = from; step < to; ++step) {
if (reflect && step % 2) {
- for (int i = stops.size() - 1; i > 0; --i) {
+ for (int i = numStops - 1; i > 0; --i) {
QGradientBound b;
b.start = step + 1 - qBound(qreal(0.), stops.at(i).first, qreal(1.));
b.stop = step + 1 - qBound(qreal(0.), stops.at(i - 1).first, qreal(1.));
@@ -2025,7 +2027,7 @@ int QPdfEnginePrivate::createShadingFunction(const QGradient *gradient, int from
gradientBounds << b;
}
} else {
- for (int i = 0; i < stops.size() - 1; ++i) {
+ for (int i = 0; i < numStops - 1; ++i) {
QGradientBound b;
b.start = step + qBound(qreal(0.), stops.at(i).first, qreal(1.));
b.stop = step + qBound(qreal(0.), stops.at(i + 1).first, qreal(1.));
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index b680bb4717..32cf1b0e83 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -697,7 +697,9 @@ static QStringList familyList(const QFontDef &req)
return family_list;
QStringList list = req.family.split(QLatin1Char(','));
- for (int i = 0; i < list.size(); ++i) {
+ const int numFamilies = list.size();
+ family_list.reserve(numFamilies);
+ for (int i = 0; i < numFamilies; ++i) {
QString str = list.at(i).trimmed();
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|| (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
@@ -1613,6 +1615,7 @@ QStringList QFontDatabase::styles(const QString &family) const
}
}
+ l.reserve(allStyles.count);
for (int i = 0; i < allStyles.count; i++) {
l.append(allStyles.styles[i]->styleName.isEmpty() ?
styleStringHelper(allStyles.styles[i]->key.weight,
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 82695ef1f3..34db39e4a8 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -1165,7 +1165,6 @@ QByteArray QFontSubset::toTruetype() const
qreal ppem = fontEngine->fontDef.pixelSize;
#define TO_TTF(x) qRound(x * 2048. / ppem)
- QVector<QTtfGlyph> glyphs;
QFontEngine::Properties properties = fontEngine->properties();
// initialize some stuff needed in createWidthArray
@@ -1200,12 +1199,13 @@ QByteArray QFontSubset::toTruetype() const
font.maxp.maxCompositeContours = 0;
font.maxp.maxComponentElements = 0;
font.maxp.maxComponentDepth = 0;
- font.maxp.numGlyphs = nGlyphs();
-
-
+ const int numGlyphs = nGlyphs();
+ font.maxp.numGlyphs = numGlyphs;
+ QVector<QTtfGlyph> glyphs;
+ glyphs.reserve(numGlyphs);
uint sumAdvances = 0;
- for (int i = 0; i < nGlyphs(); ++i) {
+ for (int i = 0; i < numGlyphs; ++i) {
glyph_t g = glyph_indices.at(i);
QPainterPath path;
glyph_metrics_t metric;
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 40689afd9a..d8e12f7024 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1935,13 +1935,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
decl.d->propertyId = QCss::FontFamily;
QVector<QCss::Value> values;
val.type = QCss::Value::String;
- val.variant = QLatin1String("Courier New");
- values << val;
- val.type = QCss::Value::TermOperatorComma;
- val.variant = QVariant();
- values << val;
- val.type = QCss::Value::String;
- val.variant = QLatin1String("courier");
+ val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
values << val;
decl.d->values = values;
decl.d->inheritable = true;