win-capture: Don't try to find window every frame

When window capture is not capturing a window, don't try to find the
window every frame.  Instead, just check once per frame.  The process of
finding a window has a lot of checks and requires a surprising amount of
processing.
This commit is contained in:
jp9000 2019-02-11 17:57:24 -08:00
parent 0948e8a629
commit c372d26c02

View File

@ -26,6 +26,7 @@ struct window_capture {
struct dc_capture capture;
float resize_timer;
float check_window_timer;
float cursor_check_time;
HWND window;
@ -158,6 +159,16 @@ static void wc_tick(void *data, float seconds)
if (!wc->title && !wc->class)
return;
wc->check_window_timer += seconds;
if (wc->check_window_timer < 1.0f) {
if (wc->capture.valid)
dc_capture_free(&wc->capture);
return;
}
wc->check_window_timer = 0.0f;
wc->window = find_window(EXCLUDE_MINIMIZED, wc->priority,
wc->class, wc->title, wc->executable);
if (!wc->window) {