From: Ivailo Monev Date: Fri, 1 Jul 2016 16:57:18 +0000 (+0000) Subject: various cleanups X-Git-Tag: 4.12.0~7110 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=49abec547568d8d414398c3e2aad7161c9bc572c;p=kde%2FKatie.git various cleanups Signed-off-by: Ivailo Monev --- diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp index 209201b20..6541d11b3 100644 --- a/src/gui/image/qpaintengine_pic.cpp +++ b/src/gui/image/qpaintengine_pic.cpp @@ -59,6 +59,8 @@ //#define QT_PICTURE_DEBUG #include +// keep in sync with qpicture.cpp +static const char *qt_mfhdr_tag = "QPIC"; // header tag QT_BEGIN_NAMESPACE @@ -103,18 +105,14 @@ bool QPicturePaintEngine::begin(QPaintDevice *pd) Q_ASSERT(d->pic_d); d->s.setDevice(&d->pic_d->pictb); - d->s.setVersion(d->pic_d->formatMajor); d->pic_d->pictb.open(QIODevice::WriteOnly | QIODevice::Truncate); d->s.writeRawData(qt_mfhdr_tag, 4); - d->s << (quint16) 0 << (quint16) d->pic_d->formatMajor << (quint16) d->pic_d->formatMinor; d->s << (quint8) QPicturePrivate::PdcBegin << (quint8) sizeof(qint32); d->pic_d->brect = QRect(); - if (d->pic_d->formatMajor >= 4) { - QRect r = pic->boundingRect(); - d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width() - << (qint32) r.height(); - } + QRect r = pic->boundingRect(); + d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width() + << (qint32) r.height(); d->pic_d->trecs = 0; d->s << (quint32)d->pic_d->trecs; // total number of records d->pic_d->formatOk = false; @@ -135,11 +133,11 @@ bool QPicturePaintEngine::end() int brect_start = data_start + 2*sizeof(qint16) + 2*sizeof(quint8); int pos = d->pic_d->pictb.pos(); d->pic_d->pictb.seek(brect_start); - if (d->pic_d->formatMajor >= 4) { // bounding rectangle - QRect r = static_cast(d->pdev)->boundingRect(); - d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width() - << (qint32) r.height(); - } + // bounding rectangle + QRect r = static_cast(d->pdev)->boundingRect(); + d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width() + << (qint32) r.height(); + // end bounding rectangle d->s << (quint32) d->pic_d->trecs; // write number of records d->pic_d->pictb.seek(cs_start); QByteArray buf = d->pic_d->pictb.buffer(); @@ -488,33 +486,19 @@ void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) if (si.chars == 0) QPaintEngine::drawTextItem(p, ti); // Draw as path - if (d->pic_d->formatMajor >= 9) { - int pos; - SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem); - QFont fnt = ti.font(); - fnt.setUnderline(false); - fnt.setStrikeOut(false); - fnt.setOverline(false); - - qreal justificationWidth = 0; - if (si.justified) - justificationWidth = si.width.toReal(); - - d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth; - writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false); - } else if (d->pic_d->formatMajor >= 8) { - // old old (buggy) format - int pos; - SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem); - d->s << QPointF(p.x(), p.y() - ti.ascent()) << ti.text() << ti.font() << ti.renderFlags(); - writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false); - } else { - // old (buggy) format - int pos; - SERIALIZE_CMD(QPicturePrivate::PdcDrawText2); - d->s << p << ti.text(); - writeCmdLength(pos, QRectF(p, QSizeF(1,1)), true); - } + int pos; + SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem); + QFont fnt = ti.font(); + fnt.setUnderline(false); + fnt.setStrikeOut(false); + fnt.setOverline(false); + + qreal justificationWidth = 0; + if (si.justified) + justificationWidth = si.width.toReal(); + + d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth; + writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false); } void QPicturePaintEngine::updateState(const QPaintEngineState &state) diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 78f4054f4..2ae2e5771 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -107,8 +107,8 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, \sa QMovie */ -const char *qt_mfhdr_tag = "QPIC"; // header tag -static const quint16 mfhdr_maj = 11; // major version # +// keep in sync with qpaintengine_pic.cpp +static const char *qt_mfhdr_tag = "QPIC"; // header tag /*! Constructs an empty picture. @@ -341,7 +341,6 @@ bool QPicture::play(QPainter *painter) QDataStream s; s.setDevice(&d->pictb); // attach data stream to buffer s.device()->seek(10); // go directly to the data - s.setVersion(mfhdr_maj); quint8 c, clen; quint32 nrecords; @@ -882,16 +881,6 @@ bool QPicturePrivate::checkFormat() return false; } - quint16 major, minor; - s >> major >> minor; // read version number - if (major > mfhdr_maj) { // new, incompatible version - qWarning("QPicturePaintEngine::checkFormat: Incompatible version %d.%d", - major, minor); - pictb.close(); - return false; - } - s.setVersion(major); - quint8 c, clen; s >> c >> clen; if (c == QPicturePrivate::PdcBegin) { @@ -954,7 +943,6 @@ QDataStream &operator>>(QDataStream &s, QPicture &r) // "init"; this code is similar to the beginning of QPicture::cmd() sr.setDevice(&r.d_func()->pictb); - sr.setVersion(mfhdr_maj); quint32 len; s >> len; QByteArray data; diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h index 081758bdc..abc3d29af 100644 --- a/src/gui/image/qpicture_p.h +++ b/src/gui/image/qpicture_p.h @@ -67,8 +67,6 @@ QT_BEGIN_NAMESPACE class QPaintEngine; -extern const char *qt_mfhdr_tag; - class QPicturePrivate { friend class QPicturePaintEngine; @@ -152,8 +150,6 @@ public: QBuffer pictb; int trecs; bool formatOk; - int formatMajor; - int formatMinor; QRect brect; QRect override_rect; QScopedPointer paintEngine; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 978d03abe..b439c1068 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -455,8 +455,6 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[count++]; } -// ### copied to tools/makeqpf/qpf2.cpp - // see the Unicode subset bitfields in the MSDN docs static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { // Any, diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index d4725177e..1b2e6523b 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -63,8 +63,6 @@ class Q_GUI_EXPORT QFontDatabase Q_GADGET Q_ENUMS(WritingSystem) public: - // do not re-order or delete entries from this enum without updating the - // QPF2 format and makeqpf!! enum WritingSystem { Any, @@ -160,9 +158,6 @@ private: friend class QFontDialog; friend class QFontDialogPrivate; friend class QFontEngineMultiXLFD; - friend class QFontEngineMultiQWS; - friend class QFontEngineMultiS60; - friend class QFontEngineMultiQPA; QFontDatabasePrivate *d; }; diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 61d31abba..4f5a4bee4 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -716,7 +716,6 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); } else { - // copied from QFontEngineQPF // ad hoc algorithm int score = fontDef.weight * fontDef.pixelSize; line_thickness = score / 700; diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp deleted file mode 100644 index 65fc26cab..000000000 --- a/src/gui/text/qfontengine_qpf.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfontengine_qpf_p.h" - -#include "qpaintengine_raster_p.h" -#include -#include - -#include -#include -#include -#if !defined(QT_NO_FREETYPE) -#include "qfontengine_ft_p.h" -#endif -#include "qcore_unix_p.h" // overrides QT_OPEN - -// for mmap -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - - -QString qws_fontCacheDir() -{ - QString dir = QDir::tempPath(); - dir.append(QLatin1String("/fonts/")); - QDir qd(dir); - if (!qd.exists() && !qd.mkpath(dir)) - dir = QDir::tempPath(); - return dir; -} - - -/* - Creates a new multi qws engine. - - This function takes ownership of the QFontEngine, increasing it's refcount. -*/ -QFontEngineMultiQWS::QFontEngineMultiQWS(QFontEngine *fe, int _script, const QStringList &fallbacks) - : QFontEngineMulti(fallbacks.size() + 1), - fallbackFamilies(fallbacks), script(_script) -{ - engines[0] = fe; - fe->ref.ref(); - fontDef = engines[0]->fontDef; -} - -void QFontEngineMultiQWS::loadEngine(int at) -{ - Q_ASSERT(at < engines.size()); - Q_ASSERT(engines.at(at) == 0); - - QFontDef request = fontDef; - request.styleStrategy |= QFont::NoFontMerging; - request.family = fallbackFamilies.at(at-1); - engines[at] = QFontDatabase::findFont(script, - /*fontprivate*/0, - request); - Q_ASSERT(engines[at]); - engines[at]->ref.ref(); - engines[at]->fontDef = request; -} - -void QFontEngineMultiQWS::draw(QPaintEngine */*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt &/*si*/) -{ - qFatal("QFontEngineMultiQWS::draw should never be called!"); -} - -QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_qpf_p.h b/src/gui/text/qfontengine_qpf_p.h deleted file mode 100644 index a64baba3f..000000000 --- a/src/gui/text/qfontengine_qpf_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFONTENGINE_QPF_P_H -#define QFONTENGINE_QPF_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qfontengine_p.h" -#include -#include - - -QT_BEGIN_NAMESPACE - - -class QFontEngineMultiQWS : public QFontEngineMulti -{ -public: - QFontEngineMultiQWS(QFontEngine *fe, int script, const QStringList &fallbacks); - - void loadEngine(int at); - void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si); - -private: - QStringList fallbackFamilies; - int script; -}; - -QT_END_NAMESPACE - -#endif // QFONTENGINE_QPF_P_H diff --git a/src/gui/text/qpfutil.cpp b/src/gui/text/qpfutil.cpp deleted file mode 100644 index a33768260..000000000 --- a/src/gui/text/qpfutil.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -static const QFontEngineQPF::TagType tagTypes[QFontEngineQPF::NumTags] = { - QFontEngineQPF::StringType, // FontName - QFontEngineQPF::StringType, // FileName - QFontEngineQPF::UInt32Type, // FileIndex - QFontEngineQPF::UInt32Type, // FontRevision - QFontEngineQPF::StringType, // FreeText - QFontEngineQPF::FixedType, // Ascent - QFontEngineQPF::FixedType, // Descent - QFontEngineQPF::FixedType, // Leading - QFontEngineQPF::FixedType, // XHeight - QFontEngineQPF::FixedType, // AverageCharWidth - QFontEngineQPF::FixedType, // MaxCharWidth - QFontEngineQPF::FixedType, // LineThickness - QFontEngineQPF::FixedType, // MinLeftBearing - QFontEngineQPF::FixedType, // MinRightBearing - QFontEngineQPF::FixedType, // UnderlinePosition - QFontEngineQPF::UInt8Type, // GlyphFormat - QFontEngineQPF::UInt8Type, // PixelSize - QFontEngineQPF::UInt8Type, // Weight - QFontEngineQPF::UInt8Type, // Style - QFontEngineQPF::StringType, // EndOfHeader - QFontEngineQPF::BitFieldType// WritingSystems -}; - -