From 2bb382f9c276a1dc1258148c156222be3576aff5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 25 Sep 2019 11:47:47 +0200 Subject: 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 --- src/quick/items/context2d/qquickcontext2d.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/quick/items/context2d') 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); } -- cgit v1.2.3