aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-05-03 11:57:06 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-05-06 11:27:22 +0000
commit2bb63f9e52b4cb025061734c171252564d69c6a9 (patch)
tree9b35adf07006ccea82cd20ae0e0d870126a9276d /src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
parentd45718b33cb97218ff042e95ee7774fd8c8d63a3 (diff)
D3D12: Implement grabWindow
Change-Id: Icb8151f26bad68795eb2e1f920297267c880b40b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp')
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
index 83ba443800..fccb127c4f 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
@@ -367,8 +367,16 @@ bool QSGD3D12RenderThread::event(QEvent *e)
Q_ASSERT(wme->window == exposedWindow || !exposedWindow);
mutex.lock();
if (wme->window) {
- // ###
- Q_UNREACHABLE();
+ // Grabbing is generally done by rendering a frame and reading the
+ // color buffer contents back, without presenting, and then
+ // creating a QImage from the returned data. It is terribly
+ // inefficient since it involves a full blocking wait for the GPU.
+ // However, our hands are tied by the existing, synchronous APIs of
+ // QQuickWindow and such.
+ QQuickWindowPrivate *wd = QQuickWindowPrivate::get(wme->window);
+ wd->syncSceneGraph();
+ wd->renderSceneGraph(wme->window->size());
+ *wme->image = engine->executeAndWaitReadbackRenderTarget();
}
if (Q_UNLIKELY(debug_loop()))
qDebug("RT - WM_Grab - waking gui to handle result");
@@ -733,7 +741,14 @@ QImage QSGD3D12RenderLoop::grab(QQuickWindow *window)
qDebug() << "grab" << window;
WindowData *w = windowFor(windows, window);
- Q_ASSERT(w);
+ // Have to support invisible (but created()'ed) windows as well.
+ // Unlike with GL, leaving that case for QQuickWindow to handle is not feasible.
+ const bool tempExpose = !w;
+ if (tempExpose) {
+ handleExposure(window);
+ w = windowFor(windows, window);
+ Q_ASSERT(w);
+ }
if (!w->thread->isRunning())
return QImage();
@@ -752,6 +767,11 @@ QImage QSGD3D12RenderLoop::grab(QQuickWindow *window)
lockedForSync = false;
w->thread->mutex.unlock();
+ result.setDevicePixelRatio(window->effectiveDevicePixelRatio());
+
+ if (tempExpose)
+ handleObscurity(w);
+
return result;
}
@@ -841,6 +861,11 @@ bool QSGD3D12RenderLoop::interleaveIncubation() const
return somethingVisible && anim->isRunning();
}
+int QSGD3D12RenderLoop::flags() const
+{
+ return SupportsGrabWithoutExpose;
+}
+
bool QSGD3D12RenderLoop::event(QEvent *e)
{
if (e->type() == QEvent::Timer) {