aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/adaptations/software
diff options
context:
space:
mode:
authorJiDe Zhang <[email protected]>2021-05-28 16:12:55 +0800
committerLaszlo Agocs <[email protected]>2022-04-19 17:39:07 +0200
commit43f705c3c01a7b78b94ea1db655c715ab2a54939 (patch)
treebde830a04a8e265072d088383f74ecc5c8919c07 /src/quick/scenegraph/adaptations/software
parent514e292d3ded029791779c422f45dcf5cbe57a1d (diff)
Support to custom the render target on the software renderer
Add QQuickRenderTarget::fromPaintDevice, aollow to get a QQuickRendererTarget from the QPaintDevice object. [ChangeLog][QtQuick] Added QQuickRenderTarget::fromPaintDevice, Allowed to set the render target of QQuickWindow on the software renderer. Task-number: QTBUG-94075 Change-Id: I4946c25d2a6315cd8f9c12a7ac7ac4cf71d95361 Reviewed-by: Laszlo Agocs <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/quick/scenegraph/adaptations/software')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp11
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp29
2 files changed, 25 insertions, 15 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
index 4ddef6b4c2..eba7ce001d 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
@@ -218,8 +218,15 @@ QSGRendererInterface::ShaderSourceTypes QSGSoftwareContext::shaderSourceType() c
void *QSGSoftwareContext::getResource(QQuickWindow *window, Resource resource) const
{
- if (resource == PainterResource && window && window->isSceneGraphInitialized())
- return static_cast<QSGSoftwareRenderContext *>(QQuickWindowPrivate::get(window)->context)->m_activePainter;
+ if (!window)
+ return nullptr;
+
+ auto cd = QQuickWindowPrivate::get(window);
+
+ if (resource == PainterResource)
+ return window->isSceneGraphInitialized() ? static_cast<QSGSoftwareRenderContext *>(cd->context)->m_activePainter : nullptr;
+ else if (resource == RedirectPaintDevice)
+ return cd->redirect.rt.paintDevice;
return nullptr;
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
index 12ffa0ef57..e56bacd187 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
@@ -92,25 +92,28 @@ void QSGSoftwareRenderer::renderScene()
void QSGSoftwareRenderer::render()
{
- if (!m_paintDevice && !m_backingStore)
+ if (!m_paintDevice && !m_backingStore && !m_rt.paintDevice)
return;
- // If there is a backingstore, set the current paint device
- if (m_backingStore) {
+ QPaintDevice *paintDevice = m_paintDevice ? m_paintDevice : m_rt.paintDevice;
+ QBackingStore *backingStore = nullptr;
+ // If no paint device and there is a backingstore, set the current paint device
+ if (!paintDevice && m_backingStore) {
// For HiDPI QBackingStores, the paint device is not valid
// until begin() has been called. See: QTBUG-55875
m_backingStore->beginPaint(QRegion());
- m_paintDevice = m_backingStore->paintDevice();
+ paintDevice = m_backingStore->paintDevice();
m_backingStore->endPaint();
+ backingStore = m_backingStore;
}
QElapsedTimer renderTimer;
setBackgroundColor(clearColor());
setBackgroundRect(QRect(0, 0,
- m_paintDevice->width() / m_paintDevice->devicePixelRatio(),
- m_paintDevice->height() / m_paintDevice->devicePixelRatio()),
- m_paintDevice->devicePixelRatio());
+ paintDevice->width() / paintDevice->devicePixelRatio(),
+ paintDevice->height() / paintDevice->devicePixelRatio()),
+ paintDevice->devicePixelRatio());
// Build Renderlist
// The renderlist is created by visiting each node in the tree and when a
@@ -135,14 +138,14 @@ void QSGSoftwareRenderer::render()
qint64 optimizeRenderListTime = renderTimer.restart();
// If Rendering to a backingstore, prepare it to be updated
- if (m_backingStore != nullptr) {
- m_backingStore->beginPaint(updateRegion);
+ if (backingStore != nullptr) {
+ backingStore->beginPaint(updateRegion);
// It is possible that a QBackingStore's paintDevice() will change
// when begin() is called.
- m_paintDevice = m_backingStore->paintDevice();
+ paintDevice = backingStore->paintDevice();
}
- QPainter painter(m_paintDevice);
+ QPainter painter(paintDevice);
painter.setRenderHint(QPainter::Antialiasing);
auto rc = static_cast<QSGSoftwareRenderContext *>(context());
QPainter *prevPainter = rc->m_activePainter;
@@ -153,8 +156,8 @@ void QSGSoftwareRenderer::render()
qint64 renderTime = renderTimer.elapsed();
painter.end();
- if (m_backingStore != nullptr)
- m_backingStore->endPaint();
+ if (backingStore != nullptr)
+ backingStore->endPaint();
rc->m_activePainter = prevPainter;
qCDebug(lcRenderer) << "render" << m_flushRegion << buildRenderListTime << optimizeRenderListTime << renderTime;