Ladybird: Account for backing store bitmap pitch

In the upcoming changes, Skia painter will be switched to Metal backend,
so we can no longer assume `pitch = width * 4` while reading Gfx::Bitmap
that wraps IOSurface populated by writing into MTLTexture that has
padded scanlines.
This commit is contained in:
Aliaksandr Kalenik 2024-06-26 17:56:20 +02:00 committed by Alexander Kalenik
parent c62cc915df
commit 8de9516272
Notes: sideshowbarker 2024-07-17 05:00:08 +09:00
2 changed files with 2 additions and 3 deletions

View file

@ -1288,7 +1288,6 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
static constexpr size_t BITS_PER_COMPONENT = 8;
static constexpr size_t BITS_PER_PIXEL = 32;
static constexpr size_t COMPONENTS_PER_PIXEL = 4;
auto* context = [[NSGraphicsContext currentContext] CGContext];
CGContextSaveGState(context);
@ -1309,7 +1308,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
bitmap_size.height(),
BITS_PER_COMPONENT,
BITS_PER_PIXEL,
COMPONENTS_PER_PIXEL * bitmap.width(),
bitmap.pitch(),
CGColorSpaceCreateDeviceRGB(),
kCGBitmapByteOrder32Little | kCGImageAlphaFirst,
provider,

View file

@ -403,7 +403,7 @@ void WebContentView::paintEvent(QPaintEvent*)
}
if (bitmap) {
QImage q_image(bitmap->scanline_u8(0), bitmap->width(), bitmap->height(), QImage::Format_RGB32);
QImage q_image(bitmap->scanline_u8(0), bitmap->width(), bitmap->height(), bitmap->pitch(), QImage::Format_RGB32);
painter.drawImage(QPoint(0, 0), q_image, QRect(0, 0, bitmap_size.width(), bitmap_size.height()));
if (bitmap_size.width() < width()) {