Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/Libeg/libeg.h

  • Property svn:executable set to *
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
41/* types */
42
43/* This should be compatible with EFI_UGA_PIXEL */
44typedef struct {
45 UINT8 b, g, r, a;
46} EG_PIXEL;
47
48typedef struct {
49 UINTN Width;
50 UINTN Height;
51 BOOLEAN HasAlpha;
52 EG_PIXEL *PixelData;
53 BOOLEAN NeedFlip;
54 UINTNpiChannels;
55} EG_IMAGE;
56
57#define EG_EIPIXELMODE_GRAY (0)
58#define EG_EIPIXELMODE_GRAY_ALPHA (1)
59#define EG_EIPIXELMODE_COLOR (2)
60#define EG_EIPIXELMODE_COLOR_ALPHA (3)
61#define EG_EIPIXELMODE_ALPHA (4)
62#define EG_MAX_EIPIXELMODE EG_EIPIXELMODE_ALPHA
63
64#define EG_EICOMPMODE_NONE (0)
65#define EG_EICOMPMODE_RLE (1)
66#define EG_EICOMPMODE_EFICOMPRESS (2)
67
68typedef struct {
69 UINTN Width;
70 UINTN Height;
71 UINTN PixelMode;
72 UINTN CompressMode;
73 const UINT8 *Data;
74 UINTN DataLength;
75} EG_EMBEDDED_IMAGE;
76
77/* functions */
78
79VOID egInitScreen(VOID);
80VOID egGetScreenSize(OUT UINTN *ScreenWidth, OUT UINTN *ScreenHeight);
81CHAR16 * egScreenDescription(VOID);
82BOOLEAN egHasGraphicsMode(VOID);
83BOOLEAN egIsGraphicsModeEnabled(VOID);
84VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable);
85
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// ADDITIONAL NOTE: As for UEFI, you should also do this in chameleon, egHasGraphicsMode()
91// only return a boolean set in egInitScreen(), and do not check if graphic mode is really enabled
92
93EG_IMAGE * egCreateImage(IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha);
94EG_IMAGE * egCreateFilledImage(IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha, IN EG_PIXEL *Color);
95EG_IMAGE * egNewImageFromImage(IN EG_IMAGE *Image);
96VOID egCopyImage(IN OUT EG_IMAGE *Image1, IN EG_IMAGE *Image2);
97EG_IMAGE * egCreateImageFromData(IN EG_PIXEL *PixelData, IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha, BOOLEAN FlipDone);
98EG_IMAGE * egNewScaledImage(IN EG_IMAGE *Image, IN UINTN NewW, IN UINTN NewH);
99VOID egCopyScaledImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *Image);
100VOID egFreeImage(IN EG_IMAGE *Image);
101EG_IMAGE * egLoadImage(IN CHAR16 *FilePath, IN BOOLEAN WantAlpha);
102EG_IMAGE * egLoadIcon(IN CHAR16 *FilePath, IN UINTN IconSize);
103EG_IMAGE * egDecodeImage(IN UINT8 *FileData, IN UINTN FileDataLength, IN CHAR16 *Format, IN BOOLEAN WantAlpha);
104
105EG_IMAGE * egPrepareEmbeddedImage(IN EG_EMBEDDED_IMAGE *EmbeddedImage, IN BOOLEAN WantAlpha);
106EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN UINTN Width, IN UINTN Height, IN EG_PIXEL *Color);
107
108EFI_STATUS egLoadFile(IN CHAR16 *FileName,
109 OUT UINT8 **FileData, OUT UINTN *FileDataLength);
110/*
111EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName,
112 IN UINT8 *FileData, IN UINTN FileDataLength);
113*/
114VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color);
115VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
116 IN UINTN AreaPosX, IN UINTN AreaPosY,
117 IN UINTN AreaWidth, IN UINTN AreaHeight,
118 IN EG_PIXEL *Color);
119VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN UINTN PosX, IN UINTN PosY);
120
121VOID egMeasureText(IN CHAR16 *Text, OUT UINTN *Width, OUT UINTN *Height);
122VOID egRenderText(IN CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN UINTN PosX, IN UINTN PosY);
123
124VOID egClearScreen(IN EG_PIXEL *Color);
125VOID egDrawImage(IN EG_IMAGE *Image, IN UINTN ScreenPosX, IN UINTN ScreenPosY);
126
127VOID egDrawImageArea(IN EG_IMAGE *Image,
128 IN UINTN AreaPosX, IN UINTN AreaPosY,
129 IN UINTN AreaWidth, IN UINTN AreaHeight,
130 IN UINTN ScreenPosX, IN UINTN ScreenPosY);
131
132EG_IMAGE * egScreenShot(VOID);
133
134VOID egVramWrite (IN VOID *data, IN UINTN width, IN UINTN Height, IN UINTN PosX, IN UINTN PosY, UINTN BytesPerScanLine);
135
136
137/*
138 * Image View structure.
139 */
140typedef struct {
141EG_IMAGE*Image;
142CHAR16*Name;
143 UINTN PosX;
144 UINTN PosY;
145} EG_IMAGE_VIEW;
146
147EG_IMAGE_VIEW * egCreateImageView(IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha, IN UINTN PosX, IN UINTN PosY, IN CHAR16 *Name);
148
149EG_IMAGE_VIEW * egCreateImageViewFromData(IN EG_PIXEL *PixelData, IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha, IN UINTN PosX, IN UINTN PosY, IN CHAR16 *Name, BOOLEAN NeedFlip);
150
151VOID egFreeImageView(IN EG_IMAGE_VIEW *ImageView);
152
153/*
154 * View structure.
155 */
156typedef struct {
157 EG_IMAGE *CompImage;
158EG_IMAGE *Background;
159 UT_array *Array; // Arrey of image View
160BOOLEANisDirty;
161 BOOLEAN AutoUpdate;
162 BOOLEAN useBackgroundColor;
163} EG_VIEW;
164
165
166
167
168VOID egViewBufferUpdate(IN OUT EG_VIEW *View);
169VOID egViewUpdate(IN OUT EG_VIEW *View);
170EG_VIEW * egCreateView(IN UINTN Width, IN UINTN Height, IN BOOLEAN HasAlpha);
171VOID egFreeView(IN EG_VIEW *View);
172VOID egViewSetBackgroundColor(IN OUT EG_VIEW *CompView, IN EG_PIXEL *Color);
173VOID egViewSetBackground(IN OUT EG_VIEW *CompView, IN EG_IMAGE *Background);
174EG_IMAGE_VIEW * egViewAddImageView(IN OUT EG_VIEW *CompView, IN EG_IMAGE_VIEW *TopView);
175VOID egViewRemoveImageViewByName(IN OUT EG_VIEW *CompView, IN CHAR16 *Name, IN UINTN NameSize);
176VOID egViewRemoveImageView(IN OUT EG_VIEW *CompView, IN EG_IMAGE_VIEW *ImageView);
177EG_PIXEL * egViewGetBackgroundColor(IN OUT EG_VIEW *CompView);
178VOID egViewSetUpdateValue(IN OUT EG_VIEW *View, IN BOOLEAN AutoUpdate);
179BOOLEAN egViewGetUpdateValue(IN OUT EG_VIEW *View);
180VOID egViewSetDirtyValue(IN OUT EG_VIEW *View, IN BOOLEAN Dirty);
181BOOLEAN egViewGetDirtyValue(IN OUT EG_VIEW *View);
182VOID egUseBackgroundColor(IN OUT EG_VIEW *CompView, IN BOOLEAN Use);
183
184#endif /* __LIBEG_LIBEG_H__ */
185
186/* EOF */
187

Archive Download this file

Revision: 2182