2 Example program using BltLib
4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/BltLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/UefiLib.h>
19 #include <Library/UefiApplicationEntryPoint.h>
20 #include <Library/UefiBootServicesTableLib.h>
41 TscBits
= Tsc2
^ Tsc1
;
42 Bits
= HighBitSet64 (TscBits
);
46 R32
= (R32
<< Bits
) | RShiftU64 (LShiftU64 (TscBits
, 64 - Bits
), 64 - Bits
);
59 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
68 BltLibGetSizes (&Width
, &Height
);
69 for (Loop
= 0; Loop
< 10000; Loop
++) {
70 W
= Width
- (Rand32 () % Width
);
71 H
= Height
- (Rand32 () % Height
);
73 X
= Rand32 () % (Width
- W
);
78 Y
= Rand32 () % (Height
- H
);
82 *(UINT32
*) (&Color
) = Rand32 () & 0xffffff;
83 BltLibVideoFill (&Color
, X
, Y
, W
, H
);
93 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
99 BltLibGetSizes (&Width
, &Height
);
100 *(UINT32
*) (&Color
) = 0;
102 for (Y
= 0; Y
< Height
; Y
++) {
103 for (X
= 0; X
< Width
; X
++) {
104 Color
.Red
= ((X
* 0x100) / Width
);
105 Color
.Green
= ((Y
* 0x100) / Height
);
106 Color
.Blue
= ((Y
* 0x100) / Height
);
107 BltLibVideoFill (&Color
, X
, Y
, 1, 1);
127 for (SqRt
= 0, Mask
= 1 << (HighBitSet32 (Uint32
) / 2);
131 SqRtMask
= SqRt
| Mask
;
132 //DEBUG ((EFI_D_INFO, "Uint32=0x%x SqRtMask=0x%x\n", Uint32, SqRtMask));
133 Squared
= (UINT32
) (SqRtMask
* SqRtMask
);
134 if (Squared
> Uint32
) {
136 } else if (Squared
< Uint32
) {
153 return Uint32SqRt ((X
* X
) + (Y
* Y
));
162 return (((TriWidth
- ColorDist
) * 0x100) / TriWidth
);
163 //return (((TriWidth * TriWidth - ColorDist * ColorDist) * 0x100) / (TriWidth * TriWidth));
171 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
175 UINTN LineWidth
, TriWidth
, ScreenWidth
;
176 UINTN TriHeight
, ScreenHeight
;
179 BltLibGetSizes (&ScreenWidth
, &ScreenHeight
);
180 *(UINT32
*) (&Color
) = 0;
181 BltLibVideoFill (&Color
, 0, 0, ScreenWidth
, ScreenHeight
);
183 TriWidth
= DivU64x32 (MultU64x32 (11547005, ScreenHeight
), 10000000);
184 TriHeight
= DivU64x32 (MultU64x32 (8660254, ScreenWidth
), 10000000);
185 if (TriWidth
> ScreenWidth
) {
186 DEBUG ((EFI_D_INFO
, "TriWidth at %d was too big\n", TriWidth
));
187 TriWidth
= ScreenWidth
;
188 } else if (TriHeight
> ScreenHeight
) {
189 DEBUG ((EFI_D_INFO
, "TriHeight at %d was too big\n", TriHeight
));
190 TriHeight
= ScreenHeight
;
193 DEBUG ((EFI_D_INFO
, "Triangle Width: %d; Height: %d\n", TriWidth
, TriHeight
));
195 X1
= (ScreenWidth
- TriWidth
) / 2;
196 X3
= X1
+ TriWidth
- 1;
198 Y2
= (ScreenHeight
- TriHeight
) / 2;
199 Y1
= Y2
+ TriHeight
- 1;
201 for (Y
= Y2
; Y
<= Y1
; Y
++) {
204 MultU64x32 (11547005, (Y
- Y2
)),
207 for (X
= X2
- LineWidth
; X
< (X2
+ LineWidth
); X
++) {
208 ColorDist
= Uint32Dist(X
- X1
, Y1
- Y
);
209 Color
.Red
= GetTriColor (ColorDist
, TriWidth
);
211 ColorDist
= Uint32Dist((X
< X2
) ? X2
- X
: X
- X2
, Y
- Y2
);
212 Color
.Green
= GetTriColor (ColorDist
, TriWidth
);
214 ColorDist
= Uint32Dist(X3
- X
, Y1
- Y
);
215 Color
.Blue
= GetTriColor (ColorDist
, TriWidth
);
217 BltLibVideoFill (&Color
, X
, Y
, 1, 1);
224 The user Entry Point for Application. The user code starts with this function
225 as the real entry point for the application.
227 @param[in] ImageHandle The firmware allocated handle for the EFI image.
228 @param[in] SystemTable A pointer to the EFI System Table.
230 @retval EFI_SUCCESS The entry point is executed successfully.
231 @retval other Some error occurs when executing this entry point.
237 IN EFI_HANDLE ImageHandle
,
238 IN EFI_SYSTEM_TABLE
*SystemTable
242 EFI_GRAPHICS_OUTPUT_PROTOCOL
*Gop
;
244 Status
= gBS
->HandleProtocol (
245 gST
->ConsoleOutHandle
,
246 &gEfiGraphicsOutputProtocolGuid
,
249 if (EFI_ERROR (Status
)) {
253 Status
= BltLibConfigure (
254 (VOID
*)(UINTN
) Gop
->Mode
->FrameBufferBase
,
257 if (EFI_ERROR (Status
)) {