diff options
author | Niklas Haas <git@haasn.xyz> | 2017-07-10 22:52:39 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-07-27 23:45:17 +0200 |
commit | f1af6e53f0b043cac2d3f1024d7d91785072f237 (patch) | |
tree | 9a0acb7243e78a83054cb71a7ce278c3d0a3271c /video/out/opengl/user_shaders.c | |
parent | ea76f79e5d89f54cf1b8e78d5c1d71bfce69d958 (diff) | |
download | mpv-f1af6e53f0b043cac2d3f1024d7d91785072f237.tar.bz2 mpv-f1af6e53f0b043cac2d3f1024d7d91785072f237.tar.xz |
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.
Diffstat (limited to 'video/out/opengl/user_shaders.c')
-rw-r--r-- | video/out/opengl/user_shaders.c | 9 |
1 files changed, 4 insertions, 5 deletions
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; } |