From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (unknown [134.134.136.20]) (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 0BEBA221F93A9 for ; Mon, 15 Jan 2018 21:13:02 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2018 21:18:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,366,1511856000"; d="scan'208";a="20127941" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jan 2018 21:18:20 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 15 Jan 2018 21:18:20 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 15 Jan 2018 21:18:19 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Tue, 16 Jan 2018 13:18:17 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: Christian Ehrhardt , "Zeng, Star" Thread-Topic: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted Thread-Index: AQHTjbNoJ1UNmXiZTkevNejMTehSJ6N191Wg Date: Tue, 16 Jan 2018 05:18:16 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9FC6AD@shsmsx102.ccr.corp.intel.com> References: <20180115034612.381104-1-ruiyu.ni@intel.com> <20180115034612.381104-3-ruiyu.ni@intel.com> In-Reply-To: <20180115034612.381104-3-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 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jan 2018 05:13:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 Sent: Monday, January 15, 2018 11:46 AM To: edk2-devel@lists.01.org Cc: Christian Ehrhardt ; Zeng, Star Subject: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing disp= lay corrupted The Graphics Output Protocol's mode information specifies the PixelsPerScan= Line property. Most of the time this is identical to HorizontalResolution. = However, due to alignment requirements etc. it may be slightly larger. I.e.= each scan line will have some "pixels" that are not visible on the screen but consume space in the frame buffer. If the graphics output protocol correctly initializes HorizontalResolution = to 1366 and PixelsPerScanLine to 1376. As a result the graphics output is b= roken. If setting HorizontalResolution to 1376 instead, the output is fine (except= for 10 invisible pixels on the right of the screen). The patch fixes this bug by using PixelsPerScanLine when calculating the li= ne width. Contributed-under: TianoCore Contribution Agreement 1.1 Reported-by: Christian Ehrhardt Signed-off-by: Christian Ehrhardt Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Christian Ehrhardt --- .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 46 ++++++++++++------= ---- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/M= deModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index 3078fe6254..c88469859b 100644 --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -21,9 +21,9 @@ #include =20 struct FRAME_BUFFER_CONFIGURE { - UINT32 WidthInBytes; + UINT32 PixelsPerScanLine; UINT32 BytesPerPixel; - UINT32 WidthInPixels; + UINT32 Width; UINT32 Height; UINT8 *FrameBuffer; EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; @@ -144,6 +144,10 @@ FrameBufferBltConfigure ( return RETURN_INVALID_PARAMETER; } =20 + if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalReso= lution) { + return RETURN_UNSUPPORTED; + } + FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl= , PixelShr); =20 if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE) @@ -160,12 +164,12 = @@ FrameBufferBltConfigure ( 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 FrameBufferInfo->HorizontalResolution; - Configure->Height =3D FrameBufferInfo->VerticalResolution; - Configure->WidthInBytes =3D Configure->WidthInPixels * Configure->Bytes= PerPixel; + Configure->BytesPerPixel =3D BytesPerPixel; + Configure->PixelFormat =3D FrameBufferInfo->PixelFormat; + Configure->FrameBuffer =3D (UINT8*) FrameBuffer; + Configure->Width =3D FrameBufferInfo->HorizontalResolution; + Configure->Height =3D FrameBufferInfo->VerticalResolution; + Configure->PixelsPerScanLine =3D FrameBufferInfo->PixelsPerScanLine; =20 return RETURN_SUCCESS; } @@ -215,7 +219,7 @@ FrameBufferBltLibVideoFill ( return RETURN_INVALID_PARAMETER; } =20 - if (DestinationX + Width > Configure->WidthInPixels) { + if (DestinationX + Width > Configure->Width) { DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (X)\n")); return RETURN_INVALID_PARAMETER; } @@ -268,9 +272,9 @@ FrameBufferBltLibVideoFill ( } } =20 - if (UseWideFill && (DestinationX =3D=3D 0) && (Width =3D=3D Configure->W= idthInPixels)) { + if (UseWideFill && (DestinationX =3D=3D 0) && (Width =3D=3D=20 + Configure->PixelsPerScanLine)) { DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n")); - Offset =3D DestinationY * Configure->WidthInPixels; + Offset =3D DestinationY * Configure->PixelsPerScanLine; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; SizeInBytes =3D WidthInBytes * Height; @@ -284,7 +288,7 @@ FrameBuffer= BltLibVideoFill ( } else { LineBufferReady =3D FALSE; for (IndexY =3D DestinationY; IndexY < (Height + DestinationY); IndexY= ++) { - Offset =3D (IndexY * Configure->WidthInPixels) + DestinationX; + Offset =3D (IndexY * Configure->PixelsPerScanLine) + DestinationX; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; =20 @@ -368,7 +372,7 @@ FrameBufferBltLibVideoToBltBuffer ( return RETURN_INVALID_PARAMETER; } =20 - if (SourceX + Width > Configure->WidthInPixels) { + if (SourceX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -394,7 +398,7 @@ FrameBufferBltLibVideoToBltBuffer ( DstY < (Height + DestinationY); SrcY++, DstY++) { =20 - Offset =3D (SrcY * Configure->WidthInPixels) + SourceX; + Offset =3D (SrcY * Configure->PixelsPerScanLine) + SourceX; Offset =3D Configure->BytesPerPixel * Offset; Source =3D Configure->FrameBuffer + Offset; =20 @@ -476,7 +480,7 @@ FrameBufferBltLibBufferToVideo ( return RETURN_INVALID_PARAMETER; } =20 - if (DestinationX + Width > Configure->WidthInPixels) { + if (DestinationX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -499,7 +503,7 @@ FrameBufferBltLibBufferToVideo ( SrcY < (Height + SourceY); SrcY++, DstY++) { =20 - Offset =3D (DstY * Configure->WidthInPixels) + DestinationX; + Offset =3D (DstY * Configure->PixelsPerScanLine) + DestinationX; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; =20 @@ -572,7 +576,7 @@ FrameBufferBltLibVideoToVideo ( return RETURN_INVALID_PARAMETER; } =20 - if (SourceX + Width > Configure->WidthInPixels) { + if (SourceX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -580,7 +584,7 @@ FrameBufferBltLibVideoToVideo ( return RETURN_INVALID_PARAMETER; } =20 - if (DestinationX + Width > Configure->WidthInPixels) { + if (DestinationX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -590,15 +594,15 @@ FrameBufferBltLibVideoToVideo ( =20 WidthInBytes =3D Width * Configure->BytesPerPixel; =20 - Offset =3D (SourceY * Configure->WidthInPixels) + SourceX; + Offset =3D (SourceY * Configure->PixelsPerScanLine) + SourceX; Offset =3D Configure->BytesPerPixel * Offset; Source =3D Configure->FrameBuffer + Offset; =20 - Offset =3D (DestinationY * Configure->WidthInPixels) + DestinationX; + Offset =3D (DestinationY * Configure->PixelsPerScanLine) +=20 + DestinationX; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; =20 - LineStride =3D Configure->WidthInBytes; + LineStride =3D Configure->BytesPerPixel * Configure->PixelsPerScanLine; if (Destination > Source) { // // Copy from last line to avoid source is corrupted by copying -- 2.15.1.windows.2