author Ryan C. Gordon <>
Wed, 06 Mar 2019 03:08:45 -0500
changeset 103 685c0014eda1
parent 44 071ea2306704
permissions -rw-r--r--
Optimize dirty rectangle rendering.

Only push the video surface to a texture immediately when the app does
SDL_Flip() or SDL_UpdateRect(0,0,0,0). If it looks like dirty rectangle
rendering, only push when we're in a PumpEvents that's close to 60Hz, under
the assumption that the app isn't in the middle of rendering if they're
pumping the event queue, and that updates to the texture faster than the
refresh rate aren't seen anyhow.

This lets things that render a little in response to every mouse event, like
TuxPaint, run at reasonable speeds and still look correct.

This probably needs to not hardcode for 60Hz, but get the actual refresh rate
from SDL2.
     2                          Simple DirectMedia Layer
     4                                   (SDL)
     6                             Version 1.2-COMPAT
     8 ---
    11 This is the Simple DirectMedia Layer, a general API that provides low
    12 level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
    13 and 2D framebuffer across multiple platforms.
    15 This code is a compatibility layer; it provides a binary-compatible API for
    16 programs written against SDL 1.2, but it uses SDL 2.0 behind the scenes. If
    17 you are writing new code, please target SDL 2.0 directly and do not use this
    18 layer.
    20 If you absolutely must have the real SDL 1.2 ("SDL 1.2 Classic"), please use
    21 the SDL-1.2 branch at, which occasionally gets
    22 bug fixes but no formal release. But we strongly encourage you not to do that.