From f1af6e53f0b043cac2d3f1024d7d91785072f237 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 10 Jul 2017 22:52:39 +0200 Subject: vo_opengl: slightly refactor user_shaders code - Each struct tex_hook now stores multiple hooks, this allows us to avoid the awkward way of the current code has to add the same pass multiple times. - As a consequence, SHADER_MAX_HOOKS was split up into SHADER_MAX_PASSES (number of tex_hooks) and SHADER_MAX_HOOKS (number of hooked textures per tex_hook), and both numbers decreased correspondingly. - Instead of having a weird free() callback, we can just leverage talloc's recursive free behavior. The only user is the user shaders code anyway. --- video/out/opengl/user_shaders.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'video/out/opengl/user_shaders.c') diff --git a/video/out/opengl/user_shaders.c b/video/out/opengl/user_shaders.c index 718034fa2d..5cfd89b5ef 100644 --- a/video/out/opengl/user_shaders.c +++ b/video/out/opengl/user_shaders.c @@ -158,7 +158,6 @@ done: return true; } -// Returns false if no more shaders could be parsed bool parse_user_shader_pass(struct mp_log *log, struct bstr *body, struct gl_user_shader *out) { @@ -166,7 +165,7 @@ bool parse_user_shader_pass(struct mp_log *log, struct bstr *body, return false; *out = (struct gl_user_shader){ - .desc = bstr0("(unknown)"), + .pass_desc = bstr0("(unknown)"), .offset = identity_trans, .width = {{ SZEXP_VAR_W, { .varname = bstr0("HOOKED") }}}, .height = {{ SZEXP_VAR_H, { .varname = bstr0("HOOKED") }}}, @@ -179,12 +178,12 @@ bool parse_user_shader_pass(struct mp_log *log, struct bstr *body, // Skip all garbage (e.g. comments) before the first header int pos = bstr_find(*body, bstr0("//!")); if (pos < 0) { - mp_warn(log, "Shader appears to contain no passes!\n"); + mp_warn(log, "Shader appears to contain no headers!\n"); return false; } *body = bstr_cut(*body, pos); - // First parse all the headers + // Parse all headers while (true) { struct bstr rest; struct bstr line = bstr_strip(bstr_getline(*body, &rest)); @@ -222,7 +221,7 @@ bool parse_user_shader_pass(struct mp_log *log, struct bstr *body, } if (bstr_eatstart0(&line, "DESC")) { - out->desc = bstr_strip(line); + out->pass_desc = bstr_strip(line); continue; } -- cgit v1.2.3