quality is not as good as if using an image. This render target allows faster rendering
in some cases, but you should avoid using it if the item is resized often.
+ \value InvertedYFramebufferObject Exactly as for FramebufferObject above, except once
+ the painting is done, prior to rendering the painted image is flipped about the
+ x-axis so that the top-most pixels are now at the bottom. Since this is done with the
+ OpenGL texture coordinates it is a much faster way to achieve this effect than using a
+ painter transform.
+
\sa setRenderTarget()
*/
\brief The item's render target.
This property defines which render target the QPainter renders into, it can be either
- QQuickPaintedItem::Image or QQuickPaintedItem::FramebufferObject. Both have certains benefits,
- typically performance versus quality. Using a framebuffer object avoids a costly upload
- of the image contents to the texture in graphics memory, while using an image enables
- high quality anti-aliasing.
+ QSGPaintedItem::Image, QSGPaintedItem::FramebufferObject or QSGPaintedItem::InvertedYFramebufferObject.
+
+ Each has certain benefits, typically performance versus quality. Using a framebuffer
+ object avoids a costly upload of the image contents to the texture in graphics memory,
+ while using an image enables high quality anti-aliasing.
\warning Resizing a framebuffer object is a costly operation, avoid using
the QQuickPaintedItem::FramebufferObject render target if the item gets resized often.
source = QRectF(0, 0, 1, 1);
else
source = QRectF(0, 0, qreal(m_size.width()) / m_fboSize.width(), qreal(m_size.height()) / m_fboSize.height());
+ QRectF dest(0, 0, m_size.width(), m_size.height());
+ if (m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject)
+ dest = QRectF(QPointF(0, m_size.height()), QPointF(m_size.width(), 0));
QSGGeometry::updateTexturedRectGeometry(&m_geometry,
- QRectF(0, 0, m_size.width(), m_size.height()),
+ dest,
source);
markDirty(DirtyGeometry);
}
if (!m_multisamplingSupported && m_smoothPainting)
m_actualRenderTarget = QQuickPaintedItem::Image;
else
- m_actualRenderTarget = QQuickPaintedItem::FramebufferObject;
+ m_actualRenderTarget = m_preferredRenderTarget;
}
if (oldTarget != m_actualRenderTarget) {
m_image = QImage();
m_fbo = m_multisampledFbo = 0;
}
- if (m_actualRenderTarget == QQuickPaintedItem::FramebufferObject) {
+ if (m_actualRenderTarget == QQuickPaintedItem::FramebufferObject ||
+ m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject) {
const QOpenGLContext *ctx = m_context->glContext();
if (m_fbo && !m_dirtyGeometry && (!ctx->format().samples() || !m_multisamplingSupported))
return;