Make capture sources w/o alpha use opaque effect

This fixes an issue primarily with filter rendering: when capturing
windows and displays, their alpha channel is almost always 0, causing
the image to be completely invisible unintentionally.  The original fix
for this for many sources was just to turn off the blending, which would
be fine if you're not rendering any filters, but filters will render to
render targets first, and that lack of alpha will end up carrying over
in to the final image.

This doesn't apply to any mac captures because mac actually seems to set
the alpha channel to 1.
This commit is contained in:
jp9000
2015-03-14 00:38:09 -07:00
parent 9b238ef71e
commit e20ec366b2
10 changed files with 63 additions and 96 deletions

View File

@@ -27,8 +27,6 @@ struct window_capture {
float resize_timer;
gs_effect_t *opaque_effect;
HWND window;
RECT last_rect;
};
@@ -58,14 +56,8 @@ static const char *wc_getname(void)
static void *wc_create(obs_data_t *settings, obs_source_t *source)
{
struct window_capture *wc;
gs_effect_t *opaque_effect = create_opaque_effect();
if (!opaque_effect)
return NULL;
wc = bzalloc(sizeof(struct window_capture));
wc->source = source;
wc->opaque_effect = opaque_effect;
struct window_capture *wc = bzalloc(sizeof(struct window_capture));
wc->source = source;
update_settings(wc, settings);
return wc;
@@ -76,16 +68,14 @@ static void wc_destroy(void *data)
struct window_capture *wc = data;
if (wc) {
obs_enter_graphics();
dc_capture_free(&wc->capture);
obs_leave_graphics();
bfree(wc->title);
bfree(wc->class);
bfree(wc->executable);
obs_enter_graphics();
gs_effect_destroy(wc->opaque_effect);
obs_leave_graphics();
bfree(wc);
}
}
@@ -198,7 +188,7 @@ static void wc_tick(void *data, float seconds)
static void wc_render(void *data, gs_effect_t *effect)
{
struct window_capture *wc = data;
dc_capture_render(&wc->capture, wc->opaque_effect);
dc_capture_render(&wc->capture, obs_get_opaque_effect());
UNUSED_PARAMETER(effect);
}