VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/Include/Library/GraphLib.h
blob: 49cea5ca00d0bb396befb45607d17c165bbce836 (plain)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/** @file
Graph library

Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
Copyright (c) 2016. VeraCrypt, Mounir IDRASSI 

This program and the accompanying materials are licensed and made available 
under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).

The full text of the license may be found at
https://opensource.org/licenses/LGPL-3.0
**/

#ifndef __GRAPHLIB_H__
#define __GRAPHLIB_H__

#include <Uefi.h>
#include <Protocol/GraphicsOutput.h>

//////////////////////////////////////////////////////////////////////////
// Graph
//////////////////////////////////////////////////////////////////////////

extern EFI_HANDLE* gGraphHandles;
extern UINTN       gGraphCount;
extern EFI_GRAPHICS_OUTPUT_PROTOCOL*	gGraphOut;

EFI_STATUS
InitGraph();

EFI_STATUS
GraphGetIO(
	IN    EFI_HANDLE								Handle,
	OUT   EFI_GRAPHICS_OUTPUT_PROTOCOL**	io
	);

EFI_STATUS
GraphGetModeInfo(
	IN    UINTN mode,
	OUT   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **info,
	OUT	UINTN* szInfo
	);

typedef struct _RECT {
	UINT32 left;
	UINT32 top;
	UINT32 right;
	UINT32 bottom;
} RECT, *PRECT;

#pragma pack(1)
typedef struct {
	UINT32   Width;
	UINT32   Height;
	RECT     Dirty;
	EFI_GRAPHICS_OUTPUT_BLT_PIXEL	 Pixels[0];
} BLT_HEADER;
#pragma pack()

enum DRAW_OPERATION {
	DrawOpSet = 0,
	DrawOpOr,
	DrawOpXor,
	DrawOpClear,
	DrawOpAlpha
};

typedef struct _DRAW_CONTEXT {
	EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
	UINT32	Op;
	UINT32	DashLine;
	UINT32	Alpha; //< 0..255
	EFI_GRAPHICS_OUTPUT_BLT_PIXEL AlphaColor;
	INT32*		Brush;		// brush points(default 1)
} DRAW_CONTEXT, *PDRAW_CONTEXT;

extern DRAW_CONTEXT	gDrawContext;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL gColorBlack;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL gColorWhite;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL gColorBlue;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL gColorGreen;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL gColorRed;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL gColorGray;
extern INT32 gBrush3[5 * 2];

EFI_STATUS
ScreenGetSize(
	OUT UINTN     *Height,
	OUT UINTN     *Width
	);

EFI_STATUS ScreenFillRect(
	IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *color,
	IN UINTN                         x,
	IN UINTN                         y,
	IN UINTN                         width,
	IN UINTN                         height
	);

EFI_STATUS ScreenDrawBlt(
	IN BLT_HEADER *blt,
	IN UINTN   x,
	IN UINTN   y
	);

EFI_STATUS
ScreenSaveBlt(
	OUT BLT_HEADER **bltScreen
	);

EFI_STATUS ScreenUpdateDirty(
	IN BLT_HEADER *blt
	);

EFI_STATUS
BltDrawBlt(
	IN OUT BLT_HEADER* canvas,
	IN BLT_HEADER* blt,
	IN UINTN x,
	IN UINTN y
	);

EFI_STATUS
RectMarkDirty(
	IN OUT PRECT rect,
	IN UINTN x,
	IN UINTN y
	);

EFI_STATUS
BltPoint(
	IN BLT_HEADER* blt,
	IN PDRAW_CONTEXT draw,
	IN UINTN x,
	IN UINTN y
	);

VOID
BltLine(
	IN BLT_HEADER* blt,
	IN PDRAW_CONTEXT draw,
	IN INT32 x0,
	IN INT32 y0,
	IN INT32 x1,
	IN INT32 y1);

VOID
BltBox(
	IN BLT_HEADER* blt,
	IN PDRAW_CONTEXT draw,
	IN INT32 x0,
	IN INT32 y0,
	IN INT32 x1,
	IN INT32 y1);

VOID
BltCircle(
	IN BLT_HEADER* blt,
	IN PDRAW_CONTEXT draw,
	IN INT32 xm,
	IN INT32 ym,
	IN INT32 r,
	IN BOOLEAN fill);

VOID
BltText(
	IN BLT_HEADER* blt,
	IN PDRAW_CONTEXT draw,
	IN INT32 x,
	IN INT32 y,
	IN INT32 scale, // 0..256 reduce 256... enlarge
	IN CONST CHAR8 *text);


EFI_STATUS
BmpGetSize(
	IN const unsigned char*      BmpImage,
	IN UINTN      BmpImageSize,
	OUT UINTN     *Height,
	OUT UINTN     *Width
	);

EFI_STATUS
BmpToBlt(
	IN CONST VOID      *BmpImage,
	IN  UINTN     BmpImageSize,
	OUT BLT_HEADER **blt
	);

VOID
BltFill(
	IN BLT_HEADER* blt,
	IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL	fill,
	IN INT32 x0,
	IN INT32 y0,
	IN INT32 x1,
	IN INT32 y1
	);

#endif