diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2025-05-01 07:37:47 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2025-05-03 07:04:15 +0000 |
| commit | 970e13db8deebf6c7542c7aede4f34703fa86769 (patch) | |
| tree | 04db96b02d5a6b2c0c7df99cf3f896054b90c56a /shm.c | |
| parent | osc: restore configured alpha if OSC-11 has no alpha value (diff) | |
config: tweak.surface-bit-depth: add support for 16-bit surfaces
This adds supports for 16-bit surfaces, using the new
PIXMAN_a16b16g16r16 buffer format. This maps to
WL_SHM_FORMAT_ABGR16161616 (little-endian).
Use the new 16-bit surfaces by default, when
gamma-correct-blending=yes.
Diffstat (limited to 'shm.c')
| -rw-r--r-- | shm.c | 53 |
1 files changed, 45 insertions, 8 deletions
@@ -338,7 +338,10 @@ get_new_buffers(struct buffer_chain *chain, size_t count, size_t total_size = 0; for (size_t i = 0; i < count; i++) { stride[i] = stride_for_format_and_width( - with_alpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8, widths[i]); + with_alpha + ? chain->pixman_fmt_with_alpha + : chain->pixman_fmt_without_alpha, + widths[i]); sizes[i] = stride[i] * heights[i]; total_size += sizes[i]; } @@ -981,8 +984,38 @@ shm_chain_new(struct wayland *wayl, bool scrollable, size_t pix_instances, enum wl_shm_format shm_fmt_with_alpha = WL_SHM_FORMAT_ARGB8888; static bool have_logged = false; + static bool have_logged_10_fallback = false; - if (desired_bit_depth == SHM_BITS_10) { +#if defined(HAVE_PIXMAN_RGBA_16) + static bool have_logged_16_fallback = false; + + if (desired_bit_depth == SHM_BITS_16) { + if (wayl->shm_have_abgr161616 && wayl->shm_have_xbgr161616) { + pixman_fmt_without_alpha = PIXMAN_a16b16g16r16; + shm_fmt_without_alpha = WL_SHM_FORMAT_XBGR16161616; + + pixman_fmt_without_alpha = PIXMAN_a16b16g16r16; + shm_fmt_with_alpha = WL_SHM_FORMAT_ABGR16161616; + + if (!have_logged) { + have_logged = true; + LOG_INFO("using 16-bit BGR surfaces"); + } + } else { + if (!have_logged_16_fallback) { + have_logged_16_fallback = true; + + LOG_WARN( + "16-bit surfaces requested, but compositor does not " + "implement ABGR161616+XBGR161616"); + } + } + } +#endif + + if (desired_bit_depth >= SHM_BITS_10 && + pixman_fmt_with_alpha == PIXMAN_a8r8g8b8) + { if (wayl->shm_have_argb2101010 && wayl->shm_have_xrgb2101010) { pixman_fmt_without_alpha = PIXMAN_x2r10g10b10; shm_fmt_without_alpha = WL_SHM_FORMAT_XRGB2101010; @@ -1010,13 +1043,13 @@ shm_chain_new(struct wayland *wayl, bool scrollable, size_t pix_instances, } else { - if (!have_logged) { - have_logged = true; + if (!have_logged_10_fallback) { + have_logged_10_fallback = true; LOG_WARN( "10-bit surfaces requested, but compositor does not " "implement ARGB2101010+XRGB2101010, or " - "ABGR2101010+XBGR2101010. Falling back to 8-bit surfaces"); + "ABGR2101010+XBGR2101010"); } } } else { @@ -1063,7 +1096,11 @@ shm_chain_bit_depth(const struct buffer_chain *chain) { const pixman_format_code_t fmt = chain->pixman_fmt_with_alpha; - return (fmt == PIXMAN_a2r10g10b10 || fmt == PIXMAN_a2b10g10r10) - ? SHM_BITS_10 - : SHM_BITS_8; + return fmt == PIXMAN_a8r8g8b8 + ? SHM_BITS_8 +#if defined(HAVE_PIXMAN_RGBA_16) + : fmt == PIXMAN_a16b16g16r16 + ? SHM_BITS_16 +#endif + : SHM_BITS_10; } |
