EE445M RTOS
Taken at the University of Texas Spring 2015
framebuffer.h
Go to the documentation of this file.
1 /* -*- mode: c; c-basic-offset: 4; -*- */
2 #ifndef __FRAMEBUFFER__
3 #define __FRAMEBUFFER__
4 
5 #include <stdarg.h>
6 #include "libstd/defines.h"
7 #include "libstd/nexus.h"
9 #include "libfont/font.h"
10 
11 /* OPTIMIZE: Pack this so we don't waste memory */
12 typedef char** framebuffer;
13 
19 framebuffer fb_init(void);
20 
27 
40 void fb_erase_string(framebuffer, point*, char*);
41 
54 inline
55 void fb_erase_string_anon(framebuffer fb, point* top_left_corner, char* string) {
56 
57  fb_erase_string(fb, top_left_corner, string);
58  free(top_left_corner);
59 }
60 
73 void fb_erase_char(framebuffer, point*, char);
74 
88 inline
89 void fb_erase_char_anon(framebuffer fb, point* top_left_corner, char c) {
90 
91  fb_erase_char_anon(fb, top_left_corner, c);
92  free(top_left_corner);
93 }
94 
104 private void _fb_draw_string(framebuffer, point*, char*);
105 
114 inline
115 void fb_draw_string(framebuffer fb, point* top_left_corner, char* string) {
116 
117  _fb_draw_string(fb, top_left_corner, string);
118 }
119 
129 inline
130 void fb_draw_string_anon_pt(framebuffer fb, point* top_left_corner, char* string) {
131 
132  _fb_draw_string(fb, top_left_corner, string);
133  free(top_left_corner);
134 }
135 
136 
146 private void _fb_draw_char(framebuffer, point*, char);
147 
158 
167 void fb_draw_shapes(framebuffer, ushort, ...);
168 
178 
188 
200 private void _fb_draw_shape(framebuffer, shape*, shade_t);
201 
211 inline void fb_erase_shape(framebuffer fb, shape* sh) {
212 
214 }
215 
228 
240 inline void fb_clear_pixel(framebuffer fb, uchar x, uchar y) {
241 
242  fb_set_pixel(fb, x, y, FB_COLOR_ERASE);
243 }
244 
256 inline void fb_erase_pixel(framebuffer fb, uchar x, uchar y) {
257 
258  fb_clear_pixel(fb, x, y);
259 }
260 
270 private void _fb_draw_line(framebuffer, point*, point*, shade_t);
271 
282 inline
283 void fb_erase_anon_line(framebuffer fb, point* point1, point* point2) {
284 
285  _fb_draw_line(fb, point1, point2, FB_COLOR_ERASE);
286  SHDestroyPoint(point1);
287  SHDestroyPoint(point2);
288 }
289 
298 inline
299 void fb_erase_line(framebuffer fb, point* point1, point* point2) {
300 
301  _fb_draw_line(fb, point1, point2, FB_COLOR_ERASE);
302 }
303 
314 inline
315 void fb_draw_anon_line(framebuffer fb, point* point1, point* point2, shade_t shade) {
316 
317  _fb_draw_line(fb, point1, point2, shade);
318  SHDestroyPoint(point1);
319  SHDestroyPoint(point2);
320 }
321 
332 inline
333 void fb_draw_line(framebuffer fb, point* point1, point* point2, shade_t shade) {
334 
335  _fb_draw_line(fb, point1, point2, shade);
336 }
337 
348  point* point1,
349  point* point2,
350  shade_t shade) {
351 
352  fb_draw_line(fb, point1, point2, shade);
353 }
354 
367 
377 inline void fb_draw_circle(framebuffer fb, circle* c) {
378 
379  fb_draw_ellipse(fb, c->center, c->radius, c->radius, c->center->shade);
380 }
381 
396 
408 
420 private
422 
435 
448 
463 
478 
480 /* private pixel_t _fb_pixel_width_of_long(long); */
481 /* private pixel_t _fb_pixel_height_of_long(long); */
482 /* private pixel_t _fb_pixel_width_of_string(char*); */
483 
484 #endif
void fb_erase_string(framebuffer, point *, char *)
Erase string on fb starting at top_left_corner.
Definition: framebuffer.c:260
void fb_draw_ellipse(framebuffer, point *, ushort, ushort, shade_t)
Draw an ellipse in fb at center with specified x- and y-radii of color shade.
Definition: framebuffer.c:147
void fb_erase_pixel(framebuffer fb, uchar x, uchar y)
Erase pixel (x,y) in .
Definition: framebuffer.h:256
ushort radius
Definition: shape.h:41
void fb_draw_string(framebuffer fb, point *top_left_corner, char *string)
Draw string on fb starting at top_left_corner.
Definition: framebuffer.h:115
Representation of a circle.
Definition: shape.h:37
Representation of a shape.
Definition: shape.h:26
private void _fb_draw_char(framebuffer, point *, char)
For internal use only.
Definition: framebuffer.c:283
shade_t shade
Definition: shape.h:18
void fb_draw_shape_arr(framebuffer, ushort, shape **)
Definition: framebuffer.c:68
private void _fb_draw_string(framebuffer, point *, char *)
For internal use only.
Definition: framebuffer.c:269
void fb_erase_string_anon(framebuffer fb, point *top_left_corner, char *string)
Erase string on fb starting at top_left_corner and free top_left_corner.
Definition: framebuffer.h:55
private void _fb_draw_shape(framebuffer, shape *, shade_t)
For internal use only.
Definition: framebuffer.c:39
void fb_console_println_coordinate(uchar, uchar, shade_t)
Print a coordinate (ordered pair) to the console followed by a newline.
Definition: framebuffer.c:327
point * center
Definition: shape.h:40
void fb_draw_string_anon_pt(framebuffer fb, point *top_left_corner, char *string)
Call fb_draw_string and destroy top_left_corner.
Definition: framebuffer.h:130
void fb_console_print_coordinate(uchar, uchar, shade_t)
Print a coordinate (ordered pair) to the console.
Definition: framebuffer.c:339
void fb_draw_shape(framebuffer, shape *)
Using as a canvas, draw .
Definition: framebuffer.c:31
void fb_destroy(framebuffer)
Destroy a framebuffer object.
Definition: framebuffer.c:22
private void _fb_fill_four_ellipse_points(framebuffer, point *, ushort, ushort)
Fill an ellipse on fb.
Definition: framebuffer.c:138
unsigned short ushort
Definition: defines.h:35
char ** framebuffer
Definition: framebuffer.h:12
void fb_draw_circle(framebuffer fb, circle *c)
Draw a circle in at with radius of color .
Definition: framebuffer.h:377
void fb_erase_char_anon(framebuffer fb, point *top_left_corner, char c)
Call and free .
Definition: framebuffer.h:89
unsigned char uchar
Definition: defines.h:34
#define FB_COLOR_ERASE
Definition: defines.h:81
void fb_draw_line(framebuffer fb, point *point1, point *point2, shade_t shade)
Draw a line segment on from to of color .to of color .shade.
Definition: framebuffer.h:333
framebuffer fb_init(void)
Create a framebuffer object and return the handle.
Definition: framebuffer.c:11
void fb_erase_anon_line(framebuffer fb, point *point1, point *point2)
Erases a line connecting two points before destroys the two points.
Definition: framebuffer.h:283
void fb_erase_char(framebuffer, point *, char)
Erase char on fb starting at top_left_corner.
Definition: framebuffer.c:96
void fb_draw_anon_line(framebuffer fb, point *point1, point *point2, shade_t shade)
Draws a line connecting two points before destroying the two points.
Definition: framebuffer.h:315
void fb_erase_shape(framebuffer fb, shape *sh)
Using as a canvas, draw .
Definition: framebuffer.h:211
void fb_erase_shape_arr(framebuffer, ushort, shape **)
Definition: framebuffer.c:76
void fb_draw_shapes(framebuffer, ushort,...)
Definition: framebuffer.c:56
void fb_draw_line_gradient(framebuffer fb, point *point1, point *point2, shade_t shade)
Draw a line segment on from to .
Definition: framebuffer.h:347
Representation of an ordered pair with a shade.
Definition: shape.h:13
private void _fb_draw_line(framebuffer, point *, point *, shade_t)
The heavy-lifter (pixel-setter) in line-segment-drawing.
Definition: framebuffer.c:105
void fb_console_println_point(point *)
Print a point (ordered pair) to the console followed by a newline.
Definition: framebuffer.c:304
void fb_draw_ellipse_fill(framebuffer, point *, ushort, ushort, shade_t)
Draw on fb a shaded ellipse described by center, x- and y-radii.
Definition: framebuffer.c:211
#define shade_t
Definition: defines.h:41
void fb_console_print_point(point *)
Print a point (ordered pair) to the console.
Definition: framebuffer.c:316
void fb_erase_line(framebuffer fb, point *point1, point *point2)
Remove a line segment on from to .
Definition: framebuffer.h:299
private void _fb_plot_four_ellipse_points(framebuffer, point *, ushort, ushort)
Plot on fb the four symmetric points on an ellipse described by a center and x- and y-offsets...
Definition: framebuffer.c:129
void fb_clear_pixel(framebuffer fb, uchar x, uchar y)
Clear pixel (x,y) in .
Definition: framebuffer.h:240
void fb_set_pixel(framebuffer, uchar, uchar, shade_t)
In fb, set pixel (x,y) to .
Definition: framebuffer.c:84