19extern BOOLEAN mDisplayInitialized;
27VideoCopyNoHorizontalOverlap (
29 IN volatile VOID *FrameBufferBase,
30 IN UINT32 HorizontalResolution,
41 UINTN DestinationLine;
46 VOID *DestinationAddr;
50 if ( DestinationY <= SourceY ) {
53 DestinationLine = DestinationY;
57 SourceLine = SourceY + Height;
58 DestinationLine = DestinationY + Height;
62 switch (BitsPerPixel) {
63 case LcdBitsPerPixel_24:
65 WidthInBytes = Width * 4;
67 for ( LineCount = 0; LineCount < Height; LineCount++ ) {
69 SourceAddr = (VOID *)((UINT32 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX);
70 DestinationAddr = (VOID *)((UINT32 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
73 CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
77 DestinationLine += Step;
82 case LcdBitsPerPixel_16_555:
83 case LcdBitsPerPixel_16_565:
84 case LcdBitsPerPixel_12_444:
86 WidthInBytes = Width * 2;
88 for ( LineCount = 0; LineCount < Height; LineCount++ ) {
90 SourceAddr = (VOID *)((UINT16 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX);
91 DestinationAddr = (VOID *)((UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
94 CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
98 DestinationLine += Step;
103 case LcdBitsPerPixel_8:
104 case LcdBitsPerPixel_4:
105 case LcdBitsPerPixel_2:
106 case LcdBitsPerPixel_1:
109 DEBUG ((DEBUG_ERROR,
"ArmVeGraphics_Blt: EfiBltVideoToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
110 Status = EFI_INVALID_PARAMETER;
121VideoCopyHorizontalOverlap (
123 IN volatile VOID *FrameBufferBase,
124 UINT32 HorizontalResolution,
135 UINT32 *PixelBuffer32bit;
136 UINT32 *SourcePixel32bit;
137 UINT32 *DestinationPixel32bit;
139 UINT16 *PixelBuffer16bit;
140 UINT16 *SourcePixel16bit;
141 UINT16 *DestinationPixel16bit;
144 UINTN DestinationPixelY;
150 switch (BitsPerPixel) {
151 case LcdBitsPerPixel_24:
154 PixelBuffer32bit = (UINT32 *)
AllocatePool ((Height * Width) *
sizeof (UINT32));
156 if (PixelBuffer32bit ==
NULL) {
157 Status = EFI_OUT_OF_RESOURCES;
161 SizeIn32Bits = Width * 4;
164 for (SourcePixelY = SourceY, DestinationPixel32bit = PixelBuffer32bit;
165 SourcePixelY < SourceY + Height;
166 SourcePixelY++, DestinationPixel32bit += Width)
169 SourcePixel32bit = (UINT32 *)FrameBufferBase + SourcePixelY * HorizontalResolution + SourceX;
172 CopyMem ((VOID *)DestinationPixel32bit, (
CONST VOID *)SourcePixel32bit, SizeIn32Bits);
176 for (DestinationPixelY = DestinationY, SourcePixel32bit = PixelBuffer32bit;
177 DestinationPixelY < DestinationY + Height;
178 DestinationPixelY++, SourcePixel32bit += Width)
181 DestinationPixel32bit = (UINT32 *)FrameBufferBase + DestinationPixelY * HorizontalResolution + DestinationX;
184 CopyMem ((VOID *)DestinationPixel32bit, (
CONST VOID *)SourcePixel32bit, SizeIn32Bits);
188 FreePool ((VOID *)PixelBuffer32bit);
192 case LcdBitsPerPixel_16_555:
193 case LcdBitsPerPixel_16_565:
194 case LcdBitsPerPixel_12_444:
196 PixelBuffer16bit = (UINT16 *)
AllocatePool ((Height * Width) *
sizeof (UINT16));
198 if (PixelBuffer16bit ==
NULL) {
199 Status = EFI_OUT_OF_RESOURCES;
205 SizeIn16Bits = Width * 2;
207 for (SourcePixelY = SourceY, DestinationPixel16bit = PixelBuffer16bit;
208 SourcePixelY < SourceY + Height;
209 SourcePixelY++, DestinationPixel16bit += Width)
212 SourcePixel16bit = (UINT16 *)FrameBufferBase + SourcePixelY * HorizontalResolution + SourceX;
215 CopyMem ((VOID *)DestinationPixel16bit, (
CONST VOID *)SourcePixel16bit, SizeIn16Bits);
220 for (DestinationPixelY = DestinationY, SourcePixel16bit = PixelBuffer16bit;
221 DestinationPixelY < DestinationY + Height;
222 DestinationPixelY++, SourcePixel16bit += Width)
225 DestinationPixel16bit = (UINT16 *)FrameBufferBase + (DestinationPixelY * HorizontalResolution + DestinationX);
228 CopyMem ((VOID *)DestinationPixel16bit, (
CONST VOID *)SourcePixel16bit, SizeIn16Bits);
232 FreePool ((VOID *)PixelBuffer16bit);
236 case LcdBitsPerPixel_8:
237 case LcdBitsPerPixel_4:
238 case LcdBitsPerPixel_2:
239 case LcdBitsPerPixel_1:
242 DEBUG ((DEBUG_ERROR,
"ArmVeGraphics_Blt: EfiBltVideoToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
243 Status = EFI_INVALID_PARAMETER;
268 UINT32 HorizontalResolution;
270 VOID *FrameBufferBase;
271 VOID *DestinationAddr;
272 UINT16 *DestinationPixel16bit;
274 UINTN DestinationPixelX;
275 UINTN DestinationLine;
279 PixelInformation = &This->Mode->Info->PixelInformation;
280 FrameBufferBase = (
UINTN *)((
UINTN)(This->Mode->FrameBufferBase));
281 HorizontalResolution = This->Mode->Info->HorizontalResolution;
285 switch (BitsPerPixel) {
286 case LcdBitsPerPixel_24:
287 WidthInBytes = Width * 4;
290 for (DestinationLine = DestinationY;
291 DestinationLine < DestinationY + Height;
295 DestinationAddr = (VOID *)((UINT32 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
298 SetMem32 (DestinationAddr, WidthInBytes, *((UINT32 *)EfiSourcePixel));
303 case LcdBitsPerPixel_16_555:
305 Pixel16bit = (UINT16)(
306 ((EfiSourcePixel->Red << 7) & PixelInformation->RedMask)
307 | ((EfiSourcePixel->Green << 2) & PixelInformation->GreenMask)
308 | ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
313 for (DestinationLine = DestinationY;
314 DestinationLine < DestinationY + Height;
317 for (DestinationPixelX = DestinationX;
318 DestinationPixelX < DestinationX + Width;
322 DestinationPixel16bit = (UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationPixelX;
325 *DestinationPixel16bit = Pixel16bit;
331 case LcdBitsPerPixel_16_565:
333 Pixel16bit = (UINT16)(
334 ((EfiSourcePixel->Red << 8) & PixelInformation->RedMask)
335 | ((EfiSourcePixel->Green << 3) & PixelInformation->GreenMask)
336 | ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
340 for (DestinationLine = DestinationY;
341 DestinationLine < DestinationY + Height;
344 for (DestinationPixelX = DestinationX;
345 DestinationPixelX < DestinationX + Width;
349 DestinationPixel16bit = (UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationPixelX;
352 *DestinationPixel16bit = Pixel16bit;
358 case LcdBitsPerPixel_12_444:
360 Pixel16bit = (UINT16)(
361 ((EfiSourcePixel->Red >> 4) & PixelInformation->RedMask)
362 | ((EfiSourcePixel->Green) & PixelInformation->GreenMask)
363 | ((EfiSourcePixel->Blue << 4) & PixelInformation->BlueMask)
367 for (DestinationLine = DestinationY;
368 DestinationLine < DestinationY + Height;
371 for (DestinationPixelX = DestinationX;
372 DestinationPixelX < DestinationX + Width;
376 DestinationPixel16bit = (UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationPixelX;
379 *DestinationPixel16bit = Pixel16bit;
385 case LcdBitsPerPixel_8:
386 case LcdBitsPerPixel_4:
387 case LcdBitsPerPixel_2:
388 case LcdBitsPerPixel_1:
391 DEBUG ((DEBUG_ERROR,
"LcdGraphicsBlt: EfiBltVideoFill: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
392 Status = EFI_INVALID_PARAMETER;
414 UINT32 HorizontalResolution;
418 VOID *FrameBufferBase;
420 VOID *DestinationAddr;
421 UINT16 *SourcePixel16bit;
425 UINTN DestinationPixelX;
426 UINTN DestinationLine;
427 UINTN BltBufferHorizontalResolution;
431 PixelInformation = &This->Mode->Info->PixelInformation;
432 HorizontalResolution = This->Mode->Info->HorizontalResolution;
433 FrameBufferBase = (
UINTN *)((
UINTN)(This->Mode->FrameBufferBase));
440 BltBufferHorizontalResolution = Width;
445 switch (BitsPerPixel) {
446 case LcdBitsPerPixel_24:
447 WidthInBytes = Width * 4;
450 for (SourceLine = SourceY, DestinationLine = DestinationY;
451 SourceLine < SourceY + Height;
452 SourceLine++, DestinationLine++)
455 SourceAddr = (VOID *)((UINT32 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX);
456 DestinationAddr = (VOID *)((UINT32 *)BltBuffer + DestinationLine * BltBufferHorizontalResolution + DestinationX);
459 CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
464 case LcdBitsPerPixel_16_555:
466 for (SourceLine = SourceY, DestinationLine = DestinationY;
467 SourceLine < SourceY + Height;
468 SourceLine++, DestinationLine++)
470 for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
471 SourcePixelX < SourceX + Width;
472 SourcePixelX++, DestinationPixelX++)
475 SourcePixel16bit = (UINT16 *)FrameBufferBase + SourceLine * HorizontalResolution + SourcePixelX;
476 EfiDestinationPixel = BltBuffer + DestinationLine * BltBufferHorizontalResolution + DestinationPixelX;
480 Pixel16bit = *SourcePixel16bit;
483 EfiDestinationPixel->Red = (UINT8)((Pixel16bit & PixelInformation->RedMask) >> 7);
484 EfiDestinationPixel->Green = (UINT8)((Pixel16bit & PixelInformation->GreenMask) >> 2);
485 EfiDestinationPixel->Blue = (UINT8)((Pixel16bit & PixelInformation->BlueMask) << 3);
492 case LcdBitsPerPixel_16_565:
494 for (SourceLine = SourceY, DestinationLine = DestinationY;
495 SourceLine < SourceY + Height;
496 SourceLine++, DestinationLine++)
498 for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
499 SourcePixelX < SourceX + Width;
500 SourcePixelX++, DestinationPixelX++)
503 SourcePixel16bit = (UINT16 *)FrameBufferBase + SourceLine * HorizontalResolution + SourcePixelX;
504 EfiDestinationPixel = BltBuffer + DestinationLine * BltBufferHorizontalResolution + DestinationPixelX;
508 Pixel16bit = *SourcePixel16bit;
512 EfiDestinationPixel->Red = (UINT8)((Pixel16bit & PixelInformation->RedMask) >> 8);
513 EfiDestinationPixel->Green = (UINT8)((Pixel16bit & PixelInformation->GreenMask) >> 3);
514 EfiDestinationPixel->Blue = (UINT8)((Pixel16bit & PixelInformation->BlueMask) << 3);
521 case LcdBitsPerPixel_12_444:
523 for (SourceLine = SourceY, DestinationLine = DestinationY;
524 SourceLine < SourceY + Height;
525 SourceLine++, DestinationLine++)
527 for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
528 SourcePixelX < SourceX + Width;
529 SourcePixelX++, DestinationPixelX++)
532 SourcePixel16bit = (UINT16 *)FrameBufferBase + SourceLine * HorizontalResolution + SourcePixelX;
533 EfiDestinationPixel = BltBuffer + DestinationLine * BltBufferHorizontalResolution + DestinationPixelX;
537 Pixel16bit = *SourcePixel16bit;
540 EfiDestinationPixel->Red = (UINT8)((Pixel16bit & PixelInformation->RedMask) >> 4);
541 EfiDestinationPixel->Green = (UINT8)((Pixel16bit & PixelInformation->GreenMask));
542 EfiDestinationPixel->Blue = (UINT8)((Pixel16bit & PixelInformation->BlueMask) << 4);
549 case LcdBitsPerPixel_8:
550 case LcdBitsPerPixel_4:
551 case LcdBitsPerPixel_2:
552 case LcdBitsPerPixel_1:
555 DEBUG ((DEBUG_ERROR,
"LcdGraphicsBlt: EfiBltVideoToBltBuffer: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
556 Status = EFI_INVALID_PARAMETER;
578 UINT32 HorizontalResolution;
582 VOID *FrameBufferBase;
584 VOID *DestinationAddr;
585 UINT16 *DestinationPixel16bit;
588 UINTN DestinationPixelX;
589 UINTN DestinationLine;
590 UINTN BltBufferHorizontalResolution;
594 PixelInformation = &This->Mode->Info->PixelInformation;
595 HorizontalResolution = This->Mode->Info->HorizontalResolution;
596 FrameBufferBase = (
UINTN *)((
UINTN)(This->Mode->FrameBufferBase));
603 BltBufferHorizontalResolution = Width;
608 switch (BitsPerPixel) {
609 case LcdBitsPerPixel_24:
610 WidthInBytes = Width * 4;
613 for (SourceLine = SourceY, DestinationLine = DestinationY;
614 SourceLine < SourceY + Height;
615 SourceLine++, DestinationLine++)
618 SourceAddr = (VOID *)((UINT32 *)BltBuffer + SourceLine * BltBufferHorizontalResolution + SourceX);
619 DestinationAddr = (VOID *)((UINT32 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
622 CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
627 case LcdBitsPerPixel_16_555:
629 for (SourceLine = SourceY, DestinationLine = DestinationY;
630 SourceLine < SourceY + Height;
631 SourceLine++, DestinationLine++)
633 for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
634 SourcePixelX < SourceX + Width;
635 SourcePixelX++, DestinationPixelX++)
638 EfiSourcePixel = BltBuffer + SourceLine * BltBufferHorizontalResolution + SourcePixelX;
639 DestinationPixel16bit = (UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationPixelX;
644 *DestinationPixel16bit = (UINT16)(
645 ((EfiSourcePixel->Red << 7) & PixelInformation->RedMask)
646 | ((EfiSourcePixel->Green << 2) & PixelInformation->GreenMask)
647 | ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
655 case LcdBitsPerPixel_16_565:
657 for (SourceLine = SourceY, DestinationLine = DestinationY;
658 SourceLine < SourceY + Height;
659 SourceLine++, DestinationLine++)
661 for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
662 SourcePixelX < SourceX + Width;
663 SourcePixelX++, DestinationPixelX++)
666 EfiSourcePixel = BltBuffer + SourceLine * BltBufferHorizontalResolution + SourcePixelX;
667 DestinationPixel16bit = (UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationPixelX;
673 *DestinationPixel16bit = (UINT16)(
674 ((EfiSourcePixel->Red << 8) & PixelInformation->RedMask)
675 | ((EfiSourcePixel->Green << 3) & PixelInformation->GreenMask)
676 | ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
683 case LcdBitsPerPixel_12_444:
685 for (SourceLine = SourceY, DestinationLine = DestinationY;
686 SourceLine < SourceY + Height;
687 SourceLine++, DestinationLine++)
689 for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
690 SourcePixelX < SourceX + Width;
691 SourcePixelX++, DestinationPixelX++)
694 EfiSourcePixel = BltBuffer + SourceLine * BltBufferHorizontalResolution + SourcePixelX;
695 DestinationPixel16bit = (UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationPixelX;
700 *DestinationPixel16bit = (UINT16)(
701 ((EfiSourcePixel->Red << 4) & PixelInformation->RedMask)
702 | ((EfiSourcePixel->Green) & PixelInformation->GreenMask)
703 | ((EfiSourcePixel->Blue >> 4) & PixelInformation->BlueMask)
711 case LcdBitsPerPixel_8:
712 case LcdBitsPerPixel_4:
713 case LcdBitsPerPixel_2:
714 case LcdBitsPerPixel_1:
717 DEBUG ((DEBUG_ERROR,
"LcdGraphicsBlt: EfiBltBufferToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
718 Status = EFI_INVALID_PARAMETER;
740 UINT32 HorizontalResolution;
742 VOID *FrameBufferBase;
744 HorizontalResolution = This->Mode->Info->HorizontalResolution;
745 FrameBufferBase = (
UINTN *)((
UINTN)(This->Mode->FrameBufferBase));
754 FrameBufferBase = (
UINTN *)((
UINTN)(This->Mode->FrameBufferBase));
759 if ( SourceY == DestinationY ) {
761 if ( SourceX == DestinationX ) {
764 }
else if (((SourceX > DestinationX) ? (SourceX - DestinationX) : (DestinationX - SourceX)) < Width ) {
766 Status = VideoCopyHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height);
769 Status = VideoCopyNoHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height);
773 Status = VideoCopyNoHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height);
801 UINT32 HorizontalResolution;
802 UINT32 VerticalResolution;
805 Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
808 if (!mDisplayInitialized) {
809 Status = InitializeDisplay (Instance);
810 if (EFI_ERROR (Status)) {
815 HorizontalResolution = This->Mode->Info->HorizontalResolution;
816 VerticalResolution = This->Mode->Info->VerticalResolution;
819 if ((Width == 0) || (Height == 0)) {
820 DEBUG ((DEBUG_ERROR,
"LcdGraphicsBlt: ERROR - Invalid dimension: Zero size area.\n"));
821 Status = EFI_INVALID_PARAMETER;
826 ASSERT (BltBuffer !=
NULL);
837 if ((SourceY + Height > VerticalResolution) || (SourceX + Width > HorizontalResolution)) {
838 DEBUG ((DEBUG_INFO,
"LcdGraphicsBlt: ERROR - Invalid source resolution.\n"));
839 DEBUG ((DEBUG_INFO,
" - SourceY=%d + Height=%d > VerticalResolution=%d.\n", SourceY, Height, VerticalResolution));
840 DEBUG ((DEBUG_INFO,
" - SourceX=%d + Width=%d > HorizontalResolution=%d.\n", SourceX, Width, HorizontalResolution));
841 Status = EFI_INVALID_PARAMETER;
848 if ((DestinationY + Height > VerticalResolution) || (DestinationX + Width > HorizontalResolution)) {
849 DEBUG ((DEBUG_INFO,
"LcdGraphicsBlt: ERROR - Invalid destination resolution.\n"));
850 DEBUG ((DEBUG_INFO,
" - DestinationY=%d + Height=%d > VerticalResolution=%d.\n", DestinationY, Height, VerticalResolution));
851 DEBUG ((DEBUG_INFO,
" - DestinationX=%d + Width=%d > HorizontalResolution=%d.\n", DestinationX, Width, HorizontalResolution));
852 Status = EFI_INVALID_PARAMETER;
861 switch (BltOperation) {
863 Status = BltVideoFill (This, BltBuffer, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
867 Status = BltVideoToBltBuffer (This, BltBuffer, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
871 Status = BltBufferToVideo (This, BltBuffer, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
875 Status = BltVideoToVideo (This, BltBuffer, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
878 case EfiGraphicsOutputBltOperationMax:
880 DEBUG ((DEBUG_ERROR,
"LcdGraphicsBlt: Invalid Operation\n"));
881 Status = EFI_INVALID_PARAMETER;
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
EFI_GRAPHICS_OUTPUT_BLT_OPERATION
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)