From c6b294a22b9d4e75854dd4e2d5c75f9b063e7bed Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 8 Feb 2022 11:54:42 +0200 Subject: macOS: Attempting workaround for Metal refresh issues For some reason, rendering to a separate render target instead of directly to the window helps with certain refresh glitches. More glitches still remain, though, perhaps related to not running window refresh at a constant rate but occasionally pausing to wait for input events. --- src/ui/scrollwidget.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/ui/scrollwidget.c') diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c index 651669c6..71e4873f 100644 --- a/src/ui/scrollwidget.c +++ b/src/ui/scrollwidget.c @@ -239,15 +239,17 @@ static void draw_ScrollWidget_(const iScrollWidget *d) { init_Paint(&p); /* Blend if opacity is not at maximum. */ p.alpha = 255 * value_Anim(&d->opacity); - SDL_Renderer *render = renderer_Window(get_Window()); - if (p.alpha < 255) { - SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND); - } - const iRect thumbRect = shrunk_Rect( - thumbRect_ScrollWidget_(d), init_I2(isPressed ? gap_UI : (gap_UI * 4 / 3), gap_UI / 2)); - fillRect_Paint(&p, thumbRect, isPressed ? uiBackgroundPressed_ColorId : tmQuote_ColorId); - if (p.alpha < 255) { - SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_NONE); + if (p.alpha > 0) { + SDL_Renderer *render = renderer_Window(get_Window()); + if (p.alpha < 255) { + SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND); + } + const iRect thumbRect = shrunk_Rect( + thumbRect_ScrollWidget_(d), init_I2(isPressed ? gap_UI : (gap_UI * 4 / 3), gap_UI / 2)); + fillRect_Paint(&p, thumbRect, isPressed ? uiBackgroundPressed_ColorId : tmQuote_ColorId); + if (p.alpha < 255) { + SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_NONE); + } } } } -- cgit v1.2.3