summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-08-04 15:16:33 (GMT)
committerAlessandro Portale <alessandro.portale@nokia.com>2010-08-04 15:16:33 (GMT)
commit22e95ba2502f893d741b774c37fc8c7bdc4b05c5 (patch)
tree7be5571774867730b7d89f7e7ab86273638f7d3e /src
parentc7b9ee03339774bd1cae7793d91dad7809be987a (diff)
downloadQt-22e95ba2502f893d741b774c37fc8c7bdc4b05c5.zip
Qt-22e95ba2502f893d741b774c37fc8c7bdc4b05c5.tar.gz
Qt-22e95ba2502f893d741b774c37fc8c7bdc4b05c5.tar.bz2
Improving text coordinate rounding in the OpenVG paint engine
Commit b0bbabe728fedb8531fc2837403856bd5ed44e1b fixed text blurriness in the OpenVG paint engine by forcing the coordinates of the text items to integer coordinates (for unrotated, unscaled text). That was not yet enough. In addition to the coordinates, also the d->pathTransform in QVGPaintEngine can have a non-integer translation. This patch makes sure that the text item coordinate combined with the translation result in final integer coordinates. Since it is not possible to set an absolute translation of a QTransform (only relative is possible), first dx() is added to p.x(), then after rounding, it is again substracted. Sam for y, but with opposite prefix, since the y-axis in Qt and in transformation matrices are in opposite directions. The ceil stunt (which I cerated by trial and error) was replaced by floor(x + aliasedCoordinateDelta), which *exactly* what other paint engines do. Task-number: QTBUG-12330 Reviewed-by: Jason Barron
Diffstat (limited to 'src')
-rw-r--r--src/openvg/qpaintengine_vg.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index e368c32..318e2b1 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -76,6 +76,9 @@ QT_BEGIN_NAMESPACE
#if !defined(QVG_NO_DRAW_GLYPHS)
+// use the same rounding as in qrasterizer.cpp (6 bit fixed point)
+static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
+
Q_DECL_IMPORT extern int qt_defaultDpiX();
Q_DECL_IMPORT extern int qt_defaultDpiY();
@@ -3439,9 +3442,10 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
// Set the transformation to use for drawing the current glyphs.
QTransform glyphTransform(d->pathTransform);
if (d->transform.type() <= QTransform::TxTranslate) {
- // Prevent blurriness of unscaled, unrotated text by using integer coordinates.
- // Using ceil(x-0.5) instead of qRound() or int-cast, behave like other paint engines.
- glyphTransform.translate(ceil(p.x() - 0.5), ceil(p.y() - 0.5));
+ // Prevent blurriness of unscaled, unrotated text by forcing integer coordinates.
+ glyphTransform.translate(
+ floor(p.x() + glyphTransform.dx() + aliasedCoordinateDelta) - glyphTransform.dx(),
+ floor(p.y() - glyphTransform.dy() + aliasedCoordinateDelta) + glyphTransform.dy());
} else {
glyphTransform.translate(p.x(), p.y());
}