From fa175f7c09e6e664f347ac9804b1a7db1d997ef2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 16 Apr 2010 10:56:38 +0200 Subject: QScrollArea: Excessive scrolling in focusNextPrevChild() We were scrolling horizontally even though the widget already fit the visible area horizontally. And conversely for vertical scrolling. Improves commit f1e92b2fdf6b6fd8aca0d05176c647dd68e21baa. Reviewed-by: Thierry Task-number: QTBUG-9425 --- src/gui/widgets/qscrollarea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qscrollarea.cpp b/src/gui/widgets/qscrollarea.cpp index 6b81d9f..38e799e 100644 --- a/src/gui/widgets/qscrollarea.cpp +++ b/src/gui/widgets/qscrollarea.cpp @@ -482,14 +482,14 @@ void QScrollArea::ensureWidgetVisible(QWidget *childWidget, int xmargin, int yma d->hbar->setValue(focusRect.center().x() - d->viewport->width() / 2); else if (focusRect.right() > visibleRect.right()) d->hbar->setValue(focusRect.right() - d->viewport->width()); - else + else if (focusRect.left() < visibleRect.left()) d->hbar->setValue(focusRect.left()); if (focusRect.height() > visibleRect.height()) d->vbar->setValue(focusRect.center().y() - d->viewport->height() / 2); else if (focusRect.bottom() > visibleRect.bottom()) d->vbar->setValue(focusRect.bottom() - d->viewport->height()); - else + else if (focusRect.top() < visibleRect.top()) d->vbar->setValue(focusRect.top()); } -- cgit v0.12 From 5480e3b68da98253ae6ec58bd0db0075225a4e22 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 15 Apr 2010 14:10:50 +0200 Subject: Cleanup & remove unused function overloads from QEgl* APIs This should make stubbing out these APIs slightly easier. Reviewed-By: TrustMe --- src/gui/egl/qegl.cpp | 58 ------------------------------------- src/gui/egl/qegl_p.h | 5 +--- src/gui/egl/qeglcontext_p.h | 6 ---- src/gui/egl/qeglproperties.cpp | 14 --------- src/gui/egl/qeglproperties_p.h | 2 -- src/opengl/qgl_egl.cpp | 2 +- src/opengl/qglpixelbuffer_egl.cpp | 4 +-- src/openvg/qwindowsurface_vgegl.cpp | 21 ++++---------- 8 files changed, 10 insertions(+), 102 deletions(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 0fe5cbe..bf9f530 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -484,42 +484,6 @@ bool QEglContext::swapBuffers(EGLSurface surface) return ok; } -// Wait for native rendering operations to complete before starting -// to use OpenGL/OpenVG operations. -void QEglContext::waitNative() -{ -#ifdef EGL_CORE_NATIVE_ENGINE - eglWaitNative(EGL_CORE_NATIVE_ENGINE); -#endif -} - -// Wait for client OpenGL/OpenVG operations to complete before -// using native rendering operations. -void QEglContext::waitClient() -{ -#ifdef EGL_OPENGL_ES_API - if (apiType == QEgl::OpenGL) { - eglBindAPI(EGL_OPENGL_ES_API); - eglWaitClient(); - } -#else - if (apiType == QEgl::OpenGL) - eglWaitGL(); -#endif -#ifdef EGL_OPENVG_API - if (apiType == QEgl::OpenVG) { - eglBindAPI(EGL_OPENVG_API); - eglWaitClient(); - } -#endif -} - -// Query the value of a configuration attribute. -bool QEglContext::configAttrib(int name, EGLint *value) const -{ - return eglGetConfigAttrib(QEgl::display(), cfg, name, value); -} - int QEglContext::configAttrib(int name) const { EGLint value; @@ -530,12 +494,6 @@ int QEglContext::configAttrib(int name) const return EGL_DONT_CARE; } -QEglProperties QEglContext::configProperties() const -{ - return QEglProperties(config()); -} - - typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR); @@ -673,22 +631,6 @@ QString QEgl::errorString(EGLint code) } } -QString QEgl::errorString() -{ - return errorString(error()); -} - -void QEgl::clearError() -{ - eglGetError(); -} - -EGLint QEgl::error() -{ - return eglGetError(); -} - - // Dump all of the EGL configurations supported by the system. void QEgl::dumpAllConfigs() { diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 6345d5d..83bdb5e 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -182,10 +182,7 @@ namespace QEgl { Q_GUI_EXPORT void dumpAllConfigs(); - Q_GUI_EXPORT void clearError(); - Q_GUI_EXPORT EGLint error(); - Q_GUI_EXPORT QString errorString(EGLint code); - Q_GUI_EXPORT QString errorString(); + Q_GUI_EXPORT QString errorString(EGLint code = eglGetError()); Q_GUI_EXPORT QString extensions(); Q_GUI_EXPORT bool hasExtension(const char* extensionName); diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index 7eec7eb..ccde00d 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -85,10 +85,6 @@ public: bool lazyDoneCurrent(); bool swapBuffers(EGLSurface surface); - void waitNative(); - void waitClient(); - - bool configAttrib(int name, EGLint *value) const; int configAttrib(int name) const; EGLContext context() const { return ctx; } @@ -99,8 +95,6 @@ public: EGLConfig config() const { return cfg; } void setConfig(EGLConfig config) { cfg = config; } - QEglProperties configProperties() const; - private: QEgl::API apiType; EGLContext ctx; diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index b34d2c3..5543547 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -292,20 +292,6 @@ static void addTag(QString& str, const QString& tag) str += tag; } -void QEglProperties::dumpAllConfigs() -{ - EGLint count = 0; - eglGetConfigs(QEgl::display(), 0, 0, &count); - if (count < 1) - return; - - EGLConfig *configs = new EGLConfig [count]; - eglGetConfigs(QEgl::display(), configs, count, &count); - for (EGLint index = 0; index < count; ++index) - qWarning() << QEglProperties(configs[index]).toString(); - delete [] configs; -} - // Convert a property list to a string suitable for debug output. QString QEglProperties::toString() const { diff --git a/src/gui/egl/qeglproperties_p.h b/src/gui/egl/qeglproperties_p.h index eebcf72..b1f9642 100644 --- a/src/gui/egl/qeglproperties_p.h +++ b/src/gui/egl/qeglproperties_p.h @@ -90,8 +90,6 @@ public: QString toString() const; - static void dumpAllConfigs(); - private: QVarLengthArray props; }; diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 822c9f6..0fbbbf9 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -147,7 +147,7 @@ void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) // 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. - QEgl::clearError(); + eglGetError(); } bool QGLFormat::hasOpenGL() diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index db9e754..0b94f5a 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -75,9 +75,9 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge ctx->setConfig(shareContext->config()); #if QGL_RENDER_TEXTURE EGLint value = EGL_FALSE; - if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA, &value) && value) + if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA) == EGL_TRUE) textureFormat = EGL_TEXTURE_RGBA; - else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB, &value) && value) + else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB) == EGL_TRUE) textureFormat = EGL_TEXTURE_RGB; #endif } else { diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 13ae807..7850a5b 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -71,18 +71,13 @@ VGImageFormat qt_vg_config_to_vg_format(QEglContext *context) QImage::Format qt_vg_config_to_image_format(QEglContext *context) { - EGLint red = 0; - EGLint green = 0; - EGLint blue = 0; - EGLint alpha = 0; - context->configAttrib(EGL_RED_SIZE, &red); - context->configAttrib(EGL_GREEN_SIZE, &green); - context->configAttrib(EGL_BLUE_SIZE, &blue); - context->configAttrib(EGL_ALPHA_SIZE, &alpha); + EGLint red = context->configAttrib(EGL_RED_SIZE); + EGLint green = context->configAttrib(EGL_GREEN_SIZE); + EGLint blue = context->configAttrib(EGL_BLUE_SIZE); + EGLint alpha = context->configAttrib(EGL_ALPHA_SIZE); QImage::Format argbFormat; #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - EGLint type = 0; - context->configAttrib(EGL_SURFACE_TYPE, &type); + EGLint type = context->configAttrib(EGL_SURFACE_TYPE); if ((type & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0) argbFormat = QImage::Format_ARGB32_Premultiplied; else @@ -210,11 +205,7 @@ void qt_vg_unregister_pixmap(QVGPixmapData *pd) static bool isPremultipliedContext(const QEglContext *context) { - EGLint value = 0; - if (context->configAttrib(EGL_SURFACE_TYPE, &value)) - return (value & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0; - else - return false; + return context->configAttrib(EGL_SURFACE_TYPE) & EGL_VG_ALPHA_FORMAT_PRE_BIT; } #endif -- cgit v0.12 From 74f28819d985984170964d12d8f527034db93017 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 16 Apr 2010 11:50:55 +0200 Subject: Set EGL_SWAP_BEHAVIOR to EGL_BUFFER_PRESERVED for regular QWidgets QGLWidgets are assumed to be buffer destroyed, however regular QWidgets assume they can to partial updates and thus need the preserved swap behaviour. Reviewed-By: Trond Task-number: QTBUG-9554 --- src/gui/egl/qeglproperties.cpp | 3 +++ src/opengl/qgl_x11egl.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index 5543547..3638de5 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -241,6 +241,9 @@ void QEglProperties::setRenderableType(QEgl::API api) // reductions in complexity are possible. bool QEglProperties::reduceConfiguration() { + if (value(EGL_SWAP_BEHAVIOR) != EGL_DONT_CARE) + removeValue(EGL_SWAP_BEHAVIOR); + #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't // find a config which supports pre-multiplied formats, remove the flag on the surface type: diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 6f210ce..d67a3ea 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -199,6 +199,10 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) configProps.setRenderableType(QEgl::OpenGL); qt_eglproperties_set_glformat(configProps, d->glFormat); + // Set buffer preserved for regular QWidgets, QGLWidgets are ok with either preserved or destroyed: + if ((devType == QInternal::Widget) && qobject_cast(static_cast(device())) == 0) + configProps.setValue(EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + if (!d->eglContext->chooseConfig(configProps, QEgl::BestPixelFormat)) { delete d->eglContext; d->eglContext = 0; -- cgit v0.12 From 8ebcd4db8d57b7e90ec86c9290682ee9c2e576b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 16 Apr 2010 14:52:05 +0200 Subject: Some QWindowSurface implementations might implement flush as a buffer flip. Such window surfaces therefore destroy the contents during flush. In order to render correctly on these surfaces, any update, no matter how small, needs to trigger the entire window to be redrawn. Auto test included. Task-number: Relates to QTBUG-9978 Reviewed-by: tom --- src/gui/painting/qbackingstore.cpp | 70 +++++++++++++++++------- src/gui/painting/qbackingstore_p.h | 4 +- src/gui/painting/qwindowsurface.cpp | 28 +++++++++- src/gui/painting/qwindowsurface_p.h | 2 + tests/auto/qwindowsurface/tst_qwindowsurface.cpp | 48 ++++++++++++++++ 5 files changed, 128 insertions(+), 24 deletions(-) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 8de9eaa..f9cd59b 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -263,7 +263,7 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi { const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft())); const QRect tlwRect(QRect(pos, rect.size())); - if (dirty.intersects(tlwRect)) + if (fullUpdatePending || dirty.intersects(tlwRect)) return false; // We don't want to scroll junk. return windowSurface->scroll(tlwRect, dx, dy); } @@ -402,7 +402,7 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const const bool widgetDirty = widget && widget != tlw; const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(windowSurface->geometry()); - if (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size()) { + if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) { if (widgetDirty) { const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size()); const QPoint offset(widget->mapTo(tlw, QPoint())); @@ -555,6 +555,18 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up return; } + if (fullUpdatePending) { + if (updateImmediately) + sendUpdateRequest(tlw, updateImmediately); + return; + } + + if (!windowSurface->hasPartialUpdateSupport()) { + fullUpdatePending = true; + sendUpdateRequest(tlw, updateImmediately); + return; + } + const QPoint offset = widget->mapTo(tlw, QPoint()); const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect()); if (qt_region_strictContains(dirty, widgetRect.translated(offset))) { @@ -638,6 +650,18 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool upd return; } + if (fullUpdatePending) { + if (updateImmediately) + sendUpdateRequest(tlw, updateImmediately); + return; + } + + if (!windowSurface->hasPartialUpdateSupport()) { + fullUpdatePending = true; + sendUpdateRequest(tlw, updateImmediately); + return; + } + const QRect widgetRect = widget->d_func()->effectiveRectFor(rect); const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint()))); if (qt_region_strictContains(dirty, translatedRect)) { @@ -833,6 +857,7 @@ void QWidgetBackingStore::updateLists(QWidget *cur) QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel) : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false) + , fullUpdatePending(0) { windowSurface = tlw->windowSurface(); if (!windowSurface) @@ -1122,6 +1147,7 @@ void QWidgetBackingStore::sync() for (int i = 0; i < dirtyWidgets.size(); ++i) resetWidget(dirtyWidgets.at(i)); dirtyWidgets.clear(); + fullUpdatePending = false; } return; } @@ -1132,28 +1158,28 @@ void QWidgetBackingStore::sync() const QRect surfaceGeometry(windowSurface->geometry()); bool repaintAllWidgets = false; - if (inTopLevelResize || surfaceGeometry != tlwRect) { - if ((inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { - if (hasStaticContents()) { - // Repaint existing dirty area and newly visible area. - const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); - const QRegion staticRegion(staticContents(0, clipRect)); - QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height()); - newVisible -= staticRegion; - dirty += newVisible; - windowSurface->setStaticContents(staticRegion); - } else { - // Repaint everything. - dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height()); - for (int i = 0; i < dirtyWidgets.size(); ++i) - resetWidget(dirtyWidgets.at(i)); - dirtyWidgets.clear(); - repaintAllWidgets = true; - } + if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { + if (hasStaticContents()) { + // Repaint existing dirty area and newly visible area. + const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); + const QRegion staticRegion(staticContents(0, clipRect)); + QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height()); + newVisible -= staticRegion; + dirty += newVisible; + windowSurface->setStaticContents(staticRegion); + } else { + // Repaint everything. + dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height()); + for (int i = 0; i < dirtyWidgets.size(); ++i) + resetWidget(dirtyWidgets.at(i)); + dirtyWidgets.clear(); + repaintAllWidgets = true; } - windowSurface->setGeometry(tlwRect); } + if (inTopLevelResize || surfaceGeometry != tlwRect) + windowSurface->setGeometry(tlwRect); + if (updatesDisabled) return; @@ -1212,6 +1238,8 @@ void QWidgetBackingStore::sync() } dirtyWidgets.clear(); + fullUpdatePending = false; + if (toClean.isEmpty()) { // Nothing to repaint. However, we might have newly exposed areas on the // screen if this function was called from sync(QWidget *, QRegion)), so diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h index 02c0f7c..6510b57 100644 --- a/src/gui/painting/qbackingstore_p.h +++ b/src/gui/painting/qbackingstore_p.h @@ -91,6 +91,7 @@ public: inline bool isDirty() const { return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync + && !fullUpdatePending #if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER) && !hasDirtyWindowDecoration() #endif @@ -115,7 +116,8 @@ private: #ifdef Q_BACKINGSTORE_SUBSURFACES QList subSurfaces; #endif - bool hasDirtyFromPreviousSync; + uint hasDirtyFromPreviousSync : 1; + uint fullUpdatePending : 1; QPoint tlwOffset; diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 8bd6344..e18ea3f 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -49,13 +49,19 @@ QT_BEGIN_NAMESPACE class QWindowSurfacePrivate { public: - QWindowSurfacePrivate(QWidget *w) : window(w), staticContentsSupport(false) {} + QWindowSurfacePrivate(QWidget *w) + : window(w) + , staticContentsSupport(0) + , partialUpdateSupport(1) + { + } QWidget *window; QRect geometry; QRegion staticContents; QList bufferImages; - bool staticContentsSupport; + uint staticContentsSupport : 1; + uint partialUpdateSupport : 1; }; /*! @@ -284,6 +290,10 @@ bool QWindowSurface::hasStaticContentsSupport() const void QWindowSurface::setStaticContentsSupport(bool enable) { + if (enable && !d_ptr->partialUpdateSupport) { + qWarning("QWindowSurface::setStaticContentsSupport: static contents support requires partial update support"); + return; + } d_ptr->staticContentsSupport = enable; } @@ -302,6 +312,20 @@ bool QWindowSurface::hasStaticContents() const return d_ptr->staticContentsSupport && !d_ptr->staticContents.isEmpty(); } +bool QWindowSurface::hasPartialUpdateSupport() const +{ + return d_ptr->partialUpdateSupport; +} + +void QWindowSurface::setPartialUpdateSupport(bool enable) +{ + if (!enable && d_ptr->staticContentsSupport) { + qWarning("QWindowSurface::setPartialUpdateSupport: static contents support requires partial update support"); + return; + } + d_ptr->partialUpdateSupport = enable; +} + void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) { // make sure we don't detach diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 0a453af..e6ee5f6 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -90,6 +90,7 @@ public: inline QRect rect(const QWidget *widget) const; bool hasStaticContentsSupport() const; + bool hasPartialUpdateSupport() const; void setStaticContents(const QRegion ®ion); QRegion staticContents() const; @@ -97,6 +98,7 @@ public: protected: bool hasStaticContents() const; void setStaticContentsSupport(bool enable); + void setPartialUpdateSupport(bool enable); private: QWindowSurfacePrivate *d_ptr; diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp index dd985ca..7dde402 100644 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp @@ -66,6 +66,7 @@ private slots: void getSetWindowSurface(); void flushOutsidePaintEvent(); void grabWidget(); + void staticContentsAndPartialUpdateSupport(); }; class MyWindowSurface : public QWindowSurface @@ -81,6 +82,8 @@ public: /* nothing */ } + using QWindowSurface::setStaticContentsSupport; + using QWindowSurface::setPartialUpdateSupport; private: QImage image; }; @@ -280,6 +283,51 @@ void tst_QWindowSurface::grabWidget() QVERIFY(QColor(childInvalidSubImage.pixel(0, 0)) == QColor(Qt::white)); } +void tst_QWindowSurface::staticContentsAndPartialUpdateSupport() +{ + QWidget widget; + MyWindowSurface surface(&widget); + + // Default values. + QVERIFY(surface.hasPartialUpdateSupport()); + QVERIFY(!surface.hasStaticContentsSupport()); + + // Partial: YES, Static: YES + surface.setStaticContentsSupport(true); + QVERIFY(surface.hasPartialUpdateSupport()); + QVERIFY(surface.hasStaticContentsSupport()); + + // Static contents requires support for partial updates. + // We simply ingore bad combinations and spit out a warning. + + // CONFLICT: Partial: NO, Static: YES + QTest::ignoreMessage(QtWarningMsg, "QWindowSurface::setPartialUpdateSupport: static contents support requires partial update support"); + surface.setPartialUpdateSupport(false); + QVERIFY(surface.hasPartialUpdateSupport()); + QVERIFY(surface.hasStaticContentsSupport()); + + // Partial: YES, Static: NO + surface.setStaticContentsSupport(false); + QVERIFY(surface.hasPartialUpdateSupport()); + QVERIFY(!surface.hasStaticContentsSupport()); + + // Partial: NO, Static: NO + surface.setPartialUpdateSupport(false); + QVERIFY(!surface.hasPartialUpdateSupport()); + QVERIFY(!surface.hasStaticContentsSupport()); + + // CONFLICT: Partial: NO, Static: YES + QTest::ignoreMessage(QtWarningMsg, "QWindowSurface::setStaticContentsSupport: static contents support requires partial update support"); + surface.setStaticContentsSupport(true); + QVERIFY(!surface.hasPartialUpdateSupport()); + QVERIFY(!surface.hasStaticContentsSupport()); + + // Partial: YES, Static: NO + surface.setPartialUpdateSupport(true); + QVERIFY(surface.hasPartialUpdateSupport()); + QVERIFY(!surface.hasStaticContentsSupport()); +} + QTEST_MAIN(tst_QWindowSurface) #else // Q_WS_MAC -- cgit v0.12