avfilter/vf_drawvg: support color expressions as setvar/call arguments.

The arguments for `setvar` and `call` commands can be colors (like `#rrggbb`).
This replaces the previous trick of using `0xRRGGBBAA` values to use colors as
procedure arguments.

The parser stores colors as the value expected by Cairo (a `double[4]`). This
array is allocated on the heap so the size of the union in `VGSArgument` is
not increased (i.e. it is still 8 bytes, instead of 32).

Signed-off-by: Ayose <ayosec@gmail.com>
This commit is contained in:
Ayose
2025-12-05 14:19:05 +00:00
committed by Marton Balint
parent 6300e340d3
commit 46c9584dc5
3 changed files with 140 additions and 41 deletions

View File

@@ -76,6 +76,16 @@ cairo_fill
cairo_set_source #a8d8f0e6
cairo_set_fill_rule 0
cairo_fill
cairo_set_source #abcdef66
cairo_stroke
cairo_set_source #123456ff
cairo_stroke
cairo_set_source #abcdef66
cairo_stroke
av_log[32]: [104:45] a0 = 1.000000 | [104:48] a2 = 123.000000
cairo_set_source #50a0f033
cairo_stroke
av_log[32]: [104:45] a0 = -1.000000 | [104:48] a2 = -123.000000
cairo_rel_line_to 1.0 3.0
cairo_rel_line_to nan 0.0

View File

@@ -93,6 +93,18 @@ defhsla c1 200 0.7 0.8 0.9
setcolor c0 fill
setcolor c1 fill
// Colors as arguments for setvar/call.
setvar color0 #123456
setvar color1 #abcdef@0.4
setvar color2 color1
setvar a 123
setcolor color2 stroke
setcolor color0 stroke
proc f3 a0 a1 a2 { setcolor a1 stroke print a0 a2 }
call f3 1 color1 a
call f3 -1 #50A0F0@0.2 (-a)
// Frame metadata
getmetadata md0 m.a
getmetadata md1 m.b