Fix paint artifacts.

Android is using double buffering, so, we need to repaint the bounding
rect of the repaint region, otherwise black holes will appear.

Change-Id: I21f36a6f5f1a6c64b605c0fef3af10dfdc5ec6e2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
BogDan Vatra 2014-02-18 15:35:13 +02:00 committed by The Qt Project
parent ef2527df68
commit 5e05c230af
3 changed files with 32 additions and 33 deletions

View File

@ -54,6 +54,9 @@ QAndroidPlatformRasterWindow::QAndroidPlatformRasterWindow(QWindow *window)
void QAndroidPlatformRasterWindow::repaint(const QRegion &region)
{
if (QAndroidPlatformWindow::parent())
return;
QRect currentGeometry = geometry().translated(mapToGlobal(QPoint(0,0)));
QRect dirtyClient = region.boundingRect();
@ -71,7 +74,7 @@ void QAndroidPlatformRasterWindow::repaint(const QRegion &region)
void QAndroidPlatformRasterWindow::setGeometry(const QRect &rect)
{
m_oldGeometry = geometry();
m_oldGeometry = geometry().translated(mapToGlobal(QPoint(0,0)));;
QAndroidPlatformWindow::setGeometry(rect);
}

View File

@ -197,7 +197,7 @@ void QAndroidPlatformScreen::scheduleUpdate()
void QAndroidPlatformScreen::setDirty(const QRect &rect)
{
QRect intersection = rect.intersected(m_geometry);
m_repaintRegion += intersection;
m_dirtyRect |= intersection;
scheduleUpdate();
}
@ -241,11 +241,9 @@ void QAndroidPlatformScreen::doRedraw()
{
PROFILE_SCOPE;
if (m_repaintRegion.isEmpty())
if (m_dirtyRect.isEmpty())
return;
QVector<QRect> rects = m_repaintRegion.rects();
QMutexLocker lock(&m_surfaceMutex);
if (m_id == -1) {
m_id = QtAndroid::createSurface(this, m_geometry, true);
@ -257,11 +255,10 @@ void QAndroidPlatformScreen::doRedraw()
ANativeWindow_Buffer nativeWindowBuffer;
ARect nativeWindowRect;
QRect br = m_repaintRegion.boundingRect();
nativeWindowRect.top = br.top();
nativeWindowRect.left = br.left();
nativeWindowRect.bottom = br.bottom() + 1; // for some reason that I don't understand the QRect bottom needs to +1 to be the same with ARect bottom
nativeWindowRect.right = br.right() + 1; // same for the right
nativeWindowRect.top = m_dirtyRect.top();
nativeWindowRect.left = m_dirtyRect.left();
nativeWindowRect.bottom = m_dirtyRect.bottom() + 1; // for some reason that I don't understand the QRect bottom needs to +1 to be the same with ARect bottom
nativeWindowRect.right = m_dirtyRect.right() + 1; // same for the right
int ret;
if ((ret = ANativeWindow_lock(m_nativeSurface, &nativeWindowBuffer, &nativeWindowRect)) < 0) {
@ -283,14 +280,14 @@ void QAndroidPlatformScreen::doRedraw()
QPainter compositePainter(&screenImage);
compositePainter.setCompositionMode(QPainter::CompositionMode_Source);
for (int rectIndex = 0; rectIndex < rects.size(); rectIndex++) {
QRegion visibleRegion = rects[rectIndex];
QRegion visibleRegion(m_dirtyRect);
foreach (QAndroidPlatformWindow *window, m_windowStack) {
if (!window->window()->isVisible()
|| !window->isRaster())
continue;
foreach (const QRect &rect, visibleRegion.rects()) {
QVector<QRect> visibleRects = visibleRegion.rects();
foreach (const QRect &rect, visibleRects) {
QRect targetRect = window->geometry();
targetRect &= rect;
@ -308,11 +305,10 @@ void QAndroidPlatformScreen::doRedraw()
foreach (const QRect &rect, visibleRegion.rects()) {
compositePainter.fillRect(rect, QColor(Qt::transparent));
}
}
ret = ANativeWindow_unlockAndPost(m_nativeSurface);
if (ret >= 0)
m_repaintRegion = QRegion();
m_dirtyRect = QRect();
}
QDpi QAndroidPlatformScreen::logicalDpi() const

View File

@ -91,7 +91,7 @@ public slots:
protected:
typedef QList<QAndroidPlatformWindow *> WindowStackType;
WindowStackType m_windowStack;
QRegion m_repaintRegion;
QRect m_dirtyRect;
QTimer m_redrawTimer;
QRect m_geometry;