summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengineex.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-07-07 10:51:52 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-07-26 10:57:11 +0200
commit5842d19cf3dff37a85cbdb31ab5a170ceaf5c7fb (patch)
treeb87af2ff273085a80c491847db05aa50ca979f92 /src/gui/painting/qpaintengineex.cpp
parentd852e6164a4aaf8e235e97cba8f0e8e9b933987c (diff)
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/qpaintengineex.cpp')
-rw-r--r--src/gui/painting/qpaintengineex.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 5105d9a963..6df410b27d 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -1003,6 +1003,22 @@ void QPaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragmen
transformChanged();
}
+void QPaintEngineEx::drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount,
+ const QPixmap &pixmap, QPainter::PixmapFragmentHints /*hints*/)
+{
+ if (pixmap.isNull())
+ return;
+
+ if (sourceRects) {
+ for (int i = 0; i < fragmentCount; ++i)
+ drawPixmap(targetRects[i], pixmap, sourceRects[i]);
+ } else {
+ QRectF sourceRect = pixmap.rect();
+ for (int i = 0; i < fragmentCount; ++i)
+ drawPixmap(targetRects[i], pixmap, sourceRect);
+ }
+}
+
void QPaintEngineEx::setState(QPainterState *s)
{
QPaintEngine::state = s;