app_server: fix flickering when drawing background

Fixes #15548.

This change disables immediate drawing of background on expose and makes drawing background a part of the update session. In previous version expose/update separation is incorrect in some cases. For example when view with B_FULL_UPDATE_ON_RESIZE is resized, it will be updated with expose cause, that will trigger flickering. Correct handling should be update on old visible area and expose on area that became visible. If immidiate exposed area erasing is preferred, it need more work to fix. Anyway delayed redrawing cause problems only on slow machine or on slow responding applications, but current master approach cause flickering even on fast machines and on any application that use non-transparent view color.

Multiple expose/update requests also seems not work properly.

Change-Id: Ibd64eb2545ceb1197f1c8bc89043de6f87f11778
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2021
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
This commit is contained in:
X512 2019-12-14 19:24:40 +09:00 committed by Stephan Aßmus
parent 03c13e58de
commit cf4ffd85fd

View File

@ -1740,44 +1740,8 @@ Window::_TriggerContentRedraw(BRegion& dirtyContentRegion)
// put this into the pending dirty region
// to eventually trigger a client redraw
bool wasExpose = fPendingUpdateSession->IsExpose();
BRegion* backgroundClearingRegion = &dirtyContentRegion;
_TransferToUpdateSession(&dirtyContentRegion);
if (fPendingUpdateSession->IsExpose()) {
if (!fContentRegionValid)
_UpdateContentRegion();
if (!wasExpose) {
// there was suddenly added a dirty region
// caused by exposing content, we need to clear
// the entire background
backgroundClearingRegion = &fPendingUpdateSession->DirtyRegion();
}
if (fDrawingEngine->LockParallelAccess()) {
bool copyToFrontEnabled = fDrawingEngine->CopyToFrontEnabled();
fDrawingEngine->SetCopyToFrontEnabled(true);
fDrawingEngine->SuspendAutoSync();
//sCurrentColor.red = rand() % 255;
//sCurrentColor.green = rand() % 255;
//sCurrentColor.blue = rand() % 255;
//sPendingColor.red = rand() % 255;
//sPendingColor.green = rand() % 255;
//sPendingColor.blue = rand() % 255;
//fDrawingEngine->FillRegion(*backgroundClearingRegion, sCurrentColor);
//snooze(10000);
fTopView->Draw(fDrawingEngine, backgroundClearingRegion,
&fContentRegion, true);
fDrawingEngine->Sync();
fDrawingEngine->SetCopyToFrontEnabled(copyToFrontEnabled);
fDrawingEngine->UnlockParallelAccess();
}
}
}
@ -1950,8 +1914,7 @@ Window::BeginUpdate(BPrivate::PortLink& link)
// supress back to front buffer copies in the drawing engine
fDrawingEngine->SetCopyToFrontEnabled(false);
if (!fCurrentUpdateSession->IsExpose()
&& fDrawingEngine->LockParallelAccess()) {
if (fDrawingEngine->LockParallelAccess()) {
fDrawingEngine->SuspendAutoSync();
fTopView->Draw(fDrawingEngine, dirty, &fContentRegion, true);