[Fix] (SharedImage): allocate and import ARGB8888/XRGB8888 images so KWin's offscreen Quick views get buffers

This commit is contained in:
2026-10-02 09:37:17 -04:00
parent 0e314f645e
commit 672261764e
11 changed files with 55 additions and 20 deletions
@@ -110,7 +110,7 @@ namespace MobileGL::MG_Remote::Server::SharedImages {
desc.width = image.Width;
desc.height = image.Height;
desc.layers = 1;
desc.format = image.Fourcc == kFourccXbgr8888 ? AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM
desc.format = FourccIgnoresAlpha(image.Fourcc) ? AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM
: AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
AHardwareBuffer* ahb = nullptr;
@@ -186,7 +186,12 @@ namespace MobileGL::MG_Remote::Server::SharedImages {
ReleaseNative(Native);
}
Bool FourccSupported(Uint32 fourcc) { return fourcc == kFourccAbgr8888 || fourcc == kFourccXbgr8888; }
Bool FourccSupported(Uint32 fourcc) {
return fourcc == kFourccAbgr8888 || fourcc == kFourccXbgr8888 || fourcc == kFourccArgb8888 ||
fourcc == kFourccXrgb8888;
}
Bool FourccIgnoresAlpha(Uint32 fourcc) { return fourcc == kFourccXbgr8888 || fourcc == kFourccXrgb8888; }
ImageRef Allocate(Uint32 width, Uint32 height, Uint32 fourcc, std::string& why) {
if (width == 0 || height == 0 || width > 16384 || height > 16384) {
@@ -38,12 +38,20 @@ namespace MobileGL::MG_Remote::Server::SharedImages {
}
inline constexpr Uint32 kFourccAbgr8888 = FourCC('A', 'B', '2', '4');
inline constexpr Uint32 kFourccXbgr8888 = FourCC('X', 'B', '2', '4');
// ARGB8888 / XRGB8888 name B, G, R, A in memory. An image of either is still stored R, G, B, A:
// its layout is the allocator's (the modifier is INVALID and no CPU mapping is offered), every
// reader and writer is this server, and they all address channels LOGICALLY - so what a
// client renders as red samples as red, whichever of the four names it allocated under.
inline constexpr Uint32 kFourccArgb8888 = FourCC('A', 'R', '2', '4');
inline constexpr Uint32 kFourccXrgb8888 = FourCC('X', 'R', '2', '4');
// "The layout is the allocator's": what an AHardwareBuffer is to anybody but its allocator.
inline constexpr Uint64 kModifierInvalid = 0x00ffffffffffffffull;
inline constexpr Uint64 kModifierLinear = 0;
// Whether images of this fourcc can be allocated (and so imported) at all.
Bool FourccSupported(Uint32 fourcc);
// The X formats: alpha reads as 1 whatever is stored.
Bool FourccIgnoresAlpha(Uint32 fourcc);
struct Image {
Uint64 Id = 0;