diff options
author | Liang Qi <liang.qi@qt.io> | 2019-08-12 13:23:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-08-12 13:23:11 +0200 |
commit | 44c393f9b61797a240bfcbff1364ecdf7af41787 (patch) | |
tree | 94cca729399f5df23cf904f7bd866397d84aac7c /src/gui | |
parent | ffc2d5722317fcab86865b11491d7bf7fef3e16d (diff) | |
parent | e66f247ccf345f1d303a92e53c21bb53d96c5af2 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
config.tests/arch/write_info.pri
Repair architecture config test for the WASM_OBJECT_FILES=1 build mode
configure.pri
tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
Done-With: Jörg Bornemann <joerg.bornemann@qt.io>
Change-Id: I9e12088356eb5bc65b53211cd7a8e330cccd1bb4
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 35 | ||||
-rw-r--r-- | src/gui/text/AGLFN_LICENSE.txt | 26 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 25 | ||||
-rw-r--r-- | src/gui/text/qfontengine_p.h | 23 | ||||
-rw-r--r-- | src/gui/text/qt_attribution.json | 17 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 3 |
7 files changed, 91 insertions, 40 deletions
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/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4b06afd4eb..5bdf3299c9 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2908,19 +2908,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 e435177843..e59d425cb6 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 ¤tlyLockedAlphaMap; -} - -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 682395ece6..48dcdbeff7 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -124,6 +124,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; } @@ -191,11 +207,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 = 0); - 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*/) @@ -346,7 +358,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 c0a0c1a177..6e535c12b3 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1103,12 +1103,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); |