summaryrefslogtreecommitdiffstatsci
path: root/tests/svg.c
blob: 2fb855a3fbffa56638632f8714a35ce557a7e168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "test.h"

#include "vkvg-svg.h"

static float       rotation   = 0.f;
static const char *path       = TESTS_DATA_ROOT "tiger.svg";
static const char *svgSubPath = TESTS_DATA_ROOT "checkbox.svg";

void svg_surface() {
    VkvgSurface svgSurf = vkvg_surface_create_from_svg(device, test_width, test_height, path);

    VkvgContext ctx = _initCtx(surf);

    vkvg_set_source_rgb(ctx, 1, 1, 1);
    vkvg_paint(ctx);

    vkvg_set_source_surface(ctx, svgSurf, 0, 0);
    vkvg_paint(ctx);

    vkvg_destroy(ctx);
    vkvg_surface_destroy(svgSurf);
}
void vkvg_svg() {
    VkvgSvg  svg = vkvg_svg_load(path);
    uint32_t w, h;
    vkvg_svg_get_dimensions(svg, &w, &h);
    VkvgContext ctx = _initCtx(surf);
    vkvg_clear(ctx);

    vkvg_svg_render(svg, ctx, NULL);

    vkvg_destroy(ctx);
    vkvg_svg_destroy(svg);
}
void vkvg_svg_sub() {
    VkvgSvg  svg = vkvg_svg_load(svgSubPath);
    uint32_t w, h;
    vkvg_svg_get_dimensions(svg, &w, &h);
    VkvgContext ctx = _initCtx(surf);
    vkvg_clear(ctx);

    vkvg_svg_render(svg, ctx, "#True");
    vkvg_translate(ctx, 200, 0);
    vkvg_svg_render(svg, ctx, "#False");

    vkvg_destroy(ctx);
    vkvg_svg_destroy(svg);
}

int main(int argc, char *argv[]) {
    no_test_size = true;

    PERFORM_TEST(svg_surface, argc, argv);
    PERFORM_TEST(vkvg_svg, argc, argv);
    PERFORM_TEST(vkvg_svg_sub, argc, argv);
    return 0;
}