public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tian, Feng" <feng.tian@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Tian, Feng" <feng.tian@intel.com>
Subject: Re: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line buffer
Date: Mon, 23 Jan 2017 08:36:36 +0000	[thread overview]
Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699AB7C7@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20170123061149.279944-3-ruiyu.ni@intel.com>

Reviewed-by: Feng Tian <feng.tian@intel.com>

Thanks
Feng

-----Original Message-----
From: Ni, Ruiyu 
Sent: Monday, January 23, 2017 2:12 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.tian@intel.com>
Subject: [PATCH 2/3] 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>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Library/FrameBufferBltLib/FrameBufferBltLib.c  | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
index 5f6eddc..011d9c5 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;
 }
 
--
2.9.0.windows.1



  reply	other threads:[~2017-01-23  8:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23  6:11 [PATCH 0/3] MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line buffer Ruiyu Ni
2017-01-23  6:11 ` [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelBitMaskFormat Ruiyu Ni
2017-01-23  8:36   ` Tian, Feng
2017-01-23  6:11 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line buffer Ruiyu Ni
2017-01-23  8:36   ` Tian, Feng [this message]
2017-01-23  6:11 ` [PATCH 3/3] OvmfPkg/QemuVideoDxe: Frame buffer config size may change in new mode Ruiyu Ni
2017-01-23 10:45   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7F1BAD85ADEA444D97065A60D2E97EE5699AB7C7@SHSMSX101.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox