14 , m_device_pixel_ratio(1)
15 , m_mirrorHorizontal(
false)
16 , m_mirrorVertical(
false)
20 , m_dirtyTexture(true)
22 , m_secondaryOffscreenSurface(
nullptr)
34 if (m_offscreenSurface)
35 return static_cast<int>(m_offscreenSurface->
image());
42 if (m_offscreenSurface) {
43 return m_offscreenSurface->
size();
61 bool doGrab = (m_live || m_grab) && m_dirtyTexture;
76 if (m_live && !m_item) {
77 delete m_offscreenSurface;
78 delete m_secondaryOffscreenSurface;
79 m_offscreenSurface =
nullptr;
80 m_secondaryOffscreenSurface =
nullptr;
100 if (m_live && m_size.
isNull()) {
101 delete m_offscreenSurface;
102 delete m_secondaryOffscreenSurface;
103 m_offscreenSurface =
nullptr;
104 m_secondaryOffscreenSurface =
nullptr;
115 if (m_dirtyTexture) {
131 if (m_live && (!m_item || m_size.
isNull())) {
132 delete m_offscreenSurface;
133 delete m_secondaryOffscreenSurface;
134 m_offscreenSurface =
nullptr;
135 m_secondaryOffscreenSurface =
nullptr;
143 m_recursive = recursive;
158 m_device_pixel_ratio = ratio;
163 if (m_mirrorHorizontal == mirror)
165 m_mirrorHorizontal = mirror;
171 if (m_mirrorVertical == mirror)
173 m_mirrorVertical = mirror;
179 m_dirtyTexture =
true;
180 if (m_live || m_grab) {
187 delete m_offscreenSurface;
188 delete m_secondaryOffscreenSurface;
190 m_renderer =
nullptr;
191 m_offscreenSurface =
nullptr;
192 m_secondaryOffscreenSurface =
nullptr;
195void QSGOpenVGLayer::grab()
197 if (!m_item || m_size.
isNull()) {
198 delete m_offscreenSurface;
199 delete m_secondaryOffscreenSurface;
200 m_offscreenSurface =
nullptr;
201 m_secondaryOffscreenSurface =
nullptr;
202 m_dirtyTexture =
false;
218 bool deleteOffscreenSurfaceLater =
false;
219 if (m_offscreenSurface ==
nullptr || m_offscreenSurface->
size() != m_size ) {
221 deleteOffscreenSurfaceLater =
true;
222 delete m_secondaryOffscreenSurface;
225 delete m_offscreenSurface;
226 delete m_secondaryOffscreenSurface;
228 m_secondaryOffscreenSurface =
nullptr;
232 if (m_recursive && !m_secondaryOffscreenSurface)
239 m_dirtyTexture =
false;
243 QRect mirrored(m_mirrorHorizontal ? m_rect.
right() * m_device_pixel_ratio : m_rect.
left() * m_device_pixel_ratio,
244 m_mirrorVertical ? m_rect.
top() * m_device_pixel_ratio : m_rect.
bottom() * m_device_pixel_ratio,
245 m_mirrorHorizontal ? -m_rect.
width() * m_device_pixel_ratio : m_rect.
width() * m_device_pixel_ratio,
246 m_mirrorVertical ? m_rect.
height() * m_device_pixel_ratio : -m_rect.
height() * m_device_pixel_ratio);
260 if (deleteOffscreenSurfaceLater) {
261 delete m_offscreenSurface;
265 qSwap(m_offscreenSurface, m_secondaryOffscreenSurface);
\inmodule QtCore\reentrant
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
\inmodule QtCore\reentrant
void setViewportRect(const QRect &rect)
Sets rect as the geometry of the viewport to render on the surface.
void setProjectionMatrixToRect(const QRectF &rect)
Convenience method that calls setProjectionMatrix() with an orthographic matrix generated from rect.
void setDeviceRect(const QRect &rect)
Sets rect as the geometry of the surface being rendered to.
void setClearColor(const QColor &color)
Use color to clear the framebuffer when clearMode() is set to QSGAbstractRenderer::ClearColorBuffer.
void setRootNode(QSGRootNode *node)
Sets the node as the root of the QSGNode scene that you want to render.
void scheduledUpdateCompleted()
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
QSGNode * firstChild() const
Returns the first child of this node.
void markDirty(DirtyState bits)
Notifies all connected renderers that the node has dirty bits.
NodeType type() const
Returns the type of this node.
void setDevicePixelRatio(qreal ratio) override
void setLive(bool live) override
bool hasMipmaps() const override
Returns true if the texture data contains mipmap levels.
void markDirtyTexture() override
QImage toImage() const override
void setMirrorVertical(bool mirror) override
bool updateTexture() override
Call this function to explicitly update the dynamic texture.
void invalidated() override
QSGOpenVGLayer(QSGRenderContext *renderContext)
void setRecursive(bool recursive) override
void setFormat(uint format) override
void setRect(const QRectF &rect) override
QSize textureSize() const override
Returns the size of the texture in pixels.
void scheduleUpdate() override
void setMirrorHorizontal(bool mirror) override
void setItem(QSGNode *item) override
bool hasAlphaChannel() const override
Returns true if the texture data contains an alpha channel.
void setHasMipmaps(bool mipmap) override
qint64 comparisonKey() const override
Returns a key suitable for comparing textures.
void setSize(const QSize &size) override
void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override
void renderScene() override
Renders the scene.
void setDevicePixelRatio(qreal ratio)
The QSGRootNode is the toplevel root of any scene graph.
constexpr bool isNull() const noexcept
Returns true if both the width and height is 0; otherwise returns false.
Combined button and popup list for selecting options.
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLint GLsizei GLsizei GLenum format
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)