From eeca1aee72a69584aa20bdb9f5c4e48d7e3cbc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 25 Mar 2011 18:06:33 +0100 Subject: Fixed underline offset after raster coordinate system change. This avoids the double-thickness lines at low point sizes which were caused by a line just barely straddling two pixels. Reviewed-by: Jens Bache-Wiig --- src/gui/painting/qpainter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 14fb772..638f4ca 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6468,7 +6468,8 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to // the text above it. - const qreal underlinePos = pos.y() + qCeil(underlineOffset); + const qreal aliasedCoordinateDelta = 0.5 - 0.015625; + const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta; if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); -- cgit v0.12 From 269b61dd08b7e37445f40e3a1d0854bcf85f445b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 29 Mar 2011 11:07:49 +0200 Subject: Added preserved contents property to QWindowSurface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we used hasPartialUpdateSupport() to deduce whether the window surface's contents are preserved when flush is called or not, but that limits us from fully supporting platforms which might allow partial updates even though the surface contents aren't preserved on flush. If hasPreservedContents() returns false, that means a flush of a region is never allowed without first painting to that region. If hasPartialUpdateSupport() returns false, the whole window surface must always be painted whenever an update is requested. Note that hasPreservedContents() will typically imply hasPartialUpdateSupport(), but not vice versa. Reviewed-by: Bjørn Erik Nilsen --- src/gui/painting/qbackingstore.cpp | 4 ++-- src/gui/painting/qwindowsurface.cpp | 10 +++++++++ src/gui/painting/qwindowsurface_p.h | 1 + src/opengl/qwindowsurface_gl.cpp | 43 +++++++++++++++---------------------- src/opengl/qwindowsurface_gl_p.h | 1 + 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index e5d8abc..a06a121 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -1143,9 +1143,9 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg return; } - // If there's no partial update support we always need + // If there's no preserved contents support we always need // to do a full repaint before flushing - if (!windowSurface->hasPartialUpdateSupport()) + if (!windowSurface->hasPreservedContents()) fullUpdatePending = true; // Nothing to repaint. diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 9b71818..050805e 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -332,6 +332,16 @@ 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 +{ + return hasPartialUpdateSupport(); +} + #ifdef Q_WS_QPA #define Q_EXPORT_SCROLLRECT Q_GUI_EXPORT #else diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 4a2775f..95b2ee4 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -102,6 +102,7 @@ public: virtual bool hasStaticContentsSupport() const; virtual bool hasPartialUpdateSupport() const; + virtual bool hasPreservedContents() const; void setStaticContents(const QRegion ®ion); QRegion staticContents() const; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index eae1c9b..4682d0d 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -338,7 +338,7 @@ struct QGLWindowSurfacePrivate QGLWindowSurfaceGLPaintDevice glDevice; QGLWindowSurface* q_ptr; - bool partialUpdateSupport; + bool swap_region_support; }; QGLFormat QGLWindowSurface::surfaceFormat; @@ -391,7 +391,7 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->q_ptr = this; d_ptr->geometry_updated = false; d_ptr->did_paint = false; - d_ptr->partialUpdateSupport = false; + d_ptr->swap_region_support = false; } QGLWindowSurface::~QGLWindowSurface() @@ -491,22 +491,10 @@ 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) != 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 - , EGL_SWAP_BEHAVIOR, &swapBehavior)) { - swapBehaviourPreserved = (swapBehavior == EGL_BUFFER_PRESERVED); - } - } - if (!swapBehaviourPreserved && !haveNOKSwapRegion) - d_ptr->partialUpdateSupport = false; // Force full-screen updates - else - d_ptr->partialUpdateSupport = true; -#else - d_ptr->partialUpdateSupport = false; + d_ptr->destructive_swap_buffers = !swapBehaviourPreserved; + + d_ptr->swap_region_support = haveNOKSwapRegion; #endif widgetPrivate->extraData()->glContext = ctx; @@ -622,7 +610,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & // mistake to call swapBuffers if nothing was painted unless // EGL_BUFFER_PRESERVED is set. This check protects the flush func from // being executed if it's for nothing. - if (!hasPartialUpdateSupport() && !d_ptr->did_paint) + if (!d_ptr->destructive_swap_buffers && !d_ptr->did_paint) return; QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); @@ -698,12 +686,12 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } #endif bool doingPartialUpdate = false; - if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AutomaticSwap) - doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2; - else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysFullSwap) - doingPartialUpdate = false; - else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysPartialSwap) - doingPartialUpdate = hasPartialUpdateSupport(); + if (d_ptr->swap_region_support) { + if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AutomaticSwap) + doingPartialUpdate = br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2; + else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysPartialSwap) + doingPartialUpdate = true; + } QGLContext *ctx = reinterpret_cast(parent->d_func()->extraData()->glContext); if (widget != window()) { @@ -1168,10 +1156,13 @@ QImage *QGLWindowSurface::buffer(const QWidget *widget) bool QGLWindowSurface::hasPartialUpdateSupport() const { - return d_ptr->partialUpdateSupport; + return !d_ptr->destructive_swap_buffers || d_ptr->swap_region_support; } - +bool QGLWindowSurface::hasPreservedContents() const +{ + return !d_ptr->destructive_swap_buffers; +} QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index e1689bf..cabb35a 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -109,6 +109,7 @@ public: QImage *buffer(const QWidget *widget); bool hasPartialUpdateSupport() const; + bool hasPreservedContents() const; QGLContext *context() const; -- cgit v0.12 From a73af692412630e9a25ae1ddb403413f3d8a1de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 29 Mar 2011 11:09:39 +0200 Subject: Added WindowSurfaceFeature enum to QWindowSurface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/gui/painting/qbackingstore.cpp | 6 +++--- src/gui/painting/qbackingstore_p.h | 3 +-- src/gui/painting/qgraphicssystem_runtime.cpp | 9 ++------- src/gui/painting/qgraphicssystem_runtime_p.h | 3 +-- src/gui/painting/qwindowsurface.cpp | 21 +++------------------ src/gui/painting/qwindowsurface_p.h | 20 +++++++++++++++++--- src/gui/painting/qwindowsurface_raster.cpp | 5 ++--- src/gui/painting/qwindowsurface_raster_p.h | 2 +- src/gui/painting/qwindowsurface_s60.cpp | 4 ++-- src/gui/painting/qwindowsurface_s60_p.h | 2 +- src/gui/painting/qwindowsurface_x11.cpp | 9 ++++++--- src/gui/painting/qwindowsurface_x11_p.h | 3 ++- src/opengl/qwindowsurface_gl.cpp | 14 +++++++------- src/opengl/qwindowsurface_gl_p.h | 3 +-- src/openvg/qwindowsurface_vg.cpp | 7 +++++-- src/openvg/qwindowsurface_vg_p.h | 2 +- 16 files changed, 55 insertions(+), 58 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 m_windowSurface; QScopedPointer 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 ®ion) { 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 ®ion); 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; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 4682d0d..3815f7b 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -1154,14 +1154,14 @@ QImage *QGLWindowSurface::buffer(const QWidget *widget) return &d_ptr->buffers.last(); } -bool QGLWindowSurface::hasPartialUpdateSupport() const +QWindowSurface::WindowSurfaceFeatures QGLWindowSurface::features() const { - return !d_ptr->destructive_swap_buffers || d_ptr->swap_region_support; -} - -bool QGLWindowSurface::hasPreservedContents() const -{ - return !d_ptr->destructive_swap_buffers; + WindowSurfaceFeatures features = 0; + if (!d_ptr->destructive_swap_buffers || d_ptr->swap_region_support) + features |= PartialUpdates; + if (!d_ptr->destructive_swap_buffers) + features |= PreservedContents; + return features; } QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index cabb35a..4ad8339 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -108,8 +108,7 @@ public: QImage *buffer(const QWidget *widget); - bool hasPartialUpdateSupport() const; - bool hasPreservedContents() const; + WindowSurfaceFeatures features() const; QGLContext *context() const; diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp index 6f99de4..eedfea5 100644 --- a/src/openvg/qwindowsurface_vg.cpp +++ b/src/openvg/qwindowsurface_vg.cpp @@ -119,9 +119,12 @@ QPaintEngine *QVGWindowSurface::paintEngine() const return d_ptr->paintEngine(); } -bool QVGWindowSurface::hasStaticContentsSupport() const +QWindowSurface::WindowSurfaceFeatures QVGWindowSurface::features() const { - d_ptr->supportsStaticContents(); + WindowSurfaceFeatures features = PartialUpdates | PreservedContents; + if (d_ptr->supportsStaticContents()) + features |= StaticContents; + return features; } int QVGWindowSurface::metric(PaintDeviceMetric met) const diff --git a/src/openvg/qwindowsurface_vg_p.h b/src/openvg/qwindowsurface_vg_p.h index 2d6b4f9..d63d077 100644 --- a/src/openvg/qwindowsurface_vg_p.h +++ b/src/openvg/qwindowsurface_vg_p.h @@ -78,7 +78,7 @@ public: QPaintEngine *paintEngine() const; - bool hasStaticContentsSupport() const; + WindowSurfaceFeatures features() const; protected: int metric(PaintDeviceMetric metric) const; -- cgit v0.12 From afba7910d6805c615c648f938a4fb53a10f0710d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 29 Mar 2011 12:20:40 +0200 Subject: Fixed bad merges in GL windowsurface and get rid of redundant variable. Reviewed-by: Jani Hautakangas --- src/opengl/qwindowsurface_gl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 3815f7b..77f6103 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -492,7 +492,14 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates."; } - d_ptr->destructive_swap_buffers = !swapBehaviourPreserved; + d_ptr->destructive_swap_buffers = true; + 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 + , EGL_SWAP_BEHAVIOR, &swapBehavior)) { + d_ptr->destructive_swap_buffers = (swapBehavior != EGL_BUFFER_PRESERVED); + } + } d_ptr->swap_region_support = haveNOKSwapRegion; #endif @@ -910,7 +917,7 @@ void QGLWindowSurface::updateGeometry() { ctx->d_func()->eglContext->config()); eglGetError(); // Clear error state. - if (hasPartialUpdateSupport()) { + if (!d_ptr->destructive_swap_buffers) { eglSurfaceAttrib(ctx->d_func()->eglContext->display(), ctx->d_func()->eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); -- cgit v0.12 From 0686a6d656641f2ac1fc1cd9710dcf538f8ff5c8 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 30 Mar 2011 14:42:45 +0200 Subject: Fix the painting for widgets painting directly on screen. Reviewed-by: Jiang Jiang --- src/gui/kernel/qcocoaview_mac.mm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 54e7e3e..b5e5d18 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -254,7 +254,10 @@ static int qCocoaViewCount = 0; qt_mac_retain_graphics_context(context); // We use a different graphics system. - if (QApplicationPrivate::graphicsSystem() != 0) { + // + // Widgets that are set to paint on screen, specifically QGLWidget, + // requires the native engine to execute in order to be drawn. + if (QApplicationPrivate::graphicsSystem() != 0 && !qwidget->testAttribute(Qt::WA_PaintOnScreen)) { // Raster engine. if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) { @@ -334,12 +337,6 @@ static int qCocoaViewCount = 0; qwidget->update(qwidget->rect()); qwidgetprivate->syncBackingStore(qwidget->rect()); } - - // Since we don't want to use the native engine, we must exit, however - // widgets that are set to paint on screen, specifically QGLWidget, - // requires the following code to execute in order to be drawn. - if (!qwidget->testAttribute(Qt::WA_PaintOnScreen)) - return; } // Native engine. -- cgit v0.12 From ecb77c6376202c12ccb0f3683a6c96a60c2c951e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 15:20:06 +0200 Subject: Revert "Fixed underline offset after raster coordinate system change." Temporarily revert commit eeca1aee72a69584aa20bdb9f5c4e48d7e3cbc16, which seemed to cause auto-test failures on Windows 7. --- src/gui/painting/qpainter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 638f4ca..14fb772 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6468,8 +6468,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to // the text above it. - const qreal aliasedCoordinateDelta = 0.5 - 0.015625; - const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta; + const qreal underlinePos = pos.y() + qCeil(underlineOffset); if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); -- cgit v0.12 From 918b0fbd8673d3d6d74c655207e9b1688357254b Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 29 Mar 2011 16:31:40 +0200 Subject: Remove Font Smoothing hack for OS X It only affects text rendering with static text/QTextLayout, rendering to images is not affected. Task-number: QTBUG-18048 Reviewed-by: Eskil --- src/declarative/util/qdeclarativeview.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 1b50a56..421cd89 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -72,7 +72,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) -extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; class QDeclarativeScene : public QGraphicsScene { @@ -707,14 +706,7 @@ void QDeclarativeView::paintEvent(QPaintEvent *event) if (frameRateDebug()) time = d->frameTimer.restart(); -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif QGraphicsView::paintEvent(event); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting); -- cgit v0.12 From b92a31da01ee50fed4b10282e79f812167faf659 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 30 Mar 2011 14:55:34 +0200 Subject: Fix horizontal centered text drawing without word wrap In this case we can't use line width to align the text, we have to use the rectangle width given in QPainter::drawText for alignment instead. Reviewed-by: Eskil --- src/gui/painting/qpainter.cpp | 17 ++++++++++++----- src/gui/text/qtextengine.cpp | 16 ++++++++++++++++ src/gui/text/qtextengine_p.h | 1 + src/gui/text/qtextlayout.cpp | 19 +------------------ 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 14fb772..64ef549 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -8149,10 +8149,6 @@ start_lengthVariant: engine.option.setTextDirection(layout_direction); if (tf & Qt::AlignJustify) engine.option.setAlignment(Qt::AlignJustify); - else if (tf & Qt::AlignRight) - engine.option.setAlignment(Qt::AlignRight); - else if (tf & Qt::AlignHCenter) - engine.option.setAlignment(Qt::AlignHCenter); else engine.option.setAlignment(Qt::AlignLeft); // do not do alignment twice @@ -8248,7 +8244,18 @@ start_lengthVariant: for (int i = 0; i < textLayout.lineCount(); i++) { QTextLine line = textLayout.lineAt(i); - line.draw(painter, QPointF(r.x(), r.y() + yoff)); + + qreal advance = line.horizontalAdvance(); + xoff = 0; + if (tf & Qt::AlignRight) { + QTextEngine *eng = textLayout.engine(); + xoff = r.width() - advance - + eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal(); + } + else if (tf & Qt::AlignHCenter) + xoff = (r.width() - advance) / 2; + + line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff)); } if (restore) { diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a63fdbf..6aa333c 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2725,6 +2725,22 @@ void QTextEngine::resolveAdditionalFormats() const specialData->resolvedFormatIndices = indices; } +QFixed QTextEngine::leadingSpaceWidth(const QScriptLine &line) +{ + if (!line.hasTrailingSpaces + || (option.flags() & QTextOption::IncludeTrailingSpaces) + || !isRightToLeft()) + return QFixed(); + + int pos = line.length; + const HB_CharAttributes *attributes = this->attributes(); + if (!attributes) + return QFixed(); + while (pos > 0 && attributes[line.from + pos - 1].whiteSpace) + --pos; + return width(line.from + pos, line.length - pos); +} + QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f) : QTextEngine(string, f), _layoutData(string, _memory, MemSize) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 50d1ff8..366c5c3 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -609,6 +609,7 @@ public: QString elidedText(Qt::TextElideMode mode, const QFixed &width, int flags = 0) const; void shapeLine(const QScriptLine &line); + QFixed leadingSpaceWidth(const QScriptLine &line); private: void setBoundary(int strPos) const; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 8eff7d2..afe6949 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -66,23 +66,6 @@ QT_BEGIN_NAMESPACE #define SuppressText 0x5012 #define SuppressBackground 0x513 -static inline QFixed leadingSpaceWidth(QTextEngine *eng, const QScriptLine &line) -{ - if (!line.hasTrailingSpaces - || (eng->option.flags() & QTextOption::IncludeTrailingSpaces) - || !(eng->option.alignment() & Qt::AlignRight) - || !eng->isRightToLeft()) - return QFixed(); - - int pos = line.length; - const HB_CharAttributes *attributes = eng->attributes(); - if (!attributes) - return QFixed(); - while (pos > 0 && attributes[line.from + pos - 1].whiteSpace) - --pos; - return eng->width(line.from + pos, line.length - pos); -} - static QFixed alignLine(QTextEngine *eng, const QScriptLine &line) { QFixed x = 0; @@ -93,7 +76,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line) if (align & Qt::AlignJustify && eng->isRightToLeft()) align = Qt::AlignRight; if (align & Qt::AlignRight) - x = line.width - (line.textAdvance + leadingSpaceWidth(eng, line)); + x = line.width - (line.textAdvance + eng->leadingSpaceWidth(line)); else if (align & Qt::AlignHCenter) x = (line.width - line.textAdvance)/2; } -- cgit v0.12 From 8abc3cd80fd55c588faffb067ab51feb4b9b6fc5 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 31 Mar 2011 08:52:08 +0400 Subject: QWS: fix the software/hardware cursor switcher because of typo, this never worked before. drop the meaningless local qt_sw_cursor variable and use the correct application-wide qws_sw_cursor one Merge-request: 2587 Reviewed-by: Harald Fernengel --- src/gui/embedded/qscreen_qws.cpp | 3 --- src/gui/embedded/qscreen_qws.h | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index e207ed1..90561fd 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE // #define QT_USE_MEMCPY_DUFF #ifndef QT_NO_QWS_CURSOR -bool qt_sw_cursor=false; Q_GUI_EXPORT QScreenCursor * qt_screencursor = 0; #endif Q_GUI_EXPORT QScreen * qt_screen = 0; @@ -119,8 +118,6 @@ ClearCacheFunc QScreen::clearCacheFunc = 0; Returns a pointer to the application's unique screen cursor. */ -extern bool qws_sw_cursor; - /*! Constructs a screen cursor */ diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h index 17ffbbb..85c775e 100644 --- a/src/gui/embedded/qscreen_qws.h +++ b/src/gui/embedded/qscreen_qws.h @@ -130,7 +130,7 @@ const int SourcePixmap=1; class QScreenCursor; extern QScreenCursor *qt_screencursor; -extern bool qt_sw_cursor; +extern bool qws_sw_cursor; class Q_GUI_EXPORT QScreenCursor { @@ -145,7 +145,7 @@ public: bool supportsAlphaCursor() const { return supportsAlpha; } - static bool enabled() { return qt_sw_cursor; } + static bool enabled() { return qws_sw_cursor; } QRect boundingRect() const { return QRect(pos - hotspot, size); } QImage image() const { return cursor; } -- cgit v0.12 From a538389b52630ec53734695b8d422c5ec124b0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Ky=C3=B6stil=C3=A4?= Date: Thu, 31 Mar 2011 14:04:47 +0200 Subject: opengl2: Make maximum cached glyph size configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the DPI of displays continues to rise, especially on mobile devices, the maximum glyph size of 64 pixels for the glyph cache has become a limitation. This problem is made worse by the fact that when the maximum glyph size is exceeded, the OpenGL paint engine falls back to using rasterized geometry for glyph rendering. This does not produce acceptable quality if the OpenGL rendering surface lacks support for multisampling. This patch offers a solution to the problem by making the cached glyph size configurable at build time. This way the limit can be set according to the capabilities of the target hardware. Signed-off-by: Sami Kyöstilä Merge-request: 1131 Reviewed-by: Samuel Rødal --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 6678522..4d1d5dc 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -98,6 +98,10 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; extern bool qt_applefontsmoothing_enabled; #endif +#if !defined(QT_MAX_CACHED_GLYPH_SIZE) +# define QT_MAX_CACHED_GLYPH_SIZE 64 +#endif + Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert); ////////////////////////////////// Private Methods ////////////////////////////////////////// @@ -1473,7 +1477,8 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem // don't try to cache huge fonts or vastly transformed fonts const qreal pixelSize = ti.fontEngine->fontDef.pixelSize; - if (pixelSize * pixelSize * qAbs(det) >= 64 * 64 || det < 0.25f || det > 4.f) + if (pixelSize * pixelSize * qAbs(det) >= QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE || + det < 0.25f || det > 4.f) drawCached = false; QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 -- cgit v0.12