summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/doc/snippets/code/doc_src_qtgui.pro4
-rw-r--r--src/gui/doc/snippets/overview/using-qt-gui.cmake2
-rw-r--r--src/gui/doc/src/qtgui.qdoc23
-rw-r--r--src/gui/opengl/qopengltextureuploader.cpp50
-rw-r--r--src/gui/painting/qbezier.cpp6
-rw-r--r--src/gui/text/qfontdatabase.cpp52
-rw-r--r--src/gui/text/qtextengine.cpp3
7 files changed, 68 insertions, 72 deletions
diff --git a/src/gui/doc/snippets/code/doc_src_qtgui.pro b/src/gui/doc/snippets/code/doc_src_qtgui.pro
index e705555336..a5eb5b576c 100644
--- a/src/gui/doc/snippets/code/doc_src_qtgui.pro
+++ b/src/gui/doc/snippets/code/doc_src_qtgui.pro
@@ -1,7 +1,3 @@
-#! [0]
-#include <QtGui>
-#! [0]
-
#! [1]
QT -= gui
#! [1]
diff --git a/src/gui/doc/snippets/overview/using-qt-gui.cmake b/src/gui/doc/snippets/overview/using-qt-gui.cmake
new file mode 100644
index 0000000000..aecfa458a0
--- /dev/null
+++ b/src/gui/doc/snippets/overview/using-qt-gui.cmake
@@ -0,0 +1,2 @@
+find_package(Qt5 COMPONENTS Gui REQUIRED)
+target_link_libraries(mytarget Qt5::Gui)
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index 53fd55bd39..c4e7d32de1 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -40,18 +40,6 @@
These classes are used internally by Qt's user interface technologies
and can also be used directly, for instance to write applications using
low-level OpenGL ES graphics APIs.
-
- To include the definitions of the module's classes, use the
- following directive:
-
- \snippet code/doc_src_qtgui.pro 0
-
- \if !defined(qtforpython)
- If you use \l qmake to build your projects, \l{Qt GUI} is included by
- default. To disable Qt GUI, add the following line to your \c .pro file:
-
- \snippet code/doc_src_qtgui.pro 1
- \endif
*/
/*!
@@ -69,14 +57,15 @@
higher level API's, like Qt Quick, that are much more suitable
than the enablers found in the Qt GUI module.
- \section1 Getting Started
+ \if !defined(qtforpython)
- To include the definitions of the module's classes, use the
- following directive:
+ \include module-use.qdocinc using qt module
+ \quotefile overview/using-qt-gui.cmake
- \snippet code/doc_src_qtgui.pro 0
+ See also the \l[QtDoc]{Building with CMake} overview.
+
+ \section2 Building with qmake
- \if !defined(qtforpython)
If you use \l qmake to build your projects, Qt GUI is included by
default. To disable Qt GUI, add the following line to your \c .pro file:
diff --git a/src/gui/opengl/qopengltextureuploader.cpp b/src/gui/opengl/qopengltextureuploader.cpp
index b8b532b3d0..d9d5403cf3 100644
--- a/src/gui/opengl/qopengltextureuploader.cpp
+++ b/src/gui/opengl/qopengltextureuploader.cpp
@@ -77,8 +77,20 @@
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#endif
-#ifndef GL_TEXTURE_SWIZZLE_RGBA
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
+#ifndef GL_TEXTURE_SWIZZLE_R
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#endif
+
+#ifndef GL_TEXTURE_SWIZZLE_G
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#endif
+
+#ifndef GL_TEXTURE_SWIZZLE_B
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#endif
+
+#ifndef GL_TEXTURE_SWIZZLE_A
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
#endif
#ifndef GL_SRGB
@@ -128,11 +140,13 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
#endif
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
- funcs->glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED);
#else
- GLint swizzle[4] = { GL_GREEN, GL_BLUE, GL_ALPHA, GL_RED };
- funcs->glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_GREEN);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_BLUE);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_ALPHA);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_RED);
#endif
externalFormat = internalFormat = GL_RGBA;
pixelType = GL_UNSIGNED_BYTE;
@@ -164,12 +178,12 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
externalFormat = GL_BGRA;
internalFormat = GL_RGB10_A2;
targetFormat = image.format();
- } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle) && (isOpenGL12orBetter || isOpenGLES3orBetter)) {
+ } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
pixelType = GL_UNSIGNED_INT_2_10_10_10_REV;
externalFormat = GL_RGBA;
internalFormat = GL_RGB10_A2;
- GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
targetFormat = image.format();
}
break;
@@ -227,8 +241,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
- GLint swizzle[4] = { GL_ZERO, GL_ZERO, GL_ZERO, GL_RED };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ALPHA);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ZERO);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ZERO);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ZERO);
externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
@@ -247,8 +263,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
- GLint swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
@@ -267,8 +285,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_SHORT;
targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
- GLint swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_SHORT;
targetFormat = image.format();
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index ddd1d997f2..8cda4b4072 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -261,9 +261,9 @@ static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offse
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
{
int map[4];
- bool p1_p2_equal = (orig->x1 == orig->x2 && orig->y1 == orig->y2);
- bool p2_p3_equal = (orig->x2 == orig->x3 && orig->y2 == orig->y3);
- bool p3_p4_equal = (orig->x3 == orig->x4 && orig->y3 == orig->y4);
+ bool p1_p2_equal = qFuzzyCompare(orig->x1, orig->x2) && qFuzzyCompare(orig->y1, orig->y2);
+ bool p2_p3_equal = qFuzzyCompare(orig->x2, orig->x3) && qFuzzyCompare(orig->y2, orig->y3);
+ bool p3_p4_equal = qFuzzyCompare(orig->x3, orig->x4) && qFuzzyCompare(orig->y3, orig->y4);
QPointF points[4];
int np = 0;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index fa9573441a..778214128e 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qfontdatabase.h"
-#include "qdebug.h"
+#include "qloggingcategory.h"
#include "qalgorithms.h"
#include "qguiapplication.h"
#include "qvarlengtharray.h" // here or earlier - workaround for VC++6
@@ -59,25 +59,13 @@
#include <stdlib.h>
#include <algorithm>
-
-// #define QFONTDATABASE_DEBUG
-#ifdef QFONTDATABASE_DEBUG
-# define FD_DEBUG qDebug
-#else
-# define FD_DEBUG if (false) qDebug
-#endif
-
-// #define FONT_MATCH_DEBUG
-#ifdef FONT_MATCH_DEBUG
-# define FM_DEBUG qDebug
-#else
-# define FM_DEBUG if (false) qDebug
-#endif
-
#include <qtgui_tracepoints_p.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcFontDb, "qt.text.font.db")
+Q_LOGGING_CATEGORY(lcFontMatch, "qt.text.font.match")
+
#define SMOOTH_SCALABLE 0xffff
#if defined(QT_BUILD_INTERNAL)
@@ -744,7 +732,7 @@ void qt_registerFont(const QString &familyName, const QString &stylename,
const QSupportedWritingSystems &writingSystems, void *handle)
{
QFontDatabasePrivate *d = privateDb();
-// qDebug() << "Adding font" << familyName << weight << style << pixelSize << antialiased;
+ qCDebug(lcFontDb) << "Adding font" << familyName << weight << style << pixelSize << "aa" << antialiased << "fixed" << fixedPitch;
QtFontStyle::Key styleKey;
styleKey.style = style;
styleKey.weight = weight;
@@ -1079,7 +1067,7 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
}
}
- FM_DEBUG( " best style has distance 0x%x", dist );
+ qCDebug(lcFontMatch, " best style has distance 0x%x", dist );
return foundry->styles[best];
}
@@ -1098,20 +1086,20 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
desc->size = 0;
- FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
+ qCDebug(lcFontMatch, " REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
for (int x = 0; x < family->count; ++x) {
QtFontFoundry *foundry = family->foundries[x];
if (!foundry_name.isEmpty() && foundry->name.compare(foundry_name, Qt::CaseInsensitive) != 0)
continue;
- FM_DEBUG(" looking for matching style in foundry '%s' %d",
+ qCDebug(lcFontMatch, " looking for matching style in foundry '%s' %d",
foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
QtFontStyle *style = bestStyle(foundry, styleKey, styleName);
if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) {
- FM_DEBUG(" ForceOutline set, but not smoothly scalable");
+ qCDebug(lcFontMatch, " ForceOutline set, but not smoothly scalable");
continue;
}
@@ -1122,7 +1110,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!(styleStrategy & QFont::ForceOutline)) {
size = style->pixelSize(pixelSize);
if (size) {
- FM_DEBUG(" found exact size match (%d pixels)", size->pixelSize);
+ qCDebug(lcFontMatch, " found exact size match (%d pixels)", size->pixelSize);
px = size->pixelSize;
}
}
@@ -1131,7 +1119,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!size && style->smoothScalable && ! (styleStrategy & QFont::PreferBitmap)) {
size = style->pixelSize(SMOOTH_SCALABLE);
if (size) {
- FM_DEBUG(" found smoothly scalable font (%d pixels)", pixelSize);
+ qCDebug(lcFontMatch, " found smoothly scalable font (%d pixels)", pixelSize);
px = pixelSize;
}
}
@@ -1140,7 +1128,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!size && style->bitmapScalable && (styleStrategy & QFont::PreferMatch)) {
size = style->pixelSize(0);
if (size) {
- FM_DEBUG(" found bitmap scalable font (%d pixels)", pixelSize);
+ qCDebug(lcFontMatch, " found bitmap scalable font (%d pixels)", pixelSize);
px = pixelSize;
}
}
@@ -1164,12 +1152,12 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (d < distance) {
distance = d;
size = style->pixelSizes + x;
- FM_DEBUG(" best size so far: %3d (%d)", size->pixelSize, pixelSize);
+ qCDebug(lcFontMatch, " best size so far: %3d (%d)", size->pixelSize, pixelSize);
}
}
if (!size) {
- FM_DEBUG(" no size supports the script we want");
+ qCDebug(lcFontMatch, " no size supports the script we want");
continue;
}
@@ -1204,7 +1192,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
this_score += qAbs(px - pixelSize);
if (this_score < score) {
- FM_DEBUG(" found a match: score %x best score so far %x",
+ qCDebug(lcFontMatch, " found a match: score %x best score so far %x",
this_score, score);
score = this_score;
@@ -1212,7 +1200,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
desc->style = style;
desc->size = size;
} else {
- FM_DEBUG(" score %x no better than best %x", this_score, score);
+ qCDebug(lcFontMatch, " score %x no better than best %x", this_score, score);
}
}
@@ -1245,7 +1233,7 @@ static int match(int script, const QFontDef &request,
char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
- FM_DEBUG("QFontDatabase::match\n"
+ qCDebug(lcFontMatch, "QFontDatabase::match\n"
" request:\n"
" family: %s [%s], script: %d\n"
" weight: %d, style: %d\n"
@@ -2683,7 +2671,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
QFontCache::Key key(request, script, multi ? 1 : 0);
engine = fontCache->findEngine(key);
if (engine) {
- FM_DEBUG("Cache hit level 1");
+ qCDebug(lcFontMatch, "Cache hit level 1");
return engine;
}
@@ -2712,7 +2700,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
else
blackListed.append(index);
} else {
- FM_DEBUG(" NO MATCH FOUND\n");
+ qCDebug(lcFontMatch, " NO MATCH FOUND\n");
}
if (!engine) {
@@ -2756,7 +2744,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
if (!engine)
engine = new QFontEngineBox(request.pixelSize);
- FM_DEBUG("returning box engine");
+ qCDebug(lcFontMatch, "returning box engine");
}
return engine;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 22c93d7ec2..2da13289bf 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1383,11 +1383,12 @@ void QTextEngine::shapeText(int item) const
if (QChar::isHighSurrogate(ucs4) && i + 1 < itemLength) {
uint low = string[i + 1];
if (QChar::isLowSurrogate(low)) {
+ // high part never changes in simple casing
+ uc[i] = ucs4;
++i;
ucs4 = QChar::surrogateToUcs4(ucs4, low);
ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
: QChar::toUpper(ucs4);
- // high part never changes in simple casing
uc[i] = QChar::lowSurrogate(ucs4);
}
} else {