QNX: Fix widgets scrolling

Qt expects scroll operations to be executed immediately. They cannot be
postponed since Qt may paint on the scrolled area afterwards.
The new code will only use an accelerated scroll operation (screen_blit)
once before the window is posted, because the blit is from the previous
buffer to the current one. Hence an additional scroll operation could
copy outdated pixel data. Additional scroll operations will be handled
by Qt. Performance issues were not perceived with this approach so far.

Task-number: QTBUG-39958
Change-Id: I6d7c3274c5db6a831a169615518fcdb4d926db70
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
This commit is contained in:
Bernd Weimer 2014-06-30 16:42:13 +02:00
parent e5a332ae54
commit 032ab648c4
2 changed files with 19 additions and 57 deletions

View File

@ -58,7 +58,8 @@ QT_BEGIN_NAMESPACE
QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window)
: QPlatformBackingStore(window),
m_hasUnflushedPaintOperations(false)
m_needsPosting(false),
m_scrolled(false)
{
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window;
@ -85,10 +86,10 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << this->window();
// Sometimes this method is called even though there is nothing to be
// flushed, for instance, after an expose event directly follows a
// geometry change event.
if (!m_hasUnflushedPaintOperations)
return;
// flushed (posted in "screen" parlance), for instance, after an expose
// event directly follows a geometry change event.
if (!m_needsPosting)
return;
QQnxWindow *targetWindow = 0;
if (window)
@ -99,25 +100,11 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const
// child windows, are performed; conceptually ,child windows have no buffers
// (actually they do have a 1x1 placeholder buffer due to libscreen limitations),
// since Qt will only draw to the backing store of the top-level window.
if (!targetWindow || targetWindow == platformWindow()) {
if (!targetWindow || targetWindow == platformWindow())
platformWindow()->post(region); // update the display with newly rendered content
// visit all pending scroll operations
for (int i = m_scrollOpList.size() - 1; i >= 0; i--) {
// do the scroll operation
ScrollOp &op = m_scrollOpList[i];
QRegion srcArea = op.totalArea.intersected( op.totalArea.translated(-op.dx, -op.dy) );
platformWindow()->scroll(srcArea, op.dx, op.dy);
}
// clear all pending scroll operations
m_scrollOpList.clear();
// update the display with newly rendered content
platformWindow()->post(region);
}
m_hasUnflushedPaintOperations = false;
m_needsPosting = false;
m_scrolled = false;
}
void QQnxRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
@ -134,31 +121,14 @@ bool QQnxRasterBackingStore::scroll(const QRegion &area, int dx, int dy)
{
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
// calculate entire region affected by scroll operation (src + dst)
QRegion totalArea = area.translated(dx, dy);
totalArea += area;
m_hasUnflushedPaintOperations = true;
m_needsPosting = true;
// visit all pending scroll operations
for (int i = m_scrollOpList.size() - 1; i >= 0; i--) {
ScrollOp &op = m_scrollOpList[i];
if (op.totalArea == totalArea) {
// same area is being scrolled again - update delta
op.dx += dx;
op.dy += dy;
return true;
} else if (op.totalArea.intersects(totalArea)) {
// current scroll overlaps previous scroll but is
// not equal in area - just paint everything
qWarning("QQNX: pending scroll operations overlap but not equal");
return false;
}
if (!m_scrolled) {
platformWindow()->scroll(area, dx, dy, true);
m_scrolled = true;
return true;
}
// create new scroll operation
m_scrollOpList.append( ScrollOp(totalArea, dx, dy) );
return true;
return false;
}
void QQnxRasterBackingStore::beginPaint(const QRegion &region)
@ -166,7 +136,7 @@ void QQnxRasterBackingStore::beginPaint(const QRegion &region)
Q_UNUSED(region);
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
m_hasUnflushedPaintOperations = true;
m_needsPosting = true;
platformWindow()->adjustBufferSize();

View File

@ -64,19 +64,11 @@ public:
void endPaint();
private:
class ScrollOp {
public:
ScrollOp(const QRegion &a, int x, int y) : totalArea(a), dx(x), dy(y) {}
QRegion totalArea;
int dx;
int dy;
};
QQnxRasterWindow *platformWindow() const;
QWindow *m_window;
QList<ScrollOp> m_scrollOpList;
bool m_hasUnflushedPaintOperations;
bool m_needsPosting;
bool m_scrolled;
};
QT_END_NAMESPACE