add major optimization to filter processing, and as a nice side effect, make it easier to create new filters and sources

This commit is contained in:
jp9000
2013-12-22 01:30:18 -07:00
parent 5471625dd7
commit 19c4ee995e
9 changed files with 148 additions and 64 deletions

View File

@@ -10,7 +10,6 @@ struct random_tex *random_create(const char *settings, obs_source_t source)
{
struct random_tex *rt = bmalloc(sizeof(struct random_tex));
uint32_t *pixels = bmalloc(20*20*4);
char *effect_file;
size_t x, y;
memset(rt, 0, sizeof(struct random_tex));
@@ -37,15 +36,6 @@ struct random_tex *random_create(const char *settings, obs_source_t source)
return NULL;
}
effect_file = obs_find_plugin_file("test-input/draw.effect");
rt->whatever = gs_create_effect_from_file(effect_file, NULL);
bfree(effect_file);
if (!rt->whatever) {
random_destroy(rt);
return NULL;
}
gs_leavecontext();
return rt;
@@ -56,7 +46,6 @@ void random_destroy(struct random_tex *rt)
if (rt) {
gs_entercontext(obs_graphics());
effect_destroy(rt->whatever);
texture_destroy(rt->texture);
bfree(rt);
@@ -66,21 +55,16 @@ void random_destroy(struct random_tex *rt)
uint32_t random_get_output_flags(struct random_tex *rt)
{
return SOURCE_VIDEO;
return SOURCE_VIDEO | SOURCE_DEFAULT_EFFECT;
}
void random_video_render(struct random_tex *rt, obs_source_t filter_target)
{
technique_t tech = effect_gettechnique(rt->whatever, "Default");
effect_settexture(rt->whatever, effect_getparambyidx(rt->whatever, 1),
rt->texture);
technique_begin(tech);
technique_beginpass(tech, 0);
effect_t effect = gs_geteffect();
eparam_t diffuse = effect_getparambyname(effect, "diffuse");
effect_settexture(effect, diffuse, rt->texture);
gs_draw_sprite(rt->texture, 0, 0, 0);
technique_endpass(tech);
technique_end(tech);
}
uint32_t random_getwidth(struct random_tex *rt)