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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* Copyright (c) 2016-2021 Hanspeter Portner (dev@open-music-kontrollers.ch)
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the Artistic License 2.0 as published by
* The Perl Foundation.
*
* This source is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Artistic License 2.0 for more details.
*
* You should have received a copy of the Artistic License 2.0
* along the source as a COPYING file. If not, obtain it from
* http://www.perlfoundation.org/artistic_license_2_0.
*/
#ifndef _LV2_CANVAS_RENDER_H
#define _LV2_CANVAS_RENDER_H
// Do NOT use this header directly, use render_{nanovg,cairo}.h instead
#include <canvas.lv2/canvas.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LV2_CANVAS_NUM_METHODS 26
typedef struct _LV2_Canvas_Meth LV2_Canvas_Meth;
typedef struct _LV2_Canvas LV2_Canvas;
typedef void (*LV2_Canvas_Func)(void *data,
LV2_Canvas_URID *urid, const LV2_Atom *body);
struct _LV2_Canvas_Meth {
LV2_URID command;
LV2_Canvas_Func func;
};
struct _LV2_Canvas {
LV2_Canvas_URID urid;
LV2_Canvas_Meth methods [LV2_CANVAS_NUM_METHODS];
};
static inline const float *
_lv2_canvas_render_get_float_vecs(LV2_Canvas_URID *urid, const LV2_Atom *body,
uint32_t *n)
{
const LV2_Atom_Vector *vec = (const LV2_Atom_Vector *)body;
const float *flt = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Vector, vec);
*n = (vec->atom.type == urid->forge.Vector)
&& (vec->body.child_type == urid->forge.Float)
&& (vec->body.child_size == sizeof(float))
? (vec->atom.size - sizeof(LV2_Atom_Vector_Body)) / vec->body.child_size
: 0;
return flt;
}
static inline const float *
_lv2_canvas_render_get_float_vec(LV2_Canvas_URID *urid, const LV2_Atom *body,
uint32_t n)
{
uint32_t N;
const float *flt = _lv2_canvas_render_get_float_vecs(urid, body, &N);
return n == N ? flt : NULL;
}
static inline const void *
_lv2_canvas_render_get_type(const LV2_Atom *body, LV2_URID type)
{
return body->type == type
? LV2_ATOM_BODY_CONST(body)
: NULL;
}
#ifdef __cplusplus
}
#endif
#endif // _LV2_CANVAS_RENDER_H
|