comparison src/libmlk-core/core/drawable.h @ 320:8f9937403749

misc: improve loading of data
author David Demelier <markand@malikania.fr>
date Fri, 01 Oct 2021 20:30:00 +0200
parents libmlk-core/core/drawable.h@d01e83210ca2
children 19782ea1cf4a
comparison
equal deleted inserted replaced
319:b843eef4cc35 320:8f9937403749
1 /*
2 * drawable.h -- automatic drawable objects
3 *
4 * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef MOLKO_CORE_DRAWABLE_H
20 #define MOLKO_CORE_DRAWABLE_H
21
22 #include "core.h"
23
24 #define DRAWABLE_STACK_MAX (128)
25
26 struct drawable {
27 void *data;
28 int x;
29 int y;
30 int (*update)(struct drawable *, unsigned int);
31 void (*draw)(struct drawable *);
32 void (*end)(struct drawable *);
33 void (*finish)(struct drawable *);
34 };
35
36 struct drawable_stack {
37 struct drawable *objects[DRAWABLE_STACK_MAX];
38 };
39
40 CORE_BEGIN_DECLS
41
42 int
43 drawable_update(struct drawable *, unsigned int);
44
45 void
46 drawable_draw(struct drawable *);
47
48 void
49 drawable_end(struct drawable *);
50
51 void
52 drawable_finish(struct drawable *);
53
54 void
55 drawable_stack_init(struct drawable_stack *);
56
57 int
58 drawable_stack_add(struct drawable_stack *, struct drawable *);
59
60 int
61 drawable_stack_update(struct drawable_stack *, unsigned int);
62
63 void
64 drawable_stack_draw(struct drawable_stack *);
65
66 int
67 drawable_stack_completed(const struct drawable_stack *);
68
69 void
70 drawable_stack_finish(struct drawable_stack *);
71
72 CORE_END_DECLS
73
74 #endif /* !MOLKO_CORE_DRAWABLE_H */