Subversion Repositories Kolibri OS

Rev

Rev 3584 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 1
/*
2
 * Copyright 2009 Vincent Sanders 
3
 *
4
 * This file is part of libnsfb, http://www.netsurf-browser.org/
5
 * Licenced under the MIT License,
6
 *                http://www.opensource.org/licenses/mit-license.php
7
 *
8
 * This is the exported interface for the libnsfb graphics library.
9
 */
10
 
11
#ifndef _LIBNSFB_H
12
#define _LIBNSFB_H 1
13
 
14
#include 
15
 
16
typedef struct nsfb_palette_s nsfb_palette_t;
17
typedef struct nsfb_cursor_s nsfb_cursor_t;
18
typedef struct nsfb_s nsfb_t;
19
typedef struct nsfb_event_s nsfb_event_t;
20
 
21
/** co-ordinate for plotting operations */
22
typedef struct nsfb_point_s {
23
    int x;
24
    int y;
25
} nsfb_point_t;
26
 
27
/** bounding box for plotting operations */
28
typedef struct nsfb_bbox_s {
29
    int x0;
30
    int y0;
31
    int x1;
32
    int y1;
33
} nsfb_bbox_t;
34
 
35
/** The type of framebuffer surface. */
36
enum nsfb_type_e {
37
    NSFB_SURFACE_NONE = 0, /**< No surface */
38
    NSFB_SURFACE_RAM, /**< RAM surface */
39
    NSFB_SURFACE_SDL, /**< SDL surface */
40
    NSFB_SURFACE_LINUX, /**< Linux framebuffer surface */
41
    NSFB_SURFACE_VNC, /**< VNC surface */
42
    NSFB_SURFACE_ABLE, /**< ABLE framebuffer surface */
3621 sourcerer 43
    NSFB_SURFACE_X, /**< X windows surface */
44
    NSFB_SURFACE_KOLIBRI
3584 sourcerer 45
};
46
 
47
enum nsfb_format_e {
48
    NSFB_FMT_ANY = 0, /* No specific format - use surface default */
49
    NSFB_FMT_XBGR8888, /* 32bpp Blue Green Red */
50
    NSFB_FMT_XRGB8888, /* 32bpp Red Green Blue */
51
    NSFB_FMT_ABGR8888, /* 32bpp Alpga Blue Green Red */
52
    NSFB_FMT_ARGB8888, /* 32bpp Alpga Red Green Blue */
53
    NSFB_FMT_RGB888, /* 24 bpp Alpga Red Green Blue */
54
    NSFB_FMT_ARGB1555, /* 16 bpp 555 */
55
    NSFB_FMT_RGB565, /* 16 bpp 565 */
56
    NSFB_FMT_I8, /* 8bpp indexed */
57
    NSFB_FMT_I4, /* 4bpp indexed */
58
    NSFB_FMT_I1, /* black and white */
59
};
60
 
61
/** Select frontend type from a name.
62
 *
63
 * @param name The name to select a frontend.
64
 * @return The surface type or NSFB_SURFACE_NONE if frontend with specified
65
 *         name was not available
66
 */
67
enum nsfb_type_e nsfb_type_from_name(const char *name);
68
 
69
/** Create a nsfb context.
70
 *
71
 * This creates a framebuffer surface context.
72
 *
73
 * @param surface_type The type of surface to create a context for.
74
 */
75
nsfb_t *nsfb_new(const enum nsfb_type_e surface_type);
76
 
77
/** Initialise selected surface context.
78
 *
79
 * @param nsfb The context returned from ::nsfb_init
80
 */
81
int nsfb_init(nsfb_t *nsfb);
82
 
83
/** Free nsfb context.
84
 *
85
 * This shuts down and releases all resources associated with an nsfb context.
86
 *
87
 * @param nsfb The context returned from ::nsfb_new to free
88
 */
89
int nsfb_free(nsfb_t *nsfb);
90
 
91
/** Claim an area of screen to be redrawn.
92
 *
93
 * Informs the nsfb library that an area of screen will be directly
94
 * updated by the user program. This is neccisarry so the library can
95
 * ensure the soft cursor plotting is correctly handled. After the
96
 * update has been perfomed ::nsfb_update should be called.
97
 *
98
 * @param box The bounding box of the area which might be altered.
99
 */
100
int nsfb_claim(nsfb_t *nsfb, nsfb_bbox_t *box);
101
 
102
/** Update an area of screen which has been redrawn.
103
 *
104
 * Informs the nsfb library that an area of screen has been directly
105
 * updated by the user program. Some surfaces only show the update on
106
 * notification. The area updated does not neccisarrily have to
107
 * corelate with a previous ::nsfb_claim bounding box, however if the
108
 * redrawn area is larger than the claimed area pointer plotting
109
 * artifacts may occour.
110
 *
111
 * @param box The bounding box of the area which has been altered.
112
 */
113
int nsfb_update(nsfb_t *nsfb, nsfb_bbox_t *box);
114
 
115
/** Obtain the geometry of a nsfb context.
116
 *
117
 * @param width a variable to store the framebuffer width in or NULL
118
 * @param height a variable to store the framebuffer height in or NULL
119
 * @param format a variable to store the framebuffer format in or NULL
120
 */
121
int nsfb_get_geometry(nsfb_t *nsfb, int *width, int *height, enum nsfb_format_e *format);
122
 
123
/** Alter the geometry of a surface
124
 *
125
 * @param nsfb The context to alter.
126
 * @param width The new display width.
127
 * @param height The new display height.
128
 * @param format The desired surface format.
129
 */
130
int nsfb_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format);
131
 
132
/** Set parameters a surface
133
 *
134
 * Some surface types can take additional parameters for
135
 * attributes. For example the linux surface uses this to allow the
136
 * setting of a different output device
137
 *
138
 * @param nsfb The surface to alter.
139
 * @param parameters The parameters for the surface.
140
 */
141
int nsfb_set_parameters(nsfb_t *nsfb, const char *parameters);
142
 
143
/** Obtain the buffer memory base and stride.
144
 *
145
 * @param nsfb The context to read.
146
 */
147
int nsfb_get_buffer(nsfb_t *nsfb, uint8_t **ptr, int *linelen);
148
 
149
/** Dump the surface to fd in PPM format
150
 */
151
bool nsfb_dump(nsfb_t *nsfb, int fd);
152
 
153
 
154
#endif
155
 
156
/*
157
 * Local variables:
158
 *  c-basic-offset: 4
159
 *  tab-width: 8
160
 * End:
161
 */