diff options
author | Eirik Aavitsland <[email protected]> | 2022-01-21 08:05:29 +0100 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2022-03-02 13:58:10 +0000 |
commit | 423b6509382c3bcc36eca78ced0254bfb463d017 (patch) | |
tree | 25405db643710cf62a81ad702fbf007cfabc51ee /tests/auto/gui/qopengl/tst_qopengl.cpp | |
parent | 27fae7207fabc5bd5e34beab0cfeedfc8b8ede78 (diff) |
Fix painting clipping glitches with fractional scaling
In QPainter, clipping can only be done on whole pixels. The various
ways of specifying a clipping rectangle to the QPainter API have been
inconsistent in how fractional rectangles (either specified directly,
or as a result of fractional scaling) are mapped (rounded) to integer
coordinates.
Also, the mappings have not made sure to keep the edge-to-edge
property of clip rects under scaling. This is particularly important
when scaling QRegions with multiple rects, as QRegion is designed on
the assumption that an area can be described as a set of edge-to-edge
rects.
The fix rounds a clip rect identically with a fill rect. (Indeed, a
followup plan would be to merge QRasterPaintEngine's
toNormalizedFillRect() with the rectangle rounding function in this
commit).
Notably, a QRectF clip is now interpreted the same as a QPainterPath
clip describing the same area.
This modifies d9cc1499954829faf9486fb72056e29f1bad58e3
Task-number: QTBUG-100329
Fixes: QTBUG-95957
Task-number: QTBUG-100343
Pick-to: 6.3
Change-Id: Iaae6464b9b17f8bf3adc69007f6ef8d623bf2c80
Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'tests/auto/gui/qopengl/tst_qopengl.cpp')
-rw-r--r-- | tests/auto/gui/qopengl/tst_qopengl.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index e2e7f153a0f..a0a1ecca177 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -1695,10 +1695,11 @@ void tst_QOpenGL::nullTextureInitializtion() /* Verify that the clipping works correctly. - The red outline should be covered by the blue rect on top and left, - while it should be clipped on the right and bottom and thus the red outline be visible + Just like fillRect, cliprect should snap rightwards and downwards in case of .5 coordinates. + The red outline should be covered by the blue rect on top, + while it should be clipped on the other edges and thus the red outline be visible - See: QTBUG-83229 + See: QTBUG-83229, modified by QTBUG-100329 */ void tst_QOpenGL::clipRect() { @@ -1754,7 +1755,7 @@ void tst_QOpenGL::clipRect() QCOMPARE(fb.size(), size); QCOMPARE(fb.pixelColor(clipRect.left() + 1, clipRect.top()), QColor(Qt::blue)); - QCOMPARE(fb.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::blue)); + QCOMPARE(fb.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::red)); QCOMPARE(fb.pixelColor(clipRect.left() + 1, clipRect.bottom()), QColor(Qt::red)); // Enable this once QTBUG-85286 is fixed |