diff --git a/src/common/api.c b/src/common/api.c index 0c0d359..176b789 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -72,7 +72,7 @@ static void ion_alloc(int fd_ion, ion_alloc_info_t* info) { iad.len = info->size; iad.align = sysconf(_SC_PAGESIZE); iad.heap_id_mask = (1<pixels, 0, PAGE_SIZE); } void GFX_clearAll(void) { - // TODO: one buffer is onscreen when cleared producing tearing - memset(gfx.fb_info.vadd, 0, PAGE_SIZE * PAGE_COUNT); + GFX_clear(gfx.screen); // clear backbuffer + gfx.cleared = 1; // defer clearing frontbuffer until offscreen } void GFX_setMode(int mode) { @@ -542,10 +543,14 @@ void GFX_flip(SDL_Surface* screen) { } } - // swap backbuffer gfx.page ^= 1; gfx.screen->pixels = gfx.fb_info.vadd + gfx.page * PAGE_SIZE; + + if (gfx.cleared) { + GFX_clear(gfx.screen); + gfx.cleared = 0; + } } void GFX_sync(void) { if (gfx.vsync!=VSYNC_OFF) {