]> code.delx.au - refind/blob - libeg/libeg.h
TianoCore build support; new use_graphics_for refind.conf token
[refind] / libeg / libeg.h
1 /*
2 * libeg/libeg.h
3 * EFI graphics library header for users
4 *
5 * Copyright (c) 2006 Christoph Pfisterer
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * Neither the name of Christoph Pfisterer nor the names of the
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #ifndef __LIBEG_LIBEG_H__
38 #define __LIBEG_LIBEG_H__
39
40 #ifndef __MAKEWITH_GNUEFI
41 #include "../include/tiano_includes.h"
42 #endif
43
44 /* types */
45
46 /* This should be compatible with EFI_UGA_PIXEL */
47 typedef struct {
48 UINT8 b, g, r, a;
49 } EG_PIXEL;
50
51 typedef struct {
52 UINTN Width;
53 UINTN Height;
54 BOOLEAN HasAlpha;
55 EG_PIXEL *PixelData;
56 } EG_IMAGE;
57
58 #define EG_EIPIXELMODE_GRAY (0)
59 #define EG_EIPIXELMODE_GRAY_ALPHA (1)
60 #define EG_EIPIXELMODE_COLOR (2)
61 #define EG_EIPIXELMODE_COLOR_ALPHA (3)
62 #define EG_EIPIXELMODE_ALPHA (4)
63 #define EG_MAX_EIPIXELMODE EG_EIPIXELMODE_ALPHA
64
65 #define EG_EICOMPMODE_NONE (0)
66 #define EG_EICOMPMODE_RLE (1)
67 #define EG_EICOMPMODE_EFICOMPRESS (2)
68
69 typedef struct {
70 UINTN Width;
71 UINTN Height;
72 UINTN PixelMode;
73 UINTN CompressMode;
74 const UINT8 *Data;
75 UINTN DataLength;
76 } EG_EMBEDDED_IMAGE;
77
78 /* functions */
79
80 VOID egInitScreen(VOID);
81 VOID egGetScreenSize(OUT UINTN *ScreenWidth, OUT UINTN *ScreenHeight);
82 CHAR16 * egScreenDescription(VOID);
83 BOOLEAN egHasGraphicsMode(VOID);
84 BOOLEAN egIsGraphicsModeEnabled(VOID);
85 VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable);
86 // NOTE: Even when egHasGraphicsMode() returns FALSE, you should
87 // call egSetGraphicsModeEnabled(FALSE) to ensure the system
88 // is running in text mode. egHasGraphicsMode() only determines
89 // if libeg can draw to the screen in graphics mode.
90
91 EG_IMAGE * egCreateImage(IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha);
92 EG_IMAGE * egCreateFilledImage(IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha, IN EG_PIXEL *Color);
93 EG_IMAGE * egCopyImage(IN EG_IMAGE *Image);
94 VOID egFreeImage(IN EG_IMAGE *Image);
95
96 EG_IMAGE * egLoadImage(IN EFI_FILE* BaseDir, IN CHAR16 *FileName, IN BOOLEAN WantAlpha);
97 EG_IMAGE * egLoadIcon(IN EFI_FILE* BaseDir, IN CHAR16 *FileName, IN UINTN IconSize);
98 EG_IMAGE * egDecodeImage(IN UINT8 *FileData, IN UINTN FileDataLength, IN CHAR16 *Format, IN BOOLEAN WantAlpha);
99 EG_IMAGE * egPrepareEmbeddedImage(IN EG_EMBEDDED_IMAGE *EmbeddedImage, IN BOOLEAN WantAlpha);
100
101 EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN UINTN Width, IN UINTN Height, IN EG_PIXEL *Color);
102
103 EFI_STATUS egLoadFile(IN EFI_FILE* BaseDir, IN CHAR16 *FileName,
104 OUT UINT8 **FileData, OUT UINTN *FileDataLength);
105 EFI_STATUS egSaveFile(IN EFI_FILE* BaseDir OPTIONAL, IN CHAR16 *FileName,
106 IN UINT8 *FileData, IN UINTN FileDataLength);
107
108 VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color);
109 VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
110 IN UINTN AreaPosX, IN UINTN AreaPosY,
111 IN UINTN AreaWidth, IN UINTN AreaHeight,
112 IN EG_PIXEL *Color);
113 VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN UINTN PosX, IN UINTN PosY);
114
115 VOID egMeasureText(IN CHAR16 *Text, OUT UINTN *Width, OUT UINTN *Height);
116 VOID egRenderText(IN CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN UINTN PosX, IN UINTN PosY);
117
118 VOID egClearScreen(IN EG_PIXEL *Color);
119 VOID egDrawImage(IN EG_IMAGE *Image, IN UINTN ScreenPosX, IN UINTN ScreenPosY);
120 VOID egDrawImageArea(IN EG_IMAGE *Image,
121 IN UINTN AreaPosX, IN UINTN AreaPosY,
122 IN UINTN AreaWidth, IN UINTN AreaHeight,
123 IN UINTN ScreenPosX, IN UINTN ScreenPosY);
124 VOID egDisplayMessage(IN CHAR16 *Text, EG_PIXEL *BGColor);
125 VOID egScreenShot(VOID);
126
127
128 #endif /* __LIBEG_LIBEG_H__ */
129
130 /* EOF */