Allow QDistanceField to be directly constructed from a QPainterPath.

Enables optimization in the case of an already existing QPainterPath.

Change-Id: I7f038673ce245ea19e400e6d2c728f07cb55e366
Task-number: QTBUG-42853
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
Michael Brasser 2015-02-20 07:57:29 -06:00
parent 33403f2c79
commit bf16940d33
2 changed files with 12 additions and 0 deletions

View File

@ -833,6 +833,17 @@ QDistanceField::QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doub
setGlyph(fontEngine, glyph, doubleResolution);
}
QDistanceField::QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution)
{
QPainterPath dfPath = path;
dfPath.translate(-dfPath.boundingRect().topLeft());
dfPath.setFillRule(Qt::WindingFill);
d = QDistanceFieldData::create(dfPath, doubleResolution);
d->glyph = glyph;
}
QDistanceField::QDistanceField(QDistanceFieldData *data)
: d(data)
{

View File

@ -97,6 +97,7 @@ public:
QDistanceField(int width, int height);
QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false);
QDistanceField(const QDistanceField &other);
bool isNull() const;