summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-09-25 14:02:04 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-09-25 14:02:04 +0200
commita1ad9a74ebb3c556c5f70f7e03be68b09598ac53 (patch)
tree615a96db418219a57a745a5899e39a9ac90744ec /src/gui
parent6d78b7a0c46ea04f4bb771d960e2f7dff1362341 (diff)
parent462f355e4fb16cc7a1838fa2dda0f763eee58c84 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/io/io.pri src/corelib/io/qdatastream.cpp src/corelib/io/qdatastream.h src/network/socket/qabstractsocket.cpp src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h src/widgets/styles/qgtkstyle.cpp tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro tests/auto/dbus/qdbusconnection/qdbusconnection.pro tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp Change-Id: I347549a024eb5bfa986699e0a11f96cc55c797a7
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp1
-rw-r--r--src/gui/image/qbmphandler.cpp6
-rw-r--r--src/gui/image/qiconengine.cpp7
-rw-r--r--src/gui/image/qiconengine.h1
-rw-r--r--src/gui/image/qimage.cpp11
-rw-r--r--src/gui/kernel/qevent.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp48
-rw-r--r--src/gui/kernel/qguiapplication.h2
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp8
-rw-r--r--src/gui/kernel/qopenglcontext.cpp16
-rw-r--r--src/gui/kernel/qopenglcontext.h2
-rw-r--r--src/gui/kernel/qopenglcontext_p.h2
-rw-r--r--src/gui/kernel/qplatformcursor.cpp2
-rw-r--r--src/gui/kernel/qplatformcursor.h2
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp5
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h5
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory.cpp46
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory_p.h1
-rw-r--r--src/gui/kernel/qplatformintegration.cpp39
-rw-r--r--src/gui/kernel/qplatformintegration.h4
-rw-r--r--src/gui/kernel/qplatformscreen.cpp2
-rw-r--r--src/gui/kernel/qplatformwindow.cpp11
-rw-r--r--src/gui/kernel/qplatformwindow.h1
-rw-r--r--src/gui/kernel/qscreen.cpp2
-rw-r--r--src/gui/kernel/qshortcutmap.cpp12
-rw-r--r--src/gui/kernel/qshortcutmap_p.h4
-rw-r--r--src/gui/kernel/qsimpledrag.cpp6
-rw-r--r--src/gui/kernel/qtouchdevice.cpp11
-rw-r--r--src/gui/kernel/qtouchdevice_p.h1
-rw-r--r--src/gui/kernel/qwindow.cpp2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp159
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h9
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h3
-rw-r--r--src/gui/opengl/qopenglengineshadermanager.cpp3
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp8
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp165
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp17
-rw-r--r--src/gui/painting/qdrawhelper.cpp6
-rw-r--r--src/gui/painting/qimagescale.cpp5
-rw-r--r--src/gui/painting/qpaintdevice.h2
-rw-r--r--src/gui/painting/qpaintdevice.qdoc8
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp7
-rw-r--r--src/gui/painting/qrasterizer.cpp28
-rw-r--r--src/gui/painting/qrgba64.h65
-rw-r--r--src/gui/painting/qrgba64.qdoc64
-rw-r--r--src/gui/text/qfont.cpp8
-rw-r--r--src/gui/text/qfontengine.cpp308
-rw-r--r--src/gui/text/qfontengine_ft.cpp49
-rw-r--r--src/gui/text/qfontengine_ft_p.h4
-rw-r--r--src/gui/text/qfontengine_p.h10
-rw-r--r--src/gui/text/qfontengine_qpf2.cpp10
-rw-r--r--src/gui/text/qtextengine_p.h16
-rw-r--r--src/gui/text/qtextlayout.cpp90
-rw-r--r--src/gui/text/qzip.cpp6
54 files changed, 872 insertions, 440 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 50a4a09102..e9995045b1 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -451,7 +451,6 @@ QAccessibleInterface::~QAccessibleInterface()
/*!
\typedef QAccessible::Id
- \relates QAccessible
Synonym for unsigned, used by the QAccessibleInterface cache.
*/
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index f124cede36..ef12b23caa 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -212,6 +212,9 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
int blue_scale = 0;
int alpha_scale = 0;
+ if (!d->isSequential())
+ d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4 ? BMP_WIN : bi.biSize)); // goto start of colormap or masks
+
if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) {
if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
return false;
@@ -299,9 +302,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
image.setDotsPerMeterX(bi.biXPelsPerMeter);
image.setDotsPerMeterY(bi.biYPelsPerMeter);
- if (!d->isSequential())
- d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
-
if (ncols > 0) { // read color table
uchar rgb[4];
int rgb_len = t == BMP_OLD ? 3 : 4;
diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp
index 49a3bead53..7411dbb054 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/gui/image/qiconengine.cpp
@@ -77,6 +77,13 @@ QSize QIconEngine::actualSize(const QSize &size, QIcon::Mode /*mode*/, QIcon::St
return size;
}
+/*!
+ \since 5.6
+ Constructs the icon engine.
+ */
+QIconEngine::QIconEngine()
+{
+}
/*!
Destroys the icon engine.
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index f0ff143b36..6c45cd216f 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -44,6 +44,7 @@ QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QIconEngine
{
public:
+ QIconEngine();
virtual ~QIconEngine();
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index aea6fc133f..7f2504ddd9 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2209,12 +2209,12 @@ int QImage::pixelIndex(int x, int y) const
*/
QRgb QImage::pixel(int x, int y) const
{
- if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) {
+ if (!d || x < 0 || x >= d->width || y < 0 || y >= d->height) {
qWarning("QImage::pixel: coordinate (%d,%d) out of range", x, y);
return 12345;
}
- const uchar * s = constScanLine(y);
+ const uchar *s = d->data + y * d->bytes_per_line;
switch(d->format) {
case Format_Mono:
return d->colortable.at((*(s + (x >> 3)) >> (~x & 7)) & 1);
@@ -4237,9 +4237,6 @@ QImage QImage::alphaChannel() const
if (!d)
return QImage();
- if (d->format == QImage::Format_Alpha8)
- return *this;
-
int w = d->width;
int h = d->height;
@@ -4269,6 +4266,10 @@ QImage QImage::alphaChannel() const
src_data += d->bytes_per_line;
dest_data += image.d->bytes_per_line;
}
+ } else if (d->format == Format_Alpha8) {
+ const uchar *src_data = d->data;
+ uchar *dest_data = image.d->data;
+ memcpy(dest_data, src_data, d->bytes_per_line * h);
} else {
QImage alpha32 = *this;
bool canSkipConversion = (d->format == Format_ARGB32 || d->format == Format_ARGB32_Premultiplied);
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index c7df6107f7..26a0ab5c0f 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -171,6 +171,8 @@ QInputEvent::~QInputEvent()
\fn ulong QInputEvent::timestamp() const
Returns the window system's timestamp for this event.
+ It will normally be in milliseconds since some arbitrary point
+ in time, such as the time when the system was started.
*/
/*! \fn void QInputEvent::setTimestamp(ulong atimestamp)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 898f14f8cb..c168a2bccc 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -99,6 +99,9 @@
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
# include <QtCore/qt_windows.h>
# include <QtCore/QLibraryInfo>
+# if defined(Q_OS_WINPHONE)
+# include <Objbase.h>
+# endif
#endif // Q_OS_WIN && !Q_OS_WINCE
#include <ctype.h>
@@ -450,8 +453,7 @@ static QWindowGeometrySpecification windowGeometrySpecification;
\row
\li Miscellaneous
\li startingUp(),
- closingDown(),
- type().
+ closingDown().
\endtable
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop
@@ -907,16 +909,6 @@ QWindowList QGuiApplication::topLevelWindows()
return topLevelWindows;
}
-/*!
- Returns the primary (or default) screen of the application, or null if there is none
-
- This will be the screen where QWindows are initially shown, unless otherwise specified.
-
- On some platforms, it may be null when there are actually no screens connected.
- It is not possible to start a new QGuiApplication while there are no screens.
- Applications which were running at the time the primary screen was removed
- will stop rendering graphics until one or more screens are restored.
-*/
QScreen *QGuiApplication::primaryScreen()
{
if (QGuiApplicationPrivate::screen_list.isEmpty())
@@ -938,7 +930,7 @@ QList<QScreen *> QGuiApplication::screens()
This signal is emitted whenever a new screen \a screen has been added to the system.
- \sa screens(), primaryScreen(), screenRemoved()
+ \sa screens(), primaryScreen, screenRemoved()
*/
/*!
@@ -955,6 +947,23 @@ QList<QScreen *> QGuiApplication::screens()
/*!
+ \property QGuiApplication::primaryScreen
+
+ \brief the primary (or default) screen of the application, or null if there is none.
+
+ This will be the screen where QWindows are initially shown, unless otherwise specified.
+
+ On some platforms, it may be null when there are actually no screens connected.
+ It is not possible to start a new QGuiApplication while there are no screens.
+ Applications which were running at the time the primary screen was removed
+ will stop rendering graphics until one or more screens are restored.
+
+ The primaryScreenChanged signal was introduced in Qt 5.6.
+
+ \sa screens()
+*/
+
+/*!
Returns the highest screen device pixel ratio found on
the system. This is the ratio between physical pixels and
device-independent pixels.
@@ -1257,6 +1266,16 @@ void QGuiApplicationPrivate::init()
#ifndef QT_NO_SESSIONMANAGER
QString session_id;
QString session_key;
+# if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ wchar_t guidstr[40];
+ GUID guid;
+ CoCreateGuid(&guid);
+ StringFromGUID2(guid, guidstr, 40);
+ session_id = QString::fromWCharArray(guidstr);
+ CoCreateGuid(&guid);
+ StringFromGUID2(guid, guidstr, 40);
+ session_key = QString::fromWCharArray(guidstr);
+# endif
#endif
int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) {
@@ -1738,7 +1757,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
// should first send a move event followed by a button changed event. Since this is not the case
// with the current event, we split it in two.
QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(
- e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers);
+ e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers, e->source);
if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
e->buttons = buttons;
@@ -1834,6 +1853,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
}
QGuiApplication::sendSpontaneousEvent(window, &ev);
+ e->eventAccepted = ev.isAccepted();
if (!e->synthetic() && !ev.isAccepted()
&& !frameStrut
&& qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 6eb26e8b06..a773122d3e 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -71,6 +71,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(QString platformName READ platformName STORED false)
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
+ Q_PROPERTY(QScreen *primaryScreen READ primaryScreen NOTIFY primaryScreenChanged STORED false)
public:
#ifdef Q_QDOC
@@ -162,6 +163,7 @@ Q_SIGNALS:
void fontDatabaseChanged();
void screenAdded(QScreen *screen);
void screenRemoved(QScreen *screen);
+ void primaryScreenChanged(QScreen *screen);
void lastWindowClosed();
void focusObjectChanged(QObject *focusObject);
void focusWindowChanged(QWindow *focusWindow);
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index de586ac46c..daba9f94a1 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -62,10 +62,10 @@ static inline qreal initialScaleFactor()
}
} else {
if (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)) {
- qWarning() << "Warning:" << legacyDevicePixelEnvVar << "is deprecated. Instead use:";
- qWarning() << " " << autoScreenEnvVar << "to enable platform plugin controlled per-screen factors.";
- qWarning() << " " << screenFactorsEnvVar << "to set per-screen factors.";
- qWarning() << " " << scaleFactorEnvVar << "to set the application global scale factor.";
+ qWarning() << "Warning:" << legacyDevicePixelEnvVar << "is deprecated. Instead use:" << endl
+ << " " << autoScreenEnvVar << "to enable platform plugin controlled per-screen factors." << endl
+ << " " << screenFactorsEnvVar << "to set per-screen factors." << endl
+ << " " << scaleFactorEnvVar << "to set the application global scale factor.";
int dpr = qEnvironmentVariableIntValue(legacyDevicePixelEnvVar);
if (dpr > 0)
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 9e5767658f..85d05959de 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -462,8 +462,7 @@ QPlatformOpenGLContext *QOpenGLContext::shareHandle() const
QOpenGLContext::QOpenGLContext(QObject *parent)
: QObject(*new QOpenGLContextPrivate(), parent)
{
- Q_D(QOpenGLContext);
- d->screen = QGuiApplication::primaryScreen();
+ setScreen(QGuiApplication::primaryScreen());
}
/*!
@@ -499,9 +498,20 @@ void QOpenGLContext::setShareContext(QOpenGLContext *shareContext)
void QOpenGLContext::setScreen(QScreen *screen)
{
Q_D(QOpenGLContext);
+ if (d->screen)
+ disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
d->screen = screen;
if (!d->screen)
d->screen = QGuiApplication::primaryScreen();
+ if (d->screen)
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
+}
+
+void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object)
+{
+ Q_Q(QOpenGLContext);
+ if (object == static_cast<QObject *>(screen))
+ q->setScreen(0);
}
/*!
@@ -1626,4 +1636,6 @@ void QOpenGLMultiGroupSharedResource::cleanup(QOpenGLContextGroup *group, QOpenG
m_groups.removeOne(group);
}
+#include "moc_qopenglcontext.cpp"
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index 85e7abfa26..841967a545 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -241,6 +241,8 @@ private:
void setTextureFunctions(QOpenGLTextureHelper* textureFuncs);
void destroy();
+
+ Q_PRIVATE_SLOT(d_func(), void _q_screenDestroyed(QObject *object))
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index f9f3ce2c5f..4a746bf12b 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -270,6 +270,8 @@ public:
static QHash<QOpenGLContext *, bool> makeCurrentTracker;
static QMutex makeCurrentTrackerMutex;
#endif
+
+ void _q_screenDestroyed(QObject *object);
};
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index 7239ac7ba4..cd43fc42fe 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h
index 4f4f9cc6ae..8c788fd27b 100644
--- a/src/gui/kernel/qplatformcursor.h
+++ b/src/gui/kernel/qplatformcursor.h
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 25894fd504..f69efe0935 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -119,6 +119,8 @@ static const int buttonRoleLayouts[2][5][14] =
QPlatformDialogHelper::QPlatformDialogHelper()
{
+ qRegisterMetaType<StandardButton>();
+ qRegisterMetaType<ButtonRole>();
}
QPlatformDialogHelper::~QPlatformDialogHelper()
@@ -651,12 +653,13 @@ void QPlatformFileDialogHelper::setOptions(const QSharedPointer<QFileDialogOptio
}
const char *QPlatformFileDialogHelper::filterRegExp =
-"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
+"^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
{
QRegExp regexp(QString::fromLatin1(filterRegExp));
+ Q_ASSERT(regexp.isValid());
QString f = filter;
int i = regexp.indexIn(f);
if (i >= 0)
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index ec88770862..936dbdfa89 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -160,6 +160,11 @@ Q_SIGNALS:
void reject();
};
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QPlatformDialogHelper::StandardButton)
+Q_DECLARE_METATYPE(QPlatformDialogHelper::ButtonRole)
+QT_BEGIN_NAMESPACE
+
class Q_GUI_EXPORT QColorDialogOptions
{
public:
diff --git a/src/gui/kernel/qplatforminputcontextfactory.cpp b/src/gui/kernel/qplatforminputcontextfactory.cpp
index a7660e76ae..fedf940dda 100644
--- a/src/gui/kernel/qplatforminputcontextfactory.cpp
+++ b/src/gui/kernel/qplatforminputcontextfactory.cpp
@@ -56,48 +56,34 @@ QStringList QPlatformInputContextFactory::keys()
#endif
}
-QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
+QString QPlatformInputContextFactory::requested()
{
- QStringList paramList = key.split(QLatin1Char(':'));
- const QString platform = paramList.takeFirst().toLower();
-
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- if (QPlatformInputContext *ret = qLoadPlugin1<QPlatformInputContext, QPlatformInputContextPlugin>(loader(), platform, paramList))
- return ret;
-#endif
- return 0;
+ QByteArray env = qgetenv("QT_IM_MODULE");
+ return env.isNull() ? QString() : QString::fromLocal8Bit(env);
}
-QPlatformInputContext *QPlatformInputContextFactory::create()
+QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
{
- QPlatformInputContext *ic = 0;
-
- QString icString = QString::fromLatin1(qgetenv("QT_IM_MODULE"));
-
- if (icString == QLatin1String("none"))
- return 0;
-
- ic = create(icString);
- if (ic && ic->isValid())
- return ic;
-
- delete ic;
- ic = 0;
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ if (!key.isEmpty()) {
+ QStringList paramList = key.split(QLatin1Char(':'));
+ const QString platform = paramList.takeFirst().toLower();
- QStringList k = keys();
- for (int i = 0; i < k.size(); ++i) {
- if (k.at(i) == icString)
- continue;
- ic = create(k.at(i));
+ QPlatformInputContext *ic = qLoadPlugin1<QPlatformInputContext, QPlatformInputContextPlugin>
+ (loader(), platform, paramList);
if (ic && ic->isValid())
return ic;
+
delete ic;
- ic = 0;
}
-
+#endif
return 0;
}
+QPlatformInputContext *QPlatformInputContextFactory::create()
+{
+ return create(requested());
+}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatforminputcontextfactory_p.h b/src/gui/kernel/qplatforminputcontextfactory_p.h
index a74c4f5f80..38f4358287 100644
--- a/src/gui/kernel/qplatforminputcontextfactory_p.h
+++ b/src/gui/kernel/qplatforminputcontextfactory_p.h
@@ -56,6 +56,7 @@ class Q_GUI_EXPORT QPlatformInputContextFactory
{
public:
static QStringList keys();
+ static QString requested();
static QPlatformInputContext *create(const QString &key);
static QPlatformInputContext *create();
};
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index e935907a62..457a420148 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -456,6 +456,24 @@ void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary)
QGuiApplicationPrivate::screen_list.append(screen);
}
emit qGuiApp->screenAdded(screen);
+
+ if (isPrimary)
+ emit qGuiApp->primaryScreenChanged(screen);
+}
+
+/*!
+ Just removes the screen, call destroyScreen instead.
+
+ \sa destroyScreen()
+*/
+
+void QPlatformIntegration::removeScreen(QScreen *screen)
+{
+ const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list[0] == screen);
+ QGuiApplicationPrivate::screen_list.removeOne(screen);
+
+ if (wasPrimary && qGuiApp && !QGuiApplicationPrivate::screen_list.isEmpty())
+ emit qGuiApp->primaryScreenChanged(QGuiApplicationPrivate::screen_list[0]);
}
/*!
@@ -469,11 +487,30 @@ void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary)
void QPlatformIntegration::destroyScreen(QPlatformScreen *screen)
{
QScreen *qScreen = screen->screen();
- QGuiApplicationPrivate::screen_list.removeOne(qScreen);
+ removeScreen(qScreen);
delete qScreen;
delete screen;
}
+/*!
+ Should be called whenever the primary screen changes.
+
+ When the screen specified as primary changes, this method will notify
+ QGuiApplication and emit the QGuiApplication::primaryScreenChanged signal.
+ */
+
+void QPlatformIntegration::setPrimaryScreen(QPlatformScreen *newPrimary)
+{
+ QScreen* newPrimaryScreen = newPrimary->screen();
+ int idx = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen);
+ Q_ASSERT(idx >= 0);
+ if (idx == 0)
+ return;
+
+ QGuiApplicationPrivate::screen_list.swap(0, idx);
+ emit qGuiApp->primaryScreenChanged(newPrimaryScreen);
+}
+
QStringList QPlatformIntegration::themeNames() const
{
return QStringList();
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index 2aa502b3d2..00c50a9861 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -172,9 +172,13 @@ public:
virtual QOpenGLContext::OpenGLModuleType openGLModuleType();
#endif
virtual void setApplicationIcon(const QIcon &icon) const;
+
+ void removeScreen(QScreen *screen);
+
protected:
void screenAdded(QPlatformScreen *screen, bool isPrimary = false);
void destroyScreen(QPlatformScreen *screen);
+ void setPrimaryScreen(QPlatformScreen *newPrimary);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index 2fb53fe16b..d1d8eba697 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -56,7 +56,7 @@ QPlatformScreen::~QPlatformScreen()
Q_D(QPlatformScreen);
if (d->screen) {
qWarning("Manually deleting a QPlatformScreen. Call QPlatformIntegration::destroyScreen instead.");
- QGuiApplicationPrivate::screen_list.removeOne(d->screen);
+ QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen);
delete d->screen;
}
}
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 0430d5a4c6..ea3b75c81c 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -702,15 +702,20 @@ QRect QPlatformWindow::windowFrameGeometry() const
a resize/move event for platforms that support it, for example to
implement heightForWidth().
*/
-QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const
+
+QRectF QPlatformWindow::closestAcceptableGeometry(const QWindow *qWindow, const QRectF &nativeRect)
{
- QWindow *qWindow = window();
const QRectF rectF = QHighDpi::fromNativePixels(nativeRect, qWindow);
- const QRectF correctedGeometryF = qt_window_private(qWindow)->closestAcceptableGeometry(rectF);
+ const QRectF correctedGeometryF = qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF);
return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF
? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
}
+QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const
+{
+ return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect);
+}
+
/*!
\class QPlatformWindow
\since 4.8
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index 1b283dbb4f..9c2817906f 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -140,6 +140,7 @@ public:
QRect windowGeometry() const;
QRect windowFrameGeometry() const;
QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const;
+ static QRectF closestAcceptableGeometry(const QWindow *w, const QRectF &nativeRect);
protected:
static QString formatWindowTitle(const QString &title, const QString &separator);
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 407b4ee9b6..b6b50372ae 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -698,7 +698,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)
{
const QDebugStateSaver saver(debug);
debug.nospace();
- debug << "QScreen(" << (void *)screen;
+ debug << "QScreen(" << (const void *)screen;
if (screen) {
debug << ", name=" << screen->name();
if (debug.verbosity() > 2) {
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 0ff5c36119..3e267f2e0b 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -386,9 +386,7 @@ QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e)
result = find(e);
if (result == QKeySequence::NoMatch && (e->modifiers() & Qt::KeypadModifier)) {
// Try to find a match without keypad modifier
- QKeyEvent event = *e;
- event.setModifiers(e->modifiers() & ~Qt::KeypadModifier);
- result = find(&event);
+ result = find(e, Qt::KeypadModifier);
}
if (result == QKeySequence::NoMatch && e->modifiers() & Qt::ShiftModifier) {
// If Shift + Key_Backtab, also try Shift + Qt::Key_Tab
@@ -441,13 +439,13 @@ bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const
which can be access through matches().
\sa matches
*/
-QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e)
+QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifiers)
{
Q_D(QShortcutMap);
if (!d->sequences.count())
return QKeySequence::NoMatch;
- createNewSequences(e, d->newEntries);
+ createNewSequences(e, d->newEntries, ignoredModifiers);
#if defined(DEBUG_QSHORTCUTMAP)
qDebug() << "Possible shortcut key sequences:" << d->newEntries;
#endif
@@ -549,7 +547,7 @@ void QShortcutMap::clearSequence(QVector<QKeySequence> &ksl)
Alters \a seq to the new sequence state, based on the
current sequence state, and the new key event \a e.
*/
-void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl)
+void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl, int ignoredModifiers)
{
Q_D(QShortcutMap);
QList<int> possibleKeys = QKeyMapper::possibleKeys(e);
@@ -579,7 +577,7 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl)
curKsl.setKey(0, 2);
curKsl.setKey(0, 3);
}
- curKsl.setKey(possibleKeys.at(pkNum), index);
+ curKsl.setKey(possibleKeys.at(pkNum) & ~ignoredModifiers, index);
}
}
}
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h
index 242c021ca4..2376d27c78 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/gui/kernel/qshortcutmap_p.h
@@ -88,10 +88,10 @@ private:
QKeySequence::SequenceMatch state();
void dispatchEvent(QKeyEvent *e);
- QKeySequence::SequenceMatch find(QKeyEvent *e);
+ QKeySequence::SequenceMatch find(QKeyEvent *e, int ignoredModifiers = 0);
QKeySequence::SequenceMatch matches(const QKeySequence &seq1, const QKeySequence &seq2) const;
QVector<const QShortcutEntry *> matches() const;
- void createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl);
+ void createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl, int ignoredModifiers);
void clearSequence(QVector<QKeySequence> &ksl);
int translateModifiers(Qt::KeyboardModifiers modifiers);
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 6e574d82e4..b02f1dd8bd 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -149,7 +149,7 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
{
QPoint nativePosition = getNativeMousePos(e, o);
move(nativePosition);
- return true; // Eat all mouse events
+ return true; // Eat all mouse move events
}
case QEvent::MouseButtonRelease:
disableEventFilter();
@@ -160,8 +160,8 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
cancel();
}
exitDndEventLoop();
- return true; // Eat all mouse events
- case QEvent::MouseButtonPress:
+ QCoreApplication::postEvent(o, new QMouseEvent(*static_cast<QMouseEvent *>(e)));
+ return true; // defer mouse release events until drag event loop has returned
case QEvent::MouseButtonDblClick:
case QEvent::Wheel:
return true;
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index 9d19fa4b92..266b5308a2 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -237,6 +237,17 @@ void QTouchDevicePrivate::registerDevice(const QTouchDevice *dev)
deviceList()->append(dev);
}
+/*!
+ \internal
+ */
+void QTouchDevicePrivate::unregisterDevice(const QTouchDevice *dev)
+{
+ QMutexLocker lock(&devicesMutex);
+ bool wasRemoved = deviceList()->removeOne(dev);
+ if (wasRemoved && deviceList()->isEmpty())
+ qRemovePostRoutine(cleanupDevicesList);
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QTouchDevice *device)
{
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index 4aff8f2f33..63b83d33ec 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -65,6 +65,7 @@ public:
int maxTouchPoints;
static void registerDevice(const QTouchDevice *dev);
+ static void unregisterDevice(const QTouchDevice *dev);
static bool isRegistered(const QTouchDevice *dev);
};
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index e93e964c6b..89bd119564 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2508,7 +2508,7 @@ QDebug operator<<(QDebug debug, const QWindow *window)
QDebugStateSaver saver(debug);
debug.nospace();
if (window) {
- debug << window->metaObject()->className() << '(' << (void *)window;
+ debug << window->metaObject()->className() << '(' << (const void *)window;
if (!window->objectName().isEmpty())
debug << ", name=" << window->objectName();
if (debug.verbosity() > 2) {
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 88cf2dac93..faa1ff8068 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -49,6 +49,7 @@ QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false;
QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;
QMutex QWindowSystemInterfacePrivate::flushEventMutex;
+QAtomicInt QWindowSystemInterfacePrivate::eventAccepted;
QWindowSystemEventHandler *QWindowSystemInterfacePrivate::eventHandler;
//------------------------------------------------------------
@@ -323,18 +324,18 @@ bool QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEven
return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text, bool autorep,
ushort count)
{
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
+ return handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
text, autorep, count);
}
-void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,
+bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,
Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
@@ -345,7 +346,7 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods) {
@@ -441,27 +442,60 @@ void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *e
windowSystemEventQueue.remove(event);
}
+void QWindowSystemInterfacePrivate::postWindowSystemEvent(WindowSystemEvent *ev)
+{
+ windowSystemEventQueue.append(ev);
+ QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
+ if (dispatcher)
+ dispatcher->wakeUp();
+}
+
+/*!
+ Handles a window system event.
+
+ By default this function posts the event on the window system event queue and
+ wakes the Gui event dispatcher. Qt Gui will then handle the event asynchonously
+ at a later point. The return value is not used in asynchronous mode and will
+ always be true.
+
+ In synchronous mode Qt Gui will process the event immediately. The return value
+ indicates if Qt accepted the event.
+
+ \sa flushWindowSystemEvents(), setSynchronousWindowSystemEvents()
+*/
bool QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
{
bool accepted = true;
if (synchronousWindowSystemEvents) {
- QGuiApplicationPrivate::processWindowSystemEvent(ev);
- accepted = ev->eventAccepted;
- delete ev;
+ if (QThread::currentThread() == QGuiApplication::instance()->thread()) {
+ // Process the event immediately on the current thread and return the accepted state.
+ QGuiApplicationPrivate::processWindowSystemEvent(ev);
+ accepted = ev->eventAccepted;
+ delete ev;
+ } else {
+ // Post the event on the Qt main thread queue and flush the queue.
+ // This will wake up the Gui thread which will process the event.
+ // Return the accepted state for the last event on the queue,
+ // which is the event posted by this function.
+ postWindowSystemEvent(ev);
+ accepted = QWindowSystemInterface::flushWindowSystemEvents();
+ }
} else {
- windowSystemEventQueue.append(ev);
- QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
- if (dispatcher)
- dispatcher->wakeUp();
+ postWindowSystemEvent(ev);
}
return accepted;
}
-void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device)
+void QWindowSystemInterface::registerTouchDevice(const QTouchDevice *device)
{
QTouchDevicePrivate::registerDevice(device);
}
+void QWindowSystemInterface::unregisterTouchDevice(const QTouchDevice *device)
+{
+ QTouchDevicePrivate::unregisterDevice(device);
+}
+
void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device,
const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
{
@@ -618,26 +652,33 @@ void QWindowSystemInterface::deferredFlushWindowSystemEvents(QEventLoop::Process
QWindowSystemInterfacePrivate::eventsFlushed.wakeOne();
}
-void QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
+/*!
+ Make Qt Gui process all events on the event queue immediately. Return the
+ accepted state for the last event on the queue.
+*/
+bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
{
const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
if (!count)
- return;
+ return false;
if (!QGuiApplication::instance()) {
qWarning().nospace()
<< "QWindowSystemInterface::flushWindowSystemEvents() invoked after "
"QGuiApplication destruction, discarding " << count << " events.";
QWindowSystemInterfacePrivate::windowSystemEventQueue.clear();
- return;
+ return false;
}
if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
+ // Post a FlushEvents event which will trigger a call back to
+ // deferredFlushWindowSystemEvents from the Gui thread.
QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ QWindowSystemInterfacePrivate::postWindowSystemEvent(e);
QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);
} else {
sendWindowSystemEvents(flags);
}
+ return QWindowSystemInterfacePrivate::eventAccepted.load() > 0;
}
bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
@@ -659,6 +700,13 @@ bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFla
nevents++;
QGuiApplicationPrivate::processWindowSystemEvent(event);
}
+
+ // Record the accepted state for the processed event
+ // (excluding flush events). This state can then be
+ // returned by flushWindowSystemEvents().
+ if (event->type != QWindowSystemInterfacePrivate::FlushEvents)
+ QWindowSystemInterfacePrivate::eventAccepted.store(event->eventAccepted);
+
delete event;
}
@@ -858,26 +906,23 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo
}
#endif
+// The following functions are used by testlib, and need to be synchronous to avoid
+// race conditions with plugins delivering native events from secondary threads.
+
Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp)
{
- QWindowSystemInterfacePrivate::MouseEvent e(w, timestamp, local, global, b, mods, Qt::MouseEventNotSynthesized);
- QGuiApplicationPrivate::processWindowSystemEvent(&e);
+ bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;
+ QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
+ QWindowSystemInterface::handleMouseEvent(w, timestamp, local, global, b, mods);
+ QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);
}
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
{
- unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
-
- // This is special handling needed for OS X which eventually will call sendEvent(), on other platforms
- // this might not be safe, e.g., on Android. See: QGuiApplicationPrivate::processKeyEvent() for
- // shortcut overriding on other platforms.
-#if defined(Q_OS_OSX)
- if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(w, timestamp, k, mods, text))
- return;
-#endif // Q_OS_OSX
-
- QWindowSystemInterfacePrivate::KeyEvent e(w, timestamp, t, k, mods, text, autorep, count);
- QGuiApplicationPrivate::processWindowSystemEvent(&e);
+ bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;
+ QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
+ QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count);
+ QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);
}
Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1)
@@ -885,37 +930,37 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int
return QWindowSystemInterface::tryHandleShortcutEventToObject(o, timestamp, k, mods, text, autorep, count);
}
-Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
- const QList<QTouchEvent::TouchPoint> &points,
- Qt::KeyboardModifiers mods = Qt::NoModifier)
+static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
{
- unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
-
- if (!points.size()) // Touch events must have at least one point
- return;
-
- if (!QTouchDevicePrivate::isRegistered(device)) // Disallow passing bogus, non-registered devices.
- return;
-
- QEvent::Type type;
- Qt::TouchPointStates states;
+ QWindowSystemInterface::TouchPoint p;
+ p.id = pt.id();
+ p.flags = pt.flags();
+ p.normalPosition = pt.normalizedPos();
+ p.area = pt.screenRect();
+ p.pressure = pt.pressure();
+ p.state = pt.state();
+ p.velocity = pt.velocity();
+ p.rawPositions = pt.rawScreenPositions();
+ return p;
+}
+static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
+{
+ QList<struct QWindowSystemInterface::TouchPoint> newList;
- QList<QTouchEvent::TouchPoint>::const_iterator point = points.constBegin();
- QList<QTouchEvent::TouchPoint>::const_iterator end = points.constEnd();
- while (point != end) {
- states |= point->state();
- ++point;
- }
+ Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
+ newList.append(touchPoint(p));
- // Determine the event type based on the combined point states.
- type = QEvent::TouchUpdate;
- if (states == Qt::TouchPointPressed)
- type = QEvent::TouchBegin;
- else if (states == Qt::TouchPointReleased)
- type = QEvent::TouchEnd;
+ return newList;
+}
- QWindowSystemInterfacePrivate::TouchEvent e(w, timestamp, type, device, points, mods);
- QGuiApplicationPrivate::processWindowSystemEvent(&e);
+Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
+ const QList<QTouchEvent::TouchPoint> &points,
+ Qt::KeyboardModifiers mods = Qt::NoModifier)
+{
+ bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;
+ QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
+ QWindowSystemInterface::handleTouchEvent(w, device, touchPointList(points), mods);
+ QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);
}
QWindowSystemEventHandler::~QWindowSystemEventHandler()
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index ace1a4fe24..97bd087b53 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -98,12 +98,12 @@ public:
static bool handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
static bool handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
- static void handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ static bool handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
ushort count = 1);
- static void handleExtendedKeyEvent(QWindow *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ static bool handleExtendedKeyEvent(QWindow *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
@@ -127,7 +127,8 @@ public:
QVector<QPointF> rawPositions; // in screen coordinates
};
- static void registerTouchDevice(QTouchDevice *device);
+ static void registerTouchDevice(const QTouchDevice *device);
+ static void unregisterTouchDevice(const QTouchDevice *device);
static void handleTouchEvent(QWindow *w, QTouchDevice *device,
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
static void handleTouchEvent(QWindow *w, ulong timestamp, QTouchDevice *device,
@@ -213,7 +214,7 @@ public:
// For event dispatcher implementations
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
static void setSynchronousWindowSystemEvents(bool enable);
- static void flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
+ static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
static int windowSystemEventsQueued();
};
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index cc0ca6bf81..e48d1e965b 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -51,6 +51,7 @@
#include <QMutex>
#include <QList>
#include <QWaitCondition>
+#include <QAtomicInt>
QT_BEGIN_NAMESPACE
@@ -481,6 +482,7 @@ public:
static WindowSystemEvent *getNonUserInputWindowSystemEvent();
static WindowSystemEvent *peekWindowSystemEvent(EventType t);
static void removeWindowSystemEvent(WindowSystemEvent *event);
+ static void postWindowSystemEvent(WindowSystemEvent *ev);
static bool handleWindowSystemEvent(WindowSystemEvent *ev);
static QElapsedTimer eventTime;
@@ -488,6 +490,7 @@ public:
static QWaitCondition eventsFlushed;
static QMutex flushEventMutex;
+ static QAtomicInt eventAccepted;
static QList<QTouchEvent::TouchPoint>
fromNativeTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points,
diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp
index 7e53c01cba..40f4ce94c2 100644
--- a/src/gui/opengl/qopenglengineshadermanager.cpp
+++ b/src/gui/opengl/qopenglengineshadermanager.cpp
@@ -427,11 +427,10 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO
if (!inCache)
shaderCache.store(newProg->program, QOpenGLContext::currentContext());
} else {
- QLatin1String none("none");
- QLatin1String br("\n");
QString error;
error = QLatin1String("Shader program failed to link,");
#if defined(QT_DEBUG)
+ QLatin1String br("\n");
error += QLatin1String("\n Shaders Used:\n");
for (int i = 0; i < newProg->program->shaders().count(); ++i) {
QOpenGLShader *shader = newProg->program->shaders().at(i);
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 3596591cf6..0e162713ce 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -951,8 +951,8 @@ QOpenGLFramebufferObject::~QOpenGLFramebufferObject()
}
/*!
- Creates and attaches an additional texture or renderbuffer of size \a width
- and \a height.
+ Creates and attaches an additional texture or renderbuffer of \a size width
+ and height.
There is always an attachment at GL_COLOR_ATTACHMENT0. Call this function
to set up additional attachments at GL_COLOR_ATTACHMENT1,
@@ -1142,7 +1142,7 @@ GLuint QOpenGLFramebufferObject::texture() const
\since 5.6
- \sa takeTextures(), texture()
+ \sa takeTexture(), texture()
*/
QVector<GLuint> QOpenGLFramebufferObject::textures() const
{
@@ -1172,7 +1172,7 @@ QVector<GLuint> QOpenGLFramebufferObject::textures() const
\since 5.3
- \sa texture(), bind(), release(), takeTextures()
+ \sa texture(), bind(), release()
*/
GLuint QOpenGLFramebufferObject::takeTexture()
{
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 668eaa9a89..d614ad8401 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -3701,7 +3701,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
- Convenience function that calls glCopyBufferSubData(\a readTarget, writeTarget, \a readOffset, \a writeOffset, \a size).
+ Convenience function that calls glCopyBufferSubData(\a readTarget, \a writeTarget, \a readOffset, \a writeOffset, \a size).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -3855,7 +3855,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
*/
/*!
- \fn void QOpenGLExtraFunctions::glEndTransformFeedback()
+ \fn void QOpenGLExtraFunctions::glEndTransformFeedback(void)
Convenience function that calls glEndTransformFeedback().
@@ -4362,7 +4362,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
*/
/*!
- \fn void QOpenGLExtraFunctions::glPauseTransformFeedback()
+ \fn void QOpenGLExtraFunctions::glPauseTransformFeedback(void)
Convenience function that calls glPauseTransformFeedback().
@@ -4427,7 +4427,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
*/
/*!
- \fn void QOpenGLExtraFunctions::glResumeTransformFeedback()
+ \fn void QOpenGLExtraFunctions::glResumeTransformFeedback(void)
Convenience function that calls glResumeTransformFeedback().
@@ -4455,7 +4455,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat * param)
- Convenience function that calls glSamplerParameterfv(\a sampler, pname, \a param).
+ Convenience function that calls glSamplerParameterfv(\a sampler, \a pname, \a param).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4624,7 +4624,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glUniform3uiv(GLint location, GLsizei count, const GLuint * value)
- Convenience function that calls glUniform3uiv(\a location, count, \a value).
+ Convenience function that calls glUniform3uiv(\a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4858,7 +4858,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glActiveShaderProgram(GLuint pipeline, GLuint program)
- Convenience function that calls glActiveShaderProgram(pipeline, program).
+ Convenience function that calls glActiveShaderProgram(\a pipeline, \a program).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4869,9 +4869,9 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
*/
/*!
- \fn void QOpenGLFunctions::glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format)
+ \fn void QOpenGLExtraFunctions::glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format)
- Convenience function that calls glBindImageTexture(unit, texture, level, layered, layer, access, format).
+ Convenience function that calls glBindImageTexture(\a unit, \a texture, \a level, \a layered, \a layer, \a access, \a format).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4884,7 +4884,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glBindProgramPipeline(GLuint pipeline)
- Convenience function that calls glBindProgramPipeline(pipeline).
+ Convenience function that calls glBindProgramPipeline(\a pipeline).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4897,7 +4897,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glBindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride)
- Convenience function that calls glBindVertexBuffer(bindingindex, buffer, offset, stride).
+ Convenience function that calls glBindVertexBuffer(\a bindingindex, \a buffer, \a offset, \a stride).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4910,7 +4910,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn GLuint QOpenGLExtraFunctions::glCreateShaderProgramv(GLenum type, GLsizei count, const GLchar *const* strings)
- Convenience function that calls glCreateShaderProgramv(type, count, strings).
+ Convenience function that calls glCreateShaderProgramv(\a type, \a count, \a strings).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4923,7 +4923,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glDeleteProgramPipelines(GLsizei n, const GLuint * pipelines)
- Convenience function that calls glDeleteProgramPipelines(n, pipelines).
+ Convenience function that calls glDeleteProgramPipelines(\a n, \a pipelines).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4936,7 +4936,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z)
- Convenience function that calls glDispatchCompute(num_groups_x, num_groups_y, num_groups_z).
+ Convenience function that calls glDispatchCompute(\a num_groups_x, \a num_groups_y, \a num_groups_z).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4949,7 +4949,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glDispatchComputeIndirect(GLintptr indirect)
- Convenience function that calls glDispatchComputeIndirect(indirect).
+ Convenience function that calls glDispatchComputeIndirect(\a indirect).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4962,7 +4962,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glDrawArraysIndirect(GLenum mode, const void * indirect)
- Convenience function that calls glDrawArraysIndirect(mode, indirect).
+ Convenience function that calls glDrawArraysIndirect(\a mode, \a indirect).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4975,7 +4975,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glDrawElementsIndirect(GLenum mode, GLenum type, const void * indirect)
- Convenience function that calls glDrawElementsIndirect(mode, type, indirect).
+ Convenience function that calls glDrawElementsIndirect(\a mode, \a type, \a indirect).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -4988,7 +4988,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glFramebufferParameteri(GLenum target, GLenum pname, GLint param)
- Convenience function that calls glFramebufferParameteri(target, pname, param).
+ Convenience function that calls glFramebufferParameteri(\a target, \a pname, \a param).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5001,7 +5001,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGenProgramPipelines(GLsizei n, GLuint* pipelines)
- Convenience function that calls glGenProgramPipelines(n, pipelines).
+ Convenience function that calls glGenProgramPipelines(\a n, \a pipelines).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5014,7 +5014,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetBooleani_v(GLenum target, GLuint index, GLboolean* data)
- Convenience function that calls glGetBooleani_v(target, index, data).
+ Convenience function that calls glGetBooleani_v(\a target, \a index, \a data).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5027,7 +5027,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetFramebufferParameteriv(GLenum target, GLenum pname, GLint* params)
- Convenience function that calls glGetFramebufferParameteriv(target, pname, params).
+ Convenience function that calls glGetFramebufferParameteriv(\a target, \a pname, \a params).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5040,7 +5040,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetMultisamplefv(GLenum pname, GLuint index, GLfloat* val)
- Convenience function that calls glGetMultisamplefv(pname, index, val).
+ Convenience function that calls glGetMultisamplefv(\a pname, \a index, \a val).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5053,7 +5053,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetProgramInterfaceiv(GLuint program, GLenum programInterface, GLenum pname, GLint* params)
- Convenience function that calls glGetProgramInterfaceiv(program, programInterface, pname, params).
+ Convenience function that calls glGetProgramInterfaceiv(\a program, \a programInterface, \a pname, \a params).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5066,7 +5066,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar* infoLog)
- Convenience function that calls glGetProgramPipelineInfoLog(pipeline, bufSize, length, infoLog).
+ Convenience function that calls glGetProgramPipelineInfoLog(\a pipeline, \a bufSize, \a length, \a infoLog).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5079,7 +5079,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint* params)
- Convenience function that calls glGetProgramPipelineiv(pipeline, pname, params).
+ Convenience function that calls glGetProgramPipelineiv(\a pipeline, \a pname, \a params).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5092,7 +5092,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn GLuint QOpenGLExtraFunctions::glGetProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar * name)
- Convenience function that calls glGetProgramResourceIndex(program, programInterface, name).
+ Convenience function that calls glGetProgramResourceIndex(\a program, \a programInterface, \a name).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5105,7 +5105,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn GLint QOpenGLExtraFunctions::glGetProgramResourceLocation(GLuint program, GLenum programInterface, const GLchar * name)
- Convenience function that calls glGetProgramResourceLocation(program, programInterface, name).
+ Convenience function that calls glGetProgramResourceLocation(\a program, \a programInterface, \a name).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5118,7 +5118,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar* name)
- Convenience function that calls glGetProgramResourceName(program, programInterface, index, bufSize, length, name).
+ Convenience function that calls glGetProgramResourceName(\a program, \a programInterface, \a index, \a bufSize, \a length, \a name).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5131,7 +5131,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetProgramResourceiv(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei* length, GLint* params)
- Convenience function that calls glGetProgramResourceiv(program, programInterface, index, propCount, props, bufSize, length, params).
+ Convenience function that calls glGetProgramResourceiv(\a program, \a programInterface, \a index, \a propCount, \a props, \a bufSize, \a length, \a params).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5144,7 +5144,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat* params)
- Convenience function that calls glGetTexLevelParameterfv(target, level, pname, params).
+ Convenience function that calls glGetTexLevelParameterfv(\a target, \a level, \a pname, \a params).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5157,7 +5157,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params)
- Convenience function that calls glGetTexLevelParameteriv(target, level, pname, params).
+ Convenience function that calls glGetTexLevelParameteriv(\a target, \a level, \a pname, \a params).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5170,7 +5170,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn GLboolean QOpenGLExtraFunctions::glIsProgramPipeline(GLuint pipeline)
- Convenience function that calls glIsProgramPipeline(pipeline).
+ Convenience function that calls glIsProgramPipeline(\a pipeline).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5183,7 +5183,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glMemoryBarrier(GLbitfield barriers)
- Convenience function that calls glMemoryBarrier(barriers).
+ Convenience function that calls glMemoryBarrier(\a barriers).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5196,7 +5196,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glMemoryBarrierByRegion(GLbitfield barriers)
- Convenience function that calls glMemoryBarrierByRegion(barriers).
+ Convenience function that calls glMemoryBarrierByRegion(\a barriers).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5209,7 +5209,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform1f(GLuint program, GLint location, GLfloat v0)
- Convenience function that calls glProgramUniform1f(program, location, v0).
+ Convenience function that calls glProgramUniform1f(\a program, \a location, \a v0).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5222,7 +5222,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat * value)
- Convenience function that calls glProgramUniform1fv(program, location, count, value).
+ Convenience function that calls glProgramUniform1fv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5235,7 +5235,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform1i(GLuint program, GLint location, GLint v0)
- Convenience function that calls glProgramUniform1i(program, location, v0).
+ Convenience function that calls glProgramUniform1i(\a program, \a location, \a v0).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5248,7 +5248,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform1iv(GLuint program, GLint location, GLsizei count, const GLint * value)
- Convenience function that calls glProgramUniform1iv(program, location, count, value).
+ Convenience function that calls glProgramUniform1iv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5261,7 +5261,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform1ui(GLuint program, GLint location, GLuint v0)
- Convenience function that calls glProgramUniform1ui(program, location, v0).
+ Convenience function that calls glProgramUniform1ui(\a program, \a location, \a v0).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5274,7 +5274,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint * value)
- Convenience function that calls glProgramUniform1uiv(program, location, count, value).
+ Convenience function that calls glProgramUniform1uiv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5287,7 +5287,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1)
- Convenience function that calls glProgramUniform2f(program, location, v0, v1).
+ Convenience function that calls glProgramUniform2f(\a program, \a location, \a v0, \a v1).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5300,7 +5300,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat * value)
- Convenience function that calls glProgramUniform2fv(program, location, count, value).
+ Convenience function that calls glProgramUniform2fv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5313,7 +5313,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1)
- Convenience function that calls glProgramUniform2i(program, location, v0, v1).
+ Convenience function that calls glProgramUniform2i(\a program, \a location, \a v0, \a v1).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5326,7 +5326,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform2iv(GLuint program, GLint location, GLsizei count, const GLint * value)
- Convenience function that calls glProgramUniform2iv(program, location, count, value).
+ Convenience function that calls glProgramUniform2iv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5339,7 +5339,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1)
- Convenience function that calls glProgramUniform2ui(program, location, v0, v1).
+ Convenience function that calls glProgramUniform2ui(\a program, \a location, \a v0, \a v1).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5352,7 +5352,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint * value)
- Convenience function that calls glProgramUniform2uiv(program, location, count, value).
+ Convenience function that calls glProgramUniform2uiv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5365,7 +5365,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
- Convenience function that calls glProgramUniform3f(program, location, v0, v1, v2).
+ Convenience function that calls glProgramUniform3f(\a program, \a location, \a v0, \a v1, \a v2).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5378,7 +5378,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat * value)
- Convenience function that calls glProgramUniform3fv(program, location, count, value).
+ Convenience function that calls glProgramUniform3fv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5391,7 +5391,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2)
- Convenience function that calls glProgramUniform3i(program, location, v0, v1, v2).
+ Convenience function that calls glProgramUniform3i(\a program, \a location, \a v0, \a v1, \a v2).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5404,7 +5404,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform3iv(GLuint program, GLint location, GLsizei count, const GLint * value)
- Convenience function that calls glProgramUniform3iv(program, location, count, value).
+ Convenience function that calls glProgramUniform3iv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5417,7 +5417,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2)
- Convenience function that calls glProgramUniform3ui(program, location, v0, v1, v2).
+ Convenience function that calls glProgramUniform3ui(\a program, \a location, \a v0, \a v1, \a v2).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5430,7 +5430,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint * value)
- Convenience function that calls glProgramUniform3uiv(program, location, count, value).
+ Convenience function that calls glProgramUniform3uiv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5443,7 +5443,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
- Convenience function that calls glProgramUniform4f(program, location, v0, v1, v2, v3).
+ Convenience function that calls glProgramUniform4f(\a program, \a location, \a v0, \a v1, \a v2, \a v3).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5456,7 +5456,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat * value)
- Convenience function that calls glProgramUniform4fv(program, location, count, value).
+ Convenience function that calls glProgramUniform4fv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5469,7 +5469,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
- Convenience function that calls glProgramUniform4i(program, location, v0, v1, v2, v3).
+ Convenience function that calls glProgramUniform4i(\a program, \a location, \a v0, \a v1, \a v2, \a v3).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5482,7 +5482,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform4iv(GLuint program, GLint location, GLsizei count, const GLint * value)
- Convenience function that calls glProgramUniform4iv(program, location, count, value).
+ Convenience function that calls glProgramUniform4iv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5495,7 +5495,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
- Convenience function that calls glProgramUniform4ui(program, location, v0, v1, v2, v3).
+ Convenience function that calls glProgramUniform4ui(\a program, \a location, \a v0, \a v1, \a v2, \a v3).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5508,7 +5508,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint * value)
- Convenience function that calls glProgramUniform4uiv(program, location, count, value).
+ Convenience function that calls glProgramUniform4uiv(\a program, \a location, \a count, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5521,7 +5521,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix2fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix2fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5534,7 +5534,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix2x3fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix2x3fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5547,7 +5547,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix2x4fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix2x4fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5560,7 +5560,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix3fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix3fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5573,7 +5573,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix3x2fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix3x2fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5586,7 +5586,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix3x4fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix3x4fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5599,7 +5599,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix4fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix4fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5612,7 +5612,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix4x2fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix4x2fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5625,7 +5625,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
- Convenience function that calls glProgramUniformMatrix4x3fv(program, location, count, transpose, value).
+ Convenience function that calls glProgramUniformMatrix4x3fv(\a program, \a location, \a count, \a transpose, \a value).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5638,7 +5638,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glSampleMaski(GLuint maskNumber, GLbitfield mask)
- Convenience function that calls glSampleMaski(maskNumber, mask).
+ Convenience function that calls glSampleMaski(\a maskNumber, \a mask).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5651,7 +5651,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glTexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations)
- Convenience function that calls glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations).
+ Convenience function that calls glTexStorage2DMultisample(\a target, \a samples, \a internalformat, \a width, \a height, \a fixedsamplelocations).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5664,7 +5664,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
- Convenience function that calls glUseProgramStages(pipeline, stages, program).
+ Convenience function that calls glUseProgramStages(\a pipeline, \a stages, \a program).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5677,7 +5677,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glValidateProgramPipeline(GLuint pipeline)
- Convenience function that calls glValidateProgramPipeline(pipeline).
+ Convenience function that calls glValidateProgramPipeline(\a pipeline).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5690,7 +5690,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glVertexAttribBinding(GLuint attribindex, GLuint bindingindex)
- Convenience function that calls glVertexAttribBinding(attribindex, bindingindex).
+ Convenience function that calls glVertexAttribBinding(\a attribindex, \a bindingindex).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5703,7 +5703,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glVertexAttribFormat(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset)
- Convenience function that calls glVertexAttribFormat(attribindex, size, type, normalized, relativeoffset).
+ Convenience function that calls glVertexAttribFormat(\a attribindex, \a size, \a type, \a normalized, \a relativeoffset).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5716,7 +5716,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glVertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset)
- Convenience function that calls glVertexAttribIFormat(attribindex, size, type, relativeoffset).
+ Convenience function that calls glVertexAttribIFormat(\a attribindex, \a size, \a type, \a relativeoffset).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -5729,7 +5729,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *)
/*!
\fn void QOpenGLExtraFunctions::glVertexBindingDivisor(GLuint bindingindex, GLuint divisor)
- Convenience function that calls glVertexBindingDivisor(bindingindex, divisor).
+ Convenience function that calls glVertexBindingDivisor(\a bindingindex, \a divisor).
This function is only available in OpenGL ES 3.x, or OpenGL 3.x or 4.x contexts. When running
with plain OpenGL, the function is only usable when the given profile and version contains the
@@ -7398,10 +7398,25 @@ static void QOPENGLF_APIENTRY qopenglfResolveVertexBindingDivisor(GLuint binding
RESOLVE_FUNC_VOID(0, VertexBindingDivisor)(bindingindex, divisor);
}
+/*!
+ Constructs a default function resolver. The resolver cannot be used until
+ \l {QOpenGLFunctions::}{initializeOpenGLFunctions()} is called to specify
+ the context.
+*/
QOpenGLExtraFunctions::QOpenGLExtraFunctions()
{
}
+/*!
+ Constructs a function resolver for context. If \a context is null, then
+ the resolver will be created for the current QOpenGLContext.
+
+ The context or another context in the group must be current.
+
+ An object constructed in this way can only be used with context and other
+ contexts that share with it. Use \l {QOpenGLFunctions::}
+ {initializeOpenGLFunctions()} to change the object's context association.
+*/
QOpenGLExtraFunctions::QOpenGLExtraFunctions(QOpenGLContext *context)
: QOpenGLFunctions(context)
{
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index 41d53be31e..9714aa4bec 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -525,7 +525,8 @@ bool QOpenGLShader::compileSourceCode(const char *source)
// The precision qualifiers are useful on OpenGL/ES systems,
// but usually not present on desktop systems.
- const QSurfaceFormat currentSurfaceFormat = QOpenGLContext::currentContext()->format();
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ const QSurfaceFormat currentSurfaceFormat = ctx->format();
QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(QOpenGLContext::currentContext());
if (currentSurfaceFormat.renderableType() == QSurfaceFormat::OpenGL
|| ctx_d->workaround_missingPrecisionQualifiers
@@ -545,10 +546,16 @@ bool QOpenGLShader::compileSourceCode(const char *source)
}
#endif
- // Append #line directive in order to compensate for text insertion
- QByteArray lineDirective = QStringLiteral("#line %1\n").arg(versionDirectivePosition.line).toUtf8();
- sourceChunks.append(lineDirective.constData());
- sourceChunkLengths.append(GLint(lineDirective.length()));
+ QByteArray lineDirective;
+ // #line is rejected by some drivers:
+ // "2.1 Mesa 8.1-devel (git-48a3d4e)" or "MESA 2.1 Mesa 8.1-devel"
+ const char *version = reinterpret_cast<const char *>(ctx->functions()->glGetString(GL_VERSION));
+ if (!version || !strstr(version, "2.1 Mesa 8")) {
+ // Append #line directive in order to compensate for text insertion
+ lineDirective = QStringLiteral("#line %1\n").arg(versionDirectivePosition.line).toUtf8();
+ sourceChunks.append(lineDirective.constData());
+ sourceChunkLengths.append(GLint(lineDirective.length()));
+ }
// Append rest of shader code
sourceChunks.append(source + versionDirectivePosition.position);
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 0cf7e20605..64a363868a 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -6326,8 +6326,6 @@ template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4
void qInitDrawhelperAsm()
{
- const uint features = qCpuFeatures();
- Q_UNUSED(features);
#ifdef __SSE2__
qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2;
@@ -6372,7 +6370,7 @@ void qInitDrawhelperAsm()
qt_fetch_radial_gradient = qt_fetch_radial_gradient_sse2;
#ifdef QT_COMPILER_SUPPORTS_SSSE3
- if (features & SSSE3) {
+ if (qCpuHasFeature(SSSE3)) {
extern void qt_blend_argb32_on_argb32_ssse3(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
int w, int h,
@@ -6466,7 +6464,7 @@ void qInitDrawhelperAsm()
#endif // Q_PROCESSOR_MIPS_32
#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
- if (features & (DSP | DSPR2)) {
+ if (qCpuHasFeature(DSP) && qCpuHasFeature(DSPR2)) {
// Composition functions are all DSP r1
qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp;
qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp;
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index 7b6a71737d..33dccc5374 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -305,7 +305,10 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
for (int x = 0; x < dw; x++) {
const unsigned int *pix = sptr + xpoints[x];
const int xap = xapoints[x];
- *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
+ if (xap > 0)
+ *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
+ else
+ *dptr = pix[0];
dptr++;
}
}
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index c360573e78..72a6ca4cb3 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -81,7 +81,7 @@ public:
int colorCount() const { return metric(PdmNumColors); }
int depth() const { return metric(PdmDepth); }
- static inline qreal devicePixelRatioFScale() {return 10000000.0; }
+ static inline qreal devicePixelRatioFScale() { return 0x10000; }
protected:
QPaintDevice() Q_DECL_NOEXCEPT;
virtual int metric(PaintDeviceMetric metric) const;
diff --git a/src/gui/painting/qpaintdevice.qdoc b/src/gui/painting/qpaintdevice.qdoc
index a83acdd21a..ef5deb154d 100644
--- a/src/gui/painting/qpaintdevice.qdoc
+++ b/src/gui/painting/qpaintdevice.qdoc
@@ -118,7 +118,13 @@
values are 1 for normal-dpi displays and 2 for high-dpi "retina"
displays.
- \sa metric()
+ \value PdmDevicePixelRatioScaled The scaled device pixel ratio for the device.
+ This is identical to PdmDevicePixelRatio, except that the value is scaled by a
+ constant factor in order to support paint devices with fractional scale factors.
+ The constant scaling factor used is devicePixelRatioFScale(). This enum value
+ has been introduced in Qt 5.6.
+
+ \sa metric(), devicePixelRatioF()
*/
/*!
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index e765a9e402..c86fdebea5 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -300,11 +300,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
}
funcs->glEnable(GL_BLEND);
- funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- // Do not write out alpha. We need blending, but only for RGB. The toplevel may have
- // alpha enabled in which case blending (writing out < 1.0 alpha values) would lead to
- // semi-transparency even when it is not wanted.
- funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
+ funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
// Backingstore texture with the normal widgets.
GLuint textureId = 0;
@@ -364,7 +360,6 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
blit(textures, i, window, deviceWindowRect, d_ptr->blitter);
}
- funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
funcs->glDisable(GL_BLEND);
d_ptr->blitter->release();
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 75bf31cde1..34d72bf493 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -863,8 +863,8 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
const Q16Dot16 iLeft = int(left);
const Q16Dot16 iRight = int(right);
const Q16Dot16 leftWidth = IntToQ16Dot16(iLeft + 1)
- - FloatToQ16Dot16(left);
- const Q16Dot16 rightWidth = FloatToQ16Dot16(right)
+ - qSafeFloatToQ16Dot16(left);
+ const Q16Dot16 rightWidth = qSafeFloatToQ16Dot16(right)
- IntToQ16Dot16(iRight);
Q16Dot16 coverage[3];
@@ -898,8 +898,8 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
const Q16Dot16 iTopFP = IntToQ16Dot16(int(pa.y()));
const Q16Dot16 iBottomFP = IntToQ16Dot16(int(pb.y()));
- const Q16Dot16 yPa = FloatToQ16Dot16(pa.y());
- const Q16Dot16 yPb = FloatToQ16Dot16(pb.y());
+ const Q16Dot16 yPa = qSafeFloatToQ16Dot16(pa.y());
+ const Q16Dot16 yPb = qSafeFloatToQ16Dot16(pb.y());
for (Q16Dot16 yFP = iTopFP; yFP <= iBottomFP; yFP += Q16Dot16Factor) {
const Q16Dot16 rowHeight = qMin(yFP + Q16Dot16Factor, yPb)
- qMax(yFP, yPa);
@@ -983,16 +983,16 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
const Q16Dot16 iRightFP = IntToQ16Dot16(int(right.y()));
const Q16Dot16 iBottomFP = IntToQ16Dot16(int(bottomBound));
- Q16Dot16 leftIntersectAf = FloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topLeftSlope);
- Q16Dot16 rightIntersectAf = FloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topRightSlope);
+ Q16Dot16 leftIntersectAf = qSafeFloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topLeftSlope);
+ Q16Dot16 rightIntersectAf = qSafeFloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topRightSlope);
Q16Dot16 leftIntersectBf = 0;
Q16Dot16 rightIntersectBf = 0;
if (iLeftFP < iTopFP)
- leftIntersectBf = FloatToQ16Dot16(left.x() + (int(topBound) - left.y()) * bottomLeftSlope);
+ leftIntersectBf = qSafeFloatToQ16Dot16(left.x() + (int(topBound) - left.y()) * bottomLeftSlope);
if (iRightFP < iTopFP)
- rightIntersectBf = FloatToQ16Dot16(right.x() + (int(topBound) - right.y()) * bottomRightSlope);
+ rightIntersectBf = qSafeFloatToQ16Dot16(right.x() + (int(topBound) - right.y()) * bottomRightSlope);
Q16Dot16 rowTop, rowBottomLeft, rowBottomRight, rowTopLeft, rowTopRight, rowBottom;
Q16Dot16 topLeftIntersectAf, topLeftIntersectBf, topRightIntersectAf, topRightIntersectBf;
@@ -1000,10 +1000,10 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
int leftMin, leftMax, rightMin, rightMax;
- const Q16Dot16 yTopFP = FloatToQ16Dot16(top.y());
- const Q16Dot16 yLeftFP = FloatToQ16Dot16(left.y());
- const Q16Dot16 yRightFP = FloatToQ16Dot16(right.y());
- const Q16Dot16 yBottomFP = FloatToQ16Dot16(bottom.y());
+ const Q16Dot16 yTopFP = qSafeFloatToQ16Dot16(top.y());
+ const Q16Dot16 yLeftFP = qSafeFloatToQ16Dot16(left.y());
+ const Q16Dot16 yRightFP = qSafeFloatToQ16Dot16(right.y());
+ const Q16Dot16 yBottomFP = qSafeFloatToQ16Dot16(bottom.y());
rowTop = qMax(iTopFP, yTopFP);
topLeftIntersectAf = leftIntersectAf +
@@ -1021,7 +1021,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
if (yFP == iLeftFP) {
const int y = Q16Dot16ToInt(yFP);
- leftIntersectBf = FloatToQ16Dot16(left.x() + (y - left.y()) * bottomLeftSlope);
+ leftIntersectBf = qSafeFloatToQ16Dot16(left.x() + (y - left.y()) * bottomLeftSlope);
topLeftIntersectBf = leftIntersectBf + Q16Dot16Multiply(bottomLeftSlopeFP, rowTopLeft - yFP);
bottomLeftIntersectAf = leftIntersectAf + Q16Dot16Multiply(topLeftSlopeFP, rowBottomLeft - yFP);
} else {
@@ -1031,7 +1031,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
if (yFP == iRightFP) {
const int y = Q16Dot16ToInt(yFP);
- rightIntersectBf = FloatToQ16Dot16(right.x() + (y - right.y()) * bottomRightSlope);
+ rightIntersectBf = qSafeFloatToQ16Dot16(right.x() + (y - right.y()) * bottomRightSlope);
topRightIntersectBf = rightIntersectBf + Q16Dot16Multiply(bottomRightSlopeFP, rowTopRight - yFP);
bottomRightIntersectAf = rightIntersectAf + Q16Dot16Multiply(topRightSlopeFP, rowBottomRight - yFP);
} else {
diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h
index b701b224be..264ec394cd 100644
--- a/src/gui/painting/qrgba64.h
+++ b/src/gui/painting/qrgba64.h
@@ -58,33 +58,34 @@ class QRgba64 {
#endif
};
+ // No constructors are allowed in C++98, since this needs to be usable in a union.
+ // We however require one for constexprs in C++11/C++14
+#ifdef Q_COMPILER_CONSTEXPR
+ explicit Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64(quint64 c) : rgba(c) { }
+#endif
public:
- // No constructors are allowed, since this needs to be usable in a union in no-c++11 mode.
- // When c++11 is mandatory, we can add all but a copy constructor.
- Q_DECL_RELAXED_CONSTEXPR static
- QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha)
- {
- QRgba64 rgba64
-#ifdef Q_COMPILER_UNIFORM_INIT
- = {}
+#ifdef Q_COMPILER_CONSTEXPR
+ Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64() : rgba(0) { }
#endif
- ;
- rgba64.rgba = quint64(red) << RedShift
- | quint64(green) << GreenShift
- | quint64(blue) << BlueShift
- | quint64(alpha) << AlphaShift;
- return rgba64;
- }
- Q_DECL_RELAXED_CONSTEXPR static
+
+ Q_DECL_CONSTEXPR static
QRgba64 fromRgba64(quint64 c)
{
- QRgba64 rgba64
-#ifdef Q_COMPILER_UNIFORM_INIT
- = {}
-#endif
- ;
+#ifdef Q_COMPILER_CONSTEXPR
+ return QRgba64(c);
+#else
+ QRgba64 rgba64;
rgba64.rgba = c;
return rgba64;
+#endif
+ }
+ Q_DECL_CONSTEXPR static
+ QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha)
+ {
+ return fromRgba64(quint64(red) << RedShift
+ | quint64(green) << GreenShift
+ | quint64(blue) << BlueShift
+ | quint64(alpha) << AlphaShift);
}
Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)
{
@@ -112,10 +113,10 @@ public:
Q_DECL_CONSTEXPR quint16 green() const { return rgba >> GreenShift; }
Q_DECL_CONSTEXPR quint16 blue() const { return rgba >> BlueShift; }
Q_DECL_CONSTEXPR quint16 alpha() const { return rgba >> AlphaShift; }
- void setRed(quint16 _red) { *this = fromRgba64(_red, green(), blue(), alpha()); }
- void setGreen(quint16 _green) { *this = fromRgba64(red(), _green, blue(), alpha()); }
- void setBlue(quint16 _blue) { *this = fromRgba64(red(), green(), _blue, alpha()); }
- void setAlpha(quint16 _alpha) { *this = fromRgba64(red(), green(), blue(), _alpha); }
+ void setRed(quint16 _red) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << RedShift)) | (quint64(_red) << RedShift); }
+ void setGreen(quint16 _green) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << GreenShift)) | (quint64(_green) << GreenShift); }
+ void setBlue(quint16 _blue) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << BlueShift)) | (quint64(_blue) << BlueShift); }
+ void setAlpha(quint16 _alpha) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << AlphaShift)) | (quint64(_alpha) << AlphaShift); }
Q_DECL_CONSTEXPR quint8 red8() const { return div_257(red()); }
Q_DECL_CONSTEXPR quint8 green8() const { return div_257(green()); }
@@ -160,16 +161,16 @@ public:
}
private:
- static Q_DECL_CONSTEXPR quint64 alphaMask() { return quint64(0xffff) << AlphaShift; }
+ static Q_DECL_CONSTEXPR quint64 alphaMask() { return Q_UINT64_C(0xffff) << AlphaShift; }
static Q_DECL_CONSTEXPR uint div_257_floor(uint x) { return (x - (x >> 8)) >> 8; }
static Q_DECL_CONSTEXPR uint div_257(uint x) { return div_257_floor(x + 128); }
static Q_DECL_CONSTEXPR uint div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; }
Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_32bit() const
{
- const quint16 a = alpha();
- if (a == 0xffff || a == 0)
+ if (isOpaque() || isTransparent())
return *this;
+ const quint32 a = alpha();
const quint16 r = (quint32(red()) * 0xffff + a/2) / a;
const quint16 g = (quint32(green()) * 0xffff + a/2) / a;
const quint16 b = (quint32(blue()) * 0xffff + a/2) / a;
@@ -177,9 +178,9 @@ private:
}
Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_64bit() const
{
- const quint16 a = alpha();
- if (a == 0xffff || a == 0)
+ if (isOpaque() || isTransparent())
return *this;
+ const quint64 a = alpha();
const quint64 fa = (Q_UINT64_C(0xffff00008000) + a/2) / a;
const quint16 r = (red() * fa + 0x80000000) >> 32;
const quint16 g = (green() * fa + 0x80000000) >> 32;
@@ -190,12 +191,12 @@ private:
Q_DECLARE_TYPEINFO(QRgba64, Q_PRIMITIVE_TYPE);
-Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
+Q_DECL_CONSTEXPR inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
{
return QRgba64::fromRgba64(r, g, b, a);
}
-Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qRgba64(quint64 c)
+Q_DECL_CONSTEXPR inline QRgba64 qRgba64(quint64 c)
{
return QRgba64::fromRgba64(c);
}
diff --git a/src/gui/painting/qrgba64.qdoc b/src/gui/painting/qrgba64.qdoc
index 29da0aa390..b786e91b03 100644
--- a/src/gui/painting/qrgba64.qdoc
+++ b/src/gui/painting/qrgba64.qdoc
@@ -36,13 +36,19 @@
QRgba64 is a 64-bit data-structure containing four 16-bit color channels: Red, green, blue and alpha.
QRgba64 can be used a replacement for QRgb when higher precision is needed. In particular a
- premultiplied QRgba64 can operate on unpremultipled QRgb without loss of precision except
+ premultiplied QRgba64 can operate on unpremultiplied QRgb without loss of precision except
for alpha 0.
\sa QRgb, QColor
*/
/*!
+ \fn QRgba64 QRgba64::operator=(quint64 rgba)
+
+ Assigns the value \a rgba to this instance of QRgba64 and returns it.
+*/
+
+/*!
\fn static QRgba64 QRgba64::fromRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
Returns the QRgba64 quadruplet (\a{r}, \a{g}, \a{b}, \a{a}).
@@ -75,27 +81,83 @@
*/
/*!
+ \fn bool QRgba64::isOpaque() const
+
+ Returns whether the color is fully opaque.
+
+ \sa isTransparent(), alpha()
+*/
+
+/*!
+ \fn bool QRgba64::isTransparent() const
+
+ Returns whether the color is transparent.
+
+ \sa isOpaque(), alpha()
+*/
+
+/*!
\fn quint16 QRgba64::red() const
Returns the 16-bit red color component.
+
+ \sa setRed()
+*/
+
+/*!
+ \fn QRgba64::setRed(quint16 red)
+
+ Sets the red color component of this color to \a red.
+
+ \sa red()
*/
/*!
\fn quint16 QRgba64::green() const
Returns the 16-bit green color component.
+
+ \sa setGreen()
+*/
+
+/*!
+ \fn QRgba64::setGreen(quint16 green)
+
+ Sets the green color component of this color to \a green.
+
+ \sa green()
*/
/*!
\fn quint16 QRgba64::blue() const
Returns the 16-bit blue color component.
+
+ \sa setBlue()
+*/
+
+/*!
+ \fn QRgba64::setBlue(quint16 blue)
+
+ Sets the blue color component of this color to \a blue.
+
+ \sa blue()
*/
/*!
\fn quint16 QRgba64::alpha() const
Returns the 16-bit alpha channel.
+
+ \sa setAlpha()
+*/
+
+/*!
+ \fn QRgba64::setAlpha(quint16 alpha)
+
+ Sets the alpha of this color to \a alpha.
+
+ \sa alpha()
*/
/*!
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 796f223797..7d9d00713c 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2218,6 +2218,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
}
if (s.version() >= QDataStream::Qt_5_4)
s << (quint8)font.d->request.hintingPreference;
+ if (s.version() >= QDataStream::Qt_5_6)
+ s << (quint8)font.d->capital;
return s;
}
@@ -2308,7 +2310,11 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
s >> value;
font.d->request.hintingPreference = QFont::HintingPreference(value);
}
-
+ if (s.version() >= QDataStream::Qt_5_6) {
+ quint8 value;
+ s >> value;
+ font.d->capital = QFont::Capitalization(value);
+ }
return s;
}
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index f9d924d10a..bef4dc5547 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -54,6 +54,7 @@
#include <private/qharfbuzz_p.h>
#include <algorithm>
+#include <limits.h>
QT_BEGIN_NAMESPACE
@@ -74,6 +75,16 @@ static inline bool qtransform_equals_no_translate(const QTransform &a, const QTr
}
}
+template<typename T>
+static inline bool qSafeFromBigEndian(const uchar *source, const uchar *end, T *output)
+{
+ if (source + sizeof(T) > end)
+ return false;
+
+ *output = qFromBigEndian<T>(source);
+ return true;
+}
+
// Harfbuzz helper functions
#ifdef QT_ENABLE_HARFBUZZ_NG
@@ -225,10 +236,14 @@ Q_AUTOTEST_EXPORT QList<QFontEngine *> QFontEngine_stopCollectingEngines()
// QFontEngine
+#define kBearingNotInitialized std::numeric_limits<qreal>::max()
+
QFontEngine::QFontEngine(Type type)
: m_type(type), ref(0),
font_(0), font_destroy_func(0),
- face_(0), face_destroy_func(0)
+ face_(0), face_destroy_func(0),
+ m_minLeftBearing(kBearingNotInitialized),
+ m_minRightBearing(kBearingNotInitialized)
{
faceData.user_data = this;
faceData.get_font_table = qt_get_font_table_default;
@@ -552,11 +567,91 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
{
glyph_metrics_t gi = boundingBox(glyph);
- bool isValid = gi.isValid();
if (leftBearing != 0)
- *leftBearing = isValid ? gi.x.toReal() : 0.0;
+ *leftBearing = gi.leftBearing().toReal();
if (rightBearing != 0)
- *rightBearing = isValid ? (gi.xoff - gi.x - gi.width).toReal() : 0.0;
+ *rightBearing = gi.rightBearing().toReal();
+}
+
+qreal QFontEngine::minLeftBearing() const
+{
+ if (m_minLeftBearing == kBearingNotInitialized)
+ minRightBearing(); // Initializes both (see below)
+
+ return m_minLeftBearing;
+}
+
+#define q16Dot16ToFloat(i) ((i) / 65536.0)
+
+#define kMinLeftSideBearingOffset 12
+#define kMinRightSideBearingOffset 14
+
+qreal QFontEngine::minRightBearing() const
+{
+ if (m_minRightBearing == kBearingNotInitialized) {
+
+ // Try the 'hhea' font table first, which covers the entire font
+ QByteArray hheaTable = getSfntTable(MAKE_TAG('h', 'h', 'e', 'a'));
+ if (hheaTable.size() >= int(kMinRightSideBearingOffset + sizeof(qint16))) {
+ const uchar *tableData = reinterpret_cast<const uchar *>(hheaTable.constData());
+ Q_ASSERT(q16Dot16ToFloat(qFromBigEndian<quint32>(tableData)) == 1.0);
+
+ qint16 minLeftSideBearing = qFromBigEndian<qint16>(tableData + kMinLeftSideBearingOffset);
+ qint16 minRightSideBearing = qFromBigEndian<qint16>(tableData + kMinRightSideBearingOffset);
+
+ // The table data is expressed as FUnits, meaning we have to take the number
+ // of units per em into account. Since pixelSize already has taken DPI into
+ // account we can use that directly instead of the point size.
+ int unitsPerEm = emSquareSize().toInt();
+ qreal funitToPixelFactor = fontDef.pixelSize / unitsPerEm;
+
+ // Some fonts on OS X (such as Gurmukhi Sangam MN, Khmer MN, Lao Sangam MN, etc.), have
+ // invalid values for their NBSPACE left bearing, causing the 'hhea' minimum bearings to
+ // be way off. We detect this by assuming that the minimum bearsings are within a certain
+ // range of the em square size.
+ static const int largestValidBearing = 4 * unitsPerEm;
+
+ if (qAbs(minLeftSideBearing) < largestValidBearing)
+ m_minLeftBearing = minLeftSideBearing * funitToPixelFactor;
+ if (qAbs(minRightSideBearing) < largestValidBearing)
+ m_minRightBearing = minRightSideBearing * funitToPixelFactor;
+ }
+
+ // Fallback in case of missing 'hhea' table (bitmap fonts e.g.) or broken 'hhea' values
+ if (m_minLeftBearing == kBearingNotInitialized || m_minRightBearing == kBearingNotInitialized) {
+
+ // To balance performance and correctness we only look at a subset of the
+ // possible glyphs in the font, based on which characters are more likely
+ // to have a left or right bearing.
+ static const ushort characterSubset[] = {
+ '(', 'C', 'F', 'K', 'V', 'X', 'Y', ']', '_', 'f', 'r', '|',
+ 127, 205, 645, 884, 922, 1070, 12386
+ };
+
+ // The font may have minimum bearings larger than 0, so we have to start at the max
+ m_minLeftBearing = m_minRightBearing = std::numeric_limits<qreal>::max();
+
+ for (uint i = 0; i < (sizeof(characterSubset) / sizeof(ushort)); ++i) {
+ const glyph_t glyph = glyphIndex(characterSubset[i]);
+ if (!glyph)
+ continue;
+
+ glyph_metrics_t glyphMetrics = const_cast<QFontEngine *>(this)->boundingBox(glyph);
+
+ // Glyphs with no contours shouldn't contribute to bearings
+ if (!glyphMetrics.width || !glyphMetrics.height)
+ continue;
+
+ m_minLeftBearing = qMin(m_minLeftBearing, glyphMetrics.leftBearing().toReal());
+ m_minRightBearing = qMin(m_minRightBearing, glyphMetrics.rightBearing().toReal());
+ }
+ }
+
+ if (m_minLeftBearing == kBearingNotInitialized || m_minRightBearing == kBearingNotInitialized)
+ qWarning() << "Failed to compute left/right minimum bearings for" << fontDef.family;
+ }
+
+ return m_minRightBearing;
}
glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs)
@@ -1039,26 +1134,38 @@ void QFontEngine::loadKerningPairs(QFixed scalingFactor)
return;
const uchar *table = reinterpret_cast<const uchar *>(tab.constData());
+ const uchar *end = table + tab.size();
+
+ quint16 version;
+ if (!qSafeFromBigEndian(table, end, &version))
+ return;
- unsigned short version = qFromBigEndian<quint16>(table);
if (version != 0) {
// qDebug("wrong version");
return;
}
- unsigned short numTables = qFromBigEndian<quint16>(table + 2);
+ quint16 numTables;
+ if (!qSafeFromBigEndian(table + 2, end, &numTables))
+ return;
+
{
int offset = 4;
for(int i = 0; i < numTables; ++i) {
- if (offset + 6 > tab.size()) {
-// qDebug("offset out of bounds");
- goto end;
- }
const uchar *header = table + offset;
- ushort version = qFromBigEndian<quint16>(header);
- ushort length = qFromBigEndian<quint16>(header+2);
- ushort coverage = qFromBigEndian<quint16>(header+4);
+ quint16 version;
+ if (!qSafeFromBigEndian(header, end, &version))
+ goto end;
+
+ quint16 length;
+ if (!qSafeFromBigEndian(header + 2, end, &length))
+ goto end;
+
+ quint16 coverage;
+ if (!qSafeFromBigEndian(header + 4, end, &coverage))
+ goto end;
+
// qDebug("subtable: version=%d, coverage=%x",version, coverage);
if(version == 0 && coverage == 0x0001) {
if (offset + length > tab.size()) {
@@ -1067,7 +1174,10 @@ void QFontEngine::loadKerningPairs(QFixed scalingFactor)
}
const uchar *data = table + offset + 6;
- ushort nPairs = qFromBigEndian<quint16>(data);
+ quint16 nPairs;
+ if (!qSafeFromBigEndian(data, end, &nPairs))
+ goto end;
+
if(nPairs * 6 + 8 > length - 6) {
// qDebug("corrupt table!");
// corrupt table
@@ -1077,8 +1187,21 @@ void QFontEngine::loadKerningPairs(QFixed scalingFactor)
int off = 8;
for(int i = 0; i < nPairs; ++i) {
QFontEngine::KernPair p;
- p.left_right = (((uint)qFromBigEndian<quint16>(data+off)) << 16) + qFromBigEndian<quint16>(data+off+2);
- p.adjust = QFixed(((int)(short)qFromBigEndian<quint16>(data+off+4))) / scalingFactor;
+
+ quint16 tmp;
+ if (!qSafeFromBigEndian(data + off, end, &tmp))
+ goto end;
+
+ p.left_right = uint(tmp) << 16;
+ if (!qSafeFromBigEndian(data + off + 2, end, &tmp))
+ goto end;
+
+ p.left_right |= tmp;
+
+ if (!qSafeFromBigEndian(data + off + 4, end, &tmp))
+ goto end;
+
+ p.adjust = QFixed(int(short(tmp))) / scalingFactor;
kerning_pairs.append(p);
off += 6;
}
@@ -1098,26 +1221,31 @@ int QFontEngine::glyphCount() const
QByteArray maxpTable = getSfntTable(MAKE_TAG('m', 'a', 'x', 'p'));
if (maxpTable.size() < 6)
return 0;
- return qFromBigEndian<quint16>(reinterpret_cast<const uchar *>(maxpTable.constData() + 4));
+
+ const uchar *source = reinterpret_cast<const uchar *>(maxpTable.constData() + 4);
+ const uchar *end = source + maxpTable.size();
+
+ quint16 count = 0;
+ qSafeFromBigEndian(source, end, &count);
+ return count;
}
const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize)
{
const uchar *header = table;
- if (tableSize < 4)
- return 0;
-
const uchar *endPtr = table + tableSize;
// version check
- if (qFromBigEndian<quint16>(header) != 0)
+ quint16 version;
+ if (!qSafeFromBigEndian(header, endPtr, &version) || version != 0)
return 0;
- unsigned short numTables = qFromBigEndian<quint16>(header + 2);
- const uchar *maps = table + 4;
- if (maps + 8 * numTables > endPtr)
+ quint16 numTables;
+ if (!qSafeFromBigEndian(header + 2, endPtr, &numTables))
return 0;
+ const uchar *maps = table + 4;
+
enum {
Invalid,
AppleRoman,
@@ -1132,8 +1260,14 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
int tableToUse = -1;
int score = Invalid;
for (int n = 0; n < numTables; ++n) {
- const quint16 platformId = qFromBigEndian<quint16>(maps + 8 * n);
- const quint16 platformSpecificId = qFromBigEndian<quint16>(maps + 8 * n + 2);
+ quint16 platformId;
+ if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId))
+ return 0;
+
+ quint16 platformSpecificId;
+ if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId))
+ return 0;
+
switch (platformId) {
case 0: // Unicode
if (score < Unicode &&
@@ -1187,20 +1321,30 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
resolveTable:
*isSymbolFont = (symbolTable > -1);
- unsigned int unicode_table = qFromBigEndian<quint32>(maps + 8*tableToUse + 4);
+ quint32 unicode_table;
+ if (!qSafeFromBigEndian(maps + 8 * tableToUse + 4, endPtr, &unicode_table))
+ return 0;
- if (!unicode_table || unicode_table + 8 > tableSize)
+ if (!unicode_table)
return 0;
// get the header of the unicode table
header = table + unicode_table;
- unsigned short format = qFromBigEndian<quint16>(header);
- unsigned int length;
- if(format < 8)
- length = qFromBigEndian<quint16>(header + 2);
- else
- length = qFromBigEndian<quint32>(header + 4);
+ quint16 format;
+ if (!qSafeFromBigEndian(header, endPtr, &format))
+ return 0;
+
+ quint32 length;
+ if (format < 8) {
+ quint16 tmp;
+ if (!qSafeFromBigEndian(header + 2, endPtr, &tmp))
+ return 0;
+ length = tmp;
+ } else {
+ if (!qSafeFromBigEndian(header + 4, endPtr, &length))
+ return 0;
+ }
if (table + unicode_table + length > endPtr)
return 0;
@@ -1215,7 +1359,7 @@ resolveTable:
// Check that none of the latin1 range are in the unicode table
bool unicodeTableHasLatin1 = false;
for (int uc=0x00; uc<0x100; ++uc) {
- if (getTrueTypeGlyphIndex(selectedTable, uc) != 0) {
+ if (getTrueTypeGlyphIndex(selectedTable, length, uc) != 0) {
unicodeTableHasLatin1 = true;
break;
}
@@ -1225,7 +1369,7 @@ resolveTable:
bool unicodeTableHasSymbols = false;
if (!unicodeTableHasLatin1) {
for (int uc=0xf000; uc<0xf100; ++uc) {
- if (getTrueTypeGlyphIndex(selectedTable, uc) != 0) {
+ if (getTrueTypeGlyphIndex(selectedTable, length, uc) != 0) {
unicodeTableHasSymbols = true;
break;
}
@@ -1243,12 +1387,17 @@ resolveTable:
return table + unicode_table;
}
-quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
+quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, int cmapSize, uint unicode)
{
- unsigned short format = qFromBigEndian<quint16>(cmap);
+ const uchar *end = cmap + cmapSize;
+ quint16 format;
+ if (!qSafeFromBigEndian(cmap, end, &format))
+ return 0;
+
if (format == 0) {
- if (unicode < 256)
- return (int) *(cmap+6+unicode);
+ const uchar *ptr = cmap + 6 + unicode;
+ if (unicode < 256 && ptr < end)
+ return quint32(*ptr);
} else if (format == 4) {
/* some fonts come with invalid cmap tables, where the last segment
specified end = start = rangeoffset = 0xffff, delta = 0x0001
@@ -1257,25 +1406,49 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
*/
if(unicode >= 0xffff)
return 0;
- quint16 segCountX2 = qFromBigEndian<quint16>(cmap + 6);
+
+ quint16 segCountX2;
+ if (!qSafeFromBigEndian(cmap + 6, end, &segCountX2))
+ return 0;
+
const unsigned char *ends = cmap + 14;
+
int i = 0;
- for (; i < segCountX2/2 && qFromBigEndian<quint16>(ends + 2*i) < unicode; i++) {}
+ for (; i < segCountX2/2; ++i) {
+ quint16 codePoint;
+ if (!qSafeFromBigEndian(ends + 2 * i, end, &codePoint))
+ return 0;
+ if (codePoint >= unicode)
+ break;
+ }
const unsigned char *idx = ends + segCountX2 + 2 + 2*i;
- quint16 startIndex = qFromBigEndian<quint16>(idx);
+ quint16 startIndex;
+ if (!qSafeFromBigEndian(idx, end, &startIndex))
+ return 0;
if (startIndex > unicode)
return 0;
idx += segCountX2;
- qint16 idDelta = (qint16)qFromBigEndian<quint16>(idx);
+
+ quint16 tmp;
+ if (!qSafeFromBigEndian(idx, end, &tmp))
+ return 0;
+ qint16 idDelta = qint16(tmp);
+
idx += segCountX2;
- quint16 idRangeoffset_t = (quint16)qFromBigEndian<quint16>(idx);
+
+ quint16 idRangeoffset_t;
+ if (!qSafeFromBigEndian(idx, end, &idRangeoffset_t))
+ return 0;
quint16 glyphIndex;
if (idRangeoffset_t) {
- quint16 id = qFromBigEndian<quint16>(idRangeoffset_t + 2*(unicode - startIndex) + idx);
+ quint16 id;
+ if (!qSafeFromBigEndian(idRangeoffset_t + 2 * (unicode - startIndex) + idx, end, &id))
+ return 0;
+
if (id)
glyphIndex = (idDelta + id) % 0x10000;
else
@@ -1285,13 +1458,19 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
}
return glyphIndex;
} else if (format == 6) {
- quint16 tableSize = qFromBigEndian<quint16>(cmap + 2);
+ quint16 tableSize;
+ if (!qSafeFromBigEndian(cmap + 2, end, &tableSize))
+ return 0;
- quint16 firstCode6 = qFromBigEndian<quint16>(cmap + 6);
+ quint16 firstCode6;
+ if (!qSafeFromBigEndian(cmap + 6, end, &firstCode6))
+ return 0;
if (unicode < firstCode6)
return 0;
- quint16 entryCount6 = qFromBigEndian<quint16>(cmap + 8);
+ quint16 entryCount6;
+ if (!qSafeFromBigEndian(cmap + 8, end, &entryCount6))
+ return 0;
if (entryCount6 * 2 + 10 > tableSize)
return 0;
@@ -1300,9 +1479,14 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
return 0;
quint16 entryIndex6 = unicode - firstCode6;
- return qFromBigEndian<quint16>(cmap + 10 + (entryIndex6 * 2));
+
+ quint16 index = 0;
+ qSafeFromBigEndian(cmap + 10 + (entryIndex6 * 2), end, &index);
+ return index;
} else if (format == 12) {
- quint32 nGroups = qFromBigEndian<quint32>(cmap + 12);
+ quint32 nGroups;
+ if (!qSafeFromBigEndian(cmap + 12, end, &nGroups))
+ return 0;
cmap += 16; // move to start of groups
@@ -1310,13 +1494,24 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
while (left <= right) {
int middle = left + ( ( right - left ) >> 1 );
- quint32 startCharCode = qFromBigEndian<quint32>(cmap + 12*middle);
+ quint32 startCharCode;
+ if (!qSafeFromBigEndian(cmap + 12 * middle, end, &startCharCode))
+ return 0;
+
if(unicode < startCharCode)
right = middle - 1;
else {
- quint32 endCharCode = qFromBigEndian<quint32>(cmap + 12*middle + 4);
- if(unicode <= endCharCode)
- return qFromBigEndian<quint32>(cmap + 12*middle + 8) + unicode - startCharCode;
+ quint32 endCharCode;
+ if (!qSafeFromBigEndian(cmap + 12 * middle + 4, end, &endCharCode))
+ return 0;
+
+ if (unicode <= endCharCode) {
+ quint32 index;
+ if (!qSafeFromBigEndian(cmap + 12 * middle + 8, end, &index))
+ return 0;
+
+ return index + unicode - startCharCode;
+ }
left = middle + 1;
}
}
@@ -1359,8 +1554,7 @@ QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)
glyph_t glyph = glyphs.glyphs[glyphs.numGlyphs - 1];
glyph_metrics_t gi = boundingBox(glyph);
if (gi.isValid())
- return round ? QFixed(qRound(gi.xoff - gi.x - gi.width))
- : QFixed(gi.xoff - gi.x - gi.width);
+ return round ? qRound(gi.rightBearing()) : gi.rightBearing();
}
return 0;
}
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 246df127ad..0d28785aa1 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -688,7 +688,6 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive));
}
- lbearing = rbearing = SHRT_MIN;
freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing);
FT_Face face = lockFace();
@@ -1258,54 +1257,6 @@ qreal QFontEngineFT::maxCharWidth() const
return metrics.max_advance >> 6;
}
-static const ushort char_table[] = {
- 40,
- 67,
- 70,
- 75,
- 86,
- 88,
- 89,
- 91,
- 95,
- 102,
- 114,
- 124,
- 127,
- 205,
- 645,
- 884,
- 922,
- 1070,
- 12386
-};
-
-static const int char_table_entries = sizeof(char_table)/sizeof(ushort);
-
-
-qreal QFontEngineFT::minLeftBearing() const
-{
- if (lbearing == SHRT_MIN)
- (void) minRightBearing(); // calculates both
- return lbearing.toReal();
-}
-
-qreal QFontEngineFT::minRightBearing() const
-{
- if (rbearing == SHRT_MIN) {
- lbearing = rbearing = 0;
- for (int i = 0; i < char_table_entries; ++i) {
- const glyph_t glyph = glyphIndex(char_table[i]);
- if (glyph != 0) {
- glyph_metrics_t gi = const_cast<QFontEngineFT *>(this)->boundingBox(glyph);
- lbearing = qMin(lbearing, gi.x);
- rbearing = qMin(rbearing, (gi.xoff - gi.x - gi.width));
- }
- }
- }
- return rbearing.toReal();
-}
-
QFixed QFontEngineFT::lineThickness() const
{
return line_thickness;
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index b81e51bf2e..83f9a4ef3d 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -208,8 +208,6 @@ private:
virtual QFixed averageCharWidth() const Q_DECL_OVERRIDE;
virtual qreal maxCharWidth() const Q_DECL_OVERRIDE;
- virtual qreal minLeftBearing() const Q_DECL_OVERRIDE;
- virtual qreal minRightBearing() const Q_DECL_OVERRIDE;
virtual QFixed lineThickness() const Q_DECL_OVERRIDE;
virtual QFixed underlinePosition() const Q_DECL_OVERRIDE;
@@ -324,8 +322,6 @@ private:
int xsize;
int ysize;
- mutable QFixed lbearing;
- mutable QFixed rbearing;
QFixed line_thickness;
QFixed underline_position;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 5329a5f11a..5282a4033e 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -214,8 +214,8 @@ public:
virtual QFixed underlinePosition() const;
virtual qreal maxCharWidth() const = 0;
- virtual qreal minLeftBearing() const { return qreal(); }
- virtual qreal minRightBearing() const { return qreal(); }
+ virtual qreal minLeftBearing() const;
+ virtual qreal minRightBearing() const;
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
@@ -240,7 +240,7 @@ public:
QFontEngineGlyphCache *glyphCache(const void *key, GlyphFormat format, const QTransform &transform) const;
static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize);
- static quint32 getTrueTypeGlyphIndex(const uchar *cmap, uint unicode);
+ static quint32 getTrueTypeGlyphIndex(const uchar *cmap, int cmapSize, uint unicode);
static QByteArray convertToPostscriptFontFamilyName(const QByteArray &fontFamily);
@@ -323,6 +323,10 @@ private:
private:
QVariant m_userData;
+
+ mutable qreal m_minLeftBearing;
+ mutable qreal m_minRightBearing;
+
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QFontEngine::ShaperFlags)
diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp
index a678b4c8ea..f2e05631a3 100644
--- a/src/gui/text/qfontengine_qpf2.cpp
+++ b/src/gui/text/qfontengine_qpf2.cpp
@@ -322,9 +322,9 @@ bool QFontEngineQPF2::getSfntTableData(uint tag, uchar *buffer, uint *length) co
glyph_t QFontEngineQPF2::glyphIndex(uint ucs4) const
{
- glyph_t glyph = getTrueTypeGlyphIndex(cmap, ucs4);
+ glyph_t glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4);
if (glyph == 0 && symbol && ucs4 < 0x100)
- glyph = getTrueTypeGlyphIndex(cmap, ucs4 + 0xf000);
+ glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4 + 0xf000);
if (!findGlyph(glyph))
glyph = 0;
@@ -348,16 +348,16 @@ bool QFontEngineQPF2::stringToCMap(const QChar *str, int len, QGlyphLayout *glyp
QStringIterator it(str, str + len);
while (it.hasNext()) {
const uint uc = it.next();
- glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc);
+ glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc);
if(!glyphs->glyphs[glyph_pos] && uc < 0x100)
- glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000);
+ glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000);
++glyph_pos;
}
} else {
QStringIterator it(str, str + len);
while (it.hasNext()) {
const uint uc = it.next();
- glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc);
+ glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc);
#if 0 && defined(DEBUG_FONTENGINE)
QChar c(uc);
if (!findGlyph(glyphs[glyph_pos].glyph) && !seenGlyphs.contains(c))
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index d2b39f274c..160daa0cfd 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -107,6 +107,22 @@ struct Q_GUI_EXPORT glyph_metrics_t
glyph_metrics_t transformed(const QTransform &xform) const;
inline bool isValid() const {return x != 100000 && y != 100000;}
+
+ inline QFixed leftBearing() const
+ {
+ if (!isValid())
+ return QFixed();
+
+ return x;
+ }
+
+ inline QFixed rightBearing() const
+ {
+ if (!isValid())
+ return QFixed();
+
+ return xoff - x - width;
+ }
};
Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE);
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index d56b9cf1b1..d68a59fae3 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1656,8 +1656,8 @@ namespace {
bool checkFullOtherwiseExtend(QScriptLine &line);
QFixed calculateNewWidth(const QScriptLine &line) const {
- return line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth
- - qMin(rightBearing, QFixed());
+ return line.textWidth + tmpData.textWidth + spaceData.textWidth
+ + softHyphenWidth + negativeRightBearing();
}
inline glyph_t currentGlyph() const
@@ -1677,33 +1677,51 @@ namespace {
}
}
- inline void adjustRightBearing(glyph_t glyph)
+ inline void calculateRightBearing(glyph_t glyph)
{
qreal rb;
fontEngine->getGlyphBearings(glyph, 0, &rb);
- rightBearing = qMin(QFixed(), QFixed::fromReal(rb));
+
+ // We only care about negative right bearings, so we limit the range
+ // of the bearing here so that we can assume it's negative in the rest
+ // of the code, as well ase use QFixed(1) as a sentinel to represent
+ // the state where we have yet to compute the right bearing.
+ rightBearing = qMin(QFixed::fromReal(rb), QFixed(0));
}
- inline void adjustRightBearing()
+ inline void calculateRightBearing()
{
if (currentPosition <= 0)
return;
- adjustRightBearing(currentGlyph());
+ calculateRightBearing(currentGlyph());
}
- inline void adjustPreviousRightBearing()
+ inline void calculateRightBearingForPreviousGlyph()
{
if (previousGlyph > 0)
- adjustRightBearing(previousGlyph);
+ calculateRightBearing(previousGlyph);
}
+ static const QFixed RightBearingNotCalculated;
+
inline void resetRightBearing()
{
- rightBearing = QFixed(1); // Any positive number is defined as invalid since only
- // negative right bearings are interesting to us.
+ rightBearing = RightBearingNotCalculated;
+ }
+
+ // We express the negative right bearing as an absolute number
+ // so that it can be applied to the width using addition.
+ inline QFixed negativeRightBearing() const
+ {
+ if (rightBearing == RightBearingNotCalculated)
+ return QFixed(0);
+
+ return qAbs(rightBearing);
}
};
+const QFixed LineBreakHelper::RightBearingNotCalculated = QFixed(1);
+
inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line)
{
LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal());
@@ -1856,7 +1874,7 @@ void QTextLine::layout_helper(int maxGlyphs)
current, lbh.logClusters, lbh.glyphs);
} else {
lbh.tmpData.length++;
- lbh.adjustPreviousRightBearing();
+ lbh.calculateRightBearingForPreviousGlyph();
}
line += lbh.tmpData;
goto found;
@@ -1938,22 +1956,36 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.tmpData.textWidth += lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]];
}
- // The actual width of the text needs to take the right bearing into account. The
- // right bearing is left-ward, which means that if the rightmost pixel is to the right
- // of the advance of the glyph, the bearing will be negative. We flip the sign
- // for the code to be more readable. Logic borrowed from qfontmetrics.cpp.
- // We ignore the right bearing if the minimum negative bearing is too little to
- // expand the text beyond the edge.
if (sb_or_ws|breakany) {
- QFixed rightBearing = lbh.rightBearing; // store previous right bearing
- if (lbh.calculateNewWidth(line) - lbh.minimumRightBearing > line.width)
- lbh.adjustRightBearing();
+ // To compute the final width of the text we need to take negative right bearing
+ // into account (negative right bearing means the glyph has pixel data past the
+ // advance length). Note that the negative right bearing is an absolute number,
+ // so that we can apply it to the width using straight forward addition.
+
+ // Store previous right bearing (for the already accepted glyph) in case we
+ // end up breaking due to the current glyph being too wide.
+ QFixed previousRightBearing = lbh.rightBearing;
+
+ // We skip calculating the right bearing if the minimum negative bearing is too
+ // small to possibly expand the text beyond the edge. Note that this optimization
+ // will in some cases fail, as the minimum right bearing reported by the font
+ // engine may not cover all the glyphs in the font. The result is that we think
+ // we don't need to break at the current glyph (because the right bearing is 0),
+ // and when we then end up breaking on the next glyph we compute the right bearing
+ // and end up with a line width that is slightly larger width than what was requested.
+ // Unfortunately we can't remove this optimization as it will slow down text
+ // layouting significantly, so we accept the slight correctnes issue.
+ if ((lbh.calculateNewWidth(line) + qAbs(lbh.minimumRightBearing)) > line.width)
+ lbh.calculateRightBearing();
+
if (lbh.checkFullOtherwiseExtend(line)) {
- // we are too wide, fix right bearing
- if (rightBearing <= 0)
- lbh.rightBearing = rightBearing; // take from cache
+ // We are too wide to accept the next glyph with its bearing, so we restore the
+ // right bearing to that of the previous glyph (the one that was already accepted),
+ // so that the bearing can be be applied to the final width of the text below.
+ if (previousRightBearing != LineBreakHelper::RightBearingNotCalculated)
+ lbh.rightBearing = previousRightBearing;
else
- lbh.adjustPreviousRightBearing();
+ lbh.calculateRightBearingForPreviousGlyph();
if (!breakany) {
line.textWidth += lbh.softHyphenWidth;
@@ -1970,10 +2002,14 @@ void QTextLine::layout_helper(int maxGlyphs)
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
found:
- if (lbh.rightBearing > 0 && !lbh.whiteSpaceOrObject) // If right bearing has not yet been adjusted
- lbh.adjustRightBearing();
line.textAdvance = line.textWidth;
- line.textWidth -= qMin(QFixed(), lbh.rightBearing);
+
+ // If right bearing has not been calculated yet, do that now
+ if (lbh.rightBearing == LineBreakHelper::RightBearingNotCalculated && !lbh.whiteSpaceOrObject)
+ lbh.calculateRightBearing();
+
+ // Then apply any negative right bearing
+ line.textWidth += lbh.negativeRightBearing();
if (line.length == 0) {
LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f",
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 6053466148..be002167cb 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -795,12 +795,6 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const
*/
/*!
- \variable FileInfo::d
- \internal
- private pointer.
-*/
-
-/*!
\class QZipReader
\internal
\since 4.5