From f673f4c8273bcdde76b36cb58cb7b5e46a87f1ac Mon Sep 17 00:00:00 2001 From: Armin Berres Date: Wed, 16 Mar 2011 08:23:57 +0100 Subject: Make getters for staticContentsSupport and partialUpdateSupport virtual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When QRuntimeGraphicsSystem is asked for its support for static contents of partial updates it should return the value for the currently running wrapped graphicssystem. As the getters have not been virtual so far this could not be implemented. Additionally the setters have been removed as these values are not supposed to be set from the outside. Only the graphicssystems itself knows what it supports. If the default values should be changed the methods should be overwritten. Merge-request: 1136 Reviewed-by: Samuel Rødal --- src/gui/painting/qbackingstore_p.h | 3 +- src/gui/painting/qgraphicssystem_runtime.cpp | 10 +++++ src/gui/painting/qgraphicssystem_runtime_p.h | 3 ++ src/gui/painting/qunifiedtoolbarsurface_mac.cpp | 1 - src/gui/painting/qwindowsurface.cpp | 28 ++------------ src/gui/painting/qwindowsurface_p.h | 6 +-- src/gui/painting/qwindowsurface_raster.cpp | 6 ++- src/gui/painting/qwindowsurface_raster_p.h | 1 + src/gui/painting/qwindowsurface_s60.cpp | 7 +++- src/gui/painting/qwindowsurface_s60_p.h | 2 + src/gui/painting/qwindowsurface_x11.cpp | 12 ++++-- src/gui/painting/qwindowsurface_x11_p.h | 1 + src/opengl/qwindowsurface_gl.cpp | 14 +++++-- src/opengl/qwindowsurface_gl_p.h | 2 + src/openvg/qwindowsurface_vg.cpp | 6 ++- src/openvg/qwindowsurface_vg_p.h | 2 + src/s60installs/bwins/QtGuiu.def | 2 - src/s60installs/eabi/QtGuiu.def | 2 - tests/auto/qwindowsurface/tst_qwindowsurface.cpp | 47 ------------------------ 19 files changed, 63 insertions(+), 92 deletions(-) diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h index 47387ab..39bf66c 100644 --- a/src/gui/painting/qbackingstore_p.h +++ b/src/gui/painting/qbackingstore_p.h @@ -262,7 +262,8 @@ private: } inline bool hasStaticContents() const - { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport(); } + { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport() + && windowSurface->hasPartialUpdateSupport(); } friend QRegion qt_dirtyRegion(QWidget *); friend class QWidgetPrivate; diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp index 5841d40..93245ef 100644 --- a/src/gui/painting/qgraphicssystem_runtime.cpp +++ b/src/gui/painting/qgraphicssystem_runtime.cpp @@ -319,6 +319,16 @@ QPoint QRuntimeWindowSurface::offset(const QWidget *widget) const return m_windowSurface->offset(widget); } +bool QRuntimeWindowSurface::hasStaticContentsSupport() const +{ + return m_windowSurface->hasStaticContentsSupport(); +} + +bool QRuntimeWindowSurface::hasPartialUpdateSupport() const +{ + return m_windowSurface->hasPartialUpdateSupport(); +} + QRuntimeGraphicsSystem::QRuntimeGraphicsSystem() : m_windowSurfaceDestroyPolicy(DestroyImmediately), m_graphicsSystem(0) diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h index 30b4e3e..998fa98 100644 --- a/src/gui/painting/qgraphicssystem_runtime_p.h +++ b/src/gui/painting/qgraphicssystem_runtime_p.h @@ -129,6 +129,9 @@ public: virtual QPoint offset(const QWidget *widget) const; + virtual bool hasStaticContentsSupport() const; + virtual bool hasPartialUpdateSupport() const; + QScopedPointer m_windowSurface; QScopedPointer m_pendingWindowSurface; diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp index e7434c7..c64f572 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp +++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp @@ -55,7 +55,6 @@ QUnifiedToolbarSurface::QUnifiedToolbarSurface(QWidget *widget) { d_ptr->image = 0; d_ptr->inSetGeometry = false; - setStaticContentsSupport(true); setGeometry(QRect(QPoint(0, 0), QSize(widget->width(), 100))); // FIXME: Fix height. } diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 029b9dc..9b71818 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -52,8 +52,6 @@ class QWindowSurfacePrivate public: QWindowSurfacePrivate(QWidget *w) : window(w) - , staticContentsSupport(0) - , partialUpdateSupport(1) { } @@ -65,8 +63,6 @@ public: #endif //Q_WS_QPA QRegion staticContents; QList bufferImages; - uint staticContentsSupport : 1; - uint partialUpdateSupport : 1; }; /*! @@ -313,16 +309,7 @@ QPoint QWindowSurface::offset(const QWidget *widget) const bool QWindowSurface::hasStaticContentsSupport() const { - return d_ptr->staticContentsSupport; -} - -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; + return false; } void QWindowSurface::setStaticContents(const QRegion ®ion) @@ -337,21 +324,12 @@ QRegion QWindowSurface::staticContents() const bool QWindowSurface::hasStaticContents() const { - return d_ptr->staticContentsSupport && !d_ptr->staticContents.isEmpty(); + return hasStaticContentsSupport() && !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; + return true; } #ifdef Q_WS_QPA diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 62137ef..4a2775f 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -100,16 +100,14 @@ public: virtual QPoint offset(const QWidget *widget) const; inline QRect rect(const QWidget *widget) const; - bool hasStaticContentsSupport() const; - bool hasPartialUpdateSupport() const; + virtual bool hasStaticContentsSupport() const; + virtual bool hasPartialUpdateSupport() const; void setStaticContents(const QRegion ®ion); QRegion staticContents() const; protected: bool hasStaticContents() const; - void setStaticContentsSupport(bool enable); - void setPartialUpdateSupport(bool enable); private: QWindowSurfacePrivate *d_ptr; diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 419518ac..3a5dcc3 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -103,7 +103,6 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa #endif d_ptr->image = 0; d_ptr->inSetGeometry = false; - setStaticContentsSupport(true); } @@ -425,6 +424,11 @@ bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy) #endif } +bool QRasterWindowSurface::hasStaticContentsSupport() const +{ + return true; +} + void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget) { diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h index 903810b..ad57d48 100644 --- a/src/gui/painting/qwindowsurface_raster_p.h +++ b/src/gui/painting/qwindowsurface_raster_p.h @@ -105,6 +105,7 @@ public: void beginPaint(const QRegion &rgn); void setGeometry(const QRect &rect); bool scroll(const QRegion &area, int dx, int dy); + bool hasStaticContentsSupport() const; private: #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 71556d7..3f2247b 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -90,8 +90,6 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget) data->fromSymbianBitmap(bitmap, true); d_ptr->device = QPixmap(data); } - - setStaticContentsSupport(true); } QS60WindowSurface::~QS60WindowSurface() @@ -231,6 +229,11 @@ void QS60WindowSurface::setGeometry(const QRect& rect) QWindowSurface::setGeometry(rect); } +bool QS60WindowSurface::hasStaticContentsSupport() const +{ + return true; +} + CFbsBitmap* QS60WindowSurface::symbianBitmap() const { QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h index d0d4925..f730c87 100644 --- a/src/gui/painting/qwindowsurface_s60_p.h +++ b/src/gui/painting/qwindowsurface_s60_p.h @@ -79,6 +79,8 @@ public: void setGeometry(const QRect &rect); + bool hasStaticContentsSupport() const; + CFbsBitmap *symbianBitmap() const; private: diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp index 2324bc2..ab4f53e 100644 --- a/src/gui/painting/qwindowsurface_x11.cpp +++ b/src/gui/painting/qwindowsurface_x11.cpp @@ -70,9 +70,6 @@ QX11WindowSurface::QX11WindowSurface(QWidget *widget) #ifndef QT_NO_XRENDER d_ptr->translucentBackground = X11->use_xrender && widget->x11Info().depth() == 32; - setStaticContentsSupport(!d_ptr->translucentBackground); -#else - setStaticContentsSupport(true); #endif } @@ -253,4 +250,13 @@ QPixmap QX11WindowSurface::grabWidget(const QWidget *widget, return px; } +bool QX11WindowSurface::hasStaticContentsSupport() const +{ +#ifndef QT_NO_XRENDER + return !d_ptr->translucentBackground; +#else + return true; +#endif +} + QT_END_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_x11_p.h b/src/gui/painting/qwindowsurface_x11_p.h index 88753ea..d5179dd 100644 --- a/src/gui/painting/qwindowsurface_x11_p.h +++ b/src/gui/painting/qwindowsurface_x11_p.h @@ -80,6 +80,7 @@ public: bool scroll(const QRegion &area, int dx, int dy); QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const; + bool hasStaticContentsSupport() const; private: QX11WindowSurfacePrivate *d_ptr; GC gc; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 21b2f09..ea1f765 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -299,6 +299,8 @@ struct QGLWindowSurfacePrivate QList buffers; QGLWindowSurfaceGLPaintDevice glDevice; QGLWindowSurface* q_ptr; + + bool partialUpdateSupport; }; QGLFormat QGLWindowSurface::surfaceFormat; @@ -351,6 +353,7 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->q_ptr = this; d_ptr->geometry_updated = false; d_ptr->did_paint = false; + d_ptr->partialUpdateSupport = false; } QGLWindowSurface::~QGLWindowSurface() @@ -429,11 +432,11 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED && ! haveNOKSwapRegion) - setPartialUpdateSupport(false); // Force full-screen updates + d_ptr->partialUpdateSupport = false; // Force full-screen updates else - setPartialUpdateSupport(true); + d_ptr->partialUpdateSupport = true; #else - setPartialUpdateSupport(false); + d_ptr->partialUpdateSupport = false; #endif widgetPrivate->extraData()->glContext = ctx; @@ -1081,6 +1084,11 @@ QImage *QGLWindowSurface::buffer(const QWidget *widget) return &d_ptr->buffers.last(); } +bool QGLWindowSurface::hasPartialUpdateSupport() const +{ + return d_ptr->partialUpdateSupport; +} + QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 67f9f41..e1689bf 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -108,6 +108,8 @@ public: QImage *buffer(const QWidget *widget); + bool hasPartialUpdateSupport() const; + QGLContext *context() const; static QGLFormat surfaceFormat; diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp index 9ce7f9a..6f99de4 100644 --- a/src/openvg/qwindowsurface_vg.cpp +++ b/src/openvg/qwindowsurface_vg.cpp @@ -57,7 +57,6 @@ QVGWindowSurface::QVGWindowSurface(QWidget *window) { // Create the default type of EGL window surface for windows. d_ptr = new QVGEGLWindowSurfaceDirect(this); - setStaticContentsSupport(d_ptr->supportsStaticContents()); } QVGWindowSurface::QVGWindowSurface @@ -120,6 +119,11 @@ QPaintEngine *QVGWindowSurface::paintEngine() const return d_ptr->paintEngine(); } +bool QVGWindowSurface::hasStaticContentsSupport() const +{ + d_ptr->supportsStaticContents(); +} + int QVGWindowSurface::metric(PaintDeviceMetric met) const { return qt_paint_device_metric(window(), met); diff --git a/src/openvg/qwindowsurface_vg_p.h b/src/openvg/qwindowsurface_vg_p.h index 06b16d0..2d6b4f9 100644 --- a/src/openvg/qwindowsurface_vg_p.h +++ b/src/openvg/qwindowsurface_vg_p.h @@ -78,6 +78,8 @@ public: QPaintEngine *paintEngine() const; + bool hasStaticContentsSupport() const; + protected: int metric(PaintDeviceMetric metric) const; diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index a1f1b50..68cdc9e 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -9875,7 +9875,6 @@ EXPORTS ?setState@QPaintEngineEx@@UAEXPAVQPainterState@@@Z @ 9874 NONAME ; void QPaintEngineEx::setState(class QPainterState *) ?setState@TouchPoint@QTouchEvent@@QAEXV?$QFlags@W4TouchPointState@Qt@@@@@Z @ 9875 NONAME ; void QTouchEvent::TouchPoint::setState(class QFlags) ?setStaticContents@QWindowSurface@@QAEXABVQRegion@@@Z @ 9876 NONAME ; void QWindowSurface::setStaticContents(class QRegion const &) - ?setStaticContentsSupport@QWindowSurface@@IAEX_N@Z @ 9877 NONAME ; void QWindowSurface::setStaticContentsSupport(bool) ?setStatus@QPictureIO@@QAEXH@Z @ 9878 NONAME ; void QPictureIO::setStatus(int) ?setStatusBar@QMainWindow@@QAEXPAVQStatusBar@@@Z @ 9879 NONAME ; void QMainWindow::setStatusBar(class QStatusBar *) ?setStatusTip@QAction@@QAEXABVQString@@@Z @ 9880 NONAME ; void QAction::setStatusTip(class QString const &) @@ -12651,7 +12650,6 @@ EXPORTS ?toImage@QRuntimePixmapData@@UBE?AVQImage@@XZ @ 12650 NONAME ; class QImage QRuntimePixmapData::toImage(void) const ??0QAbstractScrollAreaPrivate@@QAE@XZ @ 12651 NONAME ; QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate(void) ?resizeEvent@QSplitterHandle@@MAEXPAVQResizeEvent@@@Z @ 12652 NONAME ; void QSplitterHandle::resizeEvent(class QResizeEvent *) - ?setPartialUpdateSupport@QWindowSurface@@IAEX_N@Z @ 12653 NONAME ; void QWindowSurface::setPartialUpdateSupport(bool) ?HandleForegroundEventL@QS60MainAppUi@@MAEXH@Z @ 12654 NONAME ; void QS60MainAppUi::HandleForegroundEventL(int) ?curveThreshold@QStrokerOps@@QBEMXZ @ 12655 NONAME ; float QStrokerOps::curveThreshold(void) const ?createTextureData@QImageTextureGlyphCache@@UAEXHH@Z @ 12656 NONAME ; void QImageTextureGlyphCache::createTextureData(int, int) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index ef1d67c..8f4b7cc 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -3164,7 +3164,6 @@ EXPORTS _ZN14QWindowSurface10beginPaintERK7QRegion @ 3163 NONAME _ZN14QWindowSurface11setGeometryERK5QRect @ 3164 NONAME _ZN14QWindowSurface17setStaticContentsERK7QRegion @ 3165 NONAME - _ZN14QWindowSurface24setStaticContentsSupportEb @ 3166 NONAME _ZN14QWindowSurface6bufferEPK7QWidget @ 3167 NONAME _ZN14QWindowSurface6scrollERK7QRegionii @ 3168 NONAME _ZN14QWindowSurface8endPaintERK7QRegion @ 3169 NONAME @@ -11887,7 +11886,6 @@ EXPORTS _ZN14QGraphicsScale13zScaleChangedEv @ 11886 NONAME _ZN14QPaintEngineEx19drawPixmapFragmentsEPKN8QPainter14PixmapFragmentEiRK7QPixmap6QFlagsINS0_18PixmapFragmentHintEE @ 11887 NONAME _ZN14QWidgetPrivate6renderEP12QPaintDeviceRK6QPointRK7QRegion6QFlagsIN7QWidget10RenderFlagEEb @ 11888 NONAME - _ZN14QWindowSurface23setPartialUpdateSupportEb @ 11889 NONAME _ZN15QGraphicsObject12widthChangedEv @ 11890 NONAME _ZN15QGraphicsObject13heightChangedEv @ 11891 NONAME _ZN15QGraphicsObject15childrenChangedEv @ 11892 NONAME diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp index b309917..4e3435e 100644 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp @@ -82,8 +82,6 @@ public: /* nothing */ } - using QWindowSurface::setStaticContentsSupport; - using QWindowSurface::setPartialUpdateSupport; private: QImage image; }; @@ -283,51 +281,6 @@ 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