macOS: Implement QCALayerBackingStore::toImage()
It's not part of the QBackingStore API, but clients such as the Qt Quick software renderer access it through the platform backingstore, to grab the window. Change-Id: I203484ce13a5f8fb6815d27ab07f874fa9d16b8c Fixes: QTBUG-75467 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
64a2dc3962
commit
3159845c9c
@ -81,6 +81,7 @@ public:
|
|||||||
QPlatformTextureList *textures, bool translucentBackground) override;
|
QPlatformTextureList *textures, bool translucentBackground) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QImage toImage() const override;
|
||||||
QPlatformGraphicsBuffer *graphicsBuffer() const override;
|
QPlatformGraphicsBuffer *graphicsBuffer() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -534,6 +534,21 @@ void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion ®io
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QImage QCALayerBackingStore::toImage() const
|
||||||
|
{
|
||||||
|
if (!const_cast<QCALayerBackingStore*>(this)->prepareForFlush())
|
||||||
|
return QImage();
|
||||||
|
|
||||||
|
// We need to make a copy here, as the returned image could be used just
|
||||||
|
// for reading, in which case it won't detach, and then the underlying
|
||||||
|
// image data might change under the feet of the client when we re-use
|
||||||
|
// the buffer at a later point.
|
||||||
|
m_buffers.back()->lock(QPlatformGraphicsBuffer::SWReadAccess);
|
||||||
|
QImage imageCopy = m_buffers.back()->asImage()->copy();
|
||||||
|
m_buffers.back()->unlock();
|
||||||
|
return imageCopy;
|
||||||
|
}
|
||||||
|
|
||||||
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
|
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
|
||||||
{
|
{
|
||||||
return m_buffers.back().get();
|
return m_buffers.back().get();
|
||||||
|
Loading…
Reference in New Issue
Block a user