Browse Source

DiabloUI: Support non-doublebuf HW surfaces

If using a hardware surface without double-buffering, perform
rendering in a single blit to avoid flickering and tearing.
pull/1602/head
Gleb Mazovetskiy 5 years ago committed by Anders Jenbo
parent
commit
92485ed222
  1. 4
      Source/DiabloUI/diabloui.cpp
  2. 13
      Source/DiabloUI/diabloui.h

4
Source/DiabloUI/diabloui.cpp

@ -623,6 +623,8 @@ void LoadBackgroundArt(const char *pszFile, int frames)
fadeValue = 0;
BlackPalette();
SDL_FillRect(DiabloUiSurface(), NULL, 0x000000);
if (DiabloUiSurface() == pal_surface)
BltFast(nullptr, nullptr);
RenderPresent();
}
@ -655,6 +657,8 @@ void UiFadeIn()
}
SetFadeLevel(fadeValue);
}
if (DiabloUiSurface() == pal_surface)
BltFast(nullptr, nullptr);
RenderPresent();
}

13
Source/DiabloUI/diabloui.h

@ -80,7 +80,18 @@ extern bool (*gfnHeroInfo)(bool (*fninfofunc)(_uiheroinfo *));
inline SDL_Surface *DiabloUiSurface()
{
return GetOutputSurface();
auto *output_surface = GetOutputSurface();
#ifdef USE_SDL1
// When using a non double-buffered hardware surface, render the UI
// to an off-screen surface first to avoid flickering / tearing.
if ((output_surface->flags & SDL_HWSURFACE) != 0
&& (output_surface->flags & SDL_DOUBLEBUF) == 0) {
return pal_surface;
}
#endif
return output_surface;
}
void UiDestroy();

Loading…
Cancel
Save