=> c6b294a22b9d4e75854dd4e2d5c75f9b063e7bed
[1mdiff --git a/src/app.c b/src/app.c[m [1mindex 891f5d6e..b6c48062 100644[m [1m--- a/src/app.c[m [1m+++ b/src/app.c[m [36m@@ -1644,13 +1644,14 @@[m [mvoid refresh_App(void) {[m iWindow *win = j.ptr;[m setCurrent_Window(win);[m switch (win->type) {[m [31m- case main_WindowType:[m [31m- // iTime draw;[m [31m- // initCurrent_Time(&draw);[m [32m+[m[32m case main_WindowType: {[m [32m+[m[32m// iTime draw;[m [32m+[m[32m// initCurrent_Time(&draw);[m draw_MainWindow(as_MainWindow(win));[m [31m- // printf("draw: %lld \u03bcs\n", (long long) (elapsedSeconds_Time(&draw) * 1000000));[m [31m- // fflush(stdout);[m [32m+[m[32m// printf("draw: %lld \u03bcs\n", (long long) (elapsedSeconds_Time(&draw) * 1000000));[m [32m+[m[32m// fflush(stdout);[m break;[m [32m+[m[32m }[m default:[m draw_Window(win);[m break;[m [1mdiff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c[m [1mindex 651669c6..71e4873f 100644[m [1m--- a/src/ui/scrollwidget.c[m [1m+++ b/src/ui/scrollwidget.c[m [36m@@ -239,15 +239,17 @@[m [mstatic void draw_ScrollWidget_(const iScrollWidget *d) {[m init_Paint(&p);[m /* Blend if opacity is not at maximum. */[m p.alpha = 255 * value_Anim(&d->opacity);[m [31m- SDL_Renderer *render = renderer_Window(get_Window());[m [31m- if (p.alpha < 255) {[m [31m- SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND);[m [31m- }[m [31m- const iRect thumbRect = shrunk_Rect([m [31m- thumbRect_ScrollWidget_(d), init_I2(isPressed ? gap_UI : (gap_UI * 4 / 3), gap_UI / 2));[m [31m- fillRect_Paint(&p, thumbRect, isPressed ? uiBackgroundPressed_ColorId : tmQuote_ColorId);[m [31m- if (p.alpha < 255) {[m [31m- SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_NONE);[m [32m+[m[32m if (p.alpha > 0) {[m [32m+[m[32m SDL_Renderer *render = renderer_Window(get_Window());[m [32m+[m[32m if (p.alpha < 255) {[m [32m+[m[32m SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND);[m [32m+[m[32m }[m [32m+[m[32m const iRect thumbRect = shrunk_Rect([m [32m+[m[32m thumbRect_ScrollWidget_(d), init_I2(isPressed ? gap_UI : (gap_UI * 4 / 3), gap_UI / 2));[m [32m+[m[32m fillRect_Paint(&p, thumbRect, isPressed ? uiBackgroundPressed_ColorId : tmQuote_ColorId);[m [32m+[m[32m if (p.alpha < 255) {[m [32m+[m[32m SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_NONE);[m [32m+[m[32m }[m }[m }[m }[m [1mdiff --git a/src/ui/window.c b/src/ui/window.c[m [1mindex 13abc5fa..c80bfbe0 100644[m [1m--- a/src/ui/window.c[m [1m+++ b/src/ui/window.c[m [36m@@ -539,10 +539,19 @@[m [mvoid deinit_Window(iWindow *d) {[m void init_MainWindow(iMainWindow *d, iRect rect) {[m theWindow_ = &d->base;[m theMainWindow_ = d;[m [32m+[m[32m d->enableBackBuf = iFalse;[m uint32_t flags = 0;[m #if defined (iPlatformAppleDesktop)[m SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl");[m flags |= shouldDefaultToMetalRenderer_MacOS() ? SDL_WINDOW_METAL : SDL_WINDOW_OPENGL;[m [32m+[m[32m if (flags & SDL_WINDOW_METAL) {[m [32m+[m[32m /* There are some really odd refresh glitches that only occur with the Metal[m[41m [m [32m+[m[32m backend. It's perhaps related to it not expecting refresh to stop intermittently[m [32m+[m[32m to wait for input events. If forcing constant refreshing at full frame rate, the[m [32m+[m[32m problems seem to go away... Rendering everything to a separate render target[m [32m+[m[32m appears to sidestep some of the glitches. */[m [32m+[m[32m d->enableBackBuf = iTrue;[m [32m+[m[32m }[m #elif defined (iPlatformAppleMobile)[m SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");[m flags |= SDL_WINDOW_METAL;[m [36m@@ -566,6 +575,7 @@[m [mvoid init_MainWindow(iMainWindow *d, iRect rect) {[m d->place.lastNotifiedSize = zero_I2();[m d->place.snap = 0;[m d->keyboardHeight = 0;[m [32m+[m[32m d->backBuf = NULL;[m #if defined(iPlatformMobile)[m const iInt2 minSize = zero_I2(); /* windows aren't independently resizable */[m #else[m [36m@@ -637,6 +647,9 @@[m [mvoid init_MainWindow(iMainWindow *d, iRect rect) {[m }[m [m void deinit_MainWindow(iMainWindow *d) {[m [32m+[m[32m if (d->backBuf) {[m [32m+[m[32m SDL_DestroyTexture(d->backBuf);[m [32m+[m[32m }[m deinitRoots_Window_(as_Window(d));[m if (theWindow_ == as_Window(d)) {[m theWindow_ = NULL;[m [36m@@ -682,6 +695,10 @@[m [miRoot *otherRoot_Window(const iWindow *d, iRoot *root) {[m static void invalidate_MainWindow_(iMainWindow *d, iBool forced) {[m if (d && (!d->base.isInvalidated || forced)) {[m d->base.isInvalidated = iTrue;[m [32m+[m[32m if (d->enableBackBuf && d->backBuf) {[m [32m+[m[32m SDL_DestroyTexture(d->backBuf);[m [32m+[m[32m d->backBuf = NULL;[m [32m+[m[32m }[m resetFonts_Text(text_Window(d));[m postCommand_App("theme.changed auto:1"); /* forces UI invalidation */[m }[m [36m@@ -1272,11 +1289,28 @@[m [mvoid draw_MainWindow(iMainWindow *d) {[m d->maxDrawableHeight = renderSize.y;[m }[m }[m [32m+[m[32m if (d->enableBackBuf) {[m [32m+[m[32m /* Possible resize the backing buffer. */[m [32m+[m[32m if (!d->backBuf || !isEqual_I2(size_SDLTexture(d->backBuf), renderSize)) {[m [32m+[m[32m if (d->backBuf) {[m [32m+[m[32m SDL_DestroyTexture(d->backBuf);[m [32m+[m[32m }[m [32m+[m[32m d->backBuf = SDL_CreateTexture(d->base.render,[m [32m+[m[32m SDL_PIXELFORMAT_RGB888,[m [32m+[m[32m SDL_TEXTUREACCESS_TARGET,[m [32m+[m[32m renderSize.x,[m [32m+[m[32m renderSize.y);[m [32m+[m[32m printf("NEW BACKING: %dx%d %p\n", renderSize.x, renderSize.y, d->backBuf); fflush(stdout);[m [32m+[m[32m }[m [32m+[m[32m }[m }[m const int winFlags = SDL_GetWindowFlags(d->base.win);[m const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0;[m iPaint p;[m init_Paint(&p);[m [32m+[m[32m if (d->backBuf) {[m [32m+[m[32m SDL_SetRenderTarget(d->base.render, d->backBuf);[m [32m+[m[32m }[m /* Clear the window. The clear color is visible as a border around the window[m when the custom frame is being used. */ {[m setCurrent_Root(w->roots[0]);[m [36m@@ -1359,6 +1393,10 @@[m [mvoid draw_MainWindow(iMainWindow *d) {[m drawCount_ = 0;[m #endif[m }[m [32m+[m[32m if (d->backBuf) {[m [32m+[m[32m SDL_SetRenderTarget(d->base.render, NULL);[m [32m+[m[32m SDL_RenderCopy(d->base.render, d->backBuf, NULL, NULL);[m [32m+[m[32m }[m #if 0[m /* Text cache debugging. */ {[m SDL_Rect rect = { d->roots[0]->widget->rect.size.x - 640, 0, 640, 2.5 * 640 };[m [1mdiff --git a/src/ui/window.h b/src/ui/window.h[m [1mindex b4e348d2..5abf23eb 100644[m [1m--- a/src/ui/window.h[m [1m+++ b/src/ui/window.h[m [36m@@ -118,6 +118,8 @@[m [mstruct Impl_MainWindow {[m SDL_Texture * appIcon;[m int keyboardHeight; /* mobile software keyboards */[m int maxDrawableHeight;[m [32m+[m[32m iBool enableBackBuf; /* only used on macOS with Metal (helps with refresh glitches for some reason??) */[m [32m+[m[32m SDL_Texture * backBuf; /* enables refreshing the window without redrawing anything */[m };[m [m iLocalDef enum iWindowType type_Window(const iAnyWindow *d) {[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).