mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 11:22:58 +00:00
remove redundant X11 paint engine text drawing implementation
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
902b2a02af
commit
3e5b8b0e31
2 changed files with 0 additions and 140 deletions
|
@ -2116,139 +2116,4 @@ void QX11PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, co
|
|||
}
|
||||
}
|
||||
|
||||
void QX11PaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
|
||||
{
|
||||
const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
|
||||
|
||||
switch(ti.fontEngine->type()) {
|
||||
case QFontEngine::Box:
|
||||
d_func()->drawBoxTextItem(p, ti);
|
||||
break;
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
case QFontEngine::Freetype:
|
||||
drawFreetype(p, ti);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
static QPainterPath path_for_glyphs(const QVarLengthArray<glyph_t> &glyphs,
|
||||
const QVarLengthArray<QFixedPoint> &positions,
|
||||
const QFontEngineFT *ft)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
ft->lockFace();
|
||||
int i = 0;
|
||||
while (i < glyphs.size()) {
|
||||
QFontEngineFT::Glyph *glyph = ft->loadGlyph(glyphs[i], QFontEngineFT::Format_Mono);
|
||||
// #### fix case where we don't get a glyph
|
||||
if (!glyph)
|
||||
break;
|
||||
|
||||
Q_ASSERT(glyph->format == QFontEngineFT::Format_Mono);
|
||||
int n = 0;
|
||||
int h = glyph->height;
|
||||
int xp = qRound(positions[i].x);
|
||||
int yp = qRound(positions[i].y);
|
||||
|
||||
xp += glyph->x;
|
||||
yp += -glyph->y + glyph->height;
|
||||
int pitch = ((glyph->width + 31) & ~31) >> 3;
|
||||
|
||||
uchar *src = glyph->data;
|
||||
while (h--) {
|
||||
for (int x = 0; x < glyph->width; ++x) {
|
||||
bool set = src[x >> 3] & (0x80 >> (x & 7));
|
||||
if (set) {
|
||||
QRect r(xp + x, yp - h, 1, 1);
|
||||
while (x+1 < glyph->width && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
|
||||
++x;
|
||||
r.setRight(r.right()+1);
|
||||
}
|
||||
|
||||
path.addRect(r);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
src += pitch;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
ft->unlockFace();
|
||||
return path;
|
||||
}
|
||||
|
||||
void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
|
||||
{
|
||||
Q_D(QX11PaintEngine);
|
||||
if (!ti.glyphs.numGlyphs)
|
||||
return;
|
||||
|
||||
if (!d->cpen.isSolid()) {
|
||||
QPaintEngine::drawTextItem(p, ti);
|
||||
return;
|
||||
}
|
||||
|
||||
QFontEngineX11FT *ft = static_cast<QFontEngineX11FT *>(ti.fontEngine);
|
||||
QVarLengthArray<QFixedPoint> positions;
|
||||
QVarLengthArray<glyph_t> glyphs;
|
||||
const QTransform matrix = QTransform::fromTranslate(p.x(), p.y());
|
||||
|
||||
ft->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
|
||||
if (glyphs.count() == 0)
|
||||
return;
|
||||
|
||||
QPainterPath path = path_for_glyphs(glyphs, positions, ft);
|
||||
if (path.elementCount() <= 1)
|
||||
return;
|
||||
Q_ASSERT((path.elementCount() % 5) == 0);
|
||||
if (d->txop >= QTransform::TxScale) {
|
||||
painter()->save();
|
||||
painter()->setBrush(d->cpen.brush());
|
||||
painter()->setPen(Qt::NoPen);
|
||||
painter()->drawPath(path);
|
||||
painter()->restore();
|
||||
return;
|
||||
}
|
||||
|
||||
const int rectcount = 256;
|
||||
XRectangle rects[rectcount];
|
||||
int num_rects = 0;
|
||||
|
||||
QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
|
||||
QRect clip(d->polygonClipper.boundingRect());
|
||||
for (int i=0; i < path.elementCount(); i+=5) {
|
||||
int x = qRound(path.elementAt(i).x);
|
||||
int y = qRound(path.elementAt(i).y);
|
||||
int w = qRound(path.elementAt(i+1).x) - x;
|
||||
int h = qRound(path.elementAt(i+2).y) - y;
|
||||
|
||||
QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
|
||||
rect = rect.intersected(clip);
|
||||
if (rect.isEmpty())
|
||||
continue;
|
||||
|
||||
rects[num_rects].x = short(rect.x());
|
||||
rects[num_rects].y = short(rect.y());
|
||||
rects[num_rects].width = ushort(rect.width());
|
||||
rects[num_rects].height = ushort(rect.height());
|
||||
++num_rects;
|
||||
if (num_rects == rectcount) {
|
||||
XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
|
||||
num_rects = 0;
|
||||
}
|
||||
}
|
||||
if (num_rects > 0)
|
||||
XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
|
||||
|
||||
}
|
||||
#endif // !QT_NO_XRENDER
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,6 @@ public:
|
|||
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
||||
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
|
||||
void drawPath(const QPainterPath &path);
|
||||
void drawTextItem(const QPointF &p, const QTextItem &textItem);
|
||||
void drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
|
||||
Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||
|
||||
|
@ -95,10 +94,6 @@ public:
|
|||
protected:
|
||||
QX11PaintEngine(QX11PaintEnginePrivate &dptr);
|
||||
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
void drawFreetype(const QPointF &p, const QTextItemInt &si);
|
||||
#endif
|
||||
|
||||
friend class QPixmap;
|
||||
friend class QFontEngineBox;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue