diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-07-07 08:51:52 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-07-26 08:57:11 (GMT) |
commit | 5842d19cf3dff37a85cbdb31ab5a170ceaf5c7fb (patch) | |
tree | b87af2ff273085a80c491847db05aa50ca979f92 /src/gui/painting/qpaintengine_raster.cpp | |
parent | d852e6164a4aaf8e235e97cba8f0e8e9b933987c (diff) | |
download | Qt-5842d19cf3dff37a85cbdb31ab5a170ceaf5c7fb.zip Qt-5842d19cf3dff37a85cbdb31ab5a170ceaf5c7fb.tar.gz Qt-5842d19cf3dff37a85cbdb31ab5a170ceaf5c7fb.tar.bz2 |
Fixed holes in border image drawing by introducing new API.
When rasterizing two adjacent QRectFs it's important that the shared x
or y-edges have the exact same coordinates, or there might be a hole or
an overlapping pixel when they are rasterized. Since the
drawPixmapFragments API was based on a center position and a scale, it
can not be used for this purpose, as the in the situation of two
horizontally adjacent rectangles the right edge of the left-most rect
and the left edge of the right-most edge are computed differently. Thus
rounding errors can cause them to not be equal, especially when there's
also a scaling / translating painter transform involved.
Thus, to not sacrifice performance, we need to introduce a new
drawPixmapFragments API that's simply takes an array of target
rectangles and an array of source rectangles. It should give a slight
performance boost for the border pixmap use case as well, since there
are less floating point multiplications / divisions involved.
Task-number: QTBUG-19079
Reviewed-by: Kim
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 626100a..d77ef82 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2396,12 +2396,13 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe d->image_filler_xform.setupMatrix(copy, s->flags.bilinear); if (!s->flags.antialiased && s->matrix.type() == QTransform::TxScale) { - QRectF rr = s->matrix.mapRect(r); + QPointF rr_tl = s->matrix.map(r.topLeft()); + QPointF rr_br = s->matrix.map(r.bottomRight()); - const int x1 = qRound(rr.x()); - const int y1 = qRound(rr.y()); - const int x2 = qRound(rr.right()); - const int y2 = qRound(rr.bottom()); + const int x1 = qRound(rr_tl.x()); + const int y1 = qRound(rr_tl.y()); + const int x2 = qRound(rr_br.x()); + const int y2 = qRound(rr_br.y()); fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler_xform, d); return; |