platform sdl, fix screen clearing if line pitch isn't width
authorkub <derkub@gmail.com>
Wed, 28 Sep 2022 18:46:32 +0000 (18:46 +0000)
committerkub <derkub@gmail.com>
Wed, 28 Sep 2022 18:46:32 +0000 (18:46 +0000)
platform/common/plat_sdl.c

index cb02919..79664c3 100644 (file)
@@ -191,7 +191,7 @@ void plat_video_flip(void)
                g_screen_ptr = plat_sdl_screen->pixels;
                plat_video_set_buffer(g_screen_ptr);
                if (clear_buf_cnt) {
-                       memset(g_screen_ptr, 0, plat_sdl_screen->w*plat_sdl_screen->h * 2);
+                       memset(g_screen_ptr, 0, plat_sdl_screen->pitch*plat_sdl_screen->h);
                        clear_buf_cnt--;
                }
        }
@@ -225,7 +225,7 @@ void plat_video_clear_buffers(void)
        if (plat_sdl_overlay || plat_sdl_gl_active)
                memset(shadow_fb, 0, g_menuscreen_w * g_menuscreen_h * 2);
        else {
-               memset(g_screen_ptr, 0, plat_sdl_screen->w*plat_sdl_screen->h * 2);
+               memset(g_screen_ptr, 0, plat_sdl_screen->pitch*plat_sdl_screen->h);
                clear_buf_cnt = 3; // do it thrice in case of triple buffering
        }
 }