XCB: set devicePixelRatio on backing store QImages
The cocoa platform plugin, for example, already does this (via QCALayerBackingStore::GraphicsBuffer::asImage, which is called by QCALayerBackingStore::toImage). This also fixes reporting of image details when tests fail. For example, tst_QQuickShape::render before this patch: FAIL! : tst_QQuickShape::render() 'QQuickVisualTestUtils::compareImages(actualImg, refImg, &errorMessage)' returned FALSE. (Images are of different size: QSize(400, 300) QSize(200, 150) DPR: 1 1 ) and after: FAIL! : tst_QQuickShape::render() 'QQuickVisualTestUtils::compareImages(actualImg, refImg, &errorMessage)' returned FALSE. (Images are of different size: QSize(400, 300) QSize(200, 150) DPR: 2 1 ) [ChangeLog][Important Behavior Changes][XCB] The images grabbed from a window (via e.g. QQuickWindow::grabWindow) on XCB will now respect the window's devicePixelRatio. Change-Id: I72937d3284e7113efa7ab2f3b5b0fd13bc6dffca Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
cd213bb750
commit
c70fd79a17
@ -226,6 +226,7 @@ void QXcbBackingStoreImage::resize(const QSize &size)
|
|||||||
m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize);
|
m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize);
|
||||||
m_qimage = QImage(static_cast<uchar *>(m_xcb_image->data), m_xcb_image->width,
|
m_qimage = QImage(static_cast<uchar *>(m_xcb_image->data), m_xcb_image->width,
|
||||||
m_xcb_image->height, m_xcb_image->stride, m_qimage_format);
|
m_xcb_image->height, m_xcb_image->stride, m_qimage_format);
|
||||||
|
m_qimage.setDevicePixelRatio(m_backingStore->window()->devicePixelRatio());
|
||||||
m_graphics_buffer = new QXcbGraphicsBuffer(&m_qimage);
|
m_graphics_buffer = new QXcbGraphicsBuffer(&m_qimage);
|
||||||
|
|
||||||
m_xcb_pixmap = xcb_generate_id(xcb_connection());
|
m_xcb_pixmap = xcb_generate_id(xcb_connection());
|
||||||
@ -820,7 +821,9 @@ QImage QXcbBackingStore::toImage() const
|
|||||||
// Return an image that does not share QImageData with the original image,
|
// Return an image that does not share QImageData with the original image,
|
||||||
// even if they both point to the same data of the m_xcb_image, otherwise
|
// even if they both point to the same data of the m_xcb_image, otherwise
|
||||||
// painting to m_qimage would detach it from the m_xcb_image data.
|
// painting to m_qimage would detach it from the m_xcb_image data.
|
||||||
return QImage(image.constBits(), image.width(), image.height(), image.format());
|
QImage imageWrapper = QImage(image.constBits(), image.width(), image.height(), image.format());
|
||||||
|
imageWrapper.setDevicePixelRatio(image.devicePixelRatio());
|
||||||
|
return imageWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const
|
QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user