From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Christian Ehrhardt <ehrhardt@genua.de>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted
Date: Mon, 15 Jan 2018 11:46:11 +0800 [thread overview]
Message-ID: <20180115034612.381104-3-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20180115034612.381104-1-ruiyu.ni@intel.com>
The Graphics Output Protocol's mode information specifies the
PixelsPerScanLine 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 broken.
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 line width.
Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Christian Ehrhardt <ehrhardt@genua.de>
---
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 46 ++++++++++++----------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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 <Library/FrameBufferBltLib.h>
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;
}
+ if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalResolution) {
+ return RETURN_UNSUPPORTED;
+ }
+
FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl, PixelShr);
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 = BytesPerPixel;
- Configure->PixelFormat = FrameBufferInfo->PixelFormat;
- Configure->FrameBuffer = (UINT8*) FrameBuffer;
- Configure->WidthInPixels = FrameBufferInfo->HorizontalResolution;
- Configure->Height = FrameBufferInfo->VerticalResolution;
- Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
+ Configure->BytesPerPixel = BytesPerPixel;
+ Configure->PixelFormat = FrameBufferInfo->PixelFormat;
+ Configure->FrameBuffer = (UINT8*) FrameBuffer;
+ Configure->Width = FrameBufferInfo->HorizontalResolution;
+ Configure->Height = FrameBufferInfo->VerticalResolution;
+ Configure->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;
return RETURN_SUCCESS;
}
@@ -215,7 +219,7 @@ FrameBufferBltLibVideoFill (
return RETURN_INVALID_PARAMETER;
}
- 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 (
}
}
- if (UseWideFill && (DestinationX == 0) && (Width == Configure->WidthInPixels)) {
+ if (UseWideFill && (DestinationX == 0) && (Width == Configure->PixelsPerScanLine)) {
DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n"));
- Offset = DestinationY * Configure->WidthInPixels;
+ Offset = DestinationY * Configure->PixelsPerScanLine;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
SizeInBytes = WidthInBytes * Height;
@@ -284,7 +288,7 @@ FrameBufferBltLibVideoFill (
} else {
LineBufferReady = FALSE;
for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {
- Offset = (IndexY * Configure->WidthInPixels) + DestinationX;
+ Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
@@ -368,7 +372,7 @@ FrameBufferBltLibVideoToBltBuffer (
return RETURN_INVALID_PARAMETER;
}
- if (SourceX + Width > Configure->WidthInPixels) {
+ if (SourceX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -394,7 +398,7 @@ FrameBufferBltLibVideoToBltBuffer (
DstY < (Height + DestinationY);
SrcY++, DstY++) {
- Offset = (SrcY * Configure->WidthInPixels) + SourceX;
+ Offset = (SrcY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
@@ -476,7 +480,7 @@ FrameBufferBltLibBufferToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (DestinationX + Width > Configure->WidthInPixels) {
+ if (DestinationX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -499,7 +503,7 @@ FrameBufferBltLibBufferToVideo (
SrcY < (Height + SourceY);
SrcY++, DstY++) {
- Offset = (DstY * Configure->WidthInPixels) + DestinationX;
+ Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
@@ -572,7 +576,7 @@ FrameBufferBltLibVideoToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (SourceX + Width > Configure->WidthInPixels) {
+ if (SourceX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -580,7 +584,7 @@ FrameBufferBltLibVideoToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (DestinationX + Width > Configure->WidthInPixels) {
+ if (DestinationX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -590,15 +594,15 @@ FrameBufferBltLibVideoToVideo (
WidthInBytes = Width * Configure->BytesPerPixel;
- Offset = (SourceY * Configure->WidthInPixels) + SourceX;
+ Offset = (SourceY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
- Offset = (DestinationY * Configure->WidthInPixels) + DestinationX;
+ Offset = (DestinationY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
- LineStride = Configure->WidthInBytes;
+ LineStride = Configure->BytesPerPixel * Configure->PixelsPerScanLine;
if (Destination > Source) {
//
// Copy from last line to avoid source is corrupted by copying
--
2.15.1.windows.2
next prev parent reply other threads:[~2018-01-15 3:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 3:46 [PATCH 0/3] Fix two bugs in FrameBufferBltLib Ruiyu Ni
2018-01-15 3:46 ` [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data Ruiyu Ni
[not found] ` <0C09AFA07DD0434D9E2A0C6AEB0483103B9FC6E6@shsmsx102.ccr.corp.intel.com>
2018-01-16 5:24 ` Ni, Ruiyu
2018-01-15 3:46 ` Ruiyu Ni [this message]
2018-01-16 5:18 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted Zeng, Star
2018-01-15 3:46 ` [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory Ruiyu Ni
2018-01-16 5:18 ` Zeng, Star
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=20180115034612.381104-3-ruiyu.ni@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