mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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:
committed by
Alexander Kalenik
parent
c62cc915df
commit
8de9516272
@@ -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,
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user