aboutsummaryrefslogtreecommitdiffstats
path: root/src/framebuffer.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-06 05:58:46 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-06 05:58:46 +0200
commit3a9de46457dbd877bf12712fe85f398043bb7920 (patch)
tree75a389c69239704017706e6e99bf36d23ab040f3 /src/framebuffer.h
parentframebuffer.c: fb_count (diff)
downloadcrt-calibrator-3a9de46457dbd877bf12712fe85f398043bb7920.tar.gz
crt-calibrator-3a9de46457dbd877bf12712fe85f398043bb7920.tar.bz2
crt-calibrator-3a9de46457dbd877bf12712fe85f398043bb7920.tar.xz
drawing to the framebuffer
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/framebuffer.h')
-rw-r--r--src/framebuffer.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/framebuffer.h b/src/framebuffer.h
index d3f170e..1dffb82 100644
--- a/src/framebuffer.h
+++ b/src/framebuffer.h
@@ -20,6 +20,45 @@
#include <stddef.h>
+#include <stdint.h>
+
+
+/**
+ * Framebuffer information
+ */
+typedef struct framebuffer
+{
+ /**
+ * The file descriptor used to access the framebuffer, 0 if not opened
+ */
+ int fd;
+
+ /**
+ * The width of the display in pixels
+ */
+ uint32_t width;
+
+ /**
+ * The height of the display in pixels
+ */
+ uint32_t height;
+
+ /**
+ * Increment for `mem` to move to next pixel on the line
+ */
+ uint32_t bytes_per_pixel;
+
+ /**
+ * Increment for `mem` to move down one line but stay in the same column
+ */
+ uint32_t line_length;
+
+ /**
+ * Framebuffer pointer, `MAP_FAILED` (from <sys/mman.h>) if not mapped
+ */
+ int8_t* mem;
+
+} framebuffer_t;
/**
@@ -29,6 +68,27 @@
*/
size_t fb_count(void);
+/**
+ * Open a framebuffer
+ *
+ * @param index The index of the framebuffer to open
+ * @param fb Framevuffer information to fill in
+ * @return Zero on success, -1 on error
+ */
+int fb_open(size_t index, framebuffer_t* restrict fb);
+
+/**
+ * Close a framebuffer
+ *
+ * @param fb The framebuffer information
+ */
+void fb_close(framebuffer_t* restrict fb);
+
+uint32_t fb_colour(int red, int green, int blue);
+
+void fb_fill_rectangle(framebuffer_t* restrict fb, uint32_t colour,
+ uint32_t x, uint32_t y, uint32_t width, uint32_t height);
+
#endif