From 6e5ded9f44606841fb5e905394cca803c7d7abdf Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 22 Jul 2022 00:23:50 +0200 Subject: [PATCH] Expose BlurEffect and UnsharpMaskEffect. This was mostly so that people could sharpen the input if they wanted to (even though unsharp mask is not the best sharpener). BlurEffect was added mainly because it felt wrong that one could only use a compound effect and not the underlying one. --- nageru/theme.cpp | 30 ++++++++++++++++++++++++++++++ nageru/theme.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/nageru/theme.cpp b/nageru/theme.cpp index a88c6f6..937043f 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -140,6 +142,10 @@ Effect *instantiate_effect(EffectChain *chain, EffectType effect_type) return new MixEffect; case LIFT_GAMMA_GAIN_EFFECT: return new LiftGammaGainEffect; + case BLUR_EFFECT: + return new BlurEffect; + case UNSHARP_MASK_EFFECT: + return new UnsharpMaskEffect; default: fprintf(stderr, "Unhandled effect type %d\n", effect_type); abort(); @@ -622,6 +628,18 @@ int LiftGammaGainEffect_new(lua_State* L) return wrap_lua_object_nonowned(L, "EffectBlueprint", LIFT_GAMMA_GAIN_EFFECT); } +int BlurEffect_new(lua_State* L) +{ + assert(lua_gettop(L) == 0); + return wrap_lua_object_nonowned(L, "EffectBlueprint", BLUR_EFFECT); +} + +int UnsharpMaskEffect_new(lua_State* L) +{ + assert(lua_gettop(L) == 0); + return wrap_lua_object_nonowned(L, "EffectBlueprint", UNSHARP_MASK_EFFECT); +} + int InputStateInfo_get_width(lua_State* L) { assert(lua_gettop(L) == 2); @@ -997,6 +1015,16 @@ const luaL_Reg LiftGammaGainEffect_funcs[] = { { NULL, NULL } }; +const luaL_Reg BlurEffect_funcs[] = { + { "new", BlurEffect_new }, + { NULL, NULL } +}; + +const luaL_Reg UnsharpMaskEffect_funcs[] = { + { "new", UnsharpMaskEffect_new }, + { NULL, NULL } +}; + // End of effects. const luaL_Reg InputStateInfo_funcs[] = { @@ -1558,6 +1586,8 @@ Theme::Theme(const string &filename, const vector &search_dirs, Resource register_class("ResizeEffect", ResizeEffect_funcs, RESIZE_EFFECT); register_class("MultiplyEffect", MultiplyEffect_funcs, MULTIPLY_EFFECT); register_class("MixEffect", MixEffect_funcs, MIX_EFFECT); + register_class("BlurEffect", BlurEffect_funcs, BLUR_EFFECT); + register_class("UnsharpMaskEffect", UnsharpMaskEffect_funcs, UNSHARP_MASK_EFFECT); register_class("LiftGammaGainEffect", LiftGammaGainEffect_funcs, LIFT_GAMMA_GAIN_EFFECT); register_class("InputStateInfo", InputStateInfo_funcs); register_class("ThemeMenu", ThemeMenu_funcs); diff --git a/nageru/theme.h b/nageru/theme.h index 024df7a..8a0a92a 100644 --- a/nageru/theme.h +++ b/nageru/theme.h @@ -49,6 +49,8 @@ enum EffectType { MULTIPLY_EFFECT, MIX_EFFECT, LIFT_GAMMA_GAIN_EFFECT, + BLUR_EFFECT, + UNSHARP_MASK_EFFECT, NO_EFFECT_TYPE }; -- 2.39.2