From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8583081EE5 for ; Mon, 23 Jan 2017 00:36:43 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2017 00:36:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,273,1477983600"; d="scan'208";a="216478746" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 23 Jan 2017 00:36:43 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 23 Jan 2017 00:36:43 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 23 Jan 2017 00:36:43 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Mon, 23 Jan 2017 16:36:41 +0800 From: "Tian, Feng" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Tian, Feng" Thread-Topic: [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelBitMaskFormat Thread-Index: AQHSdT+f6Pwq2JCAA0yhz2XIindP0qFFvN2Q Date: Mon, 23 Jan 2017 08:36:40 +0000 Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699AB7D7@SHSMSX101.ccr.corp.intel.com> References: <20170123061149.279944-1-ruiyu.ni@intel.com> <20170123061149.279944-2-ruiyu.ni@intel.com> In-Reply-To: <20170123061149.279944-2-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelBitMaskFormat X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2017 08:36:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Feng Tian Thanks Feng -----Original Message----- From: Ni, Ruiyu=20 Sent: Monday, January 23, 2017 2:12 PM To: edk2-devel@lists.01.org Cc: Tian, Feng Subject: [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Refine ConfigurePixelB= itMaskFormat https://bugzilla.tianocore.org/show_bug.cgi?id=3D339 The patch refines ConfigurePixelBitMaskFormat() to prepare the enhancement = in next commit: Enhance this library to use dynamic allocated line buffer t= o reduce memory usage of frame buffer configure. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Feng Tian --- .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 71 +++++++++++++-----= ---- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/M= deModulePkg/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. =20 - Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2017, Intel Corporation. All rights=20 + reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e 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 }; =20 CONST EFI_PIXEL_BITMASK mRgbPixelMasks =3D { @@ -45,43 +45,47 @@ CONST EFI= _PIXEL_BITMASK mBgrPixelMasks =3D { /** Initialize the bit mask in frame buffer configure. =20 - @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; =20 + ASSERT (BytesPerPixel !=3D NULL); + MergedMasks =3D 0; Masks =3D (UINT32*) BitMask; - for (Loop =3D 0; Loop < 3; Loop++) { - ASSERT ((Loop =3D=3D 3) || (Masks[Loop] !=3D 0)); - ASSERT ((MergedMasks & Masks[Loop]) =3D=3D 0); - Configure->PixelShl[Loop] =3D HighBitSet32 (Masks[Loop]) - 23 + (Loop = * 8); - if (Configure->PixelShl[Loop] < 0) { - Configure->PixelShr[Loop] =3D -Configure->PixelShl[Loop]; - Configure->PixelShl[Loop] =3D 0; + for (Index =3D 0; Index < 3; Index++) { + ASSERT ((MergedMasks & Masks[Index]) =3D=3D 0); + + PixelShl[Index] =3D (INT8) HighBitSet32 (Masks[Index]) - 23 + (Index *= 8); + if (PixelShl[Index] < 0) { + PixelShr[Index] =3D -PixelShl[Index]; + PixelShl[Index] =3D 0; } else { - Configure->PixelShr[Loop] =3D 0; + PixelShr[Index] =3D 0; } - MergedMasks =3D (UINT32) (MergedMasks | Masks[Loop]); - DEBUG ((EFI_D_VERBOSE, "%d: shl:%d shr:%d mask:%x\n", Loop, - Configure->PixelShl[Loop], Configure->PixelShr[Loop], Masks[Lo= op])); + DEBUG ((DEBUG_INFO, "%d: shl:%d shr:%d mask:%x\n", Index, + PixelShl[Index], PixelShr[Index], Masks[Index])); + + MergedMasks =3D (UINT32) (MergedMasks | Masks[Index]); } MergedMasks =3D (UINT32) (MergedMasks | Masks[3]); =20 ASSERT (MergedMasks !=3D 0); - Configure->BytesPerPixel =3D (UINTN) ((HighBitSet32 (MergedMasks) + 7) /= 8); - - DEBUG ((EFI_D_VERBOSE, "Bytes per pixel: %d\n", Configure->BytesPerPixel= )); - - CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask)); + *BytesPerPixel =3D (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8); =20 + DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel)); } =20 /** @@ -110,6 +114,11 @@ FrameBufferBltConfigure ( IN OUT UINTN *ConfigureSize ) { + CONST EFI_PIXEL_BITMASK *BitMask; + UINTN BytesPerPixel; + INT8 PixelShl[4]; + INT8 PixelShr[4]; + if (ConfigureSize =3D=3D NULL) { return RETURN_INVALID_PARAMETER; } @@ -125,15 +134,15 @@ FrameBufferBltConfigure ( =20 switch (FrameBufferInfo->PixelFormat) { case PixelRedGreenBlueReserved8BitPerColor: - ConfigurePixelBitMaskFormat (Configure, &mRgbPixelMasks); + BitMask =3D &mRgbPixelMasks; break; =20 case PixelBlueGreenRedReserved8BitPerColor: - ConfigurePixelBitMaskFormat (Configure, &mBgrPixelMasks); + BitMask =3D &mBgrPixelMasks; break; =20 case PixelBitMask: - ConfigurePixelBitMaskFormat (Configure, &(FrameBufferInfo->PixelInform= ation)); + BitMask =3D &FrameBufferInfo->PixelInformation; break; =20 case PixelBltOnly: @@ -145,6 +154,12 @@ FrameBufferBltConfigure ( return RETURN_INVALID_PARAMETER; } =20 + FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel,=20 + PixelShl, PixelShr); + + CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask)); + CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl)); + CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr)); + Configure->BytesPerPixel =3D BytesPerPixel; Configure->PixelFormat =3D FrameBufferInfo->PixelFormat; Configure->FrameBuffer =3D (UINT8*) FrameBuffer; Configure->WidthInPixels =3D (UINTN) FrameBufferInfo->HorizontalResoluti= on; -- 2.9.0.windows.1