18 UINT32 PixelsPerScanLine;
31 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
35 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
49 OUT UINT32 *BytesPerPixel,
58 ASSERT (BytesPerPixel !=
NULL);
61 Masks = (UINT32 *)BitMask;
62 for (Index = 0; Index < 3; Index++) {
63 ASSERT ((MergedMasks & Masks[Index]) == 0);
65 PixelShl[Index] = (INT8)
HighBitSet32 (Masks[Index]) - 23 + (Index * 8);
66 if (PixelShl[Index] < 0) {
67 PixelShr[Index] = -PixelShl[Index];
75 "%d: shl:%d shr:%d mask:%x\n",
82 MergedMasks = (UINT32)(MergedMasks | Masks[Index]);
85 MergedMasks = (UINT32)(MergedMasks | Masks[3]);
87 ASSERT (MergedMasks != 0);
88 *BytesPerPixel = (UINT32)((
HighBitSet32 (MergedMasks) + 7) / 8);
89 DEBUG ((DEBUG_INFO,
"Bytes per pixel: %d\n", *BytesPerPixel));
112 IN VOID *FrameBuffer,
119 UINT32 BytesPerPixel;
123 if (ConfigureSize ==
NULL) {
127 switch (FrameBufferInfo->PixelFormat) {
129 BitMask = &mRgbPixelMasks;
133 BitMask = &mBgrPixelMasks;
137 BitMask = &FrameBufferInfo->PixelInformation;
149 if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalResolution) {
156 + FrameBufferInfo->HorizontalResolution * BytesPerPixel)
159 + FrameBufferInfo->HorizontalResolution * BytesPerPixel;
163 if (Configure ==
NULL) {
167 CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));
168 CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl));
169 CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr));
170 Configure->BytesPerPixel = BytesPerPixel;
171 Configure->PixelFormat = FrameBufferInfo->PixelFormat;
172 Configure->FrameBuffer = (UINT8 *)FrameBuffer;
173 Configure->Width = FrameBufferInfo->HorizontalResolution;
174 Configure->Height = FrameBufferInfo->VerticalResolution;
175 Configure->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;
212 BOOLEAN LineBufferReady;
220 if (DestinationY + Height > Configure->Height) {
221 DEBUG ((DEBUG_VERBOSE,
"VideoFill: Past screen (Y)\n"));
225 if (DestinationX + Width > Configure->Width) {
226 DEBUG ((DEBUG_VERBOSE,
"VideoFill: Past screen (X)\n"));
230 if ((Width == 0) || (Height == 0)) {
231 DEBUG ((DEBUG_VERBOSE,
"VideoFill: Width or Height is 0\n"));
235 WidthInBytes = Width * Configure->BytesPerPixel;
237 Uint32 = *(UINT32 *)Color;
240 (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
241 Configure->PixelMasks.RedMask) |
242 (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
243 Configure->PixelMasks.GreenMask) |
244 (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
245 Configure->PixelMasks.BlueMask)
249 "VideoFill: color=0x%x, wide-fill=0x%x\n",
259 if ((
sizeof (WideFill) % Configure->BytesPerPixel) == 0) {
260 for (IndexX = Configure->BytesPerPixel; IndexX < sizeof (WideFill); IndexX++) {
261 ((UINT8 *)&WideFill)[IndexX] = ((UINT8 *)&WideFill)[IndexX % Configure->BytesPerPixel];
269 IndexX = 1, Uint8 = ((UINT8 *)&WideFill)[0];
270 IndexX < Configure->BytesPerPixel;
273 if (Uint8 != ((UINT8 *)&WideFill)[IndexX]) {
280 SetMem (&WideFill,
sizeof (WideFill), Uint8);
284 if (UseWideFill && (DestinationX == 0) && (Width == Configure->PixelsPerScanLine)) {
285 DEBUG ((DEBUG_VERBOSE,
"VideoFill (wide, one-shot)\n"));
286 Offset = DestinationY * Configure->PixelsPerScanLine;
287 Offset = Configure->BytesPerPixel * Offset;
288 Destination = Configure->FrameBuffer + Offset;
289 SizeInBytes = WidthInBytes * Height;
290 if (SizeInBytes >= 8) {
291 SetMem32 (Destination, SizeInBytes & ~3, (UINT32)WideFill);
292 Destination += SizeInBytes & ~3;
296 if (SizeInBytes > 0) {
297 SetMem (Destination, SizeInBytes, (UINT8)(
UINTN)WideFill);
300 LineBufferReady =
FALSE;
301 for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {
302 Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;
303 Offset = Configure->BytesPerPixel * Offset;
304 Destination = Configure->FrameBuffer + Offset;
306 if (UseWideFill && (((
UINTN)Destination & 7) == 0)) {
307 DEBUG ((DEBUG_VERBOSE,
"VideoFill (wide)\n"));
308 SizeInBytes = WidthInBytes;
309 if (SizeInBytes >= 8) {
310 SetMem64 (Destination, SizeInBytes & ~7, WideFill);
311 Destination += SizeInBytes & ~7;
315 if (SizeInBytes > 0) {
316 CopyMem (Destination, &WideFill, SizeInBytes);
319 DEBUG ((DEBUG_VERBOSE,
"VideoFill (not wide)\n"));
320 if (!LineBufferReady) {
321 CopyMem (Configure->LineBuffer, &WideFill, Configure->BytesPerPixel);
322 for (IndexX = 1; IndexX < Width; ) {
324 (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)),
325 Configure->LineBuffer,
326 MIN (IndexX, Width - IndexX) * Configure->BytesPerPixel
328 IndexX +=
MIN (IndexX, Width - IndexX);
331 LineBufferReady =
TRUE;
334 CopyMem (Destination, Configure->LineBuffer, WidthInBytes);
386 if (SourceY + Height > Configure->Height) {
390 if (SourceX + Width > Configure->Width) {
394 if ((Width == 0) || (Height == 0)) {
407 WidthInBytes = Width * Configure->BytesPerPixel;
412 for (SrcY = SourceY, DstY = DestinationY;
413 DstY < (Height + DestinationY);
416 Offset = (SrcY * Configure->PixelsPerScanLine) + SourceX;
417 Offset = Configure->BytesPerPixel * Offset;
418 Source = Configure->FrameBuffer + Offset;
423 Destination = Configure->LineBuffer;
426 CopyMem (Destination, Source, WidthInBytes);
429 for (IndexX = 0; IndexX < Width; IndexX++) {
431 ((UINT8 *)BltBuffer + (DstY * Delta) +
433 Uint32 = *(UINT32 *)(Configure->LineBuffer + (IndexX * Configure->BytesPerPixel));
436 (((Uint32 & Configure->PixelMasks.RedMask) >>
437 Configure->PixelShl[0]) << Configure->PixelShr[0]) |
438 (((Uint32 & Configure->PixelMasks.GreenMask) >>
439 Configure->PixelShl[1]) << Configure->PixelShr[1]) |
440 (((Uint32 & Configure->PixelMasks.BlueMask) >>
441 Configure->PixelShl[2]) << Configure->PixelShr[2])
494 if (DestinationY + Height > Configure->Height) {
498 if (DestinationX + Width > Configure->Width) {
502 if ((Width == 0) || (Height == 0)) {
515 WidthInBytes = Width * Configure->BytesPerPixel;
517 for (SrcY = SourceY, DstY = DestinationY;
518 SrcY < (Height + SourceY);
521 Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;
522 Offset = Configure->BytesPerPixel * Offset;
523 Destination = Configure->FrameBuffer + Offset;
528 for (IndexX = 0; IndexX < Width; IndexX++) {
535 Uint32 = *(UINT32 *)Blt;
536 *(UINT32 *)(Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)) =
538 (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
539 Configure->PixelMasks.RedMask) |
540 (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
541 Configure->PixelMasks.GreenMask) |
542 (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
543 Configure->PixelMasks.BlueMask)
547 Source = Configure->LineBuffer;
550 CopyMem (Destination, Source, WidthInBytes);
591 if (SourceY + Height > Configure->Height) {
595 if (SourceX + Width > Configure->Width) {
599 if (DestinationY + Height > Configure->Height) {
603 if (DestinationX + Width > Configure->Width) {
607 if ((Width == 0) || (Height == 0)) {
611 WidthInBytes = Width * Configure->BytesPerPixel;
613 Offset = (SourceY * Configure->PixelsPerScanLine) + SourceX;
614 Offset = Configure->BytesPerPixel * Offset;
615 Source = Configure->FrameBuffer + Offset;
617 Offset = (DestinationY * Configure->PixelsPerScanLine) + DestinationX;
618 Offset = Configure->BytesPerPixel * Offset;
619 Destination = Configure->FrameBuffer + Offset;
621 LineStride = Configure->BytesPerPixel * Configure->PixelsPerScanLine;
622 if (Destination > Source) {
626 Source += Height * LineStride;
627 Destination += Height * LineStride;
628 LineStride = -LineStride;
631 while (Height-- > 0) {
632 CopyMem (Destination, Source, WidthInBytes);
634 Source += LineStride;
635 Destination += LineStride;
683 if (Configure ==
NULL) {
687 switch (BltOperation) {
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
VOID *EFIAPI SetMem64(OUT VOID *Buffer, IN UINTN Length, IN UINT64 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID *EFIAPI SetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
RETURN_STATUS FrameBufferBltLibVideoToBltBuffer(IN FRAME_BUFFER_CONFIGURE *Configure, OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta)
RETURN_STATUS FrameBufferBltLibBufferToVideo(IN FRAME_BUFFER_CONFIGURE *Configure, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta)
RETURN_STATUS FrameBufferBltLibVideoToVideo(IN FRAME_BUFFER_CONFIGURE *Configure, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height)
RETURN_STATUS EFIAPI FrameBufferBlt(IN FRAME_BUFFER_CONFIGURE *Configure, IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta)
VOID FrameBufferBltLibConfigurePixelFormat(IN CONST EFI_PIXEL_BITMASK *BitMask, OUT UINT32 *BytesPerPixel, OUT INT8 *PixelShl, OUT INT8 *PixelShr)
RETURN_STATUS EFIAPI FrameBufferBltConfigure(IN VOID *FrameBuffer, IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, IN OUT FRAME_BUFFER_CONFIGURE *Configure, IN OUT UINTN *ConfigureSize)
EFI_STATUS FrameBufferBltLibVideoFill(IN FRAME_BUFFER_CONFIGURE *Configure, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height)
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_UNSUPPORTED
#define RETURN_INVALID_PARAMETER
#define DEBUG(Expression)
EFI_GRAPHICS_OUTPUT_BLT_OPERATION
EFI_GRAPHICS_PIXEL_FORMAT
@ PixelRedGreenBlueReserved8BitPerColor
@ PixelBlueGreenRedReserved8BitPerColor