summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp2
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp2
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h20
-rw-r--r--src/gui/kernel/qopenglcontext.cpp3
-rw-r--r--src/gui/kernel/qplatformintegration.cpp3
-rw-r--r--src/gui/kernel/qplatformintegration.h3
-rw-r--r--src/gui/kernel/qsurface.cpp6
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp12
-rw-r--r--src/gui/painting/qcompositionfunctions.cpp24
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp35
-rw-r--r--src/gui/text/AGLFN_LICENSE.txt26
-rw-r--r--src/gui/text/qfontengine.cpp25
-rw-r--r--src/gui/text/qfontengine_p.h23
-rw-r--r--src/gui/text/qt_attribution.json17
-rw-r--r--src/gui/text/qtextdocument_p.cpp3
-rw-r--r--src/gui/text/qtextlayout.h4
16 files changed, 140 insertions, 68 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index cd2fe5bc10..8e0bbb6907 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -716,7 +716,7 @@ bool QImageData::checkForAlphaPixels() const
\value Format_Grayscale8 The image is stored using an 8-bit grayscale format. (added in Qt 5.5)
\value Format_Grayscale16 The image is stored using an 16-bit grayscale format. (added in Qt 5.13)
\value Format_RGBX64 The image is stored using a 64-bit halfword-ordered RGB(x) format (16-16-16-16).
- This is the same as the Format_RGBX64 except alpha must always be 65535. (added in Qt 5.12)
+ This is the same as the Format_RGBA64 except alpha must always be 65535. (added in Qt 5.12)
\value Format_RGBA64 The image is stored using a 64-bit halfword-ordered RGBA format (16-16-16-16). (added in Qt 5.12)
\value Format_RGBA64_Premultiplied The image is stored using a premultiplied 64-bit halfword-ordered
RGBA format (16-16-16-16). (added in Qt 5.12)
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 0fea416404..64f1397771 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -456,6 +456,8 @@ QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QPlatformS
{
if (!m_active)
return { qreal(1), QPoint() };
+ if (!platformScreen)
+ return { m_factor, QPoint() }; // the global factor
const QPlatformScreen *actualScreen = nativePosition ?
platformScreen->screenForPosition(*nativePosition) : platformScreen;
return { m_factor * screenSubfactor(actualScreen), actualScreen->geometry().topLeft() };
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 50221926c6..674b737808 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -59,6 +59,7 @@
#include <QtCore/qloggingcategory.h>
#include <QtGui/qregion.h>
#include <QtGui/qscreen.h>
+#include <QtGui/qvector2d.h>
#include <QtGui/qwindow.h>
QT_BEGIN_NAMESPACE
@@ -117,13 +118,26 @@ private:
namespace QHighDpi {
-template <typename T>
-inline T scale(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0))
+inline qreal scale(qreal value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
{
- Q_UNUSED(origin)
return value * scaleFactor;
}
+inline QSize scale(const QSize &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
+{
+ return value * scaleFactor;
+}
+
+inline QSizeF scale(const QSizeF &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
+{
+ return value * scaleFactor;
+}
+
+inline QVector2D scale(const QVector2D &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
+{
+ return value * float(scaleFactor);
+}
+
inline QPointF scale(const QPointF &pos, qreal scaleFactor, QPointF origin = QPointF(0, 0))
{
return (pos - origin) * scaleFactor + origin;
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 10adee438b..6f51fe3095 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -976,11 +976,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
if (!surface->surfaceHandle())
return false;
if (!surface->supportsOpenGL()) {
-#ifndef Q_OS_WASM // ### work around the WASM platform plugin using QOpenGLContext with raster surfaces.
- // see QTBUG-70076
qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface;
return false;
-#endif
}
if (!d->platformGLContext->makeCurrent(surface->surfaceHandle()))
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 490cfc6178..b3d3db0751 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -244,6 +244,9 @@ QPlatformServices *QPlatformIntegration::services() const
\value TopStackedNativeChildWindows The platform supports native child windows via
QWindowContainer without having to punch a transparent hole in the
backingstore. (since 5.10)
+
+ \value OpenGLOnRasterSurface The platform supports making a QOpenGLContext current
+ in combination with a QWindow of type RasterSurface.
*/
/*!
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index b764bd2617..d9f349555a 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -105,7 +105,8 @@ public:
AllGLFunctionsQueryable,
ApplicationIcon,
SwitchableWidgetComposition,
- TopStackedNativeChildWindows
+ TopStackedNativeChildWindows,
+ OpenGLOnRasterSurface
};
virtual ~QPlatformIntegration() { }
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 415e64b39c..709f28d431 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -39,6 +39,8 @@
#include "qsurface.h"
#include "qopenglcontext.h"
+#include <qpa/qplatformintegration.h>
+#include <QtGui/private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -103,6 +105,10 @@ QT_BEGIN_NAMESPACE
bool QSurface::supportsOpenGL() const
{
SurfaceType type = surfaceType();
+ if (type == RasterSurface) {
+ QPlatformIntegration *integ = QGuiApplicationPrivate::instance()->platformIntegration();
+ return integ->hasCapability(QPlatformIntegration::OpenGLOnRasterSurface);
+ }
return type == OpenGLSurface || type == RasterGLSurface;
}
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 2e2738ec81..238886220b 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -554,10 +554,6 @@ int QSurfaceFormat::alphaBufferSize() const
/*!
Set the desired \a size in bits of the red channel of the color buffer.
-
- \note On Mac OSX, be sure to set the buffer size of all color channels,
- otherwise this setting will have no effect. If one of the buffer sizes is not set,
- the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setRedBufferSize(int size)
{
@@ -569,10 +565,6 @@ void QSurfaceFormat::setRedBufferSize(int size)
/*!
Set the desired \a size in bits of the green channel of the color buffer.
-
- \note On Mac OSX, be sure to set the buffer size of all color channels,
- otherwise this setting will have no effect. If one of the buffer sizes is not set,
- the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setGreenBufferSize(int size)
{
@@ -584,10 +576,6 @@ void QSurfaceFormat::setGreenBufferSize(int size)
/*!
Set the desired \a size in bits of the blue channel of the color buffer.
-
- \note On Mac OSX, be sure to set the buffer size of all color channels,
- otherwise this setting will have no effect. If one of the buffer sizes is not set,
- the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setBlueBufferSize(int size)
{
diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp
index 06a849e790..ced213e36d 100644
--- a/src/gui/painting/qcompositionfunctions.cpp
+++ b/src/gui/painting/qcompositionfunctions.cpp
@@ -1813,8 +1813,10 @@ void QT_FASTCALL comp_func_Lighten_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QR
#endif
/*
- if Sca.Da + Dca.Sa >= Sa.Da
+ if Sca.Da + Dca.Sa > Sa.Da
Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa)
+ else if Sca == Sa
+ Dca' = Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
otherwise
Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
*/
@@ -1825,8 +1827,10 @@ static inline int color_dodge_op(int dst, int src, int da, int sa)
const int src_da = src * da;
const int temp = src * (255 - da) + dst * (255 - sa);
- if (src_da + dst_sa >= sa_da)
+ if (src_da + dst_sa > sa_da)
return qt_div_255(sa_da + temp);
+ else if (src == sa || sa == 0)
+ return qt_div_255(temp);
else
return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp);
}
@@ -1870,8 +1874,10 @@ static inline uint color_dodge_op_rgb64(qint64 dst, qint64 src, qint64 da, qint6
const qint64 src_da = src * da;
const qint64 temp = src * (65535 - da) + dst * (65535 - sa);
- if (src_da + dst_sa >= sa_da)
+ if (src_da + dst_sa > sa_da)
return qt_div_65535(sa_da + temp);
+ else if (src == sa || sa == 0)
+ return qt_div_65535(temp);
else
return qt_div_65535(65535 * dst_sa / (65535 - 65535 * src / sa) + temp);
}
@@ -1969,8 +1975,10 @@ void QT_FASTCALL comp_func_ColorDodge_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const
#endif
/*
- if Sca.Da + Dca.Sa <= Sa.Da
+ if Sca.Da + Dca.Sa < Sa.Da
Dca' = Sca.(1 - Da) + Dca.(1 - Sa)
+ else if Sca == 0
+ Dca' = Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
otherwise
Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa)
*/
@@ -1982,8 +1990,10 @@ static inline int color_burn_op(int dst, int src, int da, int sa)
const int temp = src * (255 - da) + dst * (255 - sa);
- if (src == 0 || src_da + dst_sa <= sa_da)
+ if (src_da + dst_sa < sa_da)
return qt_div_255(temp);
+ else if (src == 0)
+ return qt_div_255(dst_sa + temp);
return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp);
}
@@ -2027,8 +2037,10 @@ static inline uint color_burn_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64
const qint64 temp = src * (65535 - da) + dst * (65535 - sa);
- if (src == 0 || src_da + dst_sa <= sa_da)
+ if (src_da + dst_sa < sa_da)
return qt_div_65535(temp);
+ else if (src == 0)
+ return qt_div_65535(dst_sa + temp);
return qt_div_65535(sa * (src_da + dst_sa - sa_da) / src + temp);
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 0a440e5b75..5ab5514dd4 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2883,19 +2883,34 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
for (int i = 0; i < numGlyphs; i++) {
QFixed spp = fontEngine->subPixelPositionForX(positions[i].x);
- QPoint offset;
- const QImage *alphaMap = fontEngine->lockedAlphaMapForGlyph(glyphs[i], spp, neededFormat, s->matrix,
- &offset);
- if (alphaMap == 0 || alphaMap->isNull())
+ const QFontEngine::Glyph *alphaMap = fontEngine->glyphData(glyphs[i], spp, neededFormat, s->matrix);
+ if (!alphaMap)
continue;
- alphaPenBlt(alphaMap->constBits(), alphaMap->bytesPerLine(), alphaMap->depth(),
- qFloor(positions[i].x) + offset.x(),
- qRound(positions[i].y) + offset.y(),
- alphaMap->width(), alphaMap->height(),
+ int depth;
+ int bytesPerLine;
+ switch (alphaMap->format) {
+ case QFontEngine::Format_Mono:
+ depth = 1;
+ bytesPerLine = ((alphaMap->width + 31) & ~31) >> 3;
+ break;
+ case QFontEngine::Format_A8:
+ depth = 8;
+ bytesPerLine = (alphaMap->width + 3) & ~3;
+ break;
+ case QFontEngine::Format_A32:
+ depth = 32;
+ bytesPerLine = alphaMap->width * 4;
+ break;
+ default:
+ Q_UNREACHABLE();
+ };
+
+ alphaPenBlt(alphaMap->data, bytesPerLine, depth,
+ qFloor(positions[i].x) + alphaMap->x,
+ qRound(positions[i].y) - alphaMap->y,
+ alphaMap->width, alphaMap->height,
fontEngine->expectsGammaCorrectedBlending());
-
- fontEngine->unlockAlphaMapForGlyph();
}
} else {
diff --git a/src/gui/text/AGLFN_LICENSE.txt b/src/gui/text/AGLFN_LICENSE.txt
new file mode 100644
index 0000000000..50abffca15
--- /dev/null
+++ b/src/gui/text/AGLFN_LICENSE.txt
@@ -0,0 +1,26 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+Neither the name of Adobe Systems Incorporated nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 4198df6e43..403a0510fa 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -923,29 +923,10 @@ QFixed QFontEngine::subPixelPositionForX(QFixed x) const
return subPixelPosition;
}
-QImage *QFontEngine::lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
- QFontEngine::GlyphFormat neededFormat,
- const QTransform &t, QPoint *offset)
+QFontEngine::Glyph *QFontEngine::glyphData(glyph_t, QFixed,
+ QFontEngine::GlyphFormat, const QTransform &)
{
- Q_ASSERT(currentlyLockedAlphaMap.isNull());
- if (neededFormat == Format_None)
- neededFormat = Format_A32;
-
- if (neededFormat != Format_A32)
- currentlyLockedAlphaMap = alphaMapForGlyph(glyph, subPixelPosition, t);
- else
- currentlyLockedAlphaMap = alphaRGBMapForGlyph(glyph, subPixelPosition, t);
-
- if (offset != 0)
- *offset = QPoint(0, 0);
-
- return &currentlyLockedAlphaMap;
-}
-
-void QFontEngine::unlockAlphaMapForGlyph()
-{
- Q_ASSERT(!currentlyLockedAlphaMap.isNull());
- currentlyLockedAlphaMap = QImage();
+ return nullptr;
}
QImage QFontEngine::alphaMapForGlyph(glyph_t glyph)
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index e20b52cb65..a5c78d5372 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -123,6 +123,22 @@ public:
};
Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag)
+ /* Used with the Freetype font engine. We don't cache glyphs that are too large anyway, so we can make this struct rather small */
+ struct Glyph {
+ Glyph() = default;
+ ~Glyph() { delete [] data; }
+ short linearAdvance = 0;
+ unsigned char width = 0;
+ unsigned char height = 0;
+ short x = 0;
+ short y = 0;
+ short advance = 0;
+ signed char format = 0;
+ uchar *data = nullptr;
+ private:
+ Q_DISABLE_COPY(Glyph);
+ };
+
virtual ~QFontEngine();
inline Type type() const { return m_type; }
@@ -190,11 +206,7 @@ public:
virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t, const QColor &color = QColor());
- virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
- GlyphFormat neededFormat,
- const QTransform &t = QTransform(),
- QPoint *offset = nullptr);
- virtual void unlockAlphaMapForGlyph();
+ virtual Glyph *glyphData(glyph_t glyph, QFixed subPixelPosition, GlyphFormat neededFormat, const QTransform &t);
virtual bool hasInternalCaching() const { return false; }
virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed /*subPixelPosition*/, const QTransform &matrix, GlyphFormat /*format*/)
@@ -345,7 +357,6 @@ public:
void loadKerningPairs(QFixed scalingFactor);
GlyphFormat glyphFormat;
- QImage currentlyLockedAlphaMap;
int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
inline QVariant userData() const { return m_userData; }
diff --git a/src/gui/text/qt_attribution.json b/src/gui/text/qt_attribution.json
new file mode 100644
index 0000000000..c3a57267e2
--- /dev/null
+++ b/src/gui/text/qt_attribution.json
@@ -0,0 +1,17 @@
+[
+ {
+ "Id": "aglfn",
+ "Name": "Adobe Glyph List For New Fonts",
+ "QDocModule": "qtgui",
+ "Description": "Provides standardized names for glyphs.",
+ "QtUsage": "Used by PDF generator to make it easier for reader applications to resolve the original contents of rendered text.",
+ "Path": "qfontsubset_agl.cpp",
+
+ "Homepage": "https://github.com/adobe-type-tools/agl-aglfn",
+ "Version": "1.7",
+ "License": "BSD 3-Clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "AGLFN_LICENSE.txt",
+ "Copyright": "Copyright 2002, 2003, 2005, 2006, 2008, 2010, 2015 Adobe Systems"
+ }
+]
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 0e3c8d0e83..a1b1c2e92b 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1106,12 +1106,11 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
bool redoCommandsAvailable = undoState != undoStack.size();
if (stacksToClear == QTextDocument::UndoStack && undoCommandsAvailable) {
for (int i = 0; i < undoState; ++i) {
- QTextUndoCommand c = undoStack.at(undoState);
+ QTextUndoCommand c = undoStack.at(i);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
undoStack.remove(0, undoState);
- undoStack.resize(undoStack.size() - undoState);
undoState = 0;
if (emitSignals)
emitUndoAvailable(false);
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index a29791534e..2fc0fcd55a 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -114,8 +114,8 @@ public:
// not ambiguous. Implementation detail that should not be documented.
template<char = 0>
#endif
- QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice)
- : QTextLayout(text, font, const_cast<QPaintDevice*>(paintdevice))
+ QTextLayout(const QString &textData, const QFont &textFont, const QPaintDevice *paintdevice)
+ : QTextLayout(textData, textFont, const_cast<QPaintDevice*>(paintdevice))
{}
#else
QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice = nullptr);