[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/8] ui/cocoa: Fix stride resolution of pixman image
From: |
Gerd Hoffmann |
Subject: |
[PULL 3/8] ui/cocoa: Fix stride resolution of pixman image |
Date: |
Thu, 4 Mar 2021 09:37:00 +0100 |
From: Akihiko Odaki <akihiko.odaki@gmail.com>
A display can receive an image which its stride is greater than its
width. In fact, when a guest requests virtio-gpu to scan out a
smaller part of an image, virtio-gpu passes it to a display as an
image which its width represents the one of the part and its stride
equals to the one of the whole image.
This change makes ui/cocoa to cover such cases.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20210222144012.21486-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/cocoa.m | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 5ad44b84aaaf..6a59f87316b8 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -450,19 +450,19 @@ QemuCocoaView *cocoaView;
int w = pixman_image_get_width(pixman_image);
int h = pixman_image_get_height(pixman_image);
int bitsPerPixel =
PIXMAN_FORMAT_BPP(pixman_image_get_format(pixman_image));
- int bitsPerComponent = DIV_ROUND_UP(bitsPerPixel, 8) * 2;
+ int stride = pixman_image_get_stride(pixman_image);
CGDataProviderRef dataProviderRef = CGDataProviderCreateWithData(
NULL,
pixman_image_get_data(pixman_image),
- w * 4 * h,
+ stride * h,
NULL
);
CGImageRef imageRef = CGImageCreate(
w, //width
h, //height
- bitsPerComponent, //bitsPerComponent
+ DIV_ROUND_UP(bitsPerPixel, 8) * 2, //bitsPerComponent
bitsPerPixel, //bitsPerPixel
- (w * (bitsPerComponent/2)), //bytesPerRow
+ stride, //bytesPerRow
#ifdef __LITTLE_ENDIAN__
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace
for OS X >= 10.4
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
--
2.29.2
- [PULL 0/8] Ui 20210304 patches, Gerd Hoffmann, 2021/03/04
- [PULL 1/8] ui/cocoa: Remove the uses of full screen APIs, Gerd Hoffmann, 2021/03/04
- [PULL 2/8] ui/gtk: vte: fix sending multiple characeters, Gerd Hoffmann, 2021/03/04
- [PULL 6/8] ui/console: Add placeholder flag to message surface, Gerd Hoffmann, 2021/03/04
- [PULL 3/8] ui/cocoa: Fix stride resolution of pixman image,
Gerd Hoffmann <=
- [PULL 4/8] configure: Improve OpenGL dependency detections, Gerd Hoffmann, 2021/03/04
- [PULL 5/8] ui/cocoa: Replace fprintf with error_report, Gerd Hoffmann, 2021/03/04
- [PULL 7/8] ui/console: Pass placeholder surface to displays, Gerd Hoffmann, 2021/03/04
- [PULL 8/8] virtio-gpu: Do not distinguish the primary console, Gerd Hoffmann, 2021/03/04
- Re: [PULL 0/8] Ui 20210304 patches, Peter Maydell, 2021/03/05