forked from kexecboot/kexecboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fb.h
134 lines (106 loc) · 2.92 KB
/
fb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* kexecboot - A kexec based bootloader
*
* Copyright (c) 2008-2011 Yuri Bushmelev <[email protected]>
* Copyright (c) 2008 Thomas Kunze <[email protected]>
* Copyright (c) 2006 Matthew Allum <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _HAVE_FB_H
#define _HAVE_FB_H
#include "config.h"
#ifdef USE_FBMENU
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "util.h"
#include "res/fonts/font.h"
#include "rgb.h"
typedef void (*plot_pixel_func)(int x, int y,
kx_rgba color);
typedef void (*draw_hline_func)(int x, int y, int length,
kx_rgba color);
typedef struct FB {
int fd;
int type;
int visual;
int width, height;
int bpp;
int depth; /* Color depth to enable 18bpp mode */
int byte_pp; /* Byte per pixel, 0 for bpp < 8 */
int stride;
char *data;
char *backbuffer;
char *base;
int screensize;
int angle;
int real_width, real_height;
enum RGBMode rgbmode;
int red_offset;
int red_length;
int green_offset;
int green_length;
int blue_offset;
int blue_length;
plot_pixel_func plot_pixel;
draw_hline_func draw_hline;
} FB;
FB fb;
/* Picture structure */
/* FIXME: store pixels as colors triplets per uint32_t value */
typedef struct {
unsigned int width; /* picture width */
unsigned int height; /* picture height */
kx_rgba *pixels; /* RGBA array */
} kx_picture;
void fb_destroy();
int fb_new(int angle);
#ifdef DEBUG
void print_fb();
#endif
void
fb_draw_rect(int x, int y,
int width, int height, kx_rgba rgba);
void
fb_draw_rounded_rect(int x, int y,
int width, int height, kx_rgba rgba);
/* Return text width and height in pixels. Will return 0,0 for empty text */
void
fb_text_size(int *width, int *height,
const Font * font, const char *text);
int
fb_draw_constrained_text(int x, int y,
int max_x, int max_y, kx_rgba rgba,
const Font * font, const char *text);
void
fb_draw_text(int x, int y, kx_rgba rgba,
const Font * font, const char *text);
/* Move backbuffer contents to videomemory */
void fb_render();
/* Save backbuffer contents to further usage */
char *fb_dump();
/* Restore saved backbuffer */
void fb_restore(char *dump);
/* Draw picture on framebuffer */
void fb_draw_picture(int x, int y, kx_picture *pic);
/* Free picture's data structure */
void fb_destroy_picture(kx_picture *pic);
#endif /* USE_FBMENU */
#endif /* _HAVE_FB_H */