diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-01-11 15:16:39 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-01-24 15:06:39 +0800 |
commit | 1d71d0c777a2d1fe0bba7ed6d0a25b7b4c777dca (patch) | |
tree | 0b148eebdd3b21e2ca66214f9d493563513b2f92 | |
parent | 5af29d0d86c5ed700380f16f9bea3863784c0370 (diff) | |
download | edk2-1d71d0c777a2d1fe0bba7ed6d0a25b7b4c777dca.tar.gz edk2-1d71d0c777a2d1fe0bba7ed6d0a25b7b4c777dca.tar.bz2 edk2-1d71d0c777a2d1fe0bba7ed6d0a25b7b4c777dca.zip |
MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line buffer
https://bugzilla.tianocore.org/show_bug.cgi?id=339
The patch uses dynamic allocated line buffer to reduce memory usage
of frame buffer configure. (Original implementation uses 0x4000
bytes for line buffer.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
-rw-r--r-- | MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index 5f6eddcb38..011d9c52cd 100644 --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -26,12 +26,12 @@ struct FRAME_BUFFER_CONFIGURE { UINTN BytesPerPixel;
UINTN WidthInPixels;
UINTN Height;
- UINT8 LineBuffer[SIZE_4KB * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)];
UINT8 *FrameBuffer;
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
EFI_PIXEL_BITMASK PixelMasks;
INT8 PixelShl[4]; // R-G-B-Rsvd
INT8 PixelShr[4]; // R-G-B-Rsvd
+ UINT8 LineBuffer[0];
};
CONST EFI_PIXEL_BITMASK mRgbPixelMasks = {
@@ -123,15 +123,6 @@ FrameBufferBltConfigure ( return RETURN_INVALID_PARAMETER;
}
- if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)) {
- *ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE);
- return RETURN_BUFFER_TOO_SMALL;
- }
-
- if (Configure == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
-
switch (FrameBufferInfo->PixelFormat) {
case PixelRedGreenBlueReserved8BitPerColor:
BitMask = &mRgbPixelMasks;
@@ -156,6 +147,17 @@ FrameBufferBltConfigure ( FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl, PixelShr);
+ if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)
+ + FrameBufferInfo->HorizontalResolution * BytesPerPixel) {
+ *ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE)
+ + FrameBufferInfo->HorizontalResolution * BytesPerPixel;
+ return RETURN_BUFFER_TOO_SMALL;
+ }
+
+ if (Configure == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));
CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl));
CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr));
@@ -166,8 +168,6 @@ FrameBufferBltConfigure ( Configure->Height = (UINTN) FrameBufferInfo->VerticalResolution;
Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
- ASSERT (Configure->WidthInBytes < sizeof (Configure->LineBuffer));
-
return RETURN_SUCCESS;
}
|