/src/barebox/include/gui/image_renderer.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
3 | | * |
4 | | * GPL v2 |
5 | | */ |
6 | | |
7 | | #ifndef __IMAGE_RENDER_H__ |
8 | | #define __IMAGE_RENDER_H__ |
9 | | |
10 | | #include <filetype.h> |
11 | | #include <linux/list.h> |
12 | | #include <errno.h> |
13 | | #include <linux/err.h> |
14 | | #include <fb.h> |
15 | | #include <gui/image.h> |
16 | | #include <gui/gui.h> |
17 | | |
18 | | struct image_renderer { |
19 | | enum filetype type; |
20 | | struct image *(*open)(char *data, int size); |
21 | | void (*close)(struct image *img); |
22 | | int (*renderer)(struct screen *sc, struct surface *s, struct image *img); |
23 | | |
24 | | /* |
25 | | * do not free the data read from the file |
26 | | * needed by bmp support |
27 | | */ |
28 | | int keep_file_data; |
29 | | |
30 | | struct list_head list; |
31 | | }; |
32 | | |
33 | | #ifdef CONFIG_IMAGE_RENDERER |
34 | | int image_renderer_register(struct image_renderer *ir); |
35 | | void image_renderer_unregister(struct image_renderer *ir); |
36 | | |
37 | | int image_renderer_image(struct screen *sc, struct surface *s, struct image *img); |
38 | | |
39 | | struct image *image_renderer_open(const char* file); |
40 | | void image_renderer_close(struct image *img); |
41 | | |
42 | | #else |
43 | | static inline int image_renderer_register(struct image_renderer *ir) |
44 | | { |
45 | | return -EINVAL; |
46 | | } |
47 | | static inline void image_renderer_unregister(struct image_renderer *ir) {} |
48 | | |
49 | | static inline struct image *image_renderer_open(const char* file) |
50 | | { |
51 | | return ERR_PTR(-EINVAL); |
52 | | } |
53 | | |
54 | | static inline void image_renderer_close(struct image *img) {} |
55 | | |
56 | | static inline int image_renderer_image(struct screen *sc, struct surface *s, struct image *img) |
57 | | { |
58 | | return -EINVAL; |
59 | | } |
60 | | #endif |
61 | | |
62 | | static inline int image_renderer_file(struct screen *sc, struct surface *s, const char* file) |
63 | 0 | { |
64 | 0 | struct image* img = image_renderer_open(file); |
65 | 0 | int ret; |
66 | |
|
67 | 0 | if (IS_ERR(img)) |
68 | 0 | return PTR_ERR(img); |
69 | | |
70 | 0 | ret = image_renderer_image(sc, s, img); |
71 | |
|
72 | 0 | image_renderer_close(img); |
73 | |
|
74 | 0 | return ret; |
75 | 0 | } Unexecuted instantiation: fbconsole.c:image_renderer_file Unexecuted instantiation: splash.c:image_renderer_file Unexecuted instantiation: bmp.c:image_renderer_file Unexecuted instantiation: image_renderer.c:image_renderer_file |
76 | | |
77 | | #endif /* __IMAGE_RENDERER_H__ */ |