summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-03-29 09:09:39 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-03-29 09:09:39 (GMT)
commita73af692412630e9a25ae1ddb403413f3d8a1de6 (patch)
tree21ba754816f65e1f6077060483ad6dc60a43154c /src/gui
parent269b61dd08b7e37445f40e3a1d0854bcf85f445b (diff)
downloadQt-a73af692412630e9a25ae1ddb403413f3d8a1de6.zip
Qt-a73af692412630e9a25ae1ddb403413f3d8a1de6.tar.gz
Qt-a73af692412630e9a25ae1ddb403413f3d8a1de6.tar.bz2
Added WindowSurfaceFeature enum to QWindowSurface.
Now that we've added hasPreservedContents() it's cleaner to convert the various features to feature flags, which is also more extensible in case more flags are needed in the future. Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qbackingstore.cpp6
-rw-r--r--src/gui/painting/qbackingstore_p.h3
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp9
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h3
-rw-r--r--src/gui/painting/qwindowsurface.cpp21
-rw-r--r--src/gui/painting/qwindowsurface_p.h20
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp5
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp4
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_x11.cpp9
-rw-r--r--src/gui/painting/qwindowsurface_x11_p.h3
12 files changed, 41 insertions, 46 deletions
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index a06a121..42c1c35 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -588,7 +588,7 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up
return;
}
- if (!windowSurface->hasPartialUpdateSupport()) {
+ if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
fullUpdatePending = true;
sendUpdateRequest(tlw, updateImmediately);
return;
@@ -683,7 +683,7 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool upd
return;
}
- if (!windowSurface->hasPartialUpdateSupport()) {
+ if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
fullUpdatePending = true;
sendUpdateRequest(tlw, updateImmediately);
return;
@@ -1145,7 +1145,7 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg
// If there's no preserved contents support we always need
// to do a full repaint before flushing
- if (!windowSurface->hasPreservedContents())
+ if (!windowSurface->hasFeature(QWindowSurface::PreservedContents))
fullUpdatePending = true;
// Nothing to repaint.
diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h
index 39bf66c..05f4bfc 100644
--- a/src/gui/painting/qbackingstore_p.h
+++ b/src/gui/painting/qbackingstore_p.h
@@ -262,8 +262,7 @@ private:
}
inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport()
- && windowSurface->hasPartialUpdateSupport(); }
+ { return !staticWidgets.isEmpty() && windowSurface->hasFeature(QWindowSurface::StaticContents); }
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 46a6f81..d1dd7ef 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -319,14 +319,9 @@ QPoint QRuntimeWindowSurface::offset(const QWidget *widget) const
return m_windowSurface->offset(widget);
}
-bool QRuntimeWindowSurface::hasStaticContentsSupport() const
+QWindowSurface::WindowSurfaceFeatures QRuntimeWindowSurface::features() const
{
- return m_windowSurface->hasStaticContentsSupport();
-}
-
-bool QRuntimeWindowSurface::hasPartialUpdateSupport() const
-{
- return m_windowSurface->hasPartialUpdateSupport();
+ return m_windowSurface->features();
}
QRuntimeGraphicsSystem::QRuntimeGraphicsSystem()
diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h
index 998fa98..26d3777 100644
--- a/src/gui/painting/qgraphicssystem_runtime_p.h
+++ b/src/gui/painting/qgraphicssystem_runtime_p.h
@@ -129,8 +129,7 @@ public:
virtual QPoint offset(const QWidget *widget) const;
- virtual bool hasStaticContentsSupport() const;
- virtual bool hasPartialUpdateSupport() const;
+ virtual WindowSurfaceFeatures features() const;
QScopedPointer<QWindowSurface> m_windowSurface;
QScopedPointer<QWindowSurface> m_pendingWindowSurface;
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index 050805e..0fb9bf7 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -307,11 +307,6 @@ QPoint QWindowSurface::offset(const QWidget *widget) const
window surface.
*/
-bool QWindowSurface::hasStaticContentsSupport() const
-{
- return false;
-}
-
void QWindowSurface::setStaticContents(const QRegion &region)
{
d_ptr->staticContents = region;
@@ -324,22 +319,12 @@ QRegion QWindowSurface::staticContents() const
bool QWindowSurface::hasStaticContents() const
{
- return hasStaticContentsSupport() && !d_ptr->staticContents.isEmpty();
+ return hasFeature(QWindowSurface::StaticContents) && !d_ptr->staticContents.isEmpty();
}
-bool QWindowSurface::hasPartialUpdateSupport() const
-{
- return true;
-}
-
-/*!
- Says whether the window surface's contents are preserved on flush.
- If not, the window surface contents need to be fully repainted before the
- next flush.
-*/
-bool QWindowSurface::hasPreservedContents() const
+QWindowSurface::WindowSurfaceFeatures QWindowSurface::features() const
{
- return hasPartialUpdateSupport();
+ return PartialUpdates | PreservedContents;
}
#ifdef Q_WS_QPA
diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h
index 95b2ee4..a3fea67 100644
--- a/src/gui/painting/qwindowsurface_p.h
+++ b/src/gui/painting/qwindowsurface_p.h
@@ -68,6 +68,14 @@ class QPlatformWindow;
class Q_GUI_EXPORT QWindowSurface
{
public:
+ enum WindowSurfaceFeature {
+ PartialUpdates = 0x00000001, // Supports doing partial updates.
+ PreservedContents = 0x00000002, // Supports doing flush without first doing a repaint.
+ StaticContents = 0x00000004, // Supports having static content regions when being resized.
+ AllFeatures = 0xffffffff // For convenience
+ };
+ Q_DECLARE_FLAGS(WindowSurfaceFeatures, WindowSurfaceFeature)
+
QWindowSurface(QWidget *window, bool setDefaultSurface = true);
virtual ~QWindowSurface();
@@ -100,9 +108,8 @@ public:
virtual QPoint offset(const QWidget *widget) const;
inline QRect rect(const QWidget *widget) const;
- virtual bool hasStaticContentsSupport() const;
- virtual bool hasPartialUpdateSupport() const;
- virtual bool hasPreservedContents() const;
+ bool hasFeature(WindowSurfaceFeature feature) const;
+ virtual WindowSurfaceFeatures features() const;
void setStaticContents(const QRegion &region);
QRegion staticContents() const;
@@ -114,11 +121,18 @@ private:
QWindowSurfacePrivate *d_ptr;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowSurface::WindowSurfaceFeatures)
+
inline QRect QWindowSurface::rect(const QWidget *widget) const
{
return widget->rect().translated(offset(widget));
}
+inline bool QWindowSurface::hasFeature(WindowSurfaceFeature feature) const
+{
+ return (features() & feature) != 0;
+}
+
QT_END_NAMESPACE
#endif // QWINDOWSURFACE_P_H
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index a5c45c0..9860841 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -410,12 +410,11 @@ bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
#endif
}
-bool QRasterWindowSurface::hasStaticContentsSupport() const
+QWindowSurface::WindowSurfaceFeatures QRasterWindowSurface::features() const
{
- return true;
+ return QWindowSurface::AllFeatures;
}
-
void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
{
Q_D(QRasterWindowSurface);
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index 669511d..06abcd3 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -109,7 +109,7 @@ public:
void beginPaint(const QRegion &rgn);
void setGeometry(const QRect &rect);
bool scroll(const QRegion &area, int dx, int dy);
- bool hasStaticContentsSupport() const;
+ WindowSurfaceFeatures features() const;
#ifdef QT_MAC_USE_COCOA
CGContextRef imageContext();
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index 4fa25cb..9fa01ed 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -239,9 +239,9 @@ void QS60WindowSurface::setGeometry(const QRect& rect)
QWindowSurface::setGeometry(rect);
}
-bool QS60WindowSurface::hasStaticContentsSupport() const
+QWindowSurface::WindowSurfaceFeatures QS60WindowSurface::features() const
{
- return true;
+ return QWindowSurface::AllFeatures;
}
CFbsBitmap* QS60WindowSurface::symbianBitmap() const
diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h
index f730c87..25018d8 100644
--- a/src/gui/painting/qwindowsurface_s60_p.h
+++ b/src/gui/painting/qwindowsurface_s60_p.h
@@ -79,7 +79,7 @@ public:
void setGeometry(const QRect &rect);
- bool hasStaticContentsSupport() const;
+ WindowSurfaceFeatures features() const;
CFbsBitmap *symbianBitmap() const;
diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp
index ab4f53e..deb83b4 100644
--- a/src/gui/painting/qwindowsurface_x11.cpp
+++ b/src/gui/painting/qwindowsurface_x11.cpp
@@ -250,13 +250,16 @@ QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
return px;
}
-bool QX11WindowSurface::hasStaticContentsSupport() const
+QWindowSurface::WindowSurfaceFeatures QX11WindowSurface::features() const
{
+ WindowSurfaceFeatures features = QWindowSurface::PartialUpdates | QWindowSurface::PreservedContents;
#ifndef QT_NO_XRENDER
- return !d_ptr->translucentBackground;
+ if (!d_ptr->translucentBackground)
+ features |= QWindowSurface::StaticContents;
#else
- return true;
+ features |= QWindowSurface::StaticContents;
#endif
+ return features;
}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_x11_p.h b/src/gui/painting/qwindowsurface_x11_p.h
index d5179dd..df76f98 100644
--- a/src/gui/painting/qwindowsurface_x11_p.h
+++ b/src/gui/painting/qwindowsurface_x11_p.h
@@ -80,7 +80,8 @@ public:
bool scroll(const QRegion &area, int dx, int dy);
QPixmap grabWidget(const QWidget *widget,
const QRect& rectangle = QRect()) const;
- bool hasStaticContentsSupport() const;
+ WindowSurfaceFeatures features() const;
+
private:
QX11WindowSurfacePrivate *d_ptr;
GC gc;