summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2009-06-02 13:01:45 +0000
committerVincent Sanders <vince@netsurf-browser.org>2009-06-02 13:01:45 +0000
commit30edb722902dff842b5b9544f9b43846b93adc92 (patch)
treeade17d9dc0ec2985a82a767134d2f22c354d181b /include
parent3d5b21e1473dbdee6c3df66d9ba2a9d657f1b486 (diff)
downloadlibnsfb-30edb722902dff842b5b9544f9b43846b93adc92.tar.gz
libnsfb-30edb722902dff842b5b9544f9b43846b93adc92.tar.bz2
add cursor support
svn path=/trunk/libnsfb/; revision=7687
Diffstat (limited to 'include')
-rw-r--r--include/cursor.h36
-rw-r--r--include/frontend.h3
-rw-r--r--include/libnsfb.h10
-rw-r--r--include/libnsfb_cursor.h41
-rw-r--r--include/libnsfb_event.h2
-rw-r--r--include/libnsfb_plot.h5
-rw-r--r--include/libnsfb_plot_util.h8
-rw-r--r--include/nsfb.h5
-rw-r--r--include/nsfb_plot.h10
9 files changed, 111 insertions, 9 deletions
diff --git a/include/cursor.h b/include/cursor.h
new file mode 100644
index 0000000..d22d5e6
--- /dev/null
+++ b/include/cursor.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
+ *
+ * This file is part of libnsfb, http://www.netsurf-browser.org/
+ * Licenced under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * This is the *internal* interface for the cursor.
+ */
+
+#ifndef CURSOR_H
+#define CURSOR_H 1
+
+struct nsfb_cursor_s {
+ bool plotted;
+ nsfb_bbox_t loc;
+
+ /* current cursor image */
+ const nsfb_colour_t *pixel;
+ int bmp_width;
+ int bmp_height;
+ int bmp_stride;
+
+ /* current saved image */
+ nsfb_bbox_t savloc;
+ nsfb_colour_t *sav;
+ int sav_size;
+ int sav_width;
+ int sav_height;
+
+};
+
+/** plot the cursor saving the image underneath. */
+bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor);
+
+#endif /* CURSOR_H */
diff --git a/include/frontend.h b/include/frontend.h
index 9e5bedf..bf6fee6 100644
--- a/include/frontend.h
+++ b/include/frontend.h
@@ -17,6 +17,8 @@ typedef bool (nsfb_fendfn_input_t)(nsfb_t *nsfb, nsfb_event_t *event, int timeou
typedef int (nsfb_fendfn_claim_t)(nsfb_t *nsfb, nsfb_bbox_t *box);
/* frontend area release */
typedef int (nsfb_fendfn_release_t)(nsfb_t *nsfb, nsfb_bbox_t *box);
+/* frontend cursor display */
+typedef int (nsfb_fendfn_cursor_t)(nsfb_t *nsfb, struct nsfb_cursor_s *cursor);
typedef struct nsfb_frontend_rtns_s {
nsfb_fendfn_defaults_t *defaults;
@@ -26,6 +28,7 @@ typedef struct nsfb_frontend_rtns_s {
nsfb_fendfn_input_t *input;
nsfb_fendfn_claim_t *claim;
nsfb_fendfn_release_t *release;
+ nsfb_fendfn_cursor_t *cursor;
} nsfb_frontend_rtns_t;
void _nsfb_register_frontend(const enum nsfb_frontend_e type, const nsfb_frontend_rtns_t *rtns, const char *name);
diff --git a/include/libnsfb.h b/include/libnsfb.h
index c125ead..d828fca 100644
--- a/include/libnsfb.h
+++ b/include/libnsfb.h
@@ -92,11 +92,17 @@ int nsfb_release(nsfb_t *nsfb, nsfb_bbox_t *box);
*/
int nsfb_get_geometry(nsfb_t *nsfb, int *width, int *height, int *bpp);
-/** Alter a nsfb geometry
+/** Alter the geometry of a framebuffer context
+ *
+ * @param nsfb The context to alter.
+ * @param width The new display width.
+ * @param height The new display height.
+ * @param bpp The new display depth.
*/
int nsfb_set_geometry(nsfb_t *nsfb, int width, int height, int bpp);
-/** Obtain the framebuffer memory base and stride. */
+/** Obtain the framebuffer memory base and stride.
+ */
int nsfb_get_framebuffer(nsfb_t *nsfb, uint8_t **ptr, int *linelen);
#endif
diff --git a/include/libnsfb_cursor.h b/include/libnsfb_cursor.h
new file mode 100644
index 0000000..4f36793
--- /dev/null
+++ b/include/libnsfb_cursor.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
+ *
+ * This file is part of libnsfb, http://www.netsurf-browser.org/
+ * Licenced under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * This is the exported interface for the libnsfb graphics library.
+ */
+
+#ifndef _LIBNSFB_CURSOR_H
+#define _LIBNSFB_CURSOR_H 1
+
+/** Initialise the cursor.
+ */
+bool nsfb_cursor_init(nsfb_t *nsfb);
+
+/** Set cursor parameters.
+ *
+ * Set a cursor, the cursor will be shown at the specified location and
+ * size. The pixel data may be referenced untill the cursor is altered or
+ * cleared
+ *
+ * @param nsfb The frambuffer context.
+ * @param loc The location of the cursor
+ * @param pixel The pixel data for the cursor
+ */
+bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride);
+
+/** Set cursor location.
+ *
+ * @param nsfb The frambuffer context.
+ * @param loc The location of the cursor
+ */
+bool nsfb_cursor_loc_set(nsfb_t *nsfb, const nsfb_bbox_t *loc);
+
+/** get the cursor location */
+bool nsfb_cursor_loc_get(nsfb_t *nsfb, nsfb_bbox_t *loc);
+
+
+#endif
diff --git a/include/libnsfb_event.h b/include/libnsfb_event.h
index 0fa275e..5ad80f9 100644
--- a/include/libnsfb_event.h
+++ b/include/libnsfb_event.h
@@ -155,7 +155,7 @@ enum nsfb_key_code_e {
NSFB_KEY_EURO = 321,
NSFB_KEY_UNDO = 322,
- /* mouse keys */
+ /* mouse buttons */
NSFB_KEY_MOUSE_1 = 401,
NSFB_KEY_MOUSE_2 = 402,
NSFB_KEY_MOUSE_3 = 403,
diff --git a/include/libnsfb_plot.h b/include/libnsfb_plot.h
index 317ae95..4bb40fa 100644
--- a/include/libnsfb_plot.h
+++ b/include/libnsfb_plot.h
@@ -86,7 +86,7 @@ bool nsfb_plot_copy(nsfb_t *nsfb, int srcx, int srcy, int width, int height, int
/** Plot bitmap.
*/
-bool nsfb_plot_bitmap(nsfb_t *nsfb, nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha);
+bool nsfb_plot_bitmap(nsfb_t *nsfb, const nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha);
/** Plot an 8 bit glyph.
*/
@@ -97,4 +97,7 @@ bool nsfb_plot_glyph8(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int
*/
bool nsfb_plot_glyph1(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c);
+/* read rectangle into buffer */
+bool nsfb_plot_readrect(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t *buffer);
+
#endif /* _LIBNSFB_PLOT_H */
diff --git a/include/libnsfb_plot_util.h b/include/libnsfb_plot_util.h
index a1b0159..ee97b00 100644
--- a/include/libnsfb_plot_util.h
+++ b/include/libnsfb_plot_util.h
@@ -37,4 +37,12 @@ bool nsfb_plot_clip_line(const nsfb_bbox_t * restrict clip, nsfb_bbox_t * restri
bool nsfb_plot_clip_line_ctx(nsfb_t *nsfb, nsfb_bbox_t * restrict line);
+/** Obtain a bounding box which is the superset of two source boxes.
+ *
+ */
+bool nsfb_plot_add_rect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2, nsfb_bbox_t *result);
+
+/** Find if two boxes intersect. */
+bool nsfb_plot_bbox_intersect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2);
+
#endif /* _LIBNSFB_PLOT_UTIL_H */
diff --git a/include/nsfb.h b/include/nsfb.h
index cec4a63..7b28fcb 100644
--- a/include/nsfb.h
+++ b/include/nsfb.h
@@ -3,6 +3,7 @@
#include <stdint.h>
+
/** NS Framebuffer context
*/
struct nsfb_s {
@@ -17,10 +18,10 @@ struct nsfb_s {
int linelen; /**< length of a video line. */
nsfb_colour_t palette[256]; /**< palette for index modes */
- nsfb_cursor_t *cursor;
+ nsfb_cursor_t *cursor; /**< cursor */
struct nsfb_frontend_rtns_s *frontend_rtns; /**< frontend routines. */
- void *frontend_priv;
+ void *frontend_priv; /**< frontend opaque data. */
nsfb_bbox_t clip; /**< current clipping rectangle for plotters */
struct nsfb_plotter_fns_s *plotter_fns; /**< Plotter methods */
diff --git a/include/nsfb_plot.h b/include/nsfb_plot.h
index 718de6f..6574fad 100644
--- a/include/nsfb_plot.h
+++ b/include/nsfb_plot.h
@@ -60,7 +60,7 @@ typedef bool (nsfb_plotfn_ellipse_fill_t)(nsfb_t *nsfb, nsfb_bbox_t *ellipse, ns
/** Plot bitmap
*/
-typedef bool (nsfb_plotfn_bitmap_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha);
+typedef bool (nsfb_plotfn_bitmap_t)(nsfb_t *nsfb, const nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha);
/** Copy an area of screen
@@ -70,15 +70,18 @@ typedef bool (nsfb_plotfn_bitmap_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const nsfb_c
typedef bool (nsfb_plotfn_copy_t)(nsfb_t *nsfb, int srcx, int srcy, int width, int height, int dstx, int dsty);
-/** Plot an 8 bit glyph.
+/** Plot an 8 bit per pixel glyph.
*/
typedef bool (nsfb_plotfn_glyph8_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c);
-/** Plot an 1 bit glyph.
+/** Plot an 1 bit per pixel glyph.
*/
typedef bool (nsfb_plotfn_glyph1_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c);
+/** Read rectangle of screen into buffer
+ */
+typedef bool (nsfb_plotfn_readrect_t)(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t *buffer);
/** plotter function table. */
typedef struct nsfb_plotter_fns_s {
@@ -97,6 +100,7 @@ typedef struct nsfb_plotter_fns_s {
nsfb_plotfn_copy_t *copy;
nsfb_plotfn_glyph8_t *glyph8;
nsfb_plotfn_glyph1_t *glyph1;
+ nsfb_plotfn_readrect_t *readrect;
} nsfb_plotter_fns_t;