From: Ivailo Monev Date: Sun, 2 Aug 2020 04:36:43 +0000 (+0300) Subject: do not buffer in QX11PaintEngine::drawPoints() methods X-Git-Tag: 4.12.0~3640 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b9a14fbc0814d1985e55a83bd88f3936dfe671ec;p=kde%2FKatie.git do not buffer in QX11PaintEngine::drawPoints() methods twice as fast on some line drawing benchmarks with no noticable loss in other cases Signed-off-by: Ivailo Monev --- diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 14d1c9bc6..9ecae44ac 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -928,26 +928,20 @@ void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount) return; } - static const int BUF_SIZE = 1024; - XPoint xPoints[BUF_SIZE]; + XPoint xPoints[pointCount]; int i = 0, j = 0; while (i < pointCount) { - while (i < pointCount && j < BUF_SIZE) { - const QPoint &xformed = d->matrix.map(points[i]); - int x = xformed.x(); - int y = xformed.y(); - if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) { - xPoints[j].x = x; - xPoints[j].y = y; - ++j; - } - ++i; + const QPoint &xformed = d->matrix.map(points[i]); + int x = xformed.x(); + int y = xformed.y(); + if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) { + xPoints[j].x = x; + xPoints[j].y = y; + ++j; } - if (j) - XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin); - - j = 0; + ++i; } + XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin); } void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount) @@ -986,27 +980,21 @@ void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount) return; } - static const int BUF_SIZE = 1024; - XPoint xPoints[BUF_SIZE]; + XPoint xPoints[pointCount]; int i = 0, j = 0; while (i < pointCount) { - while (i < pointCount && j < BUF_SIZE) { - const QPointF &xformed = d->matrix.map(points[i]); - int x = qFloor(xformed.x()); - int y = qFloor(xformed.y()); - - if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) { - xPoints[j].x = x; - xPoints[j].y = y; - ++j; - } - ++i; + const QPointF &xformed = d->matrix.map(points[i]); + int x = qFloor(xformed.x()); + int y = qFloor(xformed.y()); + + if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) { + xPoints[j].x = x; + xPoints[j].y = y; + ++j; } - if (j) - XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin); - - j = 0; + ++i; } + XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin); } QPainter::RenderHints QX11PaintEngine::supportedRenderHints() const