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 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelBitMaskFormat
Date: Mon, 23 Jan 2017 08:36:40 +0000	[thread overview]
Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699AB7D7@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20170123061149.279944-2-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 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelBitMaskFormat

https://bugzilla.tianocore.org/show_bug.cgi?id=339
The patch refines ConfigurePixelBitMaskFormat() to prepare the enhancement in next commit: Enhance this library to use dynamic allocated line buffer to reduce memory usage of frame buffer configure.

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  | 71 +++++++++++++---------
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
index c9bb206..5f6eddc 100644
--- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
@@ -1,7 +1,7 @@
 /** @file
   FrameBufferBltLib - Library to perform blt operations on a frame buffer.
 
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights 
+ reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at @@ -30,8 +30,8 @@ struct FRAME_BUFFER_CONFIGURE {
   UINT8                           *FrameBuffer;
   EFI_GRAPHICS_PIXEL_FORMAT       PixelFormat;
   EFI_PIXEL_BITMASK               PixelMasks;
-  INTN                            PixelShl[4]; // R-G-B-Rsvd
-  INTN                            PixelShr[4]; // R-G-B-Rsvd
+  INT8                            PixelShl[4]; // R-G-B-Rsvd
+  INT8                            PixelShr[4]; // R-G-B-Rsvd
 };
 
 CONST EFI_PIXEL_BITMASK mRgbPixelMasks = { @@ -45,43 +45,47 @@ CONST EFI_PIXEL_BITMASK mBgrPixelMasks = {
 /**
   Initialize the bit mask in frame buffer configure.
 
-  @param Configure  The frame buffer configure.
-  @param BitMask    The bit mask of pixel.
+  @param BitMask       The bit mask of pixel.
+  @param BytesPerPixel Size in bytes of pixel.
+  @param PixelShl      Left shift array.
+  @param PixelShr      Right shift array.
 **/
 VOID
-ConfigurePixelBitMaskFormat (
-  IN FRAME_BUFFER_CONFIGURE     *Configure,
-  IN CONST EFI_PIXEL_BITMASK    *BitMask
+FrameBufferBltLibConfigurePixelFormat (
+  IN CONST EFI_PIXEL_BITMASK    *BitMask,
+  OUT UINTN                     *BytesPerPixel,
+  OUT INT8                      *PixelShl,
+  OUT INT8                      *PixelShr
   )
 {
-  UINTN   Loop;
+  UINT8   Index;
   UINT32  *Masks;
   UINT32  MergedMasks;
 
+  ASSERT (BytesPerPixel != NULL);
+
   MergedMasks = 0;
   Masks = (UINT32*) BitMask;
-  for (Loop = 0; Loop < 3; Loop++) {
-    ASSERT ((Loop == 3) || (Masks[Loop] != 0));
-    ASSERT ((MergedMasks & Masks[Loop]) == 0);
-    Configure->PixelShl[Loop] = HighBitSet32 (Masks[Loop]) - 23 + (Loop * 8);
-    if (Configure->PixelShl[Loop] < 0) {
-      Configure->PixelShr[Loop] = -Configure->PixelShl[Loop];
-      Configure->PixelShl[Loop] = 0;
+  for (Index = 0; Index < 3; Index++) {
+    ASSERT ((MergedMasks & Masks[Index]) == 0);
+
+    PixelShl[Index] = (INT8) HighBitSet32 (Masks[Index]) - 23 + (Index * 8);
+    if (PixelShl[Index] < 0) {
+      PixelShr[Index] = -PixelShl[Index];
+      PixelShl[Index] = 0;
     } else {
-      Configure->PixelShr[Loop] = 0;
+      PixelShr[Index] = 0;
     }
-    MergedMasks = (UINT32) (MergedMasks | Masks[Loop]);
-    DEBUG ((EFI_D_VERBOSE, "%d: shl:%d shr:%d mask:%x\n", Loop,
-            Configure->PixelShl[Loop], Configure->PixelShr[Loop], Masks[Loop]));
+    DEBUG ((DEBUG_INFO, "%d: shl:%d shr:%d mask:%x\n", Index,
+            PixelShl[Index], PixelShr[Index], Masks[Index]));
+
+    MergedMasks = (UINT32) (MergedMasks | Masks[Index]);
   }
   MergedMasks = (UINT32) (MergedMasks | Masks[3]);
 
   ASSERT (MergedMasks != 0);
-  Configure->BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);
-
-  DEBUG ((EFI_D_VERBOSE, "Bytes per pixel: %d\n", Configure->BytesPerPixel));
-
-  CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));
+  *BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);  
+ DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel));
 }
 
 /**
@@ -110,6 +114,11 @@ FrameBufferBltConfigure (
   IN OUT UINTN                                 *ConfigureSize
   )
 {
+  CONST EFI_PIXEL_BITMASK                      *BitMask;
+  UINTN                                        BytesPerPixel;
+  INT8                                         PixelShl[4];
+  INT8                                         PixelShr[4];
+
   if (ConfigureSize == NULL) {
     return RETURN_INVALID_PARAMETER;
   }
@@ -125,15 +134,15 @@ FrameBufferBltConfigure (
 
   switch (FrameBufferInfo->PixelFormat) {
   case PixelRedGreenBlueReserved8BitPerColor:
-    ConfigurePixelBitMaskFormat (Configure, &mRgbPixelMasks);
+    BitMask = &mRgbPixelMasks;
     break;
 
   case PixelBlueGreenRedReserved8BitPerColor:
-    ConfigurePixelBitMaskFormat (Configure, &mBgrPixelMasks);
+    BitMask = &mBgrPixelMasks;
     break;
 
   case PixelBitMask:
-    ConfigurePixelBitMaskFormat (Configure, &(FrameBufferInfo->PixelInformation));
+    BitMask = &FrameBufferInfo->PixelInformation;
     break;
 
   case PixelBltOnly:
@@ -145,6 +154,12 @@ FrameBufferBltConfigure (
     return RETURN_INVALID_PARAMETER;
   }
 
+  FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, 
+ PixelShl, PixelShr);
+
+  CopyMem (&Configure->PixelMasks, BitMask,  sizeof (*BitMask));
+  CopyMem (Configure->PixelShl,    PixelShl, sizeof (PixelShl));
+  CopyMem (Configure->PixelShr,    PixelShr, sizeof (PixelShr));
+  Configure->BytesPerPixel = BytesPerPixel;
   Configure->PixelFormat   = FrameBufferInfo->PixelFormat;
   Configure->FrameBuffer   = (UINT8*) FrameBuffer;
   Configure->WidthInPixels = (UINTN) FrameBufferInfo->HorizontalResolution;
--
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 [this message]
2017-01-23  6:11 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Use dynamic allocated line buffer Ruiyu Ni
2017-01-23  8:36   ` Tian, Feng
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=7F1BAD85ADEA444D97065A60D2E97EE5699AB7D7@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