FrameBufferBltLib - Library to perform blt operations on a frame buffer.\r
\r
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include <Library/FrameBufferBltLib.h>\r
\r
struct FRAME_BUFFER_CONFIGURE {\r
- UINT32 WidthInBytes;\r
+ UINT32 PixelsPerScanLine;\r
UINT32 BytesPerPixel;\r
- UINT32 WidthInPixels;\r
+ UINT32 Width;\r
UINT32 Height;\r
UINT8 *FrameBuffer;\r
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
+ if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalResolution) {\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
+\r
FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl, PixelShr);\r
\r
if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)\r
CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));\r
CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl));\r
CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr));\r
- Configure->BytesPerPixel = BytesPerPixel;\r
- Configure->PixelFormat = FrameBufferInfo->PixelFormat;\r
- Configure->FrameBuffer = (UINT8*) FrameBuffer;\r
- Configure->WidthInPixels = FrameBufferInfo->HorizontalResolution;\r
- Configure->Height = FrameBufferInfo->VerticalResolution;\r
- Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;\r
+ Configure->BytesPerPixel = BytesPerPixel;\r
+ Configure->PixelFormat = FrameBufferInfo->PixelFormat;\r
+ Configure->FrameBuffer = (UINT8*) FrameBuffer;\r
+ Configure->Width = FrameBufferInfo->HorizontalResolution;\r
+ Configure->Height = FrameBufferInfo->VerticalResolution;\r
+ Configure->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;\r
\r
return RETURN_SUCCESS;\r
}\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
- if (DestinationX + Width > Configure->WidthInPixels) {\r
+ if (DestinationX + Width > Configure->Width) {\r
DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (X)\n"));\r
return RETURN_INVALID_PARAMETER;\r
}\r
}\r
}\r
\r
- if (UseWideFill && (DestinationX == 0) && (Width == Configure->WidthInPixels)) {\r
+ if (UseWideFill && (DestinationX == 0) && (Width == Configure->PixelsPerScanLine)) {\r
DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n"));\r
- Offset = DestinationY * Configure->WidthInPixels;\r
+ Offset = DestinationY * Configure->PixelsPerScanLine;\r
Offset = Configure->BytesPerPixel * Offset;\r
Destination = Configure->FrameBuffer + Offset;\r
SizeInBytes = WidthInBytes * Height;\r
if (SizeInBytes >= 8) {\r
SetMem32 (Destination, SizeInBytes & ~3, (UINT32) WideFill);\r
+ Destination += SizeInBytes & ~3;\r
SizeInBytes &= 3;\r
}\r
if (SizeInBytes > 0) {\r
} else {\r
LineBufferReady = FALSE;\r
for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {\r
- Offset = (IndexY * Configure->WidthInPixels) + DestinationX;\r
+ Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;\r
Offset = Configure->BytesPerPixel * Offset;\r
Destination = Configure->FrameBuffer + Offset;\r
\r
SizeInBytes = WidthInBytes;\r
if (SizeInBytes >= 8) {\r
SetMem64 (Destination, SizeInBytes & ~7, WideFill);\r
+ Destination += SizeInBytes & ~7;\r
SizeInBytes &= 7;\r
}\r
if (SizeInBytes > 0) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
- if (SourceX + Width > Configure->WidthInPixels) {\r
+ if (SourceX + Width > Configure->Width) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
DstY < (Height + DestinationY);\r
SrcY++, DstY++) {\r
\r
- Offset = (SrcY * Configure->WidthInPixels) + SourceX;\r
+ Offset = (SrcY * Configure->PixelsPerScanLine) + SourceX;\r
Offset = Configure->BytesPerPixel * Offset;\r
Source = Configure->FrameBuffer + Offset;\r
\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
- if (DestinationX + Width > Configure->WidthInPixels) {\r
+ if (DestinationX + Width > Configure->Width) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
SrcY < (Height + SourceY);\r
SrcY++, DstY++) {\r
\r
- Offset = (DstY * Configure->WidthInPixels) + DestinationX;\r
+ Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;\r
Offset = Configure->BytesPerPixel * Offset;\r
Destination = Configure->FrameBuffer + Offset;\r
\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
- if (SourceX + Width > Configure->WidthInPixels) {\r
+ if (SourceX + Width > Configure->Width) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
- if (DestinationX + Width > Configure->WidthInPixels) {\r
+ if (DestinationX + Width > Configure->Width) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
\r
\r
WidthInBytes = Width * Configure->BytesPerPixel;\r
\r
- Offset = (SourceY * Configure->WidthInPixels) + SourceX;\r
+ Offset = (SourceY * Configure->PixelsPerScanLine) + SourceX;\r
Offset = Configure->BytesPerPixel * Offset;\r
Source = Configure->FrameBuffer + Offset;\r
\r
- Offset = (DestinationY * Configure->WidthInPixels) + DestinationX;\r
+ Offset = (DestinationY * Configure->PixelsPerScanLine) + DestinationX;\r
Offset = Configure->BytesPerPixel * Offset;\r
Destination = Configure->FrameBuffer + Offset;\r
\r
- LineStride = Configure->WidthInBytes;\r
+ LineStride = Configure->BytesPerPixel * Configure->PixelsPerScanLine;\r
if (Destination > Source) {\r
//\r
// Copy from last line to avoid source is corrupted by copying\r