QRasterPaintEngine: replace a QPair with a struct
Gives better naming for the members. A range consists of {begin, end}, not {first, second}. Task-number: QTBUG-104818 Change-Id: I3d6c7be2a137e1c03149d1d86ce9db38ec28a1fb Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 464607abb9e2528c2e1ccf41eec7c28703df8e2a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
faa9cf9749
commit
9222bc35da
@ -3008,7 +3008,13 @@ QRasterPaintEnginePrivate::getPenFunc(const QRectF &rect,
|
|||||||
return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend;
|
return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QPair<int, int> visibleGlyphRange(const QRectF &clip, QFontEngine *fontEngine,
|
struct VisibleGlyphRange
|
||||||
|
{
|
||||||
|
int begin;
|
||||||
|
int end;
|
||||||
|
};
|
||||||
|
|
||||||
|
static VisibleGlyphRange visibleGlyphRange(const QRectF &clip, QFontEngine *fontEngine,
|
||||||
glyph_t *glyphs, QFixedPoint *positions, int numGlyphs)
|
glyph_t *glyphs, QFixedPoint *positions, int numGlyphs)
|
||||||
{
|
{
|
||||||
QFixed clipLeft = QFixed::fromReal(clip.left() - 1);
|
QFixed clipLeft = QFixed::fromReal(clip.left() - 1);
|
||||||
@ -3038,7 +3044,7 @@ static QPair<int, int> visibleGlyphRange(const QRectF &clip, QFontEngine *fontEn
|
|||||||
break;
|
break;
|
||||||
--last;
|
--last;
|
||||||
}
|
}
|
||||||
return QPair<int, int>(first, last + 1);
|
return {first, last + 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -3064,13 +3070,13 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
|
|||||||
if (!invertible)
|
if (!invertible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPair<int, int> range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()),
|
const auto range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()),
|
||||||
textItem->fontEngine(), textItem->glyphs,
|
textItem->fontEngine(), textItem->glyphs,
|
||||||
textItem->glyphPositions, textItem->numGlyphs);
|
textItem->glyphPositions, textItem->numGlyphs);
|
||||||
QStaticTextItem copy = *textItem;
|
QStaticTextItem copy = *textItem;
|
||||||
copy.glyphs += range.first;
|
copy.glyphs += range.begin;
|
||||||
copy.glyphPositions += range.first;
|
copy.glyphPositions += range.begin;
|
||||||
copy.numGlyphs = range.second - range.first;
|
copy.numGlyphs = range.end - range.begin;
|
||||||
QPaintEngineEx::drawStaticTextItem(©);
|
QPaintEngineEx::drawStaticTextItem(©);
|
||||||
} else {
|
} else {
|
||||||
QPaintEngineEx::drawStaticTextItem(textItem);
|
QPaintEngineEx::drawStaticTextItem(textItem);
|
||||||
@ -3119,20 +3125,20 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
|
|||||||
|
|
||||||
ti.fontEngine->getGlyphPositions(ti.glyphs, QTransform::fromTranslate(p.x(), p.y()),
|
ti.fontEngine->getGlyphPositions(ti.glyphs, QTransform::fromTranslate(p.x(), p.y()),
|
||||||
ti.flags, glyphs, positions);
|
ti.flags, glyphs, positions);
|
||||||
QPair<int, int> range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()),
|
const auto range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()),
|
||||||
ti.fontEngine, glyphs.data(), positions.data(),
|
ti.fontEngine, glyphs.data(), positions.data(),
|
||||||
glyphs.size());
|
glyphs.size());
|
||||||
|
|
||||||
if (range.first >= range.second)
|
if (range.begin >= range.end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStaticTextItem staticTextItem;
|
QStaticTextItem staticTextItem;
|
||||||
staticTextItem.color = s->pen.color();
|
staticTextItem.color = s->pen.color();
|
||||||
staticTextItem.font = s->font;
|
staticTextItem.font = s->font;
|
||||||
staticTextItem.setFontEngine(ti.fontEngine);
|
staticTextItem.setFontEngine(ti.fontEngine);
|
||||||
staticTextItem.numGlyphs = range.second - range.first;
|
staticTextItem.numGlyphs = range.end - range.begin;
|
||||||
staticTextItem.glyphs = glyphs.data() + range.first;
|
staticTextItem.glyphs = glyphs.data() + range.begin;
|
||||||
staticTextItem.glyphPositions = positions.data() + range.first;
|
staticTextItem.glyphPositions = positions.data() + range.begin;
|
||||||
QPaintEngineEx::drawStaticTextItem(&staticTextItem);
|
QPaintEngineEx::drawStaticTextItem(&staticTextItem);
|
||||||
} else {
|
} else {
|
||||||
QPaintEngineEx::drawTextItem(p, ti);
|
QPaintEngineEx::drawTextItem(p, ti);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user