From ed3530bdee2b4cce4855f9196c7dcf492b1eed5c Mon Sep 17 00:00:00 2001
From: Simon Hausmann <simon.hausmann@digia.com>
Date: Fri, 8 Aug 2014 10:32:53 +0200
Subject: [PATCH] Make the QtQuick window surface type configurable

The default remains OpenGLSurface.

Change-Id: I96b400b7aa9c2b0435ea0614598e1b1f32b6d6b2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
---
 src/quick/items/qquickwindow.cpp       | 2 +-
 src/quick/scenegraph/qsgrenderloop.cpp | 5 +++++
 src/quick/scenegraph/qsgrenderloop_p.h | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 1640b58c75..b987a398a5 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -465,7 +465,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control)
         context = windowManager->createRenderContext(sg);
     }
 
-    q->setSurfaceType(QWindow::OpenGLSurface);
+    q->setSurfaceType(windowManager ? windowManager->windowSurfaceType() : QSurface::OpenGLSurface);
     q->setFormat(q->defaultFormat());
 
     animationController = new QQuickAnimatorController();
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index 064d363412..0f43ecffd7 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -86,6 +86,11 @@ QSGRenderLoop::~QSGRenderLoop()
 {
 }
 
+QSurface::SurfaceType QSGRenderLoop::windowSurfaceType() const
+{
+    return QSurface::OpenGLSurface;
+}
+
 void QSGRenderLoop::cleanup()
 {
     if (!s_instance)
diff --git a/src/quick/scenegraph/qsgrenderloop_p.h b/src/quick/scenegraph/qsgrenderloop_p.h
index 8d5312b188..b398a64234 100644
--- a/src/quick/scenegraph/qsgrenderloop_p.h
+++ b/src/quick/scenegraph/qsgrenderloop_p.h
@@ -43,6 +43,7 @@
 #define QSGRenderLoop_P_H
 
 #include <QtGui/QImage>
+#include <QtGui/QSurface>
 #include <private/qtquickglobal_p.h>
 #include <QtCore/QSet>
 
@@ -83,6 +84,8 @@ public:
     void removeWindow(QQuickWindow *win) { m_windows.remove(win); }
     QSet<QQuickWindow *> windows() const { return m_windows; }
 
+    virtual QSurface::SurfaceType windowSurfaceType() const;
+
     // ### make this less of a singleton
     static QSGRenderLoop *instance();
     static void setInstance(QSGRenderLoop *instance);
-- 
GitLab