summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-01-27 10:15:34 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-01-27 10:15:34 (GMT)
commitaac8c2678867ae86af846a2644e37b3d1436406a (patch)
tree64a5eab52fbec59c7cdf04afe5d1e76a78ce5075 /src/opengl
parent39e6aa3f4434ab31d3d862574aa505b3f946ee9b (diff)
parentb0390e68893dd04076434695be5e676b87bc067c (diff)
downloadQt-aac8c2678867ae86af846a2644e37b3d1436406a.zip
Qt-aac8c2678867ae86af846a2644e37b3d1436406a.tar.gz
Qt-aac8c2678867ae86af846a2644e37b3d1436406a.tar.bz2
Merge branch 'staging-master' of scm.dev.nokia.troll.no:qt/qt-lighthouse into master-integration
* 'staging-master' of scm.dev.nokia.troll.no:qt/qt-lighthouse: (69 commits) Lighthouse: License headers to new files in testlite Make sure we blit the fbo on flush in QGLWindowSurface Lighthouse: Wayland. Make the wayland integration closer to Lighthosue Lighthouse: Wayland, only make one fbo for the WaylandPaintDevice Making clearer separation between responsibility of different classes Make it possible to vertically mirror gl painting Lighthouse:Wayland Moving some logic into files Fix Wayland plugin to work with Wayland after some interfaces changed Make QGLContext::fromPlatformGLContext show correct sharing Remove Lighthouse specific code from QGLWindowSurface Fix X11 clipboard bug. Fix for uninitialized member in QWaylandCursor wayland: use pkgconfig for libdrm in wayland.pro wayland: remove non-public header from config.tests wayland: fix SOURCES to point to wayland.cpp in config.tests Wayland: request rbg and premultiplied argb visuals as needed Wayland: clamp window resizes to screen size Wayland: split GL code into separate files Wayland: use correct viewport for swapBuffers and correct coords Wayland: fix geometry of swapBuffers ...
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp21
-rw-r--r--src/opengl/opengl.pro.user.2.1pre183
-rw-r--r--src/opengl/qgl.cpp34
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qgl_qpa.cpp35
-rw-r--r--src/opengl/qglpaintdevice.cpp6
-rw-r--r--src/opengl/qglpaintdevice_p.h1
-rw-r--r--src/opengl/qwindowsurface_gl.cpp12
8 files changed, 124 insertions, 69 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index fe8554f..2e21fbd 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -337,7 +337,13 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
matrix.translate(brushOrigin.x(), brushOrigin.y());
QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y());
- QTransform gl_to_qt(1, 0, 0, -1, 0, height);
+ qreal m22 = -1;
+ qreal dy = height;
+ if (device->isFlipped()) {
+ m22 = 1;
+ dy = 0;
+ }
+ QTransform gl_to_qt(1, 0, 0, m22, 0, dy);
QTransform inv_matrix;
if (style == Qt::TexturePattern && textureInvertedY == -1)
inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
@@ -376,10 +382,16 @@ void QGL2PaintEngineExPrivate::updateMatrix()
// NOTE: The resultant matrix is also transposed, as GL expects column-major matracies
const GLfloat wfactor = 2.0f / width;
- const GLfloat hfactor = -2.0f / height;
+ GLfloat hfactor = -2.0f / height;
+
GLfloat dx = transform.dx();
GLfloat dy = transform.dy();
+ if (device->isFlipped()) {
+ hfactor *= -1;
+ dy -= height;
+ }
+
// Non-integer translates can have strange effects for some rendering operations such as
// anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.
if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
@@ -2063,7 +2075,10 @@ void QGL2PaintEngineExPrivate::setScissor(const QRect &rect)
{
const int left = rect.left();
const int width = rect.width();
- const int bottom = height - (rect.top() + rect.height());
+ int bottom = height - (rect.top() + rect.height());
+ if (device->isFlipped()) {
+ bottom = rect.top();
+ }
const int height = rect.height();
glScissor(left, bottom, width, height);
diff --git a/src/opengl/opengl.pro.user.2.1pre1 b/src/opengl/opengl.pro.user.2.1pre1
new file mode 100644
index 0000000..0c38724
--- /dev/null
+++ b/src/opengl/opengl.pro.user.2.1pre1
@@ -0,0 +1,83 @@
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value key="EditorConfiguration.Codec" type="QByteArray">UTF-8</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+ <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList">
+ <value type="QString">QMAKE_ABSOLUTE_SOURCE_PATH=/home/jlind/dev/qt/lighthouse-master/src/opengl</value>
+ </valuelist>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">-j9</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/jlind/builds/master-lighthouse/src/opengl</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">23</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">1</value>
+ <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">headers</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">../../../../../builds/master-lighthouse/include/QtOpenGL/headers.pri</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">4</value>
+ </data>
+</qtcreator>
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index be2da4a..0ec3a15 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -3772,24 +3772,7 @@ QGLWidget::QGLWidget(QWidget *parent, const QGLWidget* shareWidget, Qt::WindowFl
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(true); // for compatibility
-#ifdef Q_WS_QPA
- QPlatformWindowFormat platformFormat = QGLFormat::toPlatformWindowFormat(QGLFormat::defaultFormat());
- platformFormat.setUseDefaultSharedContext(false);
- if (shareWidget && shareWidget->d_func()->glcx) {
- QPlatformGLContext *sharedPlatformContext = shareWidget->d_func()->glcx->d_func()->platformContext;
- platformFormat.setSharedContext(sharedPlatformContext);
- }
- setPlatformWindowFormat(platformFormat);
- winId(); // create window;
- QGLContext *glContext = 0;
- if (platformWindow())
- glContext = QGLContext::fromPlatformGLContext(platformWindow()->glContext());
- if (glContext){
- d->init(glContext,shareWidget);
- }
-#else
d->init(new QGLContext(QGLFormat::defaultFormat(), this), shareWidget);
-#endif
}
@@ -3829,24 +3812,7 @@ QGLWidget::QGLWidget(const QGLFormat &format, QWidget *parent, const QGLWidget*
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(true); // for compatibility
-#ifdef Q_WS_QPA
- QPlatformWindowFormat platformFormat = QGLFormat::toPlatformWindowFormat(format);
- platformFormat.setUseDefaultSharedContext(false);
- if (shareWidget && shareWidget->d_func()->glcx) {
- QPlatformGLContext *sharedPlatformContext = shareWidget->d_func()->glcx->d_func()->platformContext;
- platformFormat.setSharedContext(sharedPlatformContext);
- }
- setPlatformWindowFormat(platformFormat);
- winId(); // create window;
- QGLContext *glContext = 0;
- if (platformWindow())
- glContext = QGLContext::fromPlatformGLContext(platformWindow()->glContext());
- if (glContext){
- d->init(glContext,shareWidget);
- }
-#else
d->init(new QGLContext(format, this), shareWidget);
-#endif
}
/*!
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 204abe8..5508598 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -373,6 +373,7 @@ public:
#if defined(Q_WS_QPA)
QPlatformGLContext *platformContext;
+ void setupSharing();
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
void* cx;
#endif
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 415e915..0f4b305 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -115,6 +115,16 @@ QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
return retFormat;
}
+void QGLContextPrivate::setupSharing() {
+ Q_Q(QGLContext);
+ QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext();
+ if (sharedPlatformGLContext) {
+ QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
+ sharing = true;
+ QGLContextGroup::addShare(q,actualSharedContext);
+ }
+}
+
bool QGLFormat::hasOpenGL()
{
return QApplicationPrivate::platformIntegration()->hasOpenGL();
@@ -151,19 +161,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
if (d->valid) {
d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
}
+ d->setupSharing();
}
- if (d->valid) {
- QPlatformGLContext *sharedPlatformGLContext = d->platformContext->platformWindowFormat().sharedGLContext();
- if (sharedPlatformGLContext) {
- QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
- if (actualSharedContext == shareContext) {
- d->sharing = true;//Will add combination in QGLContext::create
- }else {
- QGLContextGroup::addShare(this,actualSharedContext);
- }
- }
- }
return d->valid;
}
@@ -325,11 +325,6 @@ void QGLWidget::setMouseTracking(bool enable)
bool QGLWidget::event(QEvent *e)
{
Q_D(QGLWidget);
- if (e->type() == QEvent::WinIdChange) {
- if (platformWindow()) {
- d->glcx = QGLContext::fromPlatformGLContext(platformWindow()->glContext());
- }
- }
return QWidget::event(e);
}
@@ -377,6 +372,9 @@ QGLContext::QGLContext(QPlatformGLContext *platformContext)
Q_D(QGLContext);
d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()));
d->platformContext = platformContext;
+ d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->valid = true;
+ d->setupSharing();
}
QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext)
@@ -389,11 +387,6 @@ QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContex
QGLContext *glContext = new QGLContext(platformContext);
//Dont call create on context. This can cause the platformFormat to be set on the widget, which
//will cause the platformWindow to be recreated.
- glContext->d_func()->platformContext->setQGLContextHandle(glContext,qDeleteQGLContext);
- QGLFormat format = QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat());
- glContext->d_func()->glFormat = format;
- glContext->d_func()->valid = true;
-
return glContext;
}
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index ae61ca1..7d0eb5b 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -145,8 +145,10 @@ bool QGLPaintDevice::alphaRequested() const
return context()->d_func()->reqFormat.alpha();
}
-
-
+bool QGLPaintDevice::isFlipped() const
+{
+ return false;
+}
////////////////// QGLWidgetGLPaintDevice //////////////////
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index f90edf4..f4176fb 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -76,6 +76,7 @@ public:
virtual QGLFormat format() const;
virtual QSize size() const = 0;
virtual bool alphaRequested() const;
+ virtual bool isFlipped() const;
// returns the QGLPaintDevice for the given QPaintDevice
static QGLPaintDevice* getDevice(QPaintDevice*);
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 8b54368..5a783ca 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -402,11 +402,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
if (widgetPrivate->extraData()->glContext)
return;
-#ifdef Q_WS_QPA
- QGLContext *ctx = QGLContext::fromPlatformGLContext(widget->platformWindow()->glContext());
- if (!d_ptr->fbo && d_ptr->tried_fbo)
- d_ptr->ctx = ctx;
-#else
QGLContext *ctx = NULL;
// For translucent top-level widgets we need alpha in the format.
@@ -419,8 +414,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
} else
ctx = new QGLContext(surfaceFormat, widget);
- ctx->create(qt_gl_share_widget()->context());
-#endif
+ ctx->create(qt_gl_share_context());
#ifndef QT_NO_EGL
static bool checkedForNOKSwapRegion = false;
@@ -480,6 +474,8 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
void QGLWindowSurface::beginPaint(const QRegion &)
{
+ d_ptr->did_paint = true;
+
if (!context())
return;
@@ -494,8 +490,6 @@ void QGLWindowSurface::beginPaint(const QRegion &)
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(clearFlags);
}
-
- d_ptr->did_paint = true;
}
void QGLWindowSurface::endPaint(const QRegion &rgn)