diff options
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 86 |
1 files changed, 62 insertions, 24 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index ed541ce..eae1c9b 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -181,6 +181,7 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL) // // QGLWindowSurface // +#ifndef Q_WS_QPA class QGLGlobalShareWidget { public: @@ -256,6 +257,23 @@ void qt_destroy_gl_share_widget() { _qt_gl_share_widget()->destroy(); } +#endif//Q_WS_QPA + +const QGLContext *qt_gl_share_context() +{ +#ifdef Q_WS_QPA + //make it possible to have an assesor to defaultSharedGLContext. + const QPlatformGLContext *platformContext = QPlatformGLContext::defaultSharedContext(); + if (!platformContext) + qDebug() << "Please implement a defaultSharedContext for your platformplugin"; + return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(platformContext)); +#else + QGLWidget *widget = qt_gl_share_widget(); + if (widget) + return widget->context(); + return 0; +#endif +} #ifdef QGL_USE_TEXTURE_POOL void qt_gl_register_pixmap(QGLPixmapData *pd) @@ -319,6 +337,8 @@ struct QGLWindowSurfacePrivate QList<QImage> buffers; QGLWindowSurfaceGLPaintDevice glDevice; QGLWindowSurface* q_ptr; + + bool partialUpdateSupport; }; QGLFormat QGLWindowSurface::surfaceFormat; @@ -354,7 +374,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const QGLWindowSurface::QGLWindowSurface(QWidget *window) : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate) { - Q_ASSERT(window->isTopLevel()); +// Q_ASSERT(window->isTopLevel()); d_ptr->pb = 0; d_ptr->fbo = 0; d_ptr->ctx = 0; @@ -371,21 +391,19 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->q_ptr = this; d_ptr->geometry_updated = false; d_ptr->did_paint = false; - -#ifdef QGL_NO_PRESERVED_SWAP - setPartialUpdateSupport(false); -#endif + d_ptr->partialUpdateSupport = false; } QGLWindowSurface::~QGLWindowSurface() { if (d_ptr->ctx) glDeleteTextures(1, &d_ptr->tex_id); +#ifndef Q_WS_QPA // Dont delete the contexts. Destroying the window does that for us foreach(QGLContext **ctx, d_ptr->contexts) { delete *ctx; *ctx = 0; } - +#endif delete d_ptr->pb; delete d_ptr->fbo; delete d_ptr; @@ -422,17 +440,19 @@ void QGLWindowSurface::deleted(QObject *object) d_ptr->fbo = 0; } +#ifndef Q_WS_QPA //no need to specifically delete the QGLContext as it will be deleted by QWidget QWidgetPrivate *widgetPrivate = widget->d_func(); if (widgetPrivate->extraData()) { - union { QGLContext **ctxPtr; void **voidPtr; }; - voidPtr = &widgetPrivate->extraData()->glContext; - int index = d_ptr->contexts.indexOf(ctxPtr); + union { QGLContext **ctxPtrPtr; void **voidPtrPtr; }; + voidPtrPtr = &widgetPrivate->extraData()->glContext; + int index = d_ptr->contexts.indexOf(ctxPtrPtr); if (index != -1) { - delete *ctxPtr; - *ctxPtr = 0; + delete *ctxPtrPtr; + *ctxPtrPtr = 0; d_ptr->contexts.removeAt(index); } } +#endif } } @@ -455,7 +475,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) } else ctx = new QGLContext(surfaceFormat, widget); - ctx->create(qt_gl_share_widget()->context()); + ctx->create(qt_gl_share_context()); if (widget != qt_gl_share_widget()) ++(_qt_gl_share_widget()->widgetRefCount); @@ -471,8 +491,8 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (haveNOKSwapRegion) qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates."; } - - bool swapBehaviourPreserved = ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR); + bool swapBehaviourPreserved = (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED) + || (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT); if (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT) { EGLint swapBehavior; if (eglQuerySurface(ctx->d_func()->eglContext->display(), ctx->d_func()->eglSurface @@ -482,19 +502,21 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) } if (!swapBehaviourPreserved && !haveNOKSwapRegion) - setPartialUpdateSupport(false); // Force full-screen updates + d_ptr->partialUpdateSupport = false; // Force full-screen updates else - setPartialUpdateSupport(true); + d_ptr->partialUpdateSupport = true; +#else + d_ptr->partialUpdateSupport = false; #endif widgetPrivate->extraData()->glContext = ctx; - union { QGLContext **ctxPtr; void **voidPtr; }; + union { QGLContext **ctxPtrPtr; void **voidPtrPtr; }; connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(deleted(QObject*))); - voidPtr = &widgetPrivate->extraData()->glContext; - d_ptr->contexts << ctxPtr; + voidPtrPtr = &widgetPrivate->extraData()->glContext; + d_ptr->contexts << ctxPtrPtr; #ifndef Q_OS_SYMBIAN qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size(); #endif @@ -526,6 +548,7 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, void QGLWindowSurface::beginPaint(const QRegion &) { + d_ptr->did_paint = true; updateGeometry(); if (!context()) @@ -542,8 +565,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) @@ -607,8 +628,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); +#if !defined(Q_WS_QPA) if (!geometry().isValid()) return; +#else + if (!size().isValid()) + return; +#endif // Needed to support native child-widgets... hijackWindow(parent); @@ -842,12 +868,19 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } +#if !defined(Q_WS_QPA) void QGLWindowSurface::setGeometry(const QRect &rect) { QWindowSurface::setGeometry(rect); d_ptr->geometry_updated = true; } - +#else +void QGLWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + d_ptr->geometry_updated = true; +} +#endif void QGLWindowSurface::updateGeometry() { if (!d_ptr->geometry_updated) @@ -947,7 +980,7 @@ void QGLWindowSurface::updateGeometry() { } } -#if !defined(QT_OPENGL_ES_2) +#if !defined(QT_OPENGL_ES_2) && !defined(Q_WS_QPA) //QPA doesn't support pixelbuffers if (d_ptr->destructive_swap_buffers && (d_ptr->pb || !d_ptr->tried_pb)) { d_ptr->tried_pb = true; @@ -986,7 +1019,7 @@ void QGLWindowSurface::updateGeometry() { d_ptr->pb = 0; } } -#endif // !defined(QT_OPENGL_ES_2) +#endif // !defined(QT_OPENGL_ES_2) !defined(Q_WS_QPA) ctx->makeCurrent(); @@ -1133,6 +1166,11 @@ QImage *QGLWindowSurface::buffer(const QWidget *widget) return &d_ptr->buffers.last(); } +bool QGLWindowSurface::hasPartialUpdateSupport() const +{ + return d_ptr->partialUpdateSupport; +} + QT_END_NAMESPACE |