diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 25a012258..a3c6f72bd 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -1304,7 +1304,7 @@ static void obs_source_draw_async_texture(struct obs_source *source) gs_technique_t *tech = NULL; if (def_draw) { - effect = obs_get_default_effect(); + effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); tech = gs_effect_get_technique(effect, type); gs_technique_begin(tech); gs_technique_begin_pass(tech, 0); diff --git a/libobs/obs.c b/libobs/obs.c index d3ff752fb..39e93b5e4 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -1336,46 +1336,28 @@ obs_service_t *obs_get_service_by_name(const char *name) &obs->data.services_mutex, obs_service_addref_safe_); } -gs_effect_t *obs_get_default_effect(void) +gs_effect_t *obs_get_base_effect(enum obs_base_effect effect) { if (!obs) return NULL; - return obs->video.default_effect; -} -gs_effect_t *obs_get_default_rect_effect(void) -{ - if (!obs) return NULL; - return obs->video.default_rect_effect; -} + switch (effect) { + case OBS_EFFECT_DEFAULT: + return obs->video.default_effect; + case OBS_EFFECT_DEFAULT_RECT: + return obs->video.default_rect_effect; + case OBS_EFFECT_OPAQUE: + return obs->video.opaque_effect; + case OBS_EFFECT_SOLID: + return obs->video.solid_effect; + case OBS_EFFECT_BICUBIC: + return obs->video.bicubic_effect; + case OBS_EFFECT_LANCZOS: + return obs->video.lanczos_effect; + case OBS_EFFECT_BILINEAR_LOWRES: + return obs->video.bilinear_lowres_effect; + } -gs_effect_t *obs_get_opaque_effect(void) -{ - if (!obs) return NULL; - return obs->video.opaque_effect; -} - -gs_effect_t *obs_get_solid_effect(void) -{ - if (!obs) return NULL; - return obs->video.solid_effect; -} - -gs_effect_t *obs_get_bicubic_effect(void) -{ - if (!obs) return NULL; - return obs->video.bicubic_effect; -} - -gs_effect_t *obs_get_lanczos_effect(void) -{ - if (!obs) return NULL; - return obs->video.lanczos_effect; -} - -gs_effect_t *obs_get_bilinear_lowres_effect(void) -{ - if (!obs) return NULL; - return obs->video.bilinear_lowres_effect; + return NULL; } signal_handler_t *obs_get_signal_handler(void) diff --git a/libobs/obs.h b/libobs/obs.h index e3ab20e8c..237820b71 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -520,26 +520,18 @@ EXPORT obs_encoder_t *obs_get_encoder_by_name(const char *name); /** Gets an service by its name. */ EXPORT obs_service_t *obs_get_service_by_name(const char *name); -/** Returns the default effect for generic RGB/YUV drawing */ -EXPORT gs_effect_t *obs_get_default_effect(void); +enum obs_base_effect { + OBS_EFFECT_DEFAULT, /**< RGB/YUV */ + OBS_EFFECT_DEFAULT_RECT, /**< RGB/YUV (using texture_rect) */ + OBS_EFFECT_OPAQUE, /**< RGB/YUV (alpha set to 1.0) */ + OBS_EFFECT_SOLID, /**< RGB/YUV (solid color only) */ + OBS_EFFECT_BICUBIC, /**< Bicubic downscale */ + OBS_EFFECT_LANCZOS, /**< Lanczos downscale */ + OBS_EFFECT_BILINEAR_LOWRES, /**< Bilinear low resolution downscale */ +}; -/** Returns the default effect for generic RGB/YUV drawing using texture_rect */ -EXPORT gs_effect_t *obs_get_default_rect_effect(void); - -/** Returns the default effect for generic RGB/YUV drawing (alpha set to 1) */ -EXPORT gs_effect_t *obs_get_opaque_effect(void); - -/** Returns the solid effect for drawing solid colors */ -EXPORT gs_effect_t *obs_get_solid_effect(void); - -/** Returns the bicubic scaling effect */ -EXPORT gs_effect_t *obs_get_bicubic_effect(void); - -/** Returns the lanczos scaling effect */ -EXPORT gs_effect_t *obs_get_lanczos_effect(void); - -/** Returns the bilinear lowres scaling effect */ -EXPORT gs_effect_t *obs_get_bilinear_lowres_effect(void); +/** Returns a commonly used base effect */ +EXPORT gs_effect_t *obs_get_base_effect(enum obs_base_effect effect); /** Returns the primary obs signal handler */ EXPORT signal_handler_t *obs_get_signal_handler(void); diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 1bc065f6f..c41cd2e29 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -1983,7 +1983,7 @@ void OBSBasic::DrawBackdrop(float cx, float cy) if (!box) return; - gs_effect_t *solid = obs_get_solid_effect(); + gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID); gs_eparam_t *color = gs_effect_get_param_by_name(solid, "color"); gs_technique_t *tech = gs_effect_get_technique(solid, "Solid"); diff --git a/obs/window-basic-preview.cpp b/obs/window-basic-preview.cpp index 0641657a6..dd73773e8 100644 --- a/obs/window-basic-preview.cpp +++ b/obs/window-basic-preview.cpp @@ -768,7 +768,7 @@ void OBSBasicPreview::DrawSceneEditing() { OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); - gs_effect_t *solid = obs_get_solid_effect(); + gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID); gs_technique_t *tech = gs_effect_get_technique(solid, "Solid"); vec4 color; diff --git a/plugins/linux-capture/xcompcap-main.cpp b/plugins/linux-capture/xcompcap-main.cpp index 6eae05446..9c02f7888 100644 --- a/plugins/linux-capture/xcompcap-main.cpp +++ b/plugins/linux-capture/xcompcap-main.cpp @@ -517,7 +517,7 @@ void XCompcapMain::tick(float seconds) void XCompcapMain::render(gs_effect_t *effect) { PLock lock(&p->lock, true); - effect = obs_get_opaque_effect(); + effect = obs_get_base_effect(OBS_EFFECT_OPAQUE); if (!lock.isLocked() || !p->tex) return; @@ -530,7 +530,7 @@ void XCompcapMain::render(gs_effect_t *effect) } if (p->cursor && p->gltex && p->show_cursor && !p->cursor_outside) { - effect = obs_get_default_effect(); + effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); while (gs_effect_loop(effect, "Draw")) { xcursor_render(p->cursor); diff --git a/plugins/linux-capture/xshm-input.c b/plugins/linux-capture/xshm-input.c index 8e0fe3cfd..9379c5076 100644 --- a/plugins/linux-capture/xshm-input.c +++ b/plugins/linux-capture/xshm-input.c @@ -432,7 +432,7 @@ static void xshm_video_render(void *vptr, gs_effect_t *effect) { XSHM_DATA(vptr); - effect = obs_get_opaque_effect(); + effect = obs_get_base_effect(OBS_EFFECT_OPAQUE); if (!data->texture) return; @@ -445,7 +445,7 @@ static void xshm_video_render(void *vptr, gs_effect_t *effect) } if (data->show_cursor) { - effect = obs_get_default_effect(); + effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); while (gs_effect_loop(effect, "Draw")) { xcb_xcursor_render(data->cursor); diff --git a/plugins/mac-capture/mac-display-capture.m b/plugins/mac-capture/mac-display-capture.m index e0727918c..1a606f48f 100644 --- a/plugins/mac-capture/mac-display-capture.m +++ b/plugins/mac-capture/mac-display-capture.m @@ -263,7 +263,7 @@ static void *display_capture_create(obs_data_t *settings, dc->source = source; dc->hide_cursor = !obs_data_get_bool(settings, "show_cursor"); - dc->effect = obs_get_default_rect_effect(); + dc->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT); if (!dc->effect) goto fail; diff --git a/plugins/mac-syphon/syphon.m b/plugins/mac-syphon/syphon.m index b48f2a3b9..195432f61 100644 --- a/plugins/mac-syphon/syphon.m +++ b/plugins/mac-syphon/syphon.m @@ -418,7 +418,7 @@ static inline bool init_obs_graphics_objects(syphon_t s) s->vertbuffer = create_vertbuffer(); obs_leave_graphics(); - s->effect = obs_get_default_rect_effect(); + s->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT); return s->sampler != NULL && s->vertbuffer != NULL && s->effect != NULL; } diff --git a/plugins/win-capture/dc-capture.c b/plugins/win-capture/dc-capture.c index d1d3be1ae..d9cb8d20e 100644 --- a/plugins/win-capture/dc-capture.c +++ b/plugins/win-capture/dc-capture.c @@ -210,38 +210,3 @@ void dc_capture_render(struct dc_capture *capture, gs_effect_t *effect) if (capture->textures_written[last_tex]) draw_texture(capture, last_tex, effect); } - -gs_effect_t *create_opaque_effect(void) -{ - gs_effect_t *opaque_effect; - char *effect_file; - char *error_string = NULL; - - effect_file = obs_module_file("opaque.effect"); - if (!effect_file) { - blog(LOG_ERROR, "[create_opaque_effect] Could not find " - "opaque effect file"); - return false; - } - - obs_enter_graphics(); - - opaque_effect = gs_effect_create_from_file(effect_file, &error_string); - - if (!opaque_effect) { - if (error_string) - blog(LOG_ERROR, "[create_opaque_effect] Failed to " - "create opaque effect:\n%s", - error_string); - else - blog(LOG_ERROR, "[create_opaque_effect] Failed to " - "create opaque effect"); - } - - bfree(effect_file); - bfree(error_string); - - obs_leave_graphics(); - - return opaque_effect; -} diff --git a/plugins/win-capture/dc-capture.h b/plugins/win-capture/dc-capture.h index ff1b65c13..2574aa35b 100644 --- a/plugins/win-capture/dc-capture.h +++ b/plugins/win-capture/dc-capture.h @@ -35,5 +35,3 @@ extern void dc_capture_free(struct dc_capture *capture); extern void dc_capture_capture(struct dc_capture *capture, HWND window); extern void dc_capture_render(struct dc_capture *capture, gs_effect_t *effect); - -extern gs_effect_t *create_opaque_effect(void); diff --git a/plugins/win-capture/duplicator-monitor-capture.c b/plugins/win-capture/duplicator-monitor-capture.c index e721f4ca3..86530c392 100644 --- a/plugins/win-capture/duplicator-monitor-capture.c +++ b/plugins/win-capture/duplicator-monitor-capture.c @@ -195,7 +195,7 @@ static void duplicator_capture_render(void *data, gs_effect_t *effect) if (!texture) return; - effect = obs_get_opaque_effect(); + effect = obs_get_base_effect(OBS_EFFECT_OPAQUE); rot = capture->rot; @@ -229,7 +229,7 @@ static void duplicator_capture_render(void *data, gs_effect_t *effect) } if (capture->capture_cursor) { - effect = obs_get_default_effect(); + effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); while (gs_effect_loop(effect, "Draw")) { draw_cursor(capture); diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index eddb940aa..9afa18da9 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -1349,8 +1349,8 @@ static void game_capture_render(void *data, gs_effect_t *effect) if (!gc->texture) return; - effect = gc->config.allow_transparency ? - obs_get_default_effect() : obs_get_opaque_effect(); + effect = obs_get_base_effect(gc->config.allow_transparency ? + OBS_EFFECT_DEFAULT : OBS_EFFECT_OPAQUE); while (gs_effect_loop(effect, "Draw")) { obs_source_draw(gc->texture, 0, 0, 0, 0, @@ -1362,7 +1362,7 @@ static void game_capture_render(void *data, gs_effect_t *effect) } if (!gc->config.allow_transparency && gc->config.cursor) { - effect = obs_get_default_effect(); + effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); while (gs_effect_loop(effect, "Draw")) { game_capture_render_cursor(gc); diff --git a/plugins/win-capture/monitor-capture.c b/plugins/win-capture/monitor-capture.c index c0adb7fa5..50fc1ff98 100644 --- a/plugins/win-capture/monitor-capture.c +++ b/plugins/win-capture/monitor-capture.c @@ -147,7 +147,8 @@ static void monitor_capture_tick(void *data, float seconds) static void monitor_capture_render(void *data, gs_effect_t *effect) { struct monitor_capture *capture = data; - dc_capture_render(&capture->data, obs_get_opaque_effect()); + dc_capture_render(&capture->data, + obs_get_base_effect(OBS_EFFECT_OPAQUE)); UNUSED_PARAMETER(effect); } diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index e93d63253..697b602bc 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -190,7 +190,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, obs_get_opaque_effect()); + dc_capture_render(&wc->capture, obs_get_base_effect(OBS_EFFECT_OPAQUE)); UNUSED_PARAMETER(effect); }