Bug 245446 - [GTK] weird colours in WebKitGTK2+ browsers on OpenBSD (PowerPC, big endian, OpenGL)
Summary: [GTK] weird colours in WebKitGTK2+ browsers on OpenBSD (PowerPC, big endian, ...
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: Other Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-20 13:13 PDT by Marco van Hulten
Modified: 2024-03-07 06:03 PST (History)
8 users (show)

See Also:


Attachments
w3.org website in Midori 9.0 (88.95 KB, image/png)
2022-09-20 13:13 PDT, Marco van Hulten
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marco van Hulten 2022-09-20 13:13:07 PDT
Created attachment 462477 [details]
w3.org website in Midori 9.0

Both with Midori and Badwolf rendering show strange rendering (see attached image).
It looks like only one colour is used, but other webpages seem to use two colours.

Since the problem occurs with two browsers using WebKitGTK, I made a (not very educated) guess to report the bug here.

This is on an iMac G5 (PowerPC 970FX) with OpenBSD current (macppc port).
Comment 1 Fujii Hironori 2022-09-20 13:34:59 PDT
Same problem with bug#219916 comment#4.
WebKitGTK has USE_OPENGL_OR_ES build switch to disable OpenGL for minor operating systems which have a problem for OpenGL.
WebKitGTK has WEBKIT_DISABLE_COMPOSITING_MODE env var to disable accelerated compositing. https://trac.webkit.org/wiki/EnvironmentVariables
Comment 2 Fujii Hironori 2022-09-20 13:56:50 PDT
Looking at your screenshot. At least, it seems that red and blue are swapped.

This is the color conversion matrix.
https://github.com/WebKit/WebKit/blob/9c06eb3162b5f48ee882984e91f8ac9d4f9f1fdd/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp#L435-L445

I think there are more problems. You might need some more swizzling in BitmapTextureGL::updateContents.
https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp#L91
Comment 3 Miguel Gomez 2022-09-21 00:31:04 PDT
Cairo uses ARGB32 as the color format for its surfaces.

On little endian systems, this is stored as BGRA. When we upload the cairo surfaces into textures, we upload them as BGRA indicating that when painting them we will change that format to RGBA. The TextureMapperGL::ShouldConvertTextureBGRAToRGBA flag used in BitmapTextureGL::updateContents() takes care of that (by selecting the appropriate color conversion matrix that Fujii linked).

On big endian systems, cairo contents are stored as ARGB. This means that when uploading the surface contents to textures, we should use the flag TextureMapperGL::ShouldConvertTextureARGBToRGBA, which doesn't seem to be used.

Something like this in BitmapTextureGL::updateContents() should fix the color conversion on big endian.

#if G_BYTE_ORDER == G_LITTLE_ENDIAN
m_colorConvertFlags = TextureMapperGL::ShouldConvertTextureBGRAToRGBA;
#else
m_colorConvertFlags = TextureMapperGL::ShouldConvertTextureARGBToRGBA;
#endif
Comment 4 Dennis Camera 2024-03-04 09:30:36 PST
I tested the patch suggested by Miguel Gomez and it corrects the colours when WEBKIT_DISABLE_COMPOSITING_MODE=1 is used.

So I opened a PR with this change: 
https://github.com/WebKit/WebKit/pull/25424

When accelerated compositing is used, at least on my system, black on white text is now displayed light gray on white instead of blue on white as before.
Blue is yellow.

I suspect that RGBA is confused as BARG.
Comment 5 EWS 2024-03-07 01:53:00 PST
Committed 275780@main (c37138cb8d45): <https://commits.webkit.org/275780@main>

Reviewed commits have been landed. Closing PR #25424 and removing active labels.
Comment 6 Dennis Camera 2024-03-07 02:19:31 PST
I think that this bug should be reopened, because the colours are only fixed in non-accelerated mode.
Comment 7 Michael Catanzaro 2024-03-07 06:03:03 PST
.