summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/kms/qkmscontext.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-09-26 14:07:31 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-09-30 18:23:08 +0200
commit684990d1481b0858489596dc7b28310bb87a6dfa (patch)
tree29f6b2df7a35d610e71315cdc01e2a8b82ba9380 /src/plugins/platforms/kms/qkmscontext.cpp
parent3a2fdc48ad1066eb043f83024ddd76098f933d3a (diff)
kms: Support QOpenGLWidget and QQuickWidget
Also fixes the handling of shareContext() for contexts and format() for windows and makes QOffscreenSurface working. Change-Id: I3c3374a9de14a5b8428de3e11d9d7e1285c5b9c7 Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/plugins/platforms/kms/qkmscontext.cpp')
-rw-r--r--src/plugins/platforms/kms/qkmscontext.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/plugins/platforms/kms/qkmscontext.cpp b/src/plugins/platforms/kms/qkmscontext.cpp
index c3a4923ce1..4b4505294c 100644
--- a/src/plugins/platforms/kms/qkmscontext.cpp
+++ b/src/plugins/platforms/kms/qkmscontext.cpp
@@ -35,19 +35,18 @@
#include "qkmsdevice.h"
#include "qkmscontext.h"
#include "qkmswindow.h"
+#include "qkmsintegration.h"
-#include <QOpenGLContext>
-
+#include <QtGui/QOpenGLContext>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
QT_BEGIN_NAMESPACE
QKmsContext::QKmsContext(QOpenGLContext *context, QKmsDevice *device)
- : QPlatformOpenGLContext()
- , m_device(device)
+ : m_device(device)
{
EGLDisplay display = m_device->eglDisplay();
- EGLConfig config = q_configFromGLFormat(display, QKmsScreen::tweakFormat(context->format()), true);
+ EGLConfig config = q_configFromGLFormat(display, QKmsScreen::tweakFormat(context->format()));
m_format = q_glFormatFromConfig(display, config);
//Initialize EGLContext
@@ -57,7 +56,12 @@ QKmsContext::QKmsContext(QOpenGLContext *context, QKmsDevice *device)
};
eglBindAPI(EGL_OPENGL_ES_API);
- m_eglContext = eglCreateContext(display, config, 0, contextAttribs);
+
+ EGLContext share = EGL_NO_CONTEXT;
+ if (context->shareContext())
+ share = static_cast<QKmsContext *>(context->shareContext()->handle())->eglContext();
+
+ m_eglContext = eglCreateContext(display, config, share, contextAttribs);
if (m_eglContext == EGL_NO_CONTEXT) {
qWarning("QKmsContext::QKmsContext(): eglError: %x, this: %p",
eglGetError(), this);
@@ -72,16 +76,19 @@ bool QKmsContext::isValid() const
bool QKmsContext::makeCurrent(QPlatformSurface *surface)
{
- Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+ Q_ASSERT(surface->surface()->supportsOpenGL());
EGLDisplay display = m_device->eglDisplay();
-
- QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
- QKmsScreen *screen = static_cast<QKmsScreen *> (QPlatformScreen::platformScreenForWindow(window->window()));
-
- EGLSurface eglSurface = screen->eglSurface();
-
- screen->waitForPageFlipComplete();
+ EGLSurface eglSurface;
+
+ if (surface->surface()->surfaceClass() == QSurface::Window) {
+ QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
+ QKmsScreen *screen = static_cast<QKmsScreen *>(QPlatformScreen::platformScreenForWindow(window->window()));
+ eglSurface = screen->eglSurface();
+ screen->waitForPageFlipComplete();
+ } else {
+ eglSurface = static_cast<QKmsOffscreenWindow *>(surface)->surface();
+ }
bool ok = eglMakeCurrent(display, eglSurface, eglSurface, m_eglContext);
if (!ok)