-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreen.h
77 lines (62 loc) · 1.55 KB
/
screen.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
#ifndef SCREEN_H
#define SCREEN_H
#include <efi.h>
#include <efilib.h>
#include "config.h"
#include "basic_types.h"
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
/**
* \brief
* Represents a color in the blue-green-red-reserved format we demand
* of the video driver.
*/
typedef struct bgr {
UINT8 blue;
UINT8 green;
UINT8 red;
UINT8 unused;
} bgr;
/**
* \brief
* Some predetermined colors.
*/
extern const bgr WHITE, RED, BLUE, GREEN, BLACK;
/**
* \brief
* A more compact way of creating a BGR color.
*/
#define BGR(b, g, r) (bgr) { .blue = (b), .green = (g), .red = (r), .unused = 0 }
typedef struct mock_vram_t {
bgr data[SCREEN_WIDTH * SCREEN_HEIGHT];
} mock_vram_t;
extern mock_vram_t SCREEN_BUFFER;
/**
* \brief
* The linear framebuffer and its associated metadata.
*/
typedef struct LFB {
bgr * const pixels;
bgr * const buffer;
UINTN const width, height, pixels_per_scanline;
} LFB;
#define SET_PIXEL_INTERNAL(lfb, x, y, color, member) (lfb)->member[(x) + (lfb)->width * (y)] = (color)
#define SET_SCREEN_PIXEL(lfb, x, y, color) SET_PIXEL_INTERNAL(lfb, x, y, color, pixels)
#define SET_BUFFER_PIXEL(lfb, x, y, color) SET_PIXEL_INTERNAL(lfb, x, y, color, buffer)
LFB load_lfb(EFI_STATUS * status);
/**
* \brief
* Fills a rectangle in the buffer.
*/
void fill_rect(LFB * const lfb, rect rect, bgr color);
/**
* \brief
* Copies the buffer into the real vram.
*/
void screen_buffer_copy(LFB * const lfb);
/**
* \brief
* Clears the screen with a given color.
*/
void screen_buffer_clear(LFB * const lfb, bgr color);
#endif