13 :
QSGLayer(*(
new QSGTexturePrivate(
this)))
15 , m_context(renderContext)
17 , m_device_pixel_ratio(1)
18 , m_mirrorHorizontal(
false)
19 , m_mirrorVertical(
true)
23 , m_dirtyTexture(
true)
28QSGSoftwareLayer::~QSGSoftwareLayer()
33qint64 QSGSoftwareLayer::comparisonKey()
const
38QSize QSGSoftwareLayer::textureSize()
const
40 return m_pixmap.size();
43bool QSGSoftwareLayer::hasAlphaChannel()
const
45 return m_pixmap.hasAlphaChannel();
48bool QSGSoftwareLayer::hasMipmaps()
const
53bool QSGSoftwareLayer::updateTexture()
55 bool doGrab = (m_live || m_grab) && m_dirtyTexture;
59 emit scheduledUpdateCompleted();
64void QSGSoftwareLayer::setItem(QSGNode *item)
70 if (m_live && !m_item)
76void QSGSoftwareLayer::setRect(
const QRectF &rect)
84void QSGSoftwareLayer::setSize(
const QSize &size)
90 if (m_live && m_size.isNull())
96void QSGSoftwareLayer::scheduleUpdate()
101 if (m_dirtyTexture) {
102 emit updateRequested();
106QImage QSGSoftwareLayer::toImage()
const
108 return m_pixmap.toImage();
111void QSGSoftwareLayer::setLive(
bool live)
117 if (m_live && (!m_item || m_size.isNull()))
118 m_pixmap = QPixmap();
123void QSGSoftwareLayer::setRecursive(
bool recursive)
125 m_recursive = recursive;
128void QSGSoftwareLayer::setFormat(Format)
132void QSGSoftwareLayer::setHasMipmaps(
bool)
136void QSGSoftwareLayer::setDevicePixelRatio(qreal ratio)
138 m_device_pixel_ratio = ratio;
141void QSGSoftwareLayer::setMirrorHorizontal(
bool mirror)
143 if (m_mirrorHorizontal == mirror)
145 m_mirrorHorizontal = mirror;
149void QSGSoftwareLayer::setMirrorVertical(
bool mirror)
151 if (m_mirrorVertical == mirror)
153 m_mirrorVertical = mirror;
157void QSGSoftwareLayer::markDirtyTexture()
159 m_dirtyTexture =
true;
160 if (m_live || m_grab) {
161 emit updateRequested();
165void QSGSoftwareLayer::invalidated()
168 m_renderer =
nullptr;
171void QSGSoftwareLayer::grab()
173 if (!m_item || m_size.isNull()) {
174 m_pixmap = QPixmap();
175 m_dirtyTexture =
false;
178 QSGNode *root = m_item;
179 while (root->firstChild() && root->type() != QSGNode::RootNodeType)
180 root = root->firstChild();
181 if (root->type() != QSGNode::RootNodeType)
185 m_renderer =
new QSGSoftwarePixmapRenderer(m_context);
186 connect(m_renderer, SIGNAL(sceneGraphChanged()),
this, SLOT(markDirtyTexture()));
188 m_renderer->setDevicePixelRatio(m_device_pixel_ratio);
189 m_renderer->setRootNode(
static_cast<QSGRootNode *>(root));
191 if (m_pixmap.size() != m_size) {
192 m_pixmap = QPixmap(m_size);
193 m_pixmap.setDevicePixelRatio(m_device_pixel_ratio);
197 root->markDirty(QSGNode::DirtyForceUpdate);
198 m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate);
200 m_dirtyTexture =
false;
202 m_renderer->setDeviceRect(m_size);
203 m_renderer->setViewportRect(m_size);
204 QRect mirrored(m_mirrorHorizontal ? m_rect.right() * m_device_pixel_ratio : m_rect.left() * m_device_pixel_ratio,
205 m_mirrorVertical ? m_rect.bottom() * m_device_pixel_ratio : m_rect.top() * m_device_pixel_ratio,
206 m_mirrorHorizontal ? -m_rect.width() * m_device_pixel_ratio : m_rect.width() * m_device_pixel_ratio,
207 m_mirrorVertical ? -m_rect.height() * m_device_pixel_ratio : m_rect.height() * m_device_pixel_ratio);
208 m_renderer->setProjectionRect(mirrored);
209 m_renderer->setClearColor(Qt::transparent);
214 root->markDirty(QSGNode::DirtyForceUpdate);
222#include "moc_qsgsoftwarelayer_p.cpp"
void renderScene() final
Renders the scene.
Combined button and popup list for selecting options.