summaryrefslogtreecommitdiffstats
path: root/include/gui
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-09-26 11:59:02 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-04 17:22:09 +0200
commit3fa8d74abea368d70e49be5671ea1b135cef644d (patch)
tree7a7d06e04ff8caecc72812e5f9e4bf264667d561 /include/gui
parent21a8ef55b0a2140a7ef7bd38869ff63592335861 (diff)
downloadbarebox-3fa8d74abea368d70e49be5671ea1b135cef644d.tar.gz
barebox-3fa8d74abea368d70e49be5671ea1b135cef644d.tar.xz
gui: introduce screen and surface to factorize and simplify code
Instead of passing hundreds of parameter, just pass the right structure. struct screen represent the screen with a without double buffering. struct surface represent the part of the screen we want to render. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/gui')
-rw-r--r--include/gui/graphic_utils.h2
-rw-r--r--include/gui/gui.h36
-rw-r--r--include/gui/image_renderer.h16
3 files changed, 44 insertions, 10 deletions
diff --git a/include/gui/graphic_utils.h b/include/gui/graphic_utils.h
index 4690e51e62..4cfb8e8d4d 100644
--- a/include/gui/graphic_utils.h
+++ b/include/gui/graphic_utils.h
@@ -9,6 +9,7 @@
#include <fb.h>
#include <gui/image.h>
+#include <gui/gui.h>
void rgba_blend(struct fb_info *info, struct image *img, void* dest, int height,
int width, int startx, int starty, bool is_rgba);
@@ -16,5 +17,6 @@ void set_pixel(struct fb_info *info, void *adr, u32 px);
void set_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b);
void set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a);
void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size);
+int fb_open(const char * fbdev, struct screen *sc);
#endif /* __GRAPHIC_UTILS_H__ */
diff --git a/include/gui/gui.h b/include/gui/gui.h
new file mode 100644
index 0000000000..2f792f1017
--- /dev/null
+++ b/include/gui/gui.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPL v2
+ */
+
+#ifndef __GUI_H__
+#define __GUI_H__
+
+#include <fb.h>
+
+struct surface {
+ int x;
+ int y;
+ int width;
+ int height;
+};
+
+struct screen {
+ struct fb_info info;
+
+ struct surface s;
+
+ void *fb;
+ void *offscreenbuf;
+};
+
+static inline void* gui_screen_redering_buffer(struct screen *sc)
+{
+ if (sc->offscreenbuf)
+ return sc->offscreenbuf;
+ return sc->fb;
+}
+
+
+#endif /* __GUI_H__ */
diff --git a/include/gui/image_renderer.h b/include/gui/image_renderer.h
index 5ee9969442..e0b1eae258 100644
--- a/include/gui/image_renderer.h
+++ b/include/gui/image_renderer.h
@@ -13,13 +13,13 @@
#include <linux/err.h>
#include <fb.h>
#include <gui/image.h>
+#include <gui/gui.h>
struct image_renderer {
enum filetype type;
struct image *(*open)(char *data, int size);
void (*close)(struct image *img);
- int (*renderer)(struct fb_info *info, struct image *img, void* fb,
- int startx, int starty, void* offscreenbuf);
+ int (*renderer)(struct screen *sc, struct surface *s, struct image *img);
/*
* do not free the data read from the file
@@ -34,8 +34,7 @@ struct image_renderer {
int image_renderer_register(struct image_renderer *ir);
void image_render_unregister(struct image_renderer *ir);
-int image_renderer_image(struct fb_info *info, struct image *img, void* fb,
- int startx, int starty, void* offscreenbuf);
+int image_renderer_image(struct screen *sc, struct surface *s, struct image *img);
struct image *image_renderer_open(const char* file);
void image_renderer_close(struct image *img);
@@ -54,12 +53,10 @@ static inline struct image *image_renderer_open(const char* file)
static inline void image_renderer_close(struct image *img) {}
-int image_renderer_image(struct fb_info *info, struct image *img, void* fb,
- int startx, int starty, void* offscreenbuf);
+int image_renderer_image(struct surface *s, struct image *img);
#endif
-static inline int image_renderer_file(struct fb_info *info, const char* file, void* fb,
- int startx, int starty, void* offscreenbuf)
+static inline int image_renderer_file(struct screen *sc, struct surface *s, const char* file)
{
struct image* img = image_renderer_open(file);
int ret;
@@ -67,8 +64,7 @@ static inline int image_renderer_file(struct fb_info *info, const char* file, vo
if (IS_ERR(img))
return PTR_ERR(img);
- ret = image_renderer_image(info, img, fb, startx, starty,
- offscreenbuf);
+ ret = image_renderer_image(sc, s, img);
image_renderer_close(img);