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:
parent
e5a332ae54
commit
032ab648c4
@ -58,7 +58,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window)
|
QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window)
|
||||||
: QPlatformBackingStore(window),
|
: QPlatformBackingStore(window),
|
||||||
m_hasUnflushedPaintOperations(false)
|
m_needsPosting(false),
|
||||||
|
m_scrolled(false)
|
||||||
{
|
{
|
||||||
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window;
|
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window;
|
||||||
|
|
||||||
@ -85,9 +86,9 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion ®ion, const
|
|||||||
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << this->window();
|
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << this->window();
|
||||||
|
|
||||||
// Sometimes this method is called even though there is nothing to be
|
// Sometimes this method is called even though there is nothing to be
|
||||||
// flushed, for instance, after an expose event directly follows a
|
// flushed (posted in "screen" parlance), for instance, after an expose
|
||||||
// geometry change event.
|
// event directly follows a geometry change event.
|
||||||
if (!m_hasUnflushedPaintOperations)
|
if (!m_needsPosting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QQnxWindow *targetWindow = 0;
|
QQnxWindow *targetWindow = 0;
|
||||||
@ -99,25 +100,11 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion ®ion, const
|
|||||||
// child windows, are performed; conceptually ,child windows have no buffers
|
// child windows, are performed; conceptually ,child windows have no buffers
|
||||||
// (actually they do have a 1x1 placeholder buffer due to libscreen limitations),
|
// (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.
|
// 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
|
m_needsPosting = false;
|
||||||
for (int i = m_scrollOpList.size() - 1; i >= 0; i--) {
|
m_scrolled = false;
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
|
void QQnxRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
|
||||||
@ -134,39 +121,22 @@ bool QQnxRasterBackingStore::scroll(const QRegion &area, int dx, int dy)
|
|||||||
{
|
{
|
||||||
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
|
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
|
||||||
|
|
||||||
// calculate entire region affected by scroll operation (src + dst)
|
m_needsPosting = true;
|
||||||
QRegion totalArea = area.translated(dx, dy);
|
|
||||||
totalArea += area;
|
|
||||||
m_hasUnflushedPaintOperations = true;
|
|
||||||
|
|
||||||
// visit all pending scroll operations
|
if (!m_scrolled) {
|
||||||
for (int i = m_scrollOpList.size() - 1; i >= 0; i--) {
|
platformWindow()->scroll(area, dx, dy, true);
|
||||||
|
m_scrolled = true;
|
||||||
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;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// create new scroll operation
|
|
||||||
m_scrollOpList.append( ScrollOp(totalArea, dx, dy) );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQnxRasterBackingStore::beginPaint(const QRegion ®ion)
|
void QQnxRasterBackingStore::beginPaint(const QRegion ®ion)
|
||||||
{
|
{
|
||||||
Q_UNUSED(region);
|
Q_UNUSED(region);
|
||||||
|
|
||||||
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
|
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
|
||||||
m_hasUnflushedPaintOperations = true;
|
m_needsPosting = true;
|
||||||
|
|
||||||
platformWindow()->adjustBufferSize();
|
platformWindow()->adjustBufferSize();
|
||||||
|
|
||||||
|
@ -64,19 +64,11 @@ public:
|
|||||||
void endPaint();
|
void endPaint();
|
||||||
|
|
||||||
private:
|
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;
|
QQnxRasterWindow *platformWindow() const;
|
||||||
|
|
||||||
QWindow *m_window;
|
QWindow *m_window;
|
||||||
QList<ScrollOp> m_scrollOpList;
|
bool m_needsPosting;
|
||||||
bool m_hasUnflushedPaintOperations;
|
bool m_scrolled;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user