diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-09-25 11:47:47 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-03-05 05:52:14 +0100 |
commit | 2bb382f9c276a1dc1258148c156222be3576aff5 (patch) | |
tree | a0fbd4f1354efea9fc7ed1c4155658a08d450674 /src | |
parent | fccffcfabcae4d9e33ce899017073305fdb7d15f (diff) |
Make tst_qquickcanvasitem significant again; fix image size rounding
- the test items must be visible, so that waitForRendering() works
- arcTo::test_paint tried to render an out-of-bounds arc, which
resulted in rendering nothing. Now renders within the 100x100 canvas.
- painted() is not emitted the first time the Canvas is rendered.
- Canvas.save() saves relative to the directory from which the test is
run, while Canvas.loadImage() loads relative to the test data
directory in this autotest (other tests are loading red.png for
example). So we need to use absolute paths to test loading and saving
in the directory where the executable is.
- canvas.getContext('2d').getImageData(8.5, 8.5, 8.5, 8.5)
now triggers different rounding behavior in QRectF::toRect(),
after qtbase 88e56d0932a3615231adf40d5ae033e742d72c33:
it becomes QRect(9,9 8x8). The assert in qt_create_image_data()
needs to accommodate that.
- Fixed another pedantic warning in qt_create_image_data a few
lines above: if it creates the image itself, it needs to round
the qreal width and height values.
This reverts commit a23ee5c0de0d91859e1e76e64073861347dd9861 and
amends 424cfef3cc3c140df51905713fa3849562bc494d and
d142b2d212ea09a7919a0a2761ee9c04d5c9bda8.
Task-number: QTBUG-41043
Change-Id: I825c2c5a2bbc8d5324c3ba41a681aa68bc25a159
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/context2d/qquickcontext2d.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 54cda72a36..14fa07099f 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -986,10 +986,11 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionE pixelData->setPrototypeOf(p); if (image.isNull()) { - *pixelData->d()->image = QImage(w, h, QImage::Format_ARGB32); + *pixelData->d()->image = QImage(qRound(w), qRound(h), QImage::Format_ARGB32); pixelData->d()->image->fill(0x00000000); } else { - Q_ASSERT(image.width()== qRound(w * image.devicePixelRatioF()) && image.height() == qRound(h * image.devicePixelRatioF())); + // After qtbase 88e56d0932a3615231adf40d5ae033e742d72c33, the image size can be off by one. + Q_ASSERT(qAbs(image.width() - qRound(w * image.devicePixelRatioF())) <= 1 && qAbs(image.height() - qRound(h * image.devicePixelRatioF())) <= 1); *pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32); } |