summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2010-05-14 12:07:51 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2010-06-01 08:12:14 (GMT)
commitf3a920be362b85d248a9b76c1b15a0b096d7c90e (patch)
tree4b2d4c33ae0cc67cd731ba474f3153699c74928a /src/plugins
parent28580117adf5149e7ca15a43a398b412f4ec0ab4 (diff)
downloadQt-f3a920be362b85d248a9b76c1b15a0b096d7c90e.zip
Qt-f3a920be362b85d248a9b76c1b15a0b096d7c90e.tar.gz
Qt-f3a920be362b85d248a9b76c1b15a0b096d7c90e.tar.bz2
gl on openkode. QGLWidget only works for toplevel widgets
and QGLWindowSurface is used for anything else
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/openkode/main.cpp5
-rw-r--r--src/plugins/platforms/openkode/openkode.pro23
-rw-r--r--src/plugins/platforms/openkode/qopenkodeglintegration.cpp259
-rw-r--r--src/plugins/platforms/openkode/qopenkodeglintegration.h81
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.cpp23
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.h4
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.cpp41
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.h1
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindowsurface.cpp10
9 files changed, 424 insertions, 23 deletions
diff --git a/src/plugins/platforms/openkode/main.cpp b/src/plugins/platforms/openkode/main.cpp
index bd2b5c7..b60ae1b 100644
--- a/src/plugins/platforms/openkode/main.cpp
+++ b/src/plugins/platforms/openkode/main.cpp
@@ -48,7 +48,7 @@ class QOpenKODEPlugin : public QPlatformIntegrationPlugin
{
public:
QStringList keys() const;
- QPlatformIntegration *create(const QString&);
+ QPlatformIntegration *create(const QString&, const QStringList&);
};
QStringList QOpenKODEPlugin::keys() const
@@ -58,8 +58,9 @@ QStringList QOpenKODEPlugin::keys() const
return list;
}
-QPlatformIntegration * QOpenKODEPlugin::create(const QString& system)
+QPlatformIntegration * QOpenKODEPlugin::create(const QString& system, const QStringList& paramList)
{
+ Q_UNUSED(paramList);
if (system.toLower() == "openkode")
return new QOpenKODEIntegration;
diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro
index 042b74d..0614b3b 100644
--- a/src/plugins/platforms/openkode/openkode.pro
+++ b/src/plugins/platforms/openkode/openkode.pro
@@ -1,20 +1,37 @@
TARGET = qopenkodeintegration
include(../../qpluginbase.pri)
+QT += opengl
+
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
SOURCES = main.cpp \
qopenkodeintegration.cpp \
qopenkodewindowsurface.cpp \
- qopenkodewindow.cpp
+ qopenkodewindow.cpp \
+ qopenkodeglintegration.cpp
HEADERS = qopenkodeintegration.h \
qopenkodewindowsurface.h \
- qopenkodewindow.h
+ qopenkodewindow.h \
+ qopenkodeglintegration.h
RESOURCES = resources.qrc
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
-LIBS += -lKD -lEGL -lGLESv2
+LIBS += -lKD -lEGL
+!isEmpty(QMAKE_INCDIR_OPENGL_ES2){
+ INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2
+}
+!isEmpty(QMAKE_LIBDIR_OPENGL_ES2){
+ for(p, QMAKE_LIBDIR_OPENGL_ES2) {
+ exists($$p):LIBS += -L$$p
+ }
+}
+!isEmpty(QMAKE_LIBS_OPENGL_ES2){
+ LIBS += $$QMAKE_LIBS_OPENGL_ES2
+} else {
+ LIBS += -lGLESv2
+}
diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp
new file mode 100644
index 0000000..b0d901b
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp
@@ -0,0 +1,259 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenkodeglintegration.h"
+#include <QtCore/QDebug>
+#include <QtGui/QPlatformWindow>
+#include <QtGui/private/qapplication_p.h>
+
+#include <QtOpenGL/private/qwindowsurface_gl_p.h>
+
+#include <EGL/eglext.h>
+
+void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat)
+{
+ int redSize = glFormat.redBufferSize();
+ int greenSize = glFormat.greenBufferSize();
+ int blueSize = glFormat.blueBufferSize();
+ int alphaSize = glFormat.alphaBufferSize();
+ int depthSize = glFormat.depthBufferSize();
+ int stencilSize = glFormat.stencilBufferSize();
+ int sampleCount = glFormat.samples();
+
+ // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
+ // type has been requested. So we must check QGLFormat's booleans too if size is -1:
+ if (glFormat.alpha() && alphaSize <= 0)
+ alphaSize = 1;
+ if (glFormat.depth() && depthSize <= 0)
+ depthSize = 1;
+ if (glFormat.stencil() && stencilSize <= 0)
+ stencilSize = 1;
+ if (glFormat.sampleBuffers() && sampleCount <= 0)
+ sampleCount = 1;
+
+ // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
+ // the best performance. The EGL config selection algorithm is a bit stange in this regard:
+ // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
+ // 32-bit configs completely from the selection. So it then comes to the sorting algorithm.
+ // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort
+ // order is special and described as "by larger _total_ number of color bits.". So EGL will
+ // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on
+ // to say "If the requested number of bits in attrib_list for a particular component is 0,
+ // then the number of bits for that component is not considered". This part of the spec also
+ // seems to imply that setting the red/green/blue bits to zero means none of the components
+ // are considered and EGL disregards the entire sorting rule. It then looks to the next
+ // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being
+ // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
+ // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
+ // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
+ // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will
+ // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well.
+
+ // Now normalize the values so -1 becomes 0
+ redSize = redSize > 0 ? redSize : 0;
+ greenSize = greenSize > 0 ? greenSize : 0;
+ blueSize = blueSize > 0 ? blueSize : 0;
+ alphaSize = alphaSize > 0 ? alphaSize : 0;
+ depthSize = depthSize > 0 ? depthSize : 0;
+ stencilSize = stencilSize > 0 ? stencilSize : 0;
+ sampleCount = sampleCount > 0 ? sampleCount : 0;
+
+ eglProperties.setValue(EGL_RED_SIZE, redSize);
+ eglProperties.setValue(EGL_GREEN_SIZE, greenSize);
+ eglProperties.setValue(EGL_BLUE_SIZE, blueSize);
+ eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize);
+ eglProperties.setValue(EGL_DEPTH_SIZE, depthSize);
+ eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize);
+ eglProperties.setValue(EGL_SAMPLES, sampleCount);
+ eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0);
+}
+
+// Updates "format" with the parameters of the selected configuration.
+void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config)
+{
+ EGLint redSize = 0;
+ EGLint greenSize = 0;
+ EGLint blueSize = 0;
+ EGLint alphaSize = 0;
+ EGLint depthSize = 0;
+ EGLint stencilSize = 0;
+ EGLint sampleCount = 0;
+ EGLint level = 0;
+
+ EGLDisplay display = QEgl::display();
+ eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
+ eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
+ eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize);
+ eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize);
+ eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
+ eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
+ eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
+ eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
+
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setAlphaBufferSize(alphaSize);
+ format.setDepthBufferSize(depthSize);
+ format.setStencilBufferSize(stencilSize);
+ format.setSamples(sampleCount);
+ format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal"
+ format.setDirectRendering(true); // All EGL contexts are direct-rendered
+ format.setRgba(true); // EGL doesn't support colour index rendering
+ format.setStereo(false); // EGL doesn't support stereo buffers
+ format.setAccumBufferSize(0); // EGL doesn't support accululation buffers
+
+ // Clear the EGL error state because some of the above may
+ // have errored out because the attribute is not applicable
+ // to the surface type. Such errors don't matter.
+ eglGetError();
+}
+
+QEGLPlatformWidgetSurface::QEGLPlatformWidgetSurface()
+ :QPlatformGLWidgetSurface()
+{
+
+}
+QEGLPlatformWidgetSurface::~QEGLPlatformWidgetSurface()
+{
+}
+
+bool QEGLPlatformWidgetSurface::create(QGLWidget* widget, QGLFormat& format)
+{
+ return true;
+}
+void QEGLPlatformWidgetSurface::setGeometry(const QRect& rect)
+{
+ Q_UNUSED(rect);
+}
+bool QEGLPlatformWidgetSurface::filterEvent(QEvent *event)
+{
+ return QPlatformGLWidgetSurface::filterEvent(event);
+}
+
+QEGLPlatformContext::QEGLPlatformContext()
+{
+}
+
+QEGLPlatformContext::~QEGLPlatformContext()
+{
+ if (m_eglSurface != EGL_NO_SURFACE) {
+ doneCurrent();
+ eglDestroySurface(QEgl::display(), m_eglSurface);
+ m_eglSurface = EGL_NO_SURFACE;
+ }
+
+ if (m_context != EGL_NO_CONTEXT) {
+ eglDestroyContext(QEgl::display(), m_context);
+ m_context = EGL_NO_CONTEXT;
+ }
+}
+
+bool QEGLPlatformContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext)
+{
+ QEglProperties properties;
+ properties.setValue(EGL_CONTEXT_CLIENT_VERSION, 2);
+ //lets go with all defaults :) Seems like we get bad attributes for anything else
+ //qt_eglproperties_set_glformat(properties,format);
+ format.setDepthBufferSize(1);
+ EGLConfig config = QEgl::defaultConfig(device->devType(), QEgl::OpenGL,QEgl::Renderable);
+ QEGLPlatformContext *eglShareContext = static_cast<QEGLPlatformContext *>(shareContext);
+ if (shareContext && eglShareContext->m_context != EGL_NO_CONTEXT) {
+ m_context = eglCreateContext(QEgl::display(), config, eglShareContext->m_context, properties.properties());
+ if (m_context == EGL_NO_CONTEXT) {
+ qWarning() << "QEglContext::createContext(): Could not share context:" << QEgl::errorString();
+ shareContext = 0;
+ }
+ } else {
+ m_context = eglCreateContext(QEgl::display(), config, EGL_NO_CONTEXT, properties.properties());
+ if (m_context == EGL_NO_CONTEXT) {
+ qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << QEgl::errorString();
+ return false;
+ }
+ }
+ //Get/create the EGLSurface
+ if (device && device->devType() == QInternal::Widget){
+ QWidget* widget = static_cast<QWidget*>(device);
+ QGLWidget* glWidget = qobject_cast<QGLWidget*>(widget);
+
+ if (!widget->isTopLevel()) {
+ qWarning("Creating a GL context is only supported on top-level QWidgets");
+ return false;
+ }
+ EGLNativeWindowType winId = (EGLNativeWindowType) widget->window()->winId();
+
+ m_eglSurface = eglCreateWindowSurface(QEgl::display(), config, winId, 0);
+ makeCurrent();
+ glClearColor(0.0, 0.0, 0.0, 1.0);
+ swapBuffers();
+
+
+ } else {
+ qDebug() << "QEGLPlatformContext::create: didn't create surface!!!!!";
+ }
+ return true;
+
+}
+
+void QEGLPlatformContext::makeCurrent()
+{
+ eglBindAPI(EGL_OPENGL_API);
+ bool ok = eglMakeCurrent(QEgl::display(), m_eglSurface, m_eglSurface, m_context);
+ if (!ok)
+ qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << QEgl::errorString();
+}
+void QEGLPlatformContext::doneCurrent()
+{
+ eglBindAPI(EGL_OPENGL_ES_API);
+ bool ok = eglMakeCurrent(QEgl::display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ if (!ok)
+ qWarning() << "QEGLPlatformContext::doneCurrent():" << QEgl::errorString();
+}
+void QEGLPlatformContext::swapBuffers()
+{
+ bool ok = eglSwapBuffers(QEgl::display(), m_eglSurface);
+ if (!ok)
+ qWarning() << "QEGLPlatformContext::swapBuffers():" << QEgl::errorString();
+}
+void* QEGLPlatformContext::getProcAddress(const QString& procName)
+{
+ eglGetProcAddress(qPrintable(procName));
+}
diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.h b/src/plugins/platforms/openkode/qopenkodeglintegration.h
new file mode 100644
index 0000000..c3291b8
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodeglintegration.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENKODEGLINTEGRATION_H
+#define QOPENKODEGLINTEGRATION_H
+
+#include <QtOpenGL/qglplatformintegration_lite.h>
+#include <QtGui/private/qeglproperties_p.h>
+#include <EGL/egl.h>
+
+void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat);
+// Updates "format" with the parameters of the selected configuration.
+void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config);
+
+class QEGLPlatformWidgetSurface : public QPlatformGLWidgetSurface
+{
+public:
+ QEGLPlatformWidgetSurface();
+ virtual ~QEGLPlatformWidgetSurface();
+
+ bool create(QGLWidget*, QGLFormat&);
+ void setGeometry(const QRect&);
+ bool filterEvent(QEvent *);
+};
+
+class QEGLPlatformContext : public QPlatformGLContext
+{
+public:
+ QEGLPlatformContext();
+ ~QEGLPlatformContext();
+
+ bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext);
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void* getProcAddress(const QString& procName);
+
+private:
+ EGLContext m_context;
+ EGLSurface m_eglSurface;
+};
+
+#endif //QOPENKODEGLINTEGRATION_H
diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp
index d9430c2..cd957af 100644
--- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp
+++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp
@@ -42,6 +42,10 @@
#include "qopenkodeintegration.h"
#include "qopenkodewindowsurface.h"
#include "qopenkodewindow.h"
+#include "qopenkodeglintegration.h"
+
+#include <QtOpenGL/private/qpixmapdata_gl_p.h>
+#include <QtOpenGL/private/qwindowsurface_gl_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
@@ -198,7 +202,7 @@ QOpenKODEIntegration::QOpenKODEIntegration()
QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const
{
- return new QRasterPixmapData(type);
+ return new QGLPixmapData(type);
}
QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) const
@@ -206,9 +210,22 @@ QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId )
return new QOpenKODEWindow(tlw);
}
-QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId wid) const
+{
+ return new QGLWindowSurface(widget);
+}
+
+bool QOpenKODEIntegration::hasOpenGL() const
+{
+ return true;
+}
+QPlatformGLContext *QOpenKODEIntegration::createGLContext()
+{
+ return new QEGLPlatformContext;
+}
+QPlatformGLWidgetSurface *QOpenKODEIntegration::createGLWidgetSurface()
{
- return new QOpenKODEWindowSurface(widget,winId);
+ return new QEGLPlatformWidgetSurface;
}
GLuint QOpenKODEIntegration::blitterProgram()
diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h
index 76ce219..ad6db4b 100644
--- a/src/plugins/platforms/openkode/qopenkodeintegration.h
+++ b/src/plugins/platforms/openkode/qopenkodeintegration.h
@@ -81,6 +81,10 @@ public:
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ bool hasOpenGL() const;
+ QPlatformGLContext * createGLContext();
+ QPlatformGLWidgetSurface * createGLWidgetSurface();
+
virtual QList<QPlatformScreen *> screens() const { return mScreens; }
static GLuint blitterProgram();
diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp
index 8e1527c..4d18a6f 100644
--- a/src/plugins/platforms/openkode/qopenkodewindow.cpp
+++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp
@@ -63,23 +63,28 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw)
return;
}
- const KDint windowSize[2] = { tlw->width(), tlw->height() };
+ const KDint windowSize[2] = { tlw->width(), tlw->height()-1 };
if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) {
qErrnoWarning(kdGetError(), "Could not set native window size");
return;
}
+ KDboolean visibillity(false);
+ if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) {
+ qErrnoWarning(kdGetError(), "Could not set visibillity to false");
+ }
+
// const KDboolean windowExclusive[] = { false };
// if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) {
// qErrnoWarning(kdGetError(), "Could not set exclusive bit");
// //return;
// }
//
-// const KDint windowPos[2] = { tlw->x(), tlw->y() };
-// if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
-// qErrnoWarning(kdGetError(), "Could not set native window position");
-// return;
-// }
+ const KDint windowPos[2] = { tlw->x(), tlw->y() };
+ if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
+ qErrnoWarning(kdGetError(), "Could not set native window position");
+ return;
+ }
if (kdRealizeWindow(kdWindow, &eglWindow)) {
qErrnoWarning(kdGetError(), "Could not realize native window");
@@ -87,6 +92,11 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw)
}
}
+QOpenKODEWindow::~QOpenKODEWindow()
+{
+ qDebug() << "destroying window";
+ kdDestroyWindow(kdWindow);
+}
void QOpenKODEWindow::setGeometry(const QRect &rect)
{
const QRect geo = geometry();
@@ -98,17 +108,20 @@ void QOpenKODEWindow::setGeometry(const QRect &rect)
}
}
-// if (geo.topLeft() != rect.topLeft()) {
-// const KDint windowPos[2] = { rect.x(), rect.y() };
-// if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
-// qErrnoWarning(kdGetError(), "Could not set native window position");
-// //return;
-// }
-// }
+ if (geo.topLeft() != rect.topLeft()) {
+ const KDint windowPos[2] = { rect.x(), rect.y() };
+ if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
+ qErrnoWarning(kdGetError(), "Could not set native window position");
+ //return;
+ }
+ }
}
void QOpenKODEWindow::setVisible(bool visible)
{
-
+ KDboolean visibillity(visible);
+ if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) {
+ qErrnoWarning(kdGetError(), "Could not set visibillity to false");
+ }
}
diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h
index b52f8e6..741e676 100644
--- a/src/plugins/platforms/openkode/qopenkodewindow.h
+++ b/src/plugins/platforms/openkode/qopenkodewindow.h
@@ -50,6 +50,7 @@ class QOpenKODEWindow : public QPlatformWindow
{
public:
QOpenKODEWindow(QWidget *tlw);
+ ~QOpenKODEWindow();
void setGeometry(const QRect &rect);
void setVisible(bool visible);
diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp
index 5eb0d2d..dacd019 100644
--- a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp
+++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp
@@ -135,7 +135,7 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion &region, const QPoin
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, blitImage.bits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage.bits());
// Enable vertex attribute associated with vertex position
glEnableVertexAttribArray(posId);
@@ -157,8 +157,12 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion &region, const QPoin
if (texId)
glDeleteTextures(1, &texId);
+ eglWaitGL();
+
mContext.swapBuffers(mSurface);
mContext.doneCurrent();
+
+ eglWaitNative(EGL_CORE_NATIVE_ENGINE);
}
void QOpenKODEWindowSurface::resize(const QSize &size)
@@ -171,10 +175,14 @@ void QOpenKODEWindowSurface::resize(const QSize &size)
}
void QOpenKODEWindowSurface::beginPaint(const QRegion &region)
{
+ Q_UNUSED(region);
if (mSurface == EGL_NO_SURFACE) {
EGLConfig config = QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable);
EGLint windowAttrs[] = { EGL_NONE };
mSurface = eglCreateWindowSurface(QEgl::display(), config, mWin, windowAttrs);
+ if (mSurface == EGL_NO_SURFACE) {
+ qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
+ }
mImage = QImage(size(),QImage::Format_RGB32);
}
}