summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-04-16 15:56:33 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-04-28 15:02:06 +0000
commite3f56a8b8d749f9eb4816ee7f6355f59dac173e6 (patch)
tree31678da718dad7ac048670aa4664831a1af0a69d /examples
parent4da32851de3a1f462e1077fd9c59849863547af9 (diff)
downloadqtdeclarative-e3f56a8b8d749f9eb4816ee7f6355f59dac173e6.tar.gz
qtdeclarative-e3f56a8b8d749f9eb4816ee7f6355f59dac173e6.tar.bz2
qtdeclarative-e3f56a8b8d749f9eb4816ee7f6355f59dac173e6.zip
Fix rendercontrol example for screens with different dpr
renderWindow() was not reimplemented in the example. This is pretty bad since renderWindowFor() fails to find a window and thus falls back to using the default device pixel ratio (which is the highest dpr present in the system). The result is broken content from Quick because it operates with a dpr of 2 any time a retina screen is connected, even when the example's own QWindow is placed on a normal screen. Add also a note to the QQuickRenderControl docs because it is easy to overlook. Task-number: QTBUG-45613 Change-Id: I31bf92ec285f3d9867a5604a4b4e3bea73791932 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/rendercontrol/window_multithreaded.cpp12
-rw-r--r--examples/quick/rendercontrol/window_singlethreaded.cpp19
2 files changed, 29 insertions, 2 deletions
diff --git a/examples/quick/rendercontrol/window_multithreaded.cpp b/examples/quick/rendercontrol/window_multithreaded.cpp
index 9b6020a34..8de5a7776 100644
--- a/examples/quick/rendercontrol/window_multithreaded.cpp
+++ b/examples/quick/rendercontrol/window_multithreaded.cpp
@@ -213,6 +213,16 @@ void QuickRenderer::aboutToQuit()
m_quit = true;
}
+class RenderControl : public QQuickRenderControl
+{
+public:
+ RenderControl(QWindow *w) : m_window(w) { }
+ QWindow *renderWindow(QPoint *offset) Q_DECL_OVERRIDE;
+
+private:
+ QWindow *m_window;
+};
+
WindowMultiThreaded::WindowMultiThreaded()
: m_qmlComponent(Q_NULLPTR),
m_rootItem(0),
@@ -239,7 +249,7 @@ WindowMultiThreaded::WindowMultiThreaded()
m_offscreenSurface->setFormat(m_context->format());
m_offscreenSurface->create();
- m_renderControl = new QQuickRenderControl(this);
+ m_renderControl = new RenderControl(this);
// Create a QQuickWindow that is associated with out render control. Note that this
// window never gets created or shown, meaning that it will never get an underlying
diff --git a/examples/quick/rendercontrol/window_singlethreaded.cpp b/examples/quick/rendercontrol/window_singlethreaded.cpp
index a5748530d..1e81f08f7 100644
--- a/examples/quick/rendercontrol/window_singlethreaded.cpp
+++ b/examples/quick/rendercontrol/window_singlethreaded.cpp
@@ -56,6 +56,23 @@
#include <QQuickRenderControl>
#include <QCoreApplication>
+class RenderControl : public QQuickRenderControl
+{
+public:
+ RenderControl(QWindow *w) : m_window(w) { }
+ QWindow *renderWindow(QPoint *offset) Q_DECL_OVERRIDE;
+
+private:
+ QWindow *m_window;
+};
+
+QWindow *RenderControl::renderWindow(QPoint *offset)
+{
+ if (offset)
+ *offset = QPoint(0, 0);
+ return m_window;
+}
+
WindowSingleThreaded::WindowSingleThreaded()
: m_rootItem(0),
m_fbo(0),
@@ -85,7 +102,7 @@ WindowSingleThreaded::WindowSingleThreaded()
m_cubeRenderer = new CubeRenderer(m_offscreenSurface);
- m_renderControl = new QQuickRenderControl(this);
+ m_renderControl = new RenderControl(this);
// Create a QQuickWindow that is associated with out render control. Note that this
// window never gets created or shown, meaning that it will never get an underlying