We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3699 - [Patch] X11: Shaped windows are distorted unless width is divisible by 8
Summary: [Patch] X11: Shaped windows are distorted unless width is divisible by 8
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-11 13:29 UTC by Bogomancer
Modified: 2017-07-11 15:16 UTC (History)
0 users

See Also:


Attachments
Suggested fix (1.35 KB, patch)
2017-07-11 13:29 UTC, Bogomancer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bogomancer 2017-07-11 13:29:39 UTC
Created attachment 2795 [details]
Suggested fix

On X11, windows created using the shaped window API appear distorted unless the width of the shape surface is divisible by 8.

Steps to reproduce:

    1) Use your favorite image editor to resize one of the images in test/shapes/ to a width that's not a multiple of 8.
    2) Compile and run test/testshape.c on the image you edited.
    3) The shaped window will appear twisted and distorted.

It appears the bug was not caught sooner because all the test images are either 640 or 256 pixels wide.

I tracked down the bug to SDL_CalculateShapeBitmap() in SDL_shape.c. The shape surface is reduced to a 1-bit-per-pixel mask, but the original code doesn't take into account that X11 apparently wants each scanline to begin on a new byte.

I'm attaching a patch.
Comment 1 Sam Lantinga 2017-07-11 15:16:18 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/912b770ded2a