mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
SteamDeck: a standalone launcher for the native ARM64 Linux Steam client
Lifts Bannerlator's Linux/gamescope runtime out into an app of its own: the Wayland compositor, the proot session, the runtime installer, the fake-evdev controller path and the PulseAudio server, with none of the Wine, container or store machinery around them. One activity installs the runtime from the same winlator-contents catalog and a second one runs the session: compositor on a SurfaceView, gamescope and Valve's native arm64 client under proot, a physical pad republished into the fake-input rings, and the session's milestones on screen until the first frame arrives.
This commit is contained in:
commit
4022351e22
210 files changed
+73587
No files matched your search
@@ -0,0 +1,105 @@
|
||||
# ── Embedded Wayland compositor (experimental parallel runtime) ──────────────
|
||||
# Runs a libwayland-server compositor in-process so games launched via Wine's
|
||||
# winewayland.drv can present into it. Protocol glue is pre-generated in
|
||||
# generated/ (no host wayland-scanner needed at app build time). Built by the app
|
||||
# (add_subdirectory from ../CMakeLists.txt) and on its own by standalone/ for
|
||||
# build-waylandcomp.yml.
|
||||
add_library(bannerwayland SHARED
|
||||
src/compositor.c
|
||||
src/vk_present.c
|
||||
src/effects_chain.c
|
||||
src/vk_loader.c
|
||||
src/sc_layer.c
|
||||
src/ahb_swapchain.c
|
||||
src/waylandcomp_jni.c
|
||||
src/banner_ext.c
|
||||
src/wl_clipboard.c
|
||||
src/wl_text_input.c
|
||||
src/wl_toplevel_icon.c
|
||||
src/wl_color_mgmt.c
|
||||
src/hdr_compose.c
|
||||
generated/color-management-v1-protocol.c
|
||||
generated/xdg-shell-protocol.c
|
||||
generated/linux-dmabuf-v1-protocol.c
|
||||
generated/viewporter-protocol.c
|
||||
generated/banner-desktop-v1-protocol.c
|
||||
generated/presentation-time-protocol.c
|
||||
generated/pointer-constraints-unstable-v1-protocol.c
|
||||
generated/relative-pointer-unstable-v1-protocol.c
|
||||
generated/wlr-data-control-unstable-v1-protocol.c
|
||||
generated/text-input-unstable-v3-protocol.c
|
||||
generated/xdg-toplevel-icon-v1-protocol.c
|
||||
generated/banner-ahb-v1-protocol.c
|
||||
src/framegen_bridge.c
|
||||
src/framegen_jni.c
|
||||
)
|
||||
target_include_directories(bannerwayland PRIVATE
|
||||
generated
|
||||
prebuilt/include
|
||||
src
|
||||
# The X11 Vulkan renderer's committed SPIR-V headers (*_frag.h / upscale_vert.h, made by
|
||||
# winlator/gen_shaders.sh): the screen-effect chain (src/effects_chain.c) runs the same bytes.
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../shaders
|
||||
)
|
||||
|
||||
# ── Frame generation (feat/wayland-framegen) ─────────────────────────────────
|
||||
# The two native engines the X11 renderer runs (LSFG Native: winlator/lsfg, Win-FG Native:
|
||||
# winlator/winfg) are compiled into this library unmodified and driven by
|
||||
# src/framegen_engine.cpp through the compositor's own Turnip entry points. They need the
|
||||
# winlator tree and the vendored DXBC translator (thirdparty/dxbc, for the LSFG cache format),
|
||||
# which only the app build has: the standalone build (standalone/) gets the stub, which reports
|
||||
# every engine unavailable and generates nothing.
|
||||
set(BANNER_FRAMEGEN_LSFG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../winlator/lsfg)
|
||||
set(BANNER_FRAMEGEN_WINFG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../winlator/winfg)
|
||||
if (TARGET dxbc AND EXISTS ${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
AND EXISTS ${BANNER_FRAMEGEN_WINFG_DIR}/winfg_engine.cpp)
|
||||
message(STATUS "bannerwayland: frame-generation engines built in (LSFG Native, Win-FG Native)")
|
||||
target_sources(bannerwayland PRIVATE
|
||||
src/framegen_engine.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_probe.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_dll.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_dxbc.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_vkd.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_common.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_shaders.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_mipmaps.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_alpha.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_beta.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_gamma.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_delta.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_generate.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_chain.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_pacer.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
${BANNER_FRAMEGEN_LSFG_DIR}/lsfg_governor.cpp
|
||||
${BANNER_FRAMEGEN_WINFG_DIR}/framegen.cpp
|
||||
${BANNER_FRAMEGEN_WINFG_DIR}/winfg_vkd.cpp
|
||||
${BANNER_FRAMEGEN_WINFG_DIR}/winfg_engine.cpp
|
||||
)
|
||||
target_include_directories(bannerwayland PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/.. # <thirdparty/...> as the winlator target sees it
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../winlator # VulkanRendererContext.h (VkTable), lsfg/, winfg/
|
||||
)
|
||||
target_compile_options(bannerwayland PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17 -fvisibility=hidden>)
|
||||
target_compile_definitions(bannerwayland PRIVATE
|
||||
WINFG_UPSTREAM="${WINFG_UPSTREAM}"
|
||||
WINFG_CHAIN_HASH="${WINFG_CHAIN_HASH}"
|
||||
)
|
||||
target_link_libraries(bannerwayland dxbc atomic)
|
||||
else()
|
||||
message(STATUS "bannerwayland: frame-generation engines NOT built in (standalone build): stub")
|
||||
target_sources(bannerwayland PRIVATE src/framegen_engine_stub.c)
|
||||
endif()
|
||||
add_library(wayland-server SHARED IMPORTED)
|
||||
set_target_properties(wayland-server PROPERTIES IMPORTED_LOCATION
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/lib/libwayland-server.so)
|
||||
# Vulkan is loaded at runtime via adrenotools (Turnip), not linked directly — so the
|
||||
# compositor uses Turnip's driver, which supports dmabuf import (drm_format_modifier).
|
||||
target_link_libraries(bannerwayland
|
||||
wayland-server
|
||||
adrenotools
|
||||
dl
|
||||
log
|
||||
android
|
||||
)
|
||||
@@ -0,0 +1,910 @@
|
||||
# HDR on the Wayland backend — reconnaissance
|
||||
|
||||
> **2026-09-14: round 1 of Phase A is built** (branch `feat/wayland-hdr`, opt-in, testing only) —
|
||||
> see **§10** at the end for what was built, how it is gated and how a tester's log proves it.
|
||||
> The recon below is kept as written.
|
||||
|
||||
Written 2026-09-13. **Recon only: no product code was changed, nothing was built, nothing was
|
||||
installed on the device.** Branch surveyed: app `feat/wayland-phase2`, proton-wine
|
||||
`feat/winewayland-desktop-11.0-2`, Banners-Turnip `wayland` (Mesa `7cda7850`, v26.3.0).
|
||||
Device reads are `dumpsys` / `getprop` / `strings` only.
|
||||
|
||||
Companion docs: `ZERO_COPY_SPIKE.md` (buffer path), `WAYLAND_RUNTIME.md`.
|
||||
|
||||
---
|
||||
|
||||
## 0. Answer in one paragraph
|
||||
|
||||
**The game half of HDR is already shipping and nobody noticed.** The Wayland Turnip inside
|
||||
wcp v6 (`Proton-11.0-2.1-arm64ec-6/lib/libvulkan_freedreno_wayland.so`, verified on the device)
|
||||
already contains Mesa's full `wp_color_manager_v1` client implementation and advertises
|
||||
`VK_EXT_swapchain_colorspace` + `VK_EXT_hdr_metadata`; the shipping DXVK v3.1-gplasync already
|
||||
carries `dxgi.enableHDR` / `DXVK_HDR` and the `VK_COLOR_SPACE_HDR10_ST2084_EXT` path;
|
||||
`winewayland.drv` is a transparent 121-line shim that neither adds nor removes colour
|
||||
information. **Everything that is missing is in our compositor**, which advertises no colour
|
||||
protocol, offers only four 8-bit DRM formats over `zwp_linux_dmabuf_v1`, takes
|
||||
`surfaceFormats[0]` for its own swapchain, runs an 8-bit scene/effects chain, and never calls
|
||||
`ASurfaceTransaction_setBufferDataSpace`. The work is therefore **app-side only** — the memory
|
||||
note in `project_bannerlator_wayland_phase4` that HDR "does need a new wcp" is **wrong for the
|
||||
HDR10 (10-bit PQ) path**; a new wcp is only needed for scRGB/FP16 zero-copy. Estimated
|
||||
**4–6 engineer-days** to a plumbed, log-verifiable HDR10 path. But the Pocket FIT's panel
|
||||
reports `supportedHdrTypes=[]`, `supportedColorModes=[0]` (NATIVE only), `hdrSdrRatio
|
||||
not_available` and `displayBrightnessNits=-1`, so **nothing of it can be seen on this device**,
|
||||
and turning it on there would actively *cost* us the zero-copy DEVICE-composition win. Verdict
|
||||
in §8: **not now.**
|
||||
|
||||
---
|
||||
|
||||
## 1. Game side — how far an HDR request gets today
|
||||
|
||||
### 1.1 What a Windows game does
|
||||
|
||||
| Call | Where it lands in DXVK | Notes |
|
||||
|---|---|---|
|
||||
| `IDXGIOutput6::GetDesc1` → `DXGI_OUTPUT_DESC1::ColorSpace` | `src/dxgi/dxgi_output.cpp:220-259` | **Never queries Vulkan.** Reports `RGB_FULL_G2084_NONE_P2020` purely because `dxgi.enableHDR` is on. |
|
||||
| `IDXGISwapChain3::CheckColorSpaceSupport` | `src/dxgi/dxgi_swapchain.cpp:655-667` | This *is* backed by Vulkan (below). Note it is a swapchain method, not a factory method. |
|
||||
| `IDXGISwapChain3::SetColorSpace1` | `dxgi_swapchain.cpp:672-688` → `d3d11_swapchain.cpp:306-331` → `Presenter::supportsColorSpace` (`dxvk_presenter.cpp:319-343`) | Returns `E_INVALIDARG` if the Vulkan surface does not list the colour space. |
|
||||
| `IDXGISwapChain4::SetHDRMetaData` | `dxgi_swapchain.cpp:690-717` → `vkSetHdrMetadataEXT` | Only `DXGI_HDR_METADATA_TYPE_HDR10`. Silently dropped if `VK_EXT_hdr_metadata` is absent (`dxvk_presenter.cpp:143-149`). |
|
||||
|
||||
DXGI→Vulkan mapping (`src/d3d11/d3d11_swapchain.cpp:21-28`):
|
||||
|
||||
```
|
||||
DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 -> VK_COLOR_SPACE_HDR10_ST2084_EXT
|
||||
DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 -> VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT (scRGB)
|
||||
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 -> VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
|
||||
```
|
||||
|
||||
Swapchain formats DXVK will accept per colour space (`Presenter::pickFormat`,
|
||||
`dxvk_presenter.cpp:1043-1081`):
|
||||
|
||||
* `HDR10_ST2084` → `A2R10G10B10_UNORM_PACK32`, `A2B10G10R10_UNORM_PACK32`,
|
||||
`E5B9G9R9_UFLOAT_PACK32`, `R16G16B16A16_UNORM`, `R16G16B16A16_SFLOAT`
|
||||
* `EXTENDED_SRGB_LINEAR` (scRGB) → **`R16G16B16A16_SFLOAT` only**
|
||||
|
||||
`VK_EXT_hdr_metadata` is optional in both DXVK and vkd3d-proton. `VK_EXT_swapchain_colorspace`
|
||||
is *not* requested as an instance extension by DXVK's win32 WSI — it simply trusts the driver to
|
||||
report the extra `VkColorSpaceKHR` values from `vkGetPhysicalDeviceSurfaceFormatsKHR`. Mesa's
|
||||
Wayland WSI does exactly that (§2.3), so this is not a problem for us.
|
||||
|
||||
**vkd3d-proton (D3D12)** ships its own swapchain (`libs/vkd3d/swapchain.c`), same colour-space
|
||||
mapping (`convert_color_space`, :1717-1730), but **no fallback table**: if the requested
|
||||
HDR colour space is not in `vkGetPhysicalDeviceSurfaceFormatsKHR`, `dxgi_vk_swap_chain_select_format`
|
||||
(:1773-1791) returns `false` with the comment *"Refuse to present unsupported HDR since it will
|
||||
look completely bogus"*, and the caller skips swapchain recreation for that cycle. A D3D12 game
|
||||
that force-sets HDR without checking can therefore **stall presentation** rather than degrade.
|
||||
DXGI enumeration for D3D12 titles is still DXVK's `dxgi.dll`, so `DXVK_HDR` still drives
|
||||
`DXGI_OUTPUT_DESC1`.
|
||||
|
||||
**Verified in our shipped binaries** (device, `strings`):
|
||||
`contents/DXVK/v3.1-gplasync-0/system32/dxgi.dll` contains `dxgi.enableHDR`, `DXVK_HDR`,
|
||||
`VK_COLOR_SPACE_HDR10_ST2084_EXT`; `d3d11.dll`/`d3d9.dll`/`dxgi.dll` contain
|
||||
`VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT`; `contents/VKD3D/3.1.0-wave64-relax-1/.../d3d12core.dll`
|
||||
contains `VK_EXT_hdr_metadata`. Nothing needs rebuilding on the D3D side.
|
||||
|
||||
Proton-level gating: GE's `proton` script maps `PROTON_ENABLE_HDR` / `PROTON_USE_HDR` to
|
||||
`DXVK_HDR=1` and nothing else. For us that is one container env var — no launcher work.
|
||||
|
||||
### 1.2 The failure mode today, exactly
|
||||
|
||||
DXVK's `DXGI_OUTPUT_DESC1` will claim HDR10 as soon as `DXVK_HDR=1`, regardless of Vulkan.
|
||||
`SetColorSpace1` then fails with `E_INVALIDARG` because our compositor advertises no colour
|
||||
management, so Mesa lists only `SRGB_NONLINEAR` + `PASS_THROUGH` (§2.3). Well-behaved games fall
|
||||
back to SDR. Games that trust `GetDesc1` without checking `CheckColorSpaceSupport` can render an
|
||||
HDR-authored image into an SDR swapchain (washed out) — this is a pre-existing foot-gun, not
|
||||
something we introduce. **Recommendation regardless of whether we do HDR: do not expose a
|
||||
`DXVK_HDR` container toggle until the compositor answers truthfully**, or we invite exactly that
|
||||
bug class.
|
||||
|
||||
### 1.3 `winewayland.drv` — carries nothing for colour, and blocks nothing
|
||||
|
||||
`/home/claude-user/proton-wine-wayland2-wt/dlls/winewayland.drv/vulkan.c` is 121 lines:
|
||||
`wayland_vulkan_surface_create` wraps the `wl_surface` in a `VkSurfaceKHR`,
|
||||
`wayland_map_instance_extensions` aliases `VK_KHR_win32_surface` ⇄ `VK_KHR_wayland_surface`.
|
||||
There is **no surface-format or colour-space filtering**, so whatever Mesa advertises reaches
|
||||
DXVK unmodified. A grep for `color|colour|hdr|st2084|bt2020|gamut|10.?bit` across the whole
|
||||
driver returns only GDI colour-bitmap helpers — nothing colorimetric.
|
||||
|
||||
One real consequence: `wayland_output.c` publishes no EDID, and nothing in the tree writes the
|
||||
`EDID` registry value `win32u/sysparams.c:815-818` reads. DXVK's
|
||||
`src/wsi/win32/wsi_monitor_win32.cpp:288-361` therefore finds no EDID and falls back to its dummy
|
||||
HDR luminances (`wsi_edid.h:38-56`: min 0.01 / max 1499 / maxFullFrame 799 nits). A game will
|
||||
size its tonemapper for a 1499-nit display. Correctable later by synthesising an EDID in
|
||||
`winewayland.drv` (that *would* need a new wcp), but not a blocker.
|
||||
|
||||
### 1.4 Our bundled Turnip already speaks colour management — verified on the device
|
||||
|
||||
```
|
||||
$ strings .../Proton/11.0-2.1-arm64ec-6/lib/libvulkan_freedreno_wayland.so
|
||||
wp_color_manager_v1 PRESENT
|
||||
wp_color_management_surface_v1 PRESENT
|
||||
wp_image_description_creator_params_v1 PRESENT
|
||||
banner_ahb_v1 PRESENT (our zero-copy patch)
|
||||
VK_EXT_swapchain_colorspace PRESENT
|
||||
VK_EXT_hdr_metadata PRESENT
|
||||
```
|
||||
|
||||
The plain adrenotools driver the compositor itself loads
|
||||
(`contents/adrenotools/Mesa Turnip v26.3.0-7cda785 (Android + Wayland)/libvulkan_freedreno.so`)
|
||||
has the same colour-management symbols. Our own WSI patch is already aware of the protocol —
|
||||
`patches/wayland/banner_ahb_wsi.py` anchors one of its edits on Mesa's
|
||||
`if (display->color_manager) wp_color_manager_v1_destroy(...)` teardown line.
|
||||
|
||||
**And the zero-copy patch already maps 10-bit to gralloc** — `banner_ahb_wsi.py:99-100, 225-237`:
|
||||
|
||||
```c
|
||||
#define BANNER_AHB_FORMAT_R8G8B8A8_UNORM 1u
|
||||
#define BANNER_AHB_FORMAT_R10G10B10A2_UNORM 0x2bu /* AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM */
|
||||
...
|
||||
case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return BANNER_AHB_FORMAT_R10G10B10A2_UNORM;
|
||||
```
|
||||
|
||||
So a 10-bit HDR10 swapchain can already be gralloc-backed and go onto the display layer with the
|
||||
**shipped** wcp. `VK_FORMAT_R16G16B16A16_SFLOAT` is *not* mapped, so `banner_ahb_skip_format`
|
||||
(:239-242, applied at `:606-617`) hides FP16 surface formats whenever zero-copy is on — scRGB
|
||||
zero-copy is the one thing that needs a driver change (one enum: `AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT = 0x16`).
|
||||
|
||||
### 1.5 X11 has no path — confirmed
|
||||
|
||||
`app/src/main/cpp/winlator/VulkanRendererContext.cpp:439` hardcodes
|
||||
`swapchainFmt = VK_FORMAT_R8G8B8A8_UNORM` and `:492` hardcodes
|
||||
`imageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR`. Upstream of that, the game presents through
|
||||
`winex11.drv` into our pure-Java X11 server, which has no colour extension of any kind. HDR on X11
|
||||
would mean inventing a private X extension *and* teaching DXVK to use it. Correctly out of scope.
|
||||
|
||||
---
|
||||
|
||||
## 2. Wayland side
|
||||
|
||||
### 2.1 Protocol status
|
||||
|
||||
`wp_color_management_v1` is **merged and stable-ish**: wayland-protocols MR !14, merged
|
||||
2025-02-13, shipped in **wayland-protocols 1.41**, file
|
||||
`staging/color-management/color-management-v1.xml`. Interfaces are at **version 3** upstream today
|
||||
(v2 added `get_image_description`/`preferred_changed2`; v3 added `create_windows_bt2100` and the
|
||||
`absolute_no_adaptation` intent). Predecessors: `zwp_linux_color_management_v1` →
|
||||
`xx_color_management_v4` (the name most 2023–2025 shipping code targeted) → `wp_*` on landing.
|
||||
`frog_color_management_v1` (Valve) is still vendored by gamescope alongside the real one and is
|
||||
still functionally load-bearing on the Deck.
|
||||
|
||||
Implementers: KWin (reference impl, most mature), Mutter (merged 2025-02-25 but still does not
|
||||
advertise enough features for automatic HDR), wlroots 0.20 / Sway 1.12 (HDR10 on the Vulkan
|
||||
renderer), gamescope (v1 semantics + frog), Weston (experimental, no tone mapping).
|
||||
Proton-CachyOS's changelog notes that its `winewayland.drv` `windows_bt2100` path needs protocol
|
||||
**v3** and that *"no compositor supports it yet"* — everybody is converged on **v1**.
|
||||
|
||||
**We only need v1.** That is what Mesa binds.
|
||||
|
||||
### 2.2 Minimum viable compositor subset
|
||||
|
||||
At bind, on the `wp_color_manager_v1` global, send one event per supported item then `done`:
|
||||
|
||||
* `supported_intent`: `perceptual` (mandatory anyway — it is all Mesa ever asks for)
|
||||
* `supported_feature`: `parametric` (gates `create_parametric_creator`); optionally
|
||||
`set_mastering_display_primaries`, and `extended_target_volume` **only if** we want scRGB
|
||||
* `supported_primaries_named`: `bt2020` (HDR10), `srgb` (needed for scRGB and for Mesa's
|
||||
"use a colour surface for sRGB too" branch), `display_p3` (wide gamut)
|
||||
* `supported_tf_named`: `st2084_pq` (HDR10), `ext_linear` (scRGB), `srgb`
|
||||
|
||||
Then implement: `create_parametric_creator` → `wp_image_description_creator_params_v1`
|
||||
(`set_primaries_named`, `set_tf_named`, `set_mastering_display_primaries`,
|
||||
`set_mastering_luminance`, `set_max_cll`, `set_max_fall`) → `create` → emit
|
||||
`wp_image_description_v1.ready` (or `failed`) → `wp_color_manager_v1.get_surface` →
|
||||
`wp_color_management_surface_v1.set_image_description(desc, intent)`, double-buffered on
|
||||
`wl_surface.commit`.
|
||||
|
||||
**Not needed:** ICC creator, `wp_color_management_surface_feedback_v1`,
|
||||
`wp_image_description_info_v1`, output image descriptions, v2/v3 requests. Mesa uses none of them.
|
||||
|
||||
### 2.3 What Mesa's WSI does — read from the exact commit we build
|
||||
|
||||
Read from `src/vulkan/wsi/wsi_common_wayland.c` at Mesa `7cda7850` (4121 lines — the commit
|
||||
recorded in `banners-turnip-wayland/mesa_hash.txt`). Landed upstream as MR !32038 (Xaver Hugl,
|
||||
merged 2025-02-25, Mesa 25.1).
|
||||
|
||||
* **Bind:** `registry_handle_global` binds `wp_color_manager_v1` at **version 1** unconditionally
|
||||
when advertised (`:1536-1538`), and installs `color_manager_listener` (`:1217-1223`).
|
||||
* **Colour-space list:** `wsi_wl_display_determine_colorspaces` (`:1122-1160`) always adds
|
||||
`VK_COLOR_SPACE_SRGB_NONLINEAR_KHR` and `VK_COLOR_SPACE_PASS_THROUGH_EXT`; everything else comes
|
||||
from the static `colorspace_mapping[]` table (`:1038-1118`) and is added **only if** the
|
||||
compositor advertised that entry's primaries *and* transfer function (and, for entries flagged
|
||||
`needs_extended_range`, `feature.extended_target_volume`). Table entries include
|
||||
`HDR10_ST2084` (bt2020 + st2084_pq), `EXTENDED_SRGB_LINEAR` (srgb + ext_linear + extended range),
|
||||
`DISPLAY_P3_NONLINEAR`, `DISPLAY_P3_LINEAR`, `BT709_LINEAR`, `BT709_NONLINEAR`, `BT2020_LINEAR`,
|
||||
`HDR10_HLG`, `ADOBERGB_LINEAR`.
|
||||
* **Surface formats:** `wsi_wl_surface_get_formats2` (`:2205-2246`) emits the **full cross product** of
|
||||
`display.colorspaces` × `display.formats` with **no bit-depth gating**:
|
||||
|
||||
```c
|
||||
u_vector_foreach(cs, &display.colorspaces) {
|
||||
u_vector_foreach(disp_fmt, &display.formats) {
|
||||
if (!(disp_fmt->flags & WSI_WL_FMT_ALPHA) || !(disp_fmt->flags & WSI_WL_FMT_OPAQUE))
|
||||
continue;
|
||||
out_fmt->surfaceFormat.format = disp_fmt->vk_format;
|
||||
out_fmt->surfaceFormat.colorSpace = *cs;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Consequence: if we advertise BT.2020 + PQ but keep only 8-bit DRM formats, Mesa will happily
|
||||
offer `R8G8B8A8_UNORM` + `HDR10_ST2084` and DXVK will **not** take it (`pickFormat`'s HDR10 list
|
||||
is 10-bit/16-bit only) — so there is no accidental 8-bit-PQ trap, but there is also no HDR
|
||||
unless we also advertise a 10-bit DRM format.
|
||||
* **Apply:** `wsi_wl_swapchain_update_colorspace` (`:1323-1455`) builds the parametric creator,
|
||||
blocks on `ready`/`failed` (it dispatches the queue in a loop), sets mastering primaries /
|
||||
luminance / max_cll / max_fall when `should_use_hdr_metadata` is set for that colour space, and
|
||||
calls `set_image_description(..., RENDER_INTENT_PERCEPTUAL)`. `is_hdr_metadata_legal`
|
||||
(`:1277-1299`) drops illegal combinations rather than risking a protocol error. On `failed`
|
||||
without `extended_target_volume` it retries once without metadata.
|
||||
* **`VK_EXT_hdr_metadata`:** `wsi_wl_swapchain_set_hdr_metadata` (`:1459-1463`) just stashes
|
||||
`VkHdrMetadataEXT`; the real work is in `update_colorspace` above.
|
||||
|
||||
**Nothing to build in the driver for HDR10.** Mesa is done.
|
||||
|
||||
### 2.4 Our compositor advertises nothing colorimetric
|
||||
|
||||
Globals (`compositor.c:2527-2538`, plus `ahb_swapchain.c:406`,
|
||||
`wl_clipboard.c:522-523`, `wl_text_input.c:275`, `wl_toplevel_icon.c:35`):
|
||||
`wl_compositor` v6, `wl_subcompositor`, `wp_viewporter`, `wl_output` v2, `xdg_wm_base`,
|
||||
`zwp_linux_dmabuf_v1` **v3**, `wl_seat` v5, `banner_desktop_v1`, `wp_presentation` v2,
|
||||
pointer constraints, relative pointer, `banner_ahb_v1` v2, data device/control, text input,
|
||||
toplevel icon. **No `wp_color_manager_v1`.** `protocols/` has no colour-management XML, and
|
||||
protocol C glue is pre-generated into `generated/` (no `wayland-scanner` at app build time —
|
||||
`CMakeLists.txt:1-4`), so adding a protocol means generating and committing the files offline.
|
||||
|
||||
The dmabuf format table is 8-bit only (`compositor.c:1323-1326`):
|
||||
|
||||
```c
|
||||
#define DMABUF_NFMT 4
|
||||
static struct { uint32_t fmt; uint64_t mods[DMABUF_NMOD]; int n; } g_dmabuf_fmts[DMABUF_NFMT] = {
|
||||
{DRM_ARGB8888}, {DRM_XRGB8888}, {DRM_ABGR8888}, {DRM_XBGR8888}};
|
||||
```
|
||||
|
||||
Good news: the machinery around it is already format-agnostic.
|
||||
`vkp_dmabuf_modifiers` (`vk_present.c`) takes a DRM fourcc and asks the compositor's own Turnip via
|
||||
`VkDrmFormatModifierPropertiesListEXT`, and `drm_to_vk` (`vk_present.c:105-123`) **already** maps
|
||||
`AB30`/`XB30` → `A2B10G10R10_UNORM_PACK32`, `AR30`/`XR30` → `A2R10G10B10_UNORM_PACK32`, and
|
||||
`AB4H`/`XB4H` → `R16G16B16A16_SFLOAT`. Adding 10-bit is a table edit plus the matching
|
||||
`FOURCC` defines next to `compositor.c:415-421`.
|
||||
|
||||
The compositor's own output swapchain is oblivious (`vk_present.c:301-311, 437-466`): two instance
|
||||
extensions (`VK_KHR_surface`, `VK_KHR_android_surface` — **no `VK_EXT_swapchain_colorspace`**),
|
||||
and `VkSurfaceFormatKHR chosen = fmts[0];` (`:441`) — the first format the Android WSI happens to
|
||||
return, with whatever colour space rides along. The scene image and the whole 13-pass effects
|
||||
chain are 8-bit (`vk_present.c:54` `SCENE_FMT = VK_FORMAT_R8G8B8A8_UNORM`; `effects_chain.c:29`
|
||||
`FX_FORMAT = VK_FORMAT_R8G8B8A8_UNORM`).
|
||||
|
||||
> **Naming collision, flag it in any UI work.** The drawer already has an "HDR" effect. It is
|
||||
> `effects_chain.c:197` `P_HDR` / `app/src/main/cpp/winlator/hdr.frag` — a dual-radius bloom +
|
||||
> contrast lift ported from `HDREffect.java`, `HDRPower = 1.30`, entirely SDR and entirely fake.
|
||||
> Real HDR must be named something else ("HDR output", "HDR10") or users will conflate them.
|
||||
|
||||
### 2.5 Is there a protocol-free shortcut?
|
||||
|
||||
No. A `DRM_FORMAT_ABGR2101010` buffer is equally valid as SDR BT.709 or as PQ BT.2020; the format
|
||||
and modifier describe byte layout, not colorimetry. That ambiguity is precisely why
|
||||
`wp_color_management_v1` exists. We *could* add a `set_dataspace` request to our own
|
||||
`banner_ahb_v1` and skip the standard protocol — but Mesa would never call it, so that would need
|
||||
a driver patch (new wcp) to buy something Mesa already gives us for free. **Implement
|
||||
`wp_color_manager_v1` v1 server-side; it is strictly cheaper.**
|
||||
|
||||
---
|
||||
|
||||
## 3. Android side
|
||||
|
||||
### 3.1 The real symbols, their API levels, and what the device has
|
||||
|
||||
`frameworks/native/include/android/surface_control.h`:
|
||||
|
||||
| Symbol | API level | Present in `/system/lib64/libandroid.so` on the Pocket FIT (API 34)? |
|
||||
|---|---|---|
|
||||
| `ASurfaceTransaction_setBufferDataSpace(tx, sc, ADataSpace)` | **29** | **PRESENT** |
|
||||
| `ASurfaceTransaction_setHdrMetadata_smpte2086(tx, sc, AHdrMetadata_smpte2086*)` | **29** | **PRESENT** |
|
||||
| `ASurfaceTransaction_setHdrMetadata_cta861_3(tx, sc, AHdrMetadata_cta861_3*)` | **29** | **PRESENT** |
|
||||
| `ASurfaceTransaction_setExtendedRangeBrightness(tx, sc, float cur, float desired)` | **34** | **PRESENT** |
|
||||
| `ASurfaceTransaction_setDesiredHdrHeadroom(tx, sc, float)` | **35** | absent (expected — device is 34) |
|
||||
| `ASurfaceTransaction_setLuts` | 36 | n/a |
|
||||
| `ASurfaceTransaction_setColorSpace` | **does not exist** | — |
|
||||
| `ASurfaceTransaction_setLuma` | **does not exist** | — |
|
||||
|
||||
(Checked with `strings` on the device's own `libandroid.so`; `setEnableBackPressure` and
|
||||
`setFrameRateWithChangeStrategy` confirmed present alongside, matching what `sc_layer.c` already
|
||||
dlsyms.)
|
||||
|
||||
Our dlsym table is `sc_layer.c:82-97` — 15 entries, **none of them colorimetric**. The additions
|
||||
needed are `setBufferDataSpace` (the only mandatory one), plus optionally
|
||||
`setHdrMetadata_smpte2086` / `_cta861_3` and `setExtendedRangeBrightness`. All four are API ≤ 34,
|
||||
i.e. inside the range `sc_layer.c` already targets, so the existing "missing symbol → path
|
||||
unavailable" pattern covers older devices unchanged.
|
||||
|
||||
### 3.2 Dataspaces we would emit
|
||||
|
||||
`ADataSpace` = `STANDARD (63<<16) | TRANSFER (31<<22) | RANGE (7<<27)`, all in the NDK since 29:
|
||||
|
||||
| Constant | Value | Maps from |
|
||||
|---|---|---|
|
||||
| `ADATASPACE_BT2020_PQ` | 163971072 | `VK_COLOR_SPACE_HDR10_ST2084_EXT` |
|
||||
| `ADATASPACE_BT2020_HLG` | 168165376 | `VK_COLOR_SPACE_HDR10_HLG_EXT` |
|
||||
| `ADATASPACE_SCRGB_LINEAR` | 406913024 | `VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT` |
|
||||
| `ADATASPACE_DISPLAY_P3` | 143261696 | `VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT` |
|
||||
| `ADATASPACE_SRGB` | 142671872 | `VK_COLOR_SPACE_SRGB_NONLINEAR_KHR` (today's implicit default) |
|
||||
|
||||
Every layer on the device right now reports `dataspace=UNKNOWN (0)`, which SF treats as sRGB.
|
||||
|
||||
### 3.3 Buffer formats
|
||||
|
||||
`AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM = 0x2b` (API 26) ↔ `VK_FORMAT_A2B10G10R10_UNORM_PACK32`
|
||||
— the normal 10-bit scanout format on Adreno DPUs. QTI gralloc on this device knows it:
|
||||
`strings /vendor/lib64/libqdMetaData.so` lists `RGBA_1010102`, `RGBX_1010102`, `BGRA_1010102`,
|
||||
`BGRX_1010102`. `AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT = 0x16` (API 26) exists but is a
|
||||
compositing intermediate, not normally a scanout format — it was **not** found in the vendor
|
||||
gralloc strings, so treat FP16 gralloc allocation on this SoC as unproven.
|
||||
`AHardwareBuffer_isSupported()` (API 29) is the correct runtime probe, and we should use it rather
|
||||
than assume.
|
||||
|
||||
The compositor's own AHB pool is hardcoded 8-bit (`sc_layer.c:302`
|
||||
`.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM`) and the imported view is built with
|
||||
`DRM_ABGR8888` (`sc_layer.c:326`). That is the *copy* path; the zero-copy path
|
||||
(`sc_layer_present_ahb`, `sc_layer.c:430`) takes the game's own buffer and so already carries
|
||||
whatever format the game allocated — it just never labels it.
|
||||
|
||||
### 3.4 What SurfaceFlinger does with an HDR layer on an SDR panel
|
||||
|
||||
From `services/surfaceflinger/CompositionEngine/src/Output.cpp`, `getBestDataspace()` /
|
||||
`pickColorProfile()`:
|
||||
|
||||
* A `BT2020_PQ` layer sets `outHdrDataSpace = BT2020_PQ` but the output only *adopts* it when
|
||||
`DisplayColorProfile::hasLegacyHdrSupport(BT2020_PQ)` is true — i.e. when the Composer HAL
|
||||
reported HDR types for that display. Otherwise the output dataspace stays `DISPLAY_P3` with
|
||||
`COLORIMETRIC` intent, and the layer is **tone-mapped, not rejected**.
|
||||
* Because the HWC for an SDR-only display cannot consume a PQ buffer, the standard
|
||||
`validateDisplay()` negotiation marks that layer **CLIENT** instead of **DEVICE**, and
|
||||
RenderEngine/Skia composites it with the `libtonemap` SkSL gain shader
|
||||
(`libtonemap_LookupTonemapGain`, uniforms `in_libtonemap_displayMaxLuminance` /
|
||||
`in_libtonemap_inputMaxLuminance`).
|
||||
* **This is the trap for us.** Our whole zero-copy win is that `banner_wayland_game` composites
|
||||
DEVICE (proven 2026-09-13: DEVICE with ROT_90 + 1.5× scale at 144 Hz, −4 pts GPU busy, −3 %
|
||||
power). Tagging that layer `BT2020_PQ` on a panel with no HDR types is very likely to drop it to
|
||||
CLIENT — i.e. HDR would **buy a washed-out tone-map and pay for it with the zero-copy saving**.
|
||||
Any implementation must gate the dataspace on the *display's* reported HDR types, not on the
|
||||
game's request.
|
||||
* `setExtendedRangeBrightness` is a different mechanism: it applies only to `RANGE_EXTENDED`
|
||||
(scRGB) layers and works by having SF dim the *other* layers by `whitePointNits / maxWhitePoint`
|
||||
(`renderengine/LayerSettings.h`) while leaving the extended layer undimmed, so the boosted layer
|
||||
reads brighter by simultaneous contrast without exceeding the panel ceiling.
|
||||
**It needs the display to expose an HDR/SDR ratio.** This panel does not (§4).
|
||||
* `setDesiredHdrHeadroom` (API 35) is the PQ/HLG equivalent and overrides/`is overridden by`
|
||||
`setExtendedRangeBrightness` — last call wins. Not available on the test device at all.
|
||||
|
||||
### 3.5 `has_HDR_display` vs `getHdrCapabilities()`
|
||||
|
||||
`ro.surface_flinger.has_HDR_display` is a **build-time** declaration (`TARGET_HAS_HDR_DISPLAY`)
|
||||
that the device *has* a wide-gamut, high-luminance panel; it gates SF-internal colour-management
|
||||
machinery. `Display.getHdrCapabilities().getSupportedHdrTypes()` is the **runtime, per-display**
|
||||
answer, built from the Composer HAL's `getHdrCapabilities()` for that connector, itself derived
|
||||
from the EDID CTA-861.3 Static Metadata Data Block. **They can disagree, and on this device they
|
||||
do.** An empty list does not mean rejection — it means "tone-map it."
|
||||
|
||||
### 3.6 External display
|
||||
|
||||
On hotplug, the framework queries `getDisplayConfigs`, `getColorModes`, `getHdrCapabilities`,
|
||||
`getDisplayCapabilities` for the new display handle exactly as for the internal panel, so
|
||||
`Display.getHdrCapabilities()` on an external `Display` *is* architecturally wired to reflect the
|
||||
monitor's EDID. Whether it actually does is a vendor-HWC question; empty lists for genuinely
|
||||
HDR10 USB-C monitors are a commonly reported Snapdragon gap. **Unproven for the Pocket FIT — the
|
||||
only way to know is to plug one in.**
|
||||
|
||||
---
|
||||
|
||||
## 4. What the test device can and cannot show
|
||||
|
||||
All read today from the Pocket FIT (Adreno 750, Android 14 / API 34), read-only:
|
||||
|
||||
```
|
||||
DisplayDeviceInfo{"Built-in Screen": 1080 x 1920, ...
|
||||
supportedModes [... supportedHdrTypes=[] (all four modes) ],
|
||||
colorMode 0, supportedColorModes [0],
|
||||
hdrCapabilities HdrCapabilities{mSupportedHdrTypes=[], mMaxLuminance=500.0,
|
||||
mMaxAverageLuminance=500.0, mMinLuminance=0.0},
|
||||
hdrSdrRatio NaN, brightnessMaximum 1.0 ...}
|
||||
mBaseDisplayInfo: ... hdrSdrRatio not_available, userDisabledHdrTypes []
|
||||
```
|
||||
|
||||
```
|
||||
dumpsys SurfaceFlinger:
|
||||
Wide-Color information:
|
||||
Device supports wide color: 1
|
||||
Device uses color management: 1
|
||||
DisplayColorSetting: Managed
|
||||
Display 4630946852602928515 color modes:
|
||||
ColorMode::NATIVE (0)
|
||||
Current color mode: ColorMode::NATIVE (0)
|
||||
colorMode=NATIVE (0) renderIntent=COLORIMETRIC (0) dataspace=UNKNOWN (0) targetDataspace=UNKNOWN (0)
|
||||
displayBrightnessNits=-1.000000 sdrWhitePointNits=-1.000000 displayBrightness=nullopt
|
||||
(every layer) dataspace=UNKNOWN (0) hdr metadata types=0
|
||||
```
|
||||
|
||||
```
|
||||
getprop:
|
||||
[ro.surface_flinger.has_HDR_display]: [true]
|
||||
[ro.surface_flinger.has_wide_color_display]: [true]
|
||||
[ro.surface_flinger.wcg_composition_dataspace]: [143261696] = ADATASPACE_DISPLAY_P3
|
||||
[persist.sys.sf.color_mode]: [9] = ColorMode::DISPLAY_P3
|
||||
[vendor.display.enable_hdr10_gpu_target]: [1]
|
||||
```
|
||||
|
||||
Reading:
|
||||
|
||||
* The **build** declares an HDR, wide-colour device and even asks for `DISPLAY_P3` as the system
|
||||
colour mode (`persist.sys.sf.color_mode=9`), but the **HWC reports `supportedColorModes=[0]`
|
||||
(NATIVE only) and no HDR types**, so SF runs the display in NATIVE with COLORIMETRIC intent and
|
||||
the P3 request is inert. The props are aspirational; the HAL is the truth.
|
||||
* `hdrSdrRatio not_available` / `NaN` and `displayBrightnessNits = -1` mean
|
||||
`Display.isHdrSdrRatioAvailable()` is false → **`setExtendedRangeBrightness` has nothing to act
|
||||
on here.** The "brighten highlights on an SDR panel" trick is unavailable on this device.
|
||||
* `supportedColorModes=[0]` also means **Display-P3 wide gamut is not available either** — not
|
||||
just HDR. A P3-tagged layer would be colour-converted into the panel's native gamut, i.e. into
|
||||
whatever the panel natively is, with no way for us to know what that is.
|
||||
* 500 nits max luminance is below the ~540-nit bar AOSP's own `has_HDR_display` doc cites, and
|
||||
there is no HDR type to signal anyway.
|
||||
|
||||
**Conclusion: visual HDR cannot be demonstrated on the Pocket FIT's internal panel, and neither
|
||||
can wide gamut, and neither can extended-range brightness.** The only things provable on this
|
||||
device are (a) 10-bit buffers end to end (banding reduction, measurable), and (b) plumbing
|
||||
correctness by logs and `dumpsys`.
|
||||
|
||||
Vulkan-side, for completeness (device `strings`):
|
||||
|
||||
| Library | `VK_EXT_swapchain_colorspace` | `VK_EXT_hdr_metadata` |
|
||||
|---|---|---|
|
||||
| `/system/lib64/libvulkan.so` (platform loader — implements the Android swapchain) | **PRESENT** | **PRESENT** |
|
||||
| `/vendor/lib64/hw/vulkan.adreno.so` (Qualcomm blob) | absent | absent |
|
||||
| `/vendor/lib64/hw/vulkan.turnip.so` (vendor-shipped Turnip) | **PRESENT** | **PRESENT** |
|
||||
| wcp v6 `libvulkan_freedreno_wayland.so` (game driver) | **PRESENT** | **PRESENT** |
|
||||
|
||||
The platform loader contains the string `native_window_set_buffers_data_space(%d) failed: %s (%d)`
|
||||
— i.e. Android's own swapchain implementation is what turns a `VkColorSpaceKHR` into a surface
|
||||
dataspace. So for the **copy path**, the compositor's output HDR is genuinely just "enable
|
||||
`VK_EXT_swapchain_colorspace` at instance creation and pick a better surface format than
|
||||
`fmts[0]`". No driver work.
|
||||
|
||||
---
|
||||
|
||||
## 5. The gap list, ordered, with sizes
|
||||
|
||||
Sizes are engineer-days for someone who already knows this code. "Prove" = device-visible in logs
|
||||
or `dumpsys`, not by eye. **App-only unless marked.**
|
||||
|
||||
### Phase A — make the truth reachable (no user-visible HDR yet)
|
||||
|
||||
| # | Repo | Work | Size |
|
||||
|---|---|---|---|
|
||||
| A1 | app | **Advertise 10-bit DRM formats over `zwp_linux_dmabuf_v1`.** Add `AB30`/`XB30` (and optionally `AR30`/`XR30`, `AB4H`/`XB4H`) to `compositor.c:1323-1326` + `FOURCC` defines near `:415-421`. `vkp_dmabuf_modifiers` and `drm_to_vk` already handle them, so this is a table edit + a log line. Risk: a client picking a 10-bit format while the scene/effects chain stays 8-bit — the import works (`drm_to_vk`), the blit downconverts. Gate behind a flag until A4. | **0.5 d** |
|
||||
| A2 | app | **Generate + commit `color-management-v1` protocol glue.** Fetch `staging/color-management/color-management-v1.xml` from wayland-protocols ≥ 1.41, run `wayland-scanner` offline, commit XML + `generated/color-management-v1-{protocol.c,server-protocol.h}`, add to `CMakeLists.txt`. Mechanical. | **0.5 d** |
|
||||
| A3 | app | **Implement `wp_color_manager_v1` v1 server-side** (new `wl_color_mgmt.c`, ~400–500 lines): the global + bind-time feature/intent/primaries/tf events; the parametric creator with `set_primaries_named`/`set_tf_named`/`set_max_cll`/`set_max_fall`/`set_mastering_*`; image-description objects with `ready`/`failed`; `get_surface` → `wp_color_management_surface_v1` and `set_image_description` stored double-buffered on our `struct surface`. **Watch the blocking loop:** Mesa dispatches its queue waiting for `ready`, so we must send `ready` from the request handler's own flush, not defer it to the next frame, or a game stalls at swapchain creation. Advertise only what the *current output* can actually honour (see A5). | **2 d** |
|
||||
| A4 | app | **Carry the image description onto the Android layer.** dlsym `ASurfaceTransaction_setBufferDataSpace` (+ `setHdrMetadata_smpte2086` / `_cta861_3`) in `sc_layer.c:82-97`; map surface image description → `ADataSpace` + `AHdrMetadata_*`; apply in `sc_layer_present_ahb` (`sc_layer.c:430-470`, next to the existing `setBuffer`). Plumb the per-surface description from `compositor.c` through `ahb_swapchain.c:219`. Also set an explicit `ADATASPACE_SRGB` on the existing 8-bit path so we stop relying on `UNKNOWN`. | **1 d** |
|
||||
| A5 | app | **Capability gate.** Read `Display.getHdrCapabilities()` / `getSupportedHdrTypes()` / `isHdrSdrRatioAvailable()` (and the external `Display` when `ExternalDisplayController` has one) in Java, pass down over JNI, and *only then* advertise `bt2020`/`st2084_pq` from A3. Without this we advertise HDR on a panel that will tone-map it and drop the layer to CLIENT (§3.4). Include a `banner_log("color", ...)` line naming exactly what was advertised and why. | **0.5 d** |
|
||||
|
||||
**Phase A total: ~4.5 days. App-only. No new wcp.** End state: a game with `DXVK_HDR=1` on a
|
||||
genuinely HDR display gets an HDR10 swapchain, its buffer reaches an `ASurfaceControl` layer
|
||||
tagged `BT2020_PQ` with real mastering metadata, and `dumpsys SurfaceFlinger` proves it.
|
||||
|
||||
### Phase B — the copy path and the effects chain (only if A is kept)
|
||||
|
||||
| # | Repo | Work | Size |
|
||||
|---|---|---|---|
|
||||
| B1 | app | **10-bit output swapchain.** Add `VK_EXT_swapchain_colorspace` to `vk_present.c:301-311` (`enabledExtensionCount` 2 → 3), replace `chosen = fmts[0]` (`:441`) with a real preference walk (HDR10 + `A2B10G10R10` when the display supports it, else `R8G8B8A8_UNORM` + sRGB). The Android platform loader does the rest. | **0.5 d** |
|
||||
| B2 | app | **Widen the scene + effects chain.** `SCENE_FMT` (`vk_present.c:54`) and `FX_FORMAT` (`effects_chain.c:29`) → `A2B10G10R10_UNORM_PACK32` (or FP16 for real HDR headroom). Every one of the 13 passes samples/writes it; the debanding pass in particular must be re-tuned because its strength is calibrated for 8-bit quantisation. Memory and bandwidth go up ~25 % (or 100 % for FP16). This is the expensive item and it regresses SDR perf if done unconditionally. | **2 d** |
|
||||
| B3 | app | **Layer pool at 10-bit.** `sc_layer.c:302` pool format → `R10G10B10A2_UNORM` when the chain is 10-bit, guarded by `AHardwareBuffer_isSupported()`, with the existing `sniff_modifier`/linear-fallback retry extended. | **0.5 d** |
|
||||
|
||||
**Phase B total: ~3 days. App-only. No new wcp.**
|
||||
|
||||
### Phase C — scRGB, and the one thing that needs a wcp
|
||||
|
||||
| # | Repo | Work | Size |
|
||||
|---|---|---|---|
|
||||
| C1 | **driver (new wcp)** | Map `VK_FORMAT_R16G16B16A16_SFLOAT` → `AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT` (0x16) in `banner_ahb_format_for` (`patches/wayland/banner_ahb_wsi.py:225-237`) so FP16 swapchains are not hidden by `banner_ahb_skip_format` when zero-copy is on. One enum + a rebuild of eight drivers. **This is the only wcp-requiring item, and only for scRGB zero-copy.** Blocked on proving FP16 gralloc allocation works on Adreno at all (§3.3). | **0.5 d + a driver build cycle** |
|
||||
| C2 | app | Advertise `extended_target_volume` + `ext_linear` + `AB4H`/`XB4H`, emit `ADATASPACE_SCRGB_LINEAR`, and wire `ASurfaceTransaction_setExtendedRangeBrightness` from `Display.getHdrSdrRatio()`. | **1 d** |
|
||||
| C3 | **proton-wine (new wcp)** | *Optional, quality only.* Synthesise an EDID with a CTA-861.3 HDR static metadata block in `winewayland.drv` so DXVK reports the real panel luminance in `DXGI_OUTPUT_DESC1` instead of its 1499-nit dummy. | **1–2 d** |
|
||||
|
||||
---
|
||||
|
||||
## 6. Cheap partial wins — and which are visible on a 500-nit panel
|
||||
|
||||
| Idea | Verdict on the Pocket FIT | Notes |
|
||||
|---|---|---|
|
||||
| **10-bit output (banding)** | **Visible, and the best value here.** | This is the one real win. B1 alone (0.5 d) gets a 10-bit output swapchain; A1 (0.5 d) lets the *game* render 10-bit. Adreno 750 + the DPU handle `RGBA_1010102` natively, and `vendor.display.enable_hdr10_gpu_target=1` says the GPU target path expects it. Pairs with the existing debanding pass — arguably makes it unnecessary for 10-bit-capable games, which saves a full-screen pass. Visible on gradients (skyboxes, fog, dark interiors) where our deband pass currently earns its keep. |
|
||||
| **Display-P3 wide gamut on SDR** | **Not visible. Do not build.** | `supportedColorModes=[0]` / `ColorMode::NATIVE` — the HWC exposes no P3 mode. `persist.sys.sf.color_mode=9` asks for P3 and is ignored. Tagging a layer `ADATASPACE_DISPLAY_P3` would make SF convert P3 → the panel's native gamut, which on a NATIVE-mode display is an unknown-to-us transform. Net effect on this device: at best nothing, at worst a colour shift. |
|
||||
| **`setExtendedRangeBrightness` to lift highlights** | **Not available.** | `hdrSdrRatio not_available` / `NaN`, `displayBrightnessNits=-1`, `sdrWhitePointNits=-1`. `Display.isHdrSdrRatioAvailable()` is false, so there is no headroom to claim and SF has no nits data to dim the other layers against. |
|
||||
| **`setDesiredHdrHeadroom`** | **Not available.** | API 35; device is API 34. Absent from `libandroid.so`. |
|
||||
| **Set `ADATASPACE_SRGB` explicitly on our layers** | **Invisible but worth doing anyway (part of A4, ~0 extra cost).** | Every layer currently reports `dataspace=UNKNOWN (0)`. It works today because SF treats UNKNOWN as sRGB, but it is an accident we are relying on, and it will become wrong the moment any colour management is enabled. |
|
||||
|
||||
**So: of the three "cheap wins" in the brief, exactly one — 10-bit — is real on this hardware,
|
||||
and it is worth about 1 engineer-day (A1 + B1) on its own, independent of HDR.**
|
||||
|
||||
---
|
||||
|
||||
## 7. How we would ever prove it
|
||||
|
||||
### 7.1 Which games actually emit HDR under DXVK / VKD3D
|
||||
|
||||
Requirements: a flip-model swapchain at `R10G10B10A2_UNORM` or `R16G16B16A16_FLOAT`, an
|
||||
`IDXGISwapChain3::SetColorSpace1` call, and `DXVK_HDR=1` in the environment. Known-good
|
||||
candidates, easiest first:
|
||||
|
||||
* **D3D11 + scRGB:** *Shadow of the Tomb Raider*, *Resident Evil 2/3 Remake*, *Devil May Cry 5*,
|
||||
*Mass Effect Legendary Edition*. RE Engine titles are the usual smoke test on Linux because they
|
||||
call `SetColorSpace1` early and unconditionally when DXGI reports HDR.
|
||||
* **D3D12 + HDR10:** *Cyberpunk 2077*, *Forza Horizon 5*, *Horizon Zero Dawn*. These go through
|
||||
vkd3d-proton's stricter path (§1.1) — good for catching a half-done implementation, since a
|
||||
wrong answer **stalls presentation** instead of degrading.
|
||||
* **Sanity harness, no game needed:** anything that calls `vkGetPhysicalDeviceSurfaceFormatsKHR`
|
||||
under the layer. `vulkaninfo` is not available in the prefix, but a tiny Win32 Vulkan probe
|
||||
built against the layer's headers, or simply DXVK's own `VK_INSTANCE_LAYERS`-free log with
|
||||
`DXVK_LOG_LEVEL=info` and `DXVK_HDR=1`, will say whether the colour space was accepted. **Start
|
||||
here** — it is the cheapest signal and needs no HDR display at all.
|
||||
|
||||
### 7.2 Platform-side verification (not by eye)
|
||||
|
||||
Order of proof, each step gating the next:
|
||||
|
||||
1. **Compositor log.** New `banner_log("color", ...)` lines: which primaries/tf we advertised and
|
||||
why; every image description created (primaries, tf, max_cll, max_fall); every dataspace set on
|
||||
the layer. This is the only step that works on any device.
|
||||
2. **Guest log.** `DXVK_HDR=1` + `DXVK_LOG_LEVEL=info` → DXVK prints the chosen colour space and
|
||||
format at swapchain creation. If `SetColorSpace1` was refused, DXVK says so. Mesa's WSI prints
|
||||
`Not using HDR metadata to avoid protocol errors` when `is_hdr_metadata_legal` rejects metadata
|
||||
— catching that string is a direct test of A3's metadata plumbing.
|
||||
3. **`dumpsys SurfaceFlinger | grep banner_wayland_game`.** Today it prints
|
||||
`dataspace=UNKNOWN (0) hdr metadata types=0`. Success = `dataspace:0x9c60000` (`BT2020_PQ`, 163971072 =
|
||||
`STANDARD_BT2020|TRANSFER_ST2084|RANGE_FULL`) and `hdr metadata types=` non-zero. **Also record `composition:` on the same line**
|
||||
— if it flips DEVICE → CLIENT, HDR cost us the zero-copy win (§3.4) and that is a failure, not a
|
||||
success.
|
||||
4. **`dumpsys display`.** On whatever display is in use: `supportedHdrTypes=[...]` non-empty,
|
||||
`colorMode` ≠ 0, `hdrSdrRatio` ≠ `not_available`. This is the gate for steps 5–6; on the Pocket
|
||||
FIT's internal panel it will never pass.
|
||||
5. **`dumpsys SurfaceFlinger` Wide-Color section.** `Current color mode` should move off
|
||||
`ColorMode::NATIVE (0)`, and the output line's `dataspace=`/`targetDataspace=` should stop being
|
||||
`UNKNOWN (0)`.
|
||||
6. **Only then, by eye.**
|
||||
|
||||
### 7.3 Getting a display that can actually show it — three options, ranked
|
||||
|
||||
1. **External HDR display over USB-C (recommended, cheapest).** The app already reparents the game
|
||||
into a `Presentation` on a secondary display —
|
||||
`app/src/main/java/com/winlator/star/display/ExternalDisplayController.java`,
|
||||
`findPresentationDisplay()` picks a `DISPLAY_CATEGORY_PRESENTATION` display that is not the
|
||||
activity's own. In the Wayland session the compositor's `SurfaceView` is the reparented view, so
|
||||
`sc_layer.c`'s `ASurfaceControl_createFromWindow(vkp_window(), ...)` follows it automatically —
|
||||
**no new plumbing to test on an external panel.** Risk: `Display.getHdrCapabilities()` for a
|
||||
DP-alt-mode display depends on the vendor HWC reading the external EDID, and empty lists for
|
||||
genuinely HDR10 monitors are a common Snapdragon gap (§3.6). **Step zero is a five-minute,
|
||||
zero-code test: plug an HDR monitor in and run `dumpsys display | grep -A2 hdrCapabilities`.**
|
||||
If the external display reports HDR types, everything else follows. If it does not, options 2
|
||||
and 3 are all that remain.
|
||||
2. **The user's Galaxy Fold (Adreno 840).** Samsung foldables/flagships do report HDR10+ on the
|
||||
internal panel, so this is the most likely device to show real HDR with no extra hardware. But
|
||||
the Fold is *already* the outstanding unknown for basic Wayland bring-up (checkpoint item 1:
|
||||
"Other GPUs… the Galaxy Fold (A840) logs are still outstanding"). Chasing HDR there before
|
||||
plain Wayland is proven there inverts the priority order.
|
||||
3. **Plumbing-only verification on SDR.** Everything in §7.2 steps 1–3 works on the Pocket FIT.
|
||||
This proves the code is *correct* but proves nothing about whether it *looks right* — and
|
||||
tone-mapping quality is the entire user-visible payload of HDR. **Do not ship on this evidence
|
||||
alone.**
|
||||
|
||||
---
|
||||
|
||||
## 8. Verdict
|
||||
|
||||
**Not now. Do the 10-bit slice; park HDR behind the Fold.**
|
||||
|
||||
The reasoning, plainly:
|
||||
|
||||
* **The effort is genuinely small and smaller than we thought.** ~4.5 days to a plumbed HDR10
|
||||
path, **app-only, no new wcp** — because Mesa's colour-management client is already inside the
|
||||
shipped wcp v6 driver and our zero-copy WSI patch already maps 10-bit to gralloc. The phase-4
|
||||
memory note saying HDR "does need a new wcp" should be corrected: only scRGB/FP16 zero-copy (C1)
|
||||
does, and that is optional.
|
||||
* **But the payload is zero on the only device we can test on.** The Pocket FIT reports no HDR
|
||||
types, no colour modes but NATIVE, no HDR/SDR ratio and no brightness nits. We could not see the
|
||||
feature, could not tune the tone-mapping, and could not tell a correct implementation from a
|
||||
subtly wrong one. Shipping HDR proven only by log lines would be the exact opposite of this
|
||||
project's "device-proven, not CI-green" rule.
|
||||
* **On this device it would be a net negative if enabled.** §3.4: an HDR-dataspace layer on a
|
||||
display with no HDR types drops from DEVICE to CLIENT composition. That trades the measured
|
||||
zero-copy win (−4 pts GPU busy, −3 % power) for a GPU tone-map pass and a washed-out image. A
|
||||
capability gate (A5) prevents the harm, but a gate that is always closed on our test hardware is
|
||||
a feature nobody can exercise.
|
||||
* **It is also out of order.** The pre-4 checkpoint's ranked list puts "other GPUs" and "prove
|
||||
zero-copy where it can win, then make it the default" first, with multi-layer presentation in
|
||||
flight. HDR competes with those for the same `sc_layer.c` surface area — and multi-layer will
|
||||
rewrite exactly the code A4 touches. Landing HDR into `sc_layer.c` now means merging it twice.
|
||||
|
||||
**What the user would actually see for the effort, honestly:**
|
||||
|
||||
* **Today, Pocket FIT, full HDR (7.5 days):** nothing. Identical picture, plus a `dumpsys` line
|
||||
that says `BT2020_PQ`, plus a risk of losing zero-copy.
|
||||
* **Today, Pocket FIT, the 10-bit slice only (A1 + B1, ~1 day):** *slightly* smoother gradients in
|
||||
dark scenes and skyboxes for games that offer a 10-bit swapchain, and a plausible route to
|
||||
retiring the debanding pass (one fewer fullscreen pass) for those games. Small, real, and it is
|
||||
the foundation Phase A sits on anyway — so it is not wasted work if HDR later goes ahead.
|
||||
* **Later, on an HDR display (external monitor or the Fold), full Phase A:** genuinely brighter
|
||||
highlights and a wider gamut in the ~15 PC titles that implement HDR properly, on the one Android
|
||||
emulator that can do it. That is a real headline feature and a real differentiator — but only
|
||||
once there is a panel to show it on.
|
||||
|
||||
**Recommended sequence:**
|
||||
|
||||
1. **Five minutes, zero code:** plug an HDR monitor into the Pocket FIT's USB-C and run
|
||||
`dumpsys display | grep -A2 hdrCapabilities`. This single reading decides everything —
|
||||
it is the difference between "we can develop and prove HDR today on hardware we own" and
|
||||
"HDR is blocked on the Fold."
|
||||
2. **~1 day, independent of HDR:** the 10-bit slice (A1 + B1), gated and A/B'd for banding and
|
||||
perf. Ship it as a banding/quality improvement on its own merits.
|
||||
3. **Park Phase A (A2–A5)** until either step 1 comes back positive or the Fold is in the loop
|
||||
and plain Wayland is proven there. Revisit *after* multi-layer presentation lands, so the
|
||||
`sc_layer.c` dataspace work is written once against the final layer API.
|
||||
|
||||
---
|
||||
|
||||
## 9. What I could not establish, and why
|
||||
|
||||
* **Whether FP16 (`R16G16B16A16_FLOAT`) AHardwareBuffers are allocatable on this SoC.** Not in the
|
||||
vendor gralloc strings, and I did not install or run a probe binary (other agents are testing on
|
||||
the device). Decides whether scRGB zero-copy (C1) is possible at all. Cheap to settle later with
|
||||
a one-call `AHardwareBuffer_isSupported()` check inside the compositor's existing startup log.
|
||||
* **Whether an external HDR display over USB-C actually reports HDR types on the Pocket FIT.**
|
||||
No external display was connected and I did not connect one. This is the single highest-value
|
||||
unknown in the whole report (§8, step 1).
|
||||
* **Whether an HDR-tagged layer really drops DEVICE → CLIENT on this HWC.** The AOSP code path is
|
||||
clear (§3.4) but it is vendor-HWC behaviour and I did not test it — testing it would mean
|
||||
launching a game, which was out of scope.
|
||||
* **What the Galaxy Fold (Adreno 840, Android version unknown to me) reports.** Not connected.
|
||||
Its `getHdrCapabilities()` and `isHdrSdrRatioAvailable()` are the other decisive readings.
|
||||
* **Exact Mesa line numbers.** Cited against `wsi_common_wayland.c` fetched from
|
||||
`gitlab.freedesktop.org/mesa/mesa` at `7cda7850edd103ace21aac37d416d2fdf7a282e1`, the commit in
|
||||
`banners-turnip-wayland/mesa_hash.txt`. They are accurate for that file; they will drift if the
|
||||
Turnip base moves.
|
||||
* **DXVK/vkd3d-proton line numbers** are cited against upstream `doitsujin/dxvk@8759acd1` and
|
||||
`HansKristian-Work/vkd3d-proton@2a38e799` (master as of today), not against the exact
|
||||
v3.1-gplasync / 3.1.0-wave64-relax builds we ship. The feature presence in *our* builds was
|
||||
verified independently by `strings` on the device (§1.1); the line numbers are for orientation.
|
||||
* **Whether any of the games in §7.1 launch and run correctly under our Wayland backend at all.**
|
||||
Untested. Picking the HDR test title is its own small exercise and should start from games
|
||||
already known to work in a Wayland container.
|
||||
|
||||
---
|
||||
|
||||
## 10. Round 1 — as built (2026-09-14, `feat/wayland-hdr`)
|
||||
|
||||
Phase A (A1–A5) for HDR10, opt-in, proven by the app's own logs because the first HDR panel in the
|
||||
loop is a tester's non-rooted Galaxy Fold (Adreno 840, Android API 37: HDR10/HLG/HDR10+, 1351 nits,
|
||||
HDR/SDR ratio available). App-only; no layer change.
|
||||
|
||||
### 10.1 The gate (`wl_color_mgmt.c`, `banner_color_init`)
|
||||
|
||||
Open only when ALL hold when the compositor starts:
|
||||
|
||||
| Input | Where it comes from |
|
||||
|---|---|
|
||||
| `BANNER_WAYLAND_HDR=1` (or `true`/`on`) | container or shortcut env (`XServerDisplayActivity.resolvedWaylandHdrMode`) |
|
||||
| the game's display lists **HDR10** | `DisplayHdrInfo.supportsHdr10` for `hdrTargetDisplay()` (the TV when the game is on it) |
|
||||
| display layers with dataspace control | `sc_layer_can_tag_hdr()` = SurfaceControl API + `ASurfaceTransaction_setBufferDataSpace` |
|
||||
| the zero-copy global | `ahb_swapchain_advertised()` |
|
||||
|
||||
`BANNER_WAYLAND_HDR=force` skips the display row only (testing the negotiation on an SDR panel —
|
||||
SurfaceFlinger then tone-maps the layer). A **closed** gate advertises nothing (no
|
||||
`wp_color_manager_v1` global, no 10-bit dma-buf rows), writes `color … HDR gate CLOSED: <why>` and
|
||||
`HDR on screen: no, because <why>`, and the session is otherwise byte-for-byte the old one. With the
|
||||
switch unset the module is silent unless the display lists HDR10 or `DXVK_HDR=1` is set (one hint line).
|
||||
On an HDR10 display the app also turns **zero-copy presentation on** for the session (an HDR frame is
|
||||
only right on the game's own layer) and exports `BANNER_WSI_AHB=1` to match.
|
||||
|
||||
### 10.2 What an open gate offers (§2.2, exactly what Mesa binds)
|
||||
|
||||
`wp_color_manager_v1` **version 1**: intent `perceptual`; features `parametric` +
|
||||
`set_mastering_display_primaries` (Mesa only sends mastering luminance inside that feature's branch);
|
||||
primaries `bt2020`; transfer `st2084_pq`. Not advertised: `srgb` (so Mesa creates no colour surface for
|
||||
SDR swapchains at all), HLG (no DXGI swapchain uses it), `ext_linear`/`extended_target_volume` (scRGB =
|
||||
Phase C, needs FP16 gralloc + a layer change), ICC, `windows_scrgb`. `zwp_linux_dmabuf_v1` gains
|
||||
`AB30`/`XB30` (A2B10G10R10 — Mesa lists a VkFormat only when both the alpha and opaque fourcc are there),
|
||||
appended after the four 8-bit rows. Protocol glue generated from wayland-protocols **1.41** with
|
||||
wayland-scanner 1.24.0 (`protocols/color-management-v1.xml`).
|
||||
|
||||
Strictness: protocol errors only where a conforming client can never hit them (un-advertised
|
||||
feature/intent/primaries/tf, a property set twice, an incomplete set, a not-ready description).
|
||||
Everything a conforming client can produce on a bad day is logged and absorbed instead — out-of-range
|
||||
HDR metadata is dropped from what Android gets (and `max_cll`/`max_fall` of 0 = "unknown", which Mesa
|
||||
sends as-is), a second colour surface for the same `wl_surface` replaces the first, requests on inert
|
||||
objects are ignored. `ready` is sent from inside `create` (Mesa blocks its swapchain on it).
|
||||
Output and surface-feedback image descriptions answer `failed` (Mesa uses neither).
|
||||
|
||||
### 10.3 The layer path (`sc_layer.c`)
|
||||
|
||||
`setBufferDataSpace` (+ `setHdrMetadata_smpte2086` / `_cta861_3` when present) ride the same
|
||||
transaction as the buffer, per layer, only on change, re-sent on every new SurfaceControl (recovery
|
||||
swap, window change). A layer that was never tagged is never touched; once tagged, an untagged frame
|
||||
puts it back to `UNKNOWN` and clears the metadata. The zero-copy frame gets the surface's current
|
||||
description; the 8-bit pool copy of an HDR frame keeps the PQ tag (colours right, 8-bit precision,
|
||||
logged once); the effects pass and the overlay layer are always untagged.
|
||||
|
||||
### 10.4 When an HDR frame cannot be zero-copy — round 1's decision
|
||||
|
||||
No tone-mapping anywhere (the copy path is `vkCmdBlitImage` into an 8-bit sRGB swapchain; a PQ→SDR
|
||||
shader pass is its own project). Instead:
|
||||
|
||||
- **Effects on / frame generation on:** an HDR fullscreen game **keeps its display layer**; the
|
||||
effects chain and frame generation are skipped for it (both are 8-bit SDR and would wash it out),
|
||||
and the base surface's black frame skips them too (`vkp_render_plain`) so generated presents cannot
|
||||
pace the loop. Logged when it starts and when it ends.
|
||||
- **A window above the game on a display that cannot compose a second layer** (phase 5's
|
||||
rotated+scaled rule is untouched), **a windowed HDR game**, **zero-copy switched off**, **layer
|
||||
unavailable:** the scene goes through the copy path and the HDR frames are shown **untone-mapped
|
||||
(washed out)**; every such scene is counted and the reason logged.
|
||||
|
||||
### 10.5 Proof without root — what a tester's logs say
|
||||
|
||||
`Download/Wayland-logs/wayland-*.log`, tag `color` (plus the existing `display` capability line):
|
||||
|
||||
| Line | Means |
|
||||
|---|---|
|
||||
| `HDR gate OPEN: … "Built-in Screen" … reports HDR types HDR10, …` | the offer is on, with its inputs and which Android colour calls exist |
|
||||
| `<program> bound wp_color_manager_v1 version 1 …` | Mesa saw it: `VK_COLOR_SPACE_HDR10_ST2084_EXT` is now listed |
|
||||
| `<window>: colour-management surface created` | a swapchain asked for a non-sRGB colour space |
|
||||
| `image description #N from <program>: BT.2020, ST 2084 (PQ); mastering …; max CLL …, max FALL …` | the game's colour space + `vkSetHdrMetadataEXT` values |
|
||||
| `<window> presents WxH buffers in XB30 (10-bit A2B10G10R10) …, gralloc RGBA1010102 (10-bit)` | the 10-bit swapchain really arrived |
|
||||
| `banner_wayland_game: dataspace BT2020_PQ (0x9c60000) set on the display layer …` | the tag + metadata SurfaceFlinger received |
|
||||
| `HDR last 10 s: N frames on the display layer tagged BT2020_PQ …` | steady state |
|
||||
| `display HDR/SDR ratio X (was Y; HDR frames on screen: yes …)` | `Display.getHdrSdrRatio()` — rises above 1.00 only when Android grants HDR headroom |
|
||||
| `HDR on screen: yes / tagged but NOT confirmed / no, because …` | the verdict (written on changes, at game exit and at session end; the last one counts) |
|
||||
|
||||
DXVK's own `<exe>_dxgi.log` / `<exe>_d3d11.log` add `Color space: VK_COLOR_SPACE_HDR10_ST2084_EXT` and
|
||||
the 10-bit format at swapchain creation; Mesa's `Not using HDR metadata to avoid protocol errors`
|
||||
(stderr → `wine_debug.log`) means the game's metadata failed Mesa's own legality check.
|
||||
|
||||
## 11. Round 2 — as built (2026-09-14, `feat/wayland-hdr`; CI only, not device-proven yet)
|
||||
|
||||
Round 1 is proven on the tester's Fold (God of War, DXVK v3.1: 10-bit zero-copy, `BT2020_PQ` on the
|
||||
layer, HDR/SDR ratio 1.00 → 2.51, `HDR on screen: yes`). Round 2 makes it a setting and removes
|
||||
round 1's big limitation (§10.4: no tone-mapping, effects/frame generation skipped, washed-out copies).
|
||||
The gate itself is unchanged (§10.1) apart from its first input.
|
||||
|
||||
### 11.1 The setting, and what the launch does with it
|
||||
|
||||
- `Container.isWaylandHdr()` (extraData `waylandHdr`) and the shortcut extra `waylandHdr` (`1`/`0`/unset
|
||||
= the container's) — one resolver, `display/WaylandHdr.effective()`, used by the three editors
|
||||
(container, game shortcut, XMB game settings) and the launch path. `BANNER_WAYLAND_HDR` in the
|
||||
environment still overrides it (`1` / `0` / `force`). Editors grey the row with the reason when the
|
||||
built-in screen does not list HDR10 (`WaylandHdr.unavailableReason`), and say it applies from the
|
||||
next launch.
|
||||
- HDR on for the session (setting resolved on AND HDR10 display, or `force`): `DXVK_HDR=1` is exported
|
||||
after the user's env merge unless the user set `DXVK_HDR` themselves.
|
||||
- Every Wayland session whose display lists **HDR10** exports `BANNER_WAYLAND_HDR_MAX_NITS`,
|
||||
`…_MAX_AVG_NITS`, `…_MIN_NITS` (decimal nits from `Display.getHdrCapabilities()`; unknown values and
|
||||
a max of 0 are left out) — the contract the Wayland layer from versionCode 10 turns into EDID HDR
|
||||
metadata for DXGI (checked by the Wine side against DXVK's own EDID parser: the Fold's 1351/1351/0 →
|
||||
DXGI max 1345.43, max full-frame 1345.43, min 0.01). Never on an SDR display, whose EDID would then
|
||||
claim PQ support. One `session environment:` line logs them. Android has no live absolute nits; the
|
||||
live evidence stays the HDR/SDR ratio.
|
||||
- A "DXVK before 3.0 needs layer v10" warning was built and then **removed**: its premise was wrong
|
||||
(Wine already exposes `VK_EXT_swapchain_colorspace` at instance level; DXVK ≥ 2.1 looks for it in the
|
||||
device list, logs 0 on every Mesa system — the working v3.1 run logs 0 too — and never uses it for the
|
||||
HDR decision). Why God of War offered no HDR option on DXVK 2.4.1 is open (Fold A/B).
|
||||
|
||||
### 11.2 HDR-aware composition (`hdr_compose.c`, `hdr_encode.frag`, compositor.c `hdr_plan`)
|
||||
|
||||
Every scene with an HDR draw takes one of four routes (logged on each change, with the reason):
|
||||
|
||||
| Route | When | What reaches the display |
|
||||
|---|---|---|
|
||||
| 0 | the HDR game alone fullscreen, zero-copy on, no effects, nothing above it (or one window the overlay layer can carry) | the game's own 10-bit gralloc frames on its layer, `BT2020_PQ` (round 1) |
|
||||
| 1 | effects on, a window above on a display that cannot take a second layer, a windowed game, zero-copy off | **the HDR picture**: every draw blitted 1:1 into a 10-bit "mixed" image (each pixel still in its own encoding), ONE encode pass to PQ BT.2020 (SDR pixels sRGB → linear → BT.2020, placed at 203 nits, `BANNER_WAYLAND_HDR_SDR_NITS` overrides), the effects chain run on it in 10-bit (`vkp_effects_set_formats`), copied into a 10-bit (`RGBA1010102`) layer buffer, tagged with the game's description; 8-bit buffers if gralloc refuses 10-bit (logged) |
|
||||
| 2 | frame generation on | composed into PQ in the 8-bit scene image, through the frame-generation engine, presented through an **HDR10 swapchain** (`VK_EXT_swapchain_colorspace` enabled on the compositor instance in HDR sessions only; first `A2B10G10R10` else FP16 pair the surface lists with `HDR10_ST2084`); where the surface lists none, **tone-mapped** into the ordinary swapchain. 8 bits through the engine: gradients may band |
|
||||
| 3 | an HDR frame the compositor could not import | layer only; effects/frame generation skipped for it (round 1's behaviour, now the rare case) |
|
||||
|
||||
The tone map (mode 1 of `hdr_encode.frag`): PQ → nits → BT.2020 → BT.709, relative to SDR white, maxRGB
|
||||
curve linear to a 0.8 knee then an exponential roll-off that puts the content peak (the game's max CLL,
|
||||
else mastering max, else 1000 nits) at 98 %, sRGB-encoded. Which pixels are HDR comes from up to six
|
||||
top-first scene rects + a mask in the push constants (more windows over the game → the lowest are
|
||||
treated as SDR, logged once). A composed frame that cannot reach the layer falls back to route 2 for as
|
||||
long as that lasts (logged once each way).
|
||||
|
||||
### 11.3 The live switch (lead's addition): drawer → Graphics → "HDR output"
|
||||
|
||||
Shown only while the gate is open (the activity's 1 s HDR sampler flips `waylandHdrAvailable`). Per
|
||||
session, starts on, nothing saved. Off (`banner_color_set_output(0)`, posted through the host queue
|
||||
to the compositor thread, logged, redraw): route 0 becomes route 1 with the tone map, the picture goes
|
||||
on the layer **untagged** on 8-bit buffers (the layer's dataspace returns to `UNKNOWN`); route 2
|
||||
rebuilds the swapchain as SDR and tone-maps; route 3 cannot (nothing can read those frames) and stays
|
||||
HDR, said in the log. The game is told nothing (its DXVK_HDR and colour-manager offer were decided at
|
||||
launch). The HUD reads `Wayland · HDR` while HDR frames are on screen (tagged in the last 1.5 s and
|
||||
ratio > 1.01 where reported), `Wayland · HDR off` while the switch is off. Frames tone-mapped by the
|
||||
switch are counted separately in the verdict.
|
||||
|
||||
### 11.4 Live headroom (lead's addition after the second Fold run)
|
||||
|
||||
The Fold's second run (brightness slider at maximum) showed the ratio at 3.23 for a minute and then
|
||||
**1.00 for 3+ minutes with HDR frames on screen the whole time**, while the verdict kept saying "rose to
|
||||
3.23". Android simply gave the layer no headroom (SDR white already at the panel's limit). Now, from the
|
||||
ratio samples the app already sends (1 s + the display listener): the time with HDR frames on screen and
|
||||
the part of it with ratio > 1.01; a no-headroom streak (HDR frames on screen, ratio <= 1.01) that after
|
||||
5 s writes `no HDR headroom for 5 s … the screen brightness is probably at maximum …` (and `HDR headroom
|
||||
is back …` when it ends), tags the 10 s line and the steady ratio line, puts the HUD on `Wayland · HDR
|
||||
(no headroom)` and the drawer row on the same hint (`banner_color_hdr_state` = 2); and the verdict
|
||||
reports `headroom above 1.00 for P% of the HDR time (a of b s), now R` plus the hint while the streak
|
||||
lasts. Cheap: no new sampling, a few integers under the existing lock.
|
||||
|
||||
**Round-2 Fold run (20:23, run 34911468350):** the first no-headroom streak was a **screen recording**,
|
||||
not the brightness: the user's recording (210.8 s, BT.709 SDR H.264, finalised 20:27:30, so started
|
||||
~20:23:59) lines up with the ratio falling 2.98 → 1.00 at 20:24:00.9 and staying there to the end. So
|
||||
Android (at least Samsung's) turns HDR headroom off while the screen is recorded. Every hint now names
|
||||
both causes; whether maximum brightness does it too is still unmeasured (tester note step H).
|
||||
|
||||
### 11.5 The HUD's HDR line (round 2b, the user's layout request)
|
||||
|
||||
`40.3ms · Wayland · HDR (no headroom)` ran off the pill's right edge (the capsule's ends curve in, and the
|
||||
latency line is the bottom of the stack). The display-server label is plain `Wayland` again, and the HDR
|
||||
state is a line of its own directly under it, fed as a `FusionHdr` code (`FusionHudView.setHdrState`):
|
||||
`HDR` / `HDR (no headroom)` / `HDR off` / `HDR tone-mapped` (switch on, frame generation without an HDR10
|
||||
swapchain) / `HDR ready` (gate open, no HDR frames right now). `NONE` - every session whose gate is
|
||||
closed - draws nothing, so those HUDs are unchanged to the pixel. Pill: the extra line makes the capsule
|
||||
taller and its ends rounder, so in HDR sessions `fitCapsule()` measures every glyph's ink against the
|
||||
two rounded ends (plus the outline and 2 sp) and shifts/widens the pill until nothing crosses. Full: an
|
||||
`HDR` row under `DISP`; Tiles: the *Display* tile's sub-line; Minimal: a line under the footer; Mega: a
|
||||
fragment after `DISP` in the bottom band. Only the Fusion HUD shows the display server at all; the
|
||||
classic, GameHub and GameNative HUDs never received it and are untouched.
|
||||
|
||||
### 11.6 Round 2d (Fold evidence from 2c)
|
||||
|
||||
- **The format scan was a false negative.** FG with the AIO HDR card logged `lists no HDR10 swapchain
|
||||
format (37/0 37/1000104001 … 37/1000104012)`: `swap_init` read the surface's list into
|
||||
`VkSurfaceFormatKHR fmts[32]`, and with `VK_EXT_swapchain_colorspace` the Android WSI lists every
|
||||
format once per colour space (11 on the Fold) - the 10-bit/FP16 rows were past entry 32, and the log's
|
||||
160-char buffer cut the list too. Now: all pairs read (heap), one line with the total, colour spaces
|
||||
per format and every HDR-capable pair (10-bit/FP16 first); HDR10 pick A2B10G10R10 → A2R10G10B10 →
|
||||
FP16 → 8-bit; a driver that refuses the HDR10 swapchain gets the SDR one at once. The only other
|
||||
fixed array near it (queue families, 16) does not hold surface formats or present modes; FIFO is the
|
||||
only present mode used, so no list is read.
|
||||
- **VK_EXT_hdr_metadata** enabled in HDR sessions where the device lists it; the HDR10 swapchain gets the
|
||||
game's SMPTE 2086 / CTA-861.3 once per swapchain and image description (none if the game sent none).
|
||||
- **FP16 frame generation for HDR.** The bridge and both engines already take a format (the chain,
|
||||
the ring); lsfg-vk itself runs HDR in `R16G16B16A16_SFLOAT`. With HDR frames through an HDR10
|
||||
swapchain the scene (`g_fgscene`), the encode pass (new FP16 output), the effects and the engine run
|
||||
in FP16 where `fge_format_ok` (storage + linear sampling) passes; the PQ signal is fed as-is (the
|
||||
shaders' own HDR flags stay off - PQ is already perceptual). A chain that fails to build in FP16 is
|
||||
sticky inside both engines, so the bridge refuses the format for the session and restarts the engine
|
||||
in 8 bits instead of marking frame generation failed.
|
||||
- **Evidence beside the headroom** (app, non-root): PowerManager thermal status (+ listener) and
|
||||
`getThermalHeadroom(10)` every 10 s, `Settings.System` brightness + mode (+ observer), screenshots
|
||||
(`registerScreenCaptureCallback`, API 34) and screen recording (`addScreenRecordingCallback`, API 35,
|
||||
reflection) with the normal `DETECT_SCREEN_CAPTURE` / `DETECT_SCREEN_RECORDING` permissions. Changes
|
||||
are logged; the no-headroom lines, the 10 s line and the verdict carry the values and name the likely
|
||||
cause (recording / hot / brightness at maximum) or say none is visible. The verdict lists only the
|
||||
paths that carried frames, to leave room for it.
|
||||
|
||||
### 11.7 Round 2e (headroom request, display ceiling, coverage)
|
||||
|
||||
2d on the Fold: all pass (68 surface pairs, HDR10 swapchain A2B10G10R10, FP16 FG at 120 fps, 0 tone-mapped,
|
||||
VK_EXT_hdr_metadata, headroom 3.00 at brightness 255 **auto**). A tester's ROG Phone 9 Pro (Adreno 830,
|
||||
API 36): correct HDR frames, composed path, HDR layer ~80% of the 2400x1080 screen (windowed card), not
|
||||
hot, not recording, brightness 8-223 manual - and the HDR/SDR ratio at **1.00 the whole session**.
|
||||
- `ASurfaceTransaction_setDesiredHdrHeadroom` (API 35) on the game layer, per HDR frame, only on change:
|
||||
content peak (max CLL, else mastering max, else the display's peak) / SDR white, capped at the display's
|
||||
highest ratio; 0 (no preference) when the layer stops carrying HDR; re-sent on a fresh SurfaceControl.
|
||||
The screen surface (HDR10 swapchain for frame generation) gets the same through
|
||||
`SurfaceView.setDesiredHdrHeadroom` (API 35, reflection; `SurfaceControl.Transaction` fallback), applied
|
||||
by the app from `banner_color_screen_headroom()`.
|
||||
- `Display.getHighestHdrSdrRatio()` (Android 16+, reflection) in the display line and the verdict; 1.00
|
||||
means no boost at all, and the request is then not made.
|
||||
- HDR layer coverage in the dataspace line, the composed-picture line and on geometry changes.
|
||||
- "brightness at maximum" only for MANUAL >= 250/255; no visible cause -> "this phone may not boost HDR
|
||||
from apps (the requested headroom was …, the display's highest ratio is …)".
|
||||
|
||||
### 11.8 What is still NOT done / not proven
|
||||
|
||||
- Round 2's composition, switch and HUD line were device-tested in parts on the Fold (setting-driven
|
||||
gate, auto environment, composed picture, headroom lines, HUD); 2d is CI only.
|
||||
- The engines' own HDR flags (lsfg `hdr_support` / FSR3 HDR input) stay off: the PQ signal is treated as
|
||||
perceptual SDR-like data. If interpolation artefacts show only in HDR, that is the next thing to try.
|
||||
- Colour effects (brightness/contrast/saturation/gamma, the "HDR" bloom) operate on the PQ signal in
|
||||
route 1 and look stronger than in SDR; sharpening/AA/CRT/upscalers are perceptually fine.
|
||||
- scRGB (FP16) swapchains (Phase C) — unchanged: needs FP16 gralloc and a layer change.
|
||||
@@ -0,0 +1,472 @@
|
||||
# Bannerlator Wayland runtime (feat/wayland-runtime)
|
||||
|
||||
Experimental **parallel** display runtime: run/launch games through Wine's
|
||||
`winewayland.drv` talking to our own embedded Wayland compositor, instead of the
|
||||
X11 path (pure-Java X11 server + `libwinlator.so`). The X11 runtime stays the
|
||||
default and is untouched — this is a separate flavor/branch.
|
||||
|
||||
## What's already proven (spike repo `bannerlator-wayland`, device-tested on Adreno 750)
|
||||
- Minimal libwayland-server compositor: globals + xdg-shell handshake + buffer commit.
|
||||
- **Turnip's Vulkan WSI exports real zero-copy dmabufs to our external compositor**
|
||||
(same Mesa path winewayland.drv uses for DXVK/VKD3D) — risk #1 retired.
|
||||
- Compositor imports that dmabuf into its own Turnip VkImage (`vk_import.c`).
|
||||
The staged `src/` here is that proven code, to grow into the app-embedded compositor.
|
||||
|
||||
## Dependencies
|
||||
1. **A Proton 11 arm64ec wcp that ships `winewayland.drv`** — built on branch
|
||||
`The412Banner/proton-wine:feat/winewayland` (task #1). Nothing runs end-to-end
|
||||
without it.
|
||||
2. **Wayland runtime libs in the imagefs** so `winewayland.so` (unixlib) loads:
|
||||
`libwayland-client.so`, `libwayland-egl.so`, `libxkbcommon.so`, `libxkbregistry.so`
|
||||
(bionic aarch64). The wcp bundles them in its `lib/` as a fallback; the clean home
|
||||
is the imagefs — add via `ImageFsInstaller` (new `installWaylandLibs()`), same
|
||||
pattern as `installFFmpeg8()`.
|
||||
|
||||
## Integration plan (M4)
|
||||
- **CMake**: add `waylandcomp` as a native lib (`libbannerwayland.so`) built with the
|
||||
NDK, linking the bionic `libwayland-server`/`libvulkan`. Generate protocol glue from
|
||||
`protocols/*.xml` at build time (host `wayland-scanner`).
|
||||
- **Surface**: a `WaylandDisplayActivity` (parallel to `XServerDisplayActivity`) hosts a
|
||||
`SurfaceView`; JNI hands the `ANativeWindow` to the compositor, which creates a Vulkan
|
||||
swapchain on it and blits the imported game VkImage each frame (the last un-proven
|
||||
render step; standard Vulkan once the window exists).
|
||||
- **Input**: Android `MotionEvent`/`KeyEvent` → `wl_seat`/`wl_pointer`/`wl_keyboard`.
|
||||
- **Launch wiring**: start the compositor, export `WAYLAND_DISPLAY`, select the wayland
|
||||
driver per-prefix (registry `Drivers\Graphics = winewayland`) instead of `winex11`,
|
||||
and point the container at the winewayland wcp.
|
||||
|
||||
## Status
|
||||
- ✅ **Native lib foundation done + compile-verified.** Compositor + vk_import + pre-generated
|
||||
protocol glue build as `libbannerwayland.so` (CMake target added), linking the vendored
|
||||
bionic `libwayland-server`. Verified: compiles/links clean as an aarch64 bionic `.so`,
|
||||
exports `banner_wayland_run`, NEEDED = libwayland-server + libvulkan. JNI entry
|
||||
(`waylandcomp_jni.c`) + `WaylandCompositor.java` bring it up on a thread. Compositor-process
|
||||
runtime deps (libwayland-server/libffi/libandroid-support) staged in `jniLibs/arm64-v8a`.
|
||||
- ⏭️ **Next phase (gated on the winewayland wcp landing green):** `WaylandDisplayActivity`
|
||||
(SurfaceView) + JNI `ANativeWindow`→Vulkan swapchain + blit the imported game VkImage to the
|
||||
window (last un-proven render step) + input + launch wiring (start compositor, `WAYLAND_DISPLAY`,
|
||||
per-prefix `Drivers\Graphics=winewayland`) + `ImageFsInstaller.installWaylandLibs()` (client/egl/xkb
|
||||
into the imagefs for winewayland.so).
|
||||
|
||||
## Pointer lock / relative mouse (zwp_pointer_constraints_v1 + zwp_relative_pointer_manager_v1)
|
||||
- Both globals are advertised (version 1); glue is pre-generated in `generated/` with
|
||||
`wayland-scanner server-header` / `private-code` from `protocols/*-unstable-v1.xml` (same
|
||||
scanner version as the rest, 1.24.0), no build-time scanner needed.
|
||||
- winewayland's use: `ClipCursor`/fullscreen + hidden cursor → `lock_pointer` (persistent);
|
||||
`SetCursorPos` → lock + `set_cursor_position_hint` + commit + unlock; visible cursor +
|
||||
`ClipCursor(rect)` → `confine_pointer` with a one-rectangle region. It only turns relative
|
||||
motion on for a window its `wl_pointer` has entered, so **pointer focus follows an active
|
||||
constraint** (the desktop surface gets `leave`, the constrained surface `enter`) and goes
|
||||
back to the desktop on the next motion after the constraint ends.
|
||||
- Lock: the pointer is frozen; every input delta becomes `relative_motion` (no `motion`).
|
||||
Confine: absolute motion is clamped to surface ∩ region. The position hint is applied on
|
||||
the surface's commit (pointer moves there) and is where the pointer stays when the lock ends.
|
||||
One constraint holds at a time (a newer request ends the older one); oneshot constraints
|
||||
are defunct after ending, persistent ones re-take hold on focus re-entry.
|
||||
- App side: input type 6 = relative delta (1/256 px); `banner_on_pointer_lock(locked, x, y)`
|
||||
tells Java to switch its touch/mouse path to deltas (`XServer.setExternalRelativeMode`) and,
|
||||
on unlock, to re-sync the X pointer (the absolute input's source) to x,y. With Wayland mode
|
||||
`WinHandler.mouseEvent` routes relative-mode input to the compositor instead of the guest.
|
||||
- Session log tag `pointer`: `lock requested by …`, `locked: … frozen at x,y`, `unlocked: … (why)`,
|
||||
`confined: …`, `unconfined: …`, `relative pointer created for …`, `position hint: …`.
|
||||
Test FIFO gained `rel DX DY`.
|
||||
|
||||
## Screen surface, swapchain recovery (vk_present.c)
|
||||
- The app's UI thread never waits on the renderer: `vk_present_set_window()` only leaves the new
|
||||
`ANativeWindow` (or NULL) in a request slot; the compositor thread applies it before its next
|
||||
frame and on every vsync tick (`vkp_apply_window_request`), tearing the old swapchain down and
|
||||
releasing the old window's reference. Acquire waits at most 1 s, never forever.
|
||||
- OUT_OF_DATE / SURFACE_LOST on acquire or present rebuild the swapchain (once inline on acquire, so
|
||||
the frame isn't lost). SUBOPTIMAL is presented as is: the swapchain uses IDENTITY preTransform on
|
||||
purpose, so a rotated panel reports it on every frame. DEVICE_LOST logs
|
||||
`GPU device lost … the compositor has stopped presenting` once and stops touching the device;
|
||||
clients keep being paced (`pace_without_output`) so they don't wedge.
|
||||
- A swapchain that can't be created is retried every 0.5 s and logged once per streak.
|
||||
|
||||
## Buffer lifetime, FPS limiter (compositor.c)
|
||||
- `struct dmabuf_buffer` is reference counted: one ref for the wl_buffer resource, one per surface
|
||||
showing it. Mesa destroys a swapchain's wl_buffers when the game rebuilds its swapchain, while the
|
||||
last committed one is still on screen; the surface keeps the import (`s->dmabuf_buf`) until its
|
||||
next commit, so the window neither blinks to black nor is unmapped/remapped ("closed"/"opened").
|
||||
- Surface destroy releases its buffer immediately (`drop_dmabuf(s, 0)`), replaced buffers go back on
|
||||
the limiter's cadence. The per-surface release schedule is bounded: a slot in the past is brought
|
||||
to now, and the schedule never runs further ahead than `(releases still pending + 1)` intervals.
|
||||
|
||||
## Fullscreen mode + screen alignment
|
||||
- `WaylandCompositor.nativeSetScaleMode(fullscreenMode, screenAlignment)` takes the app's
|
||||
`Container.FULLSCREEN_OFF/FIT/STRETCH/FILL/INTEGER` (0..4) and `ALIGN_CENTER/TOP/BOTTOM` (0..2),
|
||||
any thread, any time (the drawer changes it live). `update_map()` in vk_present.c is a line-for-line
|
||||
mirror of `ViewTransformation.update()`: OFF and FIT both letterbox (OFF only differs in the app's
|
||||
fullscreen gates), TOP/BOTTOM confine the picture to the top/bottom half of the output (the
|
||||
handheld split), FILL overflow is clipped to the region. The app maps touch through the same class
|
||||
(TouchpadView → X server → input sink → scene input), the overlay arrow through
|
||||
`waylandSceneToView`, and the SurfaceView's own INPUT_SPACE touches through `vkp_output_to_scene`.
|
||||
- Log tag `screen`: `<mode>, <alignment>: WxH scene shown WxH at x,y on the WxH output` whenever the
|
||||
mapping changes (mode, alignment, scene or output size).
|
||||
|
||||
## Clipboard, text input, window icons (feat/wayland-clipboard-ime)
|
||||
Three globals winewayland used to complain about at startup, each in its own file behind the
|
||||
small interface in `src/banner_ext.h` (compositor.c only gained hook calls + accessors):
|
||||
- **Clipboard** (`src/wl_clipboard.c`): `wl_data_device_manager` **v3** and
|
||||
`zwlr_data_control_manager_v1` **v1**, selection only (start_drag is refused with `cancelled`).
|
||||
Wine prefers data-control: its desktop process then owns the clipboard without needing keyboard
|
||||
focus and the "clipboard functionality will be limited" ERR goes away too. One shared selection:
|
||||
a program's source, or text from Android (`nativeSetClipboardText`), or nothing. Data-control
|
||||
devices hear every change; `wl_data_device`s only while their client holds keyboard focus (hook in
|
||||
`keyboard_focus()`), and on focus arrival. Guest → Android: a selection with a text mime is read
|
||||
once over a pipe on the event loop (1 MiB cap, 3 s timeout) → `banner_on_clipboard_text` →
|
||||
`WaylandClipboardSync` → `ClipboardManager`. Android → guest: `OnPrimaryClipChangedListener` plus a
|
||||
re-read on resume / window focus (Android hides clipboard changes from background apps); `receive`
|
||||
is served by a non-blocking writer. Echo guard on both sides. Log tag `clipboard`.
|
||||
- **Text input** (`src/wl_text_input.c`): `zwp_text_input_manager_v3` **v1**, double-buffered state,
|
||||
`done(serial)` only when we sent events. winewayland enables text input for whichever surface gets
|
||||
`enter` and posts IME updates inside *that window's process*, so text input can't follow keyboard
|
||||
focus (the desktop surface): it follows the last clicked program window (`g_ime_click`, set in
|
||||
`pointer_input`), else the topmost non-shell window. `set_cursor_rectangle` arrives when an edit
|
||||
control calls `ImmSetCompositionWindow`; the app (`WaylandTextInput`) shows the soft keyboard only
|
||||
then (and with no hardware keyboard), hides it on disable unless the user's own toggle opened it.
|
||||
Typed text: `SurfaceInputView`'s `InputConnection` → `commit_string` / `preedit_string` + `done`.
|
||||
Deletions become Backspace/Delete key presses — winewayland's `delete_surrounding_text` handler is
|
||||
empty. Log tag `text-input`.
|
||||
- **Window icons** (`src/wl_toplevel_icon.c`): `xdg_toplevel_icon_manager_v1` **v1**, accepts and
|
||||
drops icons (`done` at bind, no sizes).
|
||||
- Host → compositor text crosses as UTF-8 `byte[]` through `banner_ext.c`'s queue (mutex + wake
|
||||
pipe), drained on the compositor thread. Glue for the three protocols is pre-generated with
|
||||
wayland-scanner 1.24.0 from `protocols/`.
|
||||
|
||||
## Compressed (UBWC) game buffers (feat/wayland-ubwc)
|
||||
- `zwp_linux_dmabuf_v1` used to advertise `LINEAR` (+`INVALID`) only, so Turnip's Wayland WSI in the
|
||||
game allocated linear swapchain images and DXVK/VKD3D resolved every frame from their tiled/UBWC
|
||||
render targets into that linear copy, before the compositor's own blit. Now `bind_dmabuf` builds
|
||||
its table at the first bind from the renderer's driver (`vkp_dmabuf_modifiers`):
|
||||
`vkGetPhysicalDeviceFormatProperties2` + `VkDrmFormatModifierPropertiesListEXT` per fourcc
|
||||
(AR24/XR24/AB24/XB24), each modifier confirmed with `vkGetPhysicalDeviceImageFormatProperties2`
|
||||
for a dma-buf-backed `TRANSFER_SRC` image. Only `DRM_FORMAT_MOD_LINEAR` (0) and
|
||||
`DRM_FORMAT_MOD_QCOM_COMPRESSED` (`0x0500000000000001`, UBWC, single memory plane on Adreno) are
|
||||
ever advertised; anything else the driver reports goes to logcat as "not advertised".
|
||||
- Mesa's WSI hands every advertised+supported modifier to `vkCreateImage` as a modifier *list* and
|
||||
Turnip picks `QCOM_COMPRESSED` whenever it is in the list (`tu_image.cc`), so with the
|
||||
advertisement the game's swapchain is UBWC. The `wl_buffer` then arrives with that modifier and
|
||||
the pixel-plane pitch/offset from the game's `vkGetImageSubresourceLayout(MEMORY_PLANE_0)`;
|
||||
`vkp_image_import_dmabuf` creates the compositor's image with the explicit modifier and that one
|
||||
plane layout (`VkImageDrmFormatModifierExplicitCreateInfoEXT`), which Turnip validates
|
||||
(`INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT` if the pitch does not fit its `fdl6` alignment). The
|
||||
swapchain blit (`vkp_render`) and the layer-mode blit (`vkp_blit_image`) read it like any other
|
||||
source; nothing CPU-side ever touches a dma-buf. Layer mode still blits into its own gralloc pool.
|
||||
- **A/B switch:** `BANNER_WAYLAND_UBWC=0` (or `false`/`off`) in the container's/shortcut's
|
||||
environment variables → `nativeSetUbwc(false)` → linear-only advertisement, exactly the old
|
||||
behaviour. Default on. The driver is still queried, so the log shows what it could have done.
|
||||
- Log tag `dmabuf`: `formats: AR24 linear+qcom_compressed, XR24 …, AB24 …, XB24 …` at the first
|
||||
bind (with ` (BANNER_WAYLAND_UBWC=0: qcom_compressed not advertised)` when off, or a second line
|
||||
`the compositor's driver (…) reports no importable qcom_compressed layout: game swapchains stay
|
||||
linear` when the adrenotools Turnip lacks it). Per window, the existing `vulkan` line now names
|
||||
the modifier: `… is presenting GPU frames through Wayland: 1920x1080, format XB24, qcom_compressed
|
||||
(zero-copy)` vs `… linear (zero-copy)`. Import failures are `error` lines naming the stage,
|
||||
modifier, size, pitch and VkResult (`dmabuf: vkCreateImage(qcom_compressed, …) -> …`).
|
||||
- Caveat: both sides must agree on the UBWC encoding for the GPU. The game runs the wcp's Wayland
|
||||
Turnip, the compositor the user's adrenotools Turnip; the layout code (`fdl6`) is the same, but a
|
||||
very different Mesa version on one side is the first suspect if a compressed frame imports fine
|
||||
yet looks scrambled — `=0` is the workaround, and the `gpu` line names both the GPU and the
|
||||
compositor's driver.
|
||||
|
||||
## Phones with no DRM node (OpenGL) — `BANNER_WAYLAND_NO_RENDER_NODE=1`
|
||||
- The feedback's `main_device` is the first of `/dev/dri/renderD128`, `renderD129`, `card0` the app
|
||||
can `stat`; retail phones (Adreno 830/840 reports, 2026-09-14) expose none, so it is `0:0`.
|
||||
Vulkan games do not care. Mesa's EGL did: its Wayland DRM initialiser failed the display in
|
||||
`dri2_setup_device()` without a render node and fell back to a software path that has no
|
||||
rasteriser in these layers — native OpenGL black, sound playing. Wayland layer versionCode 9
|
||||
(Banners-Turnip `patches/wayland/egl_wayland_no_drm_node.py`) runs zink + kopper on the Vulkan
|
||||
device without a node instead; nothing app-side is needed for that.
|
||||
- `BANNER_WAYLAND_NO_RENDER_NODE=1` (container or shortcut env) makes the compositor advertise
|
||||
`main device 0:0` on a device that does have a node, to reproduce those phones here.
|
||||
- Log lines: `dmabuf` `… no display (DRM) device …: OpenGL games need Wayland layer versionCode 9
|
||||
or newer …` when the main device is 0:0; `opengl` `<program> asked for GPU buffers but has drawn
|
||||
only software (shared-memory) frames …` once per program that asked for dma-buf feedback (EGL's
|
||||
GPU path always does) and then committed 150 wl_shm frames without making a dma-buf buffer.
|
||||
|
||||
## Zero-copy window layers (spike, `BANNER_WAYLAND_ZERO_COPY=1`)
|
||||
Research + host-side prototype in `ZERO_COPY_SPIKE.md`: why a dma-buf can't become an
|
||||
`AHardwareBuffer` (the game's buffers are DMA-heap allocations, not gralloc's), why the interop
|
||||
must start from a gralloc buffer whose native-handle fd the drivers import (Turnip's own AHB path),
|
||||
and the WSI patch this needs in our Wayland Turnip. `src/sc_layer.c` implements the receive side:
|
||||
with the variable in the container's environment, one fullscreen game window is shown on its own
|
||||
`ASurfaceControl` child of the SurfaceView (pool of three compositor-allocated AHBs, one blit,
|
||||
release fences from `setOnComplete`, geometry from the fullscreen mode); any other scene falls back
|
||||
to the swapchain blit. Log tag `layer`. Off by default.
|
||||
|
||||
## Zero-copy game frames (`BANNER_WAYLAND_ZERO_COPY=1`, drawer switch live)
|
||||
Option (a') of `ZERO_COPY_SPIKE.md`, both halves:
|
||||
- **Guest (our Wayland Turnip, banners-turnip-wayland `patches/wayland/banner_ahb_wsi.py`, all
|
||||
variants):** while the compositor's mode is on (see the live switch below), the Wayland
|
||||
WSI allocates every swapchain image as a gralloc `AHardwareBuffer` (usage GPU_SAMPLED_IMAGE |
|
||||
GPU_FRAMEBUFFER | COMPOSER_OVERLAY; UBWC when gralloc picks it and a test `vkCreateImage` with the
|
||||
explicit `QCOM_COMPRESSED` layout succeeds, else linear via a CPU usage bit; `BANNER_WSI_AHB_LINEAR=1`
|
||||
forces linear), imports the handle's dma-buf with an explicit modifier + pitch (the compositor's own
|
||||
pool-import path; `vk_android.c` is not in a platforms=wayland build), shares it through
|
||||
`zwp_linux_dmabuf_v1` as before (blit fallback), and sends the `AHardwareBuffer` once per image:
|
||||
`socketpair` + `AHardwareBuffer_sendHandleToUnixSocket` + `banner_ahb_v1.attach(wl_buffer, fd, w, h,
|
||||
stride, modifier hi/lo, image_count)`. Surface formats are limited to `R8G8B8A8_UNORM/SRGB` (and
|
||||
`A2B10G10R10`) while the mode is on: gralloc has no BGRA (DXVK/Zink blit into the swapchain image
|
||||
anyway). Marker: `strings libvulkan_freedreno_wayland*.so | grep banner_ahb_v1`.
|
||||
- **Compositor (`src/ahb_swapchain.c`, protocol `protocols/banner-ahb-v1.xml`):** the global is
|
||||
advertised on every session where a display layer is possible at all (`sc_layer_available()`);
|
||||
whether gralloc buffers are WANTED right now is the `mode` event, not the global's presence.
|
||||
`attach` → `AHardwareBuffer_recvHandleFromUnixSocket`, record on the `dmabuf_buffer`.
|
||||
When that buffer is the one fullscreen frame (`layer_candidate`, or the layer-only candidate when
|
||||
this renderer could not import it), `sc_layer_present_ahb` sets it on the `banner_wayland_game`
|
||||
SurfaceControl as is. **Acquire fence** = `DMA_BUF_IOCTL_EXPORT_SYNC_FILE(READ)` of the dma-buf: Mesa
|
||||
imports the render fence into the dma-buf (`wsi_signal_dma_buf_from_semaphore`) *before* the
|
||||
`wl_surface.commit`, so the export always carries the frame; if the ioctl fails the compositor
|
||||
polls the dma-buf instead (logged once). **Release**: `setOnComplete` →
|
||||
`getPreviousReleaseFenceFd` → `DMA_BUF_IOCTL_IMPORT_SYNC_FILE(READ)` into the dma-buf → then
|
||||
`wl_buffer.release` (still on the FPS limiter's cadence); Mesa's acquire
|
||||
(`wsi_create_sync_for_dma_buf_wait`) exports every fence of the dma-buf, so the game waits for the
|
||||
display. If the import fails the release waits on the fence fd in the event loop instead. A hidden
|
||||
or retired layer gets a 16x16 blank buffer so SurfaceFlinger actually lets go of the game's buffer.
|
||||
- **App:** `BANNER_WAYLAND_ZERO_COPY=1` (container/shortcut env) is the session's STARTING state and
|
||||
also exports `BANNER_WSI_AHB=1` into the guest (`XServerDisplayActivity.isWaylandZeroCopyRequested`),
|
||||
which is what an older driver (bound at `banner_ahb_v1` version 1) needs.
|
||||
|
||||
### The live switch ("Zero-copy presentation", Graphics tab)
|
||||
`banner_ahb_v1` version 2 adds one event, `mode(enabled)`, sent to every bound client on bind and
|
||||
again on every flip. The compositor owns the state:
|
||||
- `WaylandCompositor.nativeSetZeroCopy(on)` is live and callable from any thread. Before the
|
||||
compositor starts it just seeds `g_zero_copy`; afterwards it posts through the `banner_ext.c` host
|
||||
queue (like the clipboard/IME setters) so `ahb_swapchain_set_mode()` runs on the compositor thread,
|
||||
which flips `g_zero_copy`, broadcasts `mode`, flushes the clients and redraws.
|
||||
- **Guest:** the WSI follows `display->banner_ahb_mode`, decided per swapchain at creation. When a
|
||||
live swapchain was built for the other mode, the next `vkAcquireNextImageKHR` /
|
||||
`vkQueuePresentKHR` returns `VK_ERROR_OUT_OF_DATE_KHR` (it reuses Mesa's own `chain->retired`
|
||||
early-outs), which DXVK, vkd3d-proton and Zink all answer by rebuilding the swapchain. The mode
|
||||
event is read with a non-blocking dispatch of the display queue on each acquire/present, because
|
||||
in MAILBOX that queue is otherwise only dispatched when the acquire loop runs out of images.
|
||||
- **Compatibility, both directions.** The registry bind clamps to `MIN(advertised, 2)` — binding
|
||||
above the advertised version is a fatal `wl_display` error, and a Bannerlator from before the live
|
||||
switch advertises version 1. On version 1, and on version 2 before the first `mode` event arrives,
|
||||
the driver keeps the original contract exactly: gralloc images iff `BANNER_WSI_AHB=1`, decided per
|
||||
swapchain, and no swapchain is ever retired. Once the mode is in play `BANNER_WSI_AHB=1` no longer
|
||||
forces it on (the app exports that on every zero-copy launch, which would freeze the switch);
|
||||
`BANNER_WSI_AHB=0` still forces the whole feature off.
|
||||
- **No black frame, either way.** Switching OFF does not tear down anything: the old gralloc chain's
|
||||
frames keep being shown — on the layer when this renderer could not import them, through the copy
|
||||
path when it could — until the game has rebuilt, and only then does `sc_layer_hide()` run. Buffers
|
||||
already on the layer keep their deferred release (`ahb_swapchain_defer_release` is no longer gated
|
||||
on `g_zero_copy`, or the display would be handed a buffer it is still scanning out). Switching ON,
|
||||
the layer path resumes as soon as the first `attach` of the new chain lands.
|
||||
- **Drawer:** the toggle applies live *and* writes the env as the next launch's default. Its status
|
||||
line follows the compositor, not the switch: `nativeZeroCopyLastFrameAgeMs()` (updated on every
|
||||
zero-copy present, unlike the 10 s counter) is what makes it say "Switching on…" / "Switching off…"
|
||||
only for as long as it really is.
|
||||
- **Log lines (tag `layer`):** `zero-copy: banner_ahb_v1 version 2 advertised …`, `zero-copy: <exe>
|
||||
bound banner_ahb_v1 version N …`, `zero-copy: on|off at launch …`, `zero-copy switched on|off from
|
||||
the drawer: N bound programs told to rebuild their swapchains …`, `zero-copy: AHB swapchain from <exe> (N images, WxH, UBWC (QCOM_COMPRESSED)|linear,
|
||||
stride S px)`, `zero-copy: presenting "<title>" (<exe>) without a copy`; the 10 s `stats` line ends
|
||||
with `| N zero-copy frames`. Guest side (Mesa log, stderr of the game): `banner-ahb: WxH swapchain
|
||||
(N images) on gralloc buffers: UBWC|linear, stride S px` or the reason it stayed on standard
|
||||
buffers, plus `banner-ahb: compositor wants gralloc|standard swapchain images` and `banner-ahb:
|
||||
zero-copy switched on|off: retiring the WxH swapchain …` on a live flip.
|
||||
|
||||
## Multi-layer presentation (feat/wayland-multilayer, `src/sc_layer.c`)
|
||||
Layer mode hands the scene to SurfaceFlinger as a small, deliberately ordered **set** of Android
|
||||
display layers instead of one. The whole model, top to bottom:
|
||||
|
||||
```
|
||||
app window ....... Compose UI, the in-game drawer, the perf HUD, the on-screen controls, the
|
||||
pointer arrow - ordinary Android views in the activity's window, ALWAYS on top
|
||||
+-- SurfaceView .. the compositor's Vulkan swapchain (black while layer mode is up)
|
||||
+-- z=1 "banner_wayland_game" ...... the one fullscreen game window
|
||||
+-- z=2 "banner_wayland_overlay" ... at most ONE window drawn above the game
|
||||
```
|
||||
|
||||
- **Two layers is the hard cap** (`SC_LAYER_COUNT`). HWC composes only a few layers before
|
||||
SurfaceFlinger falls back to GPU client composition, which would throw the whole benefit away, so
|
||||
the compositor never asks for a third: a scene with two or more windows above the game goes back
|
||||
to the copy path. The count is said out loud the first time the overlay goes up (`layer`: `2
|
||||
display layers in use: "banner_wayland_game" (z=1) and "banner_wayland_overlay" (z=2) above it …`).
|
||||
- **Who owns what.** Each layer has its own `ASurfaceControl`, its own gralloc buffer pool (3
|
||||
buffers each), its own geometry and its own lifetime; `struct layer`
|
||||
in `sc_layer.c` holds all of it and the z-order is fixed by the id (nothing is re-ordered at
|
||||
runtime). The SurfaceControls are children of the SurfaceView's surface, created on first use and
|
||||
retired together when the output window changes or goes away.
|
||||
- **What can be on the game layer**, cheapest first: the game's own gralloc buffer (zero-copy, no
|
||||
copy anywhere — `ahb_swapchain.c`); one blit of the game's frame into a compositor buffer
|
||||
(`sc_layer_present`); or, with screen effects on, the compositor pass's **result** blitted into
|
||||
such a buffer (`sc_layer_present_pass` → `vkp_pass_begin` / `vkp_pass_copy_to`). The last one is
|
||||
what keeps a Look from dropping the session back to the app's swapchain: the scene → output
|
||||
mapping (Fullscreen Mode / Alignment, and the scaling a mode like FSR asks for) is then done by
|
||||
the display through `setGeometry` instead of by a second full-screen GPU blit.
|
||||
- **Present order matters, and it was measured.** The layers go up first; the base surface's black
|
||||
frame is presented *after* the layer transaction, and the effects chain runs in its own submit
|
||||
with **no swapchain image acquired**. A present holds an acquired image and the acquire semaphore
|
||||
is a vblank gate: folding the chain into that submit (one command buffer, one present — the
|
||||
shape that looks cheaper) put the whole 13-pass chain behind a vblank and measured **72 fps**
|
||||
against **111 fps** for the split shape, on HL2 + Retro CRT at 1920x1080 on the Pocket FIT (the
|
||||
copy path is 129 fps on the same scene). Anyone tempted to "optimise" this into one submit should
|
||||
read this paragraph first.
|
||||
- **What goes on the overlay layer**: exactly one draw above the game — a second Wayland toplevel
|
||||
(a launcher or settings window, a message box), copied 1:1 into the overlay pool and then
|
||||
*cropped and placed* by the display through the same `vkp_map_draw` mapping the copy path uses.
|
||||
The point is what does **not** happen: the game's frames are no longer copied through the
|
||||
compositor's swapchain just because something small sits on top of them.
|
||||
- **Transparency.** The compositor composes with blits, which overwrite — it never alpha-blends,
|
||||
on either path — so every layer is marked `ASC_TRANSPARENCY_OPAQUE` and the overlay layer is
|
||||
cropped to the window it carries. There is no blending to get wrong: no black box over the game,
|
||||
no double-darkening, and the picture is the copy path's, pixel for pixel.
|
||||
- **Input is untouched.** An `ASurfaceControl` has no input channel, so neither layer can take a
|
||||
touch: everything still reaches the app's `SurfaceView` (and the views above it) exactly as
|
||||
before, and the scene mapping touch goes through (`vkp_output_to_scene` / `ViewTransformation`)
|
||||
is the same one the layers are placed with, so the cursor still lands where it is pointing. The
|
||||
SurfaceView is not Z-on-top, so its whole subtree — both layers included — stays under the
|
||||
activity's own window: the drawer, the HUD and every Compose dialog draw above them.
|
||||
- **What cannot be layered, and why.**
|
||||
- *Frame generation*: each generated frame needs a present of its own on consecutive vblanks, and
|
||||
a display layer latches one buffer per refresh — pacing that is the swapchain's job. While an
|
||||
engine is armed the whole scene takes the copy path (unchanged).
|
||||
- *Effects with a window above the game*: the chain has to see the whole scene to look the way it
|
||||
does on the copy path (and on X11), and the game layer only carries the game. Copy path.
|
||||
- *Two or more draws above the game* (several windows, or a window with subsurfaces): a third
|
||||
layer is not worth the client-composition risk. Copy path.
|
||||
- **Lifecycle.** Hiding is top-down so nothing is uncovered for a frame; a hidden or retired layer
|
||||
gets the shared 16x16 blank buffer so SurfaceFlinger really lets go of the game's buffer (and
|
||||
reports a release fence for it) instead of holding it while invisible. `sc_layer_hide()` takes
|
||||
every layer down (scene no longer a fullscreen game, zero-copy switched off live, session end),
|
||||
`sc_layer_hide_overlay()` is used when only the window above the game closed, and
|
||||
`sc_layer_window_gone()` retires both SurfaceControls and drains both pools on a surface loss /
|
||||
HOME / resume. **The overlay layer is always RETIRED, never merely hidden** (both paths) — see
|
||||
the HWC note below: a live second SurfaceControl keeps SurfaceFlinger composing on the GPU even
|
||||
when it is invisible. The game layer keeps its SurfaceControl through a hide, because it goes up
|
||||
and down with every effects / frame-generation toggle.
|
||||
- **The display frame-rate vote belongs to one layer.** The refresh-rate stream's
|
||||
`sc_layer_set_frame_rate()` (the game's cadence, the same value the app votes on its own surface)
|
||||
is carried **only** by the layer the game presents on — the game layer. The overlay layer is
|
||||
explicitly voted `0`, so a window that redraws once a second can never hold the panel at the
|
||||
game's cadence, nor drag the game's cadence down to its own. Each layer remembers what its live
|
||||
SurfaceControl carries (`fps_applied`) and re-applies on the next transaction, and a retired
|
||||
SurfaceControl resets it so a re-created layer is re-voted from scratch. Log: `display frame-rate
|
||||
vote on banner_wayland_game: 60.00 Hz`.
|
||||
- **Stats.** The 10 s `stats` line now ends with `| N zero-copy frames` (the game's own buffers) and
|
||||
`| N layer frames` (frames the compositor put on a layer through one of its own buffers — the
|
||||
plain layer blit or the effects result). Both are hardware-composed; only the first is copy-free.
|
||||
- **Measured on the Pocket FIT (Adreno 750, portrait panel, landscape session → every layer is
|
||||
ROT_90 + scaled), `dumpsys android.hardware.graphics.composer3.IComposer/default`:** one layer is
|
||||
`composition: DEVICE/DEVICE` (game's own gralloc buffer scanned out by the DPU), with effects on
|
||||
the layer it stays `DEVICE/DEVICE`, but **two** layers flip the whole frame to `DEVICE/CLIENT` —
|
||||
SurfaceFlinger composes it on the GPU — **and it does not come back when the overlay goes away**:
|
||||
retiring the overlay's SurfaceControl (which the compositor now does rather than merely hiding
|
||||
it) leaves the frame in client composition; only re-creating the *game* layer's SurfaceControl
|
||||
clears it (HOME + resume does, reproduced twice). Retiring is still right — one fewer live layer,
|
||||
and it leaves the HWC list — it is just not the whole cure; the open follow-up is to retire and
|
||||
immediately re-create the game layer when the overlay goes, which would cost one black frame
|
||||
unless the new SurfaceControl is shown before the old one is dropped. The likely mechanism is the
|
||||
DPU's rotator budget (one rotated+scaled layer), not the layer count as such, so a device or
|
||||
orientation that needs no rotation may well take both on the DPU. Even in client composition the
|
||||
overlay layer is not a loss (SurfaceFlinger does the one blit the compositor would have done), but
|
||||
the hardware-composition win is only real for the single-layer cases. Note `VRI[ScreenDecorHwcOverlay]`
|
||||
is always `DISPLAY_DECORATION/CLIENT` (the system's rounded corners) — that is why SurfaceFlinger's
|
||||
`clientCompositionFrames` counter reads 100 % on this device in every state and is useless here.
|
||||
- **Not done yet:** a second toplevel that is itself rendering into gralloc buffers could go on the
|
||||
overlay layer zero-copy too (the token machinery in `ahb_swapchain.c` is already per-buffer, not
|
||||
per-layer); today the overlay always costs one small blit.
|
||||
|
||||
## Screen effects (feat/wayland-effects, `src/effects_chain.c`)
|
||||
The X11 renderer's screen-effect chain, run by the compositor between the composited scene and the
|
||||
output. Same SPIR-V as the X11 Vulkan renderer (`winlator/*_frag.h`, made by `winlator/gen_shaders.sh`
|
||||
and committed — the NDK build compiles no GLSL, so there is no build-time shader tooling), same
|
||||
push-constant layouts, uniform ranges and pass order, so a saved preset looks the same on both backends.
|
||||
|
||||
**Present-pass hook order (`vk_present.c`, `vkp_render`):**
|
||||
```
|
||||
scene (every draw blitted 1:1 into a scene-sized R8G8B8A8 image; compositor pass only)
|
||||
-> vkp_effects_run() effects_chain.c: scaling -> effects (below)
|
||||
-> vkp_framegen_run() framegen_bridge.c: frame generation on the chain's result (next section)
|
||||
-> update_map / blit Fullscreen Mode + Screen Alignment map the result (and each generated
|
||||
frame) onto its own swapchain image
|
||||
-> present generated frames first, the real frame last, FIFO
|
||||
```
|
||||
The compositor pass runs when either stage needs it (`vkp_effects_active() || vkp_framegen_active()`).
|
||||
Effects operate on the scene; the mapping operates on the output — the chain's result stands for
|
||||
the whole scene and goes through the same `draw_to_blit` as a plain frame. With everything off the
|
||||
frame takes the old path unchanged (draws blitted straight through the mapping); only the blit filter
|
||||
follows the scaling mode (Nearest = `VK_FILTER_NEAREST`).
|
||||
|
||||
**Pass order (locked to the X11 Vulkan renderer, `VulkanRendererContext::recordUpscalePasses`):**
|
||||
scaling → FXAA → Toon → Colour (brightness/contrast/gamma/saturation) → CAS → HDR → NTSC → CRT →
|
||||
Debanding (terminal dither). Scaling modes: 0 None / 1 Linear / 2 Nearest = a filtered resize;
|
||||
3 SGSR, 8 SGSR HQ, 7 NIS = one pass; 4 FSR / 5 FSR Fit = EASU → RCAS (fill vs fit is the Fullscreen
|
||||
Mode's business here, both run the same pair); 6 Sharpen = RCAS 1:1 (nearest scale + sharpen, as X11).
|
||||
Render scale is "Not used on Wayland": the scaling modes resize the scene to its **mapped output size**
|
||||
(3/4/5/7/8 only when that is larger than the scene, the X11 "render below display" gate; 6 always).
|
||||
Every later pass runs at that resolution, ping-ponging between two targets (+ one EASU mid target).
|
||||
|
||||
**Settings** (`WaylandCompositor.nativeSetUpscaler / nativeSetUpscaleSharpness / nativeSetCas /
|
||||
nativeSetHdr / nativeSetDeband / nativeSetScreenEffects / nativeSetLookName`, 1:1 with
|
||||
`VulkanRenderer`'s): any thread; the compositor thread snapshots them per frame, redraws even a
|
||||
static scene, and writes one `effects` line per change:
|
||||
`effects scaling=SGSR HQ 75%, CAS on 55%, Look="Game Clarity", colour b=+2 c=+12 g=1.00 s=108%`
|
||||
(`effects all off: scaling=Linear (plain blit)` when nothing is on). The chain's Vulkan objects are
|
||||
built on the first active frame (`effects chain ready: 13 passes … on <GPU>`; a driver that refuses
|
||||
them logs an `error` and effects stay off for the session). The app wires the drawer's Vulkan
|
||||
post-chain block (`XServerDialogState.on*Apply`) to these in `XServerDisplayActivity.initWaylandEffects`
|
||||
and remembers the same per-game keys as the Vulkan path (#382).
|
||||
|
||||
**Zero-copy interplay:** the chain's result no longer has to land in the app's swapchain — with a
|
||||
fullscreen game alone on screen it is copied into the game layer's own gralloc buffer and the game
|
||||
**stays on its display layer** while a Look is applied (see "Multi-layer presentation" below). It
|
||||
still takes the copy path when a window is drawn above the game (the chain has to see the whole
|
||||
scene to look as it does on X11) — `effects zero-copy paused: a window above the game needs the
|
||||
compositor pass for the whole scene` — and always while frame generation is armed
|
||||
(`framegen zero-copy paused: frame generation needs the compositor pass`); the layer comes back with
|
||||
`effects zero-copy resumed: the game is back on its own display layer`. A frame this renderer could
|
||||
not import (layer-only candidate) still goes on the layer, effects/frame generation skipped, said once.
|
||||
|
||||
## Frame generation (feat/wayland-framegen, `src/framegen_bridge.c`)
|
||||
The two **native** engines the X11 renderer hosts inside `libwinlator`'s compositor run inside the
|
||||
Wayland compositor's own Turnip device: **LSFG Native** (the user's Lossless.dll chain,
|
||||
`winlator/lsfg`) and **Win-FG Native** (our FSR3-derived optical-flow chain, `winlator/winfg`).
|
||||
The engine sources are compiled into `libbannerwayland.so` unmodified (CMake, app build only; the
|
||||
standalone build gets `framegen_engine_stub.c`) and driven by `src/framegen_engine.cpp`, which fills
|
||||
their `VkTable` by name from the compositor's `vkGetInstanceProcAddr`/`vkGetDeviceProcAddr`.
|
||||
**bionic-fg** (the guest-side win-fg Vulkan layer) is X11-only: its frames are born inside the guest
|
||||
and have nothing to attach to here, so on Wayland the "bionic" engine is always Win-FG Native.
|
||||
- **Where it runs** (the hook order above): frame generation takes the effects chain's RESULT
|
||||
(`vkp_effects_run`'s output, at its size - the scene, or the mapped output size under a scaling
|
||||
mode - moved to GENERAL), so generated frames carry the same look as real ones. The ONE hook
|
||||
`vkp_framegen_run(cmd, image, view, w, h, fmt, gens[])` records the engine's chain into the same
|
||||
command buffer and returns 0..3 generated images. Each image is then blitted through the scene ->
|
||||
output mapping into its own acquired swapchain image and presented: **generated frames first, the
|
||||
real frame last** (interpolation produces frames between N-1 and N; that one output interval of
|
||||
latency is inherent). One acquire/render-done semaphore pair and command buffer per present
|
||||
(`MAX_PRESENTS` = 4), the frame fence on the last submit. With the FIFO swapchain the presentation
|
||||
engine shows them on consecutive vblanks: that is the pacing, there are no sleeps and no host pacer.
|
||||
The swapchain is rebuilt with `multiplier - 1` extra images while armed so every present of a frame
|
||||
queues without a vblank wait. Frame generation off and effects off = the direct path, byte-for-byte
|
||||
as before.
|
||||
- **Device**: `dev_init` asks the bridge for the LSFG feature chain (`VkPhysicalDeviceVulkan12Features`
|
||||
vulkanMemoryModel + `shaderStorageImageWriteWithoutFormat/ExtendedFormats`, the same chain
|
||||
`VulkanRendererContext::createLogicalDevice` uses; instance apiVersion is 1.3 for the probe) and
|
||||
retries device creation without it if the driver refuses. Win-FG needs only a storage-capable ring
|
||||
format (RGBA8). The generation ring (`STORAGE|SAMPLED|TRANSFER_SRC|DST`, GENERAL) and the engines'
|
||||
own history live for the session; arming/disarming is a flag, a multiplier change resizes the ring.
|
||||
- **FPS limiter / vsync**: untouched. The limiter still paces the game's buffer returns (real frames);
|
||||
`applyNativeFgLocks` forces it on while multiplying, exactly as on X11 (`pacedLimitWithSlack` still
|
||||
applies through `nativeSetFpsLimit`). Generated frames never touch the limiter, the frame callbacks
|
||||
or the `wp_presentation` feedback - the guest sees one present per real frame.
|
||||
- **Zero-copy**: the layer bypasses the compositor pass, so while frame generation is armed the
|
||||
fullscreen window takes the copy path (`render_scene`: `framegen zero-copy paused: frame generation
|
||||
needs the compositor pass`) and the layer resumes when both it and the effects are off (see the
|
||||
effects section's zero-copy interplay).
|
||||
- **App side**: `WaylandCompositor.nativeSetFrameGenEngine/Armed/Tuning`, `nativeSetLsfgCachePath`,
|
||||
`nativeSetWinFgTuning`, `nativeFrameGenProblem/CapsReason/Stats` (same codes and six-float shape
|
||||
as `VulkanRenderer`). `XServerDisplayActivity.applyWaylandFrameGen` is the single apply:
|
||||
`applyLsfgNative`/`applyWinFgNative` route to it in Wayland mode (launch and drawer), the drawer's
|
||||
`onBionicFgConfigChange` has a Wayland branch, `nativeFgProblemReason`/`startLsfgStatsReadout` read
|
||||
the bridge. Every native setter is a value store, so the launch code may arm before the compositor
|
||||
thread exists.
|
||||
- **Log tag `framegen`**: `engines ready on the compositor's device: LSFG Native available (supported),
|
||||
Win-FG Native available`, `<engine> engine ready (...)`, `<engine> x2 armed (flow scale 0.80, panel
|
||||
120 Hz): ...`, `generating: <engine> x2 at 1920x1080 (1 interpolated frame per game frame)`, the
|
||||
fallbacks (`... can't start: no shader cache`, `... failed to start on the compositor's driver`,
|
||||
`... could not build its chain at WxH`, `the driver refused the LSFG feature set`), `frame generation
|
||||
off (N frames generated this session)`, and the zero-copy pause/resume above. The 10 s `stats` line
|
||||
counts generated frames in `frames on screen` and ends with `| N generated frames`; `GPU frames from
|
||||
games` never includes them.
|
||||
@@ -0,0 +1,309 @@
|
||||
# Zero-copy window layers on Wayland — research spike + host-side prototype
|
||||
|
||||
Branch `spike/wayland-zero-copy-layers` (on `feat/wayland-phase2`). Written 2026-09-13.
|
||||
|
||||
**Question.** Today every game frame is a dma-buf the compositor imports as a `VkImage`
|
||||
(`vk_present.c: vkp_image_from_dmabuf`) and blits into its own swapchain (`vkp_render`), one
|
||||
full-screen copy per frame, and the FPS gap to X11 on the AIO is ~20 % for Vulkan/D3D12
|
||||
(596 vs 752, 336 vs 430 on the Adreno 750). Wayland lets each window buffer become its own
|
||||
Android layer (`ASurfaceControl` + `AHardwareBuffer`) so SurfaceFlinger/the DPU composites it
|
||||
with no copy. The blocker: dma-buf ↔ `AHardwareBuffer` interop on Turnip/KGSL/bionic/Android 14,
|
||||
with the game on the Wayland Turnip bundled in the Proton wcp and the compositor on the
|
||||
adrenotools Turnip.
|
||||
|
||||
**Answer in one paragraph.** A raw dma-buf can never become an `AHardwareBuffer` (option b is
|
||||
closed: no public API, and the game's buffers are `/dev/dma_heap/system` allocations, not
|
||||
gralloc buffers). The interop must go the other way: the buffer is a **gralloc `AHardwareBuffer`
|
||||
first**, and its dma-buf fd (`native_handle->data[0]`) is what the Vulkan drivers import — which is
|
||||
exactly how Turnip already imports every gralloc buffer on Android (`vk_android.c`). Both Turnips
|
||||
in play already have every extension needed; nothing is missing in the drivers. What is missing is
|
||||
a **WSI hook**: Mesa's Wayland WSI always allocates its own dma-bufs and has no way to receive or
|
||||
allocate compositor-visible buffers, so **option (a) or (c) each need a ~300-line patch to
|
||||
`wsi_common_wayland.c` in our own Wayland Turnip build** (banners-turnip-wayland
|
||||
`build_turnip_wayland_wsi.sh`, Mesa `7cda7850`) plus a small private Wayland protocol. Nothing in
|
||||
the app can remove the copy on its own. Recommended: **option (a′) — the game's WSI allocates its
|
||||
swapchain images as `AHardwareBuffer`s (gralloc-native, UBWC), imports them through the AHB path
|
||||
Turnip already has, and hands the compositor the AHB over a Unix socket (`AHardwareBuffer_send/
|
||||
recvHandleFromUnixSocket`, the same mechanism the X11 renderer already uses for `GPUImage`) plus
|
||||
the dma-buf fd through `zwp_linux_dmabuf_v1` as today (so the blit path stays as the fallback).**
|
||||
The host half — one `ASurfaceControl` layer per fullscreen window, geometry from the fullscreen
|
||||
mode, release fences from `ASurfaceTransaction_setOnComplete`, black base surface, HUD/pointer as
|
||||
Android views above — is implemented in this branch as a gated prototype (`sc_layer.c`,
|
||||
`BANNER_WAYLAND_ZERO_COPY=1`) with a compositor-owned AHB pool and one blit, so the
|
||||
SurfaceFlinger side can be measured on the device before the driver work starts.
|
||||
|
||||
---
|
||||
|
||||
## 1. Buffer path options
|
||||
|
||||
Facts the options rest on (Mesa `7cda7850`, the commit both Turnips are built from):
|
||||
|
||||
- **Game-side buffers today** are dma-bufs from a DMA heap: the KGSL winsys allocates exportable
|
||||
memory with `DMA_HEAP_IOCTL_ALLOC` on `/dev/dma_heap/system` (ION on older kernels) and imports
|
||||
the fd into KGSL with `IOCTL_KGSL_GPUOBJ_IMPORT` / `KGSL_USER_MEM_TYPE_DMABUF`
|
||||
(`tu_knl_kgsl.cc:84-107`, `279-296`, `375-436`, `1836-1856`); export is a `dup()` of that fd
|
||||
(`kgsl_bo_export_dmabuf`, `:438-442`). They are **not gralloc buffers**: no `private_handle_t`,
|
||||
no metadata fd, nothing SurfaceFlinger's mapper could import.
|
||||
- **Dma-buf import works on both Turnips**: `VK_KHR_external_memory_fd`,
|
||||
`VK_EXT_external_memory_dma_buf`, `VK_EXT_image_drm_format_modifier` are unconditional
|
||||
(`tu_device.cc:253, 354, 369`); the compositor proves it every frame. Only
|
||||
`VK_EXT_physical_device_drm` is off on KGSL (`:385`) — relevant to dmabuf-v4 feedback (§2).
|
||||
- **AHB import in Turnip is dma-buf import.** `VK_ANDROID_external_memory_android_hardware_buffer`
|
||||
is exposed whenever a u_gralloc backend exists (`tu_device.cc:219, 428`), and the fallback backend
|
||||
always exists. `vkGetAndroidHardwareBufferPropertiesANDROID` does
|
||||
`AHardwareBuffer_getNativeHandle(buffer)->data[0]` → `lseek` for the size →
|
||||
`GetMemoryFdPropertiesKHR(DMA_BUF, data[0])` (`vk_android.c:1225-1236`); the image is created with
|
||||
`VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT` from the gralloc layout
|
||||
(`vk_gralloc_to_drm_explicit_layout`, `vk_android.c:140-205`; `tu_image.cc:1006-1023`). The
|
||||
layout comes from `u_gralloc_fallback.c:145-156`: on a QTI handle (magic `'gmsm'` in the first
|
||||
int) the UBWC flag `0x08000000` in the next int selects `DRM_FORMAT_MOD_QCOM_COMPRESSED`, else
|
||||
`DRM_FORMAT_MOD_LINEAR`; pitch = `pixel_stride × bpp`, offset 0. The qcom backend
|
||||
(`u_gralloc_qcom.c`, `hw_get_module`) cannot load the vendor gralloc from an app process, so the
|
||||
fallback is the one in use — the local KGSL build imports exactly `AHardwareBuffer_allocate /
|
||||
describe / getNativeHandle / acquire / release / isSupported` and `hw_get_module`, NEEDED
|
||||
`libnativewindow.so` + `libhardware.so` (readelf on `turnip608/stg/libvulkan_freedreno.so`).
|
||||
So **the Wine process already loads `libnativewindow.so`** (as a dependency of the ICD), and
|
||||
the X11 renderer already receives AHBs allocated inside guest processes over a Unix socket
|
||||
(`DRI3Extension.java:141-150` → `GPUImage(fd)` → `gpu_image.c:74-86`
|
||||
`AHardwareBuffer_recvHandleFromUnixSocket`; the sender is the X11 `libvulkan_wrapper.so` WSI).
|
||||
|
||||
### (a) Game side: `AHardwareBuffer_allocate` in the guest, exported as a dma-buf
|
||||
|
||||
Feasible with the current drivers, **but only through a WSI patch** — the app cannot do it.
|
||||
Mesa's Wayland WSI creates every native swapchain image with `wsi_create_native_image_mem`
|
||||
(`wsi_common_drm.c:760-850`): `vkAllocateMemory` with `VkExportMemoryAllocateInfo{DMA_BUF}` →
|
||||
`vkGetMemoryFdKHR` → `zwp_linux_buffer_params_v1.add(fd, …)` + `create_immed`
|
||||
(`wsi_common_wayland.c:3558-3620`). Nothing in it allocates from gralloc, and `VkNativeBufferANDROID`
|
||||
(the Android-WSI import path, `tu_image.cc:880-925`) is only reachable from the Android swapchain.
|
||||
|
||||
The patch (in our Wayland Turnip build): a new `create_mem` for the Wayland chain, selected when the
|
||||
compositor advertises a private global `banner_layer_buffer_v1`:
|
||||
1. `AHardwareBuffer_allocate(w, h, R8G8B8A8, GPU_COLOR_OUTPUT | GPU_SAMPLED_IMAGE)`;
|
||||
`vkGetAndroidHardwareBufferPropertiesANDROID` → `vkAllocateMemory` with
|
||||
`VkImportAndroidHardwareBufferInfoANDROID` (Turnip: `tu_device.cc:3828`), bind — the image was
|
||||
created with the modifier/pitch gralloc reports, i.e. UBWC on Adreno gralloc (§2).
|
||||
2. `wsi_image.dma_buf_fd = dup(native_handle->data[0])`, `drm_modifier` / `row_pitches[0]` from
|
||||
the same layout → the existing `zwp_linux_dmabuf_v1` path stays untouched: the compositor keeps
|
||||
importing a dma-buf and can keep the blit path as the fallback.
|
||||
3. `banner_layer_buffer_v1.attach(wl_buffer, socket_fd)`: the WSI creates a `socketpair`, sends one
|
||||
end in the request, and calls `AHardwareBuffer_sendHandleToUnixSocket(ahb, other_end)`; the
|
||||
compositor's request handler does `AHardwareBuffer_recvHandleFromUnixSocket` and stores the AHB
|
||||
on `struct dmabuf_buffer`. Per swapchain image, once — not per frame.
|
||||
Extensions used by the game: `VK_ANDROID_external_memory_android_hardware_buffer` only (the
|
||||
dma-buf/modifier extensions are used internally by the same driver). Note winevulkan does not
|
||||
expose the AHB extension to PE code — irrelevant here, the WSI is unix-side inside the ICD.
|
||||
Effort: 2–3 days WSI + protocol + wcp rebuild (wine-compat-engineer for the packaging).
|
||||
|
||||
### (b) Import the game's existing dma-buf as an `AHardwareBuffer`
|
||||
|
||||
**No.** There is no public API: `AHardwareBuffer_createFromHandle` exists only in
|
||||
`vndk/hardware_buffer.h` (exported by `libnativewindow.so`, so `dlsym` finds it), but it takes a
|
||||
gralloc `native_handle_t` that the vendor mapper (`IMapper::importBuffer`) validates — on QTI a
|
||||
`private_handle_t` with the `'gmsm'` magic, a metadata dma-buf, and vendor-specific ints. The game's
|
||||
buffers are bare DMA-heap fds. Fabricating a vendor handle around a foreign fd is unversioned
|
||||
private ABI (differs across gralloc4 releases/OEMs) and is exactly the kind of thing that
|
||||
reboots non-Adreno/old SoCs. `AHardwareBuffer_createFromHandle` also requires the caller to be
|
||||
in the VNDK namespace for its stub; only `dlsym` reaches it. Rejected.
|
||||
|
||||
### (c) Compositor-owned pool offered to the game
|
||||
|
||||
Compositor allocates AHBs, gets the fd from the native handle, and the game imports them. On the
|
||||
game side this is the same driver path as (a) minus gralloc (`VK_EXT_external_memory_dma_buf` +
|
||||
explicit modifier/pitch from the compositor). It **still needs the same WSI patch** (a `create_mem`
|
||||
that imports instead of exports) and in addition a protocol to carry `fd + modifier + pitch + size`
|
||||
before the swapchain image is created, plus reallocation on `vkCreateSwapchainKHR` (size changes),
|
||||
plus fence plumbing in both directions. `zwp_linux_dmabuf_v1` v4 feedback cannot express this (it
|
||||
only steers format/modifier/device; the client still allocates), and on KGSL v4 is a trap anyway:
|
||||
the driver has no DRM `dev_t`, so `same_gpu` stays false (`wsi_common_wayland.c:1660-1686`) and
|
||||
Mesa takes the prime-blit path (one extra copy per frame). The one advantage over (a) — the
|
||||
compositor decides linear vs UBWC — is moot because gralloc's decision is the right one for the DPU.
|
||||
Effort: 3–4 days; strictly more moving parts than (a). Not recommended.
|
||||
|
||||
**Recommendation: (a).** It reuses two proven mechanisms (Turnip's AHB import, the X11 path's
|
||||
AHB-over-socket), keeps `zwp_linux_dmabuf_v1` as the fallback transport, and confines the new code
|
||||
to our own Mesa build plus one small protocol.
|
||||
|
||||
## 2. Modifiers / UBWC
|
||||
|
||||
- Turnip advertises exactly two modifiers: `DRM_FORMAT_MOD_LINEAR` and
|
||||
`DRM_FORMAT_MOD_QCOM_COMPRESSED` (UBWC), the latter whenever the format tiles and
|
||||
`ubwc_possible()` (`tu_formats.cc:416-443`); explicit-modifier images accept only these two
|
||||
(`:530-575`). `QCOM_COMPRESSED` forces UBWC (`tu_image.cc:723-727`); an explicit plane layout is
|
||||
validated by `fdl6_layout_image` and rejected with
|
||||
`VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT` if the pitch does not fit
|
||||
(`:762-806`). Export/import of both is symmetric (same driver, same `fdl6` layout).
|
||||
- The compositor advertises `LINEAR` and `INVALID` only (`compositor.c: bind_dmabuf`,
|
||||
`uint64_t mods[] = {MOD_LINEAR, MOD_INVALID}`); `INVALID` is dropped by the WSI
|
||||
(`wsi_common_wayland.c:449-451`), so every game swapchain is linear today. DXVK/VKD3D render to
|
||||
their own tiled/UBWC targets and copy into the linear swapchain image at present — a full-frame
|
||||
linear write per frame on the game side, on top of the compositor's blit. This is a real part of
|
||||
the 20 %.
|
||||
- Advertising `QCOM_COMPRESSED` as well: one line in `bind_dmabuf`. The WSI intersects the
|
||||
compositor's list with the driver's (`wsi_common_drm.c:686-733`) and Turnip prefers UBWC when
|
||||
offered; `vkp_image_from_dmabuf` already passes any modifier through. Two cautions: the pitch
|
||||
the game sends is the UBWC pixel-plane pitch (Mesa reports plane 0 of the modifier, `:817-830`)
|
||||
and both sides run the same `fdl6` code, so the import must succeed on the same GPU; and a
|
||||
UBWC buffer must never be read by the CPU path (`wl_shm` is unaffected). This is independent of
|
||||
layers and worth its own A/B (experiment plan step 0).
|
||||
- For layers the buffer is gralloc's, so UBWC is decided by gralloc: QTI allocates UBWC for
|
||||
`GPU_COLOR_OUTPUT` RGBA8 unless a CPU usage bit is set (the prototype exploits exactly that:
|
||||
`sc_layer.c: alloc_slot` retries with `CPU_READ_RARELY` when a UBWC import fails). The DPU
|
||||
scans out UBWC RGBA natively; a prior device experiment (GL native rendering, 2026-06-29)
|
||||
found the SDE pipes accepted both UBWC and linear layers — rotation+scale was the blocker, not
|
||||
UBWC.
|
||||
|
||||
## 3. Per-layer composition (design; the prototype implements the single-layer subset)
|
||||
|
||||
- **wl_surface → SurfaceControl.** One `ASurfaceControl_createFromWindow(surfaceView_window,
|
||||
name)` child per mapped toplevel (and per subsurface tree flattened per toplevel); the desktop
|
||||
surface is the base layer at z 0 (or, with `g_hide_shell`, a black base — the SurfaceView's own
|
||||
buffer); toplevels get `setZOrder` from the `g_toplevels` order (`apply_zorder`), with
|
||||
`INT_MAX` reserved for the app's cursor/HUD if they ever move native. Position/scale:
|
||||
`ASurfaceTransaction_setGeometry(src = buffer rect, dst = output rect, transform 0)`, with the
|
||||
output rect produced by the same `update_map()` / `draw_to_blit()` arithmetic the blit path uses
|
||||
(`vk_present.c: vkp_map_draw`) — letterbox/FILL crop/TOP-BOTTOM half all come out identical, so
|
||||
**input stays consistent by construction**: the app maps touch through `ViewTransformation`
|
||||
with the same inputs (see `WAYLAND_RUNTIME.md` "Fullscreen mode"), and the compositor's own
|
||||
`vkp_output_to_scene` keeps working because the map is still updated every frame.
|
||||
`setBufferTransparency(OPAQUE)` for XR24/XB24; `setBufferTransform` stays 0 — the DPU refuses
|
||||
rotation+scale on one pipe (prior experiment), so a rotated panel must be handled by the
|
||||
activity's orientation, not the layer.
|
||||
- **HUD.** Already a separate layer: `PerfHudView`/`FrameRating`/cursor are Android views in
|
||||
`rootView` above `waylandSurfaceView`, i.e. the ViewRoot's SurfaceFlinger layer above the
|
||||
SurfaceView and all its child SurfaceControls. Nothing to do; the prototype keeps it.
|
||||
- **Vsync / frame callbacks.** Keep the app's Choreographer tick (`nativeVsync`) as the pacing
|
||||
edge: on each tick the compositor applies **one transaction** containing every surface that
|
||||
committed since the last tick (`setBuffer` per changed layer, geometry/z for changed ones), then
|
||||
fires `wl_callback.done` for those surfaces (as today, `fire_all_frames`). `wp_presentation`
|
||||
feedback moves from "after our present" to the transaction's `ASurfaceTransaction_setOnComplete`
|
||||
→ `ASurfaceTransactionStats_getLatchTime` / `getPresentFenceFd` (API 29) give the real on-glass
|
||||
time — better than today's `now_ns()`; `setFrameTimeline` (API 33) can be added later for
|
||||
`VK_GOOGLE_display_timing` work. Without a window, `pace_without_output` stays as is.
|
||||
- **`wl_buffer.release` timing.** Today a replaced buffer is released on the limiter's cadence,
|
||||
which is safe because the blit was waited for. With layers the buffer is on the display until
|
||||
SurfaceFlinger says otherwise: keep the buffer un-released until the OnComplete callback of the
|
||||
transaction that **replaced** it delivers `ASurfaceTransactionStats_getPreviousReleaseFenceFd`
|
||||
(this is what `ASurfaceRendererContext::transactionCompleteCallback` does), wait that fence on
|
||||
the compositor thread (or, better, hand it to the game: with option (a) the WSI can import it as
|
||||
the `WSI_ES_RELEASE` point — Turnip/KGSL implements `vk_sync.import_sync_file`,
|
||||
`tu_knl_kgsl.cc:1261-1303`), then `wl_buffer_send_release`. The FPS limiter keeps working: it only
|
||||
delays the release further. Android 16's `setBufferWithRelease` is not available on 14.
|
||||
- **Acquire fence.** Two sources: (1) if the kernel supports `DMA_BUF_IOCTL_EXPORT_SYNC_FILE`
|
||||
(6.x GKI), the WSI already attaches its present semaphore to the dma-buf as a sync_file
|
||||
(`wsi_drm_init_swapchain_implicit_sync`, `wsi_common_drm.c:368-395`, gated on the driver
|
||||
exporting `SYNC_FD` semaphores — KGSL does, `:1278-1303`), and the compositor can
|
||||
`EXPORT_SYNC_FILE(READ)` it and pass the fd to `setBuffer` — the prototype probes this on the
|
||||
first frame and logs the answer; (2) otherwise the option-(a) protocol carries a sync_fd per
|
||||
present (`vkGetSemaphoreFdKHR`), which is what the X11 wrapper does. Never `-1` for a real
|
||||
zero-copy frame.
|
||||
- **Lifecycle.** SurfaceView destroyed/recreated (background, rotation): `vkp_apply_window_request`
|
||||
already serialises window changes on the compositor thread; the layer code retires its
|
||||
SurfaceControls (hide + `reparent(NULL)` + release in the OnComplete callback) and recreates
|
||||
them on the new window. Buffers stay valid across that (gralloc buffers are process-independent
|
||||
refcounted objects), so the first frame after resume is the last committed one.
|
||||
|
||||
## 4. Risks
|
||||
|
||||
- **HWC fallback to GPU composition** (the whole point is DEVICE composition). Known from the
|
||||
2026-06-29 experiments on the Adreno 750 device: a layer with `transform 90` **and** scale went
|
||||
CLIENT and dragged the base layer with it; the same layer pre-rotated at panel resolution with
|
||||
src == dst was DEVICE on every layer, GPU_TARGET empty. So: no SurfaceControl rotation ever; on
|
||||
a landscape-native panel (handheld) the identity-transform game layer with a DPU scale should
|
||||
promote; on a portrait phone in landscape it will not, and the base swapchain path is the better
|
||||
one there — decide per device by measurement, not by assumption. Measure with
|
||||
`dumpsys SurfaceFlinger` (layer `composition: DEVICE/DEVICE` vs `DEVICE/CLIENT`, and the SDE pipe
|
||||
table `GPU_TARGET` line) with the app foreground and the drawer closed.
|
||||
- **Layer count.** The DPU has a handful of pipes (4–8 usable RGB pipes on SDM/SM8xxx); 2–3 game
|
||||
layers + base + HUD + cursor is fine, a desktop with 10 windows is not — SurfaceFlinger then
|
||||
composites the overflow on the GPU (still correct, just no gain). Policy: layers only for
|
||||
fullscreen/topmost windows, everything else stays in the base swapchain (the prototype's rule).
|
||||
- **Buffer ownership across processes.** The game's `AHardwareBuffer` is alive in the guest; the
|
||||
compositor's received copy holds its own gralloc reference, SurfaceFlinger a third. A guest crash
|
||||
mid-present leaves SurfaceFlinger with a valid buffer (no black flash). Fds: one dma-buf fd + one
|
||||
socket per swapchain image; clean up on `wl_buffer` destroy (today's `dmabuf_buffer_unref`).
|
||||
- **Fences.** Passing `-1` acquire fences with a buffer the GPU is still writing shows tearing or
|
||||
stale content; KGSL has no BO implicit sync, so the sync_file path in §3 is mandatory for the
|
||||
real thing (the prototype waits on the CPU instead, which is safe).
|
||||
- **Background / rotation / device lost.** Covered by the window-request serialisation; a device
|
||||
loss in the compositor's Turnip does not affect layers already on screen (SurfaceFlinger owns
|
||||
them) — the old path's `device_lost` message stays.
|
||||
- **Non-Adreno / old SoCs.** Everything here is NDK API 29 + gralloc-allocated buffers; the only
|
||||
vendor-specific piece is the `'gmsm'` handle sniff, which degrades to "linear with a CPU bit".
|
||||
Same risk class as the X11 ASR renderer; keep it opt-in until proven on a second SoC.
|
||||
- **`vk_present.c` stays.** Fallback for: no `ASurfaceControl` API, multi-window scenes, popups
|
||||
above the game, the first frames before the layer is up, and any device where composition goes
|
||||
CLIENT. The prototype switches per frame (`layer_candidate` in `compositor.c`).
|
||||
|
||||
## 5. Experiment plan (each step ≤ 1 hour on the device, in order)
|
||||
|
||||
Prerequisite: a build of this branch, container on Wayland, the AIO Graphics Test (Vulkan and
|
||||
D3D12 tabs) as the workload, session log in `Download/Wayland-logs/`.
|
||||
|
||||
0. **UBWC modifier A/B (no layers).** Done on `feat/wayland-ubwc` (advertised when the compositor's
|
||||
driver imports it, `BANNER_WAYLAND_UBWC=0` = old linear-only list; see `WAYLAND_RUNTIME.md`
|
||||
"Compressed (UBWC) game buffers"). Run the AIO Vulkan/D3D12 with and without. Expect
|
||||
`vulkan: … is presenting GPU frames through Wayland: WxH, format XB24, tiled (zero-copy)` and
|
||||
no `dmabuf import failed`. Records how much of the 20 % is the linear swapchain alone.
|
||||
1. **Layer mode smoke.** Put `BANNER_WAYLAND_ZERO_COPY=1` in the container's environment
|
||||
variables, launch the AIO fullscreen. Expected log lines (tag `layer`):
|
||||
`SurfaceControl "banner_wayland_game" created as a child of the screen surface`,
|
||||
`pool buffer 1920x1080 UBWC (QCOM_COMPRESSED), stride 1920 px (gralloc handle 2 fds / N ints)`
|
||||
(or `linear` after `import of a UBWC … failed` — also a result: it tells whether the compositor
|
||||
Turnip accepts gralloc's UBWC pitch), `geometry: buffer 0,0-1920,1080 -> screen …`,
|
||||
`presenting 1920x1080 game frames on their own SurfaceControl layer (UBWC pool, 3 buffers)`,
|
||||
and the probe line `kernel exports sync_file fences from the game's dma-buf …` or
|
||||
`DMA_BUF_IOCTL_EXPORT_SYNC_FILE … failed (…)`. Picture correct, HUD and pointer on top, fullscreen
|
||||
mode changes move the layer (`geometry:` lines).
|
||||
2. **Composition type.** With the AIO running: `dumpsys SurfaceFlinger | grep -A3 banner_wayland_game`
|
||||
and the `GPU_TARGET` line of the pipe table. DEVICE/DEVICE on the game layer with an empty GPU
|
||||
target = the DPU does the scaling; CLIENT = no gain on this panel orientation → try the
|
||||
handheld's native orientation / a resolution equal to the panel's.
|
||||
3. **Cost of the host copy.** AIO Vulkan fps with the flag on vs off (same cost expected ± noise,
|
||||
since the blit only changed its destination) and `dumpsys gfxinfo`/battery for 5 min each. This
|
||||
is the baseline the WSI patch is measured against.
|
||||
4. **Fence probe outcome → choose the acquire-fence design** (§3) before starting the WSI patch.
|
||||
5. **WSI patch (option a) in banners-turnip-wayland**, wcp rebuild, then the same steps 1–3 with
|
||||
the AHB arriving from the guest: log line to add on the compositor side `layer: buffer N of
|
||||
"<window>" received from the game (AHardwareBuffer WxH, UBWC)` and the fps delta vs X11.
|
||||
|
||||
Work estimates: step 0 = 0.5 day incl. A/B; host layer prototype = done (this branch, ~1 day to
|
||||
harden: async fence instead of CPU wait, per-window layers, presentation feedback from
|
||||
`getLatchTime`); option (a) WSI + protocol + wcp = 2–3 days + 1 day device proving; option (c) =
|
||||
3–4 days + the same proving; (b) = not buildable.
|
||||
|
||||
## 6. What the prototype in this branch does (`BANNER_WAYLAND_ZERO_COPY=1`)
|
||||
|
||||
Files: `src/sc_layer.{c,h}` (new), `src/vk_present.{c,h}` (`vkp_image_import_dmabuf` with a
|
||||
blit-destination role, `vkp_blit_image`, `vkp_update_map`, `vkp_map_draw`, `vkp_window`,
|
||||
`vkp_signal_first_frame`; the layer is retired on window changes), `src/compositor.c`
|
||||
(`g_zero_copy`, `layer_candidate`, the `render_scene` branch, the dma-buf sync_file probe),
|
||||
`src/waylandcomp_jni.c` + `WaylandCompositor.java` (`nativeSetZeroCopy`),
|
||||
`XServerDisplayActivity.startWaylandCompositor` (reads the flag from the container's / shortcut's
|
||||
environment variables before the compositor starts).
|
||||
|
||||
Behaviour: when the topmost draw is a client GPU frame covering the whole scene (one fullscreen
|
||||
game, nothing above it), the screen swapchain is presented black and the frame is blitted (1:1,
|
||||
`vkCmdBlitImage`, CPU-waited) into one of three compositor-allocated `AHardwareBuffer`s
|
||||
(R8G8B8A8, `GPU_COLOR_OUTPUT | GPU_SAMPLED_IMAGE`, imported into the compositor's Turnip through
|
||||
its native-handle dma-buf fd with the modifier from the `'gmsm'` sniff, linear fallback), which
|
||||
is set on a child `ASurfaceControl` of the SurfaceView with the fullscreen-mode geometry, z 1,
|
||||
opaque. `setOnComplete` returns the previous buffer's release fence, which is waited on before
|
||||
that pool slot is reused; no free slot = frame dropped (logged at most every 5 s). Any other scene
|
||||
hides the layer and draws the old way; the layer is retired when the SurfaceView goes away.
|
||||
Everything else (frame callbacks, presentation feedback, FPS limiter, HUD counting, input) is
|
||||
unchanged. Off by default: with the variable unset no new code runs.
|
||||
|
||||
Not zero-copy yet — it is the receive side. The copy disappears when step 5 lands and
|
||||
`sc_layer_present` is handed the game's own `AHardwareBuffer` instead of a pool slot.
|
||||
|
||||
## 7. Step 5 implemented (feat/wayland-zero-copy-wsi + banners-turnip-wayland `banner_ahb_wsi.py`)
|
||||
|
||||
Option (a′) as recommended, with one deviation forced by the build: the Wayland Turnip is a
|
||||
`platforms=wayland` build with Android detection off, so `VK_ANDROID_external_memory_android_hardware_buffer`
|
||||
/ `vk_android.c` do not exist in it. The WSI therefore allocates the `AHardwareBuffer` itself
|
||||
(`libnativewindow.so` dlopen'd), sniffs the gralloc handle for UBWC exactly like `u_gralloc_fallback.c`,
|
||||
and imports `native_handle->data[0]` as a dma-buf with an explicit modifier + pitch — the same path
|
||||
this compositor's pool uses (`vkp_image_import_dmabuf`) — after a test `vkCreateImage` proves the
|
||||
driver accepts that layout (linear retry otherwise). Fences: implicit via the dma-buf in both
|
||||
directions (§3's option 1, proven by the probe; the compositor imports SurfaceFlinger's release
|
||||
fence back into the dma-buf before `wl_buffer.release`). Details in `WAYLAND_RUNTIME.md`.
|
||||
@@ -0,0 +1,69 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_buffer_interface;
|
||||
|
||||
static const struct wl_interface *banner_ahb_v1_types[] = {
|
||||
NULL,
|
||||
&wl_buffer_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message banner_ahb_v1_requests[] = {
|
||||
{ "destroy", "", banner_ahb_v1_types + 0 },
|
||||
{ "attach", "ohuuuuuu", banner_ahb_v1_types + 1 },
|
||||
};
|
||||
|
||||
static const struct wl_message banner_ahb_v1_events[] = {
|
||||
{ "mode", "2u", banner_ahb_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface banner_ahb_v1_interface = {
|
||||
"banner_ahb_v1", 2,
|
||||
2, banner_ahb_v1_requests,
|
||||
1, banner_ahb_v1_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef BANNER_AHB_V1_SERVER_PROTOCOL_H
|
||||
#define BANNER_AHB_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_banner_ahb_v1 The banner_ahb_v1 protocol
|
||||
* @section page_ifaces_banner_ahb_v1 Interfaces
|
||||
* - @subpage page_iface_banner_ahb_v1 - Android gralloc buffers behind dma-buf wl_buffers
|
||||
* @section page_copyright_banner_ahb_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct banner_ahb_v1;
|
||||
struct wl_buffer;
|
||||
|
||||
#ifndef BANNER_AHB_V1_INTERFACE
|
||||
#define BANNER_AHB_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_banner_ahb_v1 banner_ahb_v1
|
||||
* @section page_iface_banner_ahb_v1_desc Description
|
||||
*
|
||||
* Zero-copy window layers on Android. A Vulkan swapchain image that the
|
||||
* client allocated as an Android AHardwareBuffer (gralloc) is still shared
|
||||
* as a dma-buf through zwp_linux_dmabuf_v1, so the compositor can import
|
||||
* and draw it the usual way. This interface additionally hands the
|
||||
* compositor the AHardwareBuffer itself, once per wl_buffer, so the
|
||||
* compositor can put the buffer straight on an Android SurfaceControl
|
||||
* layer (SurfaceFlinger / the display hardware composite it) without
|
||||
* copying it.
|
||||
*
|
||||
* The AHardwareBuffer travels over a Unix socket: the client creates a
|
||||
* socketpair, writes the buffer's handle into one end with
|
||||
* AHardwareBuffer_sendHandleToUnixSocket, then sends the other end in the
|
||||
* attach request. The compositor reads it with
|
||||
* AHardwareBuffer_recvHandleFromUnixSocket and closes the socket. Its
|
||||
* reference to the AHardwareBuffer lives as long as the wl_buffer (plus
|
||||
* whatever the display still holds).
|
||||
*
|
||||
* The compositor advertises this global whenever it can put buffers on a
|
||||
* display layer at all; whether it WANTS gralloc buffers right now is the
|
||||
* mode event (version 2), sent on bind and every time the user switches
|
||||
* zero-copy on or off during the session. A client decides per swapchain,
|
||||
* when it creates the swapchain, from the last mode it received, and a
|
||||
* client whose live swapchain was built for the other mode retires it
|
||||
* (VK_ERROR_OUT_OF_DATE_KHR on its next acquire or present) so the program
|
||||
* rebuilds it for the new mode. Buffers of the old swapchain stay fully
|
||||
* presentable until then: an attached AHardwareBuffer keeps its association
|
||||
* for the wl_buffer's lifetime whatever the mode is now. A version 1
|
||||
* client (no mode event) keeps deciding from its own environment. A
|
||||
* client that does not see the global (or does not want it) allocates
|
||||
* swapchain images the standard way; nothing else changes.
|
||||
*
|
||||
* Synchronisation stays implicit: the dma-buf carries the client's render
|
||||
* fence (DMA_BUF_IOCTL_IMPORT_SYNC_FILE by the client's driver), the
|
||||
* compositor exports it as the layer's acquire fence, and the compositor
|
||||
* imports the display's release fence into the dma-buf before it sends
|
||||
* wl_buffer.release, so the client's next acquire waits on it.
|
||||
* @section page_iface_banner_ahb_v1_api API
|
||||
* See @ref iface_banner_ahb_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_banner_ahb_v1 The banner_ahb_v1 interface
|
||||
*
|
||||
* Zero-copy window layers on Android. A Vulkan swapchain image that the
|
||||
* client allocated as an Android AHardwareBuffer (gralloc) is still shared
|
||||
* as a dma-buf through zwp_linux_dmabuf_v1, so the compositor can import
|
||||
* and draw it the usual way. This interface additionally hands the
|
||||
* compositor the AHardwareBuffer itself, once per wl_buffer, so the
|
||||
* compositor can put the buffer straight on an Android SurfaceControl
|
||||
* layer (SurfaceFlinger / the display hardware composite it) without
|
||||
* copying it.
|
||||
*
|
||||
* The AHardwareBuffer travels over a Unix socket: the client creates a
|
||||
* socketpair, writes the buffer's handle into one end with
|
||||
* AHardwareBuffer_sendHandleToUnixSocket, then sends the other end in the
|
||||
* attach request. The compositor reads it with
|
||||
* AHardwareBuffer_recvHandleFromUnixSocket and closes the socket. Its
|
||||
* reference to the AHardwareBuffer lives as long as the wl_buffer (plus
|
||||
* whatever the display still holds).
|
||||
*
|
||||
* The compositor advertises this global whenever it can put buffers on a
|
||||
* display layer at all; whether it WANTS gralloc buffers right now is the
|
||||
* mode event (version 2), sent on bind and every time the user switches
|
||||
* zero-copy on or off during the session. A client decides per swapchain,
|
||||
* when it creates the swapchain, from the last mode it received, and a
|
||||
* client whose live swapchain was built for the other mode retires it
|
||||
* (VK_ERROR_OUT_OF_DATE_KHR on its next acquire or present) so the program
|
||||
* rebuilds it for the new mode. Buffers of the old swapchain stay fully
|
||||
* presentable until then: an attached AHardwareBuffer keeps its association
|
||||
* for the wl_buffer's lifetime whatever the mode is now. A version 1
|
||||
* client (no mode event) keeps deciding from its own environment. A
|
||||
* client that does not see the global (or does not want it) allocates
|
||||
* swapchain images the standard way; nothing else changes.
|
||||
*
|
||||
* Synchronisation stays implicit: the dma-buf carries the client's render
|
||||
* fence (DMA_BUF_IOCTL_IMPORT_SYNC_FILE by the client's driver), the
|
||||
* compositor exports it as the layer's acquire fence, and the compositor
|
||||
* imports the display's release fence into the dma-buf before it sends
|
||||
* wl_buffer.release, so the client's next acquire waits on it.
|
||||
*/
|
||||
extern const struct wl_interface banner_ahb_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_banner_ahb_v1
|
||||
* @struct banner_ahb_v1_interface
|
||||
*/
|
||||
struct banner_ahb_v1_interface {
|
||||
/**
|
||||
* destroy the object
|
||||
*
|
||||
* Buffers already attached keep their AHardwareBuffer
|
||||
* association.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* hand the compositor a buffer's AHardwareBuffer
|
||||
*
|
||||
* Associates the AHardwareBuffer readable from socket with the
|
||||
* (already created) dma-buf wl_buffer. width, height and stride
|
||||
* (pixels) describe the gralloc allocation; modifier_hi/lo is the
|
||||
* DRM format modifier the dma-buf was shared with (the same value
|
||||
* passed to zwp_linux_buffer_params_v1.add); image_count is the
|
||||
* number of images in the swapchain this buffer belongs to (for
|
||||
* the compositor's log). Sent once per wl_buffer, before the
|
||||
* buffer is first attached to a surface.
|
||||
* @param buffer the dma-buf wl_buffer
|
||||
* @param socket socket the AHardwareBuffer handle was written to
|
||||
* @param width buffer width in pixels
|
||||
* @param height buffer height in pixels
|
||||
* @param stride gralloc row stride in pixels
|
||||
* @param modifier_hi high 32 bits of the DRM format modifier
|
||||
* @param modifier_lo low 32 bits of the DRM format modifier
|
||||
* @param image_count images in the client's swapchain
|
||||
*/
|
||||
void (*attach)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *buffer,
|
||||
int32_t socket,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t stride,
|
||||
uint32_t modifier_hi,
|
||||
uint32_t modifier_lo,
|
||||
uint32_t image_count);
|
||||
};
|
||||
|
||||
#define BANNER_AHB_V1_MODE 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_banner_ahb_v1
|
||||
*/
|
||||
#define BANNER_AHB_V1_MODE_SINCE_VERSION 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_banner_ahb_v1
|
||||
*/
|
||||
#define BANNER_AHB_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_banner_ahb_v1
|
||||
*/
|
||||
#define BANNER_AHB_V1_ATTACH_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_banner_ahb_v1
|
||||
* Sends an mode event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param enabled 1 = gralloc swapchain images wanted, 0 = not
|
||||
*/
|
||||
static inline void
|
||||
banner_ahb_v1_send_mode(struct wl_resource *resource_, uint32_t enabled)
|
||||
{
|
||||
wl_resource_post_event(resource_, BANNER_AHB_V1_MODE, enabled);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
|
||||
static const struct wl_interface *banner_desktop_v1_types[] = {
|
||||
NULL,
|
||||
&wl_surface_interface,
|
||||
&wl_surface_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message banner_desktop_v1_requests[] = {
|
||||
{ "destroy", "", banner_desktop_v1_types + 0 },
|
||||
{ "set_desktop", "o", banner_desktop_v1_types + 1 },
|
||||
{ "set_window", "ouii", banner_desktop_v1_types + 2 },
|
||||
{ "set_zorder", "a", banner_desktop_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface banner_desktop_v1_interface = {
|
||||
"banner_desktop_v1", 1,
|
||||
4, banner_desktop_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
#define BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_banner_desktop_v1 The banner_desktop_v1 protocol
|
||||
* @section page_ifaces_banner_desktop_v1 Interfaces
|
||||
* - @subpage page_iface_banner_desktop_v1 - Windows virtual desktop layout
|
||||
* @section page_copyright_banner_desktop_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct banner_desktop_v1;
|
||||
struct wl_surface;
|
||||
|
||||
#ifndef BANNER_DESKTOP_V1_INTERFACE
|
||||
#define BANNER_DESKTOP_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_banner_desktop_v1 banner_desktop_v1
|
||||
* @section page_iface_banner_desktop_v1_desc Description
|
||||
*
|
||||
* Each Wine process is a separate Wayland client, so a Windows virtual
|
||||
* desktop can't be built from subsurfaces. Instead the process that owns
|
||||
* the desktop window marks one surface as the desktop, and every process
|
||||
* reports where its top-level windows sit on that desktop and the global
|
||||
* window stacking order. The compositor draws the desktop at the bottom,
|
||||
* the windows at the reported positions, and sends pointer and keyboard
|
||||
* input to the desktop surface; Wine routes it to the right window.
|
||||
* @section page_iface_banner_desktop_v1_api API
|
||||
* See @ref iface_banner_desktop_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_banner_desktop_v1 The banner_desktop_v1 interface
|
||||
*
|
||||
* Each Wine process is a separate Wayland client, so a Windows virtual
|
||||
* desktop can't be built from subsurfaces. Instead the process that owns
|
||||
* the desktop window marks one surface as the desktop, and every process
|
||||
* reports where its top-level windows sit on that desktop and the global
|
||||
* window stacking order. The compositor draws the desktop at the bottom,
|
||||
* the windows at the reported positions, and sends pointer and keyboard
|
||||
* input to the desktop surface; Wine routes it to the right window.
|
||||
*/
|
||||
extern const struct wl_interface banner_desktop_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_banner_desktop_v1
|
||||
* @struct banner_desktop_v1_interface
|
||||
*/
|
||||
struct banner_desktop_v1_interface {
|
||||
/**
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* mark a surface as the virtual desktop
|
||||
*
|
||||
* The surface is drawn at the origin, below every window, and
|
||||
* sets the size of the desktop.
|
||||
*/
|
||||
void (*set_desktop)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *surface);
|
||||
/**
|
||||
* place a top-level window on the desktop
|
||||
*
|
||||
* Position of the top-left corner of the surface in desktop
|
||||
* coordinates, and the window handle used by set_zorder.
|
||||
*/
|
||||
void (*set_window)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *surface,
|
||||
uint32_t hwnd,
|
||||
int32_t x,
|
||||
int32_t y);
|
||||
/**
|
||||
* report the desktop's window stacking order
|
||||
*
|
||||
* Visible top-level window handles as 32-bit values, topmost
|
||||
* first.
|
||||
*/
|
||||
void (*set_zorder)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_array *hwnds);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_banner_desktop_v1
|
||||
*/
|
||||
#define BANNER_DESKTOP_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_banner_desktop_v1
|
||||
*/
|
||||
#define BANNER_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_banner_desktop_v1
|
||||
*/
|
||||
#define BANNER_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_banner_desktop_v1
|
||||
*/
|
||||
#define BANNER_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,216 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2019 Sebastian Wick
|
||||
* Copyright 2019 Erwin Burema
|
||||
* Copyright 2020 AMD
|
||||
* Copyright 2020-2024 Collabora, Ltd.
|
||||
* Copyright 2024 Xaver Hugl
|
||||
* Copyright 2022-2025 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_color_management_output_v1_interface;
|
||||
extern const struct wl_interface wp_color_management_surface_feedback_v1_interface;
|
||||
extern const struct wl_interface wp_color_management_surface_v1_interface;
|
||||
extern const struct wl_interface wp_image_description_creator_icc_v1_interface;
|
||||
extern const struct wl_interface wp_image_description_creator_params_v1_interface;
|
||||
extern const struct wl_interface wp_image_description_info_v1_interface;
|
||||
extern const struct wl_interface wp_image_description_v1_interface;
|
||||
|
||||
static const struct wl_interface *color_management_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wp_color_management_output_v1_interface,
|
||||
&wl_output_interface,
|
||||
&wp_color_management_surface_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wp_color_management_surface_feedback_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wp_image_description_creator_icc_v1_interface,
|
||||
&wp_image_description_creator_params_v1_interface,
|
||||
&wp_image_description_v1_interface,
|
||||
&wp_image_description_v1_interface,
|
||||
&wp_image_description_v1_interface,
|
||||
NULL,
|
||||
&wp_image_description_v1_interface,
|
||||
&wp_image_description_v1_interface,
|
||||
&wp_image_description_v1_interface,
|
||||
&wp_image_description_v1_interface,
|
||||
&wp_image_description_info_v1_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_manager_v1_requests[] = {
|
||||
{ "destroy", "", color_management_v1_types + 0 },
|
||||
{ "get_output", "no", color_management_v1_types + 8 },
|
||||
{ "get_surface", "no", color_management_v1_types + 10 },
|
||||
{ "get_surface_feedback", "no", color_management_v1_types + 12 },
|
||||
{ "create_icc_creator", "n", color_management_v1_types + 14 },
|
||||
{ "create_parametric_creator", "n", color_management_v1_types + 15 },
|
||||
{ "create_windows_scrgb", "n", color_management_v1_types + 16 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_manager_v1_events[] = {
|
||||
{ "supported_intent", "u", color_management_v1_types + 0 },
|
||||
{ "supported_feature", "u", color_management_v1_types + 0 },
|
||||
{ "supported_tf_named", "u", color_management_v1_types + 0 },
|
||||
{ "supported_primaries_named", "u", color_management_v1_types + 0 },
|
||||
{ "done", "", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_color_manager_v1_interface = {
|
||||
"wp_color_manager_v1", 1,
|
||||
7, wp_color_manager_v1_requests,
|
||||
5, wp_color_manager_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_management_output_v1_requests[] = {
|
||||
{ "destroy", "", color_management_v1_types + 0 },
|
||||
{ "get_image_description", "n", color_management_v1_types + 17 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_management_output_v1_events[] = {
|
||||
{ "image_description_changed", "", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_color_management_output_v1_interface = {
|
||||
"wp_color_management_output_v1", 1,
|
||||
2, wp_color_management_output_v1_requests,
|
||||
1, wp_color_management_output_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_management_surface_v1_requests[] = {
|
||||
{ "destroy", "", color_management_v1_types + 0 },
|
||||
{ "set_image_description", "ou", color_management_v1_types + 18 },
|
||||
{ "unset_image_description", "", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_color_management_surface_v1_interface = {
|
||||
"wp_color_management_surface_v1", 1,
|
||||
3, wp_color_management_surface_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_management_surface_feedback_v1_requests[] = {
|
||||
{ "destroy", "", color_management_v1_types + 0 },
|
||||
{ "get_preferred", "n", color_management_v1_types + 20 },
|
||||
{ "get_preferred_parametric", "n", color_management_v1_types + 21 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_color_management_surface_feedback_v1_events[] = {
|
||||
{ "preferred_changed", "u", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_color_management_surface_feedback_v1_interface = {
|
||||
"wp_color_management_surface_feedback_v1", 1,
|
||||
3, wp_color_management_surface_feedback_v1_requests,
|
||||
1, wp_color_management_surface_feedback_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_image_description_creator_icc_v1_requests[] = {
|
||||
{ "create", "n", color_management_v1_types + 22 },
|
||||
{ "set_icc_file", "huu", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_image_description_creator_icc_v1_interface = {
|
||||
"wp_image_description_creator_icc_v1", 1,
|
||||
2, wp_image_description_creator_icc_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_image_description_creator_params_v1_requests[] = {
|
||||
{ "create", "n", color_management_v1_types + 23 },
|
||||
{ "set_tf_named", "u", color_management_v1_types + 0 },
|
||||
{ "set_tf_power", "u", color_management_v1_types + 0 },
|
||||
{ "set_primaries_named", "u", color_management_v1_types + 0 },
|
||||
{ "set_primaries", "iiiiiiii", color_management_v1_types + 0 },
|
||||
{ "set_luminances", "uuu", color_management_v1_types + 0 },
|
||||
{ "set_mastering_display_primaries", "iiiiiiii", color_management_v1_types + 0 },
|
||||
{ "set_mastering_luminance", "uu", color_management_v1_types + 0 },
|
||||
{ "set_max_cll", "u", color_management_v1_types + 0 },
|
||||
{ "set_max_fall", "u", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_image_description_creator_params_v1_interface = {
|
||||
"wp_image_description_creator_params_v1", 1,
|
||||
10, wp_image_description_creator_params_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_image_description_v1_requests[] = {
|
||||
{ "destroy", "", color_management_v1_types + 0 },
|
||||
{ "get_information", "n", color_management_v1_types + 24 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_image_description_v1_events[] = {
|
||||
{ "failed", "us", color_management_v1_types + 0 },
|
||||
{ "ready", "u", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_image_description_v1_interface = {
|
||||
"wp_image_description_v1", 1,
|
||||
2, wp_image_description_v1_requests,
|
||||
2, wp_image_description_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_image_description_info_v1_events[] = {
|
||||
{ "done", "", color_management_v1_types + 0 },
|
||||
{ "icc_file", "hu", color_management_v1_types + 0 },
|
||||
{ "primaries", "iiiiiiii", color_management_v1_types + 0 },
|
||||
{ "primaries_named", "u", color_management_v1_types + 0 },
|
||||
{ "tf_power", "u", color_management_v1_types + 0 },
|
||||
{ "tf_named", "u", color_management_v1_types + 0 },
|
||||
{ "luminances", "uuu", color_management_v1_types + 0 },
|
||||
{ "target_primaries", "iiiiiiii", color_management_v1_types + 0 },
|
||||
{ "target_luminance", "uu", color_management_v1_types + 0 },
|
||||
{ "target_max_cll", "u", color_management_v1_types + 0 },
|
||||
{ "target_max_fall", "u", color_management_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_image_description_info_v1_interface = {
|
||||
"wp_image_description_info_v1", 1,
|
||||
0, NULL,
|
||||
11, wp_image_description_info_v1_events,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,121 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2014, 2015 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_buffer_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface zwp_linux_buffer_params_v1_interface;
|
||||
extern const struct wl_interface zwp_linux_dmabuf_feedback_v1_interface;
|
||||
|
||||
static const struct wl_interface *linux_dmabuf_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_linux_buffer_params_v1_interface,
|
||||
&zwp_linux_dmabuf_feedback_v1_interface,
|
||||
&zwp_linux_dmabuf_feedback_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wl_buffer_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_buffer_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_linux_dmabuf_v1_requests[] = {
|
||||
{ "destroy", "", linux_dmabuf_v1_types + 0 },
|
||||
{ "create_params", "n", linux_dmabuf_v1_types + 6 },
|
||||
{ "get_default_feedback", "4n", linux_dmabuf_v1_types + 7 },
|
||||
{ "get_surface_feedback", "4no", linux_dmabuf_v1_types + 8 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_linux_dmabuf_v1_events[] = {
|
||||
{ "format", "u", linux_dmabuf_v1_types + 0 },
|
||||
{ "modifier", "3uuu", linux_dmabuf_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_linux_dmabuf_v1_interface = {
|
||||
"zwp_linux_dmabuf_v1", 6,
|
||||
4, zwp_linux_dmabuf_v1_requests,
|
||||
2, zwp_linux_dmabuf_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_linux_buffer_params_v1_requests[] = {
|
||||
{ "destroy", "", linux_dmabuf_v1_types + 0 },
|
||||
{ "add", "huuuuu", linux_dmabuf_v1_types + 0 },
|
||||
{ "create", "iiuu", linux_dmabuf_v1_types + 0 },
|
||||
{ "create_immed", "2niiuu", linux_dmabuf_v1_types + 10 },
|
||||
{ "set_sampling_device", "6a", linux_dmabuf_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_linux_buffer_params_v1_events[] = {
|
||||
{ "created", "n", linux_dmabuf_v1_types + 15 },
|
||||
{ "failed", "", linux_dmabuf_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_linux_buffer_params_v1_interface = {
|
||||
"zwp_linux_buffer_params_v1", 6,
|
||||
5, zwp_linux_buffer_params_v1_requests,
|
||||
2, zwp_linux_buffer_params_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_linux_dmabuf_feedback_v1_requests[] = {
|
||||
{ "destroy", "", linux_dmabuf_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_linux_dmabuf_feedback_v1_events[] = {
|
||||
{ "done", "", linux_dmabuf_v1_types + 0 },
|
||||
{ "format_table", "hu", linux_dmabuf_v1_types + 0 },
|
||||
{ "main_device", "a", linux_dmabuf_v1_types + 0 },
|
||||
{ "tranche_done", "", linux_dmabuf_v1_types + 0 },
|
||||
{ "tranche_target_device", "a", linux_dmabuf_v1_types + 0 },
|
||||
{ "tranche_formats", "a", linux_dmabuf_v1_types + 0 },
|
||||
{ "tranche_flags", "u", linux_dmabuf_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_linux_dmabuf_feedback_v1_interface = {
|
||||
"zwp_linux_dmabuf_feedback_v1", 6,
|
||||
1, zwp_linux_dmabuf_feedback_v1_requests,
|
||||
7, zwp_linux_dmabuf_feedback_v1_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,996 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef LINUX_DMABUF_V1_SERVER_PROTOCOL_H
|
||||
#define LINUX_DMABUF_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_linux_dmabuf_v1 The linux_dmabuf_v1 protocol
|
||||
* @section page_ifaces_linux_dmabuf_v1 Interfaces
|
||||
* - @subpage page_iface_zwp_linux_dmabuf_v1 - factory for creating dmabuf-based wl_buffers
|
||||
* - @subpage page_iface_zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based wl_buffer
|
||||
* - @subpage page_iface_zwp_linux_dmabuf_feedback_v1 - dmabuf feedback
|
||||
* @section page_copyright_linux_dmabuf_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2014, 2015 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_buffer;
|
||||
struct wl_surface;
|
||||
struct zwp_linux_buffer_params_v1;
|
||||
struct zwp_linux_dmabuf_feedback_v1;
|
||||
struct zwp_linux_dmabuf_v1;
|
||||
|
||||
#ifndef ZWP_LINUX_DMABUF_V1_INTERFACE
|
||||
#define ZWP_LINUX_DMABUF_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_linux_dmabuf_v1 zwp_linux_dmabuf_v1
|
||||
* @section page_iface_zwp_linux_dmabuf_v1_desc Description
|
||||
*
|
||||
* This interface offers ways to create generic dmabuf-based wl_buffers.
|
||||
*
|
||||
* For more information about dmabuf, see:
|
||||
* https://www.kernel.org/doc/html/next/userspace-api/dma-buf-alloc-exchange.html
|
||||
*
|
||||
* Clients can use the get_surface_feedback request to get dmabuf feedback
|
||||
* for a particular surface. If the client wants to retrieve feedback not
|
||||
* tied to a surface, they can use the get_default_feedback request.
|
||||
*
|
||||
* The following are required from clients:
|
||||
*
|
||||
* - Clients must ensure that either all data in the dma-buf is
|
||||
* coherent for all subsequent read access or that coherency is
|
||||
* correctly handled by the underlying kernel-side dma-buf
|
||||
* implementation.
|
||||
*
|
||||
* - Don't make any more attachments after sending the buffer to the
|
||||
* compositor. Making more attachments later increases the risk of
|
||||
* the compositor not being able to use (re-import) an existing
|
||||
* dmabuf-based wl_buffer.
|
||||
*
|
||||
* The underlying graphics stack must ensure the following:
|
||||
*
|
||||
* - The dmabuf file descriptors relayed to the server will stay valid
|
||||
* for the whole lifetime of the wl_buffer. This means the server may
|
||||
* at any time use those fds to import the dmabuf into any kernel
|
||||
* sub-system that might accept it.
|
||||
*
|
||||
* However, when the underlying graphics stack fails to deliver the
|
||||
* promise, because of e.g. a device hot-unplug which raises internal
|
||||
* errors, after the wl_buffer has been successfully created the
|
||||
* compositor must not raise protocol errors to the client when dmabuf
|
||||
* import later fails.
|
||||
*
|
||||
* To create a wl_buffer from one or more dmabufs, a client creates a
|
||||
* zwp_linux_buffer_params_v1 object with a zwp_linux_dmabuf_v1.create_params
|
||||
* request. All planes required by the intended format are added with
|
||||
* the 'add' request. Finally, a 'create' or 'create_immed' request is
|
||||
* issued, which has the following outcome depending on the import success.
|
||||
*
|
||||
* The 'create' request,
|
||||
* - on success, triggers a 'created' event which provides the final
|
||||
* wl_buffer to the client.
|
||||
* - on failure, triggers a 'failed' event to convey that the server
|
||||
* cannot use the dmabufs received from the client.
|
||||
*
|
||||
* For the 'create_immed' request,
|
||||
* - on success, the server immediately imports the added dmabufs to
|
||||
* create a wl_buffer. No event is sent from the server in this case.
|
||||
* - on failure, the server can choose to either:
|
||||
* - terminate the client by raising a fatal error.
|
||||
* - mark the wl_buffer as failed, and send a 'failed' event to the
|
||||
* client. If the client uses a failed wl_buffer as an argument to any
|
||||
* request, the behaviour is compositor implementation-defined.
|
||||
*
|
||||
* For all DRM formats and unless specified in another protocol extension,
|
||||
* pre-multiplied alpha is used for pixel values.
|
||||
*
|
||||
* Unless specified otherwise in another protocol extension, implicit
|
||||
* synchronization is used. In other words, compositors and clients must
|
||||
* wait and signal fences implicitly passed via the DMA-BUF's reservation
|
||||
* mechanism.
|
||||
* @section page_iface_zwp_linux_dmabuf_v1_api API
|
||||
* See @ref iface_zwp_linux_dmabuf_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_linux_dmabuf_v1 The zwp_linux_dmabuf_v1 interface
|
||||
*
|
||||
* This interface offers ways to create generic dmabuf-based wl_buffers.
|
||||
*
|
||||
* For more information about dmabuf, see:
|
||||
* https://www.kernel.org/doc/html/next/userspace-api/dma-buf-alloc-exchange.html
|
||||
*
|
||||
* Clients can use the get_surface_feedback request to get dmabuf feedback
|
||||
* for a particular surface. If the client wants to retrieve feedback not
|
||||
* tied to a surface, they can use the get_default_feedback request.
|
||||
*
|
||||
* The following are required from clients:
|
||||
*
|
||||
* - Clients must ensure that either all data in the dma-buf is
|
||||
* coherent for all subsequent read access or that coherency is
|
||||
* correctly handled by the underlying kernel-side dma-buf
|
||||
* implementation.
|
||||
*
|
||||
* - Don't make any more attachments after sending the buffer to the
|
||||
* compositor. Making more attachments later increases the risk of
|
||||
* the compositor not being able to use (re-import) an existing
|
||||
* dmabuf-based wl_buffer.
|
||||
*
|
||||
* The underlying graphics stack must ensure the following:
|
||||
*
|
||||
* - The dmabuf file descriptors relayed to the server will stay valid
|
||||
* for the whole lifetime of the wl_buffer. This means the server may
|
||||
* at any time use those fds to import the dmabuf into any kernel
|
||||
* sub-system that might accept it.
|
||||
*
|
||||
* However, when the underlying graphics stack fails to deliver the
|
||||
* promise, because of e.g. a device hot-unplug which raises internal
|
||||
* errors, after the wl_buffer has been successfully created the
|
||||
* compositor must not raise protocol errors to the client when dmabuf
|
||||
* import later fails.
|
||||
*
|
||||
* To create a wl_buffer from one or more dmabufs, a client creates a
|
||||
* zwp_linux_buffer_params_v1 object with a zwp_linux_dmabuf_v1.create_params
|
||||
* request. All planes required by the intended format are added with
|
||||
* the 'add' request. Finally, a 'create' or 'create_immed' request is
|
||||
* issued, which has the following outcome depending on the import success.
|
||||
*
|
||||
* The 'create' request,
|
||||
* - on success, triggers a 'created' event which provides the final
|
||||
* wl_buffer to the client.
|
||||
* - on failure, triggers a 'failed' event to convey that the server
|
||||
* cannot use the dmabufs received from the client.
|
||||
*
|
||||
* For the 'create_immed' request,
|
||||
* - on success, the server immediately imports the added dmabufs to
|
||||
* create a wl_buffer. No event is sent from the server in this case.
|
||||
* - on failure, the server can choose to either:
|
||||
* - terminate the client by raising a fatal error.
|
||||
* - mark the wl_buffer as failed, and send a 'failed' event to the
|
||||
* client. If the client uses a failed wl_buffer as an argument to any
|
||||
* request, the behaviour is compositor implementation-defined.
|
||||
*
|
||||
* For all DRM formats and unless specified in another protocol extension,
|
||||
* pre-multiplied alpha is used for pixel values.
|
||||
*
|
||||
* Unless specified otherwise in another protocol extension, implicit
|
||||
* synchronization is used. In other words, compositors and clients must
|
||||
* wait and signal fences implicitly passed via the DMA-BUF's reservation
|
||||
* mechanism.
|
||||
*/
|
||||
extern const struct wl_interface zwp_linux_dmabuf_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWP_LINUX_BUFFER_PARAMS_V1_INTERFACE
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_linux_buffer_params_v1 zwp_linux_buffer_params_v1
|
||||
* @section page_iface_zwp_linux_buffer_params_v1_desc Description
|
||||
*
|
||||
* This temporary object is a collection of dmabufs and other
|
||||
* parameters that together form a single logical buffer. The temporary
|
||||
* object may eventually create one wl_buffer unless cancelled by
|
||||
* destroying it before requesting 'create'.
|
||||
*
|
||||
* Single-planar formats only require one dmabuf, however
|
||||
* multi-planar formats may require more than one dmabuf. For all
|
||||
* formats, an 'add' request must be called once per plane (even if the
|
||||
* underlying dmabuf fd is identical).
|
||||
*
|
||||
* You must use consecutive plane indices ('plane_idx' argument for 'add')
|
||||
* from zero to the number of planes used by the drm_fourcc format code.
|
||||
* All planes required by the format must be given exactly once, but can
|
||||
* be given in any order. Each plane index can only be set once; subsequent
|
||||
* calls with a plane index which has already been set will result in a
|
||||
* plane_set error being generated.
|
||||
* @section page_iface_zwp_linux_buffer_params_v1_api API
|
||||
* See @ref iface_zwp_linux_buffer_params_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_linux_buffer_params_v1 The zwp_linux_buffer_params_v1 interface
|
||||
*
|
||||
* This temporary object is a collection of dmabufs and other
|
||||
* parameters that together form a single logical buffer. The temporary
|
||||
* object may eventually create one wl_buffer unless cancelled by
|
||||
* destroying it before requesting 'create'.
|
||||
*
|
||||
* Single-planar formats only require one dmabuf, however
|
||||
* multi-planar formats may require more than one dmabuf. For all
|
||||
* formats, an 'add' request must be called once per plane (even if the
|
||||
* underlying dmabuf fd is identical).
|
||||
*
|
||||
* You must use consecutive plane indices ('plane_idx' argument for 'add')
|
||||
* from zero to the number of planes used by the drm_fourcc format code.
|
||||
* All planes required by the format must be given exactly once, but can
|
||||
* be given in any order. Each plane index can only be set once; subsequent
|
||||
* calls with a plane index which has already been set will result in a
|
||||
* plane_set error being generated.
|
||||
*/
|
||||
extern const struct wl_interface zwp_linux_buffer_params_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWP_LINUX_DMABUF_FEEDBACK_V1_INTERFACE
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_linux_dmabuf_feedback_v1 zwp_linux_dmabuf_feedback_v1
|
||||
* @section page_iface_zwp_linux_dmabuf_feedback_v1_desc Description
|
||||
*
|
||||
* This object advertises dmabuf parameters feedback. This includes the
|
||||
* preferred devices and the supported formats/modifiers.
|
||||
*
|
||||
* The parameters are sent once when this object is created and whenever they
|
||||
* change. The done event is always sent once after all parameters have been
|
||||
* sent. When a single parameter changes, all parameters are re-sent by the
|
||||
* compositor.
|
||||
*
|
||||
* Compositors can re-send the parameters when the current client buffer
|
||||
* allocations are sub-optimal. Compositors should not re-send the
|
||||
* parameters if re-allocating the buffers would not result in a more optimal
|
||||
* configuration. In particular, compositors should avoid sending the exact
|
||||
* same parameters multiple times in a row.
|
||||
*
|
||||
* The tranche_target_device and tranche_formats events are grouped by
|
||||
* tranches of preference. For each tranche, a tranche_target_device, one
|
||||
* tranche_flags and one or more tranche_formats events are sent, followed
|
||||
* by a tranche_done event finishing the list. The tranches are sent in
|
||||
* descending order of preference. All formats and modifiers in the same
|
||||
* tranche have the same preference.
|
||||
*
|
||||
* To send parameters, the compositor sends one main_device event (unless
|
||||
* the client bound version 6 or above), tranches (each consisting of one
|
||||
* tranche_target_device event, one tranche_flags event, tranche_formats
|
||||
* events and then a tranche_done event), then one done event.
|
||||
*
|
||||
* With version 6 and above, the compositor must always advertise at least
|
||||
* one tranche with the sampling flag set.
|
||||
*
|
||||
* The compositor sends a format_table event at least once for each dmabuf
|
||||
* parameters feedback object, before any tranche events. Unless the format
|
||||
* table contents change later, the compositor is free not to send another
|
||||
* format_table event for the same dmabuf parameters feedback object.
|
||||
* @section page_iface_zwp_linux_dmabuf_feedback_v1_api API
|
||||
* See @ref iface_zwp_linux_dmabuf_feedback_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_linux_dmabuf_feedback_v1 The zwp_linux_dmabuf_feedback_v1 interface
|
||||
*
|
||||
* This object advertises dmabuf parameters feedback. This includes the
|
||||
* preferred devices and the supported formats/modifiers.
|
||||
*
|
||||
* The parameters are sent once when this object is created and whenever they
|
||||
* change. The done event is always sent once after all parameters have been
|
||||
* sent. When a single parameter changes, all parameters are re-sent by the
|
||||
* compositor.
|
||||
*
|
||||
* Compositors can re-send the parameters when the current client buffer
|
||||
* allocations are sub-optimal. Compositors should not re-send the
|
||||
* parameters if re-allocating the buffers would not result in a more optimal
|
||||
* configuration. In particular, compositors should avoid sending the exact
|
||||
* same parameters multiple times in a row.
|
||||
*
|
||||
* The tranche_target_device and tranche_formats events are grouped by
|
||||
* tranches of preference. For each tranche, a tranche_target_device, one
|
||||
* tranche_flags and one or more tranche_formats events are sent, followed
|
||||
* by a tranche_done event finishing the list. The tranches are sent in
|
||||
* descending order of preference. All formats and modifiers in the same
|
||||
* tranche have the same preference.
|
||||
*
|
||||
* To send parameters, the compositor sends one main_device event (unless
|
||||
* the client bound version 6 or above), tranches (each consisting of one
|
||||
* tranche_target_device event, one tranche_flags event, tranche_formats
|
||||
* events and then a tranche_done event), then one done event.
|
||||
*
|
||||
* With version 6 and above, the compositor must always advertise at least
|
||||
* one tranche with the sampling flag set.
|
||||
*
|
||||
* The compositor sends a format_table event at least once for each dmabuf
|
||||
* parameters feedback object, before any tranche events. Unless the format
|
||||
* table contents change later, the compositor is free not to send another
|
||||
* format_table event for the same dmabuf parameters feedback object.
|
||||
*/
|
||||
extern const struct wl_interface zwp_linux_dmabuf_feedback_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
* @struct zwp_linux_dmabuf_v1_interface
|
||||
*/
|
||||
struct zwp_linux_dmabuf_v1_interface {
|
||||
/**
|
||||
* unbind the factory
|
||||
*
|
||||
* Objects created through this interface, especially wl_buffers,
|
||||
* will remain valid.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* create a temporary object for buffer parameters
|
||||
*
|
||||
* This temporary object is used to collect multiple dmabuf
|
||||
* handles into a single batch to create a wl_buffer. It can only
|
||||
* be used once and should be destroyed after a 'created' or
|
||||
* 'failed' event has been received.
|
||||
* @param params_id id for the newly created zwp_linux_buffer_params_v1
|
||||
*/
|
||||
void (*create_params)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t params_id);
|
||||
/**
|
||||
* get default feedback
|
||||
*
|
||||
* This request creates a new zwp_linux_dmabuf_feedback_v1 object
|
||||
* not bound to a particular surface. This object will deliver
|
||||
* feedback about dmabuf parameters to use if the client doesn't
|
||||
* support per-surface feedback (see get_surface_feedback).
|
||||
* @since 4
|
||||
*/
|
||||
void (*get_default_feedback)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id);
|
||||
/**
|
||||
* get feedback for a surface
|
||||
*
|
||||
* This request creates a new zwp_linux_dmabuf_feedback_v1 object
|
||||
* for the specified wl_surface. This object will deliver feedback
|
||||
* about dmabuf parameters to use for buffers attached to this
|
||||
* surface.
|
||||
*
|
||||
* If the surface is destroyed before the
|
||||
* zwp_linux_dmabuf_feedback_v1 object, the feedback object becomes
|
||||
* inert.
|
||||
* @since 4
|
||||
*/
|
||||
void (*get_surface_feedback)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
struct wl_resource *surface);
|
||||
};
|
||||
|
||||
#define ZWP_LINUX_DMABUF_V1_FORMAT 0
|
||||
#define ZWP_LINUX_DMABUF_V1_MODIFIER 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_V1_FORMAT_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION 3
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION 4
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_V1_GET_SURFACE_FEEDBACK_SINCE_VERSION 4
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
* Sends an format event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param format DRM_FORMAT code
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_v1_send_format(struct wl_resource *resource_, uint32_t format)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_V1_FORMAT, format);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_v1
|
||||
* Sends an modifier event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param format DRM_FORMAT code
|
||||
* @param modifier_hi high 32 bits of layout modifier
|
||||
* @param modifier_lo low 32 bits of layout modifier
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_v1_send_modifier(struct wl_resource *resource_, uint32_t format, uint32_t modifier_hi, uint32_t modifier_lo)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_V1_MODIFIER, format, modifier_hi, modifier_lo);
|
||||
}
|
||||
|
||||
#ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
|
||||
enum zwp_linux_buffer_params_v1_error {
|
||||
/**
|
||||
* the zwp_linux_buffer_params_v1 object has already been used to create a wl_buffer
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0,
|
||||
/**
|
||||
* plane index out of bounds
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1,
|
||||
/**
|
||||
* the plane index was already set
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2,
|
||||
/**
|
||||
* missing or too many planes to create a buffer
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3,
|
||||
/**
|
||||
* format not supported
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4,
|
||||
/**
|
||||
* invalid width or height
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5,
|
||||
/**
|
||||
* offset + stride * height goes out of dmabuf bounds
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6,
|
||||
/**
|
||||
* invalid wl_buffer resulted from importing dmabufs via the create_immed request on given buffer_params
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_WL_BUFFER = 7,
|
||||
/**
|
||||
* an array with mismatching size for a dev_t was used
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DEV_T_SIZE = 8,
|
||||
};
|
||||
#endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM_IS_VALID
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
* Validate a zwp_linux_buffer_params_v1 error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwp_linux_buffer_params_v1_error
|
||||
*/
|
||||
static inline bool
|
||||
zwp_linux_buffer_params_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_WL_BUFFER:
|
||||
return version >= 1;
|
||||
case ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DEV_T_SIZE:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM_IS_VALID */
|
||||
|
||||
#ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
|
||||
enum zwp_linux_buffer_params_v1_flags {
|
||||
/**
|
||||
* contents are y-inverted
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1,
|
||||
/**
|
||||
* content is interlaced
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2,
|
||||
/**
|
||||
* bottom field first
|
||||
*/
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4,
|
||||
};
|
||||
#endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */
|
||||
|
||||
#ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM_IS_VALID
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
* Validate a zwp_linux_buffer_params_v1 flags value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwp_linux_buffer_params_v1_flags
|
||||
*/
|
||||
static inline bool
|
||||
zwp_linux_buffer_params_v1_flags_is_valid(uint32_t value, uint32_t version) {
|
||||
uint32_t valid = 0;
|
||||
if (version >= 1)
|
||||
valid |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT;
|
||||
if (version >= 1)
|
||||
valid |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED;
|
||||
if (version >= 1)
|
||||
valid |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST;
|
||||
return (value & ~valid) == 0;
|
||||
}
|
||||
#endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
* @struct zwp_linux_buffer_params_v1_interface
|
||||
*/
|
||||
struct zwp_linux_buffer_params_v1_interface {
|
||||
/**
|
||||
* delete this object, used or not
|
||||
*
|
||||
* Cleans up the temporary data sent to the server for
|
||||
* dmabuf-based wl_buffer creation.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* add a dmabuf to the temporary set
|
||||
*
|
||||
* This request adds one dmabuf to the set in this
|
||||
* zwp_linux_buffer_params_v1.
|
||||
*
|
||||
* The 64-bit unsigned value combined from modifier_hi and
|
||||
* modifier_lo is the dmabuf layout modifier. DRM AddFB2 ioctl
|
||||
* calls this the fb modifier, which is defined in drm_mode.h of
|
||||
* Linux UAPI. This is an opaque token. Drivers use this token to
|
||||
* express tiling, compression, etc. driver-specific modifications
|
||||
* to the base format defined by the DRM fourcc code.
|
||||
*
|
||||
* Starting from version 4, the invalid_format protocol error is
|
||||
* sent if the format + modifier pair was not advertised as
|
||||
* supported.
|
||||
*
|
||||
* Starting from version 5, the invalid_format protocol error is
|
||||
* sent if all planes don't use the same modifier.
|
||||
*
|
||||
* This request raises the PLANE_IDX error if plane_idx is too
|
||||
* large. The error PLANE_SET is raised if attempting to set a
|
||||
* plane that was already set.
|
||||
* @param fd dmabuf fd
|
||||
* @param plane_idx plane index
|
||||
* @param offset offset in bytes
|
||||
* @param stride stride in bytes
|
||||
* @param modifier_hi high 32 bits of layout modifier
|
||||
* @param modifier_lo low 32 bits of layout modifier
|
||||
*/
|
||||
void (*add)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int32_t fd,
|
||||
uint32_t plane_idx,
|
||||
uint32_t offset,
|
||||
uint32_t stride,
|
||||
uint32_t modifier_hi,
|
||||
uint32_t modifier_lo);
|
||||
/**
|
||||
* create a wl_buffer from the given dmabufs
|
||||
*
|
||||
* This asks for creation of a wl_buffer from the added dmabuf
|
||||
* buffers. The wl_buffer is not created immediately but returned
|
||||
* via the 'created' event if the dmabuf sharing succeeds. The
|
||||
* sharing may fail at runtime for reasons a client cannot predict,
|
||||
* in which case the 'failed' event is triggered.
|
||||
*
|
||||
* The 'format' argument is a DRM_FORMAT code, as defined by the
|
||||
* libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the
|
||||
* authoritative source on how the format codes should work.
|
||||
*
|
||||
* The 'flags' is a bitfield of the flags defined in enum "flags".
|
||||
* 'y_invert' means that the image needs to be y-flipped.
|
||||
*
|
||||
* Flag 'interlaced' means that the frame in the buffer is not
|
||||
* progressive as usual, but interlaced. An interlaced buffer as
|
||||
* supported here must always contain both top and bottom fields.
|
||||
* The top field always begins on the first pixel row. The temporal
|
||||
* ordering between the two fields is top field first, unless
|
||||
* 'bottom_first' is specified. It is undefined whether
|
||||
* 'bottom_first' is ignored if 'interlaced' is not set.
|
||||
*
|
||||
* This protocol does not convey any information about field rate,
|
||||
* duration, or timing, other than the relative ordering between
|
||||
* the two fields in one buffer. A compositor may have to estimate
|
||||
* the intended field rate from the incoming buffer rate. It is
|
||||
* undefined whether the time of receiving wl_surface.commit with a
|
||||
* new buffer attached, applying the wl_surface state,
|
||||
* wl_surface.frame callback trigger, presentation, or any other
|
||||
* point in the compositor cycle is used to measure the frame or
|
||||
* field times. There is no support for detecting missed or late
|
||||
* frames/fields/buffers either, and there is no support whatsoever
|
||||
* for cooperating with interlaced compositor output.
|
||||
*
|
||||
* The composited image quality resulting from the use of
|
||||
* interlaced buffers is explicitly undefined. A compositor may use
|
||||
* elaborate hardware features or software to deinterlace and
|
||||
* create progressive output frames from a sequence of interlaced
|
||||
* input buffers, or it may produce substandard image quality.
|
||||
* However, compositors that cannot guarantee reasonable image
|
||||
* quality in all cases are recommended to just reject all
|
||||
* interlaced buffers.
|
||||
*
|
||||
* Any argument errors, including non-positive width or height,
|
||||
* mismatch between the number of planes and the format, bad
|
||||
* format, bad offset or stride, may be indicated by fatal protocol
|
||||
* errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS,
|
||||
* OUT_OF_BOUNDS.
|
||||
*
|
||||
* Dmabuf import errors in the server that are not obvious client
|
||||
* bugs are returned via the 'failed' event as non-fatal. This
|
||||
* allows attempting dmabuf sharing and falling back in the client
|
||||
* if it fails.
|
||||
*
|
||||
* This request can be sent only once in the object's lifetime,
|
||||
* after which the only legal request is destroy. This object
|
||||
* should be destroyed after issuing a 'create' request. Attempting
|
||||
* to use this object after issuing 'create' raises the
|
||||
* ALREADY_USED protocol error.
|
||||
*
|
||||
* It is not mandatory to issue 'create'. If a client wants to
|
||||
* cancel the buffer creation, it can just destroy this object.
|
||||
* @param width base plane width in pixels
|
||||
* @param height base plane height in pixels
|
||||
* @param format DRM_FORMAT code
|
||||
* @param flags see enum flags
|
||||
*/
|
||||
void (*create)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
uint32_t format,
|
||||
uint32_t flags);
|
||||
/**
|
||||
* immediately create a wl_buffer from the given dmabufs
|
||||
*
|
||||
* This asks for immediate creation of a wl_buffer by importing
|
||||
* the added dmabufs.
|
||||
*
|
||||
* In case of import success, no event is sent from the server, and
|
||||
* the wl_buffer is ready to be used by the client.
|
||||
*
|
||||
* Upon import failure, either of the following may happen, as seen
|
||||
* fit by the implementation: - the client is terminated with one
|
||||
* of the following fatal protocol errors: - INCOMPLETE,
|
||||
* INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS, in case of
|
||||
* argument errors such as mismatch between the number of planes
|
||||
* and the format, bad format, non-positive width or height, or bad
|
||||
* offset or stride. - INVALID_WL_BUFFER, in case the cause for
|
||||
* failure is unknown or platform specific. - the server creates an
|
||||
* invalid wl_buffer, marks it as failed and sends a 'failed' event
|
||||
* to the client. The result of using this invalid wl_buffer as an
|
||||
* argument in any request by the client is defined by the
|
||||
* compositor implementation.
|
||||
*
|
||||
* This takes the same arguments as a 'create' request, and obeys
|
||||
* the same restrictions.
|
||||
* @param buffer_id id for the newly created wl_buffer
|
||||
* @param width base plane width in pixels
|
||||
* @param height base plane height in pixels
|
||||
* @param format DRM_FORMAT code
|
||||
* @param flags see enum flags
|
||||
* @since 2
|
||||
*/
|
||||
void (*create_immed)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t buffer_id,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
uint32_t format,
|
||||
uint32_t flags);
|
||||
/**
|
||||
* set the target device of the wl_buffer
|
||||
*
|
||||
* Set the device the compositor should import the dmabufs to for
|
||||
* sampling in the next create or create_immed request.
|
||||
*
|
||||
* To avoid race conditions when the compositor removes a device
|
||||
* from the tranches, it is not a protocol error if the device
|
||||
* hasn't been advertised by the compositor in a tranche with the
|
||||
* sampling flag, but the import is likely to fail in that case.
|
||||
*
|
||||
* If the client doesn't know a suitable target device, it
|
||||
* shouldn't set one, and the compositor should attempt import on
|
||||
* all devices it supports.
|
||||
*
|
||||
* If the array is too small to contain a dev_t or larger than
|
||||
* required, the invalid_dev_t_size error will be emitted.
|
||||
* @param device device dev_t value
|
||||
* @since 6
|
||||
*/
|
||||
void (*set_sampling_device)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_array *device);
|
||||
};
|
||||
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED 0
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_ADD_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_IMMED_SINCE_VERSION 2
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
*/
|
||||
#define ZWP_LINUX_BUFFER_PARAMS_V1_SET_SAMPLING_DEVICE_SINCE_VERSION 6
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
* Sends an created event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param buffer id for the the newly created wl_buffer
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_buffer_params_v1_send_created(struct wl_resource *resource_, struct wl_resource *buffer)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_BUFFER_PARAMS_V1_CREATED, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_buffer_params_v1
|
||||
* Sends an failed event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_buffer_params_v1_send_failed(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_BUFFER_PARAMS_V1_FAILED);
|
||||
}
|
||||
|
||||
#ifndef ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM
|
||||
enum zwp_linux_dmabuf_feedback_v1_tranche_flags {
|
||||
/**
|
||||
* direct scan-out tranche
|
||||
*
|
||||
* The scanout flag is a hint that direct scan-out may be
|
||||
* attempted by the compositor on the target device if the client
|
||||
* appropriately allocates a buffer. How to allocate a buffer that
|
||||
* can be scanned out on the target device is
|
||||
* implementation-defined.
|
||||
* @since 4
|
||||
*/
|
||||
ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT = 1,
|
||||
/**
|
||||
* sampling tranche
|
||||
*
|
||||
* The sampling flag describes that the compositor is able to
|
||||
* efficiently sample from buffers imported to the target device if
|
||||
* the client appropriately allocates a buffer. How to allocate a
|
||||
* buffer that can be efficiently sampled on the target device is
|
||||
* implementation defined.
|
||||
* @since 6
|
||||
*/
|
||||
ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SAMPLING = 2,
|
||||
};
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT_SINCE_VERSION 4
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SAMPLING_SINCE_VERSION 6
|
||||
#endif /* ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM */
|
||||
|
||||
#ifndef ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM_IS_VALID
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Validate a zwp_linux_dmabuf_feedback_v1 tranche_flags value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwp_linux_dmabuf_feedback_v1_tranche_flags
|
||||
*/
|
||||
static inline bool
|
||||
zwp_linux_dmabuf_feedback_v1_tranche_flags_is_valid(uint32_t value, uint32_t version) {
|
||||
uint32_t valid = 0;
|
||||
if (version >= 4)
|
||||
valid |= ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT;
|
||||
if (version >= 6)
|
||||
valid |= ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SAMPLING;
|
||||
return (value & ~valid) == 0;
|
||||
}
|
||||
#endif /* ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* @struct zwp_linux_dmabuf_feedback_v1_interface
|
||||
*/
|
||||
struct zwp_linux_dmabuf_feedback_v1_interface {
|
||||
/**
|
||||
* destroy the feedback object
|
||||
*
|
||||
* Using this request a client can tell the server that it is not
|
||||
* going to use the zwp_linux_dmabuf_feedback_v1 object anymore.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_DONE 0
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_FORMAT_TABLE 1
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_MAIN_DEVICE 2
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_DONE 3
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_TARGET_DEVICE 4
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FORMATS 5
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS 6
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_DONE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_FORMAT_TABLE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_MAIN_DEVICE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_DONE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_TARGET_DEVICE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FORMATS_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
*/
|
||||
#define ZWP_LINUX_DMABUF_FEEDBACK_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an done event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_done(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_DONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an format_table event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param fd table file descriptor
|
||||
* @param size table size, in bytes
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_format_table(struct wl_resource *resource_, int32_t fd, uint32_t size)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_FORMAT_TABLE, fd, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an main_device event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param device device dev_t value
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_main_device(struct wl_resource *resource_, struct wl_array *device)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_MAIN_DEVICE, device);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an tranche_done event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_tranche_done(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_DONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an tranche_target_device event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param device device dev_t value
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_tranche_target_device(struct wl_resource *resource_, struct wl_array *device)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_TARGET_DEVICE, device);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an tranche_formats event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param indices array of 16-bit indexes
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_tranche_formats(struct wl_resource *resource_, struct wl_array *indices)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FORMATS, indices);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_linux_dmabuf_feedback_v1
|
||||
* Sends an tranche_flags event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param flags tranche flags
|
||||
*/
|
||||
static inline void
|
||||
zwp_linux_dmabuf_feedback_v1_send_tranche_flags(struct wl_resource *resource_, uint32_t flags)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS, flags);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2014 Jonas Ådahl
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_pointer_interface;
|
||||
extern const struct wl_interface wl_region_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface zwp_confined_pointer_v1_interface;
|
||||
extern const struct wl_interface zwp_locked_pointer_v1_interface;
|
||||
|
||||
static const struct wl_interface *pointer_constraints_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_locked_pointer_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wl_pointer_interface,
|
||||
&wl_region_interface,
|
||||
NULL,
|
||||
&zwp_confined_pointer_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wl_pointer_interface,
|
||||
&wl_region_interface,
|
||||
NULL,
|
||||
&wl_region_interface,
|
||||
&wl_region_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_pointer_constraints_v1_requests[] = {
|
||||
{ "destroy", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "lock_pointer", "noo?ou", pointer_constraints_unstable_v1_types + 2 },
|
||||
{ "confine_pointer", "noo?ou", pointer_constraints_unstable_v1_types + 7 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_pointer_constraints_v1_interface = {
|
||||
"zwp_pointer_constraints_v1", 1,
|
||||
3, zwp_pointer_constraints_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_locked_pointer_v1_requests[] = {
|
||||
{ "destroy", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "set_cursor_position_hint", "ff", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "set_region", "?o", pointer_constraints_unstable_v1_types + 12 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_locked_pointer_v1_events[] = {
|
||||
{ "locked", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "unlocked", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_locked_pointer_v1_interface = {
|
||||
"zwp_locked_pointer_v1", 1,
|
||||
3, zwp_locked_pointer_v1_requests,
|
||||
2, zwp_locked_pointer_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_confined_pointer_v1_requests[] = {
|
||||
{ "destroy", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "set_region", "?o", pointer_constraints_unstable_v1_types + 13 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_confined_pointer_v1_events[] = {
|
||||
{ "confined", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "unconfined", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_confined_pointer_v1_interface = {
|
||||
"zwp_confined_pointer_v1", 1,
|
||||
2, zwp_confined_pointer_v1_requests,
|
||||
2, zwp_confined_pointer_v1_events,
|
||||
};
|
||||
|
||||
+619
@@ -0,0 +1,619 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef POINTER_CONSTRAINTS_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
#define POINTER_CONSTRAINTS_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_pointer_constraints_unstable_v1 The pointer_constraints_unstable_v1 protocol
|
||||
* protocol for constraining pointer motions
|
||||
*
|
||||
* @section page_desc_pointer_constraints_unstable_v1 Description
|
||||
*
|
||||
* This protocol specifies a set of interfaces used for adding constraints to
|
||||
* the motion of a pointer. Possible constraints include confining pointer
|
||||
* motions to a given region, or locking it to its current position.
|
||||
*
|
||||
* In order to constrain the pointer, a client must first bind the global
|
||||
* interface "wp_pointer_constraints" which, if a compositor supports pointer
|
||||
* constraints, is exposed by the registry. Using the bound global object, the
|
||||
* client uses the request that corresponds to the type of constraint it wants
|
||||
* to make. See wp_pointer_constraints for more details.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and backward
|
||||
* incompatible changes may be made. Backward compatible changes may be added
|
||||
* together with the corresponding interface version bump. Backward
|
||||
* incompatible changes are done by bumping the version number in the protocol
|
||||
* and interface names and resetting the interface version. Once the protocol
|
||||
* is to be declared stable, the 'z' prefix and the version number in the
|
||||
* protocol and interface names are removed and the interface version number is
|
||||
* reset.
|
||||
*
|
||||
* @section page_ifaces_pointer_constraints_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zwp_pointer_constraints_v1 - constrain the movement of a pointer
|
||||
* - @subpage page_iface_zwp_locked_pointer_v1 - receive relative pointer motion events
|
||||
* - @subpage page_iface_zwp_confined_pointer_v1 - confined pointer object
|
||||
* @section page_copyright_pointer_constraints_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2014 Jonas Ådahl
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_pointer;
|
||||
struct wl_region;
|
||||
struct wl_surface;
|
||||
struct zwp_confined_pointer_v1;
|
||||
struct zwp_locked_pointer_v1;
|
||||
struct zwp_pointer_constraints_v1;
|
||||
|
||||
#ifndef ZWP_POINTER_CONSTRAINTS_V1_INTERFACE
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_pointer_constraints_v1 zwp_pointer_constraints_v1
|
||||
* @section page_iface_zwp_pointer_constraints_v1_desc Description
|
||||
*
|
||||
* The global interface exposing pointer constraining functionality. It
|
||||
* exposes two requests: lock_pointer for locking the pointer to its
|
||||
* position, and confine_pointer for locking the pointer to a region.
|
||||
*
|
||||
* The lock_pointer and confine_pointer requests create the objects
|
||||
* wp_locked_pointer and wp_confined_pointer respectively, and the client can
|
||||
* use these objects to interact with the lock.
|
||||
*
|
||||
* For any surface, only one lock or confinement may be active across all
|
||||
* wl_pointer objects of the same seat. If a lock or confinement is requested
|
||||
* when another lock or confinement is active or requested on the same surface
|
||||
* and with any of the wl_pointer objects of the same seat, an
|
||||
* 'already_constrained' error will be raised.
|
||||
* @section page_iface_zwp_pointer_constraints_v1_api API
|
||||
* See @ref iface_zwp_pointer_constraints_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_pointer_constraints_v1 The zwp_pointer_constraints_v1 interface
|
||||
*
|
||||
* The global interface exposing pointer constraining functionality. It
|
||||
* exposes two requests: lock_pointer for locking the pointer to its
|
||||
* position, and confine_pointer for locking the pointer to a region.
|
||||
*
|
||||
* The lock_pointer and confine_pointer requests create the objects
|
||||
* wp_locked_pointer and wp_confined_pointer respectively, and the client can
|
||||
* use these objects to interact with the lock.
|
||||
*
|
||||
* For any surface, only one lock or confinement may be active across all
|
||||
* wl_pointer objects of the same seat. If a lock or confinement is requested
|
||||
* when another lock or confinement is active or requested on the same surface
|
||||
* and with any of the wl_pointer objects of the same seat, an
|
||||
* 'already_constrained' error will be raised.
|
||||
*/
|
||||
extern const struct wl_interface zwp_pointer_constraints_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWP_LOCKED_POINTER_V1_INTERFACE
|
||||
#define ZWP_LOCKED_POINTER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_locked_pointer_v1 zwp_locked_pointer_v1
|
||||
* @section page_iface_zwp_locked_pointer_v1_desc Description
|
||||
*
|
||||
* The wp_locked_pointer interface represents a locked pointer state.
|
||||
*
|
||||
* While the lock of this object is active, the wl_pointer objects of the
|
||||
* associated seat will not emit any wl_pointer.motion events.
|
||||
*
|
||||
* This object will send the event 'locked' when the lock is activated.
|
||||
* Whenever the lock is activated, it is guaranteed that the locked surface
|
||||
* will already have received pointer focus and that the pointer will be
|
||||
* within the region passed to the request creating this object.
|
||||
*
|
||||
* To unlock the pointer, send the destroy request. This will also destroy
|
||||
* the wp_locked_pointer object.
|
||||
*
|
||||
* If the compositor decides to unlock the pointer the unlocked event is
|
||||
* sent. See wp_locked_pointer.unlock for details.
|
||||
*
|
||||
* When unlocking, the compositor may warp the cursor position to the set
|
||||
* cursor position hint. If it does, it will not result in any relative
|
||||
* motion events emitted via wp_relative_pointer.
|
||||
*
|
||||
* If the surface the lock was requested on is destroyed and the lock is not
|
||||
* yet activated, the wp_locked_pointer object is now defunct and must be
|
||||
* destroyed.
|
||||
* @section page_iface_zwp_locked_pointer_v1_api API
|
||||
* See @ref iface_zwp_locked_pointer_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_locked_pointer_v1 The zwp_locked_pointer_v1 interface
|
||||
*
|
||||
* The wp_locked_pointer interface represents a locked pointer state.
|
||||
*
|
||||
* While the lock of this object is active, the wl_pointer objects of the
|
||||
* associated seat will not emit any wl_pointer.motion events.
|
||||
*
|
||||
* This object will send the event 'locked' when the lock is activated.
|
||||
* Whenever the lock is activated, it is guaranteed that the locked surface
|
||||
* will already have received pointer focus and that the pointer will be
|
||||
* within the region passed to the request creating this object.
|
||||
*
|
||||
* To unlock the pointer, send the destroy request. This will also destroy
|
||||
* the wp_locked_pointer object.
|
||||
*
|
||||
* If the compositor decides to unlock the pointer the unlocked event is
|
||||
* sent. See wp_locked_pointer.unlock for details.
|
||||
*
|
||||
* When unlocking, the compositor may warp the cursor position to the set
|
||||
* cursor position hint. If it does, it will not result in any relative
|
||||
* motion events emitted via wp_relative_pointer.
|
||||
*
|
||||
* If the surface the lock was requested on is destroyed and the lock is not
|
||||
* yet activated, the wp_locked_pointer object is now defunct and must be
|
||||
* destroyed.
|
||||
*/
|
||||
extern const struct wl_interface zwp_locked_pointer_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWP_CONFINED_POINTER_V1_INTERFACE
|
||||
#define ZWP_CONFINED_POINTER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_confined_pointer_v1 zwp_confined_pointer_v1
|
||||
* @section page_iface_zwp_confined_pointer_v1_desc Description
|
||||
*
|
||||
* The wp_confined_pointer interface represents a confined pointer state.
|
||||
*
|
||||
* This object will send the event 'confined' when the confinement is
|
||||
* activated. Whenever the confinement is activated, it is guaranteed that
|
||||
* the surface the pointer is confined to will already have received pointer
|
||||
* focus and that the pointer will be within the region passed to the request
|
||||
* creating this object. It is up to the compositor to decide whether this
|
||||
* requires some user interaction and if the pointer will warp to within the
|
||||
* passed region if outside.
|
||||
*
|
||||
* To unconfine the pointer, send the destroy request. This will also destroy
|
||||
* the wp_confined_pointer object.
|
||||
*
|
||||
* If the compositor decides to unconfine the pointer the unconfined event is
|
||||
* sent. The wp_confined_pointer object is at this point defunct and should
|
||||
* be destroyed.
|
||||
* @section page_iface_zwp_confined_pointer_v1_api API
|
||||
* See @ref iface_zwp_confined_pointer_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_confined_pointer_v1 The zwp_confined_pointer_v1 interface
|
||||
*
|
||||
* The wp_confined_pointer interface represents a confined pointer state.
|
||||
*
|
||||
* This object will send the event 'confined' when the confinement is
|
||||
* activated. Whenever the confinement is activated, it is guaranteed that
|
||||
* the surface the pointer is confined to will already have received pointer
|
||||
* focus and that the pointer will be within the region passed to the request
|
||||
* creating this object. It is up to the compositor to decide whether this
|
||||
* requires some user interaction and if the pointer will warp to within the
|
||||
* passed region if outside.
|
||||
*
|
||||
* To unconfine the pointer, send the destroy request. This will also destroy
|
||||
* the wp_confined_pointer object.
|
||||
*
|
||||
* If the compositor decides to unconfine the pointer the unconfined event is
|
||||
* sent. The wp_confined_pointer object is at this point defunct and should
|
||||
* be destroyed.
|
||||
*/
|
||||
extern const struct wl_interface zwp_confined_pointer_v1_interface;
|
||||
#endif
|
||||
|
||||
#ifndef ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
* wp_pointer_constraints error values
|
||||
*
|
||||
* These errors can be emitted in response to wp_pointer_constraints
|
||||
* requests.
|
||||
*/
|
||||
enum zwp_pointer_constraints_v1_error {
|
||||
/**
|
||||
* pointer constraint already requested on that surface
|
||||
*/
|
||||
ZWP_POINTER_CONSTRAINTS_V1_ERROR_ALREADY_CONSTRAINED = 1,
|
||||
};
|
||||
#endif /* ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM_IS_VALID
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
* Validate a zwp_pointer_constraints_v1 error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwp_pointer_constraints_v1_error
|
||||
*/
|
||||
static inline bool
|
||||
zwp_pointer_constraints_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ZWP_POINTER_CONSTRAINTS_V1_ERROR_ALREADY_CONSTRAINED:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM_IS_VALID */
|
||||
|
||||
#ifndef ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
* constraint lifetime
|
||||
*
|
||||
* These values represent different lifetime semantics. They are passed
|
||||
* as arguments to the factory requests to specify how the constraint
|
||||
* lifetimes should be managed.
|
||||
*/
|
||||
enum zwp_pointer_constraints_v1_lifetime {
|
||||
/**
|
||||
* the pointer constraint is defunct once deactivated
|
||||
*
|
||||
* A oneshot pointer constraint will never reactivate once it has
|
||||
* been deactivated. See the corresponding deactivation event
|
||||
* (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined)
|
||||
* for details.
|
||||
*/
|
||||
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT = 1,
|
||||
/**
|
||||
* the pointer constraint may reactivate
|
||||
*
|
||||
* A persistent pointer constraint may again reactivate once it
|
||||
* has been deactivated. See the corresponding deactivation event
|
||||
* (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined)
|
||||
* for details.
|
||||
*/
|
||||
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT = 2,
|
||||
};
|
||||
#endif /* ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM */
|
||||
|
||||
#ifndef ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM_IS_VALID
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
* Validate a zwp_pointer_constraints_v1 lifetime value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwp_pointer_constraints_v1_lifetime
|
||||
*/
|
||||
static inline bool
|
||||
zwp_pointer_constraints_v1_lifetime_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT:
|
||||
return version >= 1;
|
||||
case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
* @struct zwp_pointer_constraints_v1_interface
|
||||
*/
|
||||
struct zwp_pointer_constraints_v1_interface {
|
||||
/**
|
||||
* destroy the pointer constraints manager object
|
||||
*
|
||||
* Used by the client to notify the server that it will no longer
|
||||
* use this pointer constraints object.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* lock pointer to a position
|
||||
*
|
||||
* The lock_pointer request lets the client request to disable
|
||||
* movements of the virtual pointer (i.e. the cursor), effectively
|
||||
* locking the pointer to a position. This request may not take
|
||||
* effect immediately; in the future, when the compositor deems
|
||||
* implementation-specific constraints are satisfied, the pointer
|
||||
* lock will be activated and the compositor sends a locked event.
|
||||
*
|
||||
* The protocol provides no guarantee that the constraints are ever
|
||||
* satisfied, and does not require the compositor to send an error
|
||||
* if the constraints cannot ever be satisfied. It is thus possible
|
||||
* to request a lock that will never activate.
|
||||
*
|
||||
* There may not be another pointer constraint of any kind
|
||||
* requested or active on the surface for any of the wl_pointer
|
||||
* objects of the seat of the passed pointer when requesting a
|
||||
* lock. If there is, an error will be raised. See general pointer
|
||||
* lock documentation for more details.
|
||||
*
|
||||
* The intersection of the region passed with this request and the
|
||||
* input region of the surface is used to determine where the
|
||||
* pointer must be in order for the lock to activate. It is up to
|
||||
* the compositor whether to warp the pointer or require some kind
|
||||
* of user interaction for the lock to activate. If the region is
|
||||
* null the surface input region is used.
|
||||
*
|
||||
* A surface may receive pointer focus without the lock being
|
||||
* activated.
|
||||
*
|
||||
* The request creates a new object wp_locked_pointer which is used
|
||||
* to interact with the lock as well as receive updates about its
|
||||
* state. See the the description of wp_locked_pointer for further
|
||||
* information.
|
||||
*
|
||||
* Note that while a pointer is locked, the wl_pointer objects of
|
||||
* the corresponding seat will not emit any wl_pointer.motion
|
||||
* events, but relative motion events will still be emitted via
|
||||
* wp_relative_pointer objects of the same seat. wl_pointer.axis
|
||||
* and wl_pointer.button events are unaffected.
|
||||
* @param surface surface to lock pointer to
|
||||
* @param pointer the pointer that should be locked
|
||||
* @param region region of surface
|
||||
* @param lifetime lock lifetime
|
||||
*/
|
||||
void (*lock_pointer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
struct wl_resource *surface,
|
||||
struct wl_resource *pointer,
|
||||
struct wl_resource *region,
|
||||
uint32_t lifetime);
|
||||
/**
|
||||
* confine pointer to a region
|
||||
*
|
||||
* The confine_pointer request lets the client request to confine
|
||||
* the pointer cursor to a given region. This request may not take
|
||||
* effect immediately; in the future, when the compositor deems
|
||||
* implementation- specific constraints are satisfied, the pointer
|
||||
* confinement will be activated and the compositor sends a
|
||||
* confined event.
|
||||
*
|
||||
* The intersection of the region passed with this request and the
|
||||
* input region of the surface is used to determine where the
|
||||
* pointer must be in order for the confinement to activate. It is
|
||||
* up to the compositor whether to warp the pointer or require some
|
||||
* kind of user interaction for the confinement to activate. If the
|
||||
* region is null the surface input region is used.
|
||||
*
|
||||
* The request will create a new object wp_confined_pointer which
|
||||
* is used to interact with the confinement as well as receive
|
||||
* updates about its state. See the the description of
|
||||
* wp_confined_pointer for further information.
|
||||
* @param surface surface to lock pointer to
|
||||
* @param pointer the pointer that should be confined
|
||||
* @param region region of surface
|
||||
* @param lifetime confinement lifetime
|
||||
*/
|
||||
void (*confine_pointer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
struct wl_resource *surface,
|
||||
struct wl_resource *pointer,
|
||||
struct wl_resource *region,
|
||||
uint32_t lifetime);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
*/
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
*/
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_LOCK_POINTER_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_pointer_constraints_v1
|
||||
*/
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_CONFINE_POINTER_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
* @struct zwp_locked_pointer_v1_interface
|
||||
*/
|
||||
struct zwp_locked_pointer_v1_interface {
|
||||
/**
|
||||
* destroy the locked pointer object
|
||||
*
|
||||
* Destroy the locked pointer object. If applicable, the
|
||||
* compositor will unlock the pointer.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* set the pointer cursor position hint
|
||||
*
|
||||
* Set the cursor position hint relative to the top left corner
|
||||
* of the surface.
|
||||
*
|
||||
* If the client is drawing its own cursor, it should update the
|
||||
* position hint to the position of its own cursor. A compositor
|
||||
* may use this information to warp the pointer upon unlock in
|
||||
* order to avoid pointer jumps.
|
||||
*
|
||||
* The cursor position hint is double buffered. The new hint will
|
||||
* only take effect when the associated surface gets it pending
|
||||
* state applied. See wl_surface.commit for details.
|
||||
* @param surface_x surface-local x coordinate
|
||||
* @param surface_y surface-local y coordinate
|
||||
*/
|
||||
void (*set_cursor_position_hint)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
wl_fixed_t surface_x,
|
||||
wl_fixed_t surface_y);
|
||||
/**
|
||||
* set a new lock region
|
||||
*
|
||||
* Set a new region used to lock the pointer.
|
||||
*
|
||||
* The new lock region is double-buffered. The new lock region will
|
||||
* only take effect when the associated surface gets its pending
|
||||
* state applied. See wl_surface.commit for details.
|
||||
*
|
||||
* For details about the lock region, see wp_locked_pointer.
|
||||
* @param region region of surface
|
||||
*/
|
||||
void (*set_region)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *region);
|
||||
};
|
||||
|
||||
#define ZWP_LOCKED_POINTER_V1_LOCKED 0
|
||||
#define ZWP_LOCKED_POINTER_V1_UNLOCKED 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
*/
|
||||
#define ZWP_LOCKED_POINTER_V1_LOCKED_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
*/
|
||||
#define ZWP_LOCKED_POINTER_V1_UNLOCKED_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
*/
|
||||
#define ZWP_LOCKED_POINTER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
*/
|
||||
#define ZWP_LOCKED_POINTER_V1_SET_CURSOR_POSITION_HINT_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
*/
|
||||
#define ZWP_LOCKED_POINTER_V1_SET_REGION_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
* Sends an locked event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_locked_pointer_v1_send_locked(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LOCKED_POINTER_V1_LOCKED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_locked_pointer_v1
|
||||
* Sends an unlocked event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_locked_pointer_v1_send_unlocked(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_LOCKED_POINTER_V1_UNLOCKED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
* @struct zwp_confined_pointer_v1_interface
|
||||
*/
|
||||
struct zwp_confined_pointer_v1_interface {
|
||||
/**
|
||||
* destroy the confined pointer object
|
||||
*
|
||||
* Destroy the confined pointer object. If applicable, the
|
||||
* compositor will unconfine the pointer.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* set a new confine region
|
||||
*
|
||||
* Set a new region used to confine the pointer.
|
||||
*
|
||||
* The new confine region is double-buffered. The new confine
|
||||
* region will only take effect when the associated surface gets
|
||||
* its pending state applied. See wl_surface.commit for details.
|
||||
*
|
||||
* If the confinement is active when the new confinement region is
|
||||
* applied and the pointer ends up outside of newly applied region,
|
||||
* the pointer may warped to a position within the new confinement
|
||||
* region. If warped, a wl_pointer.motion event will be emitted,
|
||||
* but no wp_relative_pointer.relative_motion event.
|
||||
*
|
||||
* The compositor may also, instead of using the new region,
|
||||
* unconfine the pointer.
|
||||
*
|
||||
* For details about the confine region, see wp_confined_pointer.
|
||||
* @param region region of surface
|
||||
*/
|
||||
void (*set_region)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *region);
|
||||
};
|
||||
|
||||
#define ZWP_CONFINED_POINTER_V1_CONFINED 0
|
||||
#define ZWP_CONFINED_POINTER_V1_UNCONFINED 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
*/
|
||||
#define ZWP_CONFINED_POINTER_V1_CONFINED_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
*/
|
||||
#define ZWP_CONFINED_POINTER_V1_UNCONFINED_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
*/
|
||||
#define ZWP_CONFINED_POINTER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
*/
|
||||
#define ZWP_CONFINED_POINTER_V1_SET_REGION_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
* Sends an confined event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_confined_pointer_v1_send_confined(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_CONFINED_POINTER_V1_CONFINED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
* Sends an unconfined event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwp_confined_pointer_v1_send_unconfined(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_CONFINED_POINTER_V1_UNCONFINED);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2013-2014 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_presentation_feedback_interface;
|
||||
|
||||
static const struct wl_interface *presentation_time_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_surface_interface,
|
||||
&wp_presentation_feedback_interface,
|
||||
&wl_output_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_presentation_requests[] = {
|
||||
{ "destroy", "", presentation_time_types + 0 },
|
||||
{ "feedback", "on", presentation_time_types + 7 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_presentation_events[] = {
|
||||
{ "clock_id", "u", presentation_time_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_presentation_interface = {
|
||||
"wp_presentation", 2,
|
||||
2, wp_presentation_requests,
|
||||
1, wp_presentation_events,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_presentation_feedback_events[] = {
|
||||
{ "sync_output", "o", presentation_time_types + 9 },
|
||||
{ "presented", "uuuuuuu", presentation_time_types + 0 },
|
||||
{ "discarded", "", presentation_time_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_presentation_feedback_interface = {
|
||||
"wp_presentation_feedback", 2,
|
||||
0, NULL,
|
||||
3, wp_presentation_feedback_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef PRESENTATION_TIME_SERVER_PROTOCOL_H
|
||||
#define PRESENTATION_TIME_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_presentation_time The presentation_time protocol
|
||||
* @section page_ifaces_presentation_time Interfaces
|
||||
* - @subpage page_iface_wp_presentation - timed presentation related wl_surface requests
|
||||
* - @subpage page_iface_wp_presentation_feedback - presentation time feedback event
|
||||
* @section page_copyright_presentation_time Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2013-2014 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_output;
|
||||
struct wl_surface;
|
||||
struct wp_presentation;
|
||||
struct wp_presentation_feedback;
|
||||
|
||||
#ifndef WP_PRESENTATION_INTERFACE
|
||||
#define WP_PRESENTATION_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_presentation wp_presentation
|
||||
* @section page_iface_wp_presentation_desc Description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* The main feature of this interface is accurate presentation
|
||||
* timing feedback to ensure smooth video playback while maintaining
|
||||
* audio/video synchronization. Some features use the concept of a
|
||||
* presentation clock, which is defined in the
|
||||
* presentation.clock_id event.
|
||||
*
|
||||
* A content update for a wl_surface is submitted by a
|
||||
* wl_surface.commit request. Request 'feedback' associates with
|
||||
* the wl_surface.commit and provides feedback on the content
|
||||
* update, particularly the final realized presentation time.
|
||||
*
|
||||
*
|
||||
*
|
||||
* When the final realized presentation time is available, e.g.
|
||||
* after a framebuffer flip completes, the requested
|
||||
* presentation_feedback.presented events are sent. The final
|
||||
* presentation time can differ from the compositor's predicted
|
||||
* display update time and the update's target time, especially
|
||||
* when the compositor misses its target vertical blanking period.
|
||||
* @section page_iface_wp_presentation_api API
|
||||
* See @ref iface_wp_presentation.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_presentation The wp_presentation interface
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* The main feature of this interface is accurate presentation
|
||||
* timing feedback to ensure smooth video playback while maintaining
|
||||
* audio/video synchronization. Some features use the concept of a
|
||||
* presentation clock, which is defined in the
|
||||
* presentation.clock_id event.
|
||||
*
|
||||
* A content update for a wl_surface is submitted by a
|
||||
* wl_surface.commit request. Request 'feedback' associates with
|
||||
* the wl_surface.commit and provides feedback on the content
|
||||
* update, particularly the final realized presentation time.
|
||||
*
|
||||
*
|
||||
*
|
||||
* When the final realized presentation time is available, e.g.
|
||||
* after a framebuffer flip completes, the requested
|
||||
* presentation_feedback.presented events are sent. The final
|
||||
* presentation time can differ from the compositor's predicted
|
||||
* display update time and the update's target time, especially
|
||||
* when the compositor misses its target vertical blanking period.
|
||||
*/
|
||||
extern const struct wl_interface wp_presentation_interface;
|
||||
#endif
|
||||
#ifndef WP_PRESENTATION_FEEDBACK_INTERFACE
|
||||
#define WP_PRESENTATION_FEEDBACK_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_presentation_feedback wp_presentation_feedback
|
||||
* @section page_iface_wp_presentation_feedback_desc Description
|
||||
*
|
||||
* A presentation_feedback object returns an indication that a
|
||||
* wl_surface content update has become visible to the user.
|
||||
* One object corresponds to one content update submission
|
||||
* (wl_surface.commit). There are two possible outcomes: the
|
||||
* content update is presented to the user, and a presentation
|
||||
* timestamp delivered; or, the user did not see the content
|
||||
* update because it was superseded or its surface destroyed,
|
||||
* and the content update is discarded.
|
||||
*
|
||||
* Once a presentation_feedback object has delivered a 'presented'
|
||||
* or 'discarded' event it is automatically destroyed.
|
||||
* @section page_iface_wp_presentation_feedback_api API
|
||||
* See @ref iface_wp_presentation_feedback.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_presentation_feedback The wp_presentation_feedback interface
|
||||
*
|
||||
* A presentation_feedback object returns an indication that a
|
||||
* wl_surface content update has become visible to the user.
|
||||
* One object corresponds to one content update submission
|
||||
* (wl_surface.commit). There are two possible outcomes: the
|
||||
* content update is presented to the user, and a presentation
|
||||
* timestamp delivered; or, the user did not see the content
|
||||
* update because it was superseded or its surface destroyed,
|
||||
* and the content update is discarded.
|
||||
*
|
||||
* Once a presentation_feedback object has delivered a 'presented'
|
||||
* or 'discarded' event it is automatically destroyed.
|
||||
*/
|
||||
extern const struct wl_interface wp_presentation_feedback_interface;
|
||||
#endif
|
||||
|
||||
#ifndef WP_PRESENTATION_ERROR_ENUM
|
||||
#define WP_PRESENTATION_ERROR_ENUM
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
* fatal presentation errors
|
||||
*
|
||||
* These fatal protocol errors may be emitted in response to
|
||||
* illegal presentation requests.
|
||||
*/
|
||||
enum wp_presentation_error {
|
||||
/**
|
||||
* invalid value in tv_nsec
|
||||
*/
|
||||
WP_PRESENTATION_ERROR_INVALID_TIMESTAMP = 0,
|
||||
/**
|
||||
* invalid flag
|
||||
*/
|
||||
WP_PRESENTATION_ERROR_INVALID_FLAG = 1,
|
||||
};
|
||||
#endif /* WP_PRESENTATION_ERROR_ENUM */
|
||||
|
||||
#ifndef WP_PRESENTATION_ERROR_ENUM_IS_VALID
|
||||
#define WP_PRESENTATION_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
* Validate a wp_presentation error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref wp_presentation_error
|
||||
*/
|
||||
static inline bool
|
||||
wp_presentation_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case WP_PRESENTATION_ERROR_INVALID_TIMESTAMP:
|
||||
return version >= 1;
|
||||
case WP_PRESENTATION_ERROR_INVALID_FLAG:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* WP_PRESENTATION_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
* @struct wp_presentation_interface
|
||||
*/
|
||||
struct wp_presentation_interface {
|
||||
/**
|
||||
* unbind from the presentation interface
|
||||
*
|
||||
* Informs the server that the client will no longer be using
|
||||
* this protocol object. Existing objects created by this object
|
||||
* are not affected.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* request presentation feedback information
|
||||
*
|
||||
* Request presentation feedback for the current content
|
||||
* submission on the given surface. This creates a new
|
||||
* presentation_feedback object, which will deliver the feedback
|
||||
* information once. If multiple presentation_feedback objects are
|
||||
* created for the same submission, they will all deliver the same
|
||||
* information.
|
||||
*
|
||||
* For details on what information is returned, see the
|
||||
* presentation_feedback interface.
|
||||
* @param surface target surface
|
||||
* @param callback new feedback object
|
||||
*/
|
||||
void (*feedback)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *surface,
|
||||
uint32_t callback);
|
||||
};
|
||||
|
||||
#define WP_PRESENTATION_CLOCK_ID 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
*/
|
||||
#define WP_PRESENTATION_CLOCK_ID_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
*/
|
||||
#define WP_PRESENTATION_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
*/
|
||||
#define WP_PRESENTATION_FEEDBACK_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation
|
||||
* Sends an clock_id event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param clk_id platform clock identifier
|
||||
*/
|
||||
static inline void
|
||||
wp_presentation_send_clock_id(struct wl_resource *resource_, uint32_t clk_id)
|
||||
{
|
||||
wl_resource_post_event(resource_, WP_PRESENTATION_CLOCK_ID, clk_id);
|
||||
}
|
||||
|
||||
#ifndef WP_PRESENTATION_FEEDBACK_KIND_ENUM
|
||||
#define WP_PRESENTATION_FEEDBACK_KIND_ENUM
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
* bitmask of flags in presented event
|
||||
*
|
||||
* These flags provide information about how the presentation of
|
||||
* the related content update was done. The intent is to help
|
||||
* clients assess the reliability of the feedback and the visual
|
||||
* quality with respect to possible tearing and timings.
|
||||
*/
|
||||
enum wp_presentation_feedback_kind {
|
||||
/**
|
||||
* presentation was vsync'd
|
||||
*
|
||||
* The presentation was synchronized to the "vertical retrace" by
|
||||
* the display hardware such that tearing does not happen. Relying
|
||||
* on software scheduling is not acceptable for this flag. If
|
||||
* presentation is done by a copy to the active frontbuffer, then
|
||||
* it must guarantee that tearing cannot happen.
|
||||
*/
|
||||
WP_PRESENTATION_FEEDBACK_KIND_VSYNC = 0x1,
|
||||
/**
|
||||
* hardware provided the presentation timestamp
|
||||
*
|
||||
* The display hardware provided measurements that the hardware
|
||||
* driver converted into a presentation timestamp. Sampling a clock
|
||||
* in software is not acceptable for this flag.
|
||||
*/
|
||||
WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK = 0x2,
|
||||
/**
|
||||
* hardware signalled the start of the presentation
|
||||
*
|
||||
* The display hardware signalled that it started using the new
|
||||
* image content. The opposite of this is e.g. a timer being used
|
||||
* to guess when the display hardware has switched to the new image
|
||||
* content.
|
||||
*/
|
||||
WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION = 0x4,
|
||||
/**
|
||||
* presentation was done zero-copy
|
||||
*
|
||||
* The presentation of this update was done zero-copy. This means
|
||||
* the buffer from the client was given to display hardware as is,
|
||||
* without copying it. Compositing with OpenGL counts as copying,
|
||||
* even if textured directly from the client buffer. Possible
|
||||
* zero-copy cases include direct scanout of a fullscreen surface
|
||||
* and a surface on a hardware overlay.
|
||||
*/
|
||||
WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY = 0x8,
|
||||
};
|
||||
#endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM */
|
||||
|
||||
#ifndef WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID
|
||||
#define WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
* Validate a wp_presentation_feedback kind value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref wp_presentation_feedback_kind
|
||||
*/
|
||||
static inline bool
|
||||
wp_presentation_feedback_kind_is_valid(uint32_t value, uint32_t version) {
|
||||
uint32_t valid = 0;
|
||||
if (version >= 1)
|
||||
valid |= WP_PRESENTATION_FEEDBACK_KIND_VSYNC;
|
||||
if (version >= 1)
|
||||
valid |= WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
|
||||
if (version >= 1)
|
||||
valid |= WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION;
|
||||
if (version >= 1)
|
||||
valid |= WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY;
|
||||
return (value & ~valid) == 0;
|
||||
}
|
||||
#endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID */
|
||||
|
||||
#define WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT 0
|
||||
#define WP_PRESENTATION_FEEDBACK_PRESENTED 1
|
||||
#define WP_PRESENTATION_FEEDBACK_DISCARDED 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
*/
|
||||
#define WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
*/
|
||||
#define WP_PRESENTATION_FEEDBACK_PRESENTED_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
*/
|
||||
#define WP_PRESENTATION_FEEDBACK_DISCARDED_SINCE_VERSION 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
* Sends an sync_output event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param output presentation output
|
||||
*/
|
||||
static inline void
|
||||
wp_presentation_feedback_send_sync_output(struct wl_resource *resource_, struct wl_resource *output)
|
||||
{
|
||||
wl_resource_post_event(resource_, WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
* Sends an presented event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param tv_sec_hi high 32 bits of the seconds part of the presentation timestamp
|
||||
* @param tv_sec_lo low 32 bits of the seconds part of the presentation timestamp
|
||||
* @param tv_nsec nanoseconds part of the presentation timestamp
|
||||
* @param refresh nanoseconds till next refresh
|
||||
* @param seq_hi high 32 bits of refresh counter
|
||||
* @param seq_lo low 32 bits of refresh counter
|
||||
* @param flags combination of 'kind' values
|
||||
*/
|
||||
static inline void
|
||||
wp_presentation_feedback_send_presented(struct wl_resource *resource_, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags)
|
||||
{
|
||||
wl_resource_post_event(resource_, WP_PRESENTATION_FEEDBACK_PRESENTED, tv_sec_hi, tv_sec_lo, tv_nsec, refresh, seq_hi, seq_lo, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_presentation_feedback
|
||||
* Sends an discarded event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
wp_presentation_feedback_send_discarded(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, WP_PRESENTATION_FEEDBACK_DISCARDED);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2014 Jonas Ådahl
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_pointer_interface;
|
||||
extern const struct wl_interface zwp_relative_pointer_v1_interface;
|
||||
|
||||
static const struct wl_interface *relative_pointer_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_relative_pointer_v1_interface,
|
||||
&wl_pointer_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_relative_pointer_manager_v1_requests[] = {
|
||||
{ "destroy", "", relative_pointer_unstable_v1_types + 0 },
|
||||
{ "get_relative_pointer", "no", relative_pointer_unstable_v1_types + 6 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_relative_pointer_manager_v1_interface = {
|
||||
"zwp_relative_pointer_manager_v1", 1,
|
||||
2, zwp_relative_pointer_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_relative_pointer_v1_requests[] = {
|
||||
{ "destroy", "", relative_pointer_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_relative_pointer_v1_events[] = {
|
||||
{ "relative_motion", "uuffff", relative_pointer_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_relative_pointer_v1_interface = {
|
||||
"zwp_relative_pointer_v1", 1,
|
||||
1, zwp_relative_pointer_v1_requests,
|
||||
1, zwp_relative_pointer_v1_events,
|
||||
};
|
||||
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef RELATIVE_POINTER_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
#define RELATIVE_POINTER_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_relative_pointer_unstable_v1 The relative_pointer_unstable_v1 protocol
|
||||
* protocol for relative pointer motion events
|
||||
*
|
||||
* @section page_desc_relative_pointer_unstable_v1 Description
|
||||
*
|
||||
* This protocol specifies a set of interfaces used for making clients able to
|
||||
* receive relative pointer events not obstructed by barriers (such as the
|
||||
* monitor edge or other pointer barriers).
|
||||
*
|
||||
* To start receiving relative pointer events, a client must first bind the
|
||||
* global interface "wp_relative_pointer_manager" which, if a compositor
|
||||
* supports relative pointer motion events, is exposed by the registry. After
|
||||
* having created the relative pointer manager proxy object, the client uses
|
||||
* it to create the actual relative pointer object using the
|
||||
* "get_relative_pointer" request given a wl_pointer. The relative pointer
|
||||
* motion events will then, when applicable, be transmitted via the proxy of
|
||||
* the newly created relative pointer object. See the documentation of the
|
||||
* relative pointer interface for more details.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and backward
|
||||
* incompatible changes may be made. Backward compatible changes may be added
|
||||
* together with the corresponding interface version bump. Backward
|
||||
* incompatible changes are done by bumping the version number in the protocol
|
||||
* and interface names and resetting the interface version. Once the protocol
|
||||
* is to be declared stable, the 'z' prefix and the version number in the
|
||||
* protocol and interface names are removed and the interface version number is
|
||||
* reset.
|
||||
*
|
||||
* @section page_ifaces_relative_pointer_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zwp_relative_pointer_manager_v1 - get relative pointer objects
|
||||
* - @subpage page_iface_zwp_relative_pointer_v1 - relative pointer object
|
||||
* @section page_copyright_relative_pointer_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2014 Jonas Ådahl
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_pointer;
|
||||
struct zwp_relative_pointer_manager_v1;
|
||||
struct zwp_relative_pointer_v1;
|
||||
|
||||
#ifndef ZWP_RELATIVE_POINTER_MANAGER_V1_INTERFACE
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_relative_pointer_manager_v1 zwp_relative_pointer_manager_v1
|
||||
* @section page_iface_zwp_relative_pointer_manager_v1_desc Description
|
||||
*
|
||||
* A global interface used for getting the relative pointer object for a
|
||||
* given pointer.
|
||||
* @section page_iface_zwp_relative_pointer_manager_v1_api API
|
||||
* See @ref iface_zwp_relative_pointer_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_relative_pointer_manager_v1 The zwp_relative_pointer_manager_v1 interface
|
||||
*
|
||||
* A global interface used for getting the relative pointer object for a
|
||||
* given pointer.
|
||||
*/
|
||||
extern const struct wl_interface zwp_relative_pointer_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWP_RELATIVE_POINTER_V1_INTERFACE
|
||||
#define ZWP_RELATIVE_POINTER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_relative_pointer_v1 zwp_relative_pointer_v1
|
||||
* @section page_iface_zwp_relative_pointer_v1_desc Description
|
||||
*
|
||||
* A wp_relative_pointer object is an extension to the wl_pointer interface
|
||||
* used for emitting relative pointer events. It shares the same focus as
|
||||
* wl_pointer objects of the same seat and will only emit events when it has
|
||||
* focus.
|
||||
* @section page_iface_zwp_relative_pointer_v1_api API
|
||||
* See @ref iface_zwp_relative_pointer_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_relative_pointer_v1 The zwp_relative_pointer_v1 interface
|
||||
*
|
||||
* A wp_relative_pointer object is an extension to the wl_pointer interface
|
||||
* used for emitting relative pointer events. It shares the same focus as
|
||||
* wl_pointer objects of the same seat and will only emit events when it has
|
||||
* focus.
|
||||
*/
|
||||
extern const struct wl_interface zwp_relative_pointer_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
* @struct zwp_relative_pointer_manager_v1_interface
|
||||
*/
|
||||
struct zwp_relative_pointer_manager_v1_interface {
|
||||
/**
|
||||
* destroy the relative pointer manager object
|
||||
*
|
||||
* Used by the client to notify the server that it will no longer
|
||||
* use this relative pointer manager object.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* get a relative pointer object
|
||||
*
|
||||
* Create a relative pointer interface given a wl_pointer object.
|
||||
* See the wp_relative_pointer interface for more details.
|
||||
*/
|
||||
void (*get_relative_pointer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
struct wl_resource *pointer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_GET_RELATIVE_POINTER_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
* @struct zwp_relative_pointer_v1_interface
|
||||
*/
|
||||
struct zwp_relative_pointer_v1_interface {
|
||||
/**
|
||||
* release the relative pointer object
|
||||
*
|
||||
*
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
#define ZWP_RELATIVE_POINTER_V1_RELATIVE_MOTION 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_V1_RELATIVE_MOTION_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
* Sends an relative_motion event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param utime_hi high 32 bits of a 64 bit timestamp with microsecond granularity
|
||||
* @param utime_lo low 32 bits of a 64 bit timestamp with microsecond granularity
|
||||
* @param dx the x component of the motion vector
|
||||
* @param dy the y component of the motion vector
|
||||
* @param dx_unaccel the x component of the unaccelerated motion vector
|
||||
* @param dy_unaccel the y component of the unaccelerated motion vector
|
||||
*/
|
||||
static inline void
|
||||
zwp_relative_pointer_v1_send_relative_motion(struct wl_resource *resource_, uint32_t utime_hi, uint32_t utime_lo, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWP_RELATIVE_POINTER_V1_RELATIVE_MOTION, utime_hi, utime_lo, dx, dy, dx_unaccel, dy_unaccel);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2012, 2013 Intel Corporation
|
||||
* Copyright © 2015, 2016 Jan Arne Petersen
|
||||
* Copyright © 2017, 2018 Red Hat, Inc.
|
||||
* Copyright © 2018 Purism SPC
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this
|
||||
* software and its documentation for any purpose is hereby granted
|
||||
* without fee, provided that the above copyright notice appear in
|
||||
* all copies and that both that copyright notice and this permission
|
||||
* notice appear in supporting documentation, and that the name of
|
||||
* the copyright holders not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
* THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_seat_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface zwp_text_input_v3_interface;
|
||||
|
||||
static const struct wl_interface *text_input_unstable_v3_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_surface_interface,
|
||||
&wl_surface_interface,
|
||||
&zwp_text_input_v3_interface,
|
||||
&wl_seat_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_text_input_v3_requests[] = {
|
||||
{ "destroy", "", text_input_unstable_v3_types + 0 },
|
||||
{ "enable", "", text_input_unstable_v3_types + 0 },
|
||||
{ "disable", "", text_input_unstable_v3_types + 0 },
|
||||
{ "set_surrounding_text", "sii", text_input_unstable_v3_types + 0 },
|
||||
{ "set_text_change_cause", "u", text_input_unstable_v3_types + 0 },
|
||||
{ "set_content_type", "uu", text_input_unstable_v3_types + 0 },
|
||||
{ "set_cursor_rectangle", "iiii", text_input_unstable_v3_types + 0 },
|
||||
{ "commit", "", text_input_unstable_v3_types + 0 },
|
||||
{ "set_available_actions", "2a", text_input_unstable_v3_types + 0 },
|
||||
{ "show_input_panel", "2", text_input_unstable_v3_types + 0 },
|
||||
{ "hide_input_panel", "2", text_input_unstable_v3_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_text_input_v3_events[] = {
|
||||
{ "enter", "o", text_input_unstable_v3_types + 4 },
|
||||
{ "leave", "o", text_input_unstable_v3_types + 5 },
|
||||
{ "preedit_string", "?sii", text_input_unstable_v3_types + 0 },
|
||||
{ "commit_string", "?s", text_input_unstable_v3_types + 0 },
|
||||
{ "delete_surrounding_text", "uu", text_input_unstable_v3_types + 0 },
|
||||
{ "done", "u", text_input_unstable_v3_types + 0 },
|
||||
{ "action", "2uu", text_input_unstable_v3_types + 0 },
|
||||
{ "language", "2s", text_input_unstable_v3_types + 0 },
|
||||
{ "preedit_hint", "2uuu", text_input_unstable_v3_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_text_input_v3_interface = {
|
||||
"zwp_text_input_v3", 2,
|
||||
11, zwp_text_input_v3_requests,
|
||||
9, zwp_text_input_v3_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_text_input_manager_v3_requests[] = {
|
||||
{ "destroy", "", text_input_unstable_v3_types + 0 },
|
||||
{ "get_text_input", "no", text_input_unstable_v3_types + 6 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_text_input_manager_v3_interface = {
|
||||
"zwp_text_input_manager_v3", 2,
|
||||
2, zwp_text_input_manager_v3_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,75 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_viewport_interface;
|
||||
|
||||
static const struct wl_interface *viewporter_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wp_viewport_interface,
|
||||
&wl_surface_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_viewporter_requests[] = {
|
||||
{ "destroy", "", viewporter_types + 0 },
|
||||
{ "get_viewport", "no", viewporter_types + 4 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_viewporter_interface = {
|
||||
"wp_viewporter", 1,
|
||||
2, wp_viewporter_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_viewport_requests[] = {
|
||||
{ "destroy", "", viewporter_types + 0 },
|
||||
{ "set_source", "ffff", viewporter_types + 0 },
|
||||
{ "set_destination", "ii", viewporter_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_viewport_interface = {
|
||||
"wp_viewport", 1,
|
||||
3, wp_viewport_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef VIEWPORTER_SERVER_PROTOCOL_H
|
||||
#define VIEWPORTER_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_viewporter The viewporter protocol
|
||||
* @section page_ifaces_viewporter Interfaces
|
||||
* - @subpage page_iface_wp_viewporter - surface cropping and scaling
|
||||
* - @subpage page_iface_wp_viewport - crop and scale interface to a wl_surface
|
||||
* @section page_copyright_viewporter Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_surface;
|
||||
struct wp_viewport;
|
||||
struct wp_viewporter;
|
||||
|
||||
#ifndef WP_VIEWPORTER_INTERFACE
|
||||
#define WP_VIEWPORTER_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_viewporter wp_viewporter
|
||||
* @section page_iface_wp_viewporter_desc Description
|
||||
*
|
||||
* The global interface exposing surface cropping and scaling
|
||||
* capabilities is used to instantiate an interface extension for a
|
||||
* wl_surface object. This extended interface will then allow
|
||||
* cropping and scaling the surface contents, effectively
|
||||
* disconnecting the direct relationship between the buffer and the
|
||||
* surface size.
|
||||
* @section page_iface_wp_viewporter_api API
|
||||
* See @ref iface_wp_viewporter.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_viewporter The wp_viewporter interface
|
||||
*
|
||||
* The global interface exposing surface cropping and scaling
|
||||
* capabilities is used to instantiate an interface extension for a
|
||||
* wl_surface object. This extended interface will then allow
|
||||
* cropping and scaling the surface contents, effectively
|
||||
* disconnecting the direct relationship between the buffer and the
|
||||
* surface size.
|
||||
*/
|
||||
extern const struct wl_interface wp_viewporter_interface;
|
||||
#endif
|
||||
#ifndef WP_VIEWPORT_INTERFACE
|
||||
#define WP_VIEWPORT_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_viewport wp_viewport
|
||||
* @section page_iface_wp_viewport_desc Description
|
||||
*
|
||||
* An additional interface to a wl_surface object, which allows the
|
||||
* client to specify the cropping and scaling of the surface
|
||||
* contents.
|
||||
*
|
||||
* This interface works with two concepts: the source rectangle (src_x,
|
||||
* src_y, src_width, src_height), and the destination size (dst_width,
|
||||
* dst_height). The contents of the source rectangle are scaled to the
|
||||
* destination size, and content outside the source rectangle is ignored.
|
||||
* This state is double-buffered, and is applied on the next
|
||||
* wl_surface.commit.
|
||||
*
|
||||
* The two parts of crop and scale state are independent: the source
|
||||
* rectangle, and the destination size. Initially both are unset, that
|
||||
* is, no scaling is applied. The whole of the current wl_buffer is
|
||||
* used as the source, and the surface size is as defined in
|
||||
* wl_surface.attach.
|
||||
*
|
||||
* If the destination size is set, it causes the surface size to become
|
||||
* dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
* this size. This overrides whatever the attached wl_buffer size is,
|
||||
* unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
* has no content and therefore no size. Otherwise, the size is always
|
||||
* at least 1x1 in surface local coordinates.
|
||||
*
|
||||
* If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
* taken as the source. If the source rectangle is set and the destination
|
||||
* size is not set, then src_width and src_height must be integers, and the
|
||||
* surface size becomes the source rectangle size. This results in cropping
|
||||
* without scaling. If src_width or src_height are not integers and
|
||||
* destination size is not set, the bad_size protocol error is raised when
|
||||
* the surface state is applied.
|
||||
*
|
||||
* The coordinate transformations from buffer pixel coordinates up to
|
||||
* the surface-local coordinates happen in the following order:
|
||||
* 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
* 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
* 3. crop and scale (wp_viewport.set*)
|
||||
* This means, that the source rectangle coordinates of crop and scale
|
||||
* are given in the coordinates after the buffer transform and scale,
|
||||
* i.e. in the coordinates that would be the surface-local coordinates
|
||||
* if the crop and scale was not applied.
|
||||
*
|
||||
* If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
* Otherwise, if the source rectangle is partially or completely outside of
|
||||
* the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
* when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
* out_of_buffer error.
|
||||
*
|
||||
* If the wl_surface associated with the wp_viewport is destroyed,
|
||||
* all wp_viewport requests except 'destroy' raise the protocol error
|
||||
* no_surface.
|
||||
*
|
||||
* If the wp_viewport object is destroyed, the crop and scale
|
||||
* state is removed from the wl_surface. The change will be applied
|
||||
* on the next wl_surface.commit.
|
||||
* @section page_iface_wp_viewport_api API
|
||||
* See @ref iface_wp_viewport.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_viewport The wp_viewport interface
|
||||
*
|
||||
* An additional interface to a wl_surface object, which allows the
|
||||
* client to specify the cropping and scaling of the surface
|
||||
* contents.
|
||||
*
|
||||
* This interface works with two concepts: the source rectangle (src_x,
|
||||
* src_y, src_width, src_height), and the destination size (dst_width,
|
||||
* dst_height). The contents of the source rectangle are scaled to the
|
||||
* destination size, and content outside the source rectangle is ignored.
|
||||
* This state is double-buffered, and is applied on the next
|
||||
* wl_surface.commit.
|
||||
*
|
||||
* The two parts of crop and scale state are independent: the source
|
||||
* rectangle, and the destination size. Initially both are unset, that
|
||||
* is, no scaling is applied. The whole of the current wl_buffer is
|
||||
* used as the source, and the surface size is as defined in
|
||||
* wl_surface.attach.
|
||||
*
|
||||
* If the destination size is set, it causes the surface size to become
|
||||
* dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
* this size. This overrides whatever the attached wl_buffer size is,
|
||||
* unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
* has no content and therefore no size. Otherwise, the size is always
|
||||
* at least 1x1 in surface local coordinates.
|
||||
*
|
||||
* If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
* taken as the source. If the source rectangle is set and the destination
|
||||
* size is not set, then src_width and src_height must be integers, and the
|
||||
* surface size becomes the source rectangle size. This results in cropping
|
||||
* without scaling. If src_width or src_height are not integers and
|
||||
* destination size is not set, the bad_size protocol error is raised when
|
||||
* the surface state is applied.
|
||||
*
|
||||
* The coordinate transformations from buffer pixel coordinates up to
|
||||
* the surface-local coordinates happen in the following order:
|
||||
* 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
* 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
* 3. crop and scale (wp_viewport.set*)
|
||||
* This means, that the source rectangle coordinates of crop and scale
|
||||
* are given in the coordinates after the buffer transform and scale,
|
||||
* i.e. in the coordinates that would be the surface-local coordinates
|
||||
* if the crop and scale was not applied.
|
||||
*
|
||||
* If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
* Otherwise, if the source rectangle is partially or completely outside of
|
||||
* the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
* when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
* out_of_buffer error.
|
||||
*
|
||||
* If the wl_surface associated with the wp_viewport is destroyed,
|
||||
* all wp_viewport requests except 'destroy' raise the protocol error
|
||||
* no_surface.
|
||||
*
|
||||
* If the wp_viewport object is destroyed, the crop and scale
|
||||
* state is removed from the wl_surface. The change will be applied
|
||||
* on the next wl_surface.commit.
|
||||
*/
|
||||
extern const struct wl_interface wp_viewport_interface;
|
||||
#endif
|
||||
|
||||
#ifndef WP_VIEWPORTER_ERROR_ENUM
|
||||
#define WP_VIEWPORTER_ERROR_ENUM
|
||||
enum wp_viewporter_error {
|
||||
/**
|
||||
* the surface already has a viewport object associated
|
||||
*/
|
||||
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0,
|
||||
};
|
||||
#endif /* WP_VIEWPORTER_ERROR_ENUM */
|
||||
|
||||
#ifndef WP_VIEWPORTER_ERROR_ENUM_IS_VALID
|
||||
#define WP_VIEWPORTER_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
* Validate a wp_viewporter error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref wp_viewporter_error
|
||||
*/
|
||||
static inline bool
|
||||
wp_viewporter_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* WP_VIEWPORTER_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
* @struct wp_viewporter_interface
|
||||
*/
|
||||
struct wp_viewporter_interface {
|
||||
/**
|
||||
* unbind from the cropping and scaling interface
|
||||
*
|
||||
* Informs the server that the client will not be using this
|
||||
* protocol object anymore. This does not affect any other objects,
|
||||
* wp_viewport objects included.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* extend surface interface for crop and scale
|
||||
*
|
||||
* Instantiate an interface extension for the given wl_surface to
|
||||
* crop and scale its content. If the given wl_surface already has
|
||||
* a wp_viewport object associated, the viewport_exists protocol
|
||||
* error is raised.
|
||||
* @param id the new viewport interface id
|
||||
* @param surface the surface
|
||||
*/
|
||||
void (*get_viewport)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
struct wl_resource *surface);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*/
|
||||
#define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*/
|
||||
#define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1
|
||||
|
||||
#ifndef WP_VIEWPORT_ERROR_ENUM
|
||||
#define WP_VIEWPORT_ERROR_ENUM
|
||||
enum wp_viewport_error {
|
||||
/**
|
||||
* negative or zero values in width or height
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_BAD_VALUE = 0,
|
||||
/**
|
||||
* destination size is not integer
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_BAD_SIZE = 1,
|
||||
/**
|
||||
* source rectangle extends outside of the content area
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2,
|
||||
/**
|
||||
* the wl_surface was destroyed
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_NO_SURFACE = 3,
|
||||
};
|
||||
#endif /* WP_VIEWPORT_ERROR_ENUM */
|
||||
|
||||
#ifndef WP_VIEWPORT_ERROR_ENUM_IS_VALID
|
||||
#define WP_VIEWPORT_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
* Validate a wp_viewport error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref wp_viewport_error
|
||||
*/
|
||||
static inline bool
|
||||
wp_viewport_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case WP_VIEWPORT_ERROR_BAD_VALUE:
|
||||
return version >= 1;
|
||||
case WP_VIEWPORT_ERROR_BAD_SIZE:
|
||||
return version >= 1;
|
||||
case WP_VIEWPORT_ERROR_OUT_OF_BUFFER:
|
||||
return version >= 1;
|
||||
case WP_VIEWPORT_ERROR_NO_SURFACE:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* WP_VIEWPORT_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
* @struct wp_viewport_interface
|
||||
*/
|
||||
struct wp_viewport_interface {
|
||||
/**
|
||||
* remove scaling and cropping from the surface
|
||||
*
|
||||
* The associated wl_surface's crop and scale state is removed.
|
||||
* The change is applied on the next wl_surface.commit.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* set the source rectangle for cropping
|
||||
*
|
||||
* Set the source rectangle of the associated wl_surface. See
|
||||
* wp_viewport for the description, and relation to the wl_buffer
|
||||
* size.
|
||||
*
|
||||
* If all of x, y, width and height are -1.0, the source rectangle
|
||||
* is unset instead. Any other set of values where width or height
|
||||
* are zero or negative, or x or y are negative, raise the
|
||||
* bad_value protocol error.
|
||||
*
|
||||
* The crop and scale state is double-buffered state, and will be
|
||||
* applied on the next wl_surface.commit.
|
||||
* @param x source rectangle x
|
||||
* @param y source rectangle y
|
||||
* @param width source rectangle width
|
||||
* @param height source rectangle height
|
||||
*/
|
||||
void (*set_source)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
wl_fixed_t x,
|
||||
wl_fixed_t y,
|
||||
wl_fixed_t width,
|
||||
wl_fixed_t height);
|
||||
/**
|
||||
* set the surface size for scaling
|
||||
*
|
||||
* Set the destination size of the associated wl_surface. See
|
||||
* wp_viewport for the description, and relation to the wl_buffer
|
||||
* size.
|
||||
*
|
||||
* If width is -1 and height is -1, the destination size is unset
|
||||
* instead. Any other pair of values for width and height that
|
||||
* contains zero or negative values raises the bad_value protocol
|
||||
* error.
|
||||
*
|
||||
* The crop and scale state is double-buffered state, and will be
|
||||
* applied on the next wl_surface.commit.
|
||||
* @param width surface width
|
||||
* @param height surface height
|
||||
*/
|
||||
void (*set_destination)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int32_t width,
|
||||
int32_t height);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2018 Simon Ser
|
||||
* Copyright © 2019 Ivan Molodetskikh
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this
|
||||
* software and its documentation for any purpose is hereby granted
|
||||
* without fee, provided that the above copyright notice appear in
|
||||
* all copies and that both that copyright notice and this permission
|
||||
* notice appear in supporting documentation, and that the name of
|
||||
* the copyright holders not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
* THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_seat_interface;
|
||||
extern const struct wl_interface zwlr_data_control_device_v1_interface;
|
||||
extern const struct wl_interface zwlr_data_control_offer_v1_interface;
|
||||
extern const struct wl_interface zwlr_data_control_source_v1_interface;
|
||||
|
||||
static const struct wl_interface *wlr_data_control_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&zwlr_data_control_source_v1_interface,
|
||||
&zwlr_data_control_device_v1_interface,
|
||||
&wl_seat_interface,
|
||||
&zwlr_data_control_source_v1_interface,
|
||||
&zwlr_data_control_source_v1_interface,
|
||||
&zwlr_data_control_offer_v1_interface,
|
||||
&zwlr_data_control_offer_v1_interface,
|
||||
&zwlr_data_control_offer_v1_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_manager_v1_requests[] = {
|
||||
{ "create_data_source", "n", wlr_data_control_unstable_v1_types + 2 },
|
||||
{ "get_data_device", "no", wlr_data_control_unstable_v1_types + 3 },
|
||||
{ "destroy", "", wlr_data_control_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_data_control_manager_v1_interface = {
|
||||
"zwlr_data_control_manager_v1", 2,
|
||||
3, zwlr_data_control_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_device_v1_requests[] = {
|
||||
{ "set_selection", "?o", wlr_data_control_unstable_v1_types + 5 },
|
||||
{ "destroy", "", wlr_data_control_unstable_v1_types + 0 },
|
||||
{ "set_primary_selection", "2?o", wlr_data_control_unstable_v1_types + 6 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_device_v1_events[] = {
|
||||
{ "data_offer", "n", wlr_data_control_unstable_v1_types + 7 },
|
||||
{ "selection", "?o", wlr_data_control_unstable_v1_types + 8 },
|
||||
{ "finished", "", wlr_data_control_unstable_v1_types + 0 },
|
||||
{ "primary_selection", "2?o", wlr_data_control_unstable_v1_types + 9 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_data_control_device_v1_interface = {
|
||||
"zwlr_data_control_device_v1", 2,
|
||||
3, zwlr_data_control_device_v1_requests,
|
||||
4, zwlr_data_control_device_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_source_v1_requests[] = {
|
||||
{ "offer", "s", wlr_data_control_unstable_v1_types + 0 },
|
||||
{ "destroy", "", wlr_data_control_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_source_v1_events[] = {
|
||||
{ "send", "sh", wlr_data_control_unstable_v1_types + 0 },
|
||||
{ "cancelled", "", wlr_data_control_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_data_control_source_v1_interface = {
|
||||
"zwlr_data_control_source_v1", 1,
|
||||
2, zwlr_data_control_source_v1_requests,
|
||||
2, zwlr_data_control_source_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_offer_v1_requests[] = {
|
||||
{ "receive", "sh", wlr_data_control_unstable_v1_types + 0 },
|
||||
{ "destroy", "", wlr_data_control_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_data_control_offer_v1_events[] = {
|
||||
{ "offer", "s", wlr_data_control_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_data_control_offer_v1_interface = {
|
||||
"zwlr_data_control_offer_v1", 1,
|
||||
2, zwlr_data_control_offer_v1_requests,
|
||||
1, zwlr_data_control_offer_v1_events,
|
||||
};
|
||||
|
||||
+541
@@ -0,0 +1,541 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef WLR_DATA_CONTROL_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
#define WLR_DATA_CONTROL_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_wlr_data_control_unstable_v1 The wlr_data_control_unstable_v1 protocol
|
||||
* control data devices
|
||||
*
|
||||
* @section page_desc_wlr_data_control_unstable_v1 Description
|
||||
*
|
||||
* This protocol allows a privileged client to control data devices. In
|
||||
* particular, the client will be able to manage the current selection and take
|
||||
* the role of a clipboard manager.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and
|
||||
* backward incompatible changes may be made. Backward compatible changes
|
||||
* may be added together with the corresponding interface version bump.
|
||||
* Backward incompatible changes are done by bumping the version number in
|
||||
* the protocol and interface names and resetting the interface version.
|
||||
* Once the protocol is to be declared stable, the 'z' prefix and the
|
||||
* version number in the protocol and interface names are removed and the
|
||||
* interface version number is reset.
|
||||
*
|
||||
* Note! This protocol is deprecated and not intended for production use.
|
||||
* For clipboard management, use the ext-data-control-v1 protocol.
|
||||
*
|
||||
* @section page_ifaces_wlr_data_control_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zwlr_data_control_manager_v1 - manager to control data devices
|
||||
* - @subpage page_iface_zwlr_data_control_device_v1 - manage a data device for a seat
|
||||
* - @subpage page_iface_zwlr_data_control_source_v1 - offer to transfer data
|
||||
* - @subpage page_iface_zwlr_data_control_offer_v1 - offer to transfer data
|
||||
* @section page_copyright_wlr_data_control_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2018 Simon Ser
|
||||
* Copyright © 2019 Ivan Molodetskikh
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this
|
||||
* software and its documentation for any purpose is hereby granted
|
||||
* without fee, provided that the above copyright notice appear in
|
||||
* all copies and that both that copyright notice and this permission
|
||||
* notice appear in supporting documentation, and that the name of
|
||||
* the copyright holders not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
* THIS SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_seat;
|
||||
struct zwlr_data_control_device_v1;
|
||||
struct zwlr_data_control_manager_v1;
|
||||
struct zwlr_data_control_offer_v1;
|
||||
struct zwlr_data_control_source_v1;
|
||||
|
||||
#ifndef ZWLR_DATA_CONTROL_MANAGER_V1_INTERFACE
|
||||
#define ZWLR_DATA_CONTROL_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwlr_data_control_manager_v1 zwlr_data_control_manager_v1
|
||||
* @section page_iface_zwlr_data_control_manager_v1_desc Description
|
||||
*
|
||||
* This interface is a manager that allows creating per-seat data device
|
||||
* controls.
|
||||
* @section page_iface_zwlr_data_control_manager_v1_api API
|
||||
* See @ref iface_zwlr_data_control_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwlr_data_control_manager_v1 The zwlr_data_control_manager_v1 interface
|
||||
*
|
||||
* This interface is a manager that allows creating per-seat data device
|
||||
* controls.
|
||||
*/
|
||||
extern const struct wl_interface zwlr_data_control_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWLR_DATA_CONTROL_DEVICE_V1_INTERFACE
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwlr_data_control_device_v1 zwlr_data_control_device_v1
|
||||
* @section page_iface_zwlr_data_control_device_v1_desc Description
|
||||
*
|
||||
* This interface allows a client to manage a seat's selection.
|
||||
*
|
||||
* When the seat is destroyed, this object becomes inert.
|
||||
* @section page_iface_zwlr_data_control_device_v1_api API
|
||||
* See @ref iface_zwlr_data_control_device_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwlr_data_control_device_v1 The zwlr_data_control_device_v1 interface
|
||||
*
|
||||
* This interface allows a client to manage a seat's selection.
|
||||
*
|
||||
* When the seat is destroyed, this object becomes inert.
|
||||
*/
|
||||
extern const struct wl_interface zwlr_data_control_device_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWLR_DATA_CONTROL_SOURCE_V1_INTERFACE
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwlr_data_control_source_v1 zwlr_data_control_source_v1
|
||||
* @section page_iface_zwlr_data_control_source_v1_desc Description
|
||||
*
|
||||
* The wlr_data_control_source object is the source side of a
|
||||
* wlr_data_control_offer. It is created by the source client in a data
|
||||
* transfer and provides a way to describe the offered data and a way to
|
||||
* respond to requests to transfer the data.
|
||||
* @section page_iface_zwlr_data_control_source_v1_api API
|
||||
* See @ref iface_zwlr_data_control_source_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwlr_data_control_source_v1 The zwlr_data_control_source_v1 interface
|
||||
*
|
||||
* The wlr_data_control_source object is the source side of a
|
||||
* wlr_data_control_offer. It is created by the source client in a data
|
||||
* transfer and provides a way to describe the offered data and a way to
|
||||
* respond to requests to transfer the data.
|
||||
*/
|
||||
extern const struct wl_interface zwlr_data_control_source_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWLR_DATA_CONTROL_OFFER_V1_INTERFACE
|
||||
#define ZWLR_DATA_CONTROL_OFFER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwlr_data_control_offer_v1 zwlr_data_control_offer_v1
|
||||
* @section page_iface_zwlr_data_control_offer_v1_desc Description
|
||||
*
|
||||
* A wlr_data_control_offer represents a piece of data offered for transfer
|
||||
* by another client (the source client). The offer describes the different
|
||||
* MIME types that the data can be converted to and provides the mechanism
|
||||
* for transferring the data directly from the source client.
|
||||
* @section page_iface_zwlr_data_control_offer_v1_api API
|
||||
* See @ref iface_zwlr_data_control_offer_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwlr_data_control_offer_v1 The zwlr_data_control_offer_v1 interface
|
||||
*
|
||||
* A wlr_data_control_offer represents a piece of data offered for transfer
|
||||
* by another client (the source client). The offer describes the different
|
||||
* MIME types that the data can be converted to and provides the mechanism
|
||||
* for transferring the data directly from the source client.
|
||||
*/
|
||||
extern const struct wl_interface zwlr_data_control_offer_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_manager_v1
|
||||
* @struct zwlr_data_control_manager_v1_interface
|
||||
*/
|
||||
struct zwlr_data_control_manager_v1_interface {
|
||||
/**
|
||||
* create a new data source
|
||||
*
|
||||
* Create a new data source.
|
||||
* @param id data source to create
|
||||
*/
|
||||
void (*create_data_source)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id);
|
||||
/**
|
||||
* get a data device for a seat
|
||||
*
|
||||
* Create a data device that can be used to manage a seat's
|
||||
* selection.
|
||||
*/
|
||||
void (*get_data_device)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
struct wl_resource *seat);
|
||||
/**
|
||||
* destroy the manager
|
||||
*
|
||||
* All objects created by the manager will still remain valid,
|
||||
* until their appropriate destroy request has been called.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_manager_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_MANAGER_V1_CREATE_DATA_SOURCE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_manager_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_MANAGER_V1_GET_DATA_DEVICE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_manager_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
#ifndef ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM
|
||||
enum zwlr_data_control_device_v1_error {
|
||||
/**
|
||||
* source given to set_selection or set_primary_selection was already used before
|
||||
*/
|
||||
ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_USED_SOURCE = 1,
|
||||
};
|
||||
#endif /* ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM_IS_VALID
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
* Validate a zwlr_data_control_device_v1 error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwlr_data_control_device_v1_error
|
||||
*/
|
||||
static inline bool
|
||||
zwlr_data_control_device_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_USED_SOURCE:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
* @struct zwlr_data_control_device_v1_interface
|
||||
*/
|
||||
struct zwlr_data_control_device_v1_interface {
|
||||
/**
|
||||
* copy data to the selection
|
||||
*
|
||||
* This request asks the compositor to set the selection to the
|
||||
* data from the source on behalf of the client.
|
||||
*
|
||||
* The given source may not be used in any further set_selection or
|
||||
* set_primary_selection requests. Attempting to use a previously
|
||||
* used source is a protocol error.
|
||||
*
|
||||
* To unset the selection, set the source to NULL.
|
||||
*/
|
||||
void (*set_selection)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *source);
|
||||
/**
|
||||
* destroy this data device
|
||||
*
|
||||
* Destroys the data device object.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* copy data to the primary selection
|
||||
*
|
||||
* This request asks the compositor to set the primary selection
|
||||
* to the data from the source on behalf of the client.
|
||||
*
|
||||
* The given source may not be used in any further set_selection or
|
||||
* set_primary_selection requests. Attempting to use a previously
|
||||
* used source is a protocol error.
|
||||
*
|
||||
* To unset the primary selection, set the source to NULL.
|
||||
*
|
||||
* The compositor will ignore this request if it does not support
|
||||
* primary selection.
|
||||
* @since 2
|
||||
*/
|
||||
void (*set_primary_selection)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *source);
|
||||
};
|
||||
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_DATA_OFFER 0
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_SELECTION 1
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_FINISHED 2
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_PRIMARY_SELECTION 3
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_DATA_OFFER_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_SELECTION_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_FINISHED_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_PRIMARY_SELECTION_SINCE_VERSION 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_SET_SELECTION_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_DEVICE_V1_SET_PRIMARY_SELECTION_SINCE_VERSION 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
* Sends an data_offer event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_device_v1_send_data_offer(struct wl_resource *resource_, struct wl_resource *id)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_DEVICE_V1_DATA_OFFER, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
* Sends an selection event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_device_v1_send_selection(struct wl_resource *resource_, struct wl_resource *id)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_DEVICE_V1_SELECTION, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
* Sends an finished event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_device_v1_send_finished(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_DEVICE_V1_FINISHED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_device_v1
|
||||
* Sends an primary_selection event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_device_v1_send_primary_selection(struct wl_resource *resource_, struct wl_resource *id)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_DEVICE_V1_PRIMARY_SELECTION, id);
|
||||
}
|
||||
|
||||
#ifndef ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM
|
||||
enum zwlr_data_control_source_v1_error {
|
||||
/**
|
||||
* offer sent after wlr_data_control_device.set_selection
|
||||
*/
|
||||
ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_INVALID_OFFER = 1,
|
||||
};
|
||||
#endif /* ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM_IS_VALID
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
* Validate a zwlr_data_control_source_v1 error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref zwlr_data_control_source_v1_error
|
||||
*/
|
||||
static inline bool
|
||||
zwlr_data_control_source_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_INVALID_OFFER:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
* @struct zwlr_data_control_source_v1_interface
|
||||
*/
|
||||
struct zwlr_data_control_source_v1_interface {
|
||||
/**
|
||||
* add an offered MIME type
|
||||
*
|
||||
* This request adds a MIME type to the set of MIME types
|
||||
* advertised to targets. Can be called several times to offer
|
||||
* multiple types.
|
||||
*
|
||||
* Calling this after wlr_data_control_device.set_selection is a
|
||||
* protocol error.
|
||||
* @param mime_type MIME type offered by the data source
|
||||
*/
|
||||
void (*offer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
const char *mime_type);
|
||||
/**
|
||||
* destroy this source
|
||||
*
|
||||
* Destroys the data source object.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_SEND 0
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_CANCELLED 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_SEND_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_CANCELLED_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_OFFER_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_SOURCE_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
* Sends an send event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param mime_type MIME type for the data
|
||||
* @param fd file descriptor for the data
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_source_v1_send_send(struct wl_resource *resource_, const char *mime_type, int32_t fd)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_SOURCE_V1_SEND, mime_type, fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_source_v1
|
||||
* Sends an cancelled event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_source_v1_send_cancelled(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_SOURCE_V1_CANCELLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_offer_v1
|
||||
* @struct zwlr_data_control_offer_v1_interface
|
||||
*/
|
||||
struct zwlr_data_control_offer_v1_interface {
|
||||
/**
|
||||
* request that the data is transferred
|
||||
*
|
||||
* To transfer the offered data, the client issues this request
|
||||
* and indicates the MIME type it wants to receive. The transfer
|
||||
* happens through the passed file descriptor (typically created
|
||||
* with the pipe system call). The source client writes the data in
|
||||
* the MIME type representation requested and then closes the file
|
||||
* descriptor.
|
||||
*
|
||||
* The receiving client reads from the read end of the pipe until
|
||||
* EOF and then closes its end, at which point the transfer is
|
||||
* complete.
|
||||
*
|
||||
* This request may happen multiple times for different MIME types.
|
||||
* @param mime_type MIME type desired by receiver
|
||||
* @param fd file descriptor for data transfer
|
||||
*/
|
||||
void (*receive)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
const char *mime_type,
|
||||
int32_t fd);
|
||||
/**
|
||||
* destroy this offer
|
||||
*
|
||||
* Destroys the data offer object.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
#define ZWLR_DATA_CONTROL_OFFER_V1_OFFER 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_offer_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_OFFER_V1_OFFER_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_offer_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_OFFER_V1_RECEIVE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_offer_v1
|
||||
*/
|
||||
#define ZWLR_DATA_CONTROL_OFFER_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwlr_data_control_offer_v1
|
||||
* Sends an offer event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param mime_type offered MIME type
|
||||
*/
|
||||
static inline void
|
||||
zwlr_data_control_offer_v1_send_offer(struct wl_resource *resource_, const char *mime_type)
|
||||
{
|
||||
wl_resource_post_event(resource_, ZWLR_DATA_CONTROL_OFFER_V1_OFFER, mime_type);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,184 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2008-2013 Kristian Høgsberg
|
||||
* Copyright © 2013 Rafael Antognolli
|
||||
* Copyright © 2013 Jasper St. Pierre
|
||||
* Copyright © 2010-2013 Intel Corporation
|
||||
* Copyright © 2015-2017 Samsung Electronics Co., Ltd
|
||||
* Copyright © 2015-2017 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface wl_seat_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface xdg_popup_interface;
|
||||
extern const struct wl_interface xdg_positioner_interface;
|
||||
extern const struct wl_interface xdg_surface_interface;
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
|
||||
static const struct wl_interface *xdg_shell_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&xdg_positioner_interface,
|
||||
&xdg_surface_interface,
|
||||
&wl_surface_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&xdg_popup_interface,
|
||||
&xdg_surface_interface,
|
||||
&xdg_positioner_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_output_interface,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
&xdg_positioner_interface,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_wm_base_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "create_positioner", "n", xdg_shell_types + 4 },
|
||||
{ "get_xdg_surface", "no", xdg_shell_types + 5 },
|
||||
{ "pong", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_wm_base_events[] = {
|
||||
{ "ping", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_wm_base_interface = {
|
||||
"xdg_wm_base", 5,
|
||||
4, xdg_wm_base_requests,
|
||||
1, xdg_wm_base_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_positioner_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "set_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_anchor_rect", "iiii", xdg_shell_types + 0 },
|
||||
{ "set_anchor", "u", xdg_shell_types + 0 },
|
||||
{ "set_gravity", "u", xdg_shell_types + 0 },
|
||||
{ "set_constraint_adjustment", "u", xdg_shell_types + 0 },
|
||||
{ "set_offset", "ii", xdg_shell_types + 0 },
|
||||
{ "set_reactive", "3", xdg_shell_types + 0 },
|
||||
{ "set_parent_size", "3ii", xdg_shell_types + 0 },
|
||||
{ "set_parent_configure", "3u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_positioner_interface = {
|
||||
"xdg_positioner", 5,
|
||||
10, xdg_positioner_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_surface_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "get_toplevel", "n", xdg_shell_types + 7 },
|
||||
{ "get_popup", "n?oo", xdg_shell_types + 8 },
|
||||
{ "set_window_geometry", "iiii", xdg_shell_types + 0 },
|
||||
{ "ack_configure", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_surface_events[] = {
|
||||
{ "configure", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_surface_interface = {
|
||||
"xdg_surface", 5,
|
||||
5, xdg_surface_requests,
|
||||
1, xdg_surface_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "set_parent", "?o", xdg_shell_types + 11 },
|
||||
{ "set_title", "s", xdg_shell_types + 0 },
|
||||
{ "set_app_id", "s", xdg_shell_types + 0 },
|
||||
{ "show_window_menu", "ouii", xdg_shell_types + 12 },
|
||||
{ "move", "ou", xdg_shell_types + 16 },
|
||||
{ "resize", "ouu", xdg_shell_types + 18 },
|
||||
{ "set_max_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_min_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_maximized", "", xdg_shell_types + 0 },
|
||||
{ "unset_maximized", "", xdg_shell_types + 0 },
|
||||
{ "set_fullscreen", "?o", xdg_shell_types + 21 },
|
||||
{ "unset_fullscreen", "", xdg_shell_types + 0 },
|
||||
{ "set_minimized", "", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_events[] = {
|
||||
{ "configure", "iia", xdg_shell_types + 0 },
|
||||
{ "close", "", xdg_shell_types + 0 },
|
||||
{ "configure_bounds", "4ii", xdg_shell_types + 0 },
|
||||
{ "wm_capabilities", "5a", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_interface = {
|
||||
"xdg_toplevel", 5,
|
||||
14, xdg_toplevel_requests,
|
||||
4, xdg_toplevel_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_popup_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "grab", "ou", xdg_shell_types + 22 },
|
||||
{ "reposition", "3ou", xdg_shell_types + 24 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_popup_events[] = {
|
||||
{ "configure", "iiii", xdg_shell_types + 0 },
|
||||
{ "popup_done", "", xdg_shell_types + 0 },
|
||||
{ "repositioned", "3u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_popup_interface = {
|
||||
"xdg_popup", 5,
|
||||
3, xdg_popup_requests,
|
||||
3, xdg_popup_events,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,83 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2023-2024 Matthias Klumpp
|
||||
* Copyright © 2024 David Edmundson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_buffer_interface;
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
extern const struct wl_interface xdg_toplevel_icon_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_toplevel_icon_v1_types[] = {
|
||||
NULL,
|
||||
&xdg_toplevel_icon_v1_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&xdg_toplevel_icon_v1_interface,
|
||||
&wl_buffer_interface,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_icon_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "create_icon", "n", xdg_toplevel_icon_v1_types + 1 },
|
||||
{ "set_icon", "o?o", xdg_toplevel_icon_v1_types + 2 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_icon_manager_v1_events[] = {
|
||||
{ "icon_size", "i", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "done", "", xdg_toplevel_icon_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_icon_manager_v1_interface = {
|
||||
"xdg_toplevel_icon_manager_v1", 1,
|
||||
3, xdg_toplevel_icon_manager_v1_requests,
|
||||
2, xdg_toplevel_icon_manager_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_icon_v1_requests[] = {
|
||||
{ "destroy", "", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "set_name", "s", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "add_buffer", "oi", xdg_toplevel_icon_v1_types + 4 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_icon_v1_interface = {
|
||||
"xdg_toplevel_icon_v1", 1,
|
||||
3, xdg_toplevel_icon_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_SERVER_PROTOCOL_H
|
||||
#define XDG_TOPLEVEL_ICON_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_xdg_toplevel_icon_v1 The xdg_toplevel_icon_v1 protocol
|
||||
* protocol to assign icons to toplevels
|
||||
*
|
||||
* @section page_desc_xdg_toplevel_icon_v1 Description
|
||||
*
|
||||
* This protocol allows clients to set icons for their toplevel surfaces
|
||||
* either via the XDG icon stock (using an icon name), or from pixel data.
|
||||
*
|
||||
* A toplevel icon represents the individual toplevel (unlike the application
|
||||
* or launcher icon, which represents the application as a whole), and may be
|
||||
* shown in window switchers, window overviews and taskbars that list
|
||||
* individual windows.
|
||||
*
|
||||
* This document adheres to RFC 2119 when using words like "must",
|
||||
* "should", "may", etc.
|
||||
*
|
||||
* Warning! The protocol described in this file is currently in the testing
|
||||
* phase. Backward compatible changes may be added together with the
|
||||
* corresponding interface version bump. Backward incompatible changes can
|
||||
* only be done by creating a new major version of the extension.
|
||||
*
|
||||
* @section page_ifaces_xdg_toplevel_icon_v1 Interfaces
|
||||
* - @subpage page_iface_xdg_toplevel_icon_manager_v1 - interface to manage toplevel icons
|
||||
* - @subpage page_iface_xdg_toplevel_icon_v1 - a toplevel window icon
|
||||
* @section page_copyright_xdg_toplevel_icon_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2023-2024 Matthias Klumpp
|
||||
* Copyright © 2024 David Edmundson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_buffer;
|
||||
struct xdg_toplevel;
|
||||
struct xdg_toplevel_icon_manager_v1;
|
||||
struct xdg_toplevel_icon_v1;
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_MANAGER_V1_INTERFACE
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_xdg_toplevel_icon_manager_v1 xdg_toplevel_icon_manager_v1
|
||||
* @section page_iface_xdg_toplevel_icon_manager_v1_desc Description
|
||||
*
|
||||
* This interface allows clients to create toplevel window icons and set
|
||||
* them on toplevel windows to be displayed to the user.
|
||||
* @section page_iface_xdg_toplevel_icon_manager_v1_api API
|
||||
* See @ref iface_xdg_toplevel_icon_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_xdg_toplevel_icon_manager_v1 The xdg_toplevel_icon_manager_v1 interface
|
||||
*
|
||||
* This interface allows clients to create toplevel window icons and set
|
||||
* them on toplevel windows to be displayed to the user.
|
||||
*/
|
||||
extern const struct wl_interface xdg_toplevel_icon_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_INTERFACE
|
||||
#define XDG_TOPLEVEL_ICON_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_xdg_toplevel_icon_v1 xdg_toplevel_icon_v1
|
||||
* @section page_iface_xdg_toplevel_icon_v1_desc Description
|
||||
*
|
||||
* This interface defines a toplevel icon.
|
||||
* An icon can have a name, and multiple buffers.
|
||||
* In order to be applied, the icon must have either a name, or at least
|
||||
* one buffer assigned. Applying an empty icon (with no buffer or name) to
|
||||
* a toplevel should reset its icon to the default icon.
|
||||
*
|
||||
* It is up to compositor policy whether to prefer using a buffer or loading
|
||||
* an icon via its name. See 'set_name' and 'add_buffer' for details.
|
||||
* @section page_iface_xdg_toplevel_icon_v1_api API
|
||||
* See @ref iface_xdg_toplevel_icon_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_xdg_toplevel_icon_v1 The xdg_toplevel_icon_v1 interface
|
||||
*
|
||||
* This interface defines a toplevel icon.
|
||||
* An icon can have a name, and multiple buffers.
|
||||
* In order to be applied, the icon must have either a name, or at least
|
||||
* one buffer assigned. Applying an empty icon (with no buffer or name) to
|
||||
* a toplevel should reset its icon to the default icon.
|
||||
*
|
||||
* It is up to compositor policy whether to prefer using a buffer or loading
|
||||
* an icon via its name. See 'set_name' and 'add_buffer' for details.
|
||||
*/
|
||||
extern const struct wl_interface xdg_toplevel_icon_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
* @struct xdg_toplevel_icon_manager_v1_interface
|
||||
*/
|
||||
struct xdg_toplevel_icon_manager_v1_interface {
|
||||
/**
|
||||
* destroy the toplevel icon manager
|
||||
*
|
||||
* Destroy the toplevel icon manager. This does not destroy
|
||||
* objects created with the manager.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* create a new icon instance
|
||||
*
|
||||
* Creates a new icon object. This icon can then be attached to a
|
||||
* xdg_toplevel via the 'set_icon' request.
|
||||
*/
|
||||
void (*create_icon)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id);
|
||||
/**
|
||||
* set an icon on a toplevel window
|
||||
*
|
||||
* This request assigns the icon 'icon' to 'toplevel', or clears
|
||||
* the toplevel icon if 'icon' was null. This state is
|
||||
* double-buffered and is applied on the next wl_surface.commit of
|
||||
* the toplevel.
|
||||
*
|
||||
* After making this call, the xdg_toplevel_icon_v1 provided as
|
||||
* 'icon' can be destroyed by the client without 'toplevel' losing
|
||||
* its icon. The xdg_toplevel_icon_v1 is immutable from this point,
|
||||
* and any future attempts to change it must raise the
|
||||
* 'xdg_toplevel_icon_v1.immutable' protocol error.
|
||||
*
|
||||
* The compositor must set the toplevel icon from either the pixel
|
||||
* data the icon provides, or by loading a stock icon using the
|
||||
* icon name. See the description of 'xdg_toplevel_icon_v1' for
|
||||
* details.
|
||||
*
|
||||
* If 'icon' is set to null, the icon of the respective toplevel is
|
||||
* reset to its default icon (usually the icon of the application,
|
||||
* derived from its desktop-entry file, or a placeholder icon). If
|
||||
* this request is passed an icon with no pixel buffers or icon
|
||||
* name assigned, the icon must be reset just like if 'icon' was
|
||||
* null.
|
||||
* @param toplevel the toplevel to act on
|
||||
*/
|
||||
void (*set_icon)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *toplevel,
|
||||
struct wl_resource *icon);
|
||||
};
|
||||
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_ICON_SIZE 0
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_DONE 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_ICON_SIZE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_DONE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_CREATE_ICON_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_SET_ICON_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
* Sends an icon_size event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
* @param size the edge size of the square icon in surface-local coordinates, e.g. 64
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_manager_v1_send_icon_size(struct wl_resource *resource_, int32_t size)
|
||||
{
|
||||
wl_resource_post_event(resource_, XDG_TOPLEVEL_ICON_MANAGER_V1_ICON_SIZE, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
* Sends an done event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_manager_v1_send_done(struct wl_resource *resource_)
|
||||
{
|
||||
wl_resource_post_event(resource_, XDG_TOPLEVEL_ICON_MANAGER_V1_DONE);
|
||||
}
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_ERROR_ENUM
|
||||
#define XDG_TOPLEVEL_ICON_V1_ERROR_ENUM
|
||||
enum xdg_toplevel_icon_v1_error {
|
||||
/**
|
||||
* the provided buffer does not satisfy requirements
|
||||
*/
|
||||
XDG_TOPLEVEL_ICON_V1_ERROR_INVALID_BUFFER = 1,
|
||||
/**
|
||||
* the icon has already been assigned to a toplevel and must not be changed
|
||||
*/
|
||||
XDG_TOPLEVEL_ICON_V1_ERROR_IMMUTABLE = 2,
|
||||
/**
|
||||
* the provided buffer has been destroyed before the toplevel icon
|
||||
*/
|
||||
XDG_TOPLEVEL_ICON_V1_ERROR_NO_BUFFER = 3,
|
||||
};
|
||||
#endif /* XDG_TOPLEVEL_ICON_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_ERROR_ENUM_IS_VALID
|
||||
#define XDG_TOPLEVEL_ICON_V1_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
* Validate a xdg_toplevel_icon_v1 error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref xdg_toplevel_icon_v1_error
|
||||
*/
|
||||
static inline bool
|
||||
xdg_toplevel_icon_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case XDG_TOPLEVEL_ICON_V1_ERROR_INVALID_BUFFER:
|
||||
return version >= 1;
|
||||
case XDG_TOPLEVEL_ICON_V1_ERROR_IMMUTABLE:
|
||||
return version >= 1;
|
||||
case XDG_TOPLEVEL_ICON_V1_ERROR_NO_BUFFER:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* XDG_TOPLEVEL_ICON_V1_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
* @struct xdg_toplevel_icon_v1_interface
|
||||
*/
|
||||
struct xdg_toplevel_icon_v1_interface {
|
||||
/**
|
||||
* destroy the icon object
|
||||
*
|
||||
* Destroys the 'xdg_toplevel_icon_v1' object. The icon must
|
||||
* still remain set on every toplevel it was assigned to, until the
|
||||
* toplevel icon is reset explicitly.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* set an icon name
|
||||
*
|
||||
* This request assigns an icon name to this icon. Any previously
|
||||
* set name is overridden.
|
||||
*
|
||||
* The compositor must resolve 'icon_name' according to the lookup
|
||||
* rules described in the XDG icon theme specification[1] using the
|
||||
* environment's current icon theme.
|
||||
*
|
||||
* If the compositor does not support icon names or cannot resolve
|
||||
* 'icon_name' according to the XDG icon theme specification it
|
||||
* must fall back to using pixel buffer data instead.
|
||||
*
|
||||
* If this request is made after the icon has been assigned to a
|
||||
* toplevel via 'set_icon', an 'immutable' error must be raised.
|
||||
*
|
||||
* [1]:
|
||||
* https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
|
||||
*/
|
||||
void (*set_name)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
const char *icon_name);
|
||||
/**
|
||||
* add icon data from a pixel buffer
|
||||
*
|
||||
* This request adds pixel data supplied as wl_buffer to the
|
||||
* icon.
|
||||
*
|
||||
* The client should add pixel data for all icon sizes and scales
|
||||
* that it can provide, or which are explicitly requested by the
|
||||
* compositor via 'icon_size' events on
|
||||
* xdg_toplevel_icon_manager_v1.
|
||||
*
|
||||
* The wl_buffer supplying pixel data as 'buffer' must be backed by
|
||||
* wl_shm and must be a square (width and height being equal). If
|
||||
* any of these buffer requirements are not fulfilled, a
|
||||
* 'invalid_buffer' error must be raised.
|
||||
*
|
||||
* If this icon instance already has a buffer of the same size and
|
||||
* scale from a previous 'add_buffer' request, data from the last
|
||||
* request overrides the preexisting pixel data.
|
||||
*
|
||||
* The wl_buffer must be kept alive for as long as the
|
||||
* xdg_toplevel_icon it is associated with is not destroyed,
|
||||
* otherwise a 'no_buffer' error is raised. The buffer contents
|
||||
* must not be modified after it was assigned to the icon. As a
|
||||
* result, the region of the wl_shm_pool's backing storage used for
|
||||
* the wl_buffer must not be modified after this request is sent.
|
||||
* The wl_buffer.release event is unused.
|
||||
*
|
||||
* If this request is made after the icon has been assigned to a
|
||||
* toplevel via 'set_icon', an 'immutable' error must be raised.
|
||||
* @param scale the scaling factor of the icon, e.g. 1
|
||||
*/
|
||||
void (*add_buffer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *buffer,
|
||||
int32_t scale);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_V1_SET_NAME_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_V1_ADD_BUFFER_SINCE_VERSION 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,747 @@
|
||||
/*
|
||||
* Copyright © 2008 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WAYLAND_SERVER_CORE_H
|
||||
#define WAYLAND_SERVER_CORE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "wayland-util.h"
|
||||
#include "wayland-version.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
WL_EVENT_READABLE = 0x01,
|
||||
WL_EVENT_WRITABLE = 0x02,
|
||||
WL_EVENT_HANGUP = 0x04,
|
||||
WL_EVENT_ERROR = 0x08
|
||||
};
|
||||
|
||||
/** File descriptor dispatch function type
|
||||
*
|
||||
* Functions of this type are used as callbacks for file descriptor events.
|
||||
*
|
||||
* \param fd The file descriptor delivering the event.
|
||||
* \param mask Describes the kind of the event as a bitwise-or of:
|
||||
* \c WL_EVENT_READABLE, \c WL_EVENT_WRITABLE, \c WL_EVENT_HANGUP,
|
||||
* \c WL_EVENT_ERROR.
|
||||
* \param data The user data argument of the related wl_event_loop_add_fd()
|
||||
* call.
|
||||
* \return If the event source is registered for re-check with
|
||||
* wl_event_source_check(): 0 for all done, 1 for needing a re-check.
|
||||
* If not registered, the return value is ignored and should be zero.
|
||||
*
|
||||
* \sa wl_event_loop_add_fd()
|
||||
* \memberof wl_event_source
|
||||
*/
|
||||
typedef int (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
|
||||
|
||||
/** Timer dispatch function type
|
||||
*
|
||||
* Functions of this type are used as callbacks for timer expiry.
|
||||
*
|
||||
* \param data The user data argument of the related wl_event_loop_add_timer()
|
||||
* call.
|
||||
* \return If the event source is registered for re-check with
|
||||
* wl_event_source_check(): 0 for all done, 1 for needing a re-check.
|
||||
* If not registered, the return value is ignored and should be zero.
|
||||
*
|
||||
* \sa wl_event_loop_add_timer()
|
||||
* \memberof wl_event_source
|
||||
*/
|
||||
typedef int (*wl_event_loop_timer_func_t)(void *data);
|
||||
|
||||
/** Signal dispatch function type
|
||||
*
|
||||
* Functions of this type are used as callbacks for (POSIX) signals.
|
||||
*
|
||||
* \param signal_number
|
||||
* \param data The user data argument of the related wl_event_loop_add_signal()
|
||||
* call.
|
||||
* \return If the event source is registered for re-check with
|
||||
* wl_event_source_check(): 0 for all done, 1 for needing a re-check.
|
||||
* If not registered, the return value is ignored and should be zero.
|
||||
*
|
||||
* \sa wl_event_loop_add_signal()
|
||||
* \memberof wl_event_source
|
||||
*/
|
||||
typedef int (*wl_event_loop_signal_func_t)(int signal_number, void *data);
|
||||
|
||||
/** Idle task function type
|
||||
*
|
||||
* Functions of this type are used as callbacks before blocking in
|
||||
* wl_event_loop_dispatch().
|
||||
*
|
||||
* \param data The user data argument of the related wl_event_loop_add_idle()
|
||||
* call.
|
||||
*
|
||||
* \sa wl_event_loop_add_idle() wl_event_loop_dispatch()
|
||||
* \memberof wl_event_source
|
||||
*/
|
||||
typedef void (*wl_event_loop_idle_func_t)(void *data);
|
||||
|
||||
/** \struct wl_event_loop
|
||||
*
|
||||
* \brief An event loop context
|
||||
*
|
||||
* Usually you create an event loop context, add sources to it, and call
|
||||
* wl_event_loop_dispatch() in a loop to process events.
|
||||
*
|
||||
* \sa wl_event_source
|
||||
*/
|
||||
|
||||
/** \struct wl_event_source
|
||||
*
|
||||
* \brief An abstract event source
|
||||
*
|
||||
* This is the generic type for fd, timer, signal, and idle sources.
|
||||
* Functions that operate on specific source types must not be used with
|
||||
* a different type, even if the function signature allows it.
|
||||
*/
|
||||
|
||||
struct wl_event_loop *
|
||||
wl_event_loop_create(void);
|
||||
|
||||
void
|
||||
wl_event_loop_destroy(struct wl_event_loop *loop);
|
||||
|
||||
struct wl_event_source *
|
||||
wl_event_loop_add_fd(struct wl_event_loop *loop,
|
||||
int fd, uint32_t mask,
|
||||
wl_event_loop_fd_func_t func,
|
||||
void *data);
|
||||
|
||||
int
|
||||
wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask);
|
||||
|
||||
struct wl_event_source *
|
||||
wl_event_loop_add_timer(struct wl_event_loop *loop,
|
||||
wl_event_loop_timer_func_t func,
|
||||
void *data);
|
||||
|
||||
struct wl_event_source *
|
||||
wl_event_loop_add_signal(struct wl_event_loop *loop,
|
||||
int signal_number,
|
||||
wl_event_loop_signal_func_t func,
|
||||
void *data);
|
||||
|
||||
int
|
||||
wl_event_source_timer_update(struct wl_event_source *source,
|
||||
int ms_delay);
|
||||
|
||||
int
|
||||
wl_event_source_remove(struct wl_event_source *source);
|
||||
|
||||
void
|
||||
wl_event_source_check(struct wl_event_source *source);
|
||||
|
||||
int
|
||||
wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout);
|
||||
|
||||
void
|
||||
wl_event_loop_dispatch_idle(struct wl_event_loop *loop);
|
||||
|
||||
struct wl_event_source *
|
||||
wl_event_loop_add_idle(struct wl_event_loop *loop,
|
||||
wl_event_loop_idle_func_t func,
|
||||
void *data);
|
||||
|
||||
int
|
||||
wl_event_loop_get_fd(struct wl_event_loop *loop);
|
||||
|
||||
struct wl_listener;
|
||||
|
||||
typedef void (*wl_notify_func_t)(struct wl_listener *listener, void *data);
|
||||
|
||||
void
|
||||
wl_event_loop_add_destroy_listener(struct wl_event_loop *loop,
|
||||
struct wl_listener *listener);
|
||||
|
||||
struct wl_listener *
|
||||
wl_event_loop_get_destroy_listener(struct wl_event_loop *loop,
|
||||
wl_notify_func_t notify);
|
||||
|
||||
struct wl_display *
|
||||
wl_display_create(void);
|
||||
|
||||
void
|
||||
wl_display_destroy(struct wl_display *display);
|
||||
|
||||
struct wl_event_loop *
|
||||
wl_display_get_event_loop(struct wl_display *display);
|
||||
|
||||
int
|
||||
wl_display_add_socket(struct wl_display *display, const char *name);
|
||||
|
||||
const char *
|
||||
wl_display_add_socket_auto(struct wl_display *display);
|
||||
|
||||
int
|
||||
wl_display_add_socket_fd(struct wl_display *display, int sock_fd);
|
||||
|
||||
int
|
||||
wl_display_remove_socket_fd(struct wl_display *display, int sock_fd);
|
||||
|
||||
void
|
||||
wl_display_terminate(struct wl_display *display);
|
||||
|
||||
void
|
||||
wl_display_run(struct wl_display *display);
|
||||
|
||||
void
|
||||
wl_display_flush_clients(struct wl_display *display);
|
||||
|
||||
void
|
||||
wl_display_destroy_clients(struct wl_display *display);
|
||||
|
||||
void
|
||||
wl_display_set_default_max_buffer_size(struct wl_display *display,
|
||||
size_t max_buffer_size);
|
||||
|
||||
struct wl_client;
|
||||
struct wl_global;
|
||||
|
||||
typedef void (*wl_global_bind_func_t)(struct wl_client *client, void *data,
|
||||
uint32_t version, uint32_t id);
|
||||
|
||||
typedef void (*wl_global_withdrawn_func_t)(struct wl_global *global);
|
||||
|
||||
uint32_t
|
||||
wl_display_get_serial(const struct wl_display *display);
|
||||
|
||||
uint32_t
|
||||
wl_display_next_serial(struct wl_display *display);
|
||||
|
||||
void
|
||||
wl_display_add_destroy_listener(struct wl_display *display,
|
||||
struct wl_listener *listener);
|
||||
|
||||
void
|
||||
wl_display_add_client_created_listener(struct wl_display *display,
|
||||
struct wl_listener *listener);
|
||||
|
||||
struct wl_listener *
|
||||
wl_display_get_destroy_listener(struct wl_display *display,
|
||||
wl_notify_func_t notify);
|
||||
|
||||
struct wl_global *
|
||||
wl_global_create(struct wl_display *display,
|
||||
const struct wl_interface *interface,
|
||||
int version,
|
||||
void *data, wl_global_bind_func_t bind);
|
||||
|
||||
void
|
||||
wl_global_remove(struct wl_global *global);
|
||||
|
||||
void
|
||||
wl_global_set_withdrawn_listener(struct wl_global *global,
|
||||
wl_global_withdrawn_func_t func);
|
||||
|
||||
void
|
||||
wl_global_destroy(struct wl_global *global);
|
||||
|
||||
/** A filter function for wl_global objects
|
||||
*
|
||||
* \param client The client object
|
||||
* \param global The global object to show or hide
|
||||
* \param data The user data pointer
|
||||
*
|
||||
* A filter function enables the server to decide which globals to
|
||||
* advertise to each client.
|
||||
*
|
||||
* When a wl_global filter is set, the given callback function will be
|
||||
* called during wl_global advertisement and binding.
|
||||
*
|
||||
* This function should return true if the global object should be made
|
||||
* visible to the client or false otherwise.
|
||||
*/
|
||||
typedef bool (*wl_display_global_filter_func_t)(const struct wl_client *client,
|
||||
const struct wl_global *global,
|
||||
void *data);
|
||||
|
||||
void
|
||||
wl_display_set_global_filter(struct wl_display *display,
|
||||
wl_display_global_filter_func_t filter,
|
||||
void *data);
|
||||
|
||||
const struct wl_interface *
|
||||
wl_global_get_interface(const struct wl_global *global);
|
||||
|
||||
uint32_t
|
||||
wl_global_get_name(const struct wl_global *global,
|
||||
const struct wl_client *client);
|
||||
|
||||
uint32_t
|
||||
wl_global_get_version(const struct wl_global *global);
|
||||
|
||||
struct wl_display *
|
||||
wl_global_get_display(const struct wl_global *global);
|
||||
|
||||
void *
|
||||
wl_global_get_user_data(const struct wl_global *global);
|
||||
|
||||
void
|
||||
wl_global_set_user_data(struct wl_global *global, void *data);
|
||||
|
||||
struct wl_client *
|
||||
wl_client_create(struct wl_display *display, int fd);
|
||||
|
||||
struct wl_list *
|
||||
wl_display_get_client_list(struct wl_display *display);
|
||||
|
||||
struct wl_list *
|
||||
wl_client_get_link(struct wl_client *client);
|
||||
|
||||
struct wl_client *
|
||||
wl_client_from_link(struct wl_list *link);
|
||||
|
||||
/** Iterate over a list of clients. */
|
||||
#define wl_client_for_each(client, list) \
|
||||
for (client = wl_client_from_link((list)->next); \
|
||||
wl_client_get_link(client) != (list); \
|
||||
client = wl_client_from_link(wl_client_get_link(client)->next))
|
||||
|
||||
void
|
||||
wl_client_destroy(struct wl_client *client);
|
||||
|
||||
void
|
||||
wl_client_flush(struct wl_client *client);
|
||||
|
||||
void
|
||||
wl_client_get_credentials(const struct wl_client *client,
|
||||
pid_t *pid, uid_t *uid, gid_t *gid);
|
||||
|
||||
int
|
||||
wl_client_get_fd(struct wl_client *client);
|
||||
|
||||
void
|
||||
wl_client_add_destroy_listener(struct wl_client *client,
|
||||
struct wl_listener *listener);
|
||||
|
||||
struct wl_listener *
|
||||
wl_client_get_destroy_listener(struct wl_client *client,
|
||||
wl_notify_func_t notify);
|
||||
|
||||
void
|
||||
wl_client_add_destroy_late_listener(struct wl_client *client,
|
||||
struct wl_listener *listener);
|
||||
|
||||
struct wl_listener *
|
||||
wl_client_get_destroy_late_listener(struct wl_client *client,
|
||||
wl_notify_func_t notify);
|
||||
|
||||
struct wl_resource *
|
||||
wl_client_get_object(struct wl_client *client, uint32_t id);
|
||||
|
||||
void
|
||||
wl_client_post_no_memory(struct wl_client *client);
|
||||
|
||||
void
|
||||
wl_client_post_implementation_error(struct wl_client *client,
|
||||
const char* msg, ...) WL_PRINTF(2,3);
|
||||
|
||||
void
|
||||
wl_client_add_resource_created_listener(struct wl_client *client,
|
||||
struct wl_listener *listener);
|
||||
|
||||
/** Callback function type for wl_client_for_each_resource() */
|
||||
typedef enum wl_iterator_result (*wl_client_for_each_resource_iterator_func_t)(
|
||||
struct wl_resource *resource,
|
||||
void *user_data);
|
||||
|
||||
void
|
||||
wl_client_for_each_resource(struct wl_client *client,
|
||||
wl_client_for_each_resource_iterator_func_t iterator,
|
||||
void *user_data);
|
||||
|
||||
typedef void (*wl_user_data_destroy_func_t)(void *data);
|
||||
|
||||
void
|
||||
wl_client_set_user_data(struct wl_client *client,
|
||||
void *data,
|
||||
wl_user_data_destroy_func_t dtor);
|
||||
|
||||
void *
|
||||
wl_client_get_user_data(struct wl_client *client);
|
||||
|
||||
void
|
||||
wl_client_set_max_buffer_size(struct wl_client *client, size_t max_buffer_size);
|
||||
|
||||
/** \class wl_listener
|
||||
*
|
||||
* \brief A single listener for Wayland signals
|
||||
*
|
||||
* wl_listener provides the means to listen for wl_signal notifications. Many
|
||||
* Wayland objects use wl_listener for notification of significant events like
|
||||
* object destruction.
|
||||
*
|
||||
* Clients should create wl_listener objects manually and can register them as
|
||||
* listeners to signals using wl_signal_add(), assuming the signal is
|
||||
* directly accessible. For opaque structs like wl_event_loop, adding a
|
||||
* listener should be done through provided accessor methods. A listener can
|
||||
* only listen to one signal at a time.
|
||||
*
|
||||
* \code
|
||||
* struct wl_listener your_listener;
|
||||
*
|
||||
* your_listener.notify = your_callback_method;
|
||||
*
|
||||
* // Direct access
|
||||
* wl_signal_add(&some_object->destroy_signal, &your_listener);
|
||||
*
|
||||
* // Accessor access
|
||||
* wl_event_loop *loop = ...;
|
||||
* wl_event_loop_add_destroy_listener(loop, &your_listener);
|
||||
* \endcode
|
||||
*
|
||||
* If the listener is part of a larger struct, #wl_container_of can be used
|
||||
* to retrieve a pointer to it:
|
||||
*
|
||||
* \code
|
||||
* void your_listener(struct wl_listener *listener, void *data)
|
||||
* {
|
||||
* struct your_data *data;
|
||||
*
|
||||
* your_data = wl_container_of(listener, data, your_member_name);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* If you need to remove a listener from a signal, use wl_list_remove().
|
||||
*
|
||||
* \code
|
||||
* wl_list_remove(&your_listener.link);
|
||||
* \endcode
|
||||
*
|
||||
* \sa wl_signal
|
||||
*/
|
||||
struct wl_listener {
|
||||
/** Part of wl_signal::listener_list */
|
||||
struct wl_list link;
|
||||
|
||||
/** Callback function pointer */
|
||||
wl_notify_func_t notify;
|
||||
};
|
||||
|
||||
/** \class wl_signal
|
||||
*
|
||||
* \brief A source of a type of observable event
|
||||
*
|
||||
* Signals are recognized points where significant events can be observed.
|
||||
* Compositors as well as the server can provide signals. Observers are
|
||||
* wl_listener's that are added through #wl_signal_add. Signals are emitted
|
||||
* using #wl_signal_emit, which will invoke all listeners until that
|
||||
* listener is removed by wl_list_remove() (or whenever the signal is
|
||||
* destroyed).
|
||||
*
|
||||
* \sa wl_listener for more information on using wl_signal
|
||||
*/
|
||||
struct wl_signal {
|
||||
struct wl_list listener_list;
|
||||
};
|
||||
|
||||
/** Initialize a new \ref wl_signal for use.
|
||||
*
|
||||
* \param signal The signal that will be initialized
|
||||
*
|
||||
* \memberof wl_signal
|
||||
*/
|
||||
static inline void
|
||||
wl_signal_init(struct wl_signal *signal)
|
||||
{
|
||||
wl_list_init(&signal->listener_list);
|
||||
}
|
||||
|
||||
/** Add the specified listener to this signal.
|
||||
*
|
||||
* \param signal The signal that will emit events to the listener
|
||||
* \param listener The listener to add
|
||||
*
|
||||
* \memberof wl_signal
|
||||
*/
|
||||
static inline void
|
||||
wl_signal_add(struct wl_signal *signal, struct wl_listener *listener)
|
||||
{
|
||||
wl_list_insert(signal->listener_list.prev, &listener->link);
|
||||
}
|
||||
|
||||
/** Gets the listener struct for the specified callback.
|
||||
*
|
||||
* \param signal The signal that contains the specified listener
|
||||
* \param notify The listener that is the target of this search
|
||||
* \return the list item that corresponds to the specified listener, or NULL
|
||||
* if none was found
|
||||
*
|
||||
* \memberof wl_signal
|
||||
*/
|
||||
static inline struct wl_listener *
|
||||
wl_signal_get(struct wl_signal *signal, wl_notify_func_t notify)
|
||||
{
|
||||
struct wl_listener *l;
|
||||
|
||||
wl_list_for_each(l, &signal->listener_list, link)
|
||||
if (l->notify == notify)
|
||||
return l;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Emits this signal, notifying all registered listeners.
|
||||
*
|
||||
* \param signal The signal object that will emit the signal
|
||||
* \param data The data that will be emitted with the signal
|
||||
*
|
||||
* \memberof wl_signal
|
||||
*/
|
||||
static inline void
|
||||
wl_signal_emit(struct wl_signal *signal, void *data)
|
||||
{
|
||||
struct wl_listener *l, *next;
|
||||
|
||||
wl_list_for_each_safe(l, next, &signal->listener_list, link)
|
||||
l->notify(l, data);
|
||||
}
|
||||
|
||||
void
|
||||
wl_signal_emit_mutable(struct wl_signal *signal, void *data);
|
||||
|
||||
typedef void (*wl_resource_destroy_func_t)(struct wl_resource *resource);
|
||||
|
||||
/*
|
||||
* Post an event to the client's object referred to by 'resource'.
|
||||
* 'opcode' is the event number generated from the protocol XML
|
||||
* description (the event name). The variable arguments are the event
|
||||
* parameters, in the order they appear in the protocol XML specification.
|
||||
*
|
||||
* The variable arguments' types are:
|
||||
* - type=uint: uint32_t
|
||||
* - type=int: int32_t
|
||||
* - type=fixed: wl_fixed_t
|
||||
* - type=string: (const char *) to a nil-terminated string
|
||||
* - type=array: (struct wl_array *)
|
||||
* - type=fd: int, that is an open file descriptor
|
||||
* - type=new_id: (struct wl_object *) or (struct wl_resource *)
|
||||
* - type=object: (struct wl_object *) or (struct wl_resource *)
|
||||
*/
|
||||
void
|
||||
wl_resource_post_event(struct wl_resource *resource,
|
||||
uint32_t opcode, ...);
|
||||
|
||||
void
|
||||
wl_resource_post_event_array(struct wl_resource *resource,
|
||||
uint32_t opcode, union wl_argument *args);
|
||||
|
||||
void
|
||||
wl_resource_queue_event(struct wl_resource *resource,
|
||||
uint32_t opcode, ...);
|
||||
|
||||
void
|
||||
wl_resource_queue_event_array(struct wl_resource *resource,
|
||||
uint32_t opcode, union wl_argument *args);
|
||||
|
||||
void
|
||||
wl_resource_post_error_vargs(struct wl_resource *resource,
|
||||
uint32_t code, const char *msg, va_list argp);
|
||||
|
||||
void
|
||||
wl_resource_post_error(struct wl_resource *resource,
|
||||
uint32_t code, const char *msg, ...) WL_PRINTF(3, 4);
|
||||
|
||||
void
|
||||
wl_resource_post_no_memory(struct wl_resource *resource);
|
||||
|
||||
struct wl_display *
|
||||
wl_client_get_display(struct wl_client *client);
|
||||
|
||||
struct wl_resource *
|
||||
wl_resource_create(struct wl_client *client,
|
||||
const struct wl_interface *interface,
|
||||
int version, uint32_t id);
|
||||
|
||||
void
|
||||
wl_resource_set_implementation(struct wl_resource *resource,
|
||||
const void *implementation,
|
||||
void *data,
|
||||
wl_resource_destroy_func_t destroy);
|
||||
|
||||
void
|
||||
wl_resource_set_dispatcher(struct wl_resource *resource,
|
||||
wl_dispatcher_func_t dispatcher,
|
||||
const void *implementation,
|
||||
void *data,
|
||||
wl_resource_destroy_func_t destroy);
|
||||
|
||||
void
|
||||
wl_resource_destroy(struct wl_resource *resource);
|
||||
|
||||
uint32_t
|
||||
wl_resource_get_id(const struct wl_resource *resource);
|
||||
|
||||
struct wl_list *
|
||||
wl_resource_get_link(struct wl_resource *resource);
|
||||
|
||||
struct wl_resource *
|
||||
wl_resource_from_link(struct wl_list *resource);
|
||||
|
||||
struct wl_resource *
|
||||
wl_resource_find_for_client(struct wl_list *list, struct wl_client *client);
|
||||
|
||||
struct wl_client *
|
||||
wl_resource_get_client(struct wl_resource *resource);
|
||||
|
||||
void
|
||||
wl_resource_set_user_data(struct wl_resource *resource, void *data);
|
||||
|
||||
void *
|
||||
wl_resource_get_user_data(struct wl_resource *resource);
|
||||
|
||||
int
|
||||
wl_resource_get_version(const struct wl_resource *resource);
|
||||
|
||||
void
|
||||
wl_resource_set_destructor(struct wl_resource *resource,
|
||||
wl_resource_destroy_func_t destroy);
|
||||
|
||||
int
|
||||
wl_resource_instance_of(struct wl_resource *resource,
|
||||
const struct wl_interface *interface,
|
||||
const void *implementation);
|
||||
|
||||
const char *
|
||||
wl_resource_get_class(const struct wl_resource *resource);
|
||||
|
||||
const struct wl_interface *
|
||||
wl_resource_get_interface(struct wl_resource *resource);
|
||||
|
||||
void
|
||||
wl_resource_add_destroy_listener(struct wl_resource *resource,
|
||||
struct wl_listener *listener);
|
||||
|
||||
struct wl_listener *
|
||||
wl_resource_get_destroy_listener(struct wl_resource *resource,
|
||||
wl_notify_func_t notify);
|
||||
|
||||
#define wl_resource_for_each(resource, list) \
|
||||
for (resource = 0, resource = wl_resource_from_link((list)->next); \
|
||||
wl_resource_get_link(resource) != (list); \
|
||||
resource = wl_resource_from_link(wl_resource_get_link(resource)->next))
|
||||
|
||||
#define wl_resource_for_each_safe(resource, tmp, list) \
|
||||
for (resource = 0, tmp = 0, \
|
||||
resource = wl_resource_from_link((list)->next), \
|
||||
tmp = wl_resource_from_link((list)->next->next); \
|
||||
wl_resource_get_link(resource) != (list); \
|
||||
resource = tmp, \
|
||||
tmp = wl_resource_from_link(wl_resource_get_link(resource)->next))
|
||||
|
||||
struct wl_shm_buffer *
|
||||
wl_shm_buffer_get(struct wl_resource *resource);
|
||||
|
||||
void
|
||||
wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer);
|
||||
|
||||
void
|
||||
wl_shm_buffer_end_access(struct wl_shm_buffer *buffer);
|
||||
|
||||
void *
|
||||
wl_shm_buffer_get_data(struct wl_shm_buffer *buffer);
|
||||
|
||||
int32_t
|
||||
wl_shm_buffer_get_stride(const struct wl_shm_buffer *buffer);
|
||||
|
||||
uint32_t
|
||||
wl_shm_buffer_get_format(const struct wl_shm_buffer *buffer);
|
||||
|
||||
int32_t
|
||||
wl_shm_buffer_get_width(const struct wl_shm_buffer *buffer);
|
||||
|
||||
int32_t
|
||||
wl_shm_buffer_get_height(const struct wl_shm_buffer *buffer);
|
||||
|
||||
struct wl_shm_buffer *
|
||||
wl_shm_buffer_ref(struct wl_shm_buffer *buffer);
|
||||
|
||||
void
|
||||
wl_shm_buffer_unref(struct wl_shm_buffer *buffer);
|
||||
|
||||
struct wl_shm_pool *
|
||||
wl_shm_buffer_ref_pool(struct wl_shm_buffer *buffer);
|
||||
|
||||
void
|
||||
wl_shm_pool_unref(struct wl_shm_pool *pool);
|
||||
|
||||
int
|
||||
wl_display_init_shm(struct wl_display *display);
|
||||
|
||||
uint32_t *
|
||||
wl_display_add_shm_format(struct wl_display *display, uint32_t format);
|
||||
|
||||
WL_DEPRECATED
|
||||
struct wl_shm_buffer *
|
||||
wl_shm_buffer_create(struct wl_client *client,
|
||||
uint32_t id, int32_t width, int32_t height,
|
||||
int32_t stride, uint32_t format);
|
||||
|
||||
void
|
||||
wl_log_set_handler_server(wl_log_func_t handler);
|
||||
|
||||
enum wl_protocol_logger_type {
|
||||
WL_PROTOCOL_LOGGER_REQUEST,
|
||||
WL_PROTOCOL_LOGGER_EVENT,
|
||||
};
|
||||
|
||||
struct wl_protocol_logger_message {
|
||||
struct wl_resource *resource;
|
||||
int message_opcode;
|
||||
const struct wl_message *message;
|
||||
int arguments_count;
|
||||
const union wl_argument *arguments;
|
||||
};
|
||||
|
||||
/** Callback function type for wl_display_add_protocol_logger() */
|
||||
typedef void (*wl_protocol_logger_func_t)(void *user_data,
|
||||
enum wl_protocol_logger_type direction,
|
||||
const struct wl_protocol_logger_message *message);
|
||||
|
||||
struct wl_protocol_logger *
|
||||
wl_display_add_protocol_logger(struct wl_display *display,
|
||||
wl_protocol_logger_func_t, void *user_data);
|
||||
|
||||
void
|
||||
wl_protocol_logger_destroy(struct wl_protocol_logger *logger);
|
||||
|
||||
void
|
||||
wl_fixes_handle_ack_global_remove(struct wl_resource *fixes_resource,
|
||||
struct wl_resource *registry_resource,
|
||||
uint32_t global_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright © 2008 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* \brief Include the server API, deprecations and protocol C API.
|
||||
*
|
||||
* \warning Use of this header file is discouraged. Prefer including
|
||||
* wayland-server-core.h instead, which does not include the
|
||||
* server protocol header and as such only defines the library
|
||||
* API, excluding the deprecated API below.
|
||||
*/
|
||||
|
||||
#ifndef WAYLAND_SERVER_H
|
||||
#define WAYLAND_SERVER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "wayland-server-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The user can set this macro to hide the wl_object, wl_resource and wl_buffer
|
||||
* objects alongside the associated API.
|
||||
*
|
||||
* The structs were meant to be opaque, although we missed that in the early days.
|
||||
*
|
||||
* NOTE: the list of structs, functions, etc in this section MUST NEVER GROW.
|
||||
* Otherwise we will break forward compatibility and applications that used to
|
||||
* build fine will no longer be able to do so.
|
||||
*/
|
||||
#ifndef WL_HIDE_DEPRECATED
|
||||
|
||||
struct wl_object {
|
||||
const struct wl_interface *interface;
|
||||
const void *implementation;
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
struct wl_resource {
|
||||
struct wl_object object;
|
||||
wl_resource_destroy_func_t destroy;
|
||||
struct wl_list link;
|
||||
struct wl_signal destroy_signal;
|
||||
struct wl_client *client;
|
||||
void *data;
|
||||
};
|
||||
|
||||
WL_DEPRECATED
|
||||
uint32_t
|
||||
wl_client_add_resource(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
|
||||
WL_DEPRECATED
|
||||
struct wl_resource *
|
||||
wl_client_add_object(struct wl_client *client,
|
||||
const struct wl_interface *interface,
|
||||
const void *implementation,
|
||||
uint32_t id, void *data);
|
||||
|
||||
WL_DEPRECATED
|
||||
struct wl_resource *
|
||||
wl_client_new_object(struct wl_client *client,
|
||||
const struct wl_interface *interface,
|
||||
const void *implementation, void *data);
|
||||
|
||||
WL_DEPRECATED
|
||||
struct wl_global *
|
||||
wl_display_add_global(struct wl_display *display,
|
||||
const struct wl_interface *interface,
|
||||
void *data,
|
||||
wl_global_bind_func_t bind);
|
||||
|
||||
WL_DEPRECATED
|
||||
void
|
||||
wl_display_remove_global(struct wl_display *display,
|
||||
struct wl_global *global);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "wayland-server-protocol.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,768 @@
|
||||
/*
|
||||
* Copyright © 2008 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/** \file wayland-util.h
|
||||
*
|
||||
* \brief Utility classes, functions, and macros.
|
||||
*/
|
||||
|
||||
#ifndef WAYLAND_UTIL_H
|
||||
#define WAYLAND_UTIL_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Visibility attribute */
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_EXPORT __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define WL_EXPORT
|
||||
#endif
|
||||
|
||||
/** Deprecated attribute */
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201402L)
|
||||
#define WL_DEPRECATED [[deprecated]]
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_DEPRECATED __attribute__ ((deprecated))
|
||||
#else
|
||||
#define WL_DEPRECATED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Printf-style argument attribute
|
||||
*
|
||||
* \param x Ordinality of the format string argument
|
||||
* \param y Ordinality of the argument to check against the format string
|
||||
*
|
||||
* \sa https://gcc.gnu.org/onlinedocs/gcc-3.2.1/gcc/Function-Attributes.html
|
||||
*/
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_PRINTF(x, y) __attribute__((__format__(__printf__, x, y)))
|
||||
#else
|
||||
#define WL_PRINTF(x, y)
|
||||
#endif
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
|
||||
#define WL_TYPEOF(expr) typeof(expr)
|
||||
#else
|
||||
#define WL_TYPEOF(expr) __typeof__(expr)
|
||||
#endif
|
||||
|
||||
/** \class wl_object
|
||||
*
|
||||
* \brief A protocol object.
|
||||
*
|
||||
* A `wl_object` is an opaque struct identifying the protocol object
|
||||
* underlying a `wl_proxy` or `wl_resource`.
|
||||
*
|
||||
* \note Functions accessing a `wl_object` are not normally used by client code.
|
||||
* Clients should normally use the higher level interface generated by the
|
||||
* scanner to interact with compositor objects.
|
||||
*
|
||||
*/
|
||||
struct wl_object;
|
||||
|
||||
/**
|
||||
* The maximum size of a protocol message.
|
||||
*
|
||||
* If a message size exceeds this value, the connection will be dropped.
|
||||
* Servers will send an invalid_method error before disconnecting.
|
||||
*/
|
||||
#define WL_MAX_MESSAGE_SIZE 4096
|
||||
|
||||
/**
|
||||
* Protocol message signature
|
||||
*
|
||||
* A wl_message describes the signature of an actual protocol message, such as a
|
||||
* request or event, that adheres to the Wayland protocol wire format. The
|
||||
* protocol implementation uses a wl_message within its demarshal machinery for
|
||||
* decoding messages between a compositor and its clients. In a sense, a
|
||||
* wl_message is to a protocol message like a class is to an object.
|
||||
*
|
||||
* The `name` of a wl_message is the name of the corresponding protocol message.
|
||||
*
|
||||
* The `signature` is an ordered list of symbols representing the data types
|
||||
* of message arguments and, optionally, a protocol version and indicators for
|
||||
* nullability. A leading integer in the `signature` indicates the _since_
|
||||
* version of the protocol message. A `?` preceding a data type symbol indicates
|
||||
* that the following argument type is nullable. While it is a protocol violation
|
||||
* to send messages with non-nullable arguments set to `NULL`, event handlers in
|
||||
* clients might still get called with non-nullable object arguments set to
|
||||
* `NULL`. This can happen when the client destroyed the object being used as
|
||||
* argument on its side and an event referencing that object was sent before the
|
||||
* server knew about its destruction. As this race cannot be prevented, clients
|
||||
* should - as a general rule - program their event handlers such that they can
|
||||
* handle object arguments declared non-nullable being `NULL` gracefully.
|
||||
*
|
||||
* When no arguments accompany a message, `signature` is an empty string.
|
||||
*
|
||||
* Symbols:
|
||||
*
|
||||
* * `i`: int
|
||||
* * `u`: uint
|
||||
* * `f`: fixed
|
||||
* * `s`: string
|
||||
* * `o`: object
|
||||
* * `n`: new_id
|
||||
* * `a`: array
|
||||
* * `h`: fd
|
||||
* * `?`: following argument (`o` or `s`) is nullable
|
||||
*
|
||||
* While demarshaling primitive arguments is straightforward, when demarshaling
|
||||
* messages containing `object` or `new_id` arguments, the protocol
|
||||
* implementation often must determine the type of the object. The `types` of a
|
||||
* wl_message is an array of wl_interface references that correspond to `o` and
|
||||
* `n` arguments in `signature`, with `NULL` placeholders for arguments with
|
||||
* non-object types.
|
||||
*
|
||||
* Consider the protocol event wl_display `delete_id` that has a single `uint`
|
||||
* argument. The wl_message is:
|
||||
*
|
||||
* \code
|
||||
* { "delete_id", "u", [NULL] }
|
||||
* \endcode
|
||||
*
|
||||
* Here, the message `name` is `"delete_id"`, the `signature` is `"u"`, and the
|
||||
* argument `types` is `[NULL]`, indicating that the `uint` argument has no
|
||||
* corresponding wl_interface since it is a primitive argument.
|
||||
*
|
||||
* In contrast, consider a `wl_foo` interface supporting protocol request `bar`
|
||||
* that has existed since version 2, and has two arguments: a `uint` and an
|
||||
* object of type `wl_baz_interface` that may be `NULL`. Such a `wl_message`
|
||||
* might be:
|
||||
*
|
||||
* \code
|
||||
* { "bar", "2u?o", [NULL, &wl_baz_interface] }
|
||||
* \endcode
|
||||
*
|
||||
* Here, the message `name` is `"bar"`, and the `signature` is `"2u?o"`. Notice
|
||||
* how the `2` indicates the protocol version, the `u` indicates the first
|
||||
* argument type is `uint`, and the `?o` indicates that the second argument
|
||||
* is an object that may be `NULL`. Lastly, the argument `types` array indicates
|
||||
* that no wl_interface corresponds to the first argument, while the type
|
||||
* `wl_baz_interface` corresponds to the second argument.
|
||||
*
|
||||
* \sa wl_argument
|
||||
* \sa wl_interface
|
||||
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Wire-Format">Wire Format</a>
|
||||
*/
|
||||
struct wl_message {
|
||||
/** Message name */
|
||||
const char *name;
|
||||
/** Message signature */
|
||||
const char *signature;
|
||||
/** Object argument interfaces */
|
||||
const struct wl_interface **types;
|
||||
};
|
||||
|
||||
/**
|
||||
* Protocol object interface
|
||||
*
|
||||
* A wl_interface describes the API of a protocol object defined in the Wayland
|
||||
* protocol specification. The protocol implementation uses a wl_interface
|
||||
* within its marshalling machinery for encoding client requests.
|
||||
*
|
||||
* The `name` of a wl_interface is the name of the corresponding protocol
|
||||
* interface, and `version` represents the version of the interface. The members
|
||||
* `method_count` and `event_count` represent the number of `methods` (requests)
|
||||
* and `events` in the respective wl_message members.
|
||||
*
|
||||
* For example, consider a protocol interface `foo`, marked as version `1`, with
|
||||
* two requests and one event.
|
||||
*
|
||||
* \code{.xml}
|
||||
* <interface name="foo" version="1">
|
||||
* <request name="a"></request>
|
||||
* <request name="b"></request>
|
||||
* <event name="c"></event>
|
||||
* </interface>
|
||||
* \endcode
|
||||
*
|
||||
* Given two wl_message arrays `foo_requests` and `foo_events`, a wl_interface
|
||||
* for `foo` might be:
|
||||
*
|
||||
* \code
|
||||
* struct wl_interface foo_interface = {
|
||||
* "foo", 1,
|
||||
* 2, foo_requests,
|
||||
* 1, foo_events
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* \note The server side of the protocol may define interface <em>implementation
|
||||
* types</em> that incorporate the term `interface` in their name. Take
|
||||
* care to not confuse these server-side `struct`s with a wl_interface
|
||||
* variable whose name also ends in `interface`. For example, while the
|
||||
* server may define a type `struct wl_foo_interface`, the client may
|
||||
* define a `struct wl_interface wl_foo_interface`.
|
||||
*
|
||||
* \sa wl_message
|
||||
* \sa wl_proxy
|
||||
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Interfaces">Interfaces</a>
|
||||
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Versioning">Versioning</a>
|
||||
*/
|
||||
struct wl_interface {
|
||||
/** Interface name */
|
||||
const char *name;
|
||||
/** Interface version */
|
||||
int version;
|
||||
/** Number of methods (requests) */
|
||||
int method_count;
|
||||
/** Method (request) signatures */
|
||||
const struct wl_message *methods;
|
||||
/** Number of events */
|
||||
int event_count;
|
||||
/** Event signatures */
|
||||
const struct wl_message *events;
|
||||
};
|
||||
|
||||
/** \class wl_list
|
||||
*
|
||||
* \brief Doubly-linked list
|
||||
*
|
||||
* On its own, an instance of `struct wl_list` represents the sentinel head of
|
||||
* a doubly-linked list, and must be initialized using wl_list_init().
|
||||
* When empty, the list head's `next` and `prev` members point to the list head
|
||||
* itself, otherwise `next` references the first element in the list, and `prev`
|
||||
* refers to the last element in the list.
|
||||
*
|
||||
* Use the `struct wl_list` type to represent both the list head and the links
|
||||
* between elements within the list. Use wl_list_empty() to determine if the
|
||||
* list is empty in O(1).
|
||||
*
|
||||
* All elements in the list must be of the same type. The element type must have
|
||||
* a `struct wl_list` member, often named `link` by convention. Prior to
|
||||
* insertion, there is no need to initialize an element's `link` - invoking
|
||||
* wl_list_init() on an individual list element's `struct wl_list` member is
|
||||
* unnecessary if the very next operation is wl_list_insert(). However, a
|
||||
* common idiom is to initialize an element's `link` prior to removal - ensure
|
||||
* safety by invoking wl_list_init() before wl_list_remove().
|
||||
*
|
||||
* Consider a list reference `struct wl_list foo_list`, an element type as
|
||||
* `struct element`, and an element's link member as `struct wl_list link`.
|
||||
*
|
||||
* The following code initializes a list and adds three elements to it.
|
||||
*
|
||||
* \code
|
||||
* struct wl_list foo_list;
|
||||
*
|
||||
* struct element {
|
||||
* int foo;
|
||||
* struct wl_list link;
|
||||
* };
|
||||
* struct element e1, e2, e3;
|
||||
*
|
||||
* wl_list_init(&foo_list);
|
||||
* wl_list_insert(&foo_list, &e1.link); // e1 is the first element
|
||||
* wl_list_insert(&foo_list, &e2.link); // e2 is now the first element
|
||||
* wl_list_insert(&e2.link, &e3.link); // insert e3 after e2
|
||||
* \endcode
|
||||
*
|
||||
* The list now looks like <em>[e2, e3, e1]</em>.
|
||||
*
|
||||
* The `wl_list` API provides some iterator macros. For example, to iterate
|
||||
* a list in ascending order:
|
||||
*
|
||||
* \code
|
||||
* struct element *e;
|
||||
* wl_list_for_each(e, foo_list, link) {
|
||||
* do_something_with_element(e);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* See the documentation of each iterator for details.
|
||||
* \sa http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/list.h
|
||||
*/
|
||||
struct wl_list {
|
||||
/** Previous list element */
|
||||
struct wl_list *prev;
|
||||
/** Next list element */
|
||||
struct wl_list *next;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes the list.
|
||||
*
|
||||
* \param list List to initialize
|
||||
*
|
||||
* \memberof wl_list
|
||||
*/
|
||||
void
|
||||
wl_list_init(struct wl_list *list);
|
||||
|
||||
/**
|
||||
* Inserts an element into the list, after the element represented by \p list.
|
||||
* When \p list is a reference to the list itself (the head), set the containing
|
||||
* struct of \p elm as the first element in the list.
|
||||
*
|
||||
* \note If \p elm is already part of a list, inserting it again will lead to
|
||||
* list corruption.
|
||||
*
|
||||
* \param list List element after which the new element is inserted
|
||||
* \param elm Link of the containing struct to insert into the list
|
||||
*
|
||||
* \memberof wl_list
|
||||
*/
|
||||
void
|
||||
wl_list_insert(struct wl_list *list, struct wl_list *elm);
|
||||
|
||||
/**
|
||||
* Removes an element from the list.
|
||||
*
|
||||
* \note This operation leaves \p elm in an invalid state.
|
||||
*
|
||||
* \param elm Link of the containing struct to remove from the list
|
||||
*
|
||||
* \memberof wl_list
|
||||
*/
|
||||
void
|
||||
wl_list_remove(struct wl_list *elm);
|
||||
|
||||
/**
|
||||
* Determines the length of the list.
|
||||
*
|
||||
* \note This is an O(n) operation.
|
||||
*
|
||||
* \param list List whose length is to be determined
|
||||
*
|
||||
* \return Number of elements in the list
|
||||
*
|
||||
* \memberof wl_list
|
||||
*/
|
||||
int
|
||||
wl_list_length(const struct wl_list *list);
|
||||
|
||||
/**
|
||||
* Determines if the list is empty.
|
||||
*
|
||||
* \param list List whose emptiness is to be determined
|
||||
*
|
||||
* \return 1 if empty, or 0 if not empty
|
||||
*
|
||||
* \memberof wl_list
|
||||
*/
|
||||
int
|
||||
wl_list_empty(const struct wl_list *list);
|
||||
|
||||
/**
|
||||
* Inserts all of the elements of one list into another, after the element
|
||||
* represented by \p list.
|
||||
*
|
||||
* \note This leaves \p other in an invalid state.
|
||||
*
|
||||
* \param list List element after which the other list elements will be inserted
|
||||
* \param other List of elements to insert
|
||||
*
|
||||
* \memberof wl_list
|
||||
*/
|
||||
void
|
||||
wl_list_insert_list(struct wl_list *list, struct wl_list *other);
|
||||
|
||||
/**
|
||||
* Retrieves a pointer to a containing struct, given a member name.
|
||||
*
|
||||
* This macro allows "conversion" from a pointer to a member to its containing
|
||||
* struct. This is useful if you have a contained item like a wl_list,
|
||||
* wl_listener, or wl_signal, provided via a callback or other means, and would
|
||||
* like to retrieve the struct that contains it.
|
||||
*
|
||||
* To demonstrate, the following example retrieves a pointer to
|
||||
* `example_container` given only its `destroy_listener` member:
|
||||
*
|
||||
* \code
|
||||
* struct example_container {
|
||||
* struct wl_listener destroy_listener;
|
||||
* // other members...
|
||||
* };
|
||||
*
|
||||
* void example_container_destroy(struct wl_listener *listener, void *data)
|
||||
* {
|
||||
* struct example_container *ctr;
|
||||
*
|
||||
* ctr = wl_container_of(listener, ctr, destroy_listener);
|
||||
* // destroy ctr...
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \note `sample` need not be a valid pointer. A null or uninitialised pointer
|
||||
* is sufficient.
|
||||
*
|
||||
* \param ptr Valid pointer to the contained member
|
||||
* \param sample Pointer to a struct whose type contains \p ptr
|
||||
* \param member Named location of \p ptr within the \p sample type
|
||||
*
|
||||
* \return The container for the specified pointer
|
||||
*/
|
||||
#define wl_container_of(ptr, sample, member) \
|
||||
(WL_TYPEOF(sample))((char *)(ptr) - \
|
||||
offsetof(WL_TYPEOF(*sample), member))
|
||||
|
||||
/**
|
||||
* Iterates over a list.
|
||||
*
|
||||
* This macro expresses a for-each iterator for wl_list. Given a list and
|
||||
* wl_list link member name (often named `link` by convention), this macro
|
||||
* assigns each element in the list to \p pos, which can then be referenced in
|
||||
* a trailing code block. For example, given a wl_list of `struct message`
|
||||
* elements:
|
||||
*
|
||||
* \code
|
||||
* struct message {
|
||||
* char *contents;
|
||||
* wl_list link;
|
||||
* };
|
||||
*
|
||||
* struct wl_list *message_list;
|
||||
* // Assume message_list now "contains" many messages
|
||||
*
|
||||
* struct message *m;
|
||||
* wl_list_for_each(m, message_list, link) {
|
||||
* do_something_with_message(m);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \param pos Cursor that each list element will be assigned to
|
||||
* \param head Head of the list to iterate over
|
||||
* \param member Name of the link member within the element struct
|
||||
*
|
||||
* \relates wl_list
|
||||
*/
|
||||
#define wl_list_for_each(pos, head, member) \
|
||||
for (pos = wl_container_of((head)->next, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = wl_container_of(pos->member.next, pos, member))
|
||||
|
||||
/**
|
||||
* Iterates over a list, safe against removal of the list element.
|
||||
*
|
||||
* \note Only removal of the current element, \p pos, is safe. Removing
|
||||
* any other element during traversal may lead to a loop malfunction.
|
||||
*
|
||||
* \sa wl_list_for_each()
|
||||
*
|
||||
* \param pos Cursor that each list element will be assigned to
|
||||
* \param tmp Temporary pointer of the same type as \p pos
|
||||
* \param head Head of the list to iterate over
|
||||
* \param member Name of the link member within the element struct
|
||||
*
|
||||
* \relates wl_list
|
||||
*/
|
||||
#define wl_list_for_each_safe(pos, tmp, head, member) \
|
||||
for (pos = wl_container_of((head)->next, pos, member), \
|
||||
tmp = wl_container_of((pos)->member.next, tmp, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = wl_container_of(pos->member.next, tmp, member))
|
||||
|
||||
/**
|
||||
* Iterates backwards over a list.
|
||||
*
|
||||
* \sa wl_list_for_each()
|
||||
*
|
||||
* \param pos Cursor that each list element will be assigned to
|
||||
* \param head Head of the list to iterate over
|
||||
* \param member Name of the link member within the element struct
|
||||
*
|
||||
* \relates wl_list
|
||||
*/
|
||||
#define wl_list_for_each_reverse(pos, head, member) \
|
||||
for (pos = wl_container_of((head)->prev, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = wl_container_of(pos->member.prev, pos, member))
|
||||
|
||||
/**
|
||||
* Iterates backwards over a list, safe against removal of the list element.
|
||||
*
|
||||
* \note Only removal of the current element, \p pos, is safe. Removing
|
||||
* any other element during traversal may lead to a loop malfunction.
|
||||
*
|
||||
* \sa wl_list_for_each()
|
||||
*
|
||||
* \param pos Cursor that each list element will be assigned to
|
||||
* \param tmp Temporary pointer of the same type as \p pos
|
||||
* \param head Head of the list to iterate over
|
||||
* \param member Name of the link member within the element struct
|
||||
*
|
||||
* \relates wl_list
|
||||
*/
|
||||
#define wl_list_for_each_reverse_safe(pos, tmp, head, member) \
|
||||
for (pos = wl_container_of((head)->prev, pos, member), \
|
||||
tmp = wl_container_of((pos)->member.prev, tmp, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = wl_container_of(pos->member.prev, tmp, member))
|
||||
|
||||
/**
|
||||
* \class wl_array
|
||||
*
|
||||
* Dynamic array
|
||||
*
|
||||
* A wl_array is a dynamic array that can only grow until released. It is
|
||||
* intended for relatively small allocations whose size is variable or not known
|
||||
* in advance. While construction of a wl_array does not require all elements to
|
||||
* be of the same size, wl_array_for_each() does require all elements to have
|
||||
* the same type and size.
|
||||
*
|
||||
*/
|
||||
struct wl_array {
|
||||
/** Array size */
|
||||
size_t size;
|
||||
/** Allocated space */
|
||||
size_t alloc;
|
||||
/** Array data */
|
||||
void *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes the array.
|
||||
*
|
||||
* \param array Array to initialize
|
||||
*
|
||||
* \memberof wl_array
|
||||
*/
|
||||
void
|
||||
wl_array_init(struct wl_array *array);
|
||||
|
||||
/**
|
||||
* Releases the array data.
|
||||
*
|
||||
* \note Leaves the array in an invalid state.
|
||||
*
|
||||
* \param array Array whose data is to be released
|
||||
*
|
||||
* \memberof wl_array
|
||||
*/
|
||||
void
|
||||
wl_array_release(struct wl_array *array);
|
||||
|
||||
/**
|
||||
* Increases the size of the array by \p size bytes.
|
||||
*
|
||||
* \param array Array whose size is to be increased
|
||||
* \param size Number of bytes to increase the size of the array by
|
||||
*
|
||||
* \return A pointer to the beginning of the newly appended space, or NULL when
|
||||
* resizing fails.
|
||||
*
|
||||
* \memberof wl_array
|
||||
*/
|
||||
void *
|
||||
wl_array_add(struct wl_array *array, size_t size);
|
||||
|
||||
/**
|
||||
* Copies the contents of \p source to \p array.
|
||||
*
|
||||
* \param array Destination array to copy to
|
||||
* \param source Source array to copy from
|
||||
*
|
||||
* \return 0 on success, or -1 on failure
|
||||
*
|
||||
* \memberof wl_array
|
||||
*/
|
||||
int
|
||||
wl_array_copy(struct wl_array *array, struct wl_array *source);
|
||||
|
||||
/**
|
||||
* Iterates over an array.
|
||||
*
|
||||
* This macro expresses a for-each iterator for wl_array. It assigns each
|
||||
* element in the array to \p pos, which can then be referenced in a trailing
|
||||
* code block. \p pos must be a pointer to the array element type, and all
|
||||
* array elements must be of the same type and size.
|
||||
*
|
||||
* \param pos Cursor that each array element will be assigned to
|
||||
* \param array Array to iterate over
|
||||
*
|
||||
* \relates wl_array
|
||||
* \sa wl_list_for_each()
|
||||
*/
|
||||
#define wl_array_for_each(pos, array) \
|
||||
for (pos = (array)->data; \
|
||||
(array)->size != 0 && \
|
||||
(const char *) pos < ((const char *) (array)->data + (array)->size); \
|
||||
(pos)++)
|
||||
|
||||
/**
|
||||
* Fixed-point number
|
||||
*
|
||||
* A `wl_fixed_t` is a 24.8 signed fixed-point number with a sign bit, 23 bits
|
||||
* of integer precision and 8 bits of decimal precision. Consider `wl_fixed_t`
|
||||
* as an opaque struct with methods that facilitate conversion to and from
|
||||
* `double` and `int` types.
|
||||
*/
|
||||
typedef int32_t wl_fixed_t;
|
||||
|
||||
/**
|
||||
* Converts a fixed-point number to a floating-point number.
|
||||
*
|
||||
* \param f Fixed-point number to convert
|
||||
*
|
||||
* \return Floating-point representation of the fixed-point argument
|
||||
*/
|
||||
static inline double
|
||||
wl_fixed_to_double(wl_fixed_t f)
|
||||
{
|
||||
return f / 256.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a floating-point number to a fixed-point number.
|
||||
*
|
||||
* \param d Floating-point number to convert
|
||||
*
|
||||
* \return Fixed-point representation of the floating-point argument
|
||||
*/
|
||||
static inline wl_fixed_t
|
||||
wl_fixed_from_double(double d)
|
||||
{
|
||||
return (wl_fixed_t) (round(d * 256.0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a fixed-point number to an integer.
|
||||
*
|
||||
* \param f Fixed-point number to convert
|
||||
*
|
||||
* \return Integer component of the fixed-point argument
|
||||
*/
|
||||
static inline int
|
||||
wl_fixed_to_int(wl_fixed_t f)
|
||||
{
|
||||
return f / 256;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an integer to a fixed-point number.
|
||||
*
|
||||
* \param i Integer to convert
|
||||
*
|
||||
* \return Fixed-point representation of the integer argument
|
||||
*/
|
||||
static inline wl_fixed_t
|
||||
wl_fixed_from_int(int i)
|
||||
{
|
||||
return i * 256;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protocol message argument data types
|
||||
*
|
||||
* This union represents all of the argument types in the Wayland protocol wire
|
||||
* format. The protocol implementation uses wl_argument within its marshalling
|
||||
* machinery for dispatching messages between a client and a compositor.
|
||||
*
|
||||
* \sa wl_message
|
||||
* \sa wl_interface
|
||||
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-wire-Format">Wire Format</a>
|
||||
*/
|
||||
union wl_argument {
|
||||
int32_t i; /**< `int` */
|
||||
uint32_t u; /**< `uint` */
|
||||
wl_fixed_t f; /**< `fixed` */
|
||||
const char *s; /**< `string` */
|
||||
struct wl_object *o; /**< `object` */
|
||||
uint32_t n; /**< `new_id` */
|
||||
struct wl_array *a; /**< `array` */
|
||||
int32_t h; /**< `fd` */
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatcher function type alias
|
||||
*
|
||||
* A dispatcher is a function that handles the emitting of callbacks in client
|
||||
* code. For programs directly using the C library, this is done by using
|
||||
* libffi to call function pointers. When binding to languages other than C,
|
||||
* dispatchers provide a way to abstract the function calling process to be
|
||||
* friendlier to other function calling systems.
|
||||
*
|
||||
* A dispatcher takes five arguments: The first is the dispatcher-specific
|
||||
* implementation associated with the target object. The second is the object
|
||||
* upon which the callback is being invoked (either wl_proxy or wl_resource).
|
||||
* The third and fourth arguments are the opcode and the wl_message
|
||||
* corresponding to the callback. The final argument is an array of arguments
|
||||
* received from the other process via the wire protocol.
|
||||
*
|
||||
* \param user_data Dispatcher-specific implementation data
|
||||
* \param target Callback invocation target (wl_proxy or `wl_resource`)
|
||||
* \param opcode Callback opcode
|
||||
* \param msg Callback message signature
|
||||
* \param args Array of received arguments
|
||||
*
|
||||
* \return 0 on success, or -1 on failure
|
||||
*/
|
||||
typedef int (*wl_dispatcher_func_t)(const void *user_data, void *target,
|
||||
uint32_t opcode, const struct wl_message *msg,
|
||||
union wl_argument *args);
|
||||
|
||||
/**
|
||||
* Log function type alias
|
||||
*
|
||||
* The C implementation of the Wayland protocol abstracts the details of
|
||||
* logging. Users may customize the logging behavior, with a function conforming
|
||||
* to the `wl_log_func_t` type, via `wl_log_set_handler_client` and
|
||||
* `wl_log_set_handler_server`.
|
||||
*
|
||||
* A `wl_log_func_t` must conform to the expectations of `vprintf`, and
|
||||
* expects two arguments: a string to write and a corresponding variable
|
||||
* argument list. While the string to write may contain format specifiers and
|
||||
* use values in the variable argument list, the behavior of any `wl_log_func_t`
|
||||
* depends on the implementation.
|
||||
*
|
||||
* \note Take care to not confuse this with `wl_protocol_logger_func_t`, which
|
||||
* is a specific server-side logger for requests and events.
|
||||
*
|
||||
* \param fmt String to write to the log, containing optional format
|
||||
* specifiers
|
||||
* \param args Variable argument list
|
||||
*
|
||||
* \sa wl_log_set_handler_client
|
||||
* \sa wl_log_set_handler_server
|
||||
*/
|
||||
typedef void (*wl_log_func_t)(const char *fmt, va_list args) WL_PRINTF(1, 0);
|
||||
|
||||
/**
|
||||
* Return value of an iterator function
|
||||
*
|
||||
* \sa wl_client_for_each_resource_iterator_func_t
|
||||
* \sa wl_client_for_each_resource
|
||||
*/
|
||||
enum wl_iterator_result {
|
||||
/** Stop the iteration */
|
||||
WL_ITERATOR_STOP,
|
||||
/** Continue the iteration */
|
||||
WL_ITERATOR_CONTINUE
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright © 2012 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WAYLAND_VERSION_H
|
||||
#define WAYLAND_VERSION_H
|
||||
|
||||
#define WAYLAND_VERSION_MAJOR 1
|
||||
#define WAYLAND_VERSION_MINOR 26
|
||||
#define WAYLAND_VERSION_MICRO 0
|
||||
#define WAYLAND_VERSION "1.26.0"
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="banner_ahb_v1">
|
||||
<copyright>
|
||||
Copyright 2026 The412Banner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="banner_ahb_v1" version="2">
|
||||
<description summary="Android gralloc buffers behind dma-buf wl_buffers">
|
||||
Zero-copy window layers on Android. A Vulkan swapchain image that the
|
||||
client allocated as an Android AHardwareBuffer (gralloc) is still shared
|
||||
as a dma-buf through zwp_linux_dmabuf_v1, so the compositor can import
|
||||
and draw it the usual way. This interface additionally hands the
|
||||
compositor the AHardwareBuffer itself, once per wl_buffer, so the
|
||||
compositor can put the buffer straight on an Android SurfaceControl
|
||||
layer (SurfaceFlinger / the display hardware composite it) without
|
||||
copying it.
|
||||
|
||||
The AHardwareBuffer travels over a Unix socket: the client creates a
|
||||
socketpair, writes the buffer's handle into one end with
|
||||
AHardwareBuffer_sendHandleToUnixSocket, then sends the other end in the
|
||||
attach request. The compositor reads it with
|
||||
AHardwareBuffer_recvHandleFromUnixSocket and closes the socket. Its
|
||||
reference to the AHardwareBuffer lives as long as the wl_buffer (plus
|
||||
whatever the display still holds).
|
||||
|
||||
The compositor advertises this global whenever it can put buffers on a
|
||||
display layer at all; whether it WANTS gralloc buffers right now is the
|
||||
mode event (version 2), sent on bind and every time the user switches
|
||||
zero-copy on or off during the session. A client decides per swapchain,
|
||||
when it creates the swapchain, from the last mode it received, and a
|
||||
client whose live swapchain was built for the other mode retires it
|
||||
(VK_ERROR_OUT_OF_DATE_KHR on its next acquire or present) so the program
|
||||
rebuilds it for the new mode. Buffers of the old swapchain stay fully
|
||||
presentable until then: an attached AHardwareBuffer keeps its association
|
||||
for the wl_buffer's lifetime whatever the mode is now. A version 1
|
||||
client (no mode event) keeps deciding from its own environment. A
|
||||
client that does not see the global (or does not want it) allocates
|
||||
swapchain images the standard way; nothing else changes.
|
||||
|
||||
Synchronisation stays implicit: the dma-buf carries the client's render
|
||||
fence (DMA_BUF_IOCTL_IMPORT_SYNC_FILE by the client's driver), the
|
||||
compositor exports it as the layer's acquire fence, and the compositor
|
||||
imports the display's release fence into the dma-buf before it sends
|
||||
wl_buffer.release, so the client's next acquire waits on it.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the object">
|
||||
Buffers already attached keep their AHardwareBuffer association.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="attach">
|
||||
<description summary="hand the compositor a buffer's AHardwareBuffer">
|
||||
Associates the AHardwareBuffer readable from socket with the
|
||||
(already created) dma-buf wl_buffer. width, height and stride
|
||||
(pixels) describe the gralloc allocation; modifier_hi/lo is the DRM
|
||||
format modifier the dma-buf was shared with (the same value passed to
|
||||
zwp_linux_buffer_params_v1.add); image_count is the number of images
|
||||
in the swapchain this buffer belongs to (for the compositor's log).
|
||||
Sent once per wl_buffer, before the buffer is first attached to a
|
||||
surface.
|
||||
</description>
|
||||
<arg name="buffer" type="object" interface="wl_buffer" summary="the dma-buf wl_buffer"/>
|
||||
<arg name="socket" type="fd" summary="socket the AHardwareBuffer handle was written to"/>
|
||||
<arg name="width" type="uint" summary="buffer width in pixels"/>
|
||||
<arg name="height" type="uint" summary="buffer height in pixels"/>
|
||||
<arg name="stride" type="uint" summary="gralloc row stride in pixels"/>
|
||||
<arg name="modifier_hi" type="uint" summary="high 32 bits of the DRM format modifier"/>
|
||||
<arg name="modifier_lo" type="uint" summary="low 32 bits of the DRM format modifier"/>
|
||||
<arg name="image_count" type="uint" summary="images in the client's swapchain"/>
|
||||
</request>
|
||||
|
||||
<event name="mode" since="2">
|
||||
<description summary="whether the compositor wants gralloc swapchain images now">
|
||||
Sent once right after bind and again whenever the compositor's
|
||||
zero-copy state flips (the in-game switch). enabled = 1: swapchains
|
||||
created from now on should use gralloc AHardwareBuffers and attach
|
||||
them; 0: standard buffers. A live swapchain built for the other value
|
||||
should be retired by the client (out of date) so the program rebuilds
|
||||
it; until it is, its buffers are shown as before.
|
||||
</description>
|
||||
<arg name="enabled" type="uint" summary="1 = gralloc swapchain images wanted, 0 = not"/>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="banner_desktop_v1">
|
||||
<copyright>
|
||||
Copyright 2026 The412Banner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="banner_desktop_v1" version="1">
|
||||
<description summary="Windows virtual desktop layout">
|
||||
Each Wine process is a separate Wayland client, so a Windows virtual
|
||||
desktop can't be built from subsurfaces. Instead the process that owns
|
||||
the desktop window marks one surface as the desktop, and every process
|
||||
reports where its top-level windows sit on that desktop and the global
|
||||
window stacking order. The compositor draws the desktop at the bottom,
|
||||
the windows at the reported positions, and sends pointer and keyboard
|
||||
input to the desktop surface; Wine routes it to the right window.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor"/>
|
||||
|
||||
<request name="set_desktop">
|
||||
<description summary="mark a surface as the virtual desktop">
|
||||
The surface is drawn at the origin, below every window, and sets the
|
||||
size of the desktop.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
</request>
|
||||
|
||||
<request name="set_window">
|
||||
<description summary="place a top-level window on the desktop">
|
||||
Position of the top-left corner of the surface in desktop
|
||||
coordinates, and the window handle used by set_zorder.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
<arg name="hwnd" type="uint"/>
|
||||
<arg name="x" type="int"/>
|
||||
<arg name="y" type="int"/>
|
||||
</request>
|
||||
|
||||
<request name="set_zorder">
|
||||
<description summary="report the desktop's window stacking order">
|
||||
Visible top-level window handles as 32-bit values, topmost first.
|
||||
</description>
|
||||
<arg name="hwnds" type="array"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,628 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="linux_dmabuf_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2014, 2015 Collabora, Ltd.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="zwp_linux_dmabuf_v1" version="6">
|
||||
<description summary="factory for creating dmabuf-based wl_buffers">
|
||||
This interface offers ways to create generic dmabuf-based wl_buffers.
|
||||
|
||||
For more information about dmabuf, see:
|
||||
https://www.kernel.org/doc/html/next/userspace-api/dma-buf-alloc-exchange.html
|
||||
|
||||
Clients can use the get_surface_feedback request to get dmabuf feedback
|
||||
for a particular surface. If the client wants to retrieve feedback not
|
||||
tied to a surface, they can use the get_default_feedback request.
|
||||
|
||||
The following are required from clients:
|
||||
|
||||
- Clients must ensure that either all data in the dma-buf is
|
||||
coherent for all subsequent read access or that coherency is
|
||||
correctly handled by the underlying kernel-side dma-buf
|
||||
implementation.
|
||||
|
||||
- Don't make any more attachments after sending the buffer to the
|
||||
compositor. Making more attachments later increases the risk of
|
||||
the compositor not being able to use (re-import) an existing
|
||||
dmabuf-based wl_buffer.
|
||||
|
||||
The underlying graphics stack must ensure the following:
|
||||
|
||||
- The dmabuf file descriptors relayed to the server will stay valid
|
||||
for the whole lifetime of the wl_buffer. This means the server may
|
||||
at any time use those fds to import the dmabuf into any kernel
|
||||
sub-system that might accept it.
|
||||
|
||||
However, when the underlying graphics stack fails to deliver the
|
||||
promise, because of e.g. a device hot-unplug which raises internal
|
||||
errors, after the wl_buffer has been successfully created the
|
||||
compositor must not raise protocol errors to the client when dmabuf
|
||||
import later fails.
|
||||
|
||||
To create a wl_buffer from one or more dmabufs, a client creates a
|
||||
zwp_linux_buffer_params_v1 object with a zwp_linux_dmabuf_v1.create_params
|
||||
request. All planes required by the intended format are added with
|
||||
the 'add' request. Finally, a 'create' or 'create_immed' request is
|
||||
issued, which has the following outcome depending on the import success.
|
||||
|
||||
The 'create' request,
|
||||
- on success, triggers a 'created' event which provides the final
|
||||
wl_buffer to the client.
|
||||
- on failure, triggers a 'failed' event to convey that the server
|
||||
cannot use the dmabufs received from the client.
|
||||
|
||||
For the 'create_immed' request,
|
||||
- on success, the server immediately imports the added dmabufs to
|
||||
create a wl_buffer. No event is sent from the server in this case.
|
||||
- on failure, the server can choose to either:
|
||||
- terminate the client by raising a fatal error.
|
||||
- mark the wl_buffer as failed, and send a 'failed' event to the
|
||||
client. If the client uses a failed wl_buffer as an argument to any
|
||||
request, the behaviour is compositor implementation-defined.
|
||||
|
||||
For all DRM formats and unless specified in another protocol extension,
|
||||
pre-multiplied alpha is used for pixel values.
|
||||
|
||||
Unless specified otherwise in another protocol extension, implicit
|
||||
synchronization is used. In other words, compositors and clients must
|
||||
wait and signal fences implicitly passed via the DMA-BUF's reservation
|
||||
mechanism.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="unbind the factory">
|
||||
Objects created through this interface, especially wl_buffers, will
|
||||
remain valid.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="create_params">
|
||||
<description summary="create a temporary object for buffer parameters">
|
||||
This temporary object is used to collect multiple dmabuf handles into
|
||||
a single batch to create a wl_buffer. It can only be used once and
|
||||
should be destroyed after a 'created' or 'failed' event has been
|
||||
received.
|
||||
</description>
|
||||
<arg name="params_id" type="new_id" interface="zwp_linux_buffer_params_v1"
|
||||
summary="id for the newly created zwp_linux_buffer_params_v1"/>
|
||||
</request>
|
||||
|
||||
<event name="format" deprecated-since="4">
|
||||
<description summary="supported buffer format">
|
||||
This event advertises one buffer format that the server supports.
|
||||
All the supported formats are advertised once when the client
|
||||
binds to this interface. A roundtrip after binding guarantees
|
||||
that the client has received all supported formats.
|
||||
|
||||
For the definition of the format codes, see the
|
||||
zwp_linux_buffer_params_v1::create request.
|
||||
|
||||
Starting version 4, the format event is deprecated and must not be
|
||||
sent by compositors. Instead, use get_default_feedback or
|
||||
get_surface_feedback.
|
||||
</description>
|
||||
<arg name="format" type="uint" summary="DRM_FORMAT code"/>
|
||||
</event>
|
||||
|
||||
<event name="modifier" since="3" deprecated-since="4">
|
||||
<description summary="supported buffer format modifier">
|
||||
This event advertises the formats that the server supports, along with
|
||||
the modifiers supported for each format. All the supported modifiers
|
||||
for all the supported formats are advertised once when the client
|
||||
binds to this interface. A roundtrip after binding guarantees that
|
||||
the client has received all supported format-modifier pairs.
|
||||
|
||||
For legacy support, DRM_FORMAT_MOD_INVALID (that is, modifier_hi ==
|
||||
0x00ffffff and modifier_lo == 0xffffffff) is allowed in this event.
|
||||
It indicates that the server can support the format with an implicit
|
||||
modifier. When a plane has DRM_FORMAT_MOD_INVALID as its modifier, it
|
||||
is as if no explicit modifier is specified. The effective modifier
|
||||
will be derived from the dmabuf.
|
||||
|
||||
A compositor that sends valid modifiers and DRM_FORMAT_MOD_INVALID for
|
||||
a given format supports both explicit modifiers and implicit modifiers.
|
||||
|
||||
For the definition of the format and modifier codes, see the
|
||||
zwp_linux_buffer_params_v1::create and zwp_linux_buffer_params_v1::add
|
||||
requests.
|
||||
|
||||
Starting version 4, the modifier event is deprecated and must not be
|
||||
sent by compositors. Instead, use get_default_feedback or
|
||||
get_surface_feedback.
|
||||
</description>
|
||||
<arg name="format" type="uint" summary="DRM_FORMAT code"/>
|
||||
<arg name="modifier_hi" type="uint"
|
||||
summary="high 32 bits of layout modifier"/>
|
||||
<arg name="modifier_lo" type="uint"
|
||||
summary="low 32 bits of layout modifier"/>
|
||||
</event>
|
||||
|
||||
<!-- Version 4 additions -->
|
||||
|
||||
<request name="get_default_feedback" since="4">
|
||||
<description summary="get default feedback">
|
||||
This request creates a new zwp_linux_dmabuf_feedback_v1 object not bound
|
||||
to a particular surface. This object will deliver feedback about dmabuf
|
||||
parameters to use if the client doesn't support per-surface feedback
|
||||
(see get_surface_feedback).
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwp_linux_dmabuf_feedback_v1"/>
|
||||
</request>
|
||||
|
||||
<request name="get_surface_feedback" since="4">
|
||||
<description summary="get feedback for a surface">
|
||||
This request creates a new zwp_linux_dmabuf_feedback_v1 object for the
|
||||
specified wl_surface. This object will deliver feedback about dmabuf
|
||||
parameters to use for buffers attached to this surface.
|
||||
|
||||
If the surface is destroyed before the zwp_linux_dmabuf_feedback_v1 object,
|
||||
the feedback object becomes inert.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwp_linux_dmabuf_feedback_v1"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwp_linux_buffer_params_v1" version="6">
|
||||
<description summary="parameters for creating a dmabuf-based wl_buffer">
|
||||
This temporary object is a collection of dmabufs and other
|
||||
parameters that together form a single logical buffer. The temporary
|
||||
object may eventually create one wl_buffer unless cancelled by
|
||||
destroying it before requesting 'create'.
|
||||
|
||||
Single-planar formats only require one dmabuf, however
|
||||
multi-planar formats may require more than one dmabuf. For all
|
||||
formats, an 'add' request must be called once per plane (even if the
|
||||
underlying dmabuf fd is identical).
|
||||
|
||||
You must use consecutive plane indices ('plane_idx' argument for 'add')
|
||||
from zero to the number of planes used by the drm_fourcc format code.
|
||||
All planes required by the format must be given exactly once, but can
|
||||
be given in any order. Each plane index can only be set once; subsequent
|
||||
calls with a plane index which has already been set will result in a
|
||||
plane_set error being generated.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="already_used" value="0"
|
||||
summary="the zwp_linux_buffer_params_v1 object has already been used to create a wl_buffer"/>
|
||||
<entry name="plane_idx" value="1"
|
||||
summary="plane index out of bounds"/>
|
||||
<entry name="plane_set" value="2"
|
||||
summary="the plane index was already set"/>
|
||||
<entry name="incomplete" value="3"
|
||||
summary="missing or too many planes to create a buffer"/>
|
||||
<entry name="invalid_format" value="4"
|
||||
summary="format not supported"/>
|
||||
<entry name="invalid_dimensions" value="5"
|
||||
summary="invalid width or height"/>
|
||||
<entry name="out_of_bounds" value="6"
|
||||
summary="offset + stride * height goes out of dmabuf bounds"/>
|
||||
<entry name="invalid_wl_buffer" value="7"
|
||||
summary="invalid wl_buffer resulted from importing dmabufs via
|
||||
the create_immed request on given buffer_params"/>
|
||||
<entry name="invalid_dev_t_size" value="8"
|
||||
summary="an array with mismatching size for a dev_t was used"/>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="delete this object, used or not">
|
||||
Cleans up the temporary data sent to the server for dmabuf-based
|
||||
wl_buffer creation.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="add">
|
||||
<description summary="add a dmabuf to the temporary set">
|
||||
This request adds one dmabuf to the set in this
|
||||
zwp_linux_buffer_params_v1.
|
||||
|
||||
The 64-bit unsigned value combined from modifier_hi and modifier_lo
|
||||
is the dmabuf layout modifier. DRM AddFB2 ioctl calls this the
|
||||
fb modifier, which is defined in drm_mode.h of Linux UAPI.
|
||||
This is an opaque token. Drivers use this token to express tiling,
|
||||
compression, etc. driver-specific modifications to the base format
|
||||
defined by the DRM fourcc code.
|
||||
|
||||
Starting from version 4, the invalid_format protocol error is sent if
|
||||
the format + modifier pair was not advertised as supported.
|
||||
|
||||
Starting from version 5, the invalid_format protocol error is sent if
|
||||
all planes don't use the same modifier.
|
||||
|
||||
This request raises the PLANE_IDX error if plane_idx is too large.
|
||||
The error PLANE_SET is raised if attempting to set a plane that
|
||||
was already set.
|
||||
</description>
|
||||
<arg name="fd" type="fd" summary="dmabuf fd"/>
|
||||
<arg name="plane_idx" type="uint" summary="plane index"/>
|
||||
<arg name="offset" type="uint" summary="offset in bytes"/>
|
||||
<arg name="stride" type="uint" summary="stride in bytes"/>
|
||||
<arg name="modifier_hi" type="uint"
|
||||
summary="high 32 bits of layout modifier"/>
|
||||
<arg name="modifier_lo" type="uint"
|
||||
summary="low 32 bits of layout modifier"/>
|
||||
</request>
|
||||
|
||||
<enum name="flags" bitfield="true">
|
||||
<entry name="y_invert" value="1" summary="contents are y-inverted"/>
|
||||
<entry name="interlaced" value="2" summary="content is interlaced"/>
|
||||
<entry name="bottom_first" value="4" summary="bottom field first"/>
|
||||
</enum>
|
||||
|
||||
<request name="create">
|
||||
<description summary="create a wl_buffer from the given dmabufs">
|
||||
This asks for creation of a wl_buffer from the added dmabuf
|
||||
buffers. The wl_buffer is not created immediately but returned via
|
||||
the 'created' event if the dmabuf sharing succeeds. The sharing
|
||||
may fail at runtime for reasons a client cannot predict, in
|
||||
which case the 'failed' event is triggered.
|
||||
|
||||
The 'format' argument is a DRM_FORMAT code, as defined by the
|
||||
libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the
|
||||
authoritative source on how the format codes should work.
|
||||
|
||||
The 'flags' is a bitfield of the flags defined in enum "flags".
|
||||
'y_invert' means that the image needs to be y-flipped.
|
||||
|
||||
Flag 'interlaced' means that the frame in the buffer is not
|
||||
progressive as usual, but interlaced. An interlaced buffer as
|
||||
supported here must always contain both top and bottom fields.
|
||||
The top field always begins on the first pixel row. The temporal
|
||||
ordering between the two fields is top field first, unless
|
||||
'bottom_first' is specified. It is undefined whether 'bottom_first'
|
||||
is ignored if 'interlaced' is not set.
|
||||
|
||||
This protocol does not convey any information about field rate,
|
||||
duration, or timing, other than the relative ordering between the
|
||||
two fields in one buffer. A compositor may have to estimate the
|
||||
intended field rate from the incoming buffer rate. It is undefined
|
||||
whether the time of receiving wl_surface.commit with a new buffer
|
||||
attached, applying the wl_surface state, wl_surface.frame callback
|
||||
trigger, presentation, or any other point in the compositor cycle
|
||||
is used to measure the frame or field times. There is no support
|
||||
for detecting missed or late frames/fields/buffers either, and
|
||||
there is no support whatsoever for cooperating with interlaced
|
||||
compositor output.
|
||||
|
||||
The composited image quality resulting from the use of interlaced
|
||||
buffers is explicitly undefined. A compositor may use elaborate
|
||||
hardware features or software to deinterlace and create progressive
|
||||
output frames from a sequence of interlaced input buffers, or it
|
||||
may produce substandard image quality. However, compositors that
|
||||
cannot guarantee reasonable image quality in all cases are recommended
|
||||
to just reject all interlaced buffers.
|
||||
|
||||
Any argument errors, including non-positive width or height,
|
||||
mismatch between the number of planes and the format, bad
|
||||
format, bad offset or stride, may be indicated by fatal protocol
|
||||
errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS,
|
||||
OUT_OF_BOUNDS.
|
||||
|
||||
Dmabuf import errors in the server that are not obvious client
|
||||
bugs are returned via the 'failed' event as non-fatal. This
|
||||
allows attempting dmabuf sharing and falling back in the client
|
||||
if it fails.
|
||||
|
||||
This request can be sent only once in the object's lifetime, after
|
||||
which the only legal request is destroy. This object should be
|
||||
destroyed after issuing a 'create' request. Attempting to use this
|
||||
object after issuing 'create' raises the ALREADY_USED protocol error.
|
||||
|
||||
It is not mandatory to issue 'create'. If a client wants to
|
||||
cancel the buffer creation, it can just destroy this object.
|
||||
</description>
|
||||
<arg name="width" type="int" summary="base plane width in pixels"/>
|
||||
<arg name="height" type="int" summary="base plane height in pixels"/>
|
||||
<arg name="format" type="uint" summary="DRM_FORMAT code"/>
|
||||
<arg name="flags" type="uint" enum="flags" summary="see enum flags"/>
|
||||
</request>
|
||||
|
||||
<event name="created">
|
||||
<description summary="buffer creation succeeded">
|
||||
This event indicates that the attempted buffer creation was
|
||||
successful. It provides the new wl_buffer referencing the dmabuf(s).
|
||||
|
||||
Upon receiving this event, the client should destroy the
|
||||
zwp_linux_buffer_params_v1 object.
|
||||
</description>
|
||||
<arg name="buffer" type="new_id" interface="wl_buffer"
|
||||
summary="id for the the newly created wl_buffer"/>
|
||||
</event>
|
||||
|
||||
<event name="failed">
|
||||
<description summary="buffer creation failed">
|
||||
This event indicates that the attempted buffer creation has
|
||||
failed. It usually means that one of the dmabuf constraints
|
||||
has not been fulfilled.
|
||||
|
||||
Upon receiving this event, the client should destroy the
|
||||
zwp_linux_buffer_params_v1 object.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<request name="create_immed" since="2">
|
||||
<description summary="immediately create a wl_buffer from the given
|
||||
dmabufs">
|
||||
This asks for immediate creation of a wl_buffer by importing the
|
||||
added dmabufs.
|
||||
|
||||
In case of import success, no event is sent from the server, and the
|
||||
wl_buffer is ready to be used by the client.
|
||||
|
||||
Upon import failure, either of the following may happen, as seen fit
|
||||
by the implementation:
|
||||
- the client is terminated with one of the following fatal protocol
|
||||
errors:
|
||||
- INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS,
|
||||
in case of argument errors such as mismatch between the number
|
||||
of planes and the format, bad format, non-positive width or
|
||||
height, or bad offset or stride.
|
||||
- INVALID_WL_BUFFER, in case the cause for failure is unknown or
|
||||
platform specific.
|
||||
- the server creates an invalid wl_buffer, marks it as failed and
|
||||
sends a 'failed' event to the client. The result of using this
|
||||
invalid wl_buffer as an argument in any request by the client is
|
||||
defined by the compositor implementation.
|
||||
|
||||
This takes the same arguments as a 'create' request, and obeys the
|
||||
same restrictions.
|
||||
</description>
|
||||
<arg name="buffer_id" type="new_id" interface="wl_buffer"
|
||||
summary="id for the newly created wl_buffer"/>
|
||||
<arg name="width" type="int" summary="base plane width in pixels"/>
|
||||
<arg name="height" type="int" summary="base plane height in pixels"/>
|
||||
<arg name="format" type="uint" summary="DRM_FORMAT code"/>
|
||||
<arg name="flags" type="uint" enum="flags" summary="see enum flags"/>
|
||||
</request>
|
||||
|
||||
<request name="set_sampling_device" since="6">
|
||||
<description summary="set the target device of the wl_buffer">
|
||||
Set the device the compositor should import the dmabufs to for sampling
|
||||
in the next create or create_immed request.
|
||||
|
||||
To avoid race conditions when the compositor removes a device from the
|
||||
tranches, it is not a protocol error if the device hasn't been advertised
|
||||
by the compositor in a tranche with the sampling flag, but the import is
|
||||
likely to fail in that case.
|
||||
|
||||
If the client doesn't know a suitable target device, it shouldn't set one,
|
||||
and the compositor should attempt import on all devices it supports.
|
||||
|
||||
If the array is too small to contain a dev_t or larger than required, the
|
||||
invalid_dev_t_size error will be emitted.
|
||||
</description>
|
||||
<arg name="device" type="array" summary="device dev_t value"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwp_linux_dmabuf_feedback_v1" version="6">
|
||||
<description summary="dmabuf feedback">
|
||||
This object advertises dmabuf parameters feedback. This includes the
|
||||
preferred devices and the supported formats/modifiers.
|
||||
|
||||
The parameters are sent once when this object is created and whenever they
|
||||
change. The done event is always sent once after all parameters have been
|
||||
sent. When a single parameter changes, all parameters are re-sent by the
|
||||
compositor.
|
||||
|
||||
Compositors can re-send the parameters when the current client buffer
|
||||
allocations are sub-optimal. Compositors should not re-send the
|
||||
parameters if re-allocating the buffers would not result in a more optimal
|
||||
configuration. In particular, compositors should avoid sending the exact
|
||||
same parameters multiple times in a row.
|
||||
|
||||
The tranche_target_device and tranche_formats events are grouped by
|
||||
tranches of preference. For each tranche, a tranche_target_device, one
|
||||
tranche_flags and one or more tranche_formats events are sent, followed
|
||||
by a tranche_done event finishing the list. The tranches are sent in
|
||||
descending order of preference. All formats and modifiers in the same
|
||||
tranche have the same preference.
|
||||
|
||||
To send parameters, the compositor sends one main_device event (unless
|
||||
the client bound version 6 or above), tranches (each consisting of one
|
||||
tranche_target_device event, one tranche_flags event, tranche_formats
|
||||
events and then a tranche_done event), then one done event.
|
||||
|
||||
With version 6 and above, the compositor must always advertise at least
|
||||
one tranche with the sampling flag set.
|
||||
|
||||
The compositor sends a format_table event at least once for each dmabuf
|
||||
parameters feedback object, before any tranche events. Unless the format
|
||||
table contents change later, the compositor is free not to send another
|
||||
format_table event for the same dmabuf parameters feedback object.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the feedback object">
|
||||
Using this request a client can tell the server that it is not going to
|
||||
use the zwp_linux_dmabuf_feedback_v1 object anymore.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="done">
|
||||
<description summary="all feedback has been sent">
|
||||
This event is sent after all parameters of a zwp_linux_dmabuf_feedback_v1
|
||||
object have been sent.
|
||||
|
||||
This allows changes to the zwp_linux_dmabuf_feedback_v1 parameters to be
|
||||
seen as atomic, even if they happen via multiple events.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<event name="format_table">
|
||||
<description summary="format and modifier table">
|
||||
This event provides a file descriptor which can be memory-mapped to
|
||||
access the format and modifier table.
|
||||
|
||||
The table contains a tightly packed array of consecutive format +
|
||||
modifier pairs. Each pair is 16 bytes wide. It contains a format as a
|
||||
32-bit unsigned integer, followed by 4 bytes of unused padding, and a
|
||||
modifier as a 64-bit unsigned integer. The native endianness is used.
|
||||
|
||||
The client must map the file descriptor in read-only private mode.
|
||||
|
||||
Compositors are not allowed to mutate the table file contents once this
|
||||
event has been sent. Instead, compositors must create a new, separate
|
||||
table file and re-send feedback parameters. Compositors are allowed to
|
||||
store duplicate format + modifier pairs in the table.
|
||||
</description>
|
||||
<arg name="fd" type="fd" summary="table file descriptor"/>
|
||||
<arg name="size" type="uint" summary="table size, in bytes"/>
|
||||
</event>
|
||||
|
||||
<event name="main_device" deprecated-since="6">
|
||||
<description summary="preferred main device">
|
||||
This event advertises the main device that the server prefers to use
|
||||
when direct scan-out to the target device isn't possible. The
|
||||
advertised main device may be different for each
|
||||
zwp_linux_dmabuf_feedback_v1 object, and may change over time.
|
||||
|
||||
There is exactly one main device. The compositor must send at least
|
||||
one preference tranche with tranche_target_device equal to main_device.
|
||||
|
||||
Clients need to create buffers that the main device can import and
|
||||
read from, otherwise creating the dmabuf wl_buffer will fail (see the
|
||||
zwp_linux_buffer_params_v1.create and create_immed requests for details).
|
||||
The main device will also likely be kept active by the compositor,
|
||||
so clients can use it instead of waking up another device for power
|
||||
savings.
|
||||
|
||||
In general the device is a DRM node. The DRM node type (primary vs.
|
||||
render) is unspecified. Clients must not rely on the compositor sending
|
||||
a particular node type. Clients cannot check two devices for equality
|
||||
by comparing the dev_t value.
|
||||
|
||||
If explicit modifiers are not supported and the client performs buffer
|
||||
allocations on a different device than the main device, then the client
|
||||
must force the buffer to have a linear layout.
|
||||
|
||||
With version 6 and above, this event is no longer sent. Clients should
|
||||
use a device with the sampling flag in the tranches instead.
|
||||
</description>
|
||||
<arg name="device" type="array" summary="device dev_t value"/>
|
||||
</event>
|
||||
|
||||
<event name="tranche_done">
|
||||
<description summary="a preference tranche has been sent">
|
||||
This event splits tranche_target_device and tranche_formats events into
|
||||
preference tranches. It is sent after a set of tranche_target_device
|
||||
and tranche_formats events; it represents the end of a tranche. The
|
||||
next tranche will have a lower preference.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<event name="tranche_target_device">
|
||||
<description summary="target device">
|
||||
This event advertises the target device that the server prefers to use
|
||||
for a buffer created given this tranche. The advertised target device
|
||||
may be different for each preference tranche, and may change over time.
|
||||
|
||||
There is exactly one target device per tranche.
|
||||
|
||||
The target device may be a scan-out device, for example if the
|
||||
compositor prefers to directly scan-out a buffer created given this
|
||||
tranche. The target device may be a rendering device, for example if
|
||||
the compositor prefers to texture from said buffer.
|
||||
|
||||
The client can use this hint to allocate the buffer in a way that makes
|
||||
it accessible from the target device, ideally directly. The buffer must
|
||||
still be accessible from a device with the sampling flag, either through
|
||||
direct import or a potentially more expensive fallback path. If the
|
||||
buffer can't be directly imported for sampling, then clients must be
|
||||
prepared for the compositor changing the tranche priority or making
|
||||
wl_buffer creation fail (see the zwp_linux_buffer_params_v1.create and
|
||||
create_immed requests for details).
|
||||
|
||||
If the device is a DRM node, the DRM node type (primary vs. render) is
|
||||
unspecified. Clients must not rely on the compositor sending a
|
||||
particular node type. Clients cannot check two devices for equality by
|
||||
comparing the dev_t value.
|
||||
|
||||
This event is tied to a preference tranche, see the tranche_done event.
|
||||
</description>
|
||||
<arg name="device" type="array" summary="device dev_t value"/>
|
||||
</event>
|
||||
|
||||
<event name="tranche_formats">
|
||||
<description summary="supported buffer format modifiers">
|
||||
This event advertises the format + modifier combinations that the
|
||||
compositor supports.
|
||||
|
||||
It carries an array of indices, each referring to a format + modifier
|
||||
pair in the last received format table (see the format_table event).
|
||||
Each index is a 16-bit unsigned integer in native endianness.
|
||||
|
||||
For legacy support, DRM_FORMAT_MOD_INVALID is an allowed modifier.
|
||||
It indicates that the server can support the format with an implicit
|
||||
modifier. When a buffer has DRM_FORMAT_MOD_INVALID as its modifier, it
|
||||
is as if no explicit modifier is specified. The effective modifier
|
||||
will be derived from the dmabuf.
|
||||
|
||||
A compositor that sends valid modifiers and DRM_FORMAT_MOD_INVALID for
|
||||
a given format supports both explicit modifiers and implicit modifiers.
|
||||
|
||||
Compositors must not send duplicate format + modifier pairs within the
|
||||
same tranche or across two different tranches with the same target
|
||||
device and flags.
|
||||
|
||||
This event is tied to a preference tranche, see the tranche_done event.
|
||||
|
||||
For the definition of the format and modifier codes, see the
|
||||
zwp_linux_buffer_params_v1.create request.
|
||||
</description>
|
||||
<arg name="indices" type="array" summary="array of 16-bit indexes"/>
|
||||
</event>
|
||||
|
||||
<enum name="tranche_flags" bitfield="true">
|
||||
<entry name="scanout" value="1" since="4">
|
||||
<description summary="direct scan-out tranche">
|
||||
The scanout flag is a hint that direct scan-out may be attempted by
|
||||
the compositor on the target device if the client appropriately
|
||||
allocates a buffer. How to allocate a buffer that can be scanned out
|
||||
on the target device is implementation-defined.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="sampling" value="2" since="6">
|
||||
<description summary="sampling tranche">
|
||||
The sampling flag describes that the compositor is able to efficiently
|
||||
sample from buffers imported to the target device if the client
|
||||
appropriately allocates a buffer. How to allocate a buffer that can be
|
||||
efficiently sampled on the target device is implementation defined.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<event name="tranche_flags">
|
||||
<description summary="tranche flags">
|
||||
This event sets tranche-specific flags. This event is tied to a
|
||||
preference tranche, see the tranche_done event.
|
||||
With version 6 and above, the compositor must set at least one flag
|
||||
in each tranche.
|
||||
</description>
|
||||
<arg name="flags" type="uint" enum="tranche_flags" summary="tranche flags"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
||||
@@ -0,0 +1,339 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="pointer_constraints_unstable_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2014 Jonas Ådahl
|
||||
Copyright © 2015 Red Hat Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="protocol for constraining pointer motions">
|
||||
This protocol specifies a set of interfaces used for adding constraints to
|
||||
the motion of a pointer. Possible constraints include confining pointer
|
||||
motions to a given region, or locking it to its current position.
|
||||
|
||||
In order to constrain the pointer, a client must first bind the global
|
||||
interface "wp_pointer_constraints" which, if a compositor supports pointer
|
||||
constraints, is exposed by the registry. Using the bound global object, the
|
||||
client uses the request that corresponds to the type of constraint it wants
|
||||
to make. See wp_pointer_constraints for more details.
|
||||
|
||||
Warning! The protocol described in this file is experimental and backward
|
||||
incompatible changes may be made. Backward compatible changes may be added
|
||||
together with the corresponding interface version bump. Backward
|
||||
incompatible changes are done by bumping the version number in the protocol
|
||||
and interface names and resetting the interface version. Once the protocol
|
||||
is to be declared stable, the 'z' prefix and the version number in the
|
||||
protocol and interface names are removed and the interface version number is
|
||||
reset.
|
||||
</description>
|
||||
|
||||
<interface name="zwp_pointer_constraints_v1" version="1">
|
||||
<description summary="constrain the movement of a pointer">
|
||||
The global interface exposing pointer constraining functionality. It
|
||||
exposes two requests: lock_pointer for locking the pointer to its
|
||||
position, and confine_pointer for locking the pointer to a region.
|
||||
|
||||
The lock_pointer and confine_pointer requests create the objects
|
||||
wp_locked_pointer and wp_confined_pointer respectively, and the client can
|
||||
use these objects to interact with the lock.
|
||||
|
||||
For any surface, only one lock or confinement may be active across all
|
||||
wl_pointer objects of the same seat. If a lock or confinement is requested
|
||||
when another lock or confinement is active or requested on the same surface
|
||||
and with any of the wl_pointer objects of the same seat, an
|
||||
'already_constrained' error will be raised.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<description summary="wp_pointer_constraints error values">
|
||||
These errors can be emitted in response to wp_pointer_constraints
|
||||
requests.
|
||||
</description>
|
||||
<entry name="already_constrained" value="1"
|
||||
summary="pointer constraint already requested on that surface"/>
|
||||
</enum>
|
||||
|
||||
<enum name="lifetime">
|
||||
<description summary="constraint lifetime">
|
||||
These values represent different lifetime semantics. They are passed
|
||||
as arguments to the factory requests to specify how the constraint
|
||||
lifetimes should be managed.
|
||||
</description>
|
||||
<entry name="oneshot" value="1">
|
||||
<description summary="the pointer constraint is defunct once deactivated">
|
||||
A oneshot pointer constraint will never reactivate once it has been
|
||||
deactivated. See the corresponding deactivation event
|
||||
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
|
||||
details.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="persistent" value="2">
|
||||
<description summary="the pointer constraint may reactivate">
|
||||
A persistent pointer constraint may again reactivate once it has
|
||||
been deactivated. See the corresponding deactivation event
|
||||
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
|
||||
details.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the pointer constraints manager object">
|
||||
Used by the client to notify the server that it will no longer use this
|
||||
pointer constraints object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="lock_pointer">
|
||||
<description summary="lock pointer to a position">
|
||||
The lock_pointer request lets the client request to disable movements of
|
||||
the virtual pointer (i.e. the cursor), effectively locking the pointer
|
||||
to a position. This request may not take effect immediately; in the
|
||||
future, when the compositor deems implementation-specific constraints
|
||||
are satisfied, the pointer lock will be activated and the compositor
|
||||
sends a locked event.
|
||||
|
||||
The protocol provides no guarantee that the constraints are ever
|
||||
satisfied, and does not require the compositor to send an error if the
|
||||
constraints cannot ever be satisfied. It is thus possible to request a
|
||||
lock that will never activate.
|
||||
|
||||
There may not be another pointer constraint of any kind requested or
|
||||
active on the surface for any of the wl_pointer objects of the seat of
|
||||
the passed pointer when requesting a lock. If there is, an error will be
|
||||
raised. See general pointer lock documentation for more details.
|
||||
|
||||
The intersection of the region passed with this request and the input
|
||||
region of the surface is used to determine where the pointer must be
|
||||
in order for the lock to activate. It is up to the compositor whether to
|
||||
warp the pointer or require some kind of user interaction for the lock
|
||||
to activate. If the region is null the surface input region is used.
|
||||
|
||||
A surface may receive pointer focus without the lock being activated.
|
||||
|
||||
The request creates a new object wp_locked_pointer which is used to
|
||||
interact with the lock as well as receive updates about its state. See
|
||||
the the description of wp_locked_pointer for further information.
|
||||
|
||||
Note that while a pointer is locked, the wl_pointer objects of the
|
||||
corresponding seat will not emit any wl_pointer.motion events, but
|
||||
relative motion events will still be emitted via wp_relative_pointer
|
||||
objects of the same seat. wl_pointer.axis and wl_pointer.button events
|
||||
are unaffected.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"
|
||||
summary="surface to lock pointer to"/>
|
||||
<arg name="pointer" type="object" interface="wl_pointer"
|
||||
summary="the pointer that should be locked"/>
|
||||
<arg name="region" type="object" interface="wl_region" allow-null="true"
|
||||
summary="region of surface"/>
|
||||
<arg name="lifetime" type="uint" enum="lifetime" summary="lock lifetime"/>
|
||||
</request>
|
||||
|
||||
<request name="confine_pointer">
|
||||
<description summary="confine pointer to a region">
|
||||
The confine_pointer request lets the client request to confine the
|
||||
pointer cursor to a given region. This request may not take effect
|
||||
immediately; in the future, when the compositor deems implementation-
|
||||
specific constraints are satisfied, the pointer confinement will be
|
||||
activated and the compositor sends a confined event.
|
||||
|
||||
The intersection of the region passed with this request and the input
|
||||
region of the surface is used to determine where the pointer must be
|
||||
in order for the confinement to activate. It is up to the compositor
|
||||
whether to warp the pointer or require some kind of user interaction for
|
||||
the confinement to activate. If the region is null the surface input
|
||||
region is used.
|
||||
|
||||
The request will create a new object wp_confined_pointer which is used
|
||||
to interact with the confinement as well as receive updates about its
|
||||
state. See the the description of wp_confined_pointer for further
|
||||
information.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"
|
||||
summary="surface to lock pointer to"/>
|
||||
<arg name="pointer" type="object" interface="wl_pointer"
|
||||
summary="the pointer that should be confined"/>
|
||||
<arg name="region" type="object" interface="wl_region" allow-null="true"
|
||||
summary="region of surface"/>
|
||||
<arg name="lifetime" type="uint" enum="lifetime" summary="confinement lifetime"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwp_locked_pointer_v1" version="1">
|
||||
<description summary="receive relative pointer motion events">
|
||||
The wp_locked_pointer interface represents a locked pointer state.
|
||||
|
||||
While the lock of this object is active, the wl_pointer objects of the
|
||||
associated seat will not emit any wl_pointer.motion events.
|
||||
|
||||
This object will send the event 'locked' when the lock is activated.
|
||||
Whenever the lock is activated, it is guaranteed that the locked surface
|
||||
will already have received pointer focus and that the pointer will be
|
||||
within the region passed to the request creating this object.
|
||||
|
||||
To unlock the pointer, send the destroy request. This will also destroy
|
||||
the wp_locked_pointer object.
|
||||
|
||||
If the compositor decides to unlock the pointer the unlocked event is
|
||||
sent. See wp_locked_pointer.unlock for details.
|
||||
|
||||
When unlocking, the compositor may warp the cursor position to the set
|
||||
cursor position hint. If it does, it will not result in any relative
|
||||
motion events emitted via wp_relative_pointer.
|
||||
|
||||
If the surface the lock was requested on is destroyed and the lock is not
|
||||
yet activated, the wp_locked_pointer object is now defunct and must be
|
||||
destroyed.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the locked pointer object">
|
||||
Destroy the locked pointer object. If applicable, the compositor will
|
||||
unlock the pointer.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="set_cursor_position_hint">
|
||||
<description summary="set the pointer cursor position hint">
|
||||
Set the cursor position hint relative to the top left corner of the
|
||||
surface.
|
||||
|
||||
If the client is drawing its own cursor, it should update the position
|
||||
hint to the position of its own cursor. A compositor may use this
|
||||
information to warp the pointer upon unlock in order to avoid pointer
|
||||
jumps.
|
||||
|
||||
The cursor position hint is double buffered. The new hint will only take
|
||||
effect when the associated surface gets it pending state applied. See
|
||||
wl_surface.commit for details.
|
||||
</description>
|
||||
<arg name="surface_x" type="fixed"
|
||||
summary="surface-local x coordinate"/>
|
||||
<arg name="surface_y" type="fixed"
|
||||
summary="surface-local y coordinate"/>
|
||||
</request>
|
||||
|
||||
<request name="set_region">
|
||||
<description summary="set a new lock region">
|
||||
Set a new region used to lock the pointer.
|
||||
|
||||
The new lock region is double-buffered. The new lock region will
|
||||
only take effect when the associated surface gets its pending state
|
||||
applied. See wl_surface.commit for details.
|
||||
|
||||
For details about the lock region, see wp_locked_pointer.
|
||||
</description>
|
||||
<arg name="region" type="object" interface="wl_region" allow-null="true"
|
||||
summary="region of surface"/>
|
||||
</request>
|
||||
|
||||
<event name="locked">
|
||||
<description summary="lock activation event">
|
||||
Notification that the pointer lock of the seat's pointer is activated.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<event name="unlocked">
|
||||
<description summary="lock deactivation event">
|
||||
Notification that the pointer lock of the seat's pointer is no longer
|
||||
active. If this is a oneshot pointer lock (see
|
||||
wp_pointer_constraints.lifetime) this object is now defunct and should
|
||||
be destroyed. If this is a persistent pointer lock (see
|
||||
wp_pointer_constraints.lifetime) this pointer lock may again
|
||||
reactivate in the future.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="zwp_confined_pointer_v1" version="1">
|
||||
<description summary="confined pointer object">
|
||||
The wp_confined_pointer interface represents a confined pointer state.
|
||||
|
||||
This object will send the event 'confined' when the confinement is
|
||||
activated. Whenever the confinement is activated, it is guaranteed that
|
||||
the surface the pointer is confined to will already have received pointer
|
||||
focus and that the pointer will be within the region passed to the request
|
||||
creating this object. It is up to the compositor to decide whether this
|
||||
requires some user interaction and if the pointer will warp to within the
|
||||
passed region if outside.
|
||||
|
||||
To unconfine the pointer, send the destroy request. This will also destroy
|
||||
the wp_confined_pointer object.
|
||||
|
||||
If the compositor decides to unconfine the pointer the unconfined event is
|
||||
sent. The wp_confined_pointer object is at this point defunct and should
|
||||
be destroyed.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the confined pointer object">
|
||||
Destroy the confined pointer object. If applicable, the compositor will
|
||||
unconfine the pointer.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="set_region">
|
||||
<description summary="set a new confine region">
|
||||
Set a new region used to confine the pointer.
|
||||
|
||||
The new confine region is double-buffered. The new confine region will
|
||||
only take effect when the associated surface gets its pending state
|
||||
applied. See wl_surface.commit for details.
|
||||
|
||||
If the confinement is active when the new confinement region is applied
|
||||
and the pointer ends up outside of newly applied region, the pointer may
|
||||
warped to a position within the new confinement region. If warped, a
|
||||
wl_pointer.motion event will be emitted, but no
|
||||
wp_relative_pointer.relative_motion event.
|
||||
|
||||
The compositor may also, instead of using the new region, unconfine the
|
||||
pointer.
|
||||
|
||||
For details about the confine region, see wp_confined_pointer.
|
||||
</description>
|
||||
<arg name="region" type="object" interface="wl_region" allow-null="true"
|
||||
summary="region of surface"/>
|
||||
</request>
|
||||
|
||||
<event name="confined">
|
||||
<description summary="pointer confined">
|
||||
Notification that the pointer confinement of the seat's pointer is
|
||||
activated.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<event name="unconfined">
|
||||
<description summary="pointer unconfined">
|
||||
Notification that the pointer confinement of the seat's pointer is no
|
||||
longer active. If this is a oneshot pointer confinement (see
|
||||
wp_pointer_constraints.lifetime) this object is now defunct and should
|
||||
be destroyed. If this is a persistent pointer confinement (see
|
||||
wp_pointer_constraints.lifetime) this pointer confinement may again
|
||||
reactivate in the future.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
||||
@@ -0,0 +1,268 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="presentation_time">
|
||||
<!-- wrap:70 -->
|
||||
|
||||
<copyright>
|
||||
Copyright © 2013-2014 Collabora, Ltd.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="wp_presentation" version="2">
|
||||
<description summary="timed presentation related wl_surface requests">
|
||||
|
||||
<!-- Introduction -->
|
||||
|
||||
The main feature of this interface is accurate presentation
|
||||
timing feedback to ensure smooth video playback while maintaining
|
||||
audio/video synchronization. Some features use the concept of a
|
||||
presentation clock, which is defined in the
|
||||
presentation.clock_id event.
|
||||
|
||||
A content update for a wl_surface is submitted by a
|
||||
wl_surface.commit request. Request 'feedback' associates with
|
||||
the wl_surface.commit and provides feedback on the content
|
||||
update, particularly the final realized presentation time.
|
||||
|
||||
<!-- Completing presentation -->
|
||||
|
||||
When the final realized presentation time is available, e.g.
|
||||
after a framebuffer flip completes, the requested
|
||||
presentation_feedback.presented events are sent. The final
|
||||
presentation time can differ from the compositor's predicted
|
||||
display update time and the update's target time, especially
|
||||
when the compositor misses its target vertical blanking period.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<description summary="fatal presentation errors">
|
||||
These fatal protocol errors may be emitted in response to
|
||||
illegal presentation requests.
|
||||
</description>
|
||||
<entry name="invalid_timestamp" value="0"
|
||||
summary="invalid value in tv_nsec"/>
|
||||
<entry name="invalid_flag" value="1"
|
||||
summary="invalid flag"/>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="unbind from the presentation interface">
|
||||
Informs the server that the client will no longer be using
|
||||
this protocol object. Existing objects created by this object
|
||||
are not affected.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="feedback">
|
||||
<description summary="request presentation feedback information">
|
||||
Request presentation feedback for the current content submission
|
||||
on the given surface. This creates a new presentation_feedback
|
||||
object, which will deliver the feedback information once. If
|
||||
multiple presentation_feedback objects are created for the same
|
||||
submission, they will all deliver the same information.
|
||||
|
||||
For details on what information is returned, see the
|
||||
presentation_feedback interface.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface"
|
||||
summary="target surface"/>
|
||||
<arg name="callback" type="new_id" interface="wp_presentation_feedback"
|
||||
summary="new feedback object"/>
|
||||
</request>
|
||||
|
||||
<event name="clock_id">
|
||||
<description summary="clock ID for timestamps">
|
||||
This event tells the client in which clock domain the
|
||||
compositor interprets the timestamps used by the presentation
|
||||
extension. This clock is called the presentation clock.
|
||||
|
||||
The compositor sends this event when the client binds to the
|
||||
presentation interface. The presentation clock does not change
|
||||
during the lifetime of the client connection.
|
||||
|
||||
The clock identifier is platform dependent. On POSIX platforms, the
|
||||
identifier value is one of the clockid_t values accepted by
|
||||
clock_gettime(). clock_gettime() is defined by POSIX.1-2001.
|
||||
|
||||
Timestamps in this clock domain are expressed as tv_sec_hi,
|
||||
tv_sec_lo, tv_nsec triples, each component being an unsigned
|
||||
32-bit value. Whole seconds are in tv_sec which is a 64-bit
|
||||
value combined from tv_sec_hi and tv_sec_lo, and the
|
||||
additional fractional part in tv_nsec as nanoseconds. Hence,
|
||||
for valid timestamps tv_nsec must be in [0, 999999999].
|
||||
|
||||
Note that clock_id applies only to the presentation clock,
|
||||
and implies nothing about e.g. the timestamps used in the
|
||||
Wayland core protocol input events.
|
||||
|
||||
Compositors should prefer a clock which does not jump and is
|
||||
not slewed e.g. by NTP. The absolute value of the clock is
|
||||
irrelevant. Precision of one millisecond or better is
|
||||
recommended. Clients must be able to query the current clock
|
||||
value directly, not by asking the compositor.
|
||||
</description>
|
||||
<arg name="clk_id" type="uint" summary="platform clock identifier"/>
|
||||
</event>
|
||||
|
||||
</interface>
|
||||
|
||||
<interface name="wp_presentation_feedback" version="2">
|
||||
<description summary="presentation time feedback event">
|
||||
A presentation_feedback object returns an indication that a
|
||||
wl_surface content update has become visible to the user.
|
||||
One object corresponds to one content update submission
|
||||
(wl_surface.commit). There are two possible outcomes: the
|
||||
content update is presented to the user, and a presentation
|
||||
timestamp delivered; or, the user did not see the content
|
||||
update because it was superseded or its surface destroyed,
|
||||
and the content update is discarded.
|
||||
|
||||
Once a presentation_feedback object has delivered a 'presented'
|
||||
or 'discarded' event it is automatically destroyed.
|
||||
</description>
|
||||
|
||||
<event name="sync_output">
|
||||
<description summary="presentation synchronized to this output">
|
||||
As presentation can be synchronized to only one output at a
|
||||
time, this event tells which output it was. This event is only
|
||||
sent prior to the presented event.
|
||||
|
||||
As clients may bind to the same global wl_output multiple
|
||||
times, this event is sent for each bound instance that matches
|
||||
the synchronized output. If a client has not bound to the
|
||||
right wl_output global at all, this event is not sent.
|
||||
</description>
|
||||
<arg name="output" type="object" interface="wl_output"
|
||||
summary="presentation output"/>
|
||||
</event>
|
||||
|
||||
<enum name="kind" bitfield="true">
|
||||
<description summary="bitmask of flags in presented event">
|
||||
These flags provide information about how the presentation of
|
||||
the related content update was done. The intent is to help
|
||||
clients assess the reliability of the feedback and the visual
|
||||
quality with respect to possible tearing and timings.
|
||||
</description>
|
||||
<entry name="vsync" value="0x1">
|
||||
<description summary="presentation was vsync'd">
|
||||
The presentation was synchronized to the "vertical retrace" by
|
||||
the display hardware such that tearing does not happen.
|
||||
Relying on software scheduling is not acceptable for this
|
||||
flag. If presentation is done by a copy to the active
|
||||
frontbuffer, then it must guarantee that tearing cannot
|
||||
happen.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="hw_clock" value="0x2">
|
||||
<description summary="hardware provided the presentation timestamp">
|
||||
The display hardware provided measurements that the hardware
|
||||
driver converted into a presentation timestamp. Sampling a
|
||||
clock in software is not acceptable for this flag.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="hw_completion" value="0x4">
|
||||
<description summary="hardware signalled the start of the presentation">
|
||||
The display hardware signalled that it started using the new
|
||||
image content. The opposite of this is e.g. a timer being used
|
||||
to guess when the display hardware has switched to the new
|
||||
image content.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="zero_copy" value="0x8">
|
||||
<description summary="presentation was done zero-copy">
|
||||
The presentation of this update was done zero-copy. This means
|
||||
the buffer from the client was given to display hardware as
|
||||
is, without copying it. Compositing with OpenGL counts as
|
||||
copying, even if textured directly from the client buffer.
|
||||
Possible zero-copy cases include direct scanout of a
|
||||
fullscreen surface and a surface on a hardware overlay.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<event name="presented" type="destructor">
|
||||
<description summary="the content update was displayed">
|
||||
The associated content update was displayed to the user at the
|
||||
indicated time (tv_sec_hi/lo, tv_nsec). For the interpretation of
|
||||
the timestamp, see presentation.clock_id event.
|
||||
|
||||
The timestamp corresponds to the time when the content update
|
||||
turned into light the first time on the surface's main output.
|
||||
Compositors may approximate this from the framebuffer flip
|
||||
completion events from the system, and the latency of the
|
||||
physical display path if known.
|
||||
|
||||
This event is preceded by all related sync_output events
|
||||
telling which output's refresh cycle the feedback corresponds
|
||||
to, i.e. the main output for the surface. Compositors are
|
||||
recommended to choose the output containing the largest part
|
||||
of the wl_surface, or keeping the output they previously
|
||||
chose. Having a stable presentation output association helps
|
||||
clients predict future output refreshes (vblank).
|
||||
|
||||
The 'refresh' argument gives the compositor's prediction of how
|
||||
many nanoseconds after tv_sec, tv_nsec the very next output
|
||||
refresh may occur. This is to further aid clients in
|
||||
predicting future refreshes, i.e., estimating the timestamps
|
||||
targeting the next few vblanks. If such prediction cannot
|
||||
usefully be done, the argument is zero.
|
||||
|
||||
For version 2 and later, if the output does not have a constant
|
||||
refresh rate, explicit video mode switches excluded, then the
|
||||
refresh argument must be either an appropriate rate picked by the
|
||||
compositor (e.g. fastest rate), or 0 if no such rate exists.
|
||||
For version 1, if the output does not have a constant refresh rate,
|
||||
the refresh argument must be zero.
|
||||
|
||||
The 64-bit value combined from seq_hi and seq_lo is the value
|
||||
of the output's vertical retrace counter when the content
|
||||
update was first scanned out to the display. This value must
|
||||
be compatible with the definition of MSC in
|
||||
GLX_OML_sync_control specification. Note, that if the display
|
||||
path has a non-zero latency, the time instant specified by
|
||||
this counter may differ from the timestamp's.
|
||||
|
||||
If the output does not have a concept of vertical retrace or a
|
||||
refresh cycle, or the output device is self-refreshing without
|
||||
a way to query the refresh count, then the arguments seq_hi
|
||||
and seq_lo must be zero.
|
||||
</description>
|
||||
<arg name="tv_sec_hi" type="uint"
|
||||
summary="high 32 bits of the seconds part of the presentation timestamp"/>
|
||||
<arg name="tv_sec_lo" type="uint"
|
||||
summary="low 32 bits of the seconds part of the presentation timestamp"/>
|
||||
<arg name="tv_nsec" type="uint"
|
||||
summary="nanoseconds part of the presentation timestamp"/>
|
||||
<arg name="refresh" type="uint" summary="nanoseconds till next refresh"/>
|
||||
<arg name="seq_hi" type="uint"
|
||||
summary="high 32 bits of refresh counter"/>
|
||||
<arg name="seq_lo" type="uint"
|
||||
summary="low 32 bits of refresh counter"/>
|
||||
<arg name="flags" type="uint" enum="kind" summary="combination of 'kind' values"/>
|
||||
</event>
|
||||
|
||||
<event name="discarded" type="destructor">
|
||||
<description summary="the content update was not displayed">
|
||||
The content update was never displayed to the user.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="relative_pointer_unstable_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2014 Jonas Ådahl
|
||||
Copyright © 2015 Red Hat Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="protocol for relative pointer motion events">
|
||||
This protocol specifies a set of interfaces used for making clients able to
|
||||
receive relative pointer events not obstructed by barriers (such as the
|
||||
monitor edge or other pointer barriers).
|
||||
|
||||
To start receiving relative pointer events, a client must first bind the
|
||||
global interface "wp_relative_pointer_manager" which, if a compositor
|
||||
supports relative pointer motion events, is exposed by the registry. After
|
||||
having created the relative pointer manager proxy object, the client uses
|
||||
it to create the actual relative pointer object using the
|
||||
"get_relative_pointer" request given a wl_pointer. The relative pointer
|
||||
motion events will then, when applicable, be transmitted via the proxy of
|
||||
the newly created relative pointer object. See the documentation of the
|
||||
relative pointer interface for more details.
|
||||
|
||||
Warning! The protocol described in this file is experimental and backward
|
||||
incompatible changes may be made. Backward compatible changes may be added
|
||||
together with the corresponding interface version bump. Backward
|
||||
incompatible changes are done by bumping the version number in the protocol
|
||||
and interface names and resetting the interface version. Once the protocol
|
||||
is to be declared stable, the 'z' prefix and the version number in the
|
||||
protocol and interface names are removed and the interface version number is
|
||||
reset.
|
||||
</description>
|
||||
|
||||
<interface name="zwp_relative_pointer_manager_v1" version="1">
|
||||
<description summary="get relative pointer objects">
|
||||
A global interface used for getting the relative pointer object for a
|
||||
given pointer.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the relative pointer manager object">
|
||||
Used by the client to notify the server that it will no longer use this
|
||||
relative pointer manager object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="get_relative_pointer">
|
||||
<description summary="get a relative pointer object">
|
||||
Create a relative pointer interface given a wl_pointer object. See the
|
||||
wp_relative_pointer interface for more details.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwp_relative_pointer_v1"/>
|
||||
<arg name="pointer" type="object" interface="wl_pointer"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwp_relative_pointer_v1" version="1">
|
||||
<description summary="relative pointer object">
|
||||
A wp_relative_pointer object is an extension to the wl_pointer interface
|
||||
used for emitting relative pointer events. It shares the same focus as
|
||||
wl_pointer objects of the same seat and will only emit events when it has
|
||||
focus.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="release the relative pointer object"/>
|
||||
</request>
|
||||
|
||||
<event name="relative_motion">
|
||||
<description summary="relative pointer motion">
|
||||
Relative x/y pointer motion from the pointer of the seat associated with
|
||||
this object.
|
||||
|
||||
A relative motion is in the same dimension as regular wl_pointer motion
|
||||
events, except they do not represent an absolute position. For example,
|
||||
moving a pointer from (x, y) to (x', y') would have the equivalent
|
||||
relative motion (x' - x, y' - y). If a pointer motion caused the
|
||||
absolute pointer position to be clipped by for example the edge of the
|
||||
monitor, the relative motion is unaffected by the clipping and will
|
||||
represent the unclipped motion.
|
||||
|
||||
This event also contains non-accelerated motion deltas. The
|
||||
non-accelerated delta is, when applicable, the regular pointer motion
|
||||
delta as it was before having applied motion acceleration and other
|
||||
transformations such as normalization.
|
||||
|
||||
Note that the non-accelerated delta does not represent 'raw' events as
|
||||
they were read from some device. Pointer motion acceleration is device-
|
||||
and configuration-specific and non-accelerated deltas and accelerated
|
||||
deltas may have the same value on some devices.
|
||||
|
||||
Relative motions are not coupled to wl_pointer.motion events, and can be
|
||||
sent in combination with such events, but also independently. There may
|
||||
also be scenarios where wl_pointer.motion is sent, but there is no
|
||||
relative motion. The order of an absolute and relative motion event
|
||||
originating from the same physical motion is not guaranteed.
|
||||
|
||||
If the client needs button events or focus state, it can receive them
|
||||
from a wl_pointer object of the same seat that the wp_relative_pointer
|
||||
object is associated with.
|
||||
</description>
|
||||
<arg name="utime_hi" type="uint"
|
||||
summary="high 32 bits of a 64 bit timestamp with microsecond granularity"/>
|
||||
<arg name="utime_lo" type="uint"
|
||||
summary="low 32 bits of a 64 bit timestamp with microsecond granularity"/>
|
||||
<arg name="dx" type="fixed"
|
||||
summary="the x component of the motion vector"/>
|
||||
<arg name="dy" type="fixed"
|
||||
summary="the y component of the motion vector"/>
|
||||
<arg name="dx_unaccel" type="fixed"
|
||||
summary="the x component of the unaccelerated motion vector"/>
|
||||
<arg name="dy_unaccel" type="fixed"
|
||||
summary="the y component of the unaccelerated motion vector"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
||||
@@ -0,0 +1,604 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<protocol name="text_input_unstable_v3">
|
||||
<copyright>
|
||||
Copyright © 2012, 2013 Intel Corporation
|
||||
Copyright © 2015, 2016 Jan Arne Petersen
|
||||
Copyright © 2017, 2018 Red Hat, Inc.
|
||||
Copyright © 2018 Purism SPC
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of
|
||||
the copyright holders not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission. The copyright holders make no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied
|
||||
warranty.
|
||||
|
||||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="Protocol for composing text">
|
||||
This protocol allows compositors to act as input methods and to send text
|
||||
to applications. A text input object is used to manage state of what are
|
||||
typically text entry fields in the application.
|
||||
|
||||
This document adheres to the RFC 2119 when using words like "must",
|
||||
"should", "may", etc.
|
||||
|
||||
Warning! The protocol described in this file is experimental and
|
||||
backward incompatible changes may be made. Backward compatible changes
|
||||
may be added together with the corresponding interface version bump.
|
||||
Backward incompatible changes are done by bumping the version number in
|
||||
the protocol and interface names and resetting the interface version.
|
||||
Once the protocol is to be declared stable, the 'z' prefix and the
|
||||
version number in the protocol and interface names are removed and the
|
||||
interface version number is reset.
|
||||
</description>
|
||||
|
||||
<interface name="zwp_text_input_v3" version="2">
|
||||
<description summary="text input">
|
||||
The zwp_text_input_v3 interface represents text input and input methods
|
||||
associated with a seat. It provides enter/leave events to follow the
|
||||
text input focus for a seat.
|
||||
|
||||
Requests are used to enable/disable the text-input object and set
|
||||
state information like surrounding and selected text or the content type.
|
||||
The information about the entered text is sent to the text-input object
|
||||
via the preedit_string and commit_string events.
|
||||
|
||||
Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices
|
||||
must not point to middle bytes inside a code point: they must either
|
||||
point to the first byte of a code point or to the end of the buffer.
|
||||
Lengths must be measured between two valid indices.
|
||||
|
||||
Focus moving throughout surfaces will result in the emission of
|
||||
zwp_text_input_v3.enter and zwp_text_input_v3.leave events. The focused
|
||||
surface must commit zwp_text_input_v3.enable and
|
||||
zwp_text_input_v3.disable requests as the keyboard focus moves across
|
||||
editable and non-editable elements of the UI. Those two requests are not
|
||||
expected to be paired with each other, the compositor must be able to
|
||||
handle consecutive series of the same request.
|
||||
|
||||
State is sent by the state requests (set_surrounding_text,
|
||||
set_content_type and set_cursor_rectangle) and a commit request. After an
|
||||
enter event or disable request all state information is invalidated and
|
||||
needs to be resent by the client.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="Destroy the wp_text_input">
|
||||
Destroy the wp_text_input object. Also disables all surfaces enabled
|
||||
through this wp_text_input object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="enable">
|
||||
<description summary="Request text input to be enabled">
|
||||
Requests text input on the surface previously obtained from the enter
|
||||
event.
|
||||
|
||||
This request must be issued every time the focused text input changes
|
||||
to a new one, including within the current surface. Use
|
||||
zwp_text_input_v3.disable when there is no longer any input focus on
|
||||
the current surface.
|
||||
|
||||
Clients must not enable more than one text input on the single seat
|
||||
and should disable the current text input before enabling the new one.
|
||||
Requests to enable a text input when another text input is enabled
|
||||
on the same seat must be ignored by compositor.
|
||||
|
||||
This request resets all state associated with previous enable, disable,
|
||||
set_surrounding_text, set_text_change_cause, set_content_type, and
|
||||
set_cursor_rectangle requests, as well as the state associated with
|
||||
preedit_string, commit_string, and delete_surrounding_text events.
|
||||
|
||||
The set_surrounding_text, set_content_type and set_cursor_rectangle
|
||||
requests must follow if the text input supports the necessary
|
||||
functionality.
|
||||
|
||||
State set with this request is double-buffered. It will get applied on
|
||||
the next zwp_text_input_v3.commit request, and stay valid until the
|
||||
next committed enable or disable request.
|
||||
|
||||
The changes must be applied by the compositor after issuing a
|
||||
zwp_text_input_v3.commit request.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="disable">
|
||||
<description summary="Disable text input on a surface">
|
||||
Explicitly disable text input on the current surface (typically when
|
||||
there is no focus on any text entry inside the surface).
|
||||
|
||||
State set with this request is double-buffered. It will get applied on
|
||||
the next zwp_text_input_v3.commit request.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="set_surrounding_text">
|
||||
<description summary="sets the surrounding text">
|
||||
Sets the surrounding plain text around the input, excluding the preedit
|
||||
text.
|
||||
|
||||
The client should notify the compositor of any changes in any of the
|
||||
values carried with this request, including changes caused by handling
|
||||
incoming text-input events as well as changes caused by other
|
||||
mechanisms like keyboard typing.
|
||||
|
||||
If the client is unaware of the text around the cursor, it should not
|
||||
issue this request, to signify lack of support to the compositor.
|
||||
|
||||
Text is UTF-8 encoded, and should include the cursor position, the
|
||||
complete selection and additional characters before and after them.
|
||||
There is a maximum length of wayland messages, so text can not be
|
||||
longer than 4000 bytes.
|
||||
|
||||
Cursor is the byte offset of the cursor within text buffer.
|
||||
|
||||
Anchor is the byte offset of the selection anchor within text buffer.
|
||||
If there is no selected text, anchor is the same as cursor.
|
||||
|
||||
If any preedit text is present, it is replaced with a cursor for the
|
||||
purpose of this event.
|
||||
|
||||
Values set with this request are double-buffered. They will get applied
|
||||
on the next zwp_text_input_v3.commit request, and stay valid until the
|
||||
next committed enable or disable request.
|
||||
|
||||
The initial state for affected fields is empty, meaning that the text
|
||||
input does not support sending surrounding text. If the empty values
|
||||
get applied, subsequent attempts to change them may have no effect.
|
||||
</description>
|
||||
<arg name="text" type="string"/>
|
||||
<arg name="cursor" type="int"/>
|
||||
<arg name="anchor" type="int"/>
|
||||
</request>
|
||||
|
||||
<enum name="change_cause">
|
||||
<description summary="text change reason">
|
||||
Reason for the change of surrounding text or cursor posision.
|
||||
</description>
|
||||
<entry name="input_method" value="0" summary="input method caused the change"/>
|
||||
<entry name="other" value="1" summary="something else than the input method caused the change"/>
|
||||
</enum>
|
||||
|
||||
<request name="set_text_change_cause">
|
||||
<description summary="indicates the cause of surrounding text change">
|
||||
Tells the compositor why the text surrounding the cursor changed.
|
||||
|
||||
Whenever the client detects an external change in text, cursor, or
|
||||
anchor posision, it must issue this request to the compositor. This
|
||||
request is intended to give the input method a chance to update the
|
||||
preedit text in an appropriate way, e.g. by removing it when the user
|
||||
starts typing with a keyboard.
|
||||
|
||||
cause describes the source of the change.
|
||||
|
||||
The value set with this request is double-buffered. It must be applied
|
||||
and reset to initial at the next zwp_text_input_v3.commit request.
|
||||
|
||||
The initial value of cause is input_method.
|
||||
</description>
|
||||
<arg name="cause" type="uint" enum="change_cause"/>
|
||||
</request>
|
||||
|
||||
<enum name="content_hint" bitfield="true">
|
||||
<description summary="content hint">
|
||||
Content hint is a bitmask to allow to modify the behavior of the text
|
||||
input.
|
||||
</description>
|
||||
<entry name="none" value="0x0" summary="no special behavior"/>
|
||||
<entry name="completion" value="0x1" summary="suggest word completions"/>
|
||||
<entry name="spellcheck" value="0x2" summary="suggest word corrections"/>
|
||||
<entry name="auto_capitalization" value="0x4" summary="switch to uppercase letters at the start of a sentence"/>
|
||||
<entry name="lowercase" value="0x8" summary="prefer lowercase letters"/>
|
||||
<entry name="uppercase" value="0x10" summary="prefer uppercase letters"/>
|
||||
<entry name="titlecase" value="0x20" summary="prefer casing for titles and headings (can be language dependent)"/>
|
||||
<entry name="hidden_text" value="0x40" summary="characters should be hidden"/>
|
||||
<entry name="sensitive_data" value="0x80" summary="typed text should not be stored"/>
|
||||
<entry name="latin" value="0x100" summary="just Latin characters should be entered"/>
|
||||
<entry name="multiline" value="0x200" summary="the text input is multiline"/>
|
||||
<entry
|
||||
name="on_screen_input_provided" value="0x400" since="2"
|
||||
summary="an on-screen way to fill in the input is already provided by the client"/>
|
||||
<entry
|
||||
name="no_emoji" value="0x800" since="2"
|
||||
summary="prefer not offering emoji support"/>
|
||||
<entry
|
||||
name="preedit_shown" value="0x1000" since="2"
|
||||
summary="the text input will display preedit text in place"/>
|
||||
</enum>
|
||||
|
||||
<enum name="content_purpose">
|
||||
<description summary="content purpose">
|
||||
The content purpose allows to specify the primary purpose of a text
|
||||
input.
|
||||
|
||||
This allows an input method to show special purpose input panels with
|
||||
extra characters or to disallow some characters.
|
||||
</description>
|
||||
<entry name="normal" value="0" summary="default input, allowing all characters"/>
|
||||
<entry name="alpha" value="1" summary="allow only alphabetic characters"/>
|
||||
<entry name="digits" value="2" summary="allow only digits"/>
|
||||
<entry name="number" value="3" summary="input a number (including decimal separator and sign)"/>
|
||||
<entry name="phone" value="4" summary="input a phone number"/>
|
||||
<entry name="url" value="5" summary="input an URL"/>
|
||||
<entry name="email" value="6" summary="input an email address"/>
|
||||
<entry name="name" value="7" summary="input a name of a person"/>
|
||||
<entry name="password" value="8" summary="input a password (combine with sensitive_data hint)"/>
|
||||
<entry name="pin" value="9" summary="input is a numeric password (combine with sensitive_data hint)"/>
|
||||
<entry name="date" value="10" summary="input a date"/>
|
||||
<entry name="time" value="11" summary="input a time"/>
|
||||
<entry name="datetime" value="12" summary="input a date and time"/>
|
||||
<entry name="terminal" value="13" summary="input for a terminal"/>
|
||||
</enum>
|
||||
|
||||
<request name="set_content_type">
|
||||
<description summary="set content purpose and hint">
|
||||
Sets the content purpose and content hint. While the purpose is the
|
||||
basic purpose of an input field, the hint flags allow to modify some of
|
||||
the behavior.
|
||||
|
||||
Values set with this request are double-buffered. They will get applied
|
||||
on the next zwp_text_input_v3.commit request.
|
||||
Subsequent attempts to update them may have no effect. The values
|
||||
remain valid until the next committed enable or disable request.
|
||||
|
||||
The initial value for hint is none, and the initial value for purpose
|
||||
is normal.
|
||||
</description>
|
||||
<arg name="hint" type="uint" enum="content_hint"/>
|
||||
<arg name="purpose" type="uint" enum="content_purpose"/>
|
||||
</request>
|
||||
|
||||
<request name="set_cursor_rectangle">
|
||||
<description summary="set cursor position">
|
||||
Marks an area around the cursor as a x, y, width, height rectangle in
|
||||
surface local coordinates.
|
||||
|
||||
Allows the compositor to put a window with word suggestions near the
|
||||
cursor, without obstructing the text being input.
|
||||
|
||||
If the client is unaware of the position of edited text, it should not
|
||||
issue this request, to signify lack of support to the compositor.
|
||||
|
||||
Values set with this request are double-buffered. They will get applied
|
||||
on the next zwp_text_input_v3.commit request, and stay valid until the
|
||||
next committed enable or disable request.
|
||||
|
||||
The initial values describing a cursor rectangle are empty. That means
|
||||
the text input does not support describing the cursor area. If the
|
||||
empty values get applied, subsequent attempts to change them may have
|
||||
no effect.
|
||||
|
||||
As of version 2, the zwp_text_input_v3.commit request does not apply
|
||||
values sent with this request. Instead, it stores them in a separate
|
||||
"committed" area. The committed values, if still valid, get applied on
|
||||
the next wl_surface.commit request on the surface with text-input focus.
|
||||
Both committed and applied values get invalidated on:
|
||||
|
||||
- the next committed enable or disable request, or
|
||||
- a change of the focused surface of the text-input (leave or enter events).
|
||||
|
||||
This double stage application allows the compositor to position
|
||||
the input method popup in the same frame as the contents
|
||||
of the text on the surface are updated.
|
||||
</description>
|
||||
<arg name="x" type="int"/>
|
||||
<arg name="y" type="int"/>
|
||||
<arg name="width" type="int"/>
|
||||
<arg name="height" type="int"/>
|
||||
</request>
|
||||
|
||||
<request name="commit">
|
||||
<description summary="commit state">
|
||||
Atomically applies state changes recently sent to the compositor.
|
||||
|
||||
The commit request establishes and updates the state of the client, and
|
||||
must be issued after any changes to apply them.
|
||||
|
||||
Text input state (enabled status, content purpose, content hint,
|
||||
surrounding text and change cause, cursor rectangle) is conceptually
|
||||
double-buffered within the context of a text input, i.e. between a
|
||||
committed enable request and the following committed enable or disable
|
||||
request.
|
||||
|
||||
Protocol requests modify the pending state, as opposed to the current
|
||||
state in use by the input method. A commit request atomically applies
|
||||
all pending state, replacing the current state. After commit, the new
|
||||
pending state is as documented for each related request.
|
||||
|
||||
Requests are applied in the order of arrival.
|
||||
|
||||
Neither current nor pending state are modified unless noted otherwise.
|
||||
|
||||
The compositor must count the number of commit requests coming from
|
||||
each zwp_text_input_v3 object and use the count as the serial in done
|
||||
events.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="enter">
|
||||
<description summary="enter event">
|
||||
Notification that this seat's text-input focus is on a certain surface.
|
||||
|
||||
If client has created multiple text input objects, compositor must send
|
||||
this event to all of them.
|
||||
|
||||
When the seat has the keyboard capability the text-input focus follows
|
||||
the keyboard focus. This event sets the current surface for the
|
||||
text-input object.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
</event>
|
||||
|
||||
<event name="leave">
|
||||
<description summary="leave event">
|
||||
Notification that this seat's text-input focus is no longer on a
|
||||
certain surface. The client should reset any preedit string previously
|
||||
set.
|
||||
|
||||
The leave notification clears the current surface. It is sent before
|
||||
the enter notification for the new focus. After leave event, compositor
|
||||
must ignore requests from any text input instances until next enter
|
||||
event.
|
||||
|
||||
When the seat has the keyboard capability the text-input focus follows
|
||||
the keyboard focus.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
</event>
|
||||
|
||||
<event name="preedit_string">
|
||||
<description summary="pre-edit">
|
||||
Notify when a new composing text (pre-edit) should be set at the
|
||||
current cursor position. Any previously set composing text must be
|
||||
removed. Any previously existing selected text must be removed.
|
||||
|
||||
The argument text contains the pre-edit string buffer.
|
||||
|
||||
The parameters cursor_begin and cursor_end are counted in bytes
|
||||
relative to the beginning of the submitted text buffer. Cursor should
|
||||
be hidden when both are equal to -1.
|
||||
|
||||
They could be represented by the client as a line if both values are
|
||||
the same, or as a text highlight otherwise.
|
||||
|
||||
Values set with this event are double-buffered. They must be applied
|
||||
and reset to initial on the next zwp_text_input_v3.done event.
|
||||
|
||||
The initial value of text is an empty string, and cursor_begin,
|
||||
cursor_end and cursor_hidden are all 0.
|
||||
</description>
|
||||
<arg name="text" type="string" allow-null="true"/>
|
||||
<arg name="cursor_begin" type="int"/>
|
||||
<arg name="cursor_end" type="int"/>
|
||||
</event>
|
||||
|
||||
<event name="commit_string">
|
||||
<description summary="text commit">
|
||||
Notify when text should be inserted into the editor widget. The text to
|
||||
commit could be either just a single character after a key press or the
|
||||
result of some composing (pre-edit).
|
||||
|
||||
Values set with this event are double-buffered. They must be applied
|
||||
and reset to initial on the next zwp_text_input_v3.done event.
|
||||
|
||||
The initial value of text is an empty string.
|
||||
</description>
|
||||
<arg name="text" type="string" allow-null="true"/>
|
||||
</event>
|
||||
|
||||
<event name="delete_surrounding_text">
|
||||
<description summary="delete surrounding text">
|
||||
Notify when the text around the current cursor position should be
|
||||
deleted.
|
||||
|
||||
Before_length and after_length are the number of bytes before and after
|
||||
the current cursor index (excluding the selection) to delete.
|
||||
|
||||
If a preedit text is present, in effect before_length is counted from
|
||||
the beginning of it, and after_length from its end (see done event
|
||||
sequence).
|
||||
|
||||
Values set with this event are double-buffered. They must be applied
|
||||
and reset to initial on the next zwp_text_input_v3.done event.
|
||||
|
||||
The initial values of both before_length and after_length are 0.
|
||||
</description>
|
||||
<arg name="before_length" type="uint" summary="length of text before current cursor position"/>
|
||||
<arg name="after_length" type="uint" summary="length of text after current cursor position"/>
|
||||
</event>
|
||||
|
||||
<event name="done">
|
||||
<description summary="apply changes">
|
||||
Instruct the application to apply changes to state requested by the
|
||||
preedit_string, commit_string delete_surrounding_text, and action
|
||||
events.
|
||||
|
||||
The state relating to these events is double-buffered, and each one
|
||||
modifies the pending state. This event replaces the current state with
|
||||
the pending state.
|
||||
|
||||
The application must proceed by evaluating the changes in the following
|
||||
order:
|
||||
|
||||
1. Replace existing preedit string with the cursor.
|
||||
2. Delete requested surrounding text.
|
||||
3. Insert commit string with the cursor at its end.
|
||||
4. Calculate surrounding text to send.
|
||||
5. Insert new preedit text in cursor position.
|
||||
6. Place cursor inside preedit text.
|
||||
7. Perform the requested action.
|
||||
|
||||
The serial number reflects the last state of the zwp_text_input_v3
|
||||
object known to the compositor. The value of the serial argument must
|
||||
be equal to the number of commit requests already issued on that object.
|
||||
|
||||
When the client receives a done event with a serial different than the
|
||||
number of past commit requests, it must proceed with evaluating and
|
||||
applying the changes as normal, except it should not change the current
|
||||
state of the zwp_text_input_v3 object. All pending state requests
|
||||
(set_surrounding_text, set_content_type and set_cursor_rectangle) on
|
||||
the zwp_text_input_v3 object should be sent and committed after
|
||||
receiving a zwp_text_input_v3.done event with a matching serial.
|
||||
</description>
|
||||
<arg name="serial" type="uint"/>
|
||||
</event>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
<enum name="error" since="2">
|
||||
<entry name="invalid_action" value="0" summary="an invalid or duplicate action was specified"/>
|
||||
</enum>
|
||||
|
||||
<enum name="action" since="2">
|
||||
<description summary="action">
|
||||
A possible action to perform on a text input.
|
||||
|
||||
The submit action is intended for input entries that expect some sort of
|
||||
activation after user interaction, e.g. the URL entry in a browser.
|
||||
</description>
|
||||
<entry name="none" value="0" summary="no action"/>
|
||||
<entry name="submit" value="1" summary="the action is submitted"/>
|
||||
</enum>
|
||||
|
||||
<event name="action" since="2">
|
||||
<description summary="action performed">
|
||||
An action was performed on this text input.
|
||||
|
||||
Values set with this event are double-buffered. They must be applied
|
||||
and reset to initial on the next zwp_text_input_v3.done event.
|
||||
|
||||
The initial value of action is none.
|
||||
</description>
|
||||
<arg name="action" type="uint" enum="action" summary="action performed"/>
|
||||
<arg name="serial" type="uint" summary="serial number of the action event"/>
|
||||
</event>
|
||||
|
||||
<event name="language" since="2">
|
||||
<description summary="notify of language selection">
|
||||
Notify the application of language used by the input method.
|
||||
|
||||
This event will be sent on creation if known and for all subsequent changes.
|
||||
|
||||
The language should be specified as an IETF BCP 47 tag.
|
||||
Setting an empty string will reset any known language back to the default unknown state.
|
||||
</description>
|
||||
<arg name="language" type="string" summary="new language set by IME"/>
|
||||
</event>
|
||||
|
||||
<request name="set_available_actions" since="2">
|
||||
<description summary="set the available actions">
|
||||
Set the actions available for this text input.
|
||||
|
||||
Values set with this request are double-buffered. They will get applied
|
||||
on the next zwp_text_input_v3.commit request.
|
||||
|
||||
If the available_actions array contains the none action, or contains the
|
||||
same action multiple times, the compositor must raise the invalid_action
|
||||
protocol error.
|
||||
|
||||
Initially, no actions are available.
|
||||
</description>
|
||||
<arg name="available_actions" type="array" summary="available actions"/>
|
||||
</request>
|
||||
|
||||
<request name="show_input_panel" since="2">
|
||||
<description summary="show input panel">
|
||||
Requests an input panel to be shown (e.g. a on-screen keyboard).
|
||||
|
||||
This request only hints the desired interaction pattern from the
|
||||
client side, and its effect may be ignored by compositors given
|
||||
other environmental factors. Repeated calls will be ignored.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="hide_input_panel" since="2">
|
||||
<description summary="hide input panel">
|
||||
Requests an input panel to be hidden.
|
||||
|
||||
This request only hints the desired interaction pattern from the
|
||||
client side, and its effect may be ignored by compositors given
|
||||
other environmental factors. Repeated calls will be ignored.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="preedit_hint">
|
||||
<description summary="preedit style hint">
|
||||
Style hints for the preedit string.
|
||||
</description>
|
||||
<entry name="whole" value="1" summary="simple pre-edit text style, typically underlined"/>
|
||||
<entry name="selection" value="2"
|
||||
summary="hint for a selected piece of text, e.g. per-character navigation and composition"/>
|
||||
<entry name="prediction" value="3" summary="predicted text, not typed by the user"/>
|
||||
<entry name="prefix" value="4"
|
||||
summary="prefixed text not being currently edited, e.g. prior to a 'selection' section"/>
|
||||
<entry name="suffix" value="5"
|
||||
summary="suffixed text not being currently edited, e.g. after a 'selection' section"/>
|
||||
<entry name="spelling_error" value="6" summary="spelling error"/>
|
||||
<entry name="compose_error" value="7"
|
||||
summary="wrong composition, e.g. user input that can not be transliterated"/>
|
||||
</enum>
|
||||
|
||||
<event name="preedit_hint" since="2">
|
||||
<description summary="pre-edit">
|
||||
Notify of contextual hints for the pre-edit string. This
|
||||
event is always sent together with a zwp_text_input_v3.preedit_string
|
||||
event.
|
||||
|
||||
The parameters start and end are counted in bytes relative to the
|
||||
beginning of the text buffer submitted through
|
||||
zwp_text_input_v3.preedit_string, and represent the substring in the
|
||||
pre-edit text affected by the hint.
|
||||
|
||||
Multiple events may be submitted if the preedit string has different
|
||||
sections. The extent of hints may overlap. The parts of the preedit
|
||||
string that are not covered by any zwp_text_input_v3.preedit_hint event,
|
||||
the text will be considered unhinted. This is also the case if no
|
||||
preedit_hint event is sent.
|
||||
|
||||
Clients should provide recognizable visuals to these hints. if they are
|
||||
unable to comply with this requisition, it may be preferable for them
|
||||
keep the preedit_shown content hint disabled.
|
||||
|
||||
Values set with this event are double-buffered. They must be applied
|
||||
and reset on the next zwp_text_input_v3.done event.
|
||||
</description>
|
||||
<arg name="start" type="uint" summary="starting point of the affected substring"/>
|
||||
<arg name="end" type="uint" summary="end point of the affected substring"/>
|
||||
<arg name="hint" type="uint" enum="preedit_hint" summary="hint to apply"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="zwp_text_input_manager_v3" version="2">
|
||||
<description summary="text input manager">
|
||||
A factory for text-input objects. This object is a global singleton.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="Destroy the wp_text_input_manager">
|
||||
Destroy the wp_text_input_manager object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="get_text_input">
|
||||
<description summary="create a new text input object">
|
||||
Creates a new text-input object for a given seat.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwp_text_input_v3"/>
|
||||
<arg name="seat" type="object" interface="wl_seat"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
||||
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="viewporter">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2013-2016 Collabora, Ltd.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="wp_viewporter" version="1">
|
||||
<description summary="surface cropping and scaling">
|
||||
The global interface exposing surface cropping and scaling
|
||||
capabilities is used to instantiate an interface extension for a
|
||||
wl_surface object. This extended interface will then allow
|
||||
cropping and scaling the surface contents, effectively
|
||||
disconnecting the direct relationship between the buffer and the
|
||||
surface size.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="unbind from the cropping and scaling interface">
|
||||
Informs the server that the client will not be using this
|
||||
protocol object anymore. This does not affect any other objects,
|
||||
wp_viewport objects included.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="viewport_exists" value="0"
|
||||
summary="the surface already has a viewport object associated"/>
|
||||
</enum>
|
||||
|
||||
<request name="get_viewport">
|
||||
<description summary="extend surface interface for crop and scale">
|
||||
Instantiate an interface extension for the given wl_surface to
|
||||
crop and scale its content. If the given wl_surface already has
|
||||
a wp_viewport object associated, the viewport_exists
|
||||
protocol error is raised.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="wp_viewport"
|
||||
summary="the new viewport interface id"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"
|
||||
summary="the surface"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="wp_viewport" version="1">
|
||||
<description summary="crop and scale interface to a wl_surface">
|
||||
An additional interface to a wl_surface object, which allows the
|
||||
client to specify the cropping and scaling of the surface
|
||||
contents.
|
||||
|
||||
This interface works with two concepts: the source rectangle (src_x,
|
||||
src_y, src_width, src_height), and the destination size (dst_width,
|
||||
dst_height). The contents of the source rectangle are scaled to the
|
||||
destination size, and content outside the source rectangle is ignored.
|
||||
This state is double-buffered, and is applied on the next
|
||||
wl_surface.commit.
|
||||
|
||||
The two parts of crop and scale state are independent: the source
|
||||
rectangle, and the destination size. Initially both are unset, that
|
||||
is, no scaling is applied. The whole of the current wl_buffer is
|
||||
used as the source, and the surface size is as defined in
|
||||
wl_surface.attach.
|
||||
|
||||
If the destination size is set, it causes the surface size to become
|
||||
dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
this size. This overrides whatever the attached wl_buffer size is,
|
||||
unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
has no content and therefore no size. Otherwise, the size is always
|
||||
at least 1x1 in surface local coordinates.
|
||||
|
||||
If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
taken as the source. If the source rectangle is set and the destination
|
||||
size is not set, then src_width and src_height must be integers, and the
|
||||
surface size becomes the source rectangle size. This results in cropping
|
||||
without scaling. If src_width or src_height are not integers and
|
||||
destination size is not set, the bad_size protocol error is raised when
|
||||
the surface state is applied.
|
||||
|
||||
The coordinate transformations from buffer pixel coordinates up to
|
||||
the surface-local coordinates happen in the following order:
|
||||
1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
3. crop and scale (wp_viewport.set*)
|
||||
This means, that the source rectangle coordinates of crop and scale
|
||||
are given in the coordinates after the buffer transform and scale,
|
||||
i.e. in the coordinates that would be the surface-local coordinates
|
||||
if the crop and scale was not applied.
|
||||
|
||||
If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
Otherwise, if the source rectangle is partially or completely outside of
|
||||
the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
out_of_buffer error.
|
||||
|
||||
If the wl_surface associated with the wp_viewport is destroyed,
|
||||
all wp_viewport requests except 'destroy' raise the protocol error
|
||||
no_surface.
|
||||
|
||||
If the wp_viewport object is destroyed, the crop and scale
|
||||
state is removed from the wl_surface. The change will be applied
|
||||
on the next wl_surface.commit.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="remove scaling and cropping from the surface">
|
||||
The associated wl_surface's crop and scale state is removed.
|
||||
The change is applied on the next wl_surface.commit.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="bad_value" value="0"
|
||||
summary="negative or zero values in width or height"/>
|
||||
<entry name="bad_size" value="1"
|
||||
summary="destination size is not integer"/>
|
||||
<entry name="out_of_buffer" value="2"
|
||||
summary="source rectangle extends outside of the content area"/>
|
||||
<entry name="no_surface" value="3"
|
||||
summary="the wl_surface was destroyed"/>
|
||||
</enum>
|
||||
|
||||
<request name="set_source">
|
||||
<description summary="set the source rectangle for cropping">
|
||||
Set the source rectangle of the associated wl_surface. See
|
||||
wp_viewport for the description, and relation to the wl_buffer
|
||||
size.
|
||||
|
||||
If all of x, y, width and height are -1.0, the source rectangle is
|
||||
unset instead. Any other set of values where width or height are zero
|
||||
or negative, or x or y are negative, raise the bad_value protocol
|
||||
error.
|
||||
|
||||
The crop and scale state is double-buffered state, and will be
|
||||
applied on the next wl_surface.commit.
|
||||
</description>
|
||||
<arg name="x" type="fixed" summary="source rectangle x"/>
|
||||
<arg name="y" type="fixed" summary="source rectangle y"/>
|
||||
<arg name="width" type="fixed" summary="source rectangle width"/>
|
||||
<arg name="height" type="fixed" summary="source rectangle height"/>
|
||||
</request>
|
||||
|
||||
<request name="set_destination">
|
||||
<description summary="set the surface size for scaling">
|
||||
Set the destination size of the associated wl_surface. See
|
||||
wp_viewport for the description, and relation to the wl_buffer
|
||||
size.
|
||||
|
||||
If width is -1 and height is -1, the destination size is unset
|
||||
instead. Any other pair of values for width and height that
|
||||
contains zero or negative values raises the bad_value protocol
|
||||
error.
|
||||
|
||||
The crop and scale state is double-buffered state, and will be
|
||||
applied on the next wl_surface.commit.
|
||||
</description>
|
||||
<arg name="width" type="int" summary="surface width"/>
|
||||
<arg name="height" type="int" summary="surface height"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
||||
@@ -0,0 +1,281 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="wlr_data_control_unstable_v1">
|
||||
<copyright>
|
||||
Copyright © 2018 Simon Ser
|
||||
Copyright © 2019 Ivan Molodetskikh
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of
|
||||
the copyright holders not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission. The copyright holders make no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied
|
||||
warranty.
|
||||
|
||||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="control data devices">
|
||||
This protocol allows a privileged client to control data devices. In
|
||||
particular, the client will be able to manage the current selection and take
|
||||
the role of a clipboard manager.
|
||||
|
||||
Warning! The protocol described in this file is experimental and
|
||||
backward incompatible changes may be made. Backward compatible changes
|
||||
may be added together with the corresponding interface version bump.
|
||||
Backward incompatible changes are done by bumping the version number in
|
||||
the protocol and interface names and resetting the interface version.
|
||||
Once the protocol is to be declared stable, the 'z' prefix and the
|
||||
version number in the protocol and interface names are removed and the
|
||||
interface version number is reset.
|
||||
|
||||
Note! This protocol is deprecated and not intended for production use.
|
||||
For clipboard management, use the ext-data-control-v1 protocol.
|
||||
</description>
|
||||
|
||||
<interface name="zwlr_data_control_manager_v1" version="2">
|
||||
<description summary="manager to control data devices">
|
||||
This interface is a manager that allows creating per-seat data device
|
||||
controls.
|
||||
</description>
|
||||
|
||||
<request name="create_data_source">
|
||||
<description summary="create a new data source">
|
||||
Create a new data source.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwlr_data_control_source_v1"
|
||||
summary="data source to create"/>
|
||||
</request>
|
||||
|
||||
<request name="get_data_device">
|
||||
<description summary="get a data device for a seat">
|
||||
Create a data device that can be used to manage a seat's selection.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwlr_data_control_device_v1"/>
|
||||
<arg name="seat" type="object" interface="wl_seat"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the manager">
|
||||
All objects created by the manager will still remain valid, until their
|
||||
appropriate destroy request has been called.
|
||||
</description>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_data_control_device_v1" version="2">
|
||||
<description summary="manage a data device for a seat">
|
||||
This interface allows a client to manage a seat's selection.
|
||||
|
||||
When the seat is destroyed, this object becomes inert.
|
||||
</description>
|
||||
|
||||
<request name="set_selection">
|
||||
<description summary="copy data to the selection">
|
||||
This request asks the compositor to set the selection to the data from
|
||||
the source on behalf of the client.
|
||||
|
||||
The given source may not be used in any further set_selection or
|
||||
set_primary_selection requests. Attempting to use a previously used
|
||||
source is a protocol error.
|
||||
|
||||
To unset the selection, set the source to NULL.
|
||||
</description>
|
||||
<arg name="source" type="object" interface="zwlr_data_control_source_v1"
|
||||
allow-null="true"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy this data device">
|
||||
Destroys the data device object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="data_offer">
|
||||
<description summary="introduce a new wlr_data_control_offer">
|
||||
The data_offer event introduces a new wlr_data_control_offer object,
|
||||
which will subsequently be used in either the
|
||||
wlr_data_control_device.selection event (for the regular clipboard
|
||||
selections) or the wlr_data_control_device.primary_selection event (for
|
||||
the primary clipboard selections). Immediately following the
|
||||
wlr_data_control_device.data_offer event, the new data_offer object
|
||||
will send out wlr_data_control_offer.offer events to describe the MIME
|
||||
types it offers.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwlr_data_control_offer_v1"/>
|
||||
</event>
|
||||
|
||||
<event name="selection">
|
||||
<description summary="advertise new selection">
|
||||
The selection event is sent out to notify the client of a new
|
||||
wlr_data_control_offer for the selection for this device. The
|
||||
wlr_data_control_device.data_offer and the wlr_data_control_offer.offer
|
||||
events are sent out immediately before this event to introduce the data
|
||||
offer object. The selection event is sent to a client when a new
|
||||
selection is set. The wlr_data_control_offer is valid until a new
|
||||
wlr_data_control_offer or NULL is received. The client must destroy the
|
||||
previous selection wlr_data_control_offer, if any, upon receiving this
|
||||
event.
|
||||
|
||||
The first selection event is sent upon binding the
|
||||
wlr_data_control_device object.
|
||||
</description>
|
||||
<arg name="id" type="object" interface="zwlr_data_control_offer_v1"
|
||||
allow-null="true"/>
|
||||
</event>
|
||||
|
||||
<event name="finished">
|
||||
<description summary="this data control is no longer valid">
|
||||
This data control object is no longer valid and should be destroyed by
|
||||
the client.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<event name="primary_selection" since="2">
|
||||
<description summary="advertise new primary selection">
|
||||
The primary_selection event is sent out to notify the client of a new
|
||||
wlr_data_control_offer for the primary selection for this device. The
|
||||
wlr_data_control_device.data_offer and the wlr_data_control_offer.offer
|
||||
events are sent out immediately before this event to introduce the data
|
||||
offer object. The primary_selection event is sent to a client when a
|
||||
new primary selection is set. The wlr_data_control_offer is valid until
|
||||
a new wlr_data_control_offer or NULL is received. The client must
|
||||
destroy the previous primary selection wlr_data_control_offer, if any,
|
||||
upon receiving this event.
|
||||
|
||||
If the compositor supports primary selection, the first
|
||||
primary_selection event is sent upon binding the
|
||||
wlr_data_control_device object.
|
||||
</description>
|
||||
<arg name="id" type="object" interface="zwlr_data_control_offer_v1"
|
||||
allow-null="true"/>
|
||||
</event>
|
||||
|
||||
<request name="set_primary_selection" since="2">
|
||||
<description summary="copy data to the primary selection">
|
||||
This request asks the compositor to set the primary selection to the
|
||||
data from the source on behalf of the client.
|
||||
|
||||
The given source may not be used in any further set_selection or
|
||||
set_primary_selection requests. Attempting to use a previously used
|
||||
source is a protocol error.
|
||||
|
||||
To unset the primary selection, set the source to NULL.
|
||||
|
||||
The compositor will ignore this request if it does not support primary
|
||||
selection.
|
||||
</description>
|
||||
<arg name="source" type="object" interface="zwlr_data_control_source_v1"
|
||||
allow-null="true"/>
|
||||
</request>
|
||||
|
||||
<enum name="error" since="2">
|
||||
<entry name="used_source" value="1"
|
||||
summary="source given to set_selection or set_primary_selection was already used before"/>
|
||||
</enum>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_data_control_source_v1" version="1">
|
||||
<description summary="offer to transfer data">
|
||||
The wlr_data_control_source object is the source side of a
|
||||
wlr_data_control_offer. It is created by the source client in a data
|
||||
transfer and provides a way to describe the offered data and a way to
|
||||
respond to requests to transfer the data.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_offer" value="1"
|
||||
summary="offer sent after wlr_data_control_device.set_selection"/>
|
||||
</enum>
|
||||
|
||||
<request name="offer">
|
||||
<description summary="add an offered MIME type">
|
||||
This request adds a MIME type to the set of MIME types advertised to
|
||||
targets. Can be called several times to offer multiple types.
|
||||
|
||||
Calling this after wlr_data_control_device.set_selection is a protocol
|
||||
error.
|
||||
</description>
|
||||
<arg name="mime_type" type="string"
|
||||
summary="MIME type offered by the data source"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy this source">
|
||||
Destroys the data source object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="send">
|
||||
<description summary="send the data">
|
||||
Request for data from the client. Send the data as the specified MIME
|
||||
type over the passed file descriptor, then close it.
|
||||
</description>
|
||||
<arg name="mime_type" type="string" summary="MIME type for the data"/>
|
||||
<arg name="fd" type="fd" summary="file descriptor for the data"/>
|
||||
</event>
|
||||
|
||||
<event name="cancelled">
|
||||
<description summary="selection was cancelled">
|
||||
This data source is no longer valid. The data source has been replaced
|
||||
by another data source.
|
||||
|
||||
The client should clean up and destroy this data source.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_data_control_offer_v1" version="1">
|
||||
<description summary="offer to transfer data">
|
||||
A wlr_data_control_offer represents a piece of data offered for transfer
|
||||
by another client (the source client). The offer describes the different
|
||||
MIME types that the data can be converted to and provides the mechanism
|
||||
for transferring the data directly from the source client.
|
||||
</description>
|
||||
|
||||
<request name="receive">
|
||||
<description summary="request that the data is transferred">
|
||||
To transfer the offered data, the client issues this request and
|
||||
indicates the MIME type it wants to receive. The transfer happens
|
||||
through the passed file descriptor (typically created with the pipe
|
||||
system call). The source client writes the data in the MIME type
|
||||
representation requested and then closes the file descriptor.
|
||||
|
||||
The receiving client reads from the read end of the pipe until EOF and
|
||||
then closes its end, at which point the transfer is complete.
|
||||
|
||||
This request may happen multiple times for different MIME types.
|
||||
</description>
|
||||
<arg name="mime_type" type="string"
|
||||
summary="MIME type desired by receiver"/>
|
||||
<arg name="fd" type="fd" summary="file descriptor for data transfer"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy this offer">
|
||||
Destroys the data offer object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="offer">
|
||||
<description summary="advertise offered MIME type">
|
||||
Sent immediately after creating the wlr_data_control_offer object.
|
||||
One event per offered MIME type.
|
||||
</description>
|
||||
<arg name="mime_type" type="string" summary="offered MIME type"/>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="xdg_toplevel_icon_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2023-2024 Matthias Klumpp
|
||||
Copyright © 2024 David Edmundson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="protocol to assign icons to toplevels">
|
||||
This protocol allows clients to set icons for their toplevel surfaces
|
||||
either via the XDG icon stock (using an icon name), or from pixel data.
|
||||
|
||||
A toplevel icon represents the individual toplevel (unlike the application
|
||||
or launcher icon, which represents the application as a whole), and may be
|
||||
shown in window switchers, window overviews and taskbars that list
|
||||
individual windows.
|
||||
|
||||
This document adheres to RFC 2119 when using words like "must",
|
||||
"should", "may", etc.
|
||||
|
||||
Warning! The protocol described in this file is currently in the testing
|
||||
phase. Backward compatible changes may be added together with the
|
||||
corresponding interface version bump. Backward incompatible changes can
|
||||
only be done by creating a new major version of the extension.
|
||||
</description>
|
||||
|
||||
<interface name="xdg_toplevel_icon_manager_v1" version="1">
|
||||
<description summary="interface to manage toplevel icons">
|
||||
This interface allows clients to create toplevel window icons and set
|
||||
them on toplevel windows to be displayed to the user.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the toplevel icon manager">
|
||||
Destroy the toplevel icon manager.
|
||||
This does not destroy objects created with the manager.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="create_icon">
|
||||
<description summary="create a new icon instance">
|
||||
Creates a new icon object. This icon can then be attached to a
|
||||
xdg_toplevel via the 'set_icon' request.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="xdg_toplevel_icon_v1"/>
|
||||
</request>
|
||||
|
||||
<request name="set_icon">
|
||||
<description summary="set an icon on a toplevel window">
|
||||
This request assigns the icon 'icon' to 'toplevel', or clears the
|
||||
toplevel icon if 'icon' was null.
|
||||
This state is double-buffered and is applied on the next
|
||||
wl_surface.commit of the toplevel.
|
||||
|
||||
After making this call, the xdg_toplevel_icon_v1 provided as 'icon'
|
||||
can be destroyed by the client without 'toplevel' losing its icon.
|
||||
The xdg_toplevel_icon_v1 is immutable from this point, and any
|
||||
future attempts to change it must raise the
|
||||
'xdg_toplevel_icon_v1.immutable' protocol error.
|
||||
|
||||
The compositor must set the toplevel icon from either the pixel data
|
||||
the icon provides, or by loading a stock icon using the icon name.
|
||||
See the description of 'xdg_toplevel_icon_v1' for details.
|
||||
|
||||
If 'icon' is set to null, the icon of the respective toplevel is reset
|
||||
to its default icon (usually the icon of the application, derived from
|
||||
its desktop-entry file, or a placeholder icon).
|
||||
If this request is passed an icon with no pixel buffers or icon name
|
||||
assigned, the icon must be reset just like if 'icon' was null.
|
||||
</description>
|
||||
<arg name="toplevel" type="object" interface="xdg_toplevel" summary="the toplevel to act on"/>
|
||||
<arg name="icon" type="object" interface="xdg_toplevel_icon_v1" allow-null="true"/>
|
||||
</request>
|
||||
|
||||
<event name="icon_size">
|
||||
<description summary="describes a supported & preferred icon size">
|
||||
This event indicates an icon size the compositor prefers to be
|
||||
available if the client has scalable icons and can render to any size.
|
||||
|
||||
When the 'xdg_toplevel_icon_manager_v1' object is created, the
|
||||
compositor may send one or more 'icon_size' events to describe the list
|
||||
of preferred icon sizes. If the compositor has no size preference, it
|
||||
may not send any 'icon_size' event, and it is up to the client to
|
||||
decide a suitable icon size.
|
||||
|
||||
A sequence of 'icon_size' events must be finished with a 'done' event.
|
||||
If the compositor has no size preferences, it must still send the
|
||||
'done' event, without any preceding 'icon_size' events.
|
||||
</description>
|
||||
<arg name="size" type="int"
|
||||
summary="the edge size of the square icon in surface-local coordinates, e.g. 64"/>
|
||||
</event>
|
||||
|
||||
<event name="done">
|
||||
<description summary="all information has been sent">
|
||||
This event is sent after all 'icon_size' events have been sent.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="xdg_toplevel_icon_v1" version="1">
|
||||
<description summary="a toplevel window icon">
|
||||
This interface defines a toplevel icon.
|
||||
An icon can have a name, and multiple buffers.
|
||||
In order to be applied, the icon must have either a name, or at least
|
||||
one buffer assigned. Applying an empty icon (with no buffer or name) to
|
||||
a toplevel should reset its icon to the default icon.
|
||||
|
||||
It is up to compositor policy whether to prefer using a buffer or loading
|
||||
an icon via its name. See 'set_name' and 'add_buffer' for details.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_buffer"
|
||||
summary="the provided buffer does not satisfy requirements"
|
||||
value="1"/>
|
||||
<entry name="immutable"
|
||||
summary="the icon has already been assigned to a toplevel and must not be changed"
|
||||
value="2"/>
|
||||
<entry name="no_buffer"
|
||||
summary="the provided buffer has been destroyed before the toplevel icon"
|
||||
value="3"/>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the icon object">
|
||||
Destroys the 'xdg_toplevel_icon_v1' object.
|
||||
The icon must still remain set on every toplevel it was assigned to,
|
||||
until the toplevel icon is reset explicitly.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="set_name">
|
||||
<description summary="set an icon name">
|
||||
This request assigns an icon name to this icon.
|
||||
Any previously set name is overridden.
|
||||
|
||||
The compositor must resolve 'icon_name' according to the lookup rules
|
||||
described in the XDG icon theme specification[1] using the
|
||||
environment's current icon theme.
|
||||
|
||||
If the compositor does not support icon names or cannot resolve
|
||||
'icon_name' according to the XDG icon theme specification it must
|
||||
fall back to using pixel buffer data instead.
|
||||
|
||||
If this request is made after the icon has been assigned to a toplevel
|
||||
via 'set_icon', an 'immutable' error must be raised.
|
||||
|
||||
[1]: https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
|
||||
</description>
|
||||
<arg name="icon_name" type="string"/>
|
||||
</request>
|
||||
|
||||
<request name="add_buffer">
|
||||
<description summary="add icon data from a pixel buffer">
|
||||
This request adds pixel data supplied as wl_buffer to the icon.
|
||||
|
||||
The client should add pixel data for all icon sizes and scales that
|
||||
it can provide, or which are explicitly requested by the compositor
|
||||
via 'icon_size' events on xdg_toplevel_icon_manager_v1.
|
||||
|
||||
The wl_buffer supplying pixel data as 'buffer' must be backed by wl_shm
|
||||
and must be a square (width and height being equal).
|
||||
If any of these buffer requirements are not fulfilled, a 'invalid_buffer'
|
||||
error must be raised.
|
||||
|
||||
If this icon instance already has a buffer of the same size and scale
|
||||
from a previous 'add_buffer' request, data from the last request
|
||||
overrides the preexisting pixel data.
|
||||
|
||||
The wl_buffer must be kept alive for as long as the xdg_toplevel_icon
|
||||
it is associated with is not destroyed, otherwise a 'no_buffer' error
|
||||
is raised. The buffer contents must not be modified after it was
|
||||
assigned to the icon. As a result, the region of the wl_shm_pool's
|
||||
backing storage used for the wl_buffer must not be modified after this
|
||||
request is sent. The wl_buffer.release event is unused.
|
||||
|
||||
If this request is made after the icon has been assigned to a toplevel
|
||||
via 'set_icon', an 'immutable' error must be raised.
|
||||
</description>
|
||||
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||
<arg name="scale" type="int"
|
||||
summary="the scaling factor of the icon, e.g. 1"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
||||
@@ -0,0 +1,426 @@
|
||||
/* Zero-copy game frames: banner_ahb_v1 + the game's AHardwareBuffers on the sc_layer SurfaceControl.
|
||||
* See ahb_swapchain.h and ZERO_COPY_SPIKE.md. */
|
||||
#define _GNU_SOURCE
|
||||
#include "ahb_swapchain.h"
|
||||
#include "banner_color.h"
|
||||
#include "banner_ext.h"
|
||||
#include "sc_layer.h"
|
||||
#include "vk_present.h"
|
||||
#include "banner-ahb-v1-server-protocol.h"
|
||||
#include <android/hardware_buffer.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MOD_QCOM_COMPRESSED 0x0500000000000001ULL /* DRM_FORMAT_MOD_QCOM_COMPRESSED (UBWC) */
|
||||
|
||||
/* linux/dma-buf.h (not in the NDK sysroot's older headers): sync_file export / import. */
|
||||
struct banner_dma_buf_sync_file { uint32_t flags; int32_t fd; };
|
||||
#define BANNER_DMA_BUF_SYNC_READ 1u
|
||||
#define BANNER_DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR('b', 2, struct banner_dma_buf_sync_file)
|
||||
#define BANNER_DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW('b', 3, struct banner_dma_buf_sync_file)
|
||||
|
||||
extern volatile int g_zero_copy;
|
||||
|
||||
/* One per wl_buffer the game attached an AHardwareBuffer to. Lives while the wl_buffer exists or
|
||||
* the buffer is still on the layer / held by SurfaceFlinger, whichever is longer. */
|
||||
struct ahb_buf {
|
||||
uint64_t id; /* the token sc_layer.c hands back */
|
||||
struct dmabuf_buffer *b; /* one reference held for the life of this record */
|
||||
AHardwareBuffer *ahb; /* our reference to the game's buffer */
|
||||
int w, h;
|
||||
uint32_t stride, image_count;
|
||||
uint32_t format; /* AHARDWAREBUFFER_FORMAT_* gralloc gave it (10-bit for HDR10) */
|
||||
uint64_t modifier;
|
||||
struct wl_client *client;
|
||||
struct wl_resource *resource; /* the wl_buffer; NULL once the client destroyed it */
|
||||
struct wl_listener resource_destroy;
|
||||
int on_layer; /* set on the SurfaceControl (or not yet released by SurfaceFlinger) */
|
||||
int release_pending; /* the surface let go of it while on the layer */
|
||||
int64_t deferred_ns; /* when it did (the perf line: how long the display kept it) */
|
||||
struct surface *surface; /* for the paced release; NULL = release at once */
|
||||
struct wl_event_source *fence_src; /* fallback: waiting the release fence in the event loop */
|
||||
int fence_fd;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
static struct wl_list g_bufs;
|
||||
static struct wl_list g_clients; /* bound banner_ahb_v1 resources (wl_resource links) */
|
||||
static uint64_t g_next_id = 1;
|
||||
static struct wl_event_loop *g_loop;
|
||||
static unsigned g_stat_zero_copy;
|
||||
static int g_export_failed_logged, g_import_failed_logged;
|
||||
static int g_advertised; /* the global exists */
|
||||
static int g_mode_sent = -1; /* the mode clients were last told (-1 = none yet) */
|
||||
static struct surface *g_announced; /* "presenting X without a copy" said for this surface */
|
||||
static volatile int64_t g_last_zero_copy_ns; /* when a frame last went on the layer without a copy */
|
||||
|
||||
/* SurfaceFlinger's callback thread -> compositor thread: released tokens + their fences. */
|
||||
struct released { uint64_t id; int fd; };
|
||||
static pthread_mutex_t g_rel_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct released *g_rel;
|
||||
static int g_rel_n, g_rel_cap;
|
||||
static int g_rel_pipe[2] = {-1, -1};
|
||||
|
||||
/* Which swapchains were announced (one log line per swapchain, not per image). */
|
||||
struct chain_seen { struct wl_client *client; int w, h; uint32_t image_count; uint64_t modifier; uint32_t format; };
|
||||
static struct chain_seen g_last_chain;
|
||||
|
||||
static int64_t now_ns(void) {
|
||||
struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||
}
|
||||
|
||||
static struct ahb_buf *find_buf(uint64_t id) {
|
||||
struct ahb_buf *ab;
|
||||
wl_list_for_each(ab, &g_bufs, link)
|
||||
if (ab->id == id) return ab;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void buf_free(struct ahb_buf *ab) {
|
||||
if (ab->resource) { wl_list_remove(&ab->resource_destroy.link); ab->resource = NULL; }
|
||||
if (ab->fence_src) { wl_event_source_remove(ab->fence_src); ab->fence_src = NULL; }
|
||||
if (ab->fence_fd >= 0) { close(ab->fence_fd); ab->fence_fd = -1; }
|
||||
wl_list_remove(&ab->link);
|
||||
*banner_dmabuf_ahb_slot(ab->b) = NULL;
|
||||
AHardwareBuffer_release(ab->ahb);
|
||||
banner_dmabuf_unref(ab->b);
|
||||
free(ab);
|
||||
}
|
||||
|
||||
/* Free once neither the client (wl_buffer) nor the display (layer) refers to it. */
|
||||
static void maybe_free(struct ahb_buf *ab) {
|
||||
if (!ab->resource && !ab->on_layer && !ab->fence_src) buf_free(ab);
|
||||
}
|
||||
|
||||
static void on_buffer_resource_destroyed(struct wl_listener *l, void *data) {
|
||||
struct ahb_buf *ab = wl_container_of(l, ab, resource_destroy);
|
||||
wl_list_remove(&ab->resource_destroy.link);
|
||||
ab->resource = NULL;
|
||||
ab->release_pending = 0; /* nothing left to release to */
|
||||
maybe_free(ab);
|
||||
}
|
||||
|
||||
/* ---- release: SurfaceFlinger is done with the buffer -> the game's next acquire waits, then wl_buffer.release */
|
||||
|
||||
static void send_deferred_release(struct ahb_buf *ab) {
|
||||
if (ab->release_pending && ab->resource)
|
||||
banner_release_buffer(ab->surface, ab->resource, ab->surface != NULL, ab->deferred_ns);
|
||||
ab->release_pending = 0;
|
||||
ab->surface = NULL;
|
||||
}
|
||||
|
||||
static int on_fence_readable(int fd, uint32_t mask, void *data) {
|
||||
struct ahb_buf *ab = data;
|
||||
wl_event_source_remove(ab->fence_src);
|
||||
ab->fence_src = NULL;
|
||||
close(ab->fence_fd);
|
||||
ab->fence_fd = -1;
|
||||
send_deferred_release(ab);
|
||||
maybe_free(ab);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compositor thread. Puts the display's release fence into the dma-buf so the game's driver waits
|
||||
* on it before rendering into the buffer again (Mesa exports every fence of the dma-buf as the
|
||||
* acquire semaphore), then gives the buffer back. If the kernel refuses the import, the release
|
||||
* itself waits for the fence instead. */
|
||||
static void handle_released(uint64_t id, int fd) {
|
||||
struct ahb_buf *ab = find_buf(id);
|
||||
if (!ab) { if (fd >= 0) close(fd); return; }
|
||||
ab->on_layer = 0;
|
||||
if (fd >= 0) {
|
||||
struct banner_dma_buf_sync_file imp = {.flags = BANNER_DMA_BUF_SYNC_READ, .fd = fd};
|
||||
int dmabuf_fd = banner_dmabuf_fd(ab->b);
|
||||
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, BANNER_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) {
|
||||
close(fd);
|
||||
} else {
|
||||
if (!g_import_failed_logged) {
|
||||
g_import_failed_logged = 1;
|
||||
banner_log("layer", "zero-copy: DMA_BUF_IOCTL_IMPORT_SYNC_FILE failed (%s): releases wait for the display's fence here instead",
|
||||
strerror(errno));
|
||||
}
|
||||
/* Wait it out in the event loop (a sync_file is readable once signalled). */
|
||||
struct pollfd p = {.fd = fd, .events = POLLIN};
|
||||
if (poll(&p, 1, 0) > 0) {
|
||||
close(fd);
|
||||
} else {
|
||||
ab->fence_fd = fd;
|
||||
ab->fence_src = wl_event_loop_add_fd(g_loop, fd, WL_EVENT_READABLE, on_fence_readable, ab);
|
||||
if (!ab->fence_src) { close(fd); ab->fence_fd = -1; }
|
||||
else return; /* released from on_fence_readable */
|
||||
}
|
||||
}
|
||||
}
|
||||
send_deferred_release(ab);
|
||||
maybe_free(ab);
|
||||
}
|
||||
|
||||
static int on_release_pipe(int fd, uint32_t mask, void *data) {
|
||||
char buf[64];
|
||||
while (read(fd, buf, sizeof(buf)) > 0) {}
|
||||
for (;;) {
|
||||
struct released r;
|
||||
pthread_mutex_lock(&g_rel_lock);
|
||||
if (g_rel_n == 0) { pthread_mutex_unlock(&g_rel_lock); break; }
|
||||
r = g_rel[0];
|
||||
memmove(g_rel, g_rel + 1, (size_t)(--g_rel_n) * sizeof(*g_rel));
|
||||
pthread_mutex_unlock(&g_rel_lock);
|
||||
handle_released(r.id, r.fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* SurfaceFlinger's callback thread. */
|
||||
void ahb_swapchain_layer_released(void *token, int release_fd) {
|
||||
pthread_mutex_lock(&g_rel_lock);
|
||||
if (g_rel_n == g_rel_cap) {
|
||||
int cap = g_rel_cap ? g_rel_cap * 2 : 16;
|
||||
struct released *n = realloc(g_rel, (size_t)cap * sizeof(*n));
|
||||
if (!n) { pthread_mutex_unlock(&g_rel_lock); if (release_fd >= 0) close(release_fd); return; }
|
||||
g_rel = n; g_rel_cap = cap;
|
||||
}
|
||||
g_rel[g_rel_n++] = (struct released){(uint64_t)(uintptr_t)token, release_fd};
|
||||
pthread_mutex_unlock(&g_rel_lock);
|
||||
if (g_rel_pipe[1] >= 0) { char c = 1; if (write(g_rel_pipe[1], &c, 1) < 0) {} }
|
||||
}
|
||||
|
||||
/* ---- present */
|
||||
|
||||
int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b) {
|
||||
return b && *banner_dmabuf_ahb_slot((struct dmabuf_buffer *)b) != NULL;
|
||||
}
|
||||
|
||||
int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_w, int scene_h) {
|
||||
struct ahb_buf *ab = b ? *banner_dmabuf_ahb_slot(b) : NULL;
|
||||
if (!ab) return -1;
|
||||
int dmabuf_fd = banner_dmabuf_fd(b);
|
||||
/* Acquire fence: the game's render fence, which its driver put into the dma-buf before the
|
||||
* commit (Mesa's implicit sync). The display waits on it, not the CPU. */
|
||||
int acquire = -1;
|
||||
struct banner_dma_buf_sync_file exp = {.flags = BANNER_DMA_BUF_SYNC_READ, .fd = -1};
|
||||
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, BANNER_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) {
|
||||
acquire = exp.fd;
|
||||
} else if (dmabuf_fd >= 0) {
|
||||
if (!g_export_failed_logged) {
|
||||
g_export_failed_logged = 1;
|
||||
banner_log("layer", "zero-copy: DMA_BUF_IOCTL_EXPORT_SYNC_FILE failed (%s): waiting for each frame on the CPU instead",
|
||||
strerror(errno));
|
||||
}
|
||||
struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN}; /* readable = the writers are done */
|
||||
int r;
|
||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
||||
}
|
||||
int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h,
|
||||
s ? banner_surface_color(s) : NULL, ab->format);
|
||||
if (r < 0) return -1;
|
||||
if (r == 1) return 0; /* nothing of it on screen: not on the layer, nothing to release later */
|
||||
if (!ab->on_layer) {
|
||||
ab->on_layer = 1;
|
||||
g_stat_zero_copy++;
|
||||
g_last_zero_copy_ns = now_ns();
|
||||
}
|
||||
if (s && g_announced != s) {
|
||||
char name[160];
|
||||
g_announced = s;
|
||||
banner_surface_describe(s, name, sizeof(name));
|
||||
banner_log("layer", "zero-copy: presenting %s without a copy", name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ahb_swapchain_last_frame_age_ms(void) {
|
||||
int64_t t = g_last_zero_copy_ns;
|
||||
if (!t) return -1;
|
||||
int64_t age = (now_ns() - t) / 1000000LL;
|
||||
return age > INT32_MAX ? INT32_MAX : (int)age;
|
||||
}
|
||||
|
||||
int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *buffer, struct surface *s, int paced) {
|
||||
struct ahb_buf *ab = b ? *banner_dmabuf_ahb_slot(b) : NULL;
|
||||
if (!ab || !ab->on_layer || !buffer || ab->resource != buffer) return 0;
|
||||
ab->release_pending = 1;
|
||||
ab->deferred_ns = now_ns();
|
||||
ab->surface = paced ? s : NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ahb_swapchain_surface_gone(struct surface *s) {
|
||||
struct ahb_buf *ab;
|
||||
wl_list_for_each(ab, &g_bufs, link)
|
||||
if (ab->surface == s) ab->surface = NULL;
|
||||
}
|
||||
|
||||
unsigned ahb_swapchain_stats_take(void) {
|
||||
unsigned n = g_stat_zero_copy;
|
||||
g_stat_zero_copy = 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
int ahb_swapchain_advertised(void) { return g_advertised; }
|
||||
|
||||
uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b) {
|
||||
struct ahb_buf *ab = b ? *banner_dmabuf_ahb_slot((struct dmabuf_buffer *)b) : NULL;
|
||||
return ab ? ab->format : 0;
|
||||
}
|
||||
|
||||
/* ---- banner_ahb_v1 */
|
||||
|
||||
static void ahb_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
|
||||
static void ahb_attach(struct wl_client *c, struct wl_resource *r, struct wl_resource *buffer, int32_t sock,
|
||||
uint32_t width, uint32_t height, uint32_t stride, uint32_t mod_hi, uint32_t mod_lo,
|
||||
uint32_t image_count) {
|
||||
struct dmabuf_buffer *b = banner_dmabuf_from_resource(buffer);
|
||||
uint64_t modifier = ((uint64_t)mod_hi << 32) | mod_lo;
|
||||
if (!b) {
|
||||
banner_log("layer", "zero-copy: %s attached an AHardwareBuffer to a non-dma-buf wl_buffer, ignored", banner_client_name(c));
|
||||
close(sock);
|
||||
return;
|
||||
}
|
||||
void **slot = banner_dmabuf_ahb_slot(b);
|
||||
if (*slot) { close(sock); return; } /* once per buffer */
|
||||
|
||||
/* The handle was written into the socket before the request was sent; a short wait is just
|
||||
* insurance against a slow sender. */
|
||||
struct pollfd p = {.fd = sock, .events = POLLIN};
|
||||
int pr;
|
||||
do { pr = poll(&p, 1, 1000); } while (pr < 0 && errno == EINTR);
|
||||
AHardwareBuffer *ahb = NULL;
|
||||
int rc = pr > 0 ? AHardwareBuffer_recvHandleFromUnixSocket(sock, &ahb) : -1;
|
||||
close(sock);
|
||||
if (rc != 0 || !ahb) {
|
||||
banner_log("layer", "zero-copy: receiving %s's AHardwareBuffer failed (%s)", banner_client_name(c),
|
||||
pr > 0 ? "recvHandleFromUnixSocket" : "nothing on the socket");
|
||||
return;
|
||||
}
|
||||
AHardwareBuffer_Desc d;
|
||||
AHardwareBuffer_describe(ahb, &d);
|
||||
int bw, bh;
|
||||
banner_dmabuf_size(b, &bw, &bh);
|
||||
if ((int)d.width != bw || (int)d.height != bh || (int)width != bw || (int)height != bh) {
|
||||
banner_log("layer", "zero-copy: %s's AHardwareBuffer is %ux%u but its wl_buffer %dx%d, ignored",
|
||||
banner_client_name(c), d.width, d.height, bw, bh);
|
||||
AHardwareBuffer_release(ahb);
|
||||
return;
|
||||
}
|
||||
|
||||
struct ahb_buf *ab = calloc(1, sizeof(*ab));
|
||||
if (!ab) { AHardwareBuffer_release(ahb); wl_client_post_no_memory(c); return; }
|
||||
ab->id = g_next_id++;
|
||||
ab->b = b;
|
||||
banner_dmabuf_ref(b);
|
||||
ab->ahb = ahb;
|
||||
ab->w = bw; ab->h = bh;
|
||||
ab->stride = d.stride ? d.stride : stride;
|
||||
ab->image_count = image_count;
|
||||
ab->format = d.format;
|
||||
ab->modifier = modifier;
|
||||
ab->client = c;
|
||||
ab->resource = buffer;
|
||||
ab->resource_destroy.notify = on_buffer_resource_destroyed;
|
||||
wl_resource_add_destroy_listener(buffer, &ab->resource_destroy);
|
||||
ab->fence_fd = -1;
|
||||
wl_list_insert(g_bufs.prev, &ab->link);
|
||||
*slot = ab;
|
||||
|
||||
if (g_last_chain.client != c || g_last_chain.w != bw || g_last_chain.h != bh ||
|
||||
g_last_chain.image_count != image_count || g_last_chain.modifier != modifier || g_last_chain.format != d.format) {
|
||||
g_last_chain = (struct chain_seen){c, bw, bh, image_count, modifier, d.format};
|
||||
banner_log("layer", "zero-copy: AHB swapchain from %s (%u images, %dx%d, %s, %s, stride %u px)", banner_client_name(c),
|
||||
image_count, bw, bh, banner_ahb_format_name(d.format), modifier == MOD_QCOM_COMPRESSED ? "UBWC (QCOM_COMPRESSED)"
|
||||
: modifier == 0 ? "linear" : "unknown modifier", ab->stride);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct banner_ahb_v1_interface ahb_impl = {
|
||||
.destroy = ahb_destroy,
|
||||
.attach = ahb_attach,
|
||||
};
|
||||
|
||||
static void on_client_resource_destroyed(struct wl_resource *r) {
|
||||
wl_list_remove(wl_resource_get_link(r));
|
||||
}
|
||||
|
||||
static void bind_ahb(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
static struct wl_client *last_named;
|
||||
if (ver > 2) ver = 2;
|
||||
struct wl_resource *r = wl_resource_create(c, &banner_ahb_v1_interface, (int)ver, id);
|
||||
if (!r) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(r, &ahb_impl, NULL, on_client_resource_destroyed);
|
||||
wl_list_insert(&g_clients, wl_resource_get_link(r));
|
||||
/* The mode travels with the bind, so the client's registry roundtrip already has it when it
|
||||
* decides about its first swapchain. */
|
||||
if (ver >= BANNER_AHB_V1_MODE_SINCE_VERSION) banner_ahb_v1_send_mode(r, g_zero_copy ? 1u : 0u);
|
||||
/* One line per program, not per surface-format query (each binds its own). */
|
||||
if (last_named != c) {
|
||||
last_named = c;
|
||||
banner_log("layer", "zero-copy: %s bound banner_ahb_v1 version %u (%s)", banner_client_name(c), ver,
|
||||
ver >= 2 ? "follows the live switch" : "version 1: decides from its launch environment only");
|
||||
}
|
||||
}
|
||||
|
||||
void ahb_swapchain_set_mode(int on, int live) {
|
||||
on = on ? 1 : 0;
|
||||
g_zero_copy = on;
|
||||
if (!g_advertised) {
|
||||
if (live) banner_log("layer", "zero-copy switched %s from the drawer, but no display layer is available on this device: no change",
|
||||
on ? "on" : "off");
|
||||
return;
|
||||
}
|
||||
if (g_mode_sent == on) return;
|
||||
g_mode_sent = on;
|
||||
int told = 0;
|
||||
struct wl_resource *r;
|
||||
wl_resource_for_each(r, &g_clients) {
|
||||
if (wl_resource_get_version(r) >= BANNER_AHB_V1_MODE_SINCE_VERSION) {
|
||||
banner_ahb_v1_send_mode(r, (uint32_t)on);
|
||||
told++;
|
||||
}
|
||||
}
|
||||
/* The next chain and the next fullscreen frame get announced again. */
|
||||
memset(&g_last_chain, 0, sizeof(g_last_chain));
|
||||
g_announced = NULL;
|
||||
if (live)
|
||||
banner_log("layer", "zero-copy switched %s from the drawer: %d bound program%s told to rebuild their swapchains%s",
|
||||
on ? "on" : "off", told, told == 1 ? "" : "s",
|
||||
on ? "; frames go on the display layer once the new gralloc swapchain is up"
|
||||
: "; gralloc frames still in flight stay on the layer (or take the copy path) until then");
|
||||
else
|
||||
banner_log("layer", "zero-copy: %s at launch (%s)", on ? "on" : "off",
|
||||
on ? "BANNER_WAYLAND_ZERO_COPY=1: games present their own gralloc buffers on the display layer"
|
||||
: "the drawer's Zero-copy presentation switch turns it on live");
|
||||
if (live) wl_display_flush_clients(banner_get_display());
|
||||
banner_request_redraw();
|
||||
}
|
||||
|
||||
void ahb_swapchain_init(struct wl_display *display) {
|
||||
wl_list_init(&g_bufs);
|
||||
wl_list_init(&g_clients);
|
||||
if (!sc_layer_available()) {
|
||||
banner_log("layer", "zero-copy: no display layer on this device (see the line above): banner_ahb_v1 not advertised");
|
||||
return;
|
||||
}
|
||||
g_loop = wl_display_get_event_loop(display);
|
||||
if (pipe2(g_rel_pipe, O_CLOEXEC | O_NONBLOCK) != 0) {
|
||||
banner_log("error", "zero-copy: release pipe creation failed (%s); zero-copy presents disabled", strerror(errno));
|
||||
g_rel_pipe[0] = g_rel_pipe[1] = -1;
|
||||
return;
|
||||
}
|
||||
wl_event_loop_add_fd(g_loop, g_rel_pipe[0], WL_EVENT_READABLE, on_release_pipe, NULL);
|
||||
if (!wl_global_create(display, &banner_ahb_v1_interface, 2, NULL, bind_ahb)) {
|
||||
banner_log("error", "zero-copy: banner_ahb_v1 global creation failed");
|
||||
return;
|
||||
}
|
||||
g_advertised = 1;
|
||||
banner_log("layer", "zero-copy: banner_ahb_v1 version 2 advertised (games built for it present their own gralloc buffers while the switch is on)");
|
||||
ahb_swapchain_set_mode(g_zero_copy, 0);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef AHB_SWAPCHAIN_H
|
||||
#define AHB_SWAPCHAIN_H
|
||||
/*
|
||||
* Zero-copy game frames (layer mode, BANNER_WAYLAND_ZERO_COPY=1 at launch, the drawer's "Zero-copy
|
||||
* presentation" switch live): the guest half of the design in ZERO_COPY_SPIKE.md. Our Wayland Turnip
|
||||
* (banners-turnip-wayland, patches/wayland/banner_ahb_wsi.py) binds the private global banner_ahb_v1
|
||||
* (version 2), which this compositor advertises on every session where a display layer is possible,
|
||||
* and follows its `mode` event: while the mode is on, each swapchain the game creates has its images
|
||||
* allocated as gralloc AHardwareBuffers, shared as dma-bufs through zwp_linux_dmabuf_v1 as before (so
|
||||
* the blit path still works) and handed to us once per wl_buffer over a socketpair
|
||||
* (banner_ahb_v1.attach). When such a buffer is the one fullscreen frame, it goes straight onto the
|
||||
* sc_layer SurfaceControl: SurfaceFlinger / the display scan out the game's own buffer, no copy
|
||||
* anywhere. A mode flip (ahb_swapchain_set_mode, from the drawer through the host queue) is
|
||||
* broadcast to every bound client; a client whose live swapchain was built for the other mode
|
||||
* retires it (VK_ERROR_OUT_OF_DATE_KHR) so the program rebuilds it, and until then its buffers keep
|
||||
* presenting as before: an attached AHardwareBuffer stays with its wl_buffer whatever the mode is.
|
||||
*
|
||||
* Fences stay implicit, in the dma-buf itself: Mesa imports the render fence into the dma-buf
|
||||
* before it commits, we export it as the layer's acquire fence (DMA_BUF_IOCTL_EXPORT_SYNC_FILE),
|
||||
* and import SurfaceFlinger's release fence back (DMA_BUF_IOCTL_IMPORT_SYNC_FILE) before sending
|
||||
* wl_buffer.release, so Mesa's acquire (wsi_create_sync_for_dma_buf_wait) waits for the display.
|
||||
*
|
||||
* Compositor thread unless noted. Without a usable display layer (sc_layer_available() == 0) the
|
||||
* global is not created and nothing here runs.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
struct dmabuf_buffer;
|
||||
struct surface;
|
||||
|
||||
/* ---- compositor.c -> ahb_swapchain.c */
|
||||
/* Create the banner_ahb_v1 global (when a display layer is possible at all) and the release queue. */
|
||||
void ahb_swapchain_init(struct wl_display *display);
|
||||
/* Zero-copy on/off, live: sets g_zero_copy, tells every bound client (banner_ahb_v1.mode) and logs
|
||||
* it (live = 1: a drawer switch mid-session; 0: the launch default). Compositor thread. */
|
||||
void ahb_swapchain_set_mode(int on, int live);
|
||||
/* Milliseconds since a game frame was last put on the layer without a copy (-1 = never). Any thread:
|
||||
* the drawer's status line. */
|
||||
int ahb_swapchain_last_frame_age_ms(void);
|
||||
/* 1 if the buffer carries an AHardwareBuffer from the game. */
|
||||
int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b);
|
||||
/* Show b (the topmost fullscreen frame, shown by surface s) on the layer without a copy.
|
||||
* 0 = done (or the same frame is already up), -1 = unavailable (draw the old way). */
|
||||
int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_w, int scene_h);
|
||||
/* Surface s lets go of buffer b (its wl_buffer `buffer`, NULL if the client destroyed it); paced =
|
||||
* the limiter's cadence applies. Returns 1 when the buffer is on the layer: the release is sent
|
||||
* from here once SurfaceFlinger's release fence is known. 0 = the caller releases as usual. */
|
||||
int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *buffer, struct surface *s, int paced);
|
||||
/* s is being destroyed: forget it (its deferred releases still go out, unpaced). */
|
||||
void ahb_swapchain_surface_gone(struct surface *s);
|
||||
/* Zero-copy frames since the last call (the 10 s summary). */
|
||||
unsigned ahb_swapchain_stats_take(void);
|
||||
/* 1 when the banner_ahb_v1 global exists (a display layer is possible): part of the HDR gate. */
|
||||
int ahb_swapchain_advertised(void);
|
||||
/* The AHARDWAREBUFFER_FORMAT_* of the game's buffer behind b, 0 when it has none. */
|
||||
uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b);
|
||||
|
||||
/* ---- sc_layer.c -> ahb_swapchain.c (SurfaceFlinger's callback thread): the layer let go of the
|
||||
* buffer behind `token`; release_fd (owned by the callee, -1 = none) signals when the display is
|
||||
* done reading it. */
|
||||
void ahb_swapchain_layer_released(void *token, int release_fd);
|
||||
|
||||
/* ---- ahb_swapchain.c -> compositor.c (hooks) */
|
||||
struct dmabuf_buffer *banner_dmabuf_from_resource(struct wl_resource *buffer);
|
||||
int banner_dmabuf_fd(const struct dmabuf_buffer *b); /* plane 0's dma-buf */
|
||||
void banner_dmabuf_size(const struct dmabuf_buffer *b, int *w, int *h);
|
||||
void **banner_dmabuf_ahb_slot(struct dmabuf_buffer *b); /* this module's per-buffer state */
|
||||
void banner_dmabuf_ref(struct dmabuf_buffer *b);
|
||||
void banner_dmabuf_unref(struct dmabuf_buffer *b);
|
||||
/* Give a wl_buffer back to its client now (paced = 0) or on the FPS limiter's cadence (s != NULL).
|
||||
* since_ns = when the compositor let go of it (CLOCK_MONOTONIC; the perf line's release latency). */
|
||||
void banner_release_buffer(struct surface *s, struct wl_resource *buffer, int paced, int64_t since_ns);
|
||||
/* Redraw the scene on the next tick (the present path may have changed). */
|
||||
void banner_request_redraw(void);
|
||||
/* "<title>" (program) of the window a surface belongs to, for the log. */
|
||||
void banner_surface_describe(const struct surface *s, char *out, size_t size);
|
||||
/* The surface's current image description (banner_color.h), NULL = none / HDR gate closed. */
|
||||
struct banner_color;
|
||||
const struct banner_color *banner_surface_color(const struct surface *s);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,150 @@
|
||||
#ifndef BANNER_COLOR_H
|
||||
#define BANNER_COLOR_H
|
||||
/*
|
||||
* HDR10 output on the Wayland backend (opt-in) — the compositor half of HDR_RECON.md Phase A (round 1)
|
||||
* plus HDR-aware composition (round 2, hdr_compose.h), implemented in wl_color_mgmt.c. The game half
|
||||
* already ships: Mesa's Wayland WSI in our Turnip is a wp_color_manager_v1 client and exposes
|
||||
* VK_COLOR_SPACE_HDR10_ST2084_EXT as soon as a compositor advertises BT.2020 + ST 2084; DXVK takes it
|
||||
* with DXVK_HDR=1 (the app exports it when the setting is on).
|
||||
*
|
||||
* THE GATE. Nothing here exists for a session unless all of these hold when the compositor starts:
|
||||
* - the container's / game's "HDR output" setting is on, or BANNER_WAYLAND_HDR=1 in their
|
||||
* environment (which overrides the setting either way);
|
||||
* - the display the game is on lists HDR10 among its supported HDR types (read by the app from
|
||||
* android.view.Display — a property of the connector, not of the device);
|
||||
* - display layers with dataspace control (ASurfaceTransaction_setBufferDataSpace, Android 10+)
|
||||
* and the zero-copy global (banner_ahb_v1): the HDR frame (or the composed HDR picture) is shown
|
||||
* on the game's own display layer, tagged BT2020_PQ.
|
||||
* In game, the drawer's HDR output switch (banner_color_set_output) flips between that and the same
|
||||
* frames tone-mapped to SDR, live; the gate itself never changes during a session.
|
||||
* A closed gate advertises nothing — no colour-management global, no 10-bit dma-buf formats — so the
|
||||
* session is byte-for-byte what it was before this file existed, and the session log says why.
|
||||
* BANNER_WAYLAND_HDR=force skips the display check only (testing the negotiation on an SDR panel;
|
||||
* SurfaceFlinger then tone-maps the layer, and says so in its composition type).
|
||||
*
|
||||
* WHAT AN OPEN GATE OFFERS (exactly the subset Mesa binds, HDR_RECON.md §2.2): wp_color_manager_v1
|
||||
* version 1 with the perceptual intent, the parametric creator + mastering-display metadata,
|
||||
* BT.2020 primaries and the ST 2084 (PQ) transfer function; zwp_linux_dmabuf_v1 adds AB30/XB30
|
||||
* (A2B10G10R10, the only 10-bit layout our zero-copy WSI can put in a gralloc buffer). A surface's
|
||||
* image description is double-buffered on wl_surface.commit; its frames go onto the game's display
|
||||
* layer tagged BT2020_PQ with the game's SMPTE 2086 / CTA-861.3 metadata (sc_layer.c).
|
||||
*
|
||||
* Compositor thread unless noted.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
/* ADataSpace values (NDK <android/data_space.h>) the layer path emits. */
|
||||
#define BANNER_ADATASPACE_UNKNOWN 0
|
||||
#define BANNER_ADATASPACE_BT2020_PQ 163971072 /* STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_FULL = 0x09c60000 */
|
||||
#define BANNER_ADATASPACE_BT2020_HLG 168165376 /* STANDARD_BT2020 | TRANSFER_HLG | RANGE_FULL */
|
||||
|
||||
/* One image description as the program made it, and what it becomes on a display layer. Immutable:
|
||||
* a changed description is a new record with a new identity. */
|
||||
struct banner_color {
|
||||
uint32_t identity; /* the id the `ready` event carried (never 0) */
|
||||
uint32_t primaries, tf; /* wp_color_manager_v1 named values */
|
||||
int32_t dataspace; /* ADataSpace on a display layer; 0 = none (treated as sRGB) */
|
||||
int has_st2086; /* SMPTE ST 2086: mastering display primaries + luminance */
|
||||
float red[2], green[2], blue[2], white[2]; /* CIE 1931 xy */
|
||||
float max_lum, min_lum; /* nits */
|
||||
int has_cta861; /* CTA-861.3 */
|
||||
float max_cll, max_fall; /* nits; 0 = not given */
|
||||
char text[256]; /* the session log's one-line summary of it */
|
||||
};
|
||||
|
||||
/* ---- app -> compositor (JNI, any thread) */
|
||||
/* mode 0 = off, 1 = BANNER_WAYLAND_HDR=1, 2 = BANNER_WAYLAND_HDR=force (testing). source names where
|
||||
* the switch came from; dxvk_hdr = DXVK_HDR=1 is in the game's environment; zero_copy_forced = the
|
||||
* app turned zero-copy presentation on for this session because HDR needs it. Before the start. */
|
||||
void banner_color_set_request(int mode, const char *source, int dxvk_hdr, int zero_copy_forced);
|
||||
/* The display the game is on, as android.view.Display reports it. Before the start (it feeds the
|
||||
* gate) and again whenever it changes (logged; the gate is decided once per session). */
|
||||
void banner_color_set_display(int id, const char *name, const char *formats, int hdr10, float max_lum,
|
||||
float max_avg, float min_lum, int ratio_available, float ratio, int api);
|
||||
/* One reading of Display.getHdrSdrRatio() (API 34+; < 0 = not available). listener = it came from
|
||||
* the display's ratio listener rather than the app's periodic sampler. */
|
||||
void banner_color_ratio_sample(float ratio, int listener);
|
||||
/* Milliseconds since an HDR frame last went onto a display layer; -1 = none this session. */
|
||||
int banner_color_last_frame_age_ms(void);
|
||||
/* -1 = the compositor has not decided yet, 0 = closed, 1 = open. */
|
||||
int banner_color_gate_state(void);
|
||||
/* The session is ending: write the summary line ("HDR on screen: …"). */
|
||||
void banner_color_session_end(void);
|
||||
/* 1 while HDR frames are really on screen: a frame tagged BT2020_PQ reached a display layer or the HDR
|
||||
* swapchain in the last 1.5 s AND, where the display reports an HDR/SDR ratio, its last reading is
|
||||
* above 1.01 (the HUD badge). */
|
||||
int banner_color_hdr_on_screen(void);
|
||||
/* The HUD / drawer state: 0 = no HDR frames on screen (or not confirmed yet), 1 = HDR frames on screen
|
||||
* with headroom (as banner_color_hdr_on_screen), 2 = HDR frames on screen but the display has given
|
||||
* them NO headroom (ratio <= 1.01) for 5 s or more - the brightness slider at maximum, or a screen
|
||||
* recording (Android turns HDR headroom off while the screen is recorded). */
|
||||
int banner_color_hdr_state(void);
|
||||
/* Nits SDR content is placed at inside an HDR picture (default 203, BT.2408); any thread. */
|
||||
void banner_color_set_sdr_white(float nits);
|
||||
float banner_color_sdr_white(void);
|
||||
/* The HDR session was asked for (BANNER_WAYLAND_HDR / the setting resolved on or force) — known before
|
||||
* the compositor starts, so the Vulkan instance can enable VK_EXT_swapchain_colorspace for it. */
|
||||
int banner_color_requested(void);
|
||||
/* The drawer's live "HDR output" switch, per session, starting ON. On = HDR frames go to the display as
|
||||
* HDR; off = the SAME frames are composed tone-mapped to SDR (hdr_compose.h) - the game is told nothing
|
||||
* and keeps rendering HDR (DXVK_HDR and the colour-manager offer were decided at launch). Compositor
|
||||
* thread (the app posts it through banner_host_hdr_output); logs the flip and redraws. */
|
||||
void banner_color_set_output(int on);
|
||||
/* 1 = HDR output on (any thread). */
|
||||
int banner_color_output(void);
|
||||
/* 1 while an HDR game's frames are being shown tone-mapped to SDR (the last one < 1.5 s ago); any thread. */
|
||||
int banner_color_tonemapped_on_screen(void);
|
||||
/* Device evidence beside the HDR/SDR headroom (the app, non-root APIs; any thread; HDR sessions only):
|
||||
* PowerManager thermal status (0..6, -1 unknown) + getThermalHeadroom(10) (< 0 = not available),
|
||||
* Settings.System SCREEN_BRIGHTNESS (0..255, -1 unknown) + SCREEN_BRIGHTNESS_MODE (1 auto, 0 manual).
|
||||
* Changes of status and brightness are logged; every no-headroom line, the 10 s line and the verdict
|
||||
* carry the last values. */
|
||||
void banner_color_env_sample(int thermal, float headroom, int brightness, int bmode);
|
||||
|
||||
/* ---- the explicit HDR headroom request (Android 15+: ASurfaceTransaction_setDesiredHdrHeadroom on the game
|
||||
* layer, SurfaceView.setDesiredHdrHeadroom on the screen surface). Some phones only boost HDR when asked. */
|
||||
/* The ratio to ask for an HDR frame of `c`: content peak (max CLL, else mastering max, else the display's
|
||||
* peak) / SDR white (203), capped at the display's highest ratio when it reports one; 0 = ask nothing
|
||||
* (not HDR, or the display reports it cannot boost). `why` gets the one-line reason. Any thread. */
|
||||
float banner_color_desired_headroom(const struct banner_color *c, char *why, size_t n);
|
||||
/* What was last asked for (> 0 the ratio, 0 nothing, -1 the API is missing): for the no-headroom lines. */
|
||||
void banner_color_note_headroom_request(float ratio);
|
||||
/* Display.getHighestHdrSdrRatio() (Android 16+; <= 0 = not reported). Any thread; logged when it arrives. */
|
||||
void banner_color_set_highest_ratio(float ratio);
|
||||
/* The headroom the SCREEN surface should ask for (frames through the HDR10 swapchain in the last 1.5 s),
|
||||
* 0 = none; `why` gets the reason. The app polls it and applies it. Any thread. */
|
||||
float banner_color_screen_headroom(char *why, size_t n);
|
||||
|
||||
/* ---- compositor.c -> here */
|
||||
/* Decide the gate (call after ahb_swapchain_init) and create the global when it is open. */
|
||||
void banner_color_init(struct wl_display *display);
|
||||
/* The gate is open: the 10-bit dma-buf formats may be advertised, descriptions may exist. */
|
||||
int banner_color_hdr_open(void);
|
||||
/* wl_surface.commit: the pending image description (if any request touched it) becomes current. */
|
||||
void banner_color_commit(struct wl_resource *surface);
|
||||
/* The surface's current image description; NULL = none (sRGB, today's default). */
|
||||
const struct banner_color *banner_color_of(struct wl_resource *surface);
|
||||
/* A program disconnected: if it presented HDR, its part of the summary is written now. */
|
||||
void banner_color_client_gone(struct wl_client *client);
|
||||
/* The 10 s summary tick (one `color` line when anything HDR happened in the window). */
|
||||
void banner_color_stats_tick(void);
|
||||
/* A frame of an HDR-described surface went through the compositor's own 8-bit sRGB pass this scene
|
||||
* (who = the window, reason = why it did not get the display layer). Shown untone-mapped. */
|
||||
void banner_color_frame_copied(const char *who, const char *reason);
|
||||
|
||||
/* ---- sc_layer.c / compositor.c -> here: a NEW frame of an HDR-described surface was shown, and how */
|
||||
enum banner_hdr_path {
|
||||
BANNER_HDR_ZERO_COPY = 0, /* the game's own gralloc buffer on its display layer, tagged */
|
||||
BANNER_HDR_LAYER_COPY, /* one 8-bit copy of the game's frame on its layer, tagged */
|
||||
BANNER_HDR_COMPOSED, /* the whole scene composed into one PQ picture on the game layer (hdr_compose.h) */
|
||||
BANNER_HDR_SWAPCHAIN, /* composed into PQ and presented through an HDR10 swapchain (frame generation) */
|
||||
BANNER_HDR_TONEMAPPED, /* composed and tone-mapped to SDR (HDR output switched off, or a present that
|
||||
* cannot carry HDR) - NOT HDR */
|
||||
};
|
||||
/* ahb_format = the buffer's AHARDWAREBUFFER_FORMAT_* where one exists (0 otherwise). */
|
||||
void banner_color_frame_shown(const struct banner_color *c, int path, uint32_t ahb_format);
|
||||
/* "RGBA1010102 (10-bit)" etc. for an AHARDWAREBUFFER_FORMAT_* value (static buffer). */
|
||||
const char *banner_ahb_format_name(uint32_t format);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Host → compositor message queue plus the init of the extension modules.
|
||||
*
|
||||
* The app's threads (UI thread, clipboard listener) hand text to the compositor through
|
||||
* banner_host_* ; the messages are queued under a mutex and a pipe byte wakes the wl event
|
||||
* loop, which drains them on the compositor thread — the only thread that may touch
|
||||
* wl_resources.
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <android/log.h>
|
||||
#include "banner_ext.h"
|
||||
#include "ahb_swapchain.h"
|
||||
#include "banner_color.h"
|
||||
|
||||
enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT };
|
||||
|
||||
struct host_msg {
|
||||
enum host_kind kind;
|
||||
char *text;
|
||||
size_t len;
|
||||
int a, b;
|
||||
struct host_msg *next;
|
||||
};
|
||||
|
||||
static pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct host_msg *g_head, *g_tail;
|
||||
static int g_wake[2] = {-1, -1};
|
||||
|
||||
static void host_post(enum host_kind kind, const char *text, size_t len, int a, int b) {
|
||||
struct host_msg *m = calloc(1, sizeof(*m));
|
||||
if (!m) return;
|
||||
m->kind = kind;
|
||||
m->a = a; m->b = b;
|
||||
if (text && len) {
|
||||
if (!(m->text = malloc(len + 1))) { free(m); return; }
|
||||
memcpy(m->text, text, len);
|
||||
m->text[len] = 0;
|
||||
m->len = len;
|
||||
}
|
||||
pthread_mutex_lock(&g_mu);
|
||||
if (g_tail) g_tail->next = m; else g_head = m;
|
||||
g_tail = m;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
if (g_wake[1] >= 0) {
|
||||
char c = 1;
|
||||
ssize_t n = write(g_wake[1], &c, 1);
|
||||
(void)n;
|
||||
}
|
||||
}
|
||||
|
||||
void banner_host_clipboard_text(const char *utf8, int len) {
|
||||
host_post(HOST_CLIPBOARD, utf8, len > 0 ? (size_t)len : 0, 0, 0);
|
||||
}
|
||||
void banner_host_text_commit(const char *utf8, int len) {
|
||||
host_post(HOST_TEXT_COMMIT, utf8, len > 0 ? (size_t)len : 0, 0, 0);
|
||||
}
|
||||
void banner_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end) {
|
||||
host_post(HOST_TEXT_PREEDIT, utf8, len > 0 ? (size_t)len : 0, cursor_begin, cursor_end);
|
||||
}
|
||||
void banner_host_text_delete(int before, int after) {
|
||||
host_post(HOST_TEXT_DELETE, NULL, 0, before, after);
|
||||
}
|
||||
void banner_host_zero_copy(int on, int live) {
|
||||
host_post(HOST_ZERO_COPY, NULL, 0, on, live);
|
||||
}
|
||||
void banner_host_hdr_output(int on) {
|
||||
host_post(HOST_HDR_OUTPUT, NULL, 0, on, 0);
|
||||
}
|
||||
|
||||
static int on_wake(int fd, uint32_t mask, void *data) {
|
||||
char buf[64];
|
||||
while (read(fd, buf, sizeof(buf)) > 0) {}
|
||||
for (;;) {
|
||||
pthread_mutex_lock(&g_mu);
|
||||
struct host_msg *m = g_head;
|
||||
if (m) { g_head = m->next; if (!g_head) g_tail = NULL; }
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
if (!m) break;
|
||||
switch (m->kind) {
|
||||
case HOST_CLIPBOARD:
|
||||
clipboard_host_text(m->text, m->len); /* takes the buffer */
|
||||
m->text = NULL;
|
||||
break;
|
||||
case HOST_TEXT_COMMIT:
|
||||
text_input_host_commit(m->text ? m->text : "", m->len);
|
||||
break;
|
||||
case HOST_TEXT_PREEDIT:
|
||||
text_input_host_preedit(m->text ? m->text : "", m->len, m->a, m->b);
|
||||
break;
|
||||
case HOST_TEXT_DELETE:
|
||||
text_input_host_delete(m->a, m->b);
|
||||
break;
|
||||
case HOST_ZERO_COPY:
|
||||
ahb_swapchain_set_mode(m->a, m->b);
|
||||
break;
|
||||
case HOST_HDR_OUTPUT:
|
||||
banner_color_set_output(m->a);
|
||||
break;
|
||||
}
|
||||
free(m->text);
|
||||
free(m);
|
||||
}
|
||||
wl_display_flush_clients(banner_get_display());
|
||||
return 0;
|
||||
}
|
||||
|
||||
void banner_ext_init(struct wl_display *display) {
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
if (pipe2(g_wake, O_CLOEXEC | O_NONBLOCK) == 0) {
|
||||
wl_event_loop_add_fd(loop, g_wake[0], WL_EVENT_READABLE, on_wake, NULL);
|
||||
pthread_mutex_lock(&g_mu);
|
||||
int queued = g_head != NULL; /* posted before the loop existed (clipboard refresh) */
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
if (queued) { char c = 1; ssize_t n = write(g_wake[1], &c, 1); (void)n; }
|
||||
} else
|
||||
__android_log_print(ANDROID_LOG_ERROR, "BannerWayland", "host queue pipe failed");
|
||||
clipboard_init(display);
|
||||
text_input_init(display);
|
||||
toplevel_icon_init(display);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Interface between compositor.c and the extension modules that live in their own files:
|
||||
* wl_clipboard.c wl_data_device_manager + zwlr_data_control_manager_v1 (selection only)
|
||||
* wl_text_input.c zwp_text_input_manager_v3 (host IME / soft keyboard)
|
||||
* wl_toplevel_icon.c xdg_toplevel_icon_manager_v1 (accepted, not rendered)
|
||||
* banner_ext.c the host→compositor message queue shared by the modules
|
||||
* Everything here runs on the compositor (dispatch) thread unless noted.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
void banner_log(const char *tag, const char *fmt, ...);
|
||||
|
||||
/* ---- compositor.c → modules */
|
||||
void banner_ext_init(struct wl_display *display); /* creates the globals + host queue */
|
||||
void banner_clipboard_keyboard_focus(struct wl_client *client); /* keyboard focus moved; NULL = none */
|
||||
void banner_text_input_refocus(void); /* the text-input target may have changed */
|
||||
void banner_text_input_surface_gone(struct wl_resource *surface);
|
||||
|
||||
/* ---- modules → compositor.c */
|
||||
const char *banner_client_name(struct wl_client *client);
|
||||
struct wl_display *banner_get_display(void);
|
||||
/* The surface text input follows (the last clicked window, else the topmost program window). */
|
||||
struct wl_resource *banner_ime_target(void);
|
||||
/* Scene (virtual desktop) origin of a toplevel surface; 0,0 when unknown. */
|
||||
void banner_surface_scene_origin(struct wl_resource *surface, int *x, int *y);
|
||||
/* Deliver a key press/release through the wl_keyboard path as if typed. */
|
||||
void banner_inject_key(uint32_t evdev, int pressed);
|
||||
|
||||
/* ---- modules → app (JNI upcalls; waylandcomp_jni.c) */
|
||||
void banner_on_clipboard_text(const char *utf8, int len);
|
||||
void banner_on_text_input(int enabled, const char *program, int x, int y, int w, int h);
|
||||
|
||||
/* ---- app → modules (callable from any thread; queued to the compositor thread) */
|
||||
void banner_host_clipboard_text(const char *utf8, int len); /* len 0 = clear */
|
||||
void banner_host_text_commit(const char *utf8, int len);
|
||||
void banner_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end);
|
||||
void banner_host_text_delete(int before, int after);
|
||||
void banner_host_zero_copy(int on, int live); /* the drawer's zero-copy switch (ahb_swapchain_set_mode) */
|
||||
void banner_host_hdr_output(int on); /* the drawer's HDR output switch (banner_color_set_output) */
|
||||
|
||||
/* ---- module internals reached through the queue (banner_ext.c → modules) */
|
||||
void clipboard_init(struct wl_display *display);
|
||||
void clipboard_host_text(char *utf8, size_t len); /* takes ownership of utf8 */
|
||||
void text_input_init(struct wl_display *display);
|
||||
void text_input_host_commit(const char *utf8, size_t len);
|
||||
void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end);
|
||||
void text_input_host_delete(int before, int after);
|
||||
void toplevel_icon_init(struct wl_display *display);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,654 @@
|
||||
/* Screen-effect chain — see effects_chain.h. Compositor thread unless noted. */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "effects_chain.h"
|
||||
#include "vk_loader.h"
|
||||
#include "vk_present.h" /* banner_log */
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The X11 Vulkan renderer's SPIR-V, pre-compiled by app/src/main/cpp/winlator/gen_shaders.sh
|
||||
* (glslangValidator --vn) and committed next to the GLSL: the NDK build compiles no shaders, so
|
||||
* there is no build-time tooling for CI to break. Same bytes as the X11 chain runs. */
|
||||
#include "upscale_vert.h"
|
||||
#include "sgsr_frag.h"
|
||||
#include "sgsr_quality_frag.h"
|
||||
#include "nis_frag.h"
|
||||
#include "fsr_easu_frag.h"
|
||||
#include "fsr_rcas_frag.h"
|
||||
#include "cas_frag.h"
|
||||
#include "color_frag.h"
|
||||
#include "fxaa_frag.h"
|
||||
#include "toon_frag.h"
|
||||
#include "hdr_frag.h"
|
||||
#include "ntsc_frag.h"
|
||||
#include "crt_frag.h"
|
||||
#include "deband_frag.h"
|
||||
|
||||
#define FX_FORMAT VK_FORMAT_R8G8B8A8_UNORM /* the default: every SDR frame */
|
||||
/* The chain's target format and the scene's view format. R8G8B8A8 always, except while an HDR scene
|
||||
* runs through the chain (hdr_compose.h): then the scene and the targets are A2B10G10R10, so a PQ
|
||||
* picture keeps 10 bits through every pass. A change rebuilds the chain's objects once
|
||||
* (vkp_effects_set_formats). */
|
||||
static VkFormat g_fx_fmt = FX_FORMAT, g_scene_fmt = FX_FORMAT;
|
||||
#define FX_MAX_DIM 4096 /* a FILL-mapped scene can exceed the panel; cap the chain resolution */
|
||||
|
||||
/* ------------------------------------------------------------------ settings */
|
||||
|
||||
struct fx_settings {
|
||||
int scaling; /* 0..8 */
|
||||
int sharp_pct; /* 0..100, the upscaler's own slider */
|
||||
int cas_on, cas_pct;
|
||||
int hdr_on;
|
||||
int deband_on, deband_pct; /* 0..200 */
|
||||
int color_on; /* derived: grade not neutral */
|
||||
float brightness, contrast, gamma, saturation; /* shader units (already mapped/clamped) */
|
||||
float b_raw, c_raw, s_raw; /* slider units, for the log */
|
||||
int fxaa, toon, crt, ntsc;
|
||||
char look[48];
|
||||
};
|
||||
|
||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct fx_settings g_set = {
|
||||
.scaling = 0, .sharp_pct = 75, .cas_on = 0, .cas_pct = 60, .deband_pct = 100,
|
||||
.gamma = 1.0f, .saturation = 1.0f, .s_raw = 100.0f, .look = "Off"};
|
||||
static volatile int g_changed;
|
||||
static struct fx_settings g_cur; /* the compositor thread's per-frame snapshot */
|
||||
static int g_cur_valid;
|
||||
|
||||
static void set_begin(void) { pthread_mutex_lock(&g_lock); }
|
||||
static void set_end(void) { g_changed = 1; pthread_mutex_unlock(&g_lock); }
|
||||
|
||||
void vkp_effects_set_scaling(int mode) {
|
||||
if (mode < 0 || mode > 8) mode = 0;
|
||||
set_begin(); g_set.scaling = mode; set_end();
|
||||
}
|
||||
void vkp_effects_set_upscale_sharpness(int pct) {
|
||||
if (pct < 0) pct = 0;
|
||||
if (pct > 100) pct = 100;
|
||||
set_begin(); g_set.sharp_pct = pct; set_end();
|
||||
}
|
||||
void vkp_effects_set_cas(int enabled, int pct) {
|
||||
if (pct < 0) pct = 0;
|
||||
if (pct > 100) pct = 100;
|
||||
set_begin(); g_set.cas_on = enabled ? 1 : 0; g_set.cas_pct = pct; set_end();
|
||||
}
|
||||
void vkp_effects_set_hdr(int enabled) { set_begin(); g_set.hdr_on = enabled ? 1 : 0; set_end(); }
|
||||
void vkp_effects_set_deband(int enabled, int pct) {
|
||||
if (pct < 0) pct = 0;
|
||||
if (pct > 200) pct = 200;
|
||||
set_begin(); g_set.deband_on = enabled ? 1 : 0; g_set.deband_pct = pct; set_end();
|
||||
}
|
||||
static float clampf(float v, float lo, float hi) { return v < lo ? lo : v > hi ? hi : v; }
|
||||
void vkp_effects_set_screen(float brightness, float contrast, float gamma, float saturation,
|
||||
int fxaa, int toon, int crt, int ntsc) {
|
||||
/* Same mapping as VulkanRendererContext::setColorGrade (GL ColorEffect clamps). */
|
||||
int on = !(brightness == 0.0f && contrast == 0.0f && gamma == 1.0f && saturation == 100.0f);
|
||||
set_begin();
|
||||
g_set.color_on = on;
|
||||
g_set.b_raw = brightness; g_set.c_raw = contrast; g_set.s_raw = saturation;
|
||||
g_set.brightness = clampf(brightness / 100.0f, -1.0f, 1.0f);
|
||||
g_set.contrast = clampf(contrast / 100.0f, 0.0f, 2.0f);
|
||||
g_set.saturation = clampf(saturation / 100.0f, 0.0f, 2.0f);
|
||||
g_set.gamma = clampf(gamma, 0.1f, 5.0f);
|
||||
g_set.fxaa = fxaa ? 1 : 0; g_set.toon = toon ? 1 : 0; g_set.crt = crt ? 1 : 0; g_set.ntsc = ntsc ? 1 : 0;
|
||||
set_end();
|
||||
}
|
||||
void vkp_effects_set_look(const char *name) {
|
||||
set_begin();
|
||||
snprintf(g_set.look, sizeof(g_set.look), "%s", name && *name ? name : "Custom");
|
||||
set_end();
|
||||
}
|
||||
|
||||
static const char *scaling_name(int m) {
|
||||
static const char *n[] = {"None", "Linear", "Nearest", "SGSR", "FSR", "FSR Fit", "Sharpen", "NIS", "SGSR HQ"};
|
||||
return (m >= 0 && m <= 8) ? n[m] : "?";
|
||||
}
|
||||
static int spatial_mode(int m) { return m >= 3 && m <= 8; }
|
||||
static int cas_active(const struct fx_settings *s) { return s->cas_on && s->cas_pct > 0; }
|
||||
static int effect_count(const struct fx_settings *s) {
|
||||
return s->fxaa + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on;
|
||||
}
|
||||
|
||||
static void log_settings(const struct fx_settings *s) {
|
||||
char line[400];
|
||||
int n;
|
||||
if (!spatial_mode(s->scaling) && !effect_count(s)) {
|
||||
banner_log("effects", "all off: scaling=%s (plain blit)", scaling_name(s->scaling));
|
||||
return;
|
||||
}
|
||||
n = snprintf(line, sizeof(line), "scaling=%s", scaling_name(s->scaling));
|
||||
if (spatial_mode(s->scaling)) n += snprintf(line + n, sizeof(line) - n, " %d%%", s->sharp_pct);
|
||||
if (cas_active(s)) n += snprintf(line + n, sizeof(line) - n, ", CAS on %d%%", s->cas_pct);
|
||||
else n += snprintf(line + n, sizeof(line) - n, ", CAS off");
|
||||
n += snprintf(line + n, sizeof(line) - n, ", Look=\"%s\"", s->look);
|
||||
if (s->color_on)
|
||||
n += snprintf(line + n, sizeof(line) - n, ", colour b=%+.0f c=%+.0f g=%.2f s=%.0f%%",
|
||||
s->b_raw, s->c_raw, s->gamma, s->s_raw);
|
||||
if (s->fxaa) n += snprintf(line + n, sizeof(line) - n, ", FXAA on");
|
||||
if (s->toon) n += snprintf(line + n, sizeof(line) - n, ", Toon on");
|
||||
if (s->hdr_on) n += snprintf(line + n, sizeof(line) - n, ", HDR on");
|
||||
if (s->ntsc) n += snprintf(line + n, sizeof(line) - n, ", NTSC on");
|
||||
if (s->crt) n += snprintf(line + n, sizeof(line) - n, ", CRT on");
|
||||
if (s->deband_on) n += snprintf(line + n, sizeof(line) - n, ", Deband on %d%%", s->deband_pct);
|
||||
(void)n;
|
||||
banner_log("effects", "%s", line);
|
||||
}
|
||||
|
||||
int vkp_effects_sync(void) {
|
||||
if (!g_changed && g_cur_valid) return 0;
|
||||
pthread_mutex_lock(&g_lock);
|
||||
g_changed = 0;
|
||||
g_cur = g_set;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
g_cur_valid = 1;
|
||||
log_settings(&g_cur);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vkp_effects_active(void) {
|
||||
vkp_effects_sync();
|
||||
return spatial_mode(g_cur.scaling) || effect_count(&g_cur) > 0;
|
||||
}
|
||||
|
||||
VkFilter vkp_effects_blit_filter(void) {
|
||||
vkp_effects_sync();
|
||||
return g_cur.scaling == 2 ? VK_FILTER_NEAREST : VK_FILTER_LINEAR;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ push constants
|
||||
* Byte-identical to VulkanRendererContext.h: vec4 ndc first (upscale.vert), the rest fragment-only. */
|
||||
struct pc_sgsr { float ndc[4]; float vp[4]; float edge; }; /* also NIS: vp + sharpness */
|
||||
struct pc_easu { float ndc[4]; uint32_t con0[4], con1[4], con2[4], con3[4]; float outW, outH; };
|
||||
struct pc_rcas { float ndc[4]; uint32_t con[4]; float outW, outH; };
|
||||
struct pc_res { float ndc[4]; float res[2]; float extra; float pad; }; /* fxaa/toon/hdr/crt (res), cas (sharpness), ntsc (frameCount), deband (strength) */
|
||||
struct pc_color { float ndc[4]; float b, c, g, s; };
|
||||
#define PC_MAX_SIZE sizeof(struct pc_easu) /* 88 bytes, the largest */
|
||||
|
||||
static uint32_t packf(float f) { uint32_t u; memcpy(&u, &f, 4); return u; }
|
||||
|
||||
/* Mirrors ffx_fsr1.h FsrEasuCon / FsrRcasCon exactly as the X11 renderer packs them. */
|
||||
static void easu_con(struct pc_easu *e, float inW, float inH, float outW, float outH) {
|
||||
e->con0[0] = packf(inW / outW); e->con0[1] = packf(inH / outH);
|
||||
e->con0[2] = packf(0.5f * inW / outW - 0.5f); e->con0[3] = packf(0.5f * inH / outH - 0.5f);
|
||||
e->con1[0] = packf(1.0f / inW); e->con1[1] = packf(1.0f / inH);
|
||||
e->con1[2] = packf(1.0f / inW); e->con1[3] = packf(-1.0f / inH);
|
||||
e->con2[0] = packf(-1.0f / inW); e->con2[1] = packf(2.0f / inH);
|
||||
e->con2[2] = packf(1.0f / inW); e->con2[3] = packf(2.0f / inH);
|
||||
e->con3[0] = packf(0.0f); e->con3[1] = packf(4.0f / inH);
|
||||
e->con3[2] = 0; e->con3[3] = 0;
|
||||
}
|
||||
static void rcas_con(struct pc_rcas *r, float scale01) {
|
||||
r->con[0] = packf(scale01); r->con[1] = 0; r->con[2] = 0; r->con[3] = 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ Vulkan objects */
|
||||
|
||||
struct fx_target {
|
||||
VkImage img; VkDeviceMemory mem; VkImageView view; VkFramebuffer fb; VkDescriptorSet ds;
|
||||
int w, h;
|
||||
};
|
||||
|
||||
static VkDevice g_dev;
|
||||
static VkPhysicalDevice g_pd;
|
||||
static VkPhysicalDeviceMemoryProperties g_mp;
|
||||
static int g_ready; /* 0 = objects not built, 1 = ok, -1 = failed (chain disabled, said once) */
|
||||
static VkRenderPass g_rp;
|
||||
static VkDescriptorSetLayout g_dsl;
|
||||
static VkPipelineLayout g_pl;
|
||||
static VkDescriptorPool g_dpool;
|
||||
static VkSampler g_sampler; /* linear, clamp-to-edge: what the X11 chain samples its targets with */
|
||||
enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT };
|
||||
static VkPipeline g_pipe[P_COUNT];
|
||||
static struct fx_target g_t[2], g_mid; /* ping-pong pair + the EASU output (FSR only) */
|
||||
/* The scene image belongs to vk_present; only its view + descriptor live here. */
|
||||
static struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } g_scene;
|
||||
static uint32_t g_ntsc_frame;
|
||||
|
||||
void vkp_effects_bind_device(VkDevice dev, VkPhysicalDevice pd,
|
||||
const VkPhysicalDeviceMemoryProperties *memprops) {
|
||||
g_dev = dev; g_pd = pd; g_mp = *memprops;
|
||||
}
|
||||
|
||||
static int memtype(uint32_t bits, VkMemoryPropertyFlags want) {
|
||||
for (uint32_t i = 0; i < g_mp.memoryTypeCount; i++)
|
||||
if ((bits & (1u << i)) && (g_mp.memoryTypes[i].propertyFlags & want) == want) return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static VkDescriptorSet alloc_ds(VkImageView view) {
|
||||
VkDescriptorSet ds = VK_NULL_HANDLE;
|
||||
VkDescriptorSetAllocateInfo ai = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||
.descriptorPool = g_dpool, .descriptorSetCount = 1, .pSetLayouts = &g_dsl};
|
||||
if (g_vk.AllocateDescriptorSets(g_dev, &ai, &ds) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
VkDescriptorImageInfo ii = {.sampler = g_sampler, .imageView = view,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL};
|
||||
VkWriteDescriptorSet wr = {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = ds, .dstBinding = 0,
|
||||
.descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.pImageInfo = &ii};
|
||||
g_vk.UpdateDescriptorSets(g_dev, 1, &wr, 0, NULL);
|
||||
return ds;
|
||||
}
|
||||
|
||||
static VkImageView make_view(VkImage img, VkFormat fmt) {
|
||||
VkImageView v = VK_NULL_HANDLE;
|
||||
VkImageViewCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = img,
|
||||
.viewType = VK_IMAGE_VIEW_TYPE_2D, .format = fmt,
|
||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
if (g_vk.CreateImageView(g_dev, &ci, NULL, &v) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
return v;
|
||||
}
|
||||
|
||||
static void target_destroy(struct fx_target *t) {
|
||||
if (t->ds) g_vk.FreeDescriptorSets(g_dev, g_dpool, 1, &t->ds);
|
||||
if (t->fb) g_vk.DestroyFramebuffer(g_dev, t->fb, NULL);
|
||||
if (t->view) g_vk.DestroyImageView(g_dev, t->view, NULL);
|
||||
if (t->img) g_vk.DestroyImage(g_dev, t->img, NULL);
|
||||
if (t->mem) g_vk.FreeMemory(g_dev, t->mem, NULL);
|
||||
memset(t, 0, sizeof(*t));
|
||||
}
|
||||
|
||||
/* A chain target: rendered into (colour attachment), sampled by the next pass, and blitted to
|
||||
* the swapchain when it ends up holding the result. Frames are fenced, so a resize never races
|
||||
* the GPU. 0 = ok. */
|
||||
static int target_ensure(struct fx_target *t, int w, int h, const char *what) {
|
||||
if (t->img && t->w == w && t->h == h) return 0;
|
||||
target_destroy(t);
|
||||
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = g_fx_fmt, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1,
|
||||
.arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
VkResult r = g_vk.CreateImage(g_dev, &ii, NULL, &t->img);
|
||||
if (r != VK_SUCCESS) { banner_log("error", "effects: %s image %dx%d: vkCreateImage %d", what, w, h, (int)r); return -1; }
|
||||
VkMemoryRequirements req;
|
||||
g_vk.GetImageMemoryRequirements(g_dev, t->img, &req);
|
||||
int idx = memtype(req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
if (idx < 0) idx = memtype(req.memoryTypeBits, 0);
|
||||
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = req.size,
|
||||
.memoryTypeIndex = (uint32_t)(idx < 0 ? 0 : idx)};
|
||||
r = g_vk.AllocateMemory(g_dev, &mai, NULL, &t->mem);
|
||||
if (r != VK_SUCCESS) {
|
||||
banner_log("error", "effects: %s image %dx%d (%llu bytes): vkAllocateMemory %d", what, w, h,
|
||||
(unsigned long long)req.size, (int)r);
|
||||
target_destroy(t); return -1;
|
||||
}
|
||||
g_vk.BindImageMemory(g_dev, t->img, t->mem, 0);
|
||||
if (!(t->view = make_view(t->img, g_fx_fmt))) { target_destroy(t); return -1; }
|
||||
VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = g_rp,
|
||||
.attachmentCount = 1, .pAttachments = &t->view, .width = (uint32_t)w,
|
||||
.height = (uint32_t)h, .layers = 1};
|
||||
if (g_vk.CreateFramebuffer(g_dev, &fi, NULL, &t->fb) != VK_SUCCESS) { target_destroy(t); return -1; }
|
||||
if (!(t->ds = alloc_ds(t->view))) { target_destroy(t); return -1; }
|
||||
t->w = w; t->h = h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scene_release(void) {
|
||||
if (g_scene.ds) g_vk.FreeDescriptorSets(g_dev, g_dpool, 1, &g_scene.ds);
|
||||
if (g_scene.view) g_vk.DestroyImageView(g_dev, g_scene.view, NULL);
|
||||
memset(&g_scene, 0, sizeof(g_scene));
|
||||
}
|
||||
|
||||
static int scene_ensure(VkImage img, int w, int h) {
|
||||
if (g_scene.img == img && g_scene.w == w && g_scene.h == h && g_scene.ds) return 0;
|
||||
scene_release();
|
||||
if (!(g_scene.view = make_view(img, g_scene_fmt))) return -1;
|
||||
if (!(g_scene.ds = alloc_ds(g_scene.view))) { scene_release(); return -1; }
|
||||
g_scene.img = img; g_scene.w = w; g_scene.h = h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VkShaderModule shader(const uint32_t *code, size_t size) {
|
||||
VkShaderModule m = VK_NULL_HANDLE;
|
||||
VkShaderModuleCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, .codeSize = size, .pCode = code};
|
||||
if (g_vk.CreateShaderModule(g_dev, &ci, NULL, &m) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* One full-quad post pipeline: upscale.vert + the effect's fragment shader, opaque, dynamic
|
||||
* viewport/scissor — the X11 renderer's createPostPipeline. */
|
||||
static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, size_t frag_size, const char *name) {
|
||||
VkShaderModule frag = shader(frag_code, frag_size);
|
||||
if (!frag) { banner_log("error", "effects: %s: vkCreateShaderModule failed", name); return VK_NULL_HANDLE; }
|
||||
VkPipelineShaderStageCreateInfo st[2] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .stage = VK_SHADER_STAGE_VERTEX_BIT, .module = vert, .pName = "main"},
|
||||
{.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .stage = VK_SHADER_STAGE_FRAGMENT_BIT, .module = frag, .pName = "main"}};
|
||||
VkPipelineVertexInputStateCreateInfo vi = {.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO};
|
||||
VkPipelineInputAssemblyStateCreateInfo ia = {.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP};
|
||||
VkDynamicState dyn[2] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR};
|
||||
VkPipelineDynamicStateCreateInfo ds = {.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.dynamicStateCount = 2, .pDynamicStates = dyn};
|
||||
VkPipelineViewportStateCreateInfo vp = {.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||
.viewportCount = 1, .scissorCount = 1};
|
||||
VkPipelineRasterizationStateCreateInfo rs = {.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||
.polygonMode = VK_POLYGON_MODE_FILL, .cullMode = VK_CULL_MODE_NONE,
|
||||
.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE, .lineWidth = 1.0f};
|
||||
VkPipelineMultisampleStateCreateInfo ms = {.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
||||
.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT};
|
||||
VkPipelineColorBlendAttachmentState ba = {.blendEnable = VK_FALSE, .colorWriteMask = 0xF};
|
||||
VkPipelineColorBlendStateCreateInfo cb = {.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
||||
.attachmentCount = 1, .pAttachments = &ba};
|
||||
VkGraphicsPipelineCreateInfo pi = {.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .stageCount = 2,
|
||||
.pStages = st, .pVertexInputState = &vi, .pInputAssemblyState = &ia,
|
||||
.pViewportState = &vp, .pRasterizationState = &rs, .pMultisampleState = &ms,
|
||||
.pColorBlendState = &cb, .pDynamicState = &ds, .layout = g_pl,
|
||||
.renderPass = g_rp, .subpass = 0};
|
||||
VkPipeline p = VK_NULL_HANDLE;
|
||||
VkResult r = g_vk.CreateGraphicsPipelines(g_dev, VK_NULL_HANDLE, 1, &pi, NULL, &p);
|
||||
g_vk.DestroyShaderModule(g_dev, frag, NULL);
|
||||
if (r != VK_SUCCESS) { banner_log("error", "effects: %s: vkCreateGraphicsPipelines %d", name, (int)r); return VK_NULL_HANDLE; }
|
||||
return p;
|
||||
}
|
||||
|
||||
static void objects_destroy(void) {
|
||||
if (!g_dev) return;
|
||||
scene_release();
|
||||
target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid);
|
||||
for (int i = 0; i < P_COUNT; i++) { if (g_pipe[i]) g_vk.DestroyPipeline(g_dev, g_pipe[i], NULL); g_pipe[i] = VK_NULL_HANDLE; }
|
||||
if (g_dpool) g_vk.DestroyDescriptorPool(g_dev, g_dpool, NULL);
|
||||
if (g_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL);
|
||||
if (g_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_dsl, NULL);
|
||||
if (g_sampler) g_vk.DestroySampler(g_dev, g_sampler, NULL);
|
||||
if (g_rp) g_vk.DestroyRenderPass(g_dev, g_rp, NULL);
|
||||
g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE; g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE;
|
||||
g_ready = 0;
|
||||
}
|
||||
|
||||
void vkp_effects_destroy(void) { objects_destroy(); g_dev = VK_NULL_HANDLE; }
|
||||
|
||||
void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt) {
|
||||
if (target_fmt != g_fx_fmt) {
|
||||
/* The render pass, the pipelines and the targets are built for one format: start over. */
|
||||
if (g_ready) objects_destroy();
|
||||
g_fx_fmt = target_fmt;
|
||||
g_scene_fmt = scene_fmt;
|
||||
if (g_dev)
|
||||
banner_log("effects", "chain now works in %s (%s)",
|
||||
target_fmt == FX_FORMAT ? "8-bit RGBA"
|
||||
: target_fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? "FP16 RGBA" : "10-bit RGB",
|
||||
target_fmt == FX_FORMAT ? "SDR frames"
|
||||
: target_fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? "the HDR picture for frame generation"
|
||||
: "the HDR composition's picture: PQ, or tone-mapped SDR with HDR output off");
|
||||
} else if (scene_fmt != g_scene_fmt) {
|
||||
scene_release();
|
||||
g_scene_fmt = scene_fmt;
|
||||
}
|
||||
}
|
||||
|
||||
/* Build every device object once, on the first active frame. 0 = ok, -1 = the chain is
|
||||
* unavailable for this session (logged once; frames fall back to the plain blit). */
|
||||
static int objects_ensure(void) {
|
||||
if (g_ready) return g_ready == 1 ? 0 : -1;
|
||||
if (!g_dev || !g_vk.CreateGraphicsPipelines) { g_ready = -1; banner_log("error", "effects: no device for the chain"); return -1; }
|
||||
/* Render pass: one colour target, overwritten whole (DONT_CARE), left SHADER_READ_ONLY for the
|
||||
* next pass. The dependencies order this pass after whoever read the target last (previous
|
||||
* pass / previous frame's blit) and before whoever samples or blits it next. */
|
||||
VkAttachmentDescription att = {.format = g_fx_fmt, .samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, .finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL};
|
||||
VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
|
||||
VkSubpassDescription sub = {.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .colorAttachmentCount = 1, .pColorAttachments = &ref};
|
||||
VkSubpassDependency deps[2] = {
|
||||
{.srcSubpass = VK_SUBPASS_EXTERNAL, .dstSubpass = 0,
|
||||
.srcStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT},
|
||||
{.srcSubpass = 0, .dstSubpass = VK_SUBPASS_EXTERNAL,
|
||||
.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
.dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT}};
|
||||
VkRenderPassCreateInfo rci = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .attachmentCount = 1, .pAttachments = &att,
|
||||
.subpassCount = 1, .pSubpasses = &sub, .dependencyCount = 2, .pDependencies = deps};
|
||||
if (g_vk.CreateRenderPass(g_dev, &rci, NULL, &g_rp) != VK_SUCCESS) goto fail;
|
||||
|
||||
VkSamplerCreateInfo sci = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_LINEAR,
|
||||
.minFilter = VK_FILTER_LINEAR, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE};
|
||||
if (g_vk.CreateSampler(g_dev, &sci, NULL, &g_sampler) != VK_SUCCESS) goto fail;
|
||||
|
||||
VkDescriptorSetLayoutBinding b = {.binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT};
|
||||
VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &b};
|
||||
if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_dsl) != VK_SUCCESS) goto fail;
|
||||
VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE};
|
||||
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 1, .pSetLayouts = &g_dsl,
|
||||
.pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
||||
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail;
|
||||
VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 8};
|
||||
VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = 8,
|
||||
.poolSizeCount = 1, .pPoolSizes = &ps};
|
||||
if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail;
|
||||
|
||||
VkShaderModule vert = shader(upscale_vert_code, sizeof(upscale_vert_code));
|
||||
if (!vert) goto fail;
|
||||
#define MK(slot, code, name) do { g_pipe[slot] = post_pipeline(vert, code, sizeof(code), name); if (!g_pipe[slot]) { g_vk.DestroyShaderModule(g_dev, vert, NULL); goto fail; } } while (0)
|
||||
MK(P_SGSR, sgsr_code, "sgsr");
|
||||
MK(P_SGSR_HQ, sgsr_quality_code, "sgsr_quality");
|
||||
MK(P_NIS, nis_code, "nis");
|
||||
MK(P_EASU, fsr_easu_code, "fsr_easu");
|
||||
MK(P_RCAS, fsr_rcas_code, "fsr_rcas");
|
||||
MK(P_CAS, cas_code, "cas");
|
||||
MK(P_COLOR, color_code, "color");
|
||||
MK(P_FXAA, fxaa_code, "fxaa");
|
||||
MK(P_TOON, toon_code, "toon");
|
||||
MK(P_HDR, hdr_code, "hdr");
|
||||
MK(P_NTSC, ntsc_code, "ntsc");
|
||||
MK(P_CRT, crt_code, "crt");
|
||||
MK(P_DEBAND, deband_code, "deband");
|
||||
#undef MK
|
||||
g_vk.DestroyShaderModule(g_dev, vert, NULL);
|
||||
g_ready = 1;
|
||||
banner_log("effects", "chain ready: 13 passes (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name());
|
||||
return 0;
|
||||
fail:
|
||||
objects_destroy();
|
||||
g_ready = -1;
|
||||
banner_log("error", "effects: the screen-effect chain could not be built on this driver; effects are off for this session");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ recording */
|
||||
|
||||
static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to,
|
||||
VkPipelineStageFlags src_stage, VkAccessFlags src_access,
|
||||
VkPipelineStageFlags dst_stage, VkAccessFlags dst_access) {
|
||||
VkImageMemoryBarrier b = {.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = from, .newLayout = to,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1},
|
||||
.srcAccessMask = src_access, .dstAccessMask = dst_access};
|
||||
g_vk.CmdPipelineBarrier(cmd, src_stage, dst_stage, 0, 0, NULL, 0, NULL, 1, &b);
|
||||
}
|
||||
|
||||
/* One pass: sample `src` (a descriptor in SHADER_READ_ONLY_OPTIMAL), draw the full quad into `dst`. */
|
||||
static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst, VkDescriptorSet src,
|
||||
const void *pc, uint32_t pcsz) {
|
||||
VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = g_rp, .framebuffer = dst->fb,
|
||||
.renderArea = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}};
|
||||
VkViewport vp = {0, 0, (float)dst->w, (float)dst->h, 0, 1};
|
||||
VkRect2D sc = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}};
|
||||
g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE);
|
||||
g_vk.CmdSetViewport(cmd, 0, 1, &vp);
|
||||
g_vk.CmdSetScissor(cmd, 0, 1, &sc);
|
||||
g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p);
|
||||
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, 1, &src, 0, NULL);
|
||||
g_vk.CmdPushConstants(cmd, g_pl, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, pcsz, pc);
|
||||
g_vk.CmdDraw(cmd, 4, 1, 0, 0);
|
||||
g_vk.CmdEndRenderPass(cmd);
|
||||
}
|
||||
|
||||
static const float FULL_NDC[4] = {-1.0f, -1.0f, 1.0f, 1.0f};
|
||||
#define SET_NDC(pc) memcpy((pc).ndc, FULL_NDC, sizeof(FULL_NDC))
|
||||
|
||||
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int *res_w, int *res_h) {
|
||||
const struct fx_settings *s;
|
||||
vkp_effects_sync();
|
||||
s = &g_cur;
|
||||
*res_w = scene_w; *res_h = scene_h;
|
||||
|
||||
/* The chain's resolution: the scene's mapped size (X11 runs its effects at the output extent,
|
||||
* with the scene already scaled by the base sampler). Clamped so a FILL-mapped 4K scene does
|
||||
* not allocate beyond reason; the final blit resizes the remainder. */
|
||||
int cw = out_w > 0 ? out_w : scene_w, ch = out_h > 0 ? out_h : scene_h;
|
||||
if (cw > FX_MAX_DIM) cw = FX_MAX_DIM;
|
||||
if (ch > FX_MAX_DIM) ch = FX_MAX_DIM;
|
||||
if (cw < 1) cw = 1;
|
||||
if (ch < 1) ch = 1;
|
||||
/* Spatial upscalers only have work when the scene is shown larger than it is (the X11
|
||||
* renderer's "render below display" gate); Sharpen (RCAS) runs at any size. */
|
||||
const int upscaling = cw > scene_w || ch > scene_h;
|
||||
int spatial = 0;
|
||||
if (spatial_mode(s->scaling) && (s->scaling == 6 || upscaling)) spatial = s->scaling;
|
||||
const int nfx = effect_count(s);
|
||||
const int resize = cw != scene_w || ch != scene_h;
|
||||
/* Passes that write the ping-pong pair: the scaling/resize stage (if any) + the effects.
|
||||
* Two targets are needed once any pass reads what an earlier one wrote. */
|
||||
const int npasses = ((spatial || resize) ? 1 : 0) + nfx;
|
||||
|
||||
if ((spatial || nfx) && objects_ensure() == 0 && scene_ensure(scene, scene_w, scene_h) == 0 &&
|
||||
target_ensure(&g_t[0], cw, ch, "chain") == 0 && (npasses < 2 || target_ensure(&g_t[1], cw, ch, "chain") == 0) &&
|
||||
(!(spatial == 4 || spatial == 5) || target_ensure(&g_mid, cw, ch, "EASU") == 0)) {
|
||||
/* `cur` = the image the next pass samples; `cur_ds` its descriptor. Every pass writes the
|
||||
* target that is not being read (the pair alternates; the scene is read only first). */
|
||||
VkDescriptorSet cur_ds;
|
||||
struct fx_target *cur = NULL; /* NULL = the scene image */
|
||||
#define FREE_TARGET() ((cur == &g_t[0]) ? &g_t[1] : &g_t[0])
|
||||
const float sharp01 = (float)s->sharp_pct / 100.0f;
|
||||
|
||||
/* ---- stage 1: scaling (scene -> chain res) */
|
||||
if (spatial) {
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||
struct fx_target *dst = FREE_TARGET();
|
||||
if (spatial == 3 || spatial == 8 || spatial == 7) {
|
||||
struct pc_sgsr pc = {0};
|
||||
SET_NDC(pc);
|
||||
pc.vp[0] = 1.0f / (float)scene_w; pc.vp[1] = 1.0f / (float)scene_h;
|
||||
pc.vp[2] = (float)scene_w; pc.vp[3] = (float)scene_h;
|
||||
/* SGSR EdgeSharpness 0.5 (slider 0) .. 4.5 (slider 100); NIS takes the slider as is. */
|
||||
pc.edge = spatial == 7 ? sharp01 : 0.5f + sharp01 * 4.0f;
|
||||
pass(cmd, g_pipe[spatial == 3 ? P_SGSR : spatial == 8 ? P_SGSR_HQ : P_NIS], dst, g_scene.ds, &pc, sizeof(pc));
|
||||
} else if (spatial == 6) {
|
||||
/* Sharpen: RCAS fetches the scene 1:1 (outputSize = scene size) while the quad
|
||||
* covers the chain target = nearest scale + sharpen, as the X11 renderer does. */
|
||||
struct pc_rcas pc = {0};
|
||||
SET_NDC(pc);
|
||||
rcas_con(&pc, sharp01);
|
||||
pc.outW = (float)scene_w; pc.outH = (float)scene_h;
|
||||
pass(cmd, g_pipe[P_RCAS], dst, g_scene.ds, &pc, sizeof(pc));
|
||||
} else { /* FSR (4) / FSR Fit (5): EASU scene -> mid, RCAS mid -> dst, both at chain res.
|
||||
* Fill vs fit is the Fullscreen Mode's business here (the mapping), so both
|
||||
* run the same EASU+RCAS pair. */
|
||||
struct pc_easu e = {0};
|
||||
struct pc_rcas r = {0};
|
||||
SET_NDC(e);
|
||||
easu_con(&e, (float)scene_w, (float)scene_h, (float)cw, (float)ch);
|
||||
e.outW = (float)cw; e.outH = (float)ch;
|
||||
pass(cmd, g_pipe[P_EASU], &g_mid, g_scene.ds, &e, sizeof(e));
|
||||
SET_NDC(r);
|
||||
rcas_con(&r, sharp01);
|
||||
r.outW = (float)cw; r.outH = (float)ch;
|
||||
pass(cmd, g_pipe[P_RCAS], dst, g_mid.ds, &r, sizeof(r));
|
||||
}
|
||||
cur = dst; cur_ds = dst->ds;
|
||||
} else if (resize) {
|
||||
/* No spatial pass: a plain filtered resize to the chain resolution first (Linear or
|
||||
* Nearest per the scaling mode), so the effects run at output resolution like X11. */
|
||||
struct fx_target *dst = FREE_TARGET();
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
barrier(cmd, dst->img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||
VkImageBlit bl = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .srcOffsets = {{0, 0, 0}, {scene_w, scene_h, 1}},
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{0, 0, 0}, {cw, ch, 1}}};
|
||||
g_vk.CmdBlitImage(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst->img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1, &bl, vkp_effects_blit_filter());
|
||||
barrier(cmd, dst->img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||
cur = dst; cur_ds = dst->ds;
|
||||
} else {
|
||||
/* Scene already at output size: the first effect samples it directly. */
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||
cur = NULL; cur_ds = g_scene.ds;
|
||||
}
|
||||
|
||||
/* ---- stage 2: the effects, in the X11 renderer's locked order
|
||||
* FXAA -> Toon -> Colour -> CAS -> HDR -> NTSC -> CRT -> Debanding (terminal dither).
|
||||
* Each writes the free ping-pong target; the one just read becomes free. */
|
||||
enum { FX_FXAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
|
||||
int order[8], n = 0;
|
||||
if (s->fxaa) order[n++] = FX_FXAA;
|
||||
if (s->toon) order[n++] = FX_TOON;
|
||||
if (s->color_on) order[n++] = FX_COLOR;
|
||||
if (cas_active(s)) order[n++] = FX_CAS;
|
||||
if (s->hdr_on) order[n++] = FX_HDR;
|
||||
if (s->ntsc) order[n++] = FX_NTSC;
|
||||
if (s->crt) order[n++] = FX_CRT;
|
||||
if (s->deband_on) order[n++] = FX_DEBAND;
|
||||
for (int i = 0; i < n; i++) {
|
||||
struct fx_target *dst = FREE_TARGET();
|
||||
struct pc_res pr = {0};
|
||||
SET_NDC(pr);
|
||||
pr.res[0] = (float)cw; pr.res[1] = (float)ch;
|
||||
switch (order[i]) {
|
||||
case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_TOON: pass(cmd, g_pipe[P_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_COLOR: {
|
||||
struct pc_color pc = {0};
|
||||
SET_NDC(pc);
|
||||
pc.b = s->brightness; pc.c = s->contrast; pc.g = s->gamma; pc.s = s->saturation;
|
||||
pass(cmd, g_pipe[P_COLOR], dst, cur_ds, &pc, sizeof(pc));
|
||||
break;
|
||||
}
|
||||
case FX_CAS: pr.extra = (float)s->cas_pct / 100.0f; pass(cmd, g_pipe[P_CAS], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_HDR: pass(cmd, g_pipe[P_HDR], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_NTSC:
|
||||
/* cos/sin(chromaPhase*0.5) has period 4 in the counter: mod 4 keeps the shimmer exact. */
|
||||
pr.extra = (float)(g_ntsc_frame++ & 3u);
|
||||
pass(cmd, g_pipe[P_NTSC], dst, cur_ds, &pr, sizeof(pr));
|
||||
break;
|
||||
case FX_CRT: pass(cmd, g_pipe[P_CRT], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_DEBAND: pr.extra = (float)s->deband_pct / 100.0f; pass(cmd, g_pipe[P_DEBAND], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
}
|
||||
cur = dst; cur_ds = dst->ds;
|
||||
}
|
||||
|
||||
#undef FREE_TARGET
|
||||
if (cur) {
|
||||
/* The result: written by the last render pass, now for the output blit. */
|
||||
barrier(cmd, cur->img, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
*res_w = cur->w; *res_h = cur->h;
|
||||
return cur->img;
|
||||
}
|
||||
/* Nothing ran after all (cannot happen with nfx > 0): the scene was moved to
|
||||
* SHADER_READ_ONLY above; bring it to TRANSFER_SRC for the blit. */
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
return scene;
|
||||
}
|
||||
|
||||
/* Nothing to do (a spatial mode with no room to upscale and no effect), or the chain is
|
||||
* unavailable: present the scene as composited. */
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
return scene;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#ifndef EFFECTS_CHAIN_H
|
||||
#define EFFECTS_CHAIN_H
|
||||
/*
|
||||
* Screen-effect chain for the embedded Wayland compositor: the X11 Vulkan renderer's post
|
||||
* chain (the .frag files in app/src/main/cpp/winlator, VulkanRendererContext::recordUpscalePasses) run
|
||||
* between the composited scene and the output blit, with the same SPIR-V, push-constant
|
||||
* layouts, uniform ranges and pass order, so a saved preset looks the same on both backends.
|
||||
*
|
||||
* Present-pass hook order (vk_present.c, vkp_render):
|
||||
* scene (all draws blitted 1:1 into a scene-sized image)
|
||||
* -> vkp_effects_run() this file: scaling -> effects, in the X11 order
|
||||
* -> vkp_framegen_run() frame generation (feat/wayland-framegen; inserted after this)
|
||||
* -> update_map / blit Fullscreen Mode + Screen Alignment, onto the swapchain image
|
||||
* -> present
|
||||
* When nothing is on, vkp_effects_active() is 0 and vkp_render keeps its plain path (the draws
|
||||
* are blitted straight through the mapping; only the blit filter follows Linear/Nearest).
|
||||
*
|
||||
* Pass order (LOCKED to the X11 Vulkan renderer):
|
||||
* scaling (SGSR / SGSR HQ / NIS / FSR EASU+RCAS / Sharpen=RCAS; None/Linear/Nearest = a
|
||||
* filtered resize) -> FXAA -> Toon -> Colour -> CAS -> HDR -> NTSC -> CRT -> Debanding.
|
||||
* Scaling resizes the scene to its mapped output size (there is no render scale on Wayland);
|
||||
* every later pass runs at that resolution and ping-pongs between two targets.
|
||||
*
|
||||
* Settings come from any thread (JNI); the compositor thread snapshots them once per frame and
|
||||
* logs one `effects` line per change. Vulkan objects are created lazily on the first active frame.
|
||||
*/
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
/* Compositor thread, from dev_init: the device the chain builds its objects on. */
|
||||
void vkp_effects_bind_device(VkDevice dev, VkPhysicalDevice pd,
|
||||
const VkPhysicalDeviceMemoryProperties *memprops);
|
||||
|
||||
/* Compositor thread: pick up settings changed since the last call. Returns 1 when something
|
||||
* changed (the caller redraws even a static scene); logs the `effects` line. */
|
||||
int vkp_effects_sync(void);
|
||||
|
||||
/* Compositor thread: 1 when the frame must go through the scene image + chain (any effect on,
|
||||
* or a spatial scaling mode). Modes None/Linear/Nearest alone are NOT active: the plain blit
|
||||
* handles them through vkp_effects_blit_filter(). */
|
||||
int vkp_effects_active(void);
|
||||
|
||||
/* The filter for the scene -> output resize: NEAREST for scaling mode 2, else LINEAR. */
|
||||
VkFilter vkp_effects_blit_filter(void);
|
||||
|
||||
/* THE HOOK. Records the chain into `cmd`. `scene` (scene_w x scene_h, R8G8B8A8_UNORM, in
|
||||
* TRANSFER_DST_OPTIMAL after the composite) -> the image to present, returned in
|
||||
* TRANSFER_SRC_OPTIMAL with its size in res_w / res_h. out_w/out_h = the scene's mapped size on
|
||||
* the output (what the scaling modes resize to; the caller maps the result over the whole scene
|
||||
* afterwards, so Fullscreen Mode / Alignment still apply after the chain). Returns `scene` itself
|
||||
* (transitioned to TRANSFER_SRC_OPTIMAL) when there is nothing to do or the chain is unavailable. */
|
||||
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int *res_w, int *res_h);
|
||||
|
||||
/* Compositor thread: drop every Vulkan object (device teardown / device lost). */
|
||||
void vkp_effects_destroy(void);
|
||||
|
||||
/* Compositor thread, before vkp_effects_run(): the format of the scene image it will be handed and the
|
||||
* format its own targets use. R8G8B8A8 / R8G8B8A8 for every SDR frame (the default); A2B10G10R10 /
|
||||
* A2B10G10R10 while an HDR picture runs through it (hdr_compose.h). A target-format change rebuilds the
|
||||
* chain's objects on its next run (once per switch). */
|
||||
void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt);
|
||||
|
||||
/* ---- settings (any thread; values 1:1 with the X11 Vulkan renderer's setters) ---- */
|
||||
/* 0=None 1=Linear 2=Nearest 3=SGSR 4=FSR 5=FSR Fit 6=Sharpen 7=NIS 8=SGSR HQ */
|
||||
void vkp_effects_set_scaling(int mode);
|
||||
/* Slider 0..100: RCAS lobe scale (FSR/Sharpen), SGSR EdgeSharpness 0.5..4.5, NIS sharpness. */
|
||||
void vkp_effects_set_upscale_sharpness(int pct);
|
||||
/* CAS toggle + slider 0..100 (0 = the pass is off). */
|
||||
void vkp_effects_set_cas(int enabled, int pct);
|
||||
void vkp_effects_set_hdr(int enabled);
|
||||
/* Terminal dither: slider 0..200 -> strength/100 LSBs. */
|
||||
void vkp_effects_set_deband(int enabled, int pct);
|
||||
/* Colour grade in slider units (brightness/contrast -100..100, gamma 0.5..3, saturation 0..200
|
||||
* percent; neutral = 0,0,1,100 turns the pass off) + the four shader toggles. */
|
||||
void vkp_effects_set_screen(float brightness, float contrast, float gamma, float saturation,
|
||||
int fxaa, int toon, int crt, int ntsc);
|
||||
/* The Look the current controls match ("Custom" when none), for the log line only. */
|
||||
void vkp_effects_set_look(const char *name);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,455 @@
|
||||
/* Frame generation on the Wayland backend - see framegen_bridge.h. */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "framegen_bridge.h"
|
||||
#include "framegen_engine.h"
|
||||
#include "vk_loader.h"
|
||||
#include <pthread.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <android/log.h>
|
||||
|
||||
void banner_log(const char *tag, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
#define FGLOG(...) banner_log("framegen", __VA_ARGS__)
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "BannerWayland", __VA_ARGS__)
|
||||
|
||||
/* ---- app controls (written from any thread, read on the compositor thread) ------------- */
|
||||
static _Atomic int g_kind = VKP_FG_ENGINE_LSFG;
|
||||
static _Atomic int g_armed;
|
||||
static _Atomic int g_mult = 2;
|
||||
static _Atomic int g_model = 3;
|
||||
static _Atomic int g_preset = 2;
|
||||
static _Atomic int g_cfg_dirty = 1;
|
||||
static float g_flow = 0.8f, g_refresh_hz; /* under g_lock */
|
||||
static char *g_cache_path; /* under g_lock */
|
||||
static _Atomic int g_cache_gen; /* bumps when the path changes */
|
||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* ---- device -------------------------------------------------------------------------- */
|
||||
static VkDevice g_dev;
|
||||
static VkInstance g_inst;
|
||||
static PFN_vkGetInstanceProcAddr g_gipa;
|
||||
static VkPhysicalDevice g_pd;
|
||||
static VkQueue g_queue;
|
||||
static uint32_t g_qfam;
|
||||
static int g_dev_ready, g_dev_lost, g_features_enabled;
|
||||
static VkPhysicalDeviceMemoryProperties g_memprops;
|
||||
static struct {
|
||||
PFN_vkCreateImage CreateImage;
|
||||
PFN_vkDestroyImage DestroyImage;
|
||||
PFN_vkCreateImageView CreateImageView;
|
||||
PFN_vkDestroyImageView DestroyImageView;
|
||||
PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements;
|
||||
PFN_vkAllocateMemory AllocateMemory;
|
||||
PFN_vkFreeMemory FreeMemory;
|
||||
PFN_vkBindImageMemory BindImageMemory;
|
||||
PFN_vkCmdPipelineBarrier CmdPipelineBarrier;
|
||||
PFN_vkDeviceWaitIdle DeviceWaitIdle;
|
||||
} vk;
|
||||
|
||||
/* ---- engine + generation ring (compositor thread) ------------------------------------ */
|
||||
static int g_engine_kind = -1; /* kind of the running engine, -1 = none */
|
||||
static int g_engine_ok;
|
||||
/* The engine of this kind (with this cache) could not start or build its chain; not retried
|
||||
* every frame - a new engine selection or a new cache clears it. */
|
||||
static _Atomic int g_failed_kind = -1;
|
||||
static _Atomic int g_failed_cache_gen = -1;
|
||||
|
||||
struct ring_image { VkImage img; VkDeviceMemory mem; VkImageView view; int fresh; };
|
||||
static struct ring_image g_ring[VKP_FG_MAX_GENERATIONS];
|
||||
static uint32_t g_ring_n, g_ring_w, g_ring_h;
|
||||
static VkFormat g_ring_fmt;
|
||||
|
||||
static uint64_t g_source_frames;
|
||||
static uint32_t g_planned; /* generations planned for the current source frame */
|
||||
static int g_was_armed, g_generating_logged;
|
||||
static uint32_t g_built_w, g_built_h;
|
||||
static VkFormat g_built_fmt;
|
||||
/* Deeper formats (FP16 for HDR frames) the engine failed to build its chain in this session. */
|
||||
static VkFormat g_refused_fmt[4];
|
||||
static int g_refused_n;
|
||||
static int format_refused(VkFormat f) {
|
||||
for (int i = 0; i < g_refused_n; i++) if (g_refused_fmt[i] == f) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---- stats ------------------------------------------------------------------------- */
|
||||
static _Atomic unsigned g_stat_generated; /* since the last stats_take */
|
||||
static uint64_t g_total_generated;
|
||||
static float g_presented_rate, g_source_rate; /* smoothed, 0.5 s windows */
|
||||
static uint32_t g_present_accum, g_source_accum;
|
||||
static int64_t g_window_start_ns;
|
||||
|
||||
static int64_t now_ns(void) {
|
||||
struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||
}
|
||||
|
||||
/* ====================================================================== app controls */
|
||||
|
||||
void vkp_framegen_set_engine(int kind) {
|
||||
if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_WINFG) kind = VKP_FG_ENGINE_LSFG;
|
||||
atomic_store(&g_kind, kind);
|
||||
atomic_store(&g_cfg_dirty, 1);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_armed(int armed, int multiplier) {
|
||||
if (multiplier < 2) multiplier = 2;
|
||||
if (multiplier > VKP_FG_MAX_GENERATIONS + 1) multiplier = VKP_FG_MAX_GENERATIONS + 1;
|
||||
if (atomic_exchange(&g_mult, multiplier) != multiplier) atomic_store(&g_cfg_dirty, 1);
|
||||
atomic_store(&g_armed, armed ? 1 : 0);
|
||||
LOGD("framegen: set_armed(%d, x%d)", armed, multiplier);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_lsfg_cache_path(const char *path) {
|
||||
pthread_mutex_lock(&g_lock);
|
||||
int changed = (path == NULL) != (g_cache_path == NULL) ||
|
||||
(path && g_cache_path && strcmp(path, g_cache_path) != 0);
|
||||
if (changed) {
|
||||
free(g_cache_path);
|
||||
g_cache_path = path ? strdup(path) : NULL;
|
||||
atomic_fetch_add(&g_cache_gen, 1);
|
||||
}
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_tuning(float flow_scale, float refresh_hz) {
|
||||
if (flow_scale < 0.25f) flow_scale = 0.25f;
|
||||
if (flow_scale > 1.0f) flow_scale = 1.0f;
|
||||
pthread_mutex_lock(&g_lock);
|
||||
g_flow = flow_scale;
|
||||
g_refresh_hz = refresh_hz > 1.0f ? refresh_hz : 0.0f;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
atomic_store(&g_cfg_dirty, 1);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_winfg_tuning(int model, int perf_preset) {
|
||||
atomic_store(&g_model, model == 3 ? 3 : 4);
|
||||
atomic_store(&g_preset, perf_preset < 0 ? 0 : perf_preset > 2 ? 2 : perf_preset);
|
||||
atomic_store(&g_cfg_dirty, 1);
|
||||
}
|
||||
|
||||
static int start_failed_for(int kind) {
|
||||
return atomic_load(&g_failed_kind) == kind && atomic_load(&g_failed_cache_gen) == atomic_load(&g_cache_gen);
|
||||
}
|
||||
|
||||
static void mark_failed(int kind) {
|
||||
atomic_store(&g_failed_cache_gen, atomic_load(&g_cache_gen));
|
||||
atomic_store(&g_failed_kind, kind);
|
||||
}
|
||||
|
||||
/* Same codes as VulkanRenderer.getFrameGenProblem(); computed from the live state so an engine
|
||||
* switch from the app is answered at once. */
|
||||
int vkp_framegen_problem(void) {
|
||||
if (!g_dev_ready) return -1;
|
||||
int kind = atomic_load(&g_kind);
|
||||
if (!fge_caps_ok(kind)) return 1;
|
||||
if (start_failed_for(kind)) return 2;
|
||||
if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2;
|
||||
return 0;
|
||||
}
|
||||
const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(); }
|
||||
|
||||
void vkp_framegen_stats(float out[6]) {
|
||||
float accepted = 0.0f, src = 0.0f, thermal = -1.0f;
|
||||
if (g_engine_ok) fge_telemetry(&accepted, &src, &thermal);
|
||||
/* Planned is what is generated; the governor is off on both paths. Our own measured
|
||||
* source rate serves both engines (Win-FG measures none). */
|
||||
out[0] = (float)g_planned;
|
||||
out[1] = (float)g_planned;
|
||||
out[2] = g_source_rate;
|
||||
out[3] = g_presented_rate;
|
||||
out[4] = thermal;
|
||||
out[5] = -1.0f;
|
||||
}
|
||||
|
||||
unsigned vkp_framegen_stats_take(void) { return atomic_exchange(&g_stat_generated, 0u); }
|
||||
|
||||
/* ====================================================================== device setup */
|
||||
|
||||
const void *vkp_framegen_device_features(VkInstance inst, PFN_vkGetInstanceProcAddr gipa,
|
||||
VkPhysicalDevice pd) {
|
||||
g_pd = pd; g_inst = inst; g_gipa = gipa;
|
||||
return fge_probe(gipa, inst, pd, VK_FORMAT_R8G8B8A8_UNORM);
|
||||
}
|
||||
|
||||
void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled) {
|
||||
g_dev = dev; g_queue = queue; g_qfam = qfam; g_features_enabled = features_enabled;
|
||||
#define R(n) vk.n = (PFN_vk##n)g_vk.GetDeviceProcAddr(dev, "vk" #n)
|
||||
R(CreateImage); R(DestroyImage); R(CreateImageView); R(DestroyImageView);
|
||||
R(GetImageMemoryRequirements); R(AllocateMemory); R(FreeMemory); R(BindImageMemory);
|
||||
R(CmdPipelineBarrier); R(DeviceWaitIdle);
|
||||
#undef R
|
||||
g_vk.GetPhysicalDeviceMemoryProperties(g_pd, &g_memprops);
|
||||
fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled);
|
||||
g_dev_ready = vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier;
|
||||
FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), Win-FG Native %s",
|
||||
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(),
|
||||
fge_caps_ok(VKP_FG_ENGINE_WINFG) ? "available" : "unavailable");
|
||||
}
|
||||
|
||||
void vkp_framegen_device_lost(void) { g_dev_lost = 1; }
|
||||
|
||||
/* ====================================================================== ring */
|
||||
|
||||
static void destroy_ring(void) {
|
||||
if (!g_ring_n) return;
|
||||
if (vk.DeviceWaitIdle) vk.DeviceWaitIdle(g_dev);
|
||||
for (uint32_t i = 0; i < g_ring_n; i++) {
|
||||
if (g_ring[i].view) vk.DestroyImageView(g_dev, g_ring[i].view, NULL);
|
||||
if (g_ring[i].img) vk.DestroyImage(g_dev, g_ring[i].img, NULL);
|
||||
if (g_ring[i].mem) vk.FreeMemory(g_dev, g_ring[i].mem, NULL);
|
||||
memset(&g_ring[i], 0, sizeof(g_ring[i]));
|
||||
}
|
||||
g_ring_n = 0;
|
||||
if (g_engine_ok) fge_forget_targets();
|
||||
}
|
||||
|
||||
static int memory_type(uint32_t bits, VkMemoryPropertyFlags want) {
|
||||
for (uint32_t i = 0; i < g_memprops.memoryTypeCount; i++)
|
||||
if ((bits & (1u << i)) && (g_memprops.memoryTypes[i].propertyFlags & want) == want) return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The generation targets: written by the chain through a storage view, read by the screen
|
||||
* blit. Kept in GENERAL for their whole life (both uses allow it), so there is no layout dance
|
||||
* per frame - only access barriers. */
|
||||
static int ensure_ring(uint32_t w, uint32_t h, VkFormat fmt, uint32_t n) {
|
||||
if (n > VKP_FG_MAX_GENERATIONS) n = VKP_FG_MAX_GENERATIONS;
|
||||
if (g_ring_n == n && g_ring_w == w && g_ring_h == h && g_ring_fmt == fmt) return 1;
|
||||
destroy_ring();
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
struct ring_image *r = &g_ring[i];
|
||||
VkImageCreateInfo ici = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D, .format = fmt,
|
||||
.extent = {w, h, 1}, .mipLevels = 1, .arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
if (vk.CreateImage(g_dev, &ici, NULL, &r->img) != VK_SUCCESS) { destroy_ring(); return 0; }
|
||||
VkMemoryRequirements req;
|
||||
vk.GetImageMemoryRequirements(g_dev, r->img, &req);
|
||||
int idx = memory_type(req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
.allocationSize = req.size, .memoryTypeIndex = (uint32_t)idx};
|
||||
if (idx < 0 || vk.AllocateMemory(g_dev, &mai, NULL, &r->mem) != VK_SUCCESS) { destroy_ring(); return 0; }
|
||||
vk.BindImageMemory(g_dev, r->img, r->mem, 0);
|
||||
VkImageViewCreateInfo vci = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = r->img,
|
||||
.viewType = VK_IMAGE_VIEW_TYPE_2D, .format = fmt,
|
||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
if (vk.CreateImageView(g_dev, &vci, NULL, &r->view) != VK_SUCCESS) { destroy_ring(); return 0; }
|
||||
r->fresh = 1;
|
||||
g_ring_n = i + 1;
|
||||
}
|
||||
g_ring_w = w; g_ring_h = h; g_ring_fmt = fmt;
|
||||
LOGD("framegen: generation ring %ux%u x%u", w, h, n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ====================================================================== present path */
|
||||
|
||||
static int engine_usable(void) {
|
||||
int kind = atomic_load(&g_kind);
|
||||
return g_dev_ready && !g_dev_lost && fge_caps_ok(kind) && !start_failed_for(kind);
|
||||
}
|
||||
|
||||
int vkp_framegen_format_ok(VkFormat fmt) {
|
||||
if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1;
|
||||
if (!g_dev_ready || g_dev_lost || format_refused(fmt)) return 0;
|
||||
return fge_format_ok(fmt);
|
||||
}
|
||||
|
||||
/* The engine could not build its chain in a deeper format: refuse the format for the session and
|
||||
* restart the engine on the next frame (a failed build is sticky inside both engines). */
|
||||
static void refuse_format(VkFormat fmt, int kind, int w, int h, const char *what) {
|
||||
if (g_refused_n < (int)(sizeof(g_refused_fmt) / sizeof(g_refused_fmt[0]))) g_refused_fmt[g_refused_n++] = fmt;
|
||||
FGLOG("%s could not %s in format %d (the HDR picture's FP16) at %dx%d: it restarts, and HDR frames go through "
|
||||
"it in 8 bits from the next frame", fge_engine_name(kind), what, (int)fmt, w, h);
|
||||
destroy_ring();
|
||||
fge_stop();
|
||||
g_engine_ok = 0; g_engine_kind = -1;
|
||||
}
|
||||
|
||||
int vkp_framegen_active(void) {
|
||||
return atomic_load(&g_armed) && engine_usable();
|
||||
}
|
||||
|
||||
int vkp_framegen_extra_images(void) {
|
||||
if (!vkp_framegen_active()) return 0;
|
||||
int m = atomic_load(&g_mult);
|
||||
return m - 1 > VKP_FG_MAX_GENERATIONS ? VKP_FG_MAX_GENERATIONS : m - 1;
|
||||
}
|
||||
|
||||
static int ensure_engine(int kind) {
|
||||
if (g_engine_ok && g_engine_kind == kind) return 1;
|
||||
if (start_failed_for(kind)) return 0;
|
||||
if (g_engine_ok) { destroy_ring(); fge_stop(); g_engine_ok = 0; g_engine_kind = -1; }
|
||||
char *path = NULL;
|
||||
pthread_mutex_lock(&g_lock);
|
||||
if (g_cache_path) path = strdup(g_cache_path);
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
if (kind == VKP_FG_ENGINE_LSFG && !path) {
|
||||
FGLOG("LSFG Native can't start: no shader cache (import Lossless.dll in Settings)");
|
||||
mark_failed(kind);
|
||||
return 0;
|
||||
}
|
||||
int r = fge_start(kind, path);
|
||||
free(path);
|
||||
if (r != 0) {
|
||||
FGLOG("%s failed to start on the compositor's driver; frame generation stays off",
|
||||
fge_engine_name(kind));
|
||||
mark_failed(kind);
|
||||
return 0;
|
||||
}
|
||||
g_engine_ok = 1; g_engine_kind = kind;
|
||||
atomic_store(&g_cfg_dirty, 1);
|
||||
g_built_w = g_built_h = 0;
|
||||
FGLOG("%s engine ready (%s)", fge_engine_name(kind), fge_build_info());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int g_logged_mult;
|
||||
static void log_arm_transition(int armed, int kind, int mult) {
|
||||
if (armed == g_was_armed) {
|
||||
if (armed && mult != g_logged_mult) {
|
||||
g_logged_mult = mult;
|
||||
FGLOG("%s multiplier changed to x%d (%d interpolated frames per game frame)", fge_engine_name(kind), mult, mult - 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
g_was_armed = armed;
|
||||
if (armed) {
|
||||
g_logged_mult = mult;
|
||||
float flow, hz;
|
||||
pthread_mutex_lock(&g_lock); flow = g_flow; hz = g_refresh_hz; pthread_mutex_unlock(&g_lock);
|
||||
FGLOG("%s x%d armed (flow scale %.2f, panel %.0f Hz): real frames are presented one slot late "
|
||||
"with the interpolated frames ahead of them", fge_engine_name(kind), mult, (double)flow, (double)hz);
|
||||
} else {
|
||||
FGLOG("frame generation off (%llu frames generated this session)", (unsigned long long)g_total_generated);
|
||||
g_generating_logged = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
||||
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]) {
|
||||
(void)scene_view;
|
||||
int kind = atomic_load(&g_kind);
|
||||
int armed = atomic_load(&g_armed);
|
||||
int mult = atomic_load(&g_mult);
|
||||
g_planned = 0;
|
||||
if (!armed || !engine_usable() || w <= 0 || h <= 0) { log_arm_transition(0, kind, mult); return 0; }
|
||||
if (!ensure_engine(kind)) { log_arm_transition(0, kind, mult); return 0; }
|
||||
log_arm_transition(1, kind, mult);
|
||||
|
||||
if (atomic_exchange(&g_cfg_dirty, 0)) {
|
||||
float flow, hz;
|
||||
pthread_mutex_lock(&g_lock); flow = g_flow; hz = g_refresh_hz; pthread_mutex_unlock(&g_lock);
|
||||
fge_configure((uint32_t)mult, flow, hz, atomic_load(&g_model), atomic_load(&g_preset));
|
||||
}
|
||||
if (!fge_prepare((uint32_t)w, (uint32_t)h, fmt)) {
|
||||
if (fmt != VK_FORMAT_R8G8B8A8_UNORM && fge_unavailable()) {
|
||||
refuse_format(fmt, kind, w, h, "build its chain");
|
||||
return 0;
|
||||
}
|
||||
if (fge_unavailable()) {
|
||||
FGLOG("%s could not build its chain at %dx%d; frame generation stays off", fge_engine_name(kind), w, h);
|
||||
mark_failed(kind);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (g_built_w != (uint32_t)w || g_built_h != (uint32_t)h || g_built_fmt != fmt) {
|
||||
g_built_w = (uint32_t)w; g_built_h = (uint32_t)h; g_built_fmt = fmt;
|
||||
g_generating_logged = 0;
|
||||
}
|
||||
uint32_t want = (uint32_t)(mult - 1);
|
||||
if (!ensure_ring((uint32_t)w, (uint32_t)h, fmt, want)) {
|
||||
if (fmt != VK_FORMAT_R8G8B8A8_UNORM) { refuse_format(fmt, kind, w, h, "make its generation ring"); return 0; }
|
||||
FGLOG("no memory for the generation ring (%dx%d x%u); frame generation stays off", w, h, want);
|
||||
mark_failed(kind);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t n_gen = fge_plan(g_ring_n, ++g_source_frames, g_presented_rate);
|
||||
if (n_gen > g_ring_n) n_gen = g_ring_n;
|
||||
g_planned = n_gen;
|
||||
|
||||
/* The scene image was just written (blits, and whatever the effects chain did); make that
|
||||
* visible to the engine's copy (TRANSFER) and shaders (COMPUTE). Fresh ring images get their
|
||||
* one UNDEFINED -> GENERAL transition here; the others need TRANSFER-read -> COMPUTE-write. */
|
||||
VkImageMemoryBarrier bars[1 + VKP_FG_MAX_GENERATIONS];
|
||||
uint32_t nb = 0;
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = scene, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
for (uint32_t g = 0; g < n_gen; g++) {
|
||||
struct ring_image *r = &g_ring[g];
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.srcAccessMask = r->fresh ? 0 : VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT,
|
||||
.oldLayout = r->fresh ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_GENERAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = r->img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
r->fresh = 0;
|
||||
}
|
||||
vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
0, 0, NULL, 0, NULL, nb, bars);
|
||||
|
||||
/* Frame N in; the shared passes (the whole flow pyramid) run only when generating. */
|
||||
fge_process(cmd, scene, (uint32_t)w, (uint32_t)h, n_gen);
|
||||
for (uint32_t g = 0; g < n_gen; g++) {
|
||||
fge_generate(cmd, g, n_gen, g_ring[g].img, g_ring[g].view, (uint32_t)w, (uint32_t)h);
|
||||
gens[g] = g_ring[g].img;
|
||||
}
|
||||
if (n_gen) {
|
||||
/* Compute writes -> the screen blits (this command buffer and the later per-present ones;
|
||||
* a barrier's first scope covers everything submitted earlier on the queue). */
|
||||
nb = 0;
|
||||
for (uint32_t g = 0; g < n_gen; g++)
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = g_ring[g].img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 0, NULL, nb, bars);
|
||||
if (!g_generating_logged) {
|
||||
g_generating_logged = 1;
|
||||
FGLOG("generating: %s x%d at %dx%d (%u interpolated frame%s per game frame%s)",
|
||||
fge_engine_name(kind), mult, w, h, n_gen, n_gen == 1 ? "" : "s",
|
||||
fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? ", FP16: the HDR picture" : "");
|
||||
}
|
||||
}
|
||||
return (int)n_gen;
|
||||
}
|
||||
|
||||
void vkp_framegen_presented(int generated) {
|
||||
if (generated < 0) generated = 0;
|
||||
int64_t now = now_ns();
|
||||
if (!g_window_start_ns) { g_window_start_ns = now; g_present_accum = 0; g_source_accum = 0; }
|
||||
g_present_accum += (uint32_t)generated + 1u;
|
||||
g_source_accum += 1u;
|
||||
if (generated) {
|
||||
atomic_fetch_add(&g_stat_generated, (unsigned)generated);
|
||||
g_total_generated += (uint64_t)generated;
|
||||
}
|
||||
float elapsed = (float)(now - g_window_start_ns) / 1e9f;
|
||||
if (elapsed < 0.5f) return; /* half-second window, like the X11 renderer */
|
||||
float rate = (float)g_present_accum / elapsed, src = (float)g_source_accum / elapsed;
|
||||
g_presented_rate = g_presented_rate > 0.0f ? g_presented_rate + (rate - g_presented_rate) * 0.25f : rate;
|
||||
g_source_rate = g_source_rate > 0.0f ? g_source_rate + (src - g_source_rate) * 0.25f : src;
|
||||
g_window_start_ns = now;
|
||||
g_present_accum = 0;
|
||||
g_source_accum = 0;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef FRAMEGEN_BRIDGE_H
|
||||
#define FRAMEGEN_BRIDGE_H
|
||||
/*
|
||||
* Frame generation on the Wayland backend (feat/wayland-framegen).
|
||||
*
|
||||
* The two NATIVE engines the X11 renderer runs inside libwinlator's compositor - LSFG Native
|
||||
* (the user's Lossless.dll chain, lsfg/) and Win-FG Native (our own FSR3-derived optical-flow
|
||||
* chain, winfg/) - are hosted here inside the Wayland compositor's Turnip device. Both consume
|
||||
* consecutive presented frames and emit interpolated frames between them; the guest never
|
||||
* sees any of it. bionic-fg (the guest-side win-fg Vulkan layer) is X11-only and is not
|
||||
* ported: its frames are born inside the guest and have nothing to attach to here.
|
||||
*
|
||||
* Present order per scene frame (vk_present.c):
|
||||
* scene -> effects -> FRAME GENERATION -> mapping/blit -> swapchain
|
||||
* The scene is composed 1:1 into an off-screen image, the effects chain runs on it, then
|
||||
* vkp_framegen_run() (the one hook) feeds that image to the engine and hands back up to three
|
||||
* generated images. vk_present.c blits the generated frames to the screen FIRST and the real
|
||||
* frame LAST (interpolation produces frames that belong between N-1 and N), one FIFO present
|
||||
* each, so the panel shows them on consecutive vblanks - the same pacing the X11 native path
|
||||
* is device-proven with. No sleeps, no host-side pacer.
|
||||
*
|
||||
* Threads: the set_* controls are called from the app (JNI, any thread) and only store
|
||||
* values; everything that touches Vulkan runs on the compositor thread inside vkp_render().
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_WINFG = 1 };
|
||||
/* Hard ceiling on generated frames per source frame (2x..4x -> 1..3), as on X11. */
|
||||
#define VKP_FG_MAX_GENERATIONS 3
|
||||
|
||||
/* ---- app controls (any thread) ------------------------------------------------------- */
|
||||
void vkp_framegen_set_engine(int kind);
|
||||
/* multiplier 2..4; armed = 0 stops generating (the ring and the engine stay for a re-arm). */
|
||||
void vkp_framegen_set_armed(int armed, int multiplier);
|
||||
/* LSFG Native: the SPIR-V cache built from the user's Lossless.dll (LsfgNative.ensureCache). */
|
||||
void vkp_framegen_set_lsfg_cache_path(const char *path);
|
||||
/* Flow scale 0.25..1.0 and the panel's real refresh rate (the pacer never generates above it). */
|
||||
void vkp_framegen_set_tuning(float flow_scale, float refresh_hz);
|
||||
/* Win-FG Native: interpolation model (3/4) and performance preset (0..2). */
|
||||
void vkp_framegen_set_winfg_tuning(int model, int perf_preset);
|
||||
/* Same codes as VulkanRenderer.getFrameGenProblem(): -1 not known yet (device not up), 0 fine,
|
||||
* 1 the driver lacks what the selected engine needs (vkp_framegen_caps_reason says what),
|
||||
* 2 the engine failed to start / build its chain. */
|
||||
int vkp_framegen_problem(void);
|
||||
const char *vkp_framegen_caps_reason(void);
|
||||
/* Same shape as VulkanRenderer.getFrameGenStats(): {generations trusted, generations planned,
|
||||
* real (source) fps, presented fps incl. generated frames, thermal (-1 = none), ms per
|
||||
* generated frame (-1 = unknown)}. */
|
||||
void vkp_framegen_stats(float out[6]);
|
||||
/* Generated frames presented since the last call (compositor.c, the 10 s stats line). */
|
||||
unsigned vkp_framegen_stats_take(void);
|
||||
|
||||
/* ---- vk_present.c: device setup (compositor thread) ----------------------------------- */
|
||||
/* Before vkCreateDevice: probe what the engines need on this physical device and return the
|
||||
* pNext chain to hang on VkDeviceCreateInfo (NULL when the device cannot run the LSFG chain -
|
||||
* Win-FG needs no feature). Owned by the bridge, valid until the next call. */
|
||||
const void *vkp_framegen_device_features(VkInstance inst, PFN_vkGetInstanceProcAddr gipa,
|
||||
VkPhysicalDevice pd);
|
||||
/* After the device exists (features_enabled = the chain above was accepted). */
|
||||
void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled);
|
||||
/* VK_ERROR_DEVICE_LOST: never touch the device again. */
|
||||
void vkp_framegen_device_lost(void);
|
||||
|
||||
/* ---- vk_present.c: present path (compositor thread) ------------------------------------ */
|
||||
/* 1 when this frame must go through the compositor pass (armed and the engine can run). Safe
|
||||
* before the device is up (0). */
|
||||
int vkp_framegen_active(void);
|
||||
/* Extra swapchain images wanted so every present of one scene frame is queued without waiting
|
||||
* for a vblank: multiplier - 1 while armed, 0 otherwise. A change means "rebuild the swapchain". */
|
||||
int vkp_framegen_extra_images(void);
|
||||
/* THE hook. Called once per composed scene frame, after the effects hook, with the scene image
|
||||
* (GENERAL, w x h, fmt, TRANSFER_SRC|SAMPLED). Records the engine's chain into `cmd` and
|
||||
* returns how many generated frames (0..VKP_FG_MAX_GENERATIONS) it produced, their images in
|
||||
* gens[] (GENERAL, w x h, already made visible to TRANSFER reads). 0 = present the scene alone. */
|
||||
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
||||
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]);
|
||||
/* After the presents of one scene frame: how many generated frames actually reached the
|
||||
* swapchain (rate tracking + the stats counters). */
|
||||
void vkp_framegen_presented(int generated);
|
||||
/* 1 when vkp_framegen_run can be fed `fmt` (the 8-bit scene always; FP16 for HDR frames where the
|
||||
* device can generate in it and the engine has not refused it this session). A chain that fails to
|
||||
* build in a deeper format is not an engine failure: the engine restarts and the format is refused,
|
||||
* so the caller goes back to 8 bits. */
|
||||
int vkp_framegen_format_ok(VkFormat fmt);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,250 @@
|
||||
// C++ side of the Wayland frame-generation bridge - see framegen_engine.h.
|
||||
//
|
||||
// Hosts the SAME engine objects the X11 renderer drives (lsfg::Engine, winfg::Engine), fed from
|
||||
// the compositor's own Turnip entry points. Nothing in winlator/lsfg or winlator/winfg is
|
||||
// modified: the engines take a VkTable (VulkanRendererContext.h) for their dispatch, and one is
|
||||
// filled here by name from the compositor's vkGetInstanceProcAddr / vkGetDeviceProcAddr.
|
||||
#include "framegen_engine.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "VulkanRendererContext.h" // VkTable
|
||||
#include "lsfg/lsfg_engine.h"
|
||||
#include "lsfg/lsfg_probe.h"
|
||||
#include "lsfg/lsfg_vkd.h"
|
||||
#include "winfg/winfg_engine.h"
|
||||
|
||||
#define ELOG(...) __android_log_print(ANDROID_LOG_INFO, "BannerWayland", "framegen: " __VA_ARGS__)
|
||||
#define ELOGE(...) __android_log_print(ANDROID_LOG_ERROR, "BannerWayland", "framegen: " __VA_ARGS__)
|
||||
|
||||
namespace {
|
||||
|
||||
VkTable g_table{};
|
||||
lsfg::Caps g_caps{};
|
||||
VkPhysicalDeviceVulkan12Features g_v12{};
|
||||
VkPhysicalDeviceFeatures2 g_f2{};
|
||||
VkPhysicalDevice g_pd = VK_NULL_HANDLE;
|
||||
VkDevice g_dev = VK_NULL_HANDLE;
|
||||
VkQueue g_queue = VK_NULL_HANDLE;
|
||||
uint32_t g_qfam = 0;
|
||||
bool g_probed = false, g_ready = false;
|
||||
|
||||
std::unique_ptr<lsfg::Engine> g_lsfg;
|
||||
std::unique_ptr<winfg::Engine> g_winfg;
|
||||
int g_kind = -1;
|
||||
char g_build[96] = "";
|
||||
|
||||
// Instance-level entry points the engines and the probe use.
|
||||
#define FGE_INSTANCE_FUNCS(X) \
|
||||
X(GetPhysicalDeviceProperties) X(GetPhysicalDeviceMemoryProperties) \
|
||||
X(GetPhysicalDeviceFeatures2) X(GetPhysicalDeviceFormatProperties) \
|
||||
X(GetPhysicalDeviceQueueFamilyProperties) X(GetDeviceProcAddr)
|
||||
// Device-level: the LSFG chain's 34 (lsfg_vkd.h), win-fg's extras (winfg_vkd.cpp) and the
|
||||
// generic set either may reach for. Anything left null in VkTable is never called.
|
||||
#define FGE_DEVICE_FUNCS(X) \
|
||||
X(AllocateDescriptorSets) X(AllocateMemory) X(BindBufferMemory) X(BindImageMemory) \
|
||||
X(CmdBindDescriptorSets) X(CmdBindPipeline) X(CmdCopyImage) X(CmdDispatch) \
|
||||
X(CmdPipelineBarrier) X(CreateBuffer) X(CreateComputePipelines) X(CreateDescriptorPool) \
|
||||
X(CreateDescriptorSetLayout) X(CreateImage) X(CreateImageView) X(CreatePipelineLayout) \
|
||||
X(CreateSampler) X(CreateShaderModule) X(DestroyBuffer) X(DestroyDescriptorPool) \
|
||||
X(DestroyDescriptorSetLayout) X(DestroyImage) X(DestroyImageView) X(DestroyPipeline) \
|
||||
X(DestroyPipelineLayout) X(DestroySampler) X(DestroyShaderModule) X(FreeMemory) \
|
||||
X(GetBufferMemoryRequirements) X(GetImageMemoryRequirements) X(MapMemory) X(UnmapMemory) \
|
||||
X(UpdateDescriptorSets) X(CmdClearColorImage) X(DeviceWaitIdle) X(ResetDescriptorPool) \
|
||||
X(QueueSubmit) X(CreateFence) X(DestroyFence) X(WaitForFences) \
|
||||
X(ResetFences) X(GetFenceStatus) X(CreateSemaphore) X(DestroySemaphore) \
|
||||
X(CreateCommandPool) X(DestroyCommandPool) X(AllocateCommandBuffers) \
|
||||
X(FreeCommandBuffers) X(BeginCommandBuffer) X(EndCommandBuffer) X(ResetCommandBuffer) \
|
||||
X(CmdBlitImage) X(CmdCopyBufferToImage) X(FreeDescriptorSets) X(FlushMappedMemoryRanges) \
|
||||
X(GetDeviceQueue) X(CreateQueryPool) X(DestroyQueryPool) X(CmdResetQueryPool) \
|
||||
X(CmdWriteTimestamp) X(GetQueryPoolResults)
|
||||
|
||||
void fill_instance(PFN_vkGetInstanceProcAddr gipa, VkInstance inst) {
|
||||
#define X(n) g_table.n = reinterpret_cast<PFN_vk##n>(gipa(inst, "vk" #n));
|
||||
FGE_INSTANCE_FUNCS(X)
|
||||
#undef X
|
||||
}
|
||||
|
||||
void fill_device(VkDevice dev) {
|
||||
if (!g_table.GetDeviceProcAddr) return;
|
||||
#define X(n) g_table.n = reinterpret_cast<PFN_vk##n>(g_table.GetDeviceProcAddr(dev, "vk" #n));
|
||||
FGE_DEVICE_FUNCS(X)
|
||||
#undef X
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
|
||||
const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkFormat ring_fmt) {
|
||||
g_pd = pd;
|
||||
fill_instance(gipa, inst);
|
||||
std::vector<VkExtensionProperties> exts;
|
||||
auto enumExts = reinterpret_cast<PFN_vkEnumerateDeviceExtensionProperties>(
|
||||
gipa(inst, "vkEnumerateDeviceExtensionProperties"));
|
||||
if (enumExts) {
|
||||
uint32_t n = 0;
|
||||
enumExts(pd, nullptr, &n, nullptr);
|
||||
exts.resize(n);
|
||||
if (n) enumExts(pd, nullptr, &n, exts.data());
|
||||
}
|
||||
g_caps = lsfg::Caps{};
|
||||
// No Vulkan 1.1 compat here: the Wayland compositor only ever runs on Turnip (adrenotools),
|
||||
// which reports 1.3+; the stock-driver case the compat flag exists for cannot reach it.
|
||||
g_caps.features = lsfg::queryFeatures(g_table, pd, exts, /*allowVk11=*/false);
|
||||
g_caps.probedFormat = ring_fmt;
|
||||
g_caps.storageOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||
? lsfg::probeStorageFormat(g_table, pd, ring_fmt) : false;
|
||||
g_caps.linearBlitOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||
? lsfg::probeLinearBlit(g_table, pd, ring_fmt) : false;
|
||||
g_probed = true;
|
||||
if (!g_caps.features.deviceGatesPass()) {
|
||||
lsfg::explain(g_caps);
|
||||
ELOG("device gates for the LSFG chain fail: %s", g_caps.reason);
|
||||
return nullptr;
|
||||
}
|
||||
// Same chain VulkanRendererContext::createLogicalDevice hangs on its device.
|
||||
g_v12 = VkPhysicalDeviceVulkan12Features{};
|
||||
g_v12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||
g_v12.vulkanMemoryModel = VK_TRUE;
|
||||
g_v12.vulkanMemoryModelDeviceScope =
|
||||
g_caps.features.vulkanMemoryModelDeviceScope ? VK_TRUE : VK_FALSE;
|
||||
g_f2 = VkPhysicalDeviceFeatures2{};
|
||||
g_f2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
g_f2.pNext = &g_v12;
|
||||
g_f2.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
|
||||
g_f2.features.shaderStorageImageExtendedFormats = VK_TRUE;
|
||||
return &g_f2;
|
||||
}
|
||||
|
||||
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled) {
|
||||
if (!g_probed) fill_instance(gipa, inst);
|
||||
g_pd = pd; g_dev = dev; g_queue = queue; g_qfam = qfam;
|
||||
fill_device(dev);
|
||||
g_caps.featuresEnabled = features_enabled != 0;
|
||||
lsfg::explain(g_caps);
|
||||
g_ready = true;
|
||||
ELOG("device ready: lsfg caps '%s', storage on ring format %d", g_caps.reason,
|
||||
(int)g_caps.storageOnSwapchainFormat);
|
||||
}
|
||||
|
||||
int fge_caps_ok(int kind) {
|
||||
if (!g_ready) return 0;
|
||||
if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0;
|
||||
return g_caps.supported() ? 1 : 0;
|
||||
}
|
||||
|
||||
const char *fge_caps_reason(void) { return g_caps.reason; }
|
||||
|
||||
int fge_format_ok(VkFormat fmt) {
|
||||
if (!g_ready || !g_table.GetPhysicalDeviceFormatProperties || fmt == VK_FORMAT_UNDEFINED) return 0;
|
||||
return lsfg::probeStorageFormat(g_table, g_pd, fmt) && lsfg::probeLinearBlit(g_table, g_pd, fmt) ? 1 : 0;
|
||||
}
|
||||
|
||||
int fge_start(int kind, const char *cache_path) {
|
||||
fge_stop();
|
||||
if (!g_ready) return -1;
|
||||
if (kind == 1) {
|
||||
auto e = std::make_unique<winfg::Engine>();
|
||||
if (!e->init(g_table, g_pd, g_dev, g_qfam, g_queue)) {
|
||||
ELOGE("winfg-native: engine init failed");
|
||||
return -1;
|
||||
}
|
||||
g_winfg = std::move(e);
|
||||
g_kind = 1;
|
||||
#if defined(WINFG_UPSTREAM) && defined(WINFG_CHAIN_HASH)
|
||||
std::snprintf(g_build, sizeof(g_build), "chain %s, src %s", WINFG_UPSTREAM, WINFG_CHAIN_HASH);
|
||||
#else
|
||||
std::snprintf(g_build, sizeof(g_build), "embedded chain");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if (!cache_path || !*cache_path) return -1;
|
||||
if (!lsfgVkdInit(g_table)) {
|
||||
ELOGE("lsfg-native: dispatch incomplete");
|
||||
return -1;
|
||||
}
|
||||
auto e = std::make_unique<lsfg::Engine>();
|
||||
if (!e->init(g_dev, g_pd, cache_path, g_caps.features.spirvTarget)) {
|
||||
ELOGE("lsfg-native: engine init failed (cache %s, spirv target 0x%x)", cache_path,
|
||||
g_caps.features.spirvTarget);
|
||||
return -1;
|
||||
}
|
||||
g_lsfg = std::move(e);
|
||||
g_kind = 0;
|
||||
std::snprintf(g_build, sizeof(g_build), "spirv target 0x%x, cache %s",
|
||||
g_caps.features.spirvTarget, cache_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fge_stop(void) {
|
||||
if ((g_lsfg || g_winfg) && g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev);
|
||||
g_lsfg.reset();
|
||||
g_winfg.reset();
|
||||
g_kind = -1;
|
||||
}
|
||||
|
||||
int fge_unavailable(void) {
|
||||
if (g_kind == 1) return g_winfg && g_winfg->unavailable() ? 1 : 0;
|
||||
return g_lsfg && g_lsfg->unavailable() ? 1 : 0;
|
||||
}
|
||||
|
||||
void fge_configure(uint32_t multiplier, float flow_scale, float refresh_hz, int model,
|
||||
int perf_preset) {
|
||||
if (multiplier < 2) multiplier = 2;
|
||||
if (g_kind == 1 && g_winfg) g_winfg->configure(multiplier, model, perf_preset, flow_scale);
|
||||
else if (g_lsfg) g_lsfg->configure(multiplier, 0, flow_scale, refresh_hz);
|
||||
}
|
||||
|
||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
||||
if (g_kind == 1) return g_winfg && g_winfg->prepare(w, h, fmt) ? 1 : 0;
|
||||
if (!g_lsfg) return 0;
|
||||
// The Wayland scene is the game's own size when it runs fullscreen, so the flow pyramid is
|
||||
// scaled against that (X11 passes the X screen size here for the same reason).
|
||||
g_lsfg->setGuestExtent(w, h);
|
||||
return g_lsfg->prepare(w, h, fmt) ? 1 : 0;
|
||||
}
|
||||
|
||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
||||
if (g_kind == 1) return g_winfg ? g_winfg->plan(capacity) : 0;
|
||||
if (!g_lsfg) return 0;
|
||||
g_lsfg->setPresentedRate(presented_rate);
|
||||
return g_lsfg->plan(capacity, source_frames);
|
||||
}
|
||||
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) {
|
||||
if (g_kind == 1) { if (g_winfg) g_winfg->process(cmd, source, w, h, gens); return; }
|
||||
if (g_lsfg) g_lsfg->process(cmd, source, w, h, gens);
|
||||
}
|
||||
|
||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||
uint32_t w, uint32_t h) {
|
||||
if (g_kind == 1) { if (g_winfg) g_winfg->generateInto(cmd, g, count, img, view, w, h); return; }
|
||||
if (g_lsfg) g_lsfg->generateInto(cmd, g, g, img, view, w, h);
|
||||
}
|
||||
|
||||
void fge_forget_targets(void) {
|
||||
if (g_lsfg) g_lsfg->forgetTargets();
|
||||
}
|
||||
|
||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
||||
*accepted = 0.0f; *source_rate = 0.0f; *thermal = -1.0f;
|
||||
if (g_kind == 0 && g_lsfg) {
|
||||
*accepted = (float)g_lsfg->acceptedGenerations();
|
||||
*source_rate = g_lsfg->sourceRate();
|
||||
*thermal = (float)g_lsfg->thermalStatus();
|
||||
}
|
||||
}
|
||||
|
||||
const char *fge_engine_name(int kind) { return kind == 1 ? "Win-FG Native" : "LSFG Native"; }
|
||||
const char *fge_build_info(void) { return g_build; }
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef FRAMEGEN_ENGINE_H
|
||||
#define FRAMEGEN_ENGINE_H
|
||||
/*
|
||||
* C face of the C++ frame-generation engines for framegen_bridge.c.
|
||||
*
|
||||
* framegen_engine.cpp wraps lsfg::Engine (winlator/lsfg) and winfg::Engine (winlator/winfg)
|
||||
* unmodified - the same objects the X11 renderer (VulkanRendererContext) drives - and fills
|
||||
* their dispatch tables from the compositor's own Turnip entry points. The standalone
|
||||
* compositor build (no winlator tree) compiles framegen_engine_stub.c instead, which reports
|
||||
* "engines not built in" and generates nothing.
|
||||
*
|
||||
* Every function runs on the compositor thread.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Probe the physical device and build the VkDeviceCreateInfo pNext chain the LSFG chain needs
|
||||
* (vulkanMemoryModel + storage-image features; nothing for Win-FG). Returns the chain, or NULL
|
||||
* when the device fails a gate. `ring_fmt` is the format the engines generate into; it must be
|
||||
* storage-capable for either engine. */
|
||||
const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkFormat ring_fmt);
|
||||
/* The device exists; resolve device-level entry points. features_enabled = fge_probe's chain
|
||||
* was accepted by vkCreateDevice. */
|
||||
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled);
|
||||
/* 1 when engine `kind` can run on this device (its capability gates pass). */
|
||||
int fge_caps_ok(int kind);
|
||||
/* Why the LSFG gates fail ("supported" when they pass); static string. */
|
||||
const char *fge_caps_reason(void);
|
||||
/* 1 when the engines can generate in `fmt` on this device (storage + linear sampling), beyond the
|
||||
* ring format probed at fge_probe - the FP16 scene of HDR frames (vk_present.c). */
|
||||
int fge_format_ok(VkFormat fmt);
|
||||
|
||||
/* Create engine `kind` (LSFG needs the cache path; Win-FG ignores it). 0 = ready, -1 = failed.
|
||||
* Only one engine holds GPU resources at a time; a different kind replaces it. */
|
||||
int fge_start(int kind, const char *cache_path);
|
||||
void fge_stop(void);
|
||||
/* The engine came up but later found it cannot generate (chain build failed). */
|
||||
int fge_unavailable(void);
|
||||
void fge_configure(uint32_t multiplier, float flow_scale, float refresh_hz, int model,
|
||||
int perf_preset);
|
||||
/* Build/rebuild the chain for this extent; the guest extent for the flow pyramid is the same
|
||||
* (the Wayland scene is the game's own size in fullscreen). 1 = chain valid. */
|
||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt);
|
||||
/* How many frames to generate for this source frame (0 until the history is valid). */
|
||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate);
|
||||
/* Take the scene image (GENERAL) as frame N and run the shared part of the chain. */
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens);
|
||||
/* Synthesise generated frame g of `count` into a storage image (GENERAL). */
|
||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||
uint32_t w, uint32_t h);
|
||||
/* The generation targets were recreated: drop cached descriptors. */
|
||||
void fge_forget_targets(void);
|
||||
/* Engine-side telemetry: accepted generations, source rate (0 = engine has none), thermal. */
|
||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal);
|
||||
const char *fge_engine_name(int kind);
|
||||
/* "lsfg-native"/"winfg-native" build provenance for the start log line. */
|
||||
const char *fge_build_info(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Stand-in for framegen_engine.cpp when the compositor is built on its own (standalone/, no
|
||||
* winlator tree, no dxbc). Every engine is reported unavailable; nothing is generated. */
|
||||
#include "framegen_engine.h"
|
||||
|
||||
const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkFormat ring_fmt) {
|
||||
(void)gipa; (void)inst; (void)pd; (void)ring_fmt;
|
||||
return NULL;
|
||||
}
|
||||
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled) {
|
||||
(void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled;
|
||||
}
|
||||
int fge_caps_ok(int kind) { (void)kind; return 0; }
|
||||
const char *fge_caps_reason(void) { return "frame-generation engines not built into this compositor"; }
|
||||
int fge_format_ok(VkFormat fmt) { (void)fmt; return 0; }
|
||||
int fge_start(int kind, const char *cache_path) { (void)kind; (void)cache_path; return -1; }
|
||||
void fge_stop(void) {}
|
||||
int fge_unavailable(void) { return 1; }
|
||||
void fge_configure(uint32_t multiplier, float flow_scale, float refresh_hz, int model, int perf_preset) {
|
||||
(void)multiplier; (void)flow_scale; (void)refresh_hz; (void)model; (void)perf_preset;
|
||||
}
|
||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) { (void)w; (void)h; (void)fmt; return 0; }
|
||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
||||
(void)capacity; (void)source_frames; (void)presented_rate; return 0;
|
||||
}
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) {
|
||||
(void)cmd; (void)source; (void)w; (void)h; (void)gens;
|
||||
}
|
||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||
uint32_t w, uint32_t h) {
|
||||
(void)cmd; (void)g; (void)count; (void)img; (void)view; (void)w; (void)h;
|
||||
}
|
||||
void fge_forget_targets(void) {}
|
||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
||||
*accepted = 0.0f; *source_rate = 0.0f; *thermal = -1.0f;
|
||||
}
|
||||
const char *fge_engine_name(int kind) { return kind == 1 ? "Win-FG Native" : "LSFG Native"; }
|
||||
const char *fge_build_info(void) { return "stub"; }
|
||||
@@ -0,0 +1,66 @@
|
||||
/* JNI for frame generation on the Wayland backend (WaylandCompositor.nativeFrameGen* /
|
||||
* nativeSet*FrameGen* / nativeSetLsfgCachePath / nativeSetWinFgTuning). Every call only stores
|
||||
* a value in framegen_bridge.c; the compositor thread picks it up on its next frame, so these
|
||||
* are safe from any thread and before the compositor is up (the app arms the engine from its
|
||||
* launch code while the SurfaceView is still coming). */
|
||||
#include <jni.h>
|
||||
#include "framegen_bridge.h"
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetFrameGenEngine(JNIEnv *env, jclass clazz, jint kind) {
|
||||
(void)env; (void)clazz;
|
||||
vkp_framegen_set_engine((int)kind);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetFrameGenArmed(JNIEnv *env, jclass clazz,
|
||||
jboolean armed, jint multiplier) {
|
||||
(void)env; (void)clazz;
|
||||
vkp_framegen_set_armed(armed ? 1 : 0, (int)multiplier);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetLsfgCachePath(JNIEnv *env, jclass clazz, jstring path) {
|
||||
(void)clazz;
|
||||
if (!path) { vkp_framegen_set_lsfg_cache_path(NULL); return; }
|
||||
const char *c = (*env)->GetStringUTFChars(env, path, NULL);
|
||||
vkp_framegen_set_lsfg_cache_path(c);
|
||||
if (c) (*env)->ReleaseStringUTFChars(env, path, c);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetFrameGenTuning(JNIEnv *env, jclass clazz,
|
||||
jfloat flowScale, jfloat refreshHz) {
|
||||
(void)env; (void)clazz;
|
||||
vkp_framegen_set_tuning((float)flowScale, (float)refreshHz);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetWinFgTuning(JNIEnv *env, jclass clazz,
|
||||
jint model, jint perfPreset) {
|
||||
(void)env; (void)clazz;
|
||||
vkp_framegen_set_winfg_tuning((int)model, (int)perfPreset);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeFrameGenProblem(JNIEnv *env, jclass clazz) {
|
||||
(void)env; (void)clazz;
|
||||
return (jint)vkp_framegen_problem();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeFrameGenCapsReason(JNIEnv *env, jclass clazz) {
|
||||
(void)clazz;
|
||||
const char *r = vkp_framegen_caps_reason();
|
||||
return (*env)->NewStringUTF(env, r ? r : "");
|
||||
}
|
||||
|
||||
JNIEXPORT jfloatArray JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeFrameGenStats(JNIEnv *env, jclass clazz) {
|
||||
(void)clazz;
|
||||
float st[6] = {0.f, 0.f, 0.f, 0.f, -1.f, -1.f};
|
||||
vkp_framegen_stats(st);
|
||||
jfloatArray arr = (*env)->NewFloatArray(env, 6);
|
||||
if (arr) (*env)->SetFloatArrayRegion(env, arr, 0, 6, st);
|
||||
return arr;
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
/* HDR composition: the encode pass over the mixed scene - see hdr_compose.h. Compositor thread. */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "hdr_compose.h"
|
||||
#include "vk_loader.h"
|
||||
#include "vk_present.h" /* banner_log, vkp_gpu_name */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* SPIR-V, pre-compiled (glslangValidator -V hdr_encode.frag --vn hdr_encode_code) and committed next
|
||||
* to the GLSL, like every other shader of the compositor: the NDK build compiles no shaders. The quad
|
||||
* is the effect chain's upscale.vert (same bytes, from app/src/main/cpp/winlator). */
|
||||
/* The headers define plain (external) arrays and effects_chain.c includes upscale_vert.h too: this
|
||||
* translation unit gets its own copy under another name, so the link sees no duplicate symbol. */
|
||||
#define upscale_vert_code hdrc_upscale_vert_code
|
||||
#include "upscale_vert.h"
|
||||
#undef upscale_vert_code
|
||||
#include "hdr_encode_frag.h"
|
||||
|
||||
#define MIXED_FORMAT VK_FORMAT_A2B10G10R10_UNORM_PACK32
|
||||
|
||||
struct pc_encode { float ndc[4]; float params[4]; float rects[HDRC_MAX_RECTS][4]; }; /* 128 bytes */
|
||||
|
||||
static VkDevice g_dev;
|
||||
static int g_ready; /* 0 = not built, 1 = ok, -1 = unavailable (said once) */
|
||||
static VkSampler g_sampler;
|
||||
static VkDescriptorSetLayout g_dsl;
|
||||
static VkPipelineLayout g_pl;
|
||||
static VkDescriptorPool g_dpool;
|
||||
static VkShaderModule g_vert, g_frag;
|
||||
|
||||
/* One render pass + pipeline per output format: the HDR picture is 10-bit, frame generation's scene
|
||||
* 8-bit - or FP16 where the engine takes it (vk_present.c FG_HDR_FMT). */
|
||||
#define NFMT 3
|
||||
static struct { VkFormat fmt; VkRenderPass rp; VkPipeline pipe; } g_out[NFMT] = {
|
||||
{VK_FORMAT_A2B10G10R10_UNORM_PACK32}, {VK_FORMAT_R8G8B8A8_UNORM}, {VK_FORMAT_R16G16B16A16_SFLOAT}};
|
||||
|
||||
/* The mixed image's view + descriptor, and each output image's view + framebuffer: kept while the
|
||||
* image handle (and size) stays the same, rebuilt when vk_present re-creates the image. */
|
||||
static struct { VkImage img; int w, h; VkImageView view; VkDescriptorSet ds; } g_src;
|
||||
#define NOUT 3
|
||||
static struct { VkImage img; VkFormat fmt; int w, h; VkImageView view; VkFramebuffer fb; } g_dst[NOUT];
|
||||
static int g_dst_next;
|
||||
|
||||
void hdrc_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops) {
|
||||
(void)memprops;
|
||||
g_dev = dev;
|
||||
}
|
||||
|
||||
static void src_release(void) {
|
||||
if (g_src.ds) g_vk.FreeDescriptorSets(g_dev, g_dpool, 1, &g_src.ds);
|
||||
if (g_src.view) g_vk.DestroyImageView(g_dev, g_src.view, NULL);
|
||||
memset(&g_src, 0, sizeof(g_src));
|
||||
}
|
||||
|
||||
static void dst_release(int i) {
|
||||
if (g_dst[i].fb) g_vk.DestroyFramebuffer(g_dev, g_dst[i].fb, NULL);
|
||||
if (g_dst[i].view) g_vk.DestroyImageView(g_dev, g_dst[i].view, NULL);
|
||||
memset(&g_dst[i], 0, sizeof(g_dst[i]));
|
||||
}
|
||||
|
||||
void hdrc_forget_image(VkImage img) {
|
||||
if (!g_dev || !img) return;
|
||||
if (g_src.img == img) src_release();
|
||||
for (int i = 0; i < NOUT; i++) if (g_dst[i].img == img) dst_release(i);
|
||||
}
|
||||
|
||||
void hdrc_destroy(void) {
|
||||
if (!g_dev) return;
|
||||
src_release();
|
||||
for (int i = 0; i < NOUT; i++) dst_release(i);
|
||||
for (int i = 0; i < NFMT; i++) {
|
||||
if (g_out[i].pipe) g_vk.DestroyPipeline(g_dev, g_out[i].pipe, NULL);
|
||||
if (g_out[i].rp) g_vk.DestroyRenderPass(g_dev, g_out[i].rp, NULL);
|
||||
g_out[i].pipe = VK_NULL_HANDLE; g_out[i].rp = VK_NULL_HANDLE;
|
||||
}
|
||||
if (g_vert) g_vk.DestroyShaderModule(g_dev, g_vert, NULL);
|
||||
if (g_frag) g_vk.DestroyShaderModule(g_dev, g_frag, NULL);
|
||||
if (g_dpool) g_vk.DestroyDescriptorPool(g_dev, g_dpool, NULL);
|
||||
if (g_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL);
|
||||
if (g_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_dsl, NULL);
|
||||
if (g_sampler) g_vk.DestroySampler(g_dev, g_sampler, NULL);
|
||||
g_vert = g_frag = VK_NULL_HANDLE; g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE;
|
||||
g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE;
|
||||
g_ready = 0;
|
||||
g_dev = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
static VkShaderModule shader(const uint32_t *code, size_t size) {
|
||||
VkShaderModule m = VK_NULL_HANDLE;
|
||||
VkShaderModuleCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, .codeSize = size, .pCode = code};
|
||||
if (g_vk.CreateShaderModule(g_dev, &ci, NULL, &m) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* The render pass: one colour target written whole (DONT_CARE), left in TRANSFER_DST_OPTIMAL for the
|
||||
* effects chain / the copies that follow. The dependencies order it after whoever read or wrote the
|
||||
* target last (last frame's blit or chain) and before whoever samples, blits or copies it next. */
|
||||
static VkRenderPass make_rp(VkFormat fmt) {
|
||||
VkAttachmentDescription att = {.format = fmt, .samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||
.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.finalLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL};
|
||||
VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
|
||||
VkSubpassDescription sub = {.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .colorAttachmentCount = 1,
|
||||
.pColorAttachments = &ref};
|
||||
VkSubpassDependency deps[2] = {
|
||||
{.srcSubpass = VK_SUBPASS_EXTERNAL, .dstSubpass = 0,
|
||||
.srcStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT |
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT},
|
||||
{.srcSubpass = 0, .dstSubpass = VK_SUBPASS_EXTERNAL,
|
||||
.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
.dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT |
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT}};
|
||||
VkRenderPassCreateInfo rci = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .attachmentCount = 1,
|
||||
.pAttachments = &att, .subpassCount = 1, .pSubpasses = &sub,
|
||||
.dependencyCount = 2, .pDependencies = deps};
|
||||
VkRenderPass rp = VK_NULL_HANDLE;
|
||||
if (g_vk.CreateRenderPass(g_dev, &rci, NULL, &rp) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
return rp;
|
||||
}
|
||||
|
||||
static VkPipeline make_pipe(VkRenderPass rp) {
|
||||
VkPipelineShaderStageCreateInfo st[2] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .stage = VK_SHADER_STAGE_VERTEX_BIT,
|
||||
.module = g_vert, .pName = "main"},
|
||||
{.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
.module = g_frag, .pName = "main"}};
|
||||
VkPipelineVertexInputStateCreateInfo vi = {.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO};
|
||||
VkPipelineInputAssemblyStateCreateInfo ia = {.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP};
|
||||
VkDynamicState dyn[2] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR};
|
||||
VkPipelineDynamicStateCreateInfo ds = {.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.dynamicStateCount = 2, .pDynamicStates = dyn};
|
||||
VkPipelineViewportStateCreateInfo vp = {.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||
.viewportCount = 1, .scissorCount = 1};
|
||||
VkPipelineRasterizationStateCreateInfo rs = {.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||
.polygonMode = VK_POLYGON_MODE_FILL, .cullMode = VK_CULL_MODE_NONE,
|
||||
.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE, .lineWidth = 1.0f};
|
||||
VkPipelineMultisampleStateCreateInfo ms = {.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
||||
.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT};
|
||||
VkPipelineColorBlendAttachmentState ba = {.blendEnable = VK_FALSE, .colorWriteMask = 0xF};
|
||||
VkPipelineColorBlendStateCreateInfo cb = {.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
||||
.attachmentCount = 1, .pAttachments = &ba};
|
||||
VkGraphicsPipelineCreateInfo pi = {.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .stageCount = 2,
|
||||
.pStages = st, .pVertexInputState = &vi, .pInputAssemblyState = &ia,
|
||||
.pViewportState = &vp, .pRasterizationState = &rs, .pMultisampleState = &ms,
|
||||
.pColorBlendState = &cb, .pDynamicState = &ds, .layout = g_pl,
|
||||
.renderPass = rp, .subpass = 0};
|
||||
VkPipeline p = VK_NULL_HANDLE;
|
||||
if (g_vk.CreateGraphicsPipelines(g_dev, VK_NULL_HANDLE, 1, &pi, NULL, &p) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
return p;
|
||||
}
|
||||
|
||||
static int objects_ensure(void) {
|
||||
if (g_ready) return g_ready == 1 ? 0 : -1;
|
||||
g_ready = -1;
|
||||
if (!g_dev || !g_vk.CreateGraphicsPipelines) goto fail;
|
||||
VkSamplerCreateInfo sci = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_NEAREST,
|
||||
.minFilter = VK_FILTER_NEAREST, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE};
|
||||
if (g_vk.CreateSampler(g_dev, &sci, NULL, &g_sampler) != VK_SUCCESS) goto fail;
|
||||
VkDescriptorSetLayoutBinding b = {.binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT};
|
||||
VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.bindingCount = 1, .pBindings = &b};
|
||||
if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_dsl) != VK_SUCCESS) goto fail;
|
||||
VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
.offset = 0, .size = sizeof(struct pc_encode)};
|
||||
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 1,
|
||||
.pSetLayouts = &g_dsl, .pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
||||
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail;
|
||||
VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2};
|
||||
VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = 2,
|
||||
.poolSizeCount = 1, .pPoolSizes = &ps};
|
||||
if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail;
|
||||
if (!(g_vert = shader(hdrc_upscale_vert_code, sizeof(hdrc_upscale_vert_code)))) goto fail;
|
||||
if (!(g_frag = shader(hdr_encode_code, sizeof(hdr_encode_code)))) goto fail;
|
||||
for (int i = 0; i < NFMT; i++) {
|
||||
if (!(g_out[i].rp = make_rp(g_out[i].fmt))) goto fail;
|
||||
if (!(g_out[i].pipe = make_pipe(g_out[i].rp))) goto fail;
|
||||
}
|
||||
g_ready = 1;
|
||||
banner_log("color", "HDR composition ready on %s: scenes that mix HDR and SDR content are put into one "
|
||||
"encoding (PQ BT.2020, or tone-mapped sRGB) instead of being shown washed out", vkp_gpu_name());
|
||||
return 0;
|
||||
fail:
|
||||
{
|
||||
VkDevice keep = g_dev;
|
||||
hdrc_destroy();
|
||||
g_dev = keep;
|
||||
}
|
||||
g_ready = -1;
|
||||
banner_log("error", "color: the HDR composition pass could not be built on this driver; HDR scenes that cannot "
|
||||
"stay on the game's own layer are shown the old way (washed out) this session");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static VkImageView make_view(VkImage img, VkFormat fmt) {
|
||||
VkImageView v = VK_NULL_HANDLE;
|
||||
VkImageViewCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = img,
|
||||
.viewType = VK_IMAGE_VIEW_TYPE_2D, .format = fmt,
|
||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
if (g_vk.CreateImageView(g_dev, &ci, NULL, &v) != VK_SUCCESS) return VK_NULL_HANDLE;
|
||||
return v;
|
||||
}
|
||||
|
||||
static int src_ensure(VkImage img, int w, int h) {
|
||||
if (g_src.img == img && g_src.w == w && g_src.h == h && g_src.ds) return 0;
|
||||
src_release();
|
||||
if (!(g_src.view = make_view(img, MIXED_FORMAT))) return -1;
|
||||
VkDescriptorSetAllocateInfo ai = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||
.descriptorPool = g_dpool, .descriptorSetCount = 1, .pSetLayouts = &g_dsl};
|
||||
if (g_vk.AllocateDescriptorSets(g_dev, &ai, &g_src.ds) != VK_SUCCESS) { g_src.ds = VK_NULL_HANDLE; src_release(); return -1; }
|
||||
VkDescriptorImageInfo ii = {.sampler = g_sampler, .imageView = g_src.view,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL};
|
||||
VkWriteDescriptorSet wr = {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = g_src.ds, .dstBinding = 0,
|
||||
.descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.pImageInfo = &ii};
|
||||
g_vk.UpdateDescriptorSets(g_dev, 1, &wr, 0, NULL);
|
||||
g_src.img = img; g_src.w = w; g_src.h = h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fmt_slot(VkFormat fmt) {
|
||||
for (int i = 0; i < NFMT; i++) if (g_out[i].fmt == fmt) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static VkFramebuffer dst_ensure(VkImage img, VkFormat fmt, int w, int h, VkRenderPass rp) {
|
||||
for (int i = 0; i < NOUT; i++)
|
||||
if (g_dst[i].img == img && g_dst[i].fmt == fmt && g_dst[i].w == w && g_dst[i].h == h && g_dst[i].fb)
|
||||
return g_dst[i].fb;
|
||||
int i = g_dst_next;
|
||||
g_dst_next = (g_dst_next + 1) % NOUT;
|
||||
dst_release(i);
|
||||
if (!(g_dst[i].view = make_view(img, fmt))) return VK_NULL_HANDLE;
|
||||
VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = rp,
|
||||
.attachmentCount = 1, .pAttachments = &g_dst[i].view, .width = (uint32_t)w,
|
||||
.height = (uint32_t)h, .layers = 1};
|
||||
if (g_vk.CreateFramebuffer(g_dev, &fi, NULL, &g_dst[i].fb) != VK_SUCCESS) { g_dst[i].fb = VK_NULL_HANDLE; dst_release(i); return VK_NULL_HANDLE; }
|
||||
g_dst[i].img = img; g_dst[i].fmt = fmt; g_dst[i].w = w; g_dst[i].h = h;
|
||||
return g_dst[i].fb;
|
||||
}
|
||||
|
||||
int hdrc_encode(VkCommandBuffer cmd, VkImage mixed, VkImage out, VkFormat out_fmt, int w, int h,
|
||||
const struct hdrc_params *p) {
|
||||
if (!mixed || !out || w <= 0 || h <= 0 || !p || objects_ensure() != 0) return -1;
|
||||
int slot = fmt_slot(out_fmt);
|
||||
if (slot < 0) return -1;
|
||||
if (src_ensure(mixed, w, h) != 0) return -1;
|
||||
VkFramebuffer fb = dst_ensure(out, out_fmt, w, h, g_out[slot].rp);
|
||||
if (!fb) return -1;
|
||||
|
||||
/* The composite blits wrote the mixed image; the pass samples it. */
|
||||
VkImageMemoryBarrier b = {.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = mixed, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1},
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, .dstAccessMask = VK_ACCESS_SHADER_READ_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &b);
|
||||
|
||||
struct pc_encode pc;
|
||||
memset(&pc, 0, sizeof(pc));
|
||||
pc.ndc[0] = -1.0f; pc.ndc[1] = -1.0f; pc.ndc[2] = 1.0f; pc.ndc[3] = 1.0f;
|
||||
int count = p->count < 0 ? 0 : p->count > HDRC_MAX_RECTS ? HDRC_MAX_RECTS : p->count;
|
||||
unsigned mask = p->hdr_mask & ((1u << HDRC_MAX_RECTS) - 1u);
|
||||
pc.params[0] = p->sdr_white_nits > 0.0f ? p->sdr_white_nits : 203.0f;
|
||||
pc.params[1] = p->peak_nits > 0.0f ? p->peak_nits : 1000.0f;
|
||||
pc.params[2] = p->mode == HDRC_OUT_SDR ? 1.0f : 0.0f;
|
||||
pc.params[3] = (float)count + 16.0f * (float)mask;
|
||||
for (int i = 0; i < count; i++) memcpy(pc.rects[i], p->rects[i], sizeof(pc.rects[i]));
|
||||
|
||||
VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = g_out[slot].rp,
|
||||
.framebuffer = fb, .renderArea = {{0, 0}, {(uint32_t)w, (uint32_t)h}}};
|
||||
VkViewport vp = {0, 0, (float)w, (float)h, 0, 1};
|
||||
VkRect2D sc = {{0, 0}, {(uint32_t)w, (uint32_t)h}};
|
||||
g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE);
|
||||
g_vk.CmdSetViewport(cmd, 0, 1, &vp);
|
||||
g_vk.CmdSetScissor(cmd, 0, 1, &sc);
|
||||
g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_out[slot].pipe);
|
||||
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, 1, &g_src.ds, 0, NULL);
|
||||
g_vk.CmdPushConstants(cmd, g_pl, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pc), &pc);
|
||||
g_vk.CmdDraw(cmd, 4, 1, 0, 0);
|
||||
g_vk.CmdEndRenderPass(cmd);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#ifndef HDR_COMPOSE_H
|
||||
#define HDR_COMPOSE_H
|
||||
/*
|
||||
* HDR composition (round 2 of HDR_RECON.md's Phase B): when an HDR game cannot be alone on its own
|
||||
* display layer - screen effects on, frame generation on, a window above it on a display that cannot
|
||||
* compose a second layer, a windowed game, a frame without a gralloc buffer - the whole scene is put
|
||||
* into ONE encoding instead of being blitted into an 8-bit sRGB target as it stands (which shows the
|
||||
* game's PQ frames washed out).
|
||||
*
|
||||
* vk_present.c blits every draw 1:1 into a 10-bit "mixed" image (each pixel still in its own
|
||||
* encoding) and hdrc_encode() runs hdr_encode.frag over it into the output image:
|
||||
* HDRC_OUT_PQ - PQ BT.2020 (SDR pixels placed at the SDR reference white): goes onto the game's
|
||||
* display layer tagged BT2020_PQ (sc_layer.c), or into an HDR10 swapchain;
|
||||
* HDRC_OUT_SDR - sRGB BT.709 with the HDR pixels tone-mapped: for a present that cannot carry HDR.
|
||||
* Which encoding a pixel is in comes from the draws' rectangles (the topmost draw decides).
|
||||
*
|
||||
* Compositor thread. Objects are built lazily on the first use; if the driver refuses them, the
|
||||
* encode is unavailable for the session (logged once) and the caller falls back.
|
||||
*/
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#define HDRC_MAX_RECTS 6
|
||||
|
||||
enum hdrc_mode { HDRC_OUT_PQ = 0, HDRC_OUT_SDR = 1 };
|
||||
|
||||
struct hdrc_params {
|
||||
enum hdrc_mode mode;
|
||||
float sdr_white_nits; /* SDR reference white inside the HDR picture (203) */
|
||||
float peak_nits; /* HDR content peak for the tone-map (max CLL / mastering max, else 1000) */
|
||||
int count; /* rects, top draw first */
|
||||
unsigned hdr_mask; /* bit i: rects[i] is an HDR draw */
|
||||
float rects[HDRC_MAX_RECTS][4]; /* scene pixels x0, y0, x1, y1 */
|
||||
};
|
||||
|
||||
/* Called from dev_init (device up). */
|
||||
void hdrc_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops);
|
||||
/* Device teardown. */
|
||||
void hdrc_destroy(void);
|
||||
/* vk_present is about to destroy `img` (a resize of the mixed / scene / picture image): drop the view,
|
||||
* descriptor and framebuffer cached for it, so a later image that happens to reuse the handle value is
|
||||
* never drawn through a view of the destroyed one. */
|
||||
void hdrc_forget_image(VkImage img);
|
||||
|
||||
/* Record the encode: `mixed` (w x h, VK_FORMAT_A2B10G10R10_UNORM_PACK32, in TRANSFER_DST_OPTIMAL after
|
||||
* the composite blits) -> `out` (w x h, out_fmt, created with COLOR_ATTACHMENT + SAMPLED usage), which
|
||||
* is left in TRANSFER_DST_OPTIMAL - the layout vkp_effects_run() takes its scene in. 0 = recorded,
|
||||
* -1 = unavailable (nothing recorded; `mixed` untouched). */
|
||||
int hdrc_encode(VkCommandBuffer cmd, VkImage mixed, VkImage out, VkFormat out_fmt, int w, int h,
|
||||
const struct hdrc_params *p);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,129 @@
|
||||
#version 450
|
||||
|
||||
// =============================================================================
|
||||
// HDR composition: one encoding for the whole scene (waylandcomp/src/hdr_compose.c).
|
||||
//
|
||||
// The compositor composes with blits, which copy values and know nothing about what they mean.
|
||||
// When an HDR game (PQ-encoded BT.2020 frames) shares the scene with SDR content (sRGB windows, the
|
||||
// desktop, a window above the game), every draw is first blitted 1:1 into a 10-bit "mixed" image -
|
||||
// each pixel still in its own encoding - and this pass turns the mixed image into ONE encoding:
|
||||
//
|
||||
// mode 0 (HDR out, PQ BT.2020): HDR pixels pass through; SDR pixels are decoded (sRGB),
|
||||
// converted BT.709 -> BT.2020 and placed at the SDR reference white (params.x nits,
|
||||
// 203 = Report ITU-R BT.2408), then PQ-encoded.
|
||||
// mode 1 (SDR out, sRGB): SDR pixels pass through; HDR pixels are PQ-decoded, converted
|
||||
// BT.2020 -> BT.709, tone-mapped relative to the SDR reference white (linear below a
|
||||
// knee, a smooth roll-off above it that puts the content's peak, params.y nits, at 98 %)
|
||||
// and sRGB-encoded - what a display that cannot take HDR gets instead of washed-out PQ.
|
||||
//
|
||||
// Which encoding a pixel is in: the topmost draw covering it decides. params.w packs the number of
|
||||
// rects (count, 0..6) and a bitmask of which of them are HDR (count + 16 * mask); rects are scene
|
||||
// pixels (x0, y0, x1, y1), TOP draw first, listed down to the lowest HDR draw (everything below
|
||||
// that is SDR, and so is any pixel no listed rect covers).
|
||||
//
|
||||
// Conventions match upscale.vert / the effect passes: combined-image-sampler at binding 0, the
|
||||
// push-constant block leads with vec4 ndc (offset 0). The target is exactly scene-sized, so
|
||||
// gl_FragCoord is the scene pixel and texelFetch reads the mixed image 1:1 (no filtering).
|
||||
// Float-only mask arithmetic (no bitwise ops).
|
||||
// =============================================================================
|
||||
|
||||
layout(binding = 0) uniform sampler2D Mixed;
|
||||
|
||||
layout(push_constant) uniform PC {
|
||||
vec4 ndc; // upscale.vert's quad
|
||||
vec4 params; // x = SDR white nits, y = HDR content peak nits (mode 1), z = mode, w = count + 16 * mask
|
||||
vec4 rects[6]; // top-first scene rects
|
||||
} pc;
|
||||
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
const float PQ_M1 = 0.1593017578125;
|
||||
const float PQ_M2 = 78.84375;
|
||||
const float PQ_C1 = 0.8359375;
|
||||
const float PQ_C2 = 18.8515625;
|
||||
const float PQ_C3 = 18.6875;
|
||||
|
||||
// Column-major: each group of three is one COLUMN (the coefficients of R, then of G, then of B).
|
||||
const mat3 BT709_TO_BT2020 = mat3(0.6274, 0.0691, 0.0164,
|
||||
0.3293, 0.9195, 0.0880,
|
||||
0.0433, 0.0114, 0.8956);
|
||||
const mat3 BT2020_TO_BT709 = mat3( 1.6605, -0.1246, -0.0182,
|
||||
-0.5876, 1.1329, -0.1006,
|
||||
-0.0728, -0.0083, 1.1187);
|
||||
|
||||
vec3 srgbToLinear(vec3 c) {
|
||||
vec3 lo = c / 12.92;
|
||||
vec3 hi = pow((c + 0.055) / 1.055, vec3(2.4));
|
||||
return mix(lo, hi, step(vec3(0.04045), c));
|
||||
}
|
||||
|
||||
vec3 linearToSrgb(vec3 c) {
|
||||
vec3 lo = c * 12.92;
|
||||
vec3 hi = 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055;
|
||||
return mix(lo, hi, step(vec3(0.0031308), c));
|
||||
}
|
||||
|
||||
// PQ code (0..1) -> luminance / 10000 cd/m2 (SMPTE ST 2084 EOTF).
|
||||
vec3 pqToLinear(vec3 e) {
|
||||
vec3 p = pow(clamp(e, 0.0, 1.0), vec3(1.0 / PQ_M2));
|
||||
return pow(max(p - PQ_C1, 0.0) / max(PQ_C2 - PQ_C3 * p, 1e-6), vec3(1.0 / PQ_M1));
|
||||
}
|
||||
|
||||
// luminance / 10000 cd/m2 -> PQ code (inverse EOTF).
|
||||
vec3 linearToPq(vec3 y) {
|
||||
vec3 p = pow(clamp(y, 0.0, 1.0), vec3(PQ_M1));
|
||||
return pow((PQ_C1 + PQ_C2 * p) / (1.0 + PQ_C3 * p), vec3(PQ_M2));
|
||||
}
|
||||
|
||||
// Tone curve in units of SDR white: identity up to the knee, then an exponential roll-off towards 1
|
||||
// whose rate puts `peak` (also in SDR-white units) at 98 % of the range.
|
||||
float toneCurve(float x, float peak) {
|
||||
const float knee = 0.8;
|
||||
if (x <= knee) return x;
|
||||
float span = max(peak - knee, 0.05);
|
||||
float rate = max(span / 3.912, 1.0 - knee); // ln(50) = 3.912; never steeper than the identity
|
||||
return knee + (1.0 - knee) * (1.0 - exp(-(x - knee) / rate));
|
||||
}
|
||||
|
||||
bool isHdrPixel(vec2 p) {
|
||||
float packed = pc.params.w;
|
||||
float count = mod(packed, 16.0);
|
||||
float mask = floor(packed / 16.0);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (float(i) >= count - 0.5) break;
|
||||
vec4 r = pc.rects[i];
|
||||
if (p.x >= r.x && p.y >= r.y && p.x < r.z && p.y < r.w) {
|
||||
float bit = mod(floor(mask / exp2(float(i))), 2.0);
|
||||
return bit > 0.5;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 c = texelFetch(Mixed, ivec2(gl_FragCoord.xy), 0).rgb;
|
||||
bool hdr = isHdrPixel(gl_FragCoord.xy);
|
||||
float sdrWhite = max(pc.params.x, 1.0);
|
||||
vec3 outc;
|
||||
if (pc.params.z < 0.5) {
|
||||
// HDR out: PQ BT.2020.
|
||||
if (hdr) {
|
||||
outc = c;
|
||||
} else {
|
||||
vec3 nits = (BT709_TO_BT2020 * srgbToLinear(c)) * sdrWhite;
|
||||
outc = linearToPq(nits / 10000.0);
|
||||
}
|
||||
} else {
|
||||
// SDR out: sRGB BT.709, HDR tone-mapped.
|
||||
if (!hdr) {
|
||||
outc = c;
|
||||
} else {
|
||||
vec3 rel = max(BT2020_TO_BT709 * (pqToLinear(c) * 10000.0), 0.0) / sdrWhite;
|
||||
float m = max(max(rel.r, rel.g), rel.b);
|
||||
if (m > 1e-6) rel *= toneCurve(m, max(pc.params.y, sdrWhite) / sdrWhite) / m;
|
||||
outc = linearToSrgb(clamp(rel, 0.0, 1.0));
|
||||
}
|
||||
}
|
||||
outColor = vec4(outc, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
// 1116.5.0
|
||||
#pragma once
|
||||
const uint32_t hdr_encode_code[] = {
|
||||
0x07230203,0x00010000,0x0008000b,0x0000018e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||
0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000010d,0x00000186,0x0000018d,
|
||||
0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,
|
||||
0x6e69616d,0x00000000,0x00070005,0x0000000b,0x62677273,0x694c6f54,0x7261656e,0x33667628,
|
||||
0x0000003b,0x00030005,0x0000000a,0x00000063,0x00070005,0x0000000e,0x656e696c,0x6f547261,
|
||||
0x62677253,0x33667628,0x0000003b,0x00030005,0x0000000d,0x00000063,0x00060005,0x00000011,
|
||||
0x6f547170,0x656e694c,0x76287261,0x003b3366,0x00030005,0x00000010,0x00000065,0x00060005,
|
||||
0x00000014,0x656e696c,0x6f547261,0x76287150,0x003b3366,0x00030005,0x00000013,0x00000079,
|
||||
0x00070005,0x0000001a,0x656e6f74,0x76727543,0x31662865,0x3b31663b,0x00000000,0x00030005,
|
||||
0x00000018,0x00000078,0x00040005,0x00000019,0x6b616570,0x00000000,0x00060005,0x00000021,
|
||||
0x64487369,0x78695072,0x76286c65,0x003b3266,0x00030005,0x00000020,0x00000070,0x00030005,
|
||||
0x00000023,0x00006f6c,0x00030005,0x00000028,0x00006968,0x00030005,0x0000003c,0x00006f6c,
|
||||
0x00030005,0x0000003f,0x00006968,0x00030005,0x00000050,0x00000070,0x00030005,0x0000006f,
|
||||
0x00000070,0x00040005,0x0000008c,0x6e617073,0x00000000,0x00040005,0x00000091,0x65746172,
|
||||
0x00000000,0x00040005,0x000000a2,0x6b636170,0x00006465,0x00030005,0x000000a7,0x00004350,
|
||||
0x00040006,0x000000a7,0x00000000,0x0063646e,0x00050006,0x000000a7,0x00000001,0x61726170,
|
||||
0x0000736d,0x00050006,0x000000a7,0x00000002,0x74636572,0x00000073,0x00030005,0x000000a9,
|
||||
0x00006370,0x00040005,0x000000b0,0x6e756f63,0x00000074,0x00040005,0x000000b4,0x6b73616d,
|
||||
0x00000000,0x00030005,0x000000b9,0x00000069,0x00030005,0x000000cd,0x00000072,0x00030005,
|
||||
0x000000f5,0x00746962,0x00030005,0x00000106,0x00000063,0x00040005,0x0000010a,0x6578694d,
|
||||
0x00000064,0x00060005,0x0000010d,0x465f6c67,0x43676172,0x64726f6f,0x00000000,0x00030005,
|
||||
0x00000116,0x00726468,0x00040005,0x00000117,0x61726170,0x0000006d,0x00050005,0x0000011b,
|
||||
0x57726473,0x65746968,0x00000000,0x00040005,0x00000127,0x6374756f,0x00000000,0x00040005,
|
||||
0x0000012a,0x7374696e,0x00000000,0x00040005,0x00000139,0x61726170,0x0000006d,0x00040005,
|
||||
0x00000143,0x61726170,0x0000006d,0x00030005,0x0000014c,0x006c6572,0x00040005,0x0000015a,
|
||||
0x61726170,0x0000006d,0x00030005,0x00000164,0x0000006d,0x00040005,0x00000177,0x61726170,
|
||||
0x0000006d,0x00040005,0x00000179,0x61726170,0x0000006d,0x00040005,0x00000183,0x61726170,
|
||||
0x0000006d,0x00050005,0x00000186,0x4374756f,0x726f6c6f,0x00000000,0x00060005,0x0000018d,
|
||||
0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040047,0x000000a6,0x00000006,0x00000010,
|
||||
0x00030047,0x000000a7,0x00000002,0x00050048,0x000000a7,0x00000000,0x00000023,0x00000000,
|
||||
0x00050048,0x000000a7,0x00000001,0x00000023,0x00000010,0x00050048,0x000000a7,0x00000002,
|
||||
0x00000023,0x00000020,0x00040047,0x0000010a,0x00000021,0x00000000,0x00040047,0x0000010a,
|
||||
0x00000022,0x00000000,0x00040047,0x0000010d,0x0000000b,0x0000000f,0x00040047,0x00000186,
|
||||
0x0000001e,0x00000000,0x00040047,0x0000018d,0x0000001e,0x00000000,0x00020013,0x00000002,
|
||||
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
|
||||
0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007,0x00040021,0x00000009,
|
||||
0x00000007,0x00000008,0x00040020,0x00000016,0x00000007,0x00000006,0x00050021,0x00000017,
|
||||
0x00000006,0x00000016,0x00000016,0x00040017,0x0000001c,0x00000006,0x00000002,0x00040020,
|
||||
0x0000001d,0x00000007,0x0000001c,0x00020014,0x0000001e,0x00040021,0x0000001f,0x0000001e,
|
||||
0x0000001d,0x0004002b,0x00000006,0x00000025,0x414eb852,0x0004002b,0x00000006,0x0000002a,
|
||||
0x3d6147ae,0x0004002b,0x00000006,0x0000002d,0x3f870a3d,0x0004002b,0x00000006,0x00000030,
|
||||
0x4019999a,0x0006002c,0x00000007,0x00000031,0x00000030,0x00000030,0x00000030,0x0004002b,
|
||||
0x00000006,0x00000035,0x3d25aee6,0x0006002c,0x00000007,0x00000036,0x00000035,0x00000035,
|
||||
0x00000035,0x0004002b,0x00000006,0x00000041,0x3ed55555,0x0006002c,0x00000007,0x00000042,
|
||||
0x00000041,0x00000041,0x00000041,0x0004002b,0x00000006,0x00000049,0x3b4d2e1c,0x0006002c,
|
||||
0x00000007,0x0000004a,0x00000049,0x00000049,0x00000049,0x0004002b,0x00000006,0x00000052,
|
||||
0x00000000,0x0004002b,0x00000006,0x00000053,0x3f800000,0x0004002b,0x00000006,0x00000057,
|
||||
0x3c4fcdac,0x0006002c,0x00000007,0x00000058,0x00000057,0x00000057,0x00000057,0x0004002b,
|
||||
0x00000006,0x0000005b,0x3f560000,0x0004002b,0x00000006,0x00000060,0x4196d000,0x0004002b,
|
||||
0x00000006,0x00000061,0x41958000,0x0004002b,0x00000006,0x00000066,0x358637bd,0x0004002b,
|
||||
0x00000006,0x0000006a,0x40c8e06b,0x0006002c,0x00000007,0x0000006b,0x0000006a,0x0000006a,
|
||||
0x0000006a,0x0004002b,0x00000006,0x00000074,0x3e232000,0x0006002c,0x00000007,0x00000075,
|
||||
0x00000074,0x00000074,0x00000074,0x0004002b,0x00000006,0x00000080,0x429db000,0x0006002c,
|
||||
0x00000007,0x00000081,0x00000080,0x00000080,0x00000080,0x0004002b,0x00000006,0x00000086,
|
||||
0x3f4ccccd,0x0004002b,0x00000006,0x0000008f,0x3d4ccccd,0x0004002b,0x00000006,0x00000093,
|
||||
0x407a5e35,0x0004002b,0x00000006,0x00000095,0x3e4ccccd,0x00040017,0x000000a3,0x00000006,
|
||||
0x00000004,0x00040015,0x000000a4,0x00000020,0x00000000,0x0004002b,0x000000a4,0x000000a5,
|
||||
0x00000006,0x0004001c,0x000000a6,0x000000a3,0x000000a5,0x0005001e,0x000000a7,0x000000a3,
|
||||
0x000000a3,0x000000a6,0x00040020,0x000000a8,0x00000009,0x000000a7,0x0004003b,0x000000a8,
|
||||
0x000000a9,0x00000009,0x00040015,0x000000aa,0x00000020,0x00000001,0x0004002b,0x000000aa,
|
||||
0x000000ab,0x00000001,0x0004002b,0x000000a4,0x000000ac,0x00000003,0x00040020,0x000000ad,
|
||||
0x00000009,0x00000006,0x0004002b,0x00000006,0x000000b2,0x41800000,0x00040020,0x000000b8,
|
||||
0x00000007,0x000000aa,0x0004002b,0x000000aa,0x000000ba,0x00000000,0x0004002b,0x000000aa,
|
||||
0x000000c1,0x00000006,0x0004002b,0x00000006,0x000000c6,0x3f000000,0x00040020,0x000000cc,
|
||||
0x00000007,0x000000a3,0x0004002b,0x000000aa,0x000000ce,0x00000002,0x00040020,0x000000d0,
|
||||
0x00000009,0x000000a3,0x0004002b,0x000000a4,0x000000d3,0x00000000,0x0004002b,0x000000a4,
|
||||
0x000000db,0x00000001,0x0004002b,0x000000a4,0x000000e6,0x00000002,0x0004002b,0x00000006,
|
||||
0x000000fc,0x40000000,0x0003002a,0x0000001e,0x00000103,0x00090019,0x00000107,0x00000006,
|
||||
0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000108,
|
||||
0x00000107,0x00040020,0x00000109,0x00000000,0x00000108,0x0004003b,0x00000109,0x0000010a,
|
||||
0x00000000,0x00040020,0x0000010c,0x00000001,0x000000a3,0x0004003b,0x0000010c,0x0000010d,
|
||||
0x00000001,0x00040017,0x00000110,0x000000aa,0x00000002,0x00040020,0x00000115,0x00000007,
|
||||
0x0000001e,0x00040018,0x0000012b,0x00000007,0x00000003,0x0004002b,0x00000006,0x0000012c,
|
||||
0x3f209d49,0x0004002b,0x00000006,0x0000012d,0x3d8d844d,0x0004002b,0x00000006,0x0000012e,
|
||||
0x3c86594b,0x0006002c,0x00000007,0x0000012f,0x0000012c,0x0000012d,0x0000012e,0x0004002b,
|
||||
0x00000006,0x00000130,0x3ea89a02,0x0004002b,0x00000006,0x00000131,0x3f6b645a,0x0004002b,
|
||||
0x00000006,0x00000132,0x3db43958,0x0006002c,0x00000007,0x00000133,0x00000130,0x00000131,
|
||||
0x00000132,0x0004002b,0x00000006,0x00000134,0x3d315b57,0x0004002b,0x00000006,0x00000135,
|
||||
0x3c3ac711,0x0004002b,0x00000006,0x00000136,0x3f65460b,0x0006002c,0x00000007,0x00000137,
|
||||
0x00000134,0x00000135,0x00000136,0x0006002c,0x0000012b,0x00000138,0x0000012f,0x00000133,
|
||||
0x00000137,0x0004002b,0x00000006,0x00000140,0x461c4000,0x0004002b,0x00000006,0x0000014d,
|
||||
0x3fd48b44,0x0004002b,0x00000006,0x0000014e,0xbdff2e49,0x0004002b,0x00000006,0x0000014f,
|
||||
0xbc95182b,0x0006002c,0x00000007,0x00000150,0x0000014d,0x0000014e,0x0000014f,0x0004002b,
|
||||
0x00000006,0x00000151,0xbf166cf4,0x0004002b,0x00000006,0x00000152,0x3f9102de,0x0004002b,
|
||||
0x00000006,0x00000153,0xbdce075f,0x0006002c,0x00000007,0x00000154,0x00000151,0x00000152,
|
||||
0x00000153,0x0004002b,0x00000006,0x00000155,0xbd95182b,0x0004002b,0x00000006,0x00000156,
|
||||
0xbc07fcb9,0x0004002b,0x00000006,0x00000157,0x3f8f3190,0x0006002c,0x00000007,0x00000158,
|
||||
0x00000155,0x00000156,0x00000157,0x0006002c,0x0000012b,0x00000159,0x00000150,0x00000154,
|
||||
0x00000158,0x00040020,0x00000185,0x00000003,0x000000a3,0x0004003b,0x00000185,0x00000186,
|
||||
0x00000003,0x00040020,0x0000018c,0x00000001,0x0000001c,0x0004003b,0x0000018c,0x0000018d,
|
||||
0x00000001,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
|
||||
0x0004003b,0x00000008,0x00000106,0x00000007,0x0004003b,0x00000115,0x00000116,0x00000007,
|
||||
0x0004003b,0x0000001d,0x00000117,0x00000007,0x0004003b,0x00000016,0x0000011b,0x00000007,
|
||||
0x0004003b,0x00000008,0x00000127,0x00000007,0x0004003b,0x00000008,0x0000012a,0x00000007,
|
||||
0x0004003b,0x00000008,0x00000139,0x00000007,0x0004003b,0x00000008,0x00000143,0x00000007,
|
||||
0x0004003b,0x00000008,0x0000014c,0x00000007,0x0004003b,0x00000008,0x0000015a,0x00000007,
|
||||
0x0004003b,0x00000016,0x00000164,0x00000007,0x0004003b,0x00000016,0x00000177,0x00000007,
|
||||
0x0004003b,0x00000016,0x00000179,0x00000007,0x0004003b,0x00000008,0x00000183,0x00000007,
|
||||
0x0004003d,0x00000108,0x0000010b,0x0000010a,0x0004003d,0x000000a3,0x0000010e,0x0000010d,
|
||||
0x0007004f,0x0000001c,0x0000010f,0x0000010e,0x0000010e,0x00000000,0x00000001,0x0004006e,
|
||||
0x00000110,0x00000111,0x0000010f,0x00040064,0x00000107,0x00000112,0x0000010b,0x0007005f,
|
||||
0x000000a3,0x00000113,0x00000112,0x00000111,0x00000002,0x000000ba,0x0008004f,0x00000007,
|
||||
0x00000114,0x00000113,0x00000113,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000106,
|
||||
0x00000114,0x0004003d,0x000000a3,0x00000118,0x0000010d,0x0007004f,0x0000001c,0x00000119,
|
||||
0x00000118,0x00000118,0x00000000,0x00000001,0x0003003e,0x00000117,0x00000119,0x00050039,
|
||||
0x0000001e,0x0000011a,0x00000021,0x00000117,0x0003003e,0x00000116,0x0000011a,0x00060041,
|
||||
0x000000ad,0x0000011c,0x000000a9,0x000000ab,0x000000d3,0x0004003d,0x00000006,0x0000011d,
|
||||
0x0000011c,0x0007000c,0x00000006,0x0000011e,0x00000001,0x00000028,0x0000011d,0x00000053,
|
||||
0x0003003e,0x0000011b,0x0000011e,0x00060041,0x000000ad,0x0000011f,0x000000a9,0x000000ab,
|
||||
0x000000e6,0x0004003d,0x00000006,0x00000120,0x0000011f,0x000500b8,0x0000001e,0x00000121,
|
||||
0x00000120,0x000000c6,0x000300f7,0x00000123,0x00000000,0x000400fa,0x00000121,0x00000122,
|
||||
0x00000145,0x000200f8,0x00000122,0x0004003d,0x0000001e,0x00000124,0x00000116,0x000300f7,
|
||||
0x00000126,0x00000000,0x000400fa,0x00000124,0x00000125,0x00000129,0x000200f8,0x00000125,
|
||||
0x0004003d,0x00000007,0x00000128,0x00000106,0x0003003e,0x00000127,0x00000128,0x000200f9,
|
||||
0x00000126,0x000200f8,0x00000129,0x0004003d,0x00000007,0x0000013a,0x00000106,0x0003003e,
|
||||
0x00000139,0x0000013a,0x00050039,0x00000007,0x0000013b,0x0000000b,0x00000139,0x00050091,
|
||||
0x00000007,0x0000013c,0x00000138,0x0000013b,0x0004003d,0x00000006,0x0000013d,0x0000011b,
|
||||
0x0005008e,0x00000007,0x0000013e,0x0000013c,0x0000013d,0x0003003e,0x0000012a,0x0000013e,
|
||||
0x0004003d,0x00000007,0x0000013f,0x0000012a,0x00060050,0x00000007,0x00000141,0x00000140,
|
||||
0x00000140,0x00000140,0x00050088,0x00000007,0x00000142,0x0000013f,0x00000141,0x0003003e,
|
||||
0x00000143,0x00000142,0x00050039,0x00000007,0x00000144,0x00000014,0x00000143,0x0003003e,
|
||||
0x00000127,0x00000144,0x000200f9,0x00000126,0x000200f8,0x00000126,0x000200f9,0x00000123,
|
||||
0x000200f8,0x00000145,0x0004003d,0x0000001e,0x00000146,0x00000116,0x000400a8,0x0000001e,
|
||||
0x00000147,0x00000146,0x000300f7,0x00000149,0x00000000,0x000400fa,0x00000147,0x00000148,
|
||||
0x0000014b,0x000200f8,0x00000148,0x0004003d,0x00000007,0x0000014a,0x00000106,0x0003003e,
|
||||
0x00000127,0x0000014a,0x000200f9,0x00000149,0x000200f8,0x0000014b,0x0004003d,0x00000007,
|
||||
0x0000015b,0x00000106,0x0003003e,0x0000015a,0x0000015b,0x00050039,0x00000007,0x0000015c,
|
||||
0x00000011,0x0000015a,0x0005008e,0x00000007,0x0000015d,0x0000015c,0x00000140,0x00050091,
|
||||
0x00000007,0x0000015e,0x00000159,0x0000015d,0x00060050,0x00000007,0x0000015f,0x00000052,
|
||||
0x00000052,0x00000052,0x0007000c,0x00000007,0x00000160,0x00000001,0x00000028,0x0000015e,
|
||||
0x0000015f,0x0004003d,0x00000006,0x00000161,0x0000011b,0x00060050,0x00000007,0x00000162,
|
||||
0x00000161,0x00000161,0x00000161,0x00050088,0x00000007,0x00000163,0x00000160,0x00000162,
|
||||
0x0003003e,0x0000014c,0x00000163,0x00050041,0x00000016,0x00000165,0x0000014c,0x000000d3,
|
||||
0x0004003d,0x00000006,0x00000166,0x00000165,0x00050041,0x00000016,0x00000167,0x0000014c,
|
||||
0x000000db,0x0004003d,0x00000006,0x00000168,0x00000167,0x0007000c,0x00000006,0x00000169,
|
||||
0x00000001,0x00000028,0x00000166,0x00000168,0x00050041,0x00000016,0x0000016a,0x0000014c,
|
||||
0x000000e6,0x0004003d,0x00000006,0x0000016b,0x0000016a,0x0007000c,0x00000006,0x0000016c,
|
||||
0x00000001,0x00000028,0x00000169,0x0000016b,0x0003003e,0x00000164,0x0000016c,0x0004003d,
|
||||
0x00000006,0x0000016d,0x00000164,0x000500ba,0x0000001e,0x0000016e,0x0000016d,0x00000066,
|
||||
0x000300f7,0x00000170,0x00000000,0x000400fa,0x0000016e,0x0000016f,0x00000170,0x000200f8,
|
||||
0x0000016f,0x00060041,0x000000ad,0x00000171,0x000000a9,0x000000ab,0x000000db,0x0004003d,
|
||||
0x00000006,0x00000172,0x00000171,0x0004003d,0x00000006,0x00000173,0x0000011b,0x0007000c,
|
||||
0x00000006,0x00000174,0x00000001,0x00000028,0x00000172,0x00000173,0x0004003d,0x00000006,
|
||||
0x00000175,0x0000011b,0x00050088,0x00000006,0x00000176,0x00000174,0x00000175,0x0004003d,
|
||||
0x00000006,0x00000178,0x00000164,0x0003003e,0x00000177,0x00000178,0x0003003e,0x00000179,
|
||||
0x00000176,0x00060039,0x00000006,0x0000017a,0x0000001a,0x00000177,0x00000179,0x0004003d,
|
||||
0x00000006,0x0000017b,0x00000164,0x00050088,0x00000006,0x0000017c,0x0000017a,0x0000017b,
|
||||
0x0004003d,0x00000007,0x0000017d,0x0000014c,0x0005008e,0x00000007,0x0000017e,0x0000017d,
|
||||
0x0000017c,0x0003003e,0x0000014c,0x0000017e,0x000200f9,0x00000170,0x000200f8,0x00000170,
|
||||
0x0004003d,0x00000007,0x0000017f,0x0000014c,0x00060050,0x00000007,0x00000180,0x00000052,
|
||||
0x00000052,0x00000052,0x00060050,0x00000007,0x00000181,0x00000053,0x00000053,0x00000053,
|
||||
0x0008000c,0x00000007,0x00000182,0x00000001,0x0000002b,0x0000017f,0x00000180,0x00000181,
|
||||
0x0003003e,0x00000183,0x00000182,0x00050039,0x00000007,0x00000184,0x0000000e,0x00000183,
|
||||
0x0003003e,0x00000127,0x00000184,0x000200f9,0x00000149,0x000200f8,0x00000149,0x000200f9,
|
||||
0x00000123,0x000200f8,0x00000123,0x0004003d,0x00000007,0x00000187,0x00000127,0x00050051,
|
||||
0x00000006,0x00000188,0x00000187,0x00000000,0x00050051,0x00000006,0x00000189,0x00000187,
|
||||
0x00000001,0x00050051,0x00000006,0x0000018a,0x00000187,0x00000002,0x00070050,0x000000a3,
|
||||
0x0000018b,0x00000188,0x00000189,0x0000018a,0x00000053,0x0003003e,0x00000186,0x0000018b,
|
||||
0x000100fd,0x00010038,0x00050036,0x00000007,0x0000000b,0x00000000,0x00000009,0x00030037,
|
||||
0x00000008,0x0000000a,0x000200f8,0x0000000c,0x0004003b,0x00000008,0x00000023,0x00000007,
|
||||
0x0004003b,0x00000008,0x00000028,0x00000007,0x0004003d,0x00000007,0x00000024,0x0000000a,
|
||||
0x00060050,0x00000007,0x00000026,0x00000025,0x00000025,0x00000025,0x00050088,0x00000007,
|
||||
0x00000027,0x00000024,0x00000026,0x0003003e,0x00000023,0x00000027,0x0004003d,0x00000007,
|
||||
0x00000029,0x0000000a,0x00060050,0x00000007,0x0000002b,0x0000002a,0x0000002a,0x0000002a,
|
||||
0x00050081,0x00000007,0x0000002c,0x00000029,0x0000002b,0x00060050,0x00000007,0x0000002e,
|
||||
0x0000002d,0x0000002d,0x0000002d,0x00050088,0x00000007,0x0000002f,0x0000002c,0x0000002e,
|
||||
0x0007000c,0x00000007,0x00000032,0x00000001,0x0000001a,0x0000002f,0x00000031,0x0003003e,
|
||||
0x00000028,0x00000032,0x0004003d,0x00000007,0x00000033,0x00000023,0x0004003d,0x00000007,
|
||||
0x00000034,0x00000028,0x0004003d,0x00000007,0x00000037,0x0000000a,0x0007000c,0x00000007,
|
||||
0x00000038,0x00000001,0x00000030,0x00000036,0x00000037,0x0008000c,0x00000007,0x00000039,
|
||||
0x00000001,0x0000002e,0x00000033,0x00000034,0x00000038,0x000200fe,0x00000039,0x00010038,
|
||||
0x00050036,0x00000007,0x0000000e,0x00000000,0x00000009,0x00030037,0x00000008,0x0000000d,
|
||||
0x000200f8,0x0000000f,0x0004003b,0x00000008,0x0000003c,0x00000007,0x0004003b,0x00000008,
|
||||
0x0000003f,0x00000007,0x0004003d,0x00000007,0x0000003d,0x0000000d,0x0005008e,0x00000007,
|
||||
0x0000003e,0x0000003d,0x00000025,0x0003003e,0x0000003c,0x0000003e,0x0004003d,0x00000007,
|
||||
0x00000040,0x0000000d,0x0007000c,0x00000007,0x00000043,0x00000001,0x0000001a,0x00000040,
|
||||
0x00000042,0x0005008e,0x00000007,0x00000044,0x00000043,0x0000002d,0x00060050,0x00000007,
|
||||
0x00000045,0x0000002a,0x0000002a,0x0000002a,0x00050083,0x00000007,0x00000046,0x00000044,
|
||||
0x00000045,0x0003003e,0x0000003f,0x00000046,0x0004003d,0x00000007,0x00000047,0x0000003c,
|
||||
0x0004003d,0x00000007,0x00000048,0x0000003f,0x0004003d,0x00000007,0x0000004b,0x0000000d,
|
||||
0x0007000c,0x00000007,0x0000004c,0x00000001,0x00000030,0x0000004a,0x0000004b,0x0008000c,
|
||||
0x00000007,0x0000004d,0x00000001,0x0000002e,0x00000047,0x00000048,0x0000004c,0x000200fe,
|
||||
0x0000004d,0x00010038,0x00050036,0x00000007,0x00000011,0x00000000,0x00000009,0x00030037,
|
||||
0x00000008,0x00000010,0x000200f8,0x00000012,0x0004003b,0x00000008,0x00000050,0x00000007,
|
||||
0x0004003d,0x00000007,0x00000051,0x00000010,0x00060050,0x00000007,0x00000054,0x00000052,
|
||||
0x00000052,0x00000052,0x00060050,0x00000007,0x00000055,0x00000053,0x00000053,0x00000053,
|
||||
0x0008000c,0x00000007,0x00000056,0x00000001,0x0000002b,0x00000051,0x00000054,0x00000055,
|
||||
0x0007000c,0x00000007,0x00000059,0x00000001,0x0000001a,0x00000056,0x00000058,0x0003003e,
|
||||
0x00000050,0x00000059,0x0004003d,0x00000007,0x0000005a,0x00000050,0x00060050,0x00000007,
|
||||
0x0000005c,0x0000005b,0x0000005b,0x0000005b,0x00050083,0x00000007,0x0000005d,0x0000005a,
|
||||
0x0000005c,0x00060050,0x00000007,0x0000005e,0x00000052,0x00000052,0x00000052,0x0007000c,
|
||||
0x00000007,0x0000005f,0x00000001,0x00000028,0x0000005d,0x0000005e,0x0004003d,0x00000007,
|
||||
0x00000062,0x00000050,0x0005008e,0x00000007,0x00000063,0x00000062,0x00000061,0x00060050,
|
||||
0x00000007,0x00000064,0x00000060,0x00000060,0x00000060,0x00050083,0x00000007,0x00000065,
|
||||
0x00000064,0x00000063,0x00060050,0x00000007,0x00000067,0x00000066,0x00000066,0x00000066,
|
||||
0x0007000c,0x00000007,0x00000068,0x00000001,0x00000028,0x00000065,0x00000067,0x00050088,
|
||||
0x00000007,0x00000069,0x0000005f,0x00000068,0x0007000c,0x00000007,0x0000006c,0x00000001,
|
||||
0x0000001a,0x00000069,0x0000006b,0x000200fe,0x0000006c,0x00010038,0x00050036,0x00000007,
|
||||
0x00000014,0x00000000,0x00000009,0x00030037,0x00000008,0x00000013,0x000200f8,0x00000015,
|
||||
0x0004003b,0x00000008,0x0000006f,0x00000007,0x0004003d,0x00000007,0x00000070,0x00000013,
|
||||
0x00060050,0x00000007,0x00000071,0x00000052,0x00000052,0x00000052,0x00060050,0x00000007,
|
||||
0x00000072,0x00000053,0x00000053,0x00000053,0x0008000c,0x00000007,0x00000073,0x00000001,
|
||||
0x0000002b,0x00000070,0x00000071,0x00000072,0x0007000c,0x00000007,0x00000076,0x00000001,
|
||||
0x0000001a,0x00000073,0x00000075,0x0003003e,0x0000006f,0x00000076,0x0004003d,0x00000007,
|
||||
0x00000077,0x0000006f,0x0005008e,0x00000007,0x00000078,0x00000077,0x00000060,0x00060050,
|
||||
0x00000007,0x00000079,0x0000005b,0x0000005b,0x0000005b,0x00050081,0x00000007,0x0000007a,
|
||||
0x00000079,0x00000078,0x0004003d,0x00000007,0x0000007b,0x0000006f,0x0005008e,0x00000007,
|
||||
0x0000007c,0x0000007b,0x00000061,0x00060050,0x00000007,0x0000007d,0x00000053,0x00000053,
|
||||
0x00000053,0x00050081,0x00000007,0x0000007e,0x0000007d,0x0000007c,0x00050088,0x00000007,
|
||||
0x0000007f,0x0000007a,0x0000007e,0x0007000c,0x00000007,0x00000082,0x00000001,0x0000001a,
|
||||
0x0000007f,0x00000081,0x000200fe,0x00000082,0x00010038,0x00050036,0x00000006,0x0000001a,
|
||||
0x00000000,0x00000017,0x00030037,0x00000016,0x00000018,0x00030037,0x00000016,0x00000019,
|
||||
0x000200f8,0x0000001b,0x0004003b,0x00000016,0x0000008c,0x00000007,0x0004003b,0x00000016,
|
||||
0x00000091,0x00000007,0x0004003d,0x00000006,0x00000085,0x00000018,0x000500bc,0x0000001e,
|
||||
0x00000087,0x00000085,0x00000086,0x000300f7,0x00000089,0x00000000,0x000400fa,0x00000087,
|
||||
0x00000088,0x00000089,0x000200f8,0x00000088,0x0004003d,0x00000006,0x0000008a,0x00000018,
|
||||
0x000200fe,0x0000008a,0x000200f8,0x00000089,0x0004003d,0x00000006,0x0000008d,0x00000019,
|
||||
0x00050083,0x00000006,0x0000008e,0x0000008d,0x00000086,0x0007000c,0x00000006,0x00000090,
|
||||
0x00000001,0x00000028,0x0000008e,0x0000008f,0x0003003e,0x0000008c,0x00000090,0x0004003d,
|
||||
0x00000006,0x00000092,0x0000008c,0x00050088,0x00000006,0x00000094,0x00000092,0x00000093,
|
||||
0x0007000c,0x00000006,0x00000096,0x00000001,0x00000028,0x00000094,0x00000095,0x0003003e,
|
||||
0x00000091,0x00000096,0x0004003d,0x00000006,0x00000097,0x00000018,0x00050083,0x00000006,
|
||||
0x00000098,0x00000097,0x00000086,0x0004007f,0x00000006,0x00000099,0x00000098,0x0004003d,
|
||||
0x00000006,0x0000009a,0x00000091,0x00050088,0x00000006,0x0000009b,0x00000099,0x0000009a,
|
||||
0x0006000c,0x00000006,0x0000009c,0x00000001,0x0000001b,0x0000009b,0x00050083,0x00000006,
|
||||
0x0000009d,0x00000053,0x0000009c,0x00050085,0x00000006,0x0000009e,0x00000095,0x0000009d,
|
||||
0x00050081,0x00000006,0x0000009f,0x00000086,0x0000009e,0x000200fe,0x0000009f,0x00010038,
|
||||
0x00050036,0x0000001e,0x00000021,0x00000000,0x0000001f,0x00030037,0x0000001d,0x00000020,
|
||||
0x000200f8,0x00000022,0x0004003b,0x00000016,0x000000a2,0x00000007,0x0004003b,0x00000016,
|
||||
0x000000b0,0x00000007,0x0004003b,0x00000016,0x000000b4,0x00000007,0x0004003b,0x000000b8,
|
||||
0x000000b9,0x00000007,0x0004003b,0x000000cc,0x000000cd,0x00000007,0x0004003b,0x00000016,
|
||||
0x000000f5,0x00000007,0x00060041,0x000000ad,0x000000ae,0x000000a9,0x000000ab,0x000000ac,
|
||||
0x0004003d,0x00000006,0x000000af,0x000000ae,0x0003003e,0x000000a2,0x000000af,0x0004003d,
|
||||
0x00000006,0x000000b1,0x000000a2,0x0005008d,0x00000006,0x000000b3,0x000000b1,0x000000b2,
|
||||
0x0003003e,0x000000b0,0x000000b3,0x0004003d,0x00000006,0x000000b5,0x000000a2,0x00050088,
|
||||
0x00000006,0x000000b6,0x000000b5,0x000000b2,0x0006000c,0x00000006,0x000000b7,0x00000001,
|
||||
0x00000008,0x000000b6,0x0003003e,0x000000b4,0x000000b7,0x0003003e,0x000000b9,0x000000ba,
|
||||
0x000200f9,0x000000bb,0x000200f8,0x000000bb,0x000400f6,0x000000bd,0x000000be,0x00000000,
|
||||
0x000200f9,0x000000bf,0x000200f8,0x000000bf,0x0004003d,0x000000aa,0x000000c0,0x000000b9,
|
||||
0x000500b1,0x0000001e,0x000000c2,0x000000c0,0x000000c1,0x000400fa,0x000000c2,0x000000bc,
|
||||
0x000000bd,0x000200f8,0x000000bc,0x0004003d,0x000000aa,0x000000c3,0x000000b9,0x0004006f,
|
||||
0x00000006,0x000000c4,0x000000c3,0x0004003d,0x00000006,0x000000c5,0x000000b0,0x00050083,
|
||||
0x00000006,0x000000c7,0x000000c5,0x000000c6,0x000500be,0x0000001e,0x000000c8,0x000000c4,
|
||||
0x000000c7,0x000300f7,0x000000ca,0x00000000,0x000400fa,0x000000c8,0x000000c9,0x000000ca,
|
||||
0x000200f8,0x000000c9,0x000200f9,0x000000bd,0x000200f8,0x000000ca,0x0004003d,0x000000aa,
|
||||
0x000000cf,0x000000b9,0x00060041,0x000000d0,0x000000d1,0x000000a9,0x000000ce,0x000000cf,
|
||||
0x0004003d,0x000000a3,0x000000d2,0x000000d1,0x0003003e,0x000000cd,0x000000d2,0x00050041,
|
||||
0x00000016,0x000000d4,0x00000020,0x000000d3,0x0004003d,0x00000006,0x000000d5,0x000000d4,
|
||||
0x00050041,0x00000016,0x000000d6,0x000000cd,0x000000d3,0x0004003d,0x00000006,0x000000d7,
|
||||
0x000000d6,0x000500be,0x0000001e,0x000000d8,0x000000d5,0x000000d7,0x000300f7,0x000000da,
|
||||
0x00000000,0x000400fa,0x000000d8,0x000000d9,0x000000da,0x000200f8,0x000000d9,0x00050041,
|
||||
0x00000016,0x000000dc,0x00000020,0x000000db,0x0004003d,0x00000006,0x000000dd,0x000000dc,
|
||||
0x00050041,0x00000016,0x000000de,0x000000cd,0x000000db,0x0004003d,0x00000006,0x000000df,
|
||||
0x000000de,0x000500be,0x0000001e,0x000000e0,0x000000dd,0x000000df,0x000200f9,0x000000da,
|
||||
0x000200f8,0x000000da,0x000700f5,0x0000001e,0x000000e1,0x000000d8,0x000000ca,0x000000e0,
|
||||
0x000000d9,0x000300f7,0x000000e3,0x00000000,0x000400fa,0x000000e1,0x000000e2,0x000000e3,
|
||||
0x000200f8,0x000000e2,0x00050041,0x00000016,0x000000e4,0x00000020,0x000000d3,0x0004003d,
|
||||
0x00000006,0x000000e5,0x000000e4,0x00050041,0x00000016,0x000000e7,0x000000cd,0x000000e6,
|
||||
0x0004003d,0x00000006,0x000000e8,0x000000e7,0x000500b8,0x0000001e,0x000000e9,0x000000e5,
|
||||
0x000000e8,0x000200f9,0x000000e3,0x000200f8,0x000000e3,0x000700f5,0x0000001e,0x000000ea,
|
||||
0x000000e1,0x000000da,0x000000e9,0x000000e2,0x000300f7,0x000000ec,0x00000000,0x000400fa,
|
||||
0x000000ea,0x000000eb,0x000000ec,0x000200f8,0x000000eb,0x00050041,0x00000016,0x000000ed,
|
||||
0x00000020,0x000000db,0x0004003d,0x00000006,0x000000ee,0x000000ed,0x00050041,0x00000016,
|
||||
0x000000ef,0x000000cd,0x000000ac,0x0004003d,0x00000006,0x000000f0,0x000000ef,0x000500b8,
|
||||
0x0000001e,0x000000f1,0x000000ee,0x000000f0,0x000200f9,0x000000ec,0x000200f8,0x000000ec,
|
||||
0x000700f5,0x0000001e,0x000000f2,0x000000ea,0x000000e3,0x000000f1,0x000000eb,0x000300f7,
|
||||
0x000000f4,0x00000000,0x000400fa,0x000000f2,0x000000f3,0x000000f4,0x000200f8,0x000000f3,
|
||||
0x0004003d,0x00000006,0x000000f6,0x000000b4,0x0004003d,0x000000aa,0x000000f7,0x000000b9,
|
||||
0x0004006f,0x00000006,0x000000f8,0x000000f7,0x0006000c,0x00000006,0x000000f9,0x00000001,
|
||||
0x0000001d,0x000000f8,0x00050088,0x00000006,0x000000fa,0x000000f6,0x000000f9,0x0006000c,
|
||||
0x00000006,0x000000fb,0x00000001,0x00000008,0x000000fa,0x0005008d,0x00000006,0x000000fd,
|
||||
0x000000fb,0x000000fc,0x0003003e,0x000000f5,0x000000fd,0x0004003d,0x00000006,0x000000fe,
|
||||
0x000000f5,0x000500ba,0x0000001e,0x000000ff,0x000000fe,0x000000c6,0x000200fe,0x000000ff,
|
||||
0x000200f8,0x000000f4,0x000200f9,0x000000be,0x000200f8,0x000000be,0x0004003d,0x000000aa,
|
||||
0x00000101,0x000000b9,0x00050080,0x000000aa,0x00000102,0x00000101,0x000000ab,0x0003003e,
|
||||
0x000000b9,0x00000102,0x000200f9,0x000000bb,0x000200f8,0x000000bd,0x000200fe,0x00000103,
|
||||
0x00010038
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,174 @@
|
||||
#ifndef SC_LAYER_H
|
||||
#define SC_LAYER_H
|
||||
/*
|
||||
* Layer mode (BANNER_WAYLAND_ZERO_COPY=1): the scene is handed to SurfaceFlinger as a small,
|
||||
* deliberately ordered SET of Android display layers — ASurfaceControl children of the
|
||||
* compositor's SurfaceView — instead of being blitted into the compositor's own swapchain.
|
||||
*
|
||||
* app window ......... Compose UI, the in-game drawer, the HUD, the on-screen controls and
|
||||
* the pointer arrow: ordinary Android views, ALWAYS above everything
|
||||
* below (the SurfaceView is not Z-on-top, so its whole subtree is under
|
||||
* the window's own content). None of the layers below take input:
|
||||
* an ASurfaceControl has no input channel, so touch and mouse keep
|
||||
* reaching the SurfaceView exactly as they did.
|
||||
* +-- SurfaceView ..... the compositor's Vulkan swapchain; black while layer mode is up
|
||||
* +-- z=1 "banner_wayland_game" ...... the one fullscreen game window
|
||||
* +-- z=2 "banner_wayland_overlay" ... at most one window drawn ABOVE the game
|
||||
*
|
||||
* TWO layers is the hard cap (SC_LAYER_COUNT), and deliberately so: HWC composes only a few
|
||||
* layers before SurfaceFlinger falls back to GPU client composition, which would throw away the
|
||||
* whole benefit. The count is logged when the second layer first goes up.
|
||||
*
|
||||
* MEASURED on the Pocket FIT (Adreno 750, portrait panel + landscape session, so every layer is
|
||||
* ROT_90 + scaled), `dumpsys android.hardware.graphics.composer3.IComposer/default`: one layer is
|
||||
* `composition: DEVICE/DEVICE`, effects on the layer keep it DEVICE/DEVICE — but a SECOND layer
|
||||
* flips the whole frame to `DEVICE/CLIENT`. It does not come back when the overlay goes away.
|
||||
* The overlay layer is retired rather than hidden for that reason, but the fallback outlives it.
|
||||
* The likely mechanism is the DPU's rotator budget (one rotated+scaled layer), not the layer count
|
||||
* as such, so a device or orientation needing no rotation may well take both on the DPU. Even in
|
||||
* client composition the overlay layer is not a loss — SurfaceFlinger does the one blit the
|
||||
* compositor would have done — but the hardware-composition win is only real for one layer.
|
||||
*
|
||||
* COMPOSITION RECOVERY (sc_layer.c, swap_sc_begin): retiring the overlay arms the game layer, and
|
||||
* the NEXT frame is presented on a brand-new SurfaceControl while the old one is hidden and
|
||||
* unparented in the SAME transaction. SurfaceFlinger applies a transaction atomically, so no
|
||||
* composited frame is ever missing the game — no black frame, no dropped frame beyond the layer
|
||||
* creation itself. One `layer` line is written when it happens.
|
||||
*
|
||||
* ⚠️ It does NOT restore hardware composition on this panel, and that was measured, not assumed
|
||||
* (2026-09-14, Wizardry on the game layer + Wine's Task Manager on the overlay, reproduced twice):
|
||||
* - two layers -> DEVICE/CLIENT
|
||||
* - overlay retired + fresh game SurfaceControl -> still DEVICE/CLIENT, 24 s later too
|
||||
* - layer path dropped entirely and re-created -> still DEVICE/CLIENT
|
||||
* - drawer opened and closed, no second window -> DEVICE/DEVICE (control: the drawer is not the cause)
|
||||
* - HOME + resume -> DEVICE/DEVICE
|
||||
* HOME + resume re-creates the app's whole window and SurfaceView (`VRI[XServerDisplayActivity]#0`
|
||||
* becomes `#4`), not just this child layer — so the sticky state belongs to the parent surface or
|
||||
* the display. Re-creating the parent would cost a real black frame and a swapchain rebuild, which
|
||||
* is worse than the few percent of GPU that client composition costs. The cure that actually keeps
|
||||
* the win is PREVENTION, and it IS implemented: sc_layer_overlay_affordable() declines the second
|
||||
* layer when the game layer is both rotated and scaled, and the window above the game goes down the
|
||||
* copy path instead (what the pre-phase-4 code did) — one blit SurfaceFlinger would have done
|
||||
* anyway, and the session keeps DEVICE composition throughout. Where a second layer costs nothing,
|
||||
* nothing changes.
|
||||
*
|
||||
* What can be on the game layer, cheapest first:
|
||||
* - the game's own gralloc buffer (ahb_swapchain.c, true zero-copy: no copy anywhere);
|
||||
* - one blit of the game's frame into a compositor-allocated AHardwareBuffer (sc_layer_present);
|
||||
* - with screen effects on, the compositor pass's result blitted into such a buffer
|
||||
* (sc_layer_present_pass) — the game STAYS on its layer while a Look is applied, and the
|
||||
* scene -> output mapping is done by the display (setGeometry) instead of a second GPU blit.
|
||||
* The compositor never alpha-blends (it composes with blits, which overwrite), so every layer is
|
||||
* marked OPAQUE and the overlay layer is cropped to the window it carries: the picture is the
|
||||
* same as the copy path's, pixel for pixel.
|
||||
*
|
||||
* Compositor thread only, except the SurfaceFlinger OnComplete callbacks (binder threads), which
|
||||
* only touch the pools under g_lock. sc_layer_hide*() is safe at any time.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <android/hardware_buffer.h>
|
||||
|
||||
struct vkp_image;
|
||||
struct vkp_draw;
|
||||
struct banner_color;
|
||||
|
||||
/* The layers, bottom first. The z-order is the array order (z = id + 1). */
|
||||
enum sc_layer_id { SC_LAYER_GAME = 0, SC_LAYER_OVERLAY = 1, SC_LAYER_COUNT = 2 };
|
||||
|
||||
/* 1 when this device has the SurfaceControl API the layers need (Android 10+, libnativewindow's
|
||||
* getNativeHandle); the reason is logged (tag `layer`) the first time it is missing. */
|
||||
int sc_layer_available(void);
|
||||
|
||||
/* One-shot: does the kernel export a sync_file from the game's dma-buf (DMA_BUF_IOCTL_EXPORT_SYNC_FILE)?
|
||||
* Decides where a zero-copy acquire fence can come from; result goes to the session log. */
|
||||
void sc_layer_probe_dmabuf_fd(int fd);
|
||||
|
||||
/* HDR (banner_color.h): can a display layer be told its buffer's colour encoding here
|
||||
* (ASurfaceTransaction_setBufferDataSpace, Android 10+)? Part of the HDR gate. */
|
||||
int sc_layer_can_tag_hdr(void);
|
||||
/* Which of the colour calls this libandroid has, for the gate's log line. */
|
||||
void sc_layer_hdr_symbols(char *out, size_t size);
|
||||
|
||||
/* COLOUR on the game layer: `color` is the image description of the frame being presented (NULL =
|
||||
* none, i.e. sRGB). A layer that was never tagged is never touched (no setBufferDataSpace call at all:
|
||||
* a session without an HDR description behaves exactly as before); once tagged, a later untagged frame
|
||||
* puts the layer back to UNKNOWN. SMPTE 2086 / CTA-861.3 metadata travel with the dataspace. */
|
||||
|
||||
/* GAME layer: show `src` (the fullscreen window's imported frame, scene-sized) on it, placed
|
||||
* through the current fullscreen mode / alignment mapping. 0 = shown (or deliberately dropped: no
|
||||
* free buffer), -1 = the layer path is unavailable this frame and the caller must draw the old way.
|
||||
* The copy into the layer buffer is 8-bit: an HDR frame keeps its tag (its colours stay right), and
|
||||
* loses precision. */
|
||||
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct banner_color *color);
|
||||
|
||||
/* GAME layer, screen effects on: run the compositor pass (composite `draws` + the effects chain,
|
||||
* vkp_pass_begin) and put its result on the layer. Same return values as sc_layer_present. */
|
||||
int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int scene_h);
|
||||
|
||||
/* GAME layer, HDR (hdr_compose.h): the whole scene - `draws`, hf->is_hdr marking the HDR ones - composed
|
||||
* into one 10-bit PQ BT.2020 picture with the effects applied (vkp_pass_begin_hdr), copied into a
|
||||
* 10-bit layer buffer (8-bit where gralloc refuses those) and shown tagged with `color` (the topmost HDR
|
||||
* draw's description). The overlay layer is not used: the picture already holds what is above the game.
|
||||
* Same return values as sc_layer_present. */
|
||||
struct vkp_hdr_frame;
|
||||
int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf,
|
||||
int scene_w, int scene_h, const struct banner_color *color);
|
||||
|
||||
/* GAME layer, zero-copy (ahb_swapchain.c): show the game's own w x h AHardwareBuffer, gated by
|
||||
* acquire_fd (a sync_file the layer waits on before reading; owned by the callee, -1 = none).
|
||||
* token identifies the buffer: once a later transaction replaces it (or the layer is hidden or
|
||||
* retired), ahb_swapchain_layer_released(token, release_fd) reports SurfaceFlinger's release fence
|
||||
* for it. Presenting the token already on the layer only updates the placement. 0 = on the layer,
|
||||
* 1 = nothing of it is on screen (layer hidden, the buffer was not taken), -1 = unavailable this
|
||||
* frame (the caller draws the old way). `color` / `ahb_format`: the frame's image description (NULL =
|
||||
* none) and the buffer's AHARDWAREBUFFER_FORMAT_*, for the dataspace and the HDR evidence. */
|
||||
int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, void *token,
|
||||
int scene_w, int scene_h, const struct banner_color *color, uint32_t ahb_format);
|
||||
|
||||
/* Vote a panel refresh rate for the layer the game presents on (VRR / refresh-rate matching), the
|
||||
* same rate and compatibility the app votes on its own surface with Surface.setFrameRate; 0 = no
|
||||
* vote. Needed because a zero-copy game's frames go onto the GAME layer and never reach the app's
|
||||
* surface, so the surface vote alone does not describe the game's cadence to SurfaceFlinger. Only
|
||||
* the game layer ever carries it: the overlay layer is explicitly voted 0, so a window that redraws
|
||||
* once a second can never hold (or drop) the panel at the game's cadence. Callable from any thread
|
||||
* at any time (it only stores the rate); the compositor applies it with the layer's next
|
||||
* transaction, and re-applies it whenever a SurfaceControl is re-created. A no-op on devices whose
|
||||
* libandroid has no ASurfaceTransaction_setFrameRate. */
|
||||
void sc_layer_set_frame_rate(float fps);
|
||||
|
||||
/* Is a SECOND display layer worth raising on THIS display? Ask before committing the game to its
|
||||
* layer, not after: on a display where the answer is no, the whole scene must go down the copy path
|
||||
* from the start, or the game layer would be shown and hidden again on every frame.
|
||||
*
|
||||
* The answer is computed from what the layer path knows — the rotation the presentation engine
|
||||
* applies to everything we hand it (VkSurfaceCapabilitiesKHR::currentTransform) and the game
|
||||
* layer's own src -> dst rectangles — and never from a device or panel allowlist. ROTATED AND
|
||||
* SCALED is the combination measured to cost hardware composition (below); either alone is fine.
|
||||
* The reason is written to the session log once, and again if the answer changes. */
|
||||
int sc_layer_overlay_affordable(void);
|
||||
|
||||
/* OVERLAY layer: show `src` (one window's imported frame) above the game layer, at the placement
|
||||
* `geo` = {src x0,y0,x1,y1 in image pixels, dst x0,y0,x1,y1 in output pixels} from vkp_map_draw.
|
||||
* 0 = shown or dropped, -1 = unavailable (the caller must fall back to the copy path). */
|
||||
int sc_layer_present_overlay(struct vkp_image *src, const int geo[8]);
|
||||
|
||||
/* The scene is not a single fullscreen window this frame: hide every layer that is up. */
|
||||
void sc_layer_hide(void);
|
||||
/* Only the overlay layer: nothing is above the game any more. The game keeps its layer, but its
|
||||
* SurfaceControl is swapped for a fresh one on the next frame (composition recovery, above — which
|
||||
* on this panel does not in fact win hardware composition back; see the measurement there). */
|
||||
void sc_layer_hide_overlay(void);
|
||||
|
||||
/* The output window changed or went away (compositor thread, from vkp_apply_window_request). */
|
||||
void sc_layer_window_gone(void);
|
||||
|
||||
/* Frames the compositor put on a layer through one of its own buffers (a blit or the effects
|
||||
* pass) since the last call — the zero-copy frames ahb_swapchain.c counts are NOT included.
|
||||
* For the 10 s summary. */
|
||||
unsigned sc_layer_frames_take(void);
|
||||
/* Frames dropped since the last call because every layer buffer was still held by the display (the
|
||||
* 10 s perf line; the "no free layer buffer" log line itself is rate-limited). */
|
||||
unsigned sc_layer_drops_take(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
/* Compositor-side dmabuf import into Turnip (see vk_import.h). */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "vk_import.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#define MOD_INVALID 0x00ffffffffffffffULL
|
||||
|
||||
static int g_ready = -1; /* -1 = untried, 0 = ok, 1 = init failed */
|
||||
static VkInstance g_inst;
|
||||
static VkPhysicalDevice g_pd;
|
||||
static VkDevice g_dev;
|
||||
static PFN_vkGetMemoryFdPropertiesKHR p_getMemFdProps;
|
||||
|
||||
static int has_ext(VkExtensionProperties *e, uint32_t n, const char *name) {
|
||||
for (uint32_t i = 0; i < n; i++)
|
||||
if (!strcmp(e[i].extensionName, name)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vk_init(void) {
|
||||
if (g_ready >= 0) return g_ready == 0 ? 0 : -1;
|
||||
|
||||
VkApplicationInfo app = {.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
.pApplicationName = "spike-compositor-import",
|
||||
.apiVersion = VK_API_VERSION_1_1};
|
||||
VkInstanceCreateInfo ici = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pApplicationInfo = &app};
|
||||
if (vkCreateInstance(&ici, NULL, &g_inst) != VK_SUCCESS) {
|
||||
fprintf(stderr, "[imp] vkCreateInstance failed\n");
|
||||
g_ready = 1; return -1;
|
||||
}
|
||||
uint32_t npd = 0;
|
||||
vkEnumeratePhysicalDevices(g_inst, &npd, NULL);
|
||||
if (!npd) { g_ready = 1; return -1; }
|
||||
VkPhysicalDevice pds[8];
|
||||
if (npd > 8) npd = 8;
|
||||
vkEnumeratePhysicalDevices(g_inst, &npd, pds);
|
||||
g_pd = pds[0]; /* Turnip is forced via VK_ICD_FILENAMES */
|
||||
|
||||
const char *want[] = {"VK_KHR_external_memory_fd",
|
||||
"VK_EXT_external_memory_dma_buf",
|
||||
"VK_EXT_image_drm_format_modifier",
|
||||
"VK_KHR_image_format_list"};
|
||||
uint32_t ne = 0;
|
||||
vkEnumerateDeviceExtensionProperties(g_pd, NULL, &ne, NULL);
|
||||
VkExtensionProperties *exts = calloc(ne, sizeof(*exts));
|
||||
vkEnumerateDeviceExtensionProperties(g_pd, NULL, &ne, exts);
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
if (!has_ext(exts, ne, want[i]))
|
||||
fprintf(stderr, "[imp] WARNING device missing %s\n", want[i]);
|
||||
free(exts);
|
||||
|
||||
float prio = 1.0f;
|
||||
VkDeviceQueueCreateInfo qci = {.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = 0, .queueCount = 1,
|
||||
.pQueuePriorities = &prio};
|
||||
VkDeviceCreateInfo dci = {.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.queueCreateInfoCount = 1, .pQueueCreateInfos = &qci,
|
||||
.enabledExtensionCount = 4, .ppEnabledExtensionNames = want};
|
||||
if (vkCreateDevice(g_pd, &dci, NULL, &g_dev) != VK_SUCCESS) {
|
||||
fprintf(stderr, "[imp] vkCreateDevice failed\n");
|
||||
g_ready = 1; return -1;
|
||||
}
|
||||
p_getMemFdProps = (PFN_vkGetMemoryFdPropertiesKHR)vkGetDeviceProcAddr(
|
||||
g_dev, "vkGetMemoryFdPropertiesKHR");
|
||||
g_ready = 0;
|
||||
fprintf(stderr, "[imp] Vulkan import device ready (Turnip)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VkFormat drm_to_vk(uint32_t drm) {
|
||||
/* XR24/AR24 (XRGB/ARGB8888, little-endian bytes B,G,R,X) -> BGRA8. */
|
||||
return VK_FORMAT_B8G8R8A8_UNORM;
|
||||
}
|
||||
|
||||
int vk_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier, int w, int h,
|
||||
uint32_t stride, uint32_t offset) {
|
||||
if (modifier == MOD_INVALID) {
|
||||
fprintf(stderr, "[imp] skip: INVALID modifier (needs implicit path)\n");
|
||||
return -1;
|
||||
}
|
||||
if (vk_init() != 0) return -1;
|
||||
|
||||
VkSubresourceLayout plane = {.offset = offset, .rowPitch = stride};
|
||||
VkImageDrmFormatModifierExplicitCreateInfoEXT modInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
|
||||
.drmFormatModifier = modifier,
|
||||
.drmFormatModifierPlaneCount = 1,
|
||||
.pPlaneLayouts = &plane};
|
||||
VkExternalMemoryImageCreateInfo extImg = {
|
||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
|
||||
.pNext = &modInfo,
|
||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT};
|
||||
VkImageCreateInfo ici = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.pNext = &extImg,
|
||||
.imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = drm_to_vk(drm_format),
|
||||
.extent = {w, h, 1},
|
||||
.mipLevels = 1, .arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,
|
||||
.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
VkImage image;
|
||||
VkResult r = vkCreateImage(g_dev, &ici, NULL, &image);
|
||||
if (r != VK_SUCCESS) {
|
||||
fprintf(stderr, "[imp] vkCreateImage(drm_modifier) -> %d\n", r);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int dupfd = dup(fd);
|
||||
uint32_t allowed_types = 0xffffffff;
|
||||
if (p_getMemFdProps) {
|
||||
VkMemoryFdPropertiesKHR fp = {.sType = VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR};
|
||||
if (p_getMemFdProps(g_dev, VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
dupfd, &fp) == VK_SUCCESS)
|
||||
allowed_types = fp.memoryTypeBits;
|
||||
}
|
||||
VkMemoryRequirements req;
|
||||
vkGetImageMemoryRequirements(g_dev, image, &req);
|
||||
uint32_t bits = req.memoryTypeBits & allowed_types;
|
||||
int type_idx = -1;
|
||||
for (int i = 0; i < 32; i++)
|
||||
if (bits & (1u << i)) { type_idx = i; break; }
|
||||
if (type_idx < 0) {
|
||||
fprintf(stderr, "[imp] no compatible memory type\n");
|
||||
vkDestroyImage(g_dev, image, NULL); close(dupfd); return -1;
|
||||
}
|
||||
|
||||
VkImportMemoryFdInfoKHR imp = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
.fd = dupfd};
|
||||
VkMemoryDedicatedAllocateInfo ded = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
|
||||
.pNext = &imp, .image = image};
|
||||
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
.pNext = &ded,
|
||||
.allocationSize = req.size,
|
||||
.memoryTypeIndex = (uint32_t)type_idx};
|
||||
VkDeviceMemory mem;
|
||||
r = vkAllocateMemory(g_dev, &mai, NULL, &mem);
|
||||
if (r != VK_SUCCESS) {
|
||||
fprintf(stderr, "[imp] vkAllocateMemory(import fd) -> %d\n", r);
|
||||
vkDestroyImage(g_dev, image, NULL); close(dupfd); return -1;
|
||||
}
|
||||
r = vkBindImageMemory(g_dev, image, mem, 0);
|
||||
if (r != VK_SUCCESS) {
|
||||
fprintf(stderr, "[imp] vkBindImageMemory -> %d\n", r);
|
||||
vkFreeMemory(g_dev, mem, NULL); vkDestroyImage(g_dev, image, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"[imp] *** IMPORTED dmabuf -> VkImage OK (memType %d, size %llu) "
|
||||
"==> compositor can turn game frames into VkImages\n",
|
||||
type_idx, (unsigned long long)req.size);
|
||||
/* import took ownership of dupfd; free our objects */
|
||||
vkFreeMemory(g_dev, mem, NULL);
|
||||
vkDestroyImage(g_dev, image, NULL);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef VK_IMPORT_H
|
||||
#define VK_IMPORT_H
|
||||
#include <stdint.h>
|
||||
/*
|
||||
* Import a received dmabuf into the compositor's own Vulkan (Turnip) device as a
|
||||
* VkImage and bind its memory. This is the M4-import de-risk: if we can import +
|
||||
* bind, sampling/blitting it to screen is standard Vulkan. Non-fatal: returns 0
|
||||
* on success, negative on failure, and logs details. Does NOT consume `fd`
|
||||
* (dups internally).
|
||||
*/
|
||||
int vk_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier,
|
||||
int w, int h, uint32_t stride, uint32_t offset);
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
/* See vk_loader.h. */
|
||||
#define _GNU_SOURCE
|
||||
#include "vk_loader.h"
|
||||
#include "../../adrenotools/include/adrenotools/driver.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#define TAG "BannerWayland"
|
||||
|
||||
struct vk_api g_vk;
|
||||
static void *g_handle;
|
||||
static PFN_vkGetInstanceProcAddr g_gip;
|
||||
|
||||
int vk_loader_open(const char *driver_path, const char *library_name,
|
||||
const char *native_lib_dir) {
|
||||
if (driver_path && library_name && native_lib_dir) {
|
||||
char *tmpdir = NULL;
|
||||
if (asprintf(&tmpdir, "%stemp", driver_path) < 0) tmpdir = NULL;
|
||||
if (tmpdir) mkdir(tmpdir, S_IRWXU | S_IRWXG);
|
||||
g_handle = adrenotools_open_libvulkan(
|
||||
RTLD_LOCAL | RTLD_NOW, ADRENOTOOLS_DRIVER_CUSTOM, tmpdir,
|
||||
native_lib_dir, driver_path, library_name, NULL, NULL);
|
||||
free(tmpdir);
|
||||
__android_log_print(g_handle ? ANDROID_LOG_INFO : ANDROID_LOG_ERROR, TAG,
|
||||
"adrenotools Turnip handle=%p (%s / %s)", g_handle,
|
||||
driver_path, library_name);
|
||||
}
|
||||
if (!g_handle) {
|
||||
g_handle = dlopen("libvulkan.so", RTLD_LOCAL | RTLD_NOW);
|
||||
__android_log_print(ANDROID_LOG_WARN, TAG,
|
||||
"no adrenotools driver -> system libvulkan handle=%p "
|
||||
"(dmabuf import likely unsupported)", g_handle);
|
||||
}
|
||||
if (!g_handle) return -1;
|
||||
g_gip = (PFN_vkGetInstanceProcAddr)dlsym(g_handle, "vkGetInstanceProcAddr");
|
||||
if (!g_gip) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, TAG, "no vkGetInstanceProcAddr");
|
||||
return -1;
|
||||
}
|
||||
#define X(n) g_vk.n = (PFN_vk##n)g_gip(NULL, "vk" #n);
|
||||
VK_GLOBAL_FUNCS(X)
|
||||
#undef X
|
||||
return g_vk.CreateInstance ? 0 : -1;
|
||||
}
|
||||
|
||||
PFN_vkGetInstanceProcAddr vk_loader_gipa(void) { return g_gip; }
|
||||
|
||||
void vk_loader_load_instance(VkInstance instance) {
|
||||
#define X(n) g_vk.n = (PFN_vk##n)g_gip(instance, "vk" #n);
|
||||
VK_INSTANCE_FUNCS(X)
|
||||
#undef X
|
||||
}
|
||||
|
||||
void vk_loader_load_device(VkDevice device) {
|
||||
#define X(n) g_vk.n = (PFN_vk##n)g_vk.GetDeviceProcAddr(device, "vk" #n);
|
||||
VK_DEVICE_FUNCS(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef VK_LOADER_H
|
||||
#define VK_LOADER_H
|
||||
/*
|
||||
* Loads Turnip via adrenotools (the same path the app uses for the guest renderer)
|
||||
* and resolves every Vulkan entry point through its vkGetInstanceProcAddr — NOT the
|
||||
* process-default system Adreno driver, which lacks VK_EXT_image_drm_format_modifier /
|
||||
* dmabuf import. All compositor Vulkan calls go through g_vk.* .
|
||||
*/
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#define VK_GLOBAL_FUNCS(X) X(CreateInstance) X(EnumerateInstanceExtensionProperties)
|
||||
|
||||
#define VK_INSTANCE_FUNCS(X) \
|
||||
X(EnumeratePhysicalDevices) X(GetPhysicalDeviceProperties) \
|
||||
X(GetPhysicalDeviceQueueFamilyProperties) X(GetPhysicalDeviceSurfaceSupportKHR) \
|
||||
X(GetPhysicalDeviceSurfaceCapabilitiesKHR) X(GetPhysicalDeviceSurfaceFormatsKHR) \
|
||||
X(CreateAndroidSurfaceKHR) X(DestroySurfaceKHR) X(CreateDevice) \
|
||||
X(GetDeviceProcAddr) X(EnumerateDeviceExtensionProperties) \
|
||||
X(GetPhysicalDeviceMemoryProperties) X(GetPhysicalDeviceFormatProperties2) \
|
||||
X(GetPhysicalDeviceImageFormatProperties2)
|
||||
|
||||
#define VK_DEVICE_FUNCS(X) \
|
||||
X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \
|
||||
X(CreateCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \
|
||||
X(DeviceWaitIdle) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \
|
||||
X(BindImageMemory) X(DestroyImage) X(FreeMemory) X(AcquireNextImageKHR) \
|
||||
X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \
|
||||
X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \
|
||||
X(QueueWaitIdle) X(GetMemoryFdPropertiesKHR) \
|
||||
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) \
|
||||
/* screen-effect chain (effects_chain.c): graphics pipelines over full-screen quads */ \
|
||||
X(CreateShaderModule) X(DestroyShaderModule) X(CreatePipelineLayout) X(DestroyPipelineLayout) \
|
||||
X(CreateGraphicsPipelines) X(DestroyPipeline) X(CreateRenderPass) X(DestroyRenderPass) \
|
||||
X(CreateFramebuffer) X(DestroyFramebuffer) X(CreateImageView) X(DestroyImageView) \
|
||||
X(CreateSampler) X(DestroySampler) X(CreateDescriptorSetLayout) X(DestroyDescriptorSetLayout) \
|
||||
X(CreateDescriptorPool) X(DestroyDescriptorPool) X(AllocateDescriptorSets) X(FreeDescriptorSets) \
|
||||
X(UpdateDescriptorSets) X(CmdBeginRenderPass) X(CmdEndRenderPass) X(CmdBindPipeline) \
|
||||
X(CmdBindDescriptorSets) X(CmdPushConstants) X(CmdDraw) X(CmdSetViewport) X(CmdSetScissor) \
|
||||
/* frame generation (framegen_bridge.c / vk_present.c per-present sync slots) */ \
|
||||
X(DestroySemaphore)
|
||||
|
||||
struct vk_api {
|
||||
#define X(n) PFN_vk##n n;
|
||||
VK_GLOBAL_FUNCS(X) VK_INSTANCE_FUNCS(X) VK_DEVICE_FUNCS(X)
|
||||
#undef X
|
||||
};
|
||||
extern struct vk_api g_vk;
|
||||
|
||||
/* Open Turnip via adrenotools (falls back to system libvulkan if any arg is NULL)
|
||||
* and load global entry points. Returns 0 on success. */
|
||||
int vk_loader_open(const char *driver_path, const char *library_name,
|
||||
const char *native_lib_dir);
|
||||
void vk_loader_load_instance(VkInstance instance);
|
||||
void vk_loader_load_device(VkDevice device);
|
||||
/* The driver's vkGetInstanceProcAddr (NULL before vk_loader_open): for modules that resolve their
|
||||
* own entry points, e.g. the frame-generation engines (framegen_engine.cpp). */
|
||||
PFN_vkGetInstanceProcAddr vk_loader_gipa(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,185 @@
|
||||
#ifndef VK_PRESENT_H
|
||||
#define VK_PRESENT_H
|
||||
#include <stdint.h>
|
||||
#include <android/native_window.h>
|
||||
/*
|
||||
* Android-surface render backend for the embedded Wayland compositor.
|
||||
* Owns a Turnip VkDevice + a swapchain on the SurfaceView's ANativeWindow. Each
|
||||
* client buffer becomes an image (a dmabuf from winewayland's Vulkan WSI is
|
||||
* imported zero-copy; a wl_shm buffer is copied into a host-visible image), and
|
||||
* every frame blits the whole scene — desktop, windows, subsurfaces — in order.
|
||||
*/
|
||||
|
||||
// Set the Turnip driver to load (adrenotools). Call before the first frame.
|
||||
// NULL args -> the backend falls back to the system libvulkan (dmabuf import will
|
||||
// likely fail — Adreno lacks drm_format_modifier). driver_path ends with '/'.
|
||||
void vk_present_set_driver(const char *driver_path, const char *library_name,
|
||||
const char *native_lib_dir);
|
||||
|
||||
// Set/replace the output window (from Surface via ANativeWindow_fromSurface; the backend
|
||||
// owns the reference from then on). NULL = the surface is gone. Callable from any thread
|
||||
// and never blocks: the request is applied by the compositor thread (vkp_render /
|
||||
// vkp_apply_window_request), which tears the old swapchain down and releases the old window.
|
||||
void vk_present_set_window(ANativeWindow *window);
|
||||
/* Compositor thread: apply a pending window change now. Returns 1 if the window changed. */
|
||||
int vkp_apply_window_request(void);
|
||||
|
||||
/* How the scene is mapped onto the output (the app's Container.FULLSCREEN_* / ALIGN_* values,
|
||||
* mirrored 1:1 from ViewTransformation.java so touch input, which is mapped by the app with
|
||||
* that class, lands on the same pixels). Callable from any thread, applies on the next frame. */
|
||||
enum vkp_scale_mode { VKP_MODE_OFF = 0, VKP_MODE_FIT = 1, VKP_MODE_STRETCH = 2, VKP_MODE_FILL = 3,
|
||||
VKP_MODE_INTEGER = 4 };
|
||||
enum vkp_align { VKP_ALIGN_CENTER = 0, VKP_ALIGN_TOP = 1, VKP_ALIGN_BOTTOM = 2 };
|
||||
void vk_present_set_scale_mode(int mode, int alignment);
|
||||
/* Output pixel (0..output size) -> scene pixel through the current mapping (compositor thread).
|
||||
* Returns 0 before the first frame has established a mapping (sx/sy untouched). */
|
||||
int vkp_output_to_scene(double ox, double oy, double *sx, double *sy);
|
||||
/* Output size in pixels (0x0 before the first swapchain). */
|
||||
void vkp_output_size(int *w, int *h);
|
||||
|
||||
struct vkp_image;
|
||||
|
||||
/* DRM format modifiers this backend knows the memory layout of (both single-plane on Adreno):
|
||||
* LINEAR, and QCOM_COMPRESSED = UBWC (drm_fourcc.h: fourcc_mod_code(QCOM = 0x05, 1)). */
|
||||
#define VKP_MOD_LINEAR 0x0000000000000000ULL
|
||||
#define VKP_MOD_QCOM_COMPRESSED 0x0500000000000001ULL
|
||||
#define VKP_MOD_INVALID 0x00ffffffffffffffULL
|
||||
/* "linear", "qcom_compressed", or "modifier 0x…" for anything else (static buffer). */
|
||||
const char *vkp_modifier_name(uint64_t modifier);
|
||||
/* The modifiers a dma-buf of this DRM fourcc can be imported with as a blit source, asked of the
|
||||
* renderer's own driver (VkDrmFormatModifierPropertiesListEXT, each confirmed for a dma-buf-backed
|
||||
* TRANSFER_SRC image with vkGetPhysicalDeviceImageFormatProperties2). Only LINEAR and
|
||||
* QCOM_COMPRESSED are ever returned (the ones this file can describe a plane layout for); other
|
||||
* modifiers the driver reports are logged once. Returns the count, 0 when the device is not up
|
||||
* (LINEAR is then the only safe assumption). Compositor thread. */
|
||||
int vkp_dmabuf_modifiers(uint32_t drm_format, uint64_t *out, int max);
|
||||
|
||||
// Import a dmabuf (single plane). NULL on failure. The image aliases the buffer, so
|
||||
// later client frames rendered into the same buffer show up without re-importing.
|
||||
struct vkp_image *vkp_image_from_dmabuf(int fd, uint32_t drm_format, uint64_t modifier,
|
||||
int w, int h, uint32_t stride, uint32_t offset);
|
||||
// Same, choosing the role: as_blit_dst = 0 imports a client frame (blit source), 1 imports a
|
||||
// buffer this backend blits INTO (layer mode's AHardwareBuffer pool, see sc_layer.h).
|
||||
struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier,
|
||||
int w, int h, uint32_t stride, uint32_t offset,
|
||||
int as_blit_dst);
|
||||
int vkp_image_is_dmabuf(const struct vkp_image *img);
|
||||
|
||||
// Create a host-visible image and copy BGRA/XRGB8888 pixels into it. NULL on failure.
|
||||
struct vkp_image *vkp_image_create_shm(int w, int h);
|
||||
void vkp_image_upload_shm(struct vkp_image *img, const void *data, int stride);
|
||||
|
||||
int vkp_image_width(const struct vkp_image *img);
|
||||
int vkp_image_height(const struct vkp_image *img);
|
||||
void vkp_image_destroy(struct vkp_image *img);
|
||||
|
||||
// One scene draw: the src rectangle of an image (image pixels) scaled into the dst
|
||||
// rectangle (scene pixels). The scene is mapped onto the output by the scale mode.
|
||||
struct vkp_draw {
|
||||
struct vkp_image *img;
|
||||
float sx, sy, sw, sh;
|
||||
int dx, dy, dw, dh;
|
||||
};
|
||||
|
||||
// The GPU the renderer runs on ("Adreno (TM) 750"), empty before the device is up.
|
||||
const char *vkp_gpu_name(void);
|
||||
|
||||
// 0 if the renderer can create images (device up), -1 otherwise.
|
||||
int vkp_ready(void);
|
||||
/* Whether an output window is attached (or requested); without one vkp_render() draws nothing. */
|
||||
int vkp_has_window(void);
|
||||
/* 1 once the Vulkan device was lost: nothing is presented any more (the session must restart). */
|
||||
int vkp_device_lost(void);
|
||||
|
||||
// Clear to black, blit the draws in order (first = bottom) and present.
|
||||
// Returns 0 on success, -1 if nothing could be presented (no window yet, etc.).
|
||||
int vkp_render(int scene_w, int scene_h, const struct vkp_draw *draws, int n);
|
||||
/* A black frame with no compositor pass (no effects, no frame generation), whatever is armed: the
|
||||
* base surface under an HDR game that keeps its display layer (compositor.c). */
|
||||
int vkp_render_plain(int scene_w, int scene_h);
|
||||
/* Layer mode's base surface: make sure it shows a plain black frame under the display layers. A frame
|
||||
* is presented only when the base is not already black on the current swapchain (entering layer mode,
|
||||
* after a copy-path / frame-generation frame, after a swapchain rebuild); otherwise nothing is drawn
|
||||
* or presented at all. 0 = the base is black, -1 = no output. Compositor thread. */
|
||||
int vkp_base_black(int scene_w, int scene_h);
|
||||
|
||||
/* ---- perf counters (the 10 s `perf` line, compositor.c) ----
|
||||
* Everything the compositor thread spends in the driver, since the last vkp_perf_take(). Times in ns. */
|
||||
struct vkp_perf {
|
||||
unsigned acquires, presents, waits;
|
||||
int64_t acquire_ns, acquire_max_ns; /* vkAcquireNextImageKHR */
|
||||
int64_t present_ns, present_max_ns; /* vkQueuePresentKHR */
|
||||
int64_t wait_ns, wait_max_ns; /* vkWaitForFences on the compositor's own work */
|
||||
unsigned base_presents; /* black frames presented under the display layers */
|
||||
unsigned base_kept; /* layer frames that kept the black frame already there */
|
||||
unsigned gpu_release_waits; /* layer-buffer release fences waited for on the GPU */
|
||||
};
|
||||
void vkp_perf_take(struct vkp_perf *out);
|
||||
/* 1 when a release fence (sync_file) can be handed to the GPU as a wait (VK_KHR_external_semaphore_fd):
|
||||
* the layer pool then reuses a buffer the display is still reading without blocking on the CPU. */
|
||||
int vkp_can_wait_sync_fd(void);
|
||||
|
||||
/* ---- HDR composition (hdr_compose.h) ----
|
||||
* An HDR game that cannot be alone on its display layer: the scene is composed into ONE encoding. */
|
||||
struct banner_color;
|
||||
struct vkp_hdr_frame {
|
||||
const unsigned char *is_hdr; /* per draw: 1 = its image holds PQ BT.2020 (the surface's description) */
|
||||
float peak_nits; /* the HDR content's peak, for a tone-map (max CLL / mastering max; 0 = 1000) */
|
||||
int tonemap; /* 1 = the drawer's HDR output switch is off: tone-map to SDR, never PQ */
|
||||
const struct banner_color *color; /* the topmost HDR draw's description: an HDR10 swapchain's metadata */
|
||||
};
|
||||
/* vkp_render for a scene with HDR draws (frame generation): composed into PQ and presented through an
|
||||
* HDR10 swapchain where the surface offers one (and hf->tonemap is 0), else tone-mapped into the ordinary
|
||||
* one. *how = 1 HDR10, 2 tone-mapped, 0 the HDR pass was unavailable (shown the old way). Same return as
|
||||
* vkp_render. */
|
||||
int vkp_render_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
|
||||
const struct vkp_hdr_frame *hf, int *how);
|
||||
/* vkp_pass_begin for a scene with HDR draws: composed into a 10-bit picture - PQ BT.2020, or sRGB
|
||||
* tone-mapped when hf->tonemap - the effects run on it in 10-bit, the result (rw x rh, A2B10G10R10) is
|
||||
* left for vkp_pass_copy_to() into a layer buffer (a blit: 10-bit or 8-bit). -1 = not possible (nothing
|
||||
* recorded). */
|
||||
int vkp_pass_begin_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
|
||||
const struct vkp_hdr_frame *hf, int *rw, int *rh);
|
||||
|
||||
/* ---- layer mode helpers (sc_layer.c; compositor thread) ---- */
|
||||
/* Whole-image copy of src into dst (a blit-destination dmabuf image), waited for on the CPU.
|
||||
* wait_fd: a sync_file the copy must wait for before writing dst (the display's release fence of that
|
||||
* buffer), -1 = none. Always consumed (handed to the GPU, or waited for and closed). */
|
||||
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd);
|
||||
/* Refresh the scene -> output mapping for this scene size without presenting (creates the
|
||||
* swapchain if needed, since the mapping is in output pixels). 0 = mapping valid. */
|
||||
int vkp_update_map(int scene_w, int scene_h);
|
||||
/* Map a draw through the current mapping: out = {src x0,y0,x1,y1 (image px), dst x0,y0,x1,y1
|
||||
* (output px)}, clipped like the blit path. 0 = nothing of it is visible. */
|
||||
int vkp_map_draw(const struct vkp_draw *d, int out[8]);
|
||||
/* The same for a bare w x h buffer shown over the whole scene (no vkp_image: zero-copy layers). */
|
||||
int vkp_map_rect(int img_w, int img_h, int scene_w, int scene_h, int out[8]);
|
||||
/* The output window frames go to (NULL = none); compositor thread. */
|
||||
/* Degrees the display rotates every layer we present by (0/90/180/270), -1 before the swapchain
|
||||
* exists. From VkSurfaceCapabilitiesKHR::currentTransform, i.e. what the presentation engine says
|
||||
* it does — never a device allowlist. The layer path uses it to decide whether a SECOND display
|
||||
* layer is affordable on this display (sc_layer_present_overlay). */
|
||||
int vkp_surface_rotation_degrees(void);
|
||||
|
||||
ANativeWindow *vkp_window(void);
|
||||
/* Fire the one-shot first-frame notification (layer mode presents outside vkp_render). */
|
||||
void vkp_signal_first_frame(void);
|
||||
|
||||
/* ---- the compositor pass into a layer buffer (sc_layer.c; compositor thread) ----
|
||||
* Screen effects on the game's own Android layer: compose `draws` into the scene image and run the
|
||||
* effects chain WITHOUT presenting, then copy the result into a gralloc layer buffer. Three steps
|
||||
* because the chain's result size (a scaling mode resizes to the scene's mapped output size) is
|
||||
* only known once the chain has run, and the layer buffer is allocated from it.
|
||||
* begin: 0 = a pass is in progress, its result is *rw x *rh; -1 = not possible (draw the old way).
|
||||
* Exactly one of copy_to (blit into dst, submit, wait; 0 = done) / abort (drop it unsubmitted)
|
||||
* must follow a successful begin. The chain deliberately runs with NO swapchain image acquired -
|
||||
* see the comment in vk_present.c. Frame generation is not run here (see WAYLAND_RUNTIME.md). */
|
||||
int vkp_pass_begin(int scene_w, int scene_h, const struct vkp_draw *draws, int n, int *rw, int *rh);
|
||||
/* wait_fd: as for vkp_blit_image (consumed in every case). */
|
||||
int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd);
|
||||
void vkp_pass_abort(void);
|
||||
|
||||
// Session log (compositor.c): one line to Download/Wayland-logs and logcat.
|
||||
void banner_log(const char *tag, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,632 @@
|
||||
/*
|
||||
* JNI entry for the embedded Wayland compositor (experimental parallel runtime).
|
||||
* Starts the compositor on a dedicated thread (it blocks in the wl event loop).
|
||||
* The render-to-Surface backend + input are added in the M4 phase; this brings up
|
||||
* the server so a Wayland client (eventually winewayland.drv) can connect.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/resource.h>
|
||||
#include <android/log.h>
|
||||
#include <android/native_window_jni.h>
|
||||
#include "vk_present.h"
|
||||
#include "banner_ext.h"
|
||||
#include "ahb_swapchain.h"
|
||||
#include "sc_layer.h"
|
||||
#include "effects_chain.h"
|
||||
#include "banner_color.h"
|
||||
|
||||
extern int banner_wayland_run(void);
|
||||
extern void banner_wayland_send_pointer(int action, int x, int y);
|
||||
extern void banner_wayland_send_key(int evdev, int state);
|
||||
extern void banner_wayland_send_scene_input(int type, int a, int b);
|
||||
extern void banner_wayland_vsync(int64_t frame_time_ns);
|
||||
extern volatile int g_fps_limit;
|
||||
extern volatile int g_hide_shell;
|
||||
extern volatile int g_zero_copy;
|
||||
extern volatile unsigned g_zero_copy_last;
|
||||
extern volatile int g_ubwc;
|
||||
extern volatile int g_no_render_node;
|
||||
extern volatile int g_output_refresh_mhz;
|
||||
extern volatile int g_output_w, g_output_h;
|
||||
|
||||
#define TAG "BannerWayland"
|
||||
|
||||
static JavaVM *g_jvm;
|
||||
static jclass g_compositor_cls; /* global ref */
|
||||
static jmethodID g_on_first_frame; /* static void onFirstFramePresented() */
|
||||
static jmethodID g_on_game_surface; /* static void onGameSurface(String, String) */
|
||||
static jmethodID g_on_game_frame; /* static void onGameFrame() */
|
||||
static jmethodID g_on_game_program; /* static void onGameProgram(int, String) */
|
||||
static jmethodID g_on_pointer_lock; /* static void onPointerLock(boolean, int, int) */
|
||||
static jmethodID g_on_clipboard; /* static void onClipboardText(byte[]) */
|
||||
static jmethodID g_on_text_input; /* static void onTextInput(boolean, String, int, int, int, int) */
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
(void)reserved;
|
||||
g_jvm = vm;
|
||||
JNIEnv *env;
|
||||
if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_6) == JNI_OK) {
|
||||
jclass c = (*env)->FindClass(env, "com/the412banner/steamdeck/wayland/WaylandCompositor");
|
||||
if (c) {
|
||||
g_compositor_cls = (*env)->NewGlobalRef(env, c);
|
||||
g_on_first_frame = (*env)->GetStaticMethodID(env, g_compositor_cls,
|
||||
"onFirstFramePresented", "()V");
|
||||
g_on_game_surface = (*env)->GetStaticMethodID(env, g_compositor_cls, "onGameSurface",
|
||||
"(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
g_on_game_frame = (*env)->GetStaticMethodID(env, g_compositor_cls, "onGameFrame", "()V");
|
||||
g_on_game_program = (*env)->GetStaticMethodID(env, g_compositor_cls, "onGameProgram",
|
||||
"(ILjava/lang/String;)V");
|
||||
if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); g_on_game_program = NULL; }
|
||||
g_on_pointer_lock = (*env)->GetStaticMethodID(env, g_compositor_cls, "onPointerLock", "(ZII)V");
|
||||
g_on_clipboard = (*env)->GetStaticMethodID(env, g_compositor_cls, "onClipboardText", "([B)V");
|
||||
g_on_text_input = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInput",
|
||||
"(ZLjava/lang/String;IIII)V");
|
||||
}
|
||||
}
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
/* Called from vk_present.c on the compositor thread when the first client frame is
|
||||
* presented. Attaches to the JVM (this thread is a bare pthread) and calls back into
|
||||
* Java so the launch overlay can dismiss. Fires exactly once. */
|
||||
void banner_on_first_frame(void) {
|
||||
if (!g_jvm || !g_compositor_cls || !g_on_first_frame) return;
|
||||
JNIEnv *env = NULL;
|
||||
int attached = 0;
|
||||
if ((*g_jvm)->GetEnv(g_jvm, (void **)&env, JNI_VERSION_1_6) != JNI_OK) {
|
||||
if ((*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL) != JNI_OK) return;
|
||||
attached = 1;
|
||||
}
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_first_frame);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
if (attached) (*g_jvm)->DetachCurrentThread(g_jvm);
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "first client frame presented -> notified app");
|
||||
}
|
||||
|
||||
/* The compositor thread stays attached once it first calls into Java: the HUD gets an upcall
|
||||
* for every game frame. */
|
||||
static __thread JNIEnv *t_env;
|
||||
static __thread int t_attached;
|
||||
|
||||
static JNIEnv *thread_env(void) {
|
||||
if (t_env) return t_env;
|
||||
if (!g_jvm) return NULL;
|
||||
JNIEnv *env = NULL;
|
||||
if ((*g_jvm)->GetEnv(g_jvm, (void **)&env, JNI_VERSION_1_6) != JNI_OK) {
|
||||
if ((*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL) != JNI_OK) return NULL;
|
||||
t_attached = 1;
|
||||
}
|
||||
return t_env = env;
|
||||
}
|
||||
|
||||
/* A window started presenting GPU frames (window = its description), or NULL when it closed. */
|
||||
void banner_on_game_surface(const char *window, const char *gpu) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_game_surface || !(env = thread_env())) return;
|
||||
jstring jw = window ? (*env)->NewStringUTF(env, window) : NULL;
|
||||
jstring jg = gpu ? (*env)->NewStringUTF(env, gpu) : NULL;
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_game_surface, jw, jg);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
if (jw) (*env)->DeleteLocalRef(env, jw);
|
||||
if (jg) (*env)->DeleteLocalRef(env, jg);
|
||||
}
|
||||
|
||||
/* The program behind the game window that just started presenting: its Linux pid and executable name
|
||||
* ("" = unknown). The app arms its launch-time CPU affinity on it. Compositor thread. */
|
||||
void banner_on_game_program(int pid, const char *program) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_game_program || !(env = thread_env())) return;
|
||||
jstring jp = (*env)->NewStringUTF(env, program ? program : "");
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_game_program, (jint)pid, jp);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
if (jp) (*env)->DeleteLocalRef(env, jp);
|
||||
}
|
||||
|
||||
/* One GPU frame from that window. */
|
||||
void banner_on_game_frame(void) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_game_frame || !(env = thread_env())) return;
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_game_frame);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
}
|
||||
|
||||
/* A program locked the pointer (locked = 1; the app's input path switches to deltas) or the lock
|
||||
* ended (locked = 0; x,y = where the pointer is now, in scene coordinates, for the app to re-sync
|
||||
* its own pointer to). Compositor thread. */
|
||||
void banner_on_pointer_lock(int locked, int x, int y) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_pointer_lock || !(env = thread_env())) return;
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_pointer_lock, (jboolean)(locked != 0), (jint)x, (jint)y);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
}
|
||||
|
||||
/* A program copied text (UTF-8, not NUL-terminated for the app's sake — a byte[] so emoji and
|
||||
* NULs survive JNI). Compositor thread. */
|
||||
void banner_on_clipboard_text(const char *utf8, int len) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_clipboard || !(env = thread_env())) return;
|
||||
jbyteArray arr = (*env)->NewByteArray(env, len);
|
||||
if (!arr) { (*env)->ExceptionClear(env); return; }
|
||||
(*env)->SetByteArrayRegion(env, arr, 0, len, (const jbyte *)utf8);
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_clipboard, arr);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
(*env)->DeleteLocalRef(env, arr);
|
||||
}
|
||||
|
||||
/* A program started (enabled) or stopped accepting IME text; x,y,w,h = its caret rectangle in
|
||||
* scene pixels (all 0 = unknown). Compositor thread. */
|
||||
void banner_on_text_input(int enabled, const char *program, int x, int y, int w, int h) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_text_input || !(env = thread_env())) return;
|
||||
jstring jp = (*env)->NewStringUTF(env, program ? program : "");
|
||||
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_text_input, (jboolean)(enabled != 0), jp,
|
||||
(jint)x, (jint)y, (jint)w, (jint)h);
|
||||
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
|
||||
if (jp) (*env)->DeleteLocalRef(env, jp);
|
||||
}
|
||||
|
||||
/* android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY: the level the hwui RenderThread runs at. */
|
||||
#define COMPOSITOR_NICE (-8)
|
||||
|
||||
static void *comp_thread(void *arg) {
|
||||
(void)arg;
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "compositor thread starting");
|
||||
/* Every buffer release, frame callback and layer transaction of the session goes through this one
|
||||
* thread. It is named, so `ps -T`, the logs and the drawer's Thread Priority Boost (PerfPriority
|
||||
* matches thread names) can find it, and it runs at display priority instead of whatever the
|
||||
* thread that started it had. Never lowered: a thread that already runs hotter keeps its value. */
|
||||
pthread_setname_np(pthread_self(), "wl-compositor");
|
||||
const id_t tid = (id_t)gettid();
|
||||
errno = 0;
|
||||
const int before = getpriority(PRIO_PROCESS, tid);
|
||||
int refused = 0;
|
||||
if (before > COMPOSITOR_NICE && setpriority(PRIO_PROCESS, tid, COMPOSITOR_NICE) != 0) refused = errno ? errno : -1;
|
||||
const int after = getpriority(PRIO_PROCESS, tid);
|
||||
if (refused)
|
||||
banner_log("perf", "compositor thread %d \"wl-compositor\": stays at nice %d, a higher priority was refused (%s)",
|
||||
(int)tid, after, refused > 0 ? strerror(refused) : "?");
|
||||
else
|
||||
banner_log("perf", "compositor thread %d \"wl-compositor\": nice %d -> %d", (int)tid, before, after);
|
||||
banner_wayland_run();
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "compositor thread exited");
|
||||
if (t_attached) (*g_jvm)->DetachCurrentThread(g_jvm);
|
||||
t_env = NULL; t_attached = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void set_runtime_dir(JNIEnv *env, jstring xdgRuntimeDir) {
|
||||
if (!xdgRuntimeDir) return;
|
||||
const char *dir = (*env)->GetStringUTFChars(env, xdgRuntimeDir, NULL);
|
||||
if (dir) {
|
||||
setenv("XDG_RUNTIME_DIR", dir, 1);
|
||||
(*env)->ReleaseStringUTFChars(env, xdgRuntimeDir, dir);
|
||||
}
|
||||
}
|
||||
|
||||
static void start_thread(void) {
|
||||
pthread_t t;
|
||||
if (pthread_create(&t, NULL, comp_thread, NULL) == 0)
|
||||
pthread_detach(t);
|
||||
else
|
||||
__android_log_print(ANDROID_LOG_ERROR, TAG, "pthread_create failed");
|
||||
}
|
||||
|
||||
/* Headless start (no output window) — used for bring-up tests. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeStart(JNIEnv *env, jclass clazz,
|
||||
jstring xdgRuntimeDir) {
|
||||
set_runtime_dir(env, xdgRuntimeDir);
|
||||
start_thread();
|
||||
}
|
||||
|
||||
static char *dup_jstr(JNIEnv *env, jstring s) {
|
||||
if (!s) return NULL;
|
||||
const char *c = (*env)->GetStringUTFChars(env, s, NULL);
|
||||
char *out = c ? strdup(c) : NULL;
|
||||
if (c) (*env)->ReleaseStringUTFChars(env, s, c);
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Start with a real output Surface + the container's Turnip driver (adrenotools).
|
||||
* Frames committed by clients are composited to this Surface via Turnip. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeStartWithSurface(
|
||||
JNIEnv *env, jclass clazz, jobject surface, jstring xdgRuntimeDir,
|
||||
jstring driverPath, jstring libraryName, jstring nativeLibDir) {
|
||||
set_runtime_dir(env, xdgRuntimeDir);
|
||||
char *dp = dup_jstr(env, driverPath);
|
||||
char *ln = dup_jstr(env, libraryName);
|
||||
char *nl = dup_jstr(env, nativeLibDir);
|
||||
vk_present_set_driver(dp, ln, nl);
|
||||
free(dp); free(ln); free(nl);
|
||||
if (surface) {
|
||||
ANativeWindow *win = ANativeWindow_fromSurface(env, surface);
|
||||
vk_present_set_window(win); /* backend acquires; released on nativeSetSurface(null) */
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "output window bound (%p)", (void *)win);
|
||||
}
|
||||
start_thread();
|
||||
}
|
||||
|
||||
/* Inject a pointer event from the Android SurfaceView touch listener (UI thread).
|
||||
* action: 0=down 1=move 2=up; x/y in output space (0..1919, 0..1079). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSendPointer(
|
||||
JNIEnv *env, jclass clazz, jint action, jint x, jint y) {
|
||||
banner_wayland_send_pointer(action, x, y);
|
||||
}
|
||||
|
||||
/* Inject a key event. evdev = Linux input keycode (KEY_A=30…); state 1=down 0=up. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSendKey(
|
||||
JNIEnv *env, jclass clazz, jint evdev, jint state) {
|
||||
banner_wayland_send_key(evdev, state);
|
||||
}
|
||||
|
||||
/* App X-server input in scene (virtual desktop) coordinates; see banner_wayland_send_scene_input. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSendSceneInput(
|
||||
JNIEnv *env, jclass clazz, jint type, jint a, jint b) {
|
||||
banner_wayland_send_scene_input(type, a, b);
|
||||
}
|
||||
|
||||
/* One screen refresh (Choreographer frame callback, UI thread): the compositor draws once. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeVsync(JNIEnv *env, jclass clazz, jlong frameTimeNanos) {
|
||||
banner_wayland_vsync((int64_t)frameTimeNanos);
|
||||
}
|
||||
|
||||
/* Shortcut launches: don't draw explorer's windows (desktop, taskbar), like X11's unviewable classes. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHideShell(JNIEnv *env, jclass clazz, jboolean hide) {
|
||||
g_hide_shell = hide ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Zero-copy layer mode (BANNER_WAYLAND_ZERO_COPY=1 at launch, the drawer's switch live): one fullscreen
|
||||
* window on its own Android layer instead of the swapchain blit (sc_layer.c / ahb_swapchain.c). Any
|
||||
* thread, any time: before the compositor starts it is the launch default; afterwards the compositor
|
||||
* thread flips the state, tells the bound games to rebuild their swapchains for it and redraws. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetZeroCopy(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
int live = banner_get_display() != NULL;
|
||||
if (!live) g_zero_copy = on ? 1 : 0; /* read by ahb_swapchain_init before the queue drains */
|
||||
banner_host_zero_copy(on ? 1 : 0, live);
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "zero-copy layer mode %s%s", on ? "on" : "off", live ? " (live)" : "");
|
||||
}
|
||||
|
||||
/* Milliseconds since the compositor last put a game frame on the layer without a copy; -1 = never
|
||||
* this session. The drawer's status line ("switching..." until the frames arrive / stop). */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeZeroCopyLastFrameAgeMs(JNIEnv *env, jclass clazz) {
|
||||
return (jint)ahb_swapchain_last_frame_age_ms();
|
||||
}
|
||||
|
||||
/* Zero-copy frames in the last completed 10 s stats window (on_stats_timer), for the drawer's live line. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeZeroCopyFrames(JNIEnv *env, jclass clazz) {
|
||||
return (jint)g_zero_copy_last;
|
||||
}
|
||||
|
||||
/* Compressed (UBWC) game buffers: advertise DRM_FORMAT_MOD_QCOM_COMPRESSED on zwp_linux_dmabuf_v1 when
|
||||
* the renderer's driver imports it (default on; BANNER_WAYLAND_UBWC=0 = off). Set before the compositor
|
||||
* starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetUbwc(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
g_ubwc = on ? 1 : 0;
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "compressed (UBWC) game buffers %s", on ? "on" : "off");
|
||||
}
|
||||
|
||||
/* Debug: name no DRM device in the dma-buf feedback (BANNER_WAYLAND_NO_RENDER_NODE=1), the way a
|
||||
* phone that exposes no /dev/dri node to apps does. Set before the compositor starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetNoRenderNode(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
g_no_render_node = on ? 1 : 0;
|
||||
if (on) __android_log_print(ANDROID_LOG_INFO, TAG, "debug: advertising no DRM device (main device 0:0)");
|
||||
}
|
||||
|
||||
/* VRR / refresh-rate matching: the rate the app is voting for the panel, mirrored onto the game's
|
||||
* own SurfaceControl layer. Under zero-copy the game's frames bypass the app's surface entirely, so
|
||||
* without this SurfaceFlinger never sees the game's cadence. 0 = clear the vote. Any thread, any
|
||||
* time; the compositor applies it with its next layer transaction and logs the change. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetLayerFrameRate(JNIEnv *env, jclass clazz, jfloat hz) {
|
||||
(void)env; (void)clazz;
|
||||
sc_layer_set_frame_rate((float)hz);
|
||||
}
|
||||
|
||||
/* The panel's refresh rate (Hz) for the advertised wl_output mode. Set before the compositor starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetOutputRefreshRate(JNIEnv *env, jclass clazz, jfloat hz) {
|
||||
g_output_refresh_mhz = hz > 1.0f ? (int)(hz * 1000.0f + 0.5f) : 0;
|
||||
}
|
||||
|
||||
/* The container's screen size for the advertised wl_output mode. Set before the compositor starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetOutputSize(JNIEnv *env, jclass clazz, jint w, jint h) {
|
||||
g_output_w = w > 0 ? w : 0;
|
||||
g_output_h = h > 0 ? h : 0;
|
||||
}
|
||||
|
||||
/* Fullscreen mode + screen alignment (Container.FULLSCREEN_* / ALIGN_* values): how the scene is
|
||||
* fitted onto the output. Any thread, any time; the next frame uses it. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetScaleMode(JNIEnv *env, jclass clazz, jint mode, jint alignment) {
|
||||
vk_present_set_scale_mode(mode, alignment);
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "scale mode %d alignment %d", mode, alignment);
|
||||
}
|
||||
|
||||
/* ---- screen effects (effects_chain.c): the X11 Vulkan renderer's post chain in the compositor.
|
||||
* Any thread, any time; the compositor thread applies them on its next frame and logs one
|
||||
* `effects` line per change. Values are 1:1 with VulkanRenderer's setters. */
|
||||
|
||||
/* Scaling mode: 0=None 1=Linear 2=Nearest 3=SGSR 4=FSR 5=FSR Fit 6=Sharpen 7=NIS 8=SGSR HQ. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetUpscaler(JNIEnv *env, jclass clazz, jint mode) {
|
||||
vkp_effects_set_scaling(mode);
|
||||
}
|
||||
|
||||
/* The upscaler's sharpness slider 0..100 (RCAS lobe / SGSR edge / NIS sharpness). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetUpscaleSharpness(JNIEnv *env, jclass clazz, jint sharpness) {
|
||||
vkp_effects_set_upscale_sharpness(sharpness);
|
||||
}
|
||||
|
||||
/* AMD CAS sharpen toggle + level 0..100 (0 = pass off). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetCas(JNIEnv *env, jclass clazz, jboolean enabled, jint sharpness) {
|
||||
vkp_effects_set_cas(enabled ? 1 : 0, sharpness);
|
||||
}
|
||||
|
||||
/* Fake-HDR toggle. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHdr(JNIEnv *env, jclass clazz, jboolean enabled) {
|
||||
vkp_effects_set_hdr(enabled ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Terminal debanding toggle + strength 0..200 (100 = 1 LSB). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetDeband(JNIEnv *env, jclass clazz, jboolean enabled, jint strength) {
|
||||
vkp_effects_set_deband(enabled ? 1 : 0, strength);
|
||||
}
|
||||
|
||||
/* Colour grade (slider units: brightness/contrast -100..100, gamma 0.5..3, saturation 0..200 %) and the
|
||||
* FXAA / Toon / CRT / NTSC toggles — VulkanRenderer.setScreenEffects. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetScreenEffects(JNIEnv *env, jclass clazz, jfloat brightness,
|
||||
jfloat contrast, jfloat gamma, jfloat saturation, jboolean fxaa, jboolean toon, jboolean crt, jboolean ntsc) {
|
||||
vkp_effects_set_screen(brightness, contrast, gamma, saturation, fxaa ? 1 : 0, toon ? 1 : 0, crt ? 1 : 0, ntsc ? 1 : 0);
|
||||
}
|
||||
|
||||
/* One "display" line in the session log, written from Java: facts that live in the Android
|
||||
* framework (the panel's HDR capability) rather than in the compositor. banner_log() mirrors to
|
||||
* logcat and appends to the session file when one is open, so this is safe at any point. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeLogDisplay(JNIEnv *env, jclass clazz, jstring message) {
|
||||
char *s = dup_jstr(env, message);
|
||||
if (s) banner_log("display", "%s", s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* The same under the "perf" area: facts the app knows about the session's performance setup (the CPU
|
||||
* cores the game is pinned to, say). Same safety as nativeLogDisplay. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeLogPerf(JNIEnv *env, jclass clazz, jstring message) {
|
||||
char *s = dup_jstr(env, message);
|
||||
if (s) banner_log("perf", "%s", s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* ---- HDR10 output, round 1 (banner_color.h / wl_color_mgmt.c) ---- */
|
||||
|
||||
/* The opt-in: mode 0 off, 1 BANNER_WAYLAND_HDR=1, 2 =force (testing). Before the compositor starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHdrRequest(JNIEnv *env, jclass clazz, jint mode,
|
||||
jstring source, jboolean dxvkHdr, jboolean zeroCopyForced) {
|
||||
char *s = dup_jstr(env, source);
|
||||
banner_color_set_request((int)mode, s, dxvkHdr ? 1 : 0, zeroCopyForced ? 1 : 0);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* The game's display as android.view.Display reports it (before the start; again on every change). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHdrDisplay(JNIEnv *env, jclass clazz, jint id, jstring name,
|
||||
jstring formats, jboolean hdr10, jfloat maxLum, jfloat maxAvg, jfloat minLum, jboolean ratioAvailable,
|
||||
jfloat ratio, jint api) {
|
||||
char *n = dup_jstr(env, name), *f = dup_jstr(env, formats);
|
||||
banner_color_set_display((int)id, n, f, hdr10 ? 1 : 0, (float)maxLum, (float)maxAvg, (float)minLum,
|
||||
ratioAvailable ? 1 : 0, (float)ratio, (int)api);
|
||||
free(n); free(f);
|
||||
}
|
||||
|
||||
/* One Display.getHdrSdrRatio() reading (listener = from the display's ratio listener). Any thread. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrSdrRatioSample(JNIEnv *env, jclass clazz, jfloat ratio,
|
||||
jboolean listener) {
|
||||
banner_color_ratio_sample((float)ratio, listener ? 1 : 0);
|
||||
}
|
||||
|
||||
/* ms since an HDR frame last reached a display layer, -1 = never this session. Any thread. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrLastFrameAgeMs(JNIEnv *env, jclass clazz) {
|
||||
return (jint)banner_color_last_frame_age_ms();
|
||||
}
|
||||
|
||||
/* -1 = not decided yet, 0 = closed, 1 = open. Any thread. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrGateState(JNIEnv *env, jclass clazz) {
|
||||
return (jint)banner_color_gate_state();
|
||||
}
|
||||
|
||||
/* The session is ending: the "HDR on screen: ..." summary line. Any thread, once. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrSessionEnd(JNIEnv *env, jclass clazz) {
|
||||
banner_color_session_end();
|
||||
}
|
||||
|
||||
/* HDR frames really on screen right now (the HUD badge). Any thread. */
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrOnScreen(JNIEnv *env, jclass clazz) {
|
||||
return banner_color_hdr_on_screen() ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/* One "color" line in the session log from Java. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeLogColor(JNIEnv *env, jclass clazz, jstring message) {
|
||||
char *s = dup_jstr(env, message);
|
||||
if (s) banner_log("color", "%s", s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* One line in the session log under an area Java names ("gpu", "nvapi"): launch facts the app decides.
|
||||
* The area is the log's 9-character column; an empty one reads "app". */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeLog(JNIEnv *env, jclass clazz, jstring area, jstring message) {
|
||||
char *a = dup_jstr(env, area), *s = dup_jstr(env, message);
|
||||
if (s) banner_log(a && a[0] ? a : "app", "%s", s);
|
||||
free(a);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* SDR content's level inside an HDR picture, in nits (default 203). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHdrSdrWhite(JNIEnv *env, jclass clazz, jfloat nits) {
|
||||
banner_color_set_sdr_white((float)nits);
|
||||
}
|
||||
|
||||
/* The drawer's live HDR output switch: on = HDR frames as HDR, off = the same frames tone-mapped to SDR.
|
||||
* Applied on the compositor thread (logged there, with a redraw). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHdrOutput(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
if (banner_get_display()) banner_host_hdr_output(on ? 1 : 0);
|
||||
else banner_color_set_output(on ? 1 : 0); /* no compositor thread yet: nothing is drawing either */
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrOutput(JNIEnv *env, jclass clazz) {
|
||||
return banner_color_output() ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/* Device evidence for the HDR lines: thermal status + headroom, brightness + mode. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrEnvSample(JNIEnv *env, jclass clazz, jint thermal,
|
||||
jfloat headroom, jint brightness, jint mode) {
|
||||
banner_color_env_sample((int)thermal, (float)headroom != (float)headroom ? -1.0f : (float)headroom,
|
||||
(int)brightness, (int)mode);
|
||||
}
|
||||
|
||||
/* Display.getHighestHdrSdrRatio() (Android 16+), <= 0 = not reported. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetHdrHighestRatio(JNIEnv *env, jclass clazz, jfloat ratio) {
|
||||
banner_color_set_highest_ratio((float)ratio == (float)ratio ? (float)ratio : -1.0f);
|
||||
}
|
||||
|
||||
/* The HDR headroom the screen surface should ask for (HDR10 swapchain frames in the last 1.5 s), 0 = none. */
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrScreenHeadroom(JNIEnv *env, jclass clazz) {
|
||||
return (jfloat)banner_color_screen_headroom(NULL, 0);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrScreenHeadroomWhy(JNIEnv *env, jclass clazz) {
|
||||
char why[200];
|
||||
banner_color_screen_headroom(why, sizeof(why));
|
||||
return (*env)->NewStringUTF(env, why);
|
||||
}
|
||||
|
||||
/* The app's screen-surface request, for the no-headroom lines: > 0 asked, 0 cleared, -1 not possible. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrNoteHeadroomRequest(JNIEnv *env, jclass clazz, jfloat ratio) {
|
||||
banner_color_note_headroom_request((float)ratio);
|
||||
}
|
||||
|
||||
/* 0 none, 1 HDR frames on screen with headroom, 2 HDR frames on screen without headroom for 5 s+. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrState(JNIEnv *env, jclass clazz) {
|
||||
return (jint)banner_color_hdr_state();
|
||||
}
|
||||
|
||||
/* An HDR game's frames were shown tone-mapped to SDR in the last 1.5 s (the drawer's status line). */
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeHdrToneMappedOnScreen(JNIEnv *env, jclass clazz) {
|
||||
return banner_color_tonemapped_on_screen() ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/* The Look the controls currently match (null = Custom) — only named in the session log. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetLookName(JNIEnv *env, jclass clazz, jstring name) {
|
||||
char *s = dup_jstr(env, name);
|
||||
vkp_effects_set_look(s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* The in-game FPS limiter: frames per second, 0 = unlimited. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetFpsLimit(JNIEnv *env, jclass clazz, jint fps) {
|
||||
g_fps_limit = fps > 0 ? fps : 0;
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "fps limit %d", fps);
|
||||
}
|
||||
|
||||
/* Swap/clear the output window (e.g. SurfaceView recreated/destroyed). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetSurface(
|
||||
JNIEnv *env, jclass clazz, jobject surface) {
|
||||
if (surface) {
|
||||
vk_present_set_window(ANativeWindow_fromSurface(env, surface));
|
||||
} else {
|
||||
vk_present_set_window(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- clipboard + text input (any thread; queued to the compositor thread) ----
|
||||
* Text crosses as UTF-8 byte arrays: JNI's modified UTF-8 would mangle emoji. */
|
||||
|
||||
static char *dup_bytes(JNIEnv *env, jbyteArray arr, int *len) {
|
||||
*len = 0;
|
||||
if (!arr) return NULL;
|
||||
jsize n = (*env)->GetArrayLength(env, arr);
|
||||
char *buf = malloc((size_t)n + 1);
|
||||
if (!buf) return NULL;
|
||||
if (n) (*env)->GetByteArrayRegion(env, arr, 0, n, (jbyte *)buf);
|
||||
buf[n] = 0;
|
||||
*len = (int)n;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Android's clipboard text becomes the guest's selection (empty/null = clear). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeSetClipboardText(JNIEnv *env, jclass clazz, jbyteArray utf8) {
|
||||
int len;
|
||||
char *buf = dup_bytes(env, utf8, &len);
|
||||
banner_host_clipboard_text(buf ? buf : "", len);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* Soft-keyboard text committed to the program accepting text input. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeTextInputCommit(JNIEnv *env, jclass clazz, jbyteArray utf8) {
|
||||
int len;
|
||||
char *buf = dup_bytes(env, utf8, &len);
|
||||
if (buf && len) banner_host_text_commit(buf, len);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* Composing (pre-edit) text; cursorBegin/cursorEnd are character indexes into it, -1 = end. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeTextInputPreedit(JNIEnv *env, jclass clazz, jbyteArray utf8,
|
||||
jint cursorBegin, jint cursorEnd) {
|
||||
int len;
|
||||
char *buf = dup_bytes(env, utf8, &len);
|
||||
banner_host_text_preedit(buf ? buf : "", len, cursorBegin, cursorEnd);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* The IME deleted characters around the caret. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_the412banner_steamdeck_wayland_WaylandCompositor_nativeTextInputDelete(JNIEnv *env, jclass clazz, jint before, jint after) {
|
||||
banner_host_text_delete(before, after);
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
/*
|
||||
* Clipboard: wl_data_device_manager (core, v3) and zwlr_data_control_manager_v1 (v1), selection
|
||||
* only — drag and drop is refused. Both protocols share one selection:
|
||||
*
|
||||
* owner CLIENT a program's wl_data_source / zwlr_data_control_source_v1 (its mime list)
|
||||
* owner HOST text the app pushed from Android's clipboard (offered under the text mimes)
|
||||
* owner NONE nothing
|
||||
*
|
||||
* Every selection change is announced to every data-control device (they see the selection
|
||||
* regardless of focus, as the protocol says) and to the wl_data_devices of the client holding
|
||||
* keyboard focus; a client also gets the current selection when its keyboard focus arrives.
|
||||
*
|
||||
* winewayland prefers zwlr_data_control (it then runs the clipboard from the desktop process
|
||||
* without needing keyboard focus) and tags its own offers with application/x.winewayland.tag
|
||||
* so it can ignore them when they come back; we pass mime lists through untouched.
|
||||
*
|
||||
* Guest → Android: when a program sets a selection with a text mime, the compositor asks for it
|
||||
* once over a pipe on the event loop (non-blocking, 1 MiB cap, 3 s timeout) and hands the text
|
||||
* to the app (banner_on_clipboard_text → ClipboardManager). Android → guest: the app's text
|
||||
* becomes the HOST selection; receive requests are answered with a non-blocking writer.
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include "banner_ext.h"
|
||||
#include "wlr-data-control-unstable-v1-server-protocol.h"
|
||||
|
||||
#define CLIP_MAX_BYTES (1024 * 1024)
|
||||
#define CLIP_READ_TIMEOUT_MS 3000
|
||||
#define CLIP_WRITE_TIMEOUT_MS 5000
|
||||
#define MAX_MIMES 64
|
||||
|
||||
static struct wl_display *g_disp;
|
||||
|
||||
enum owner { OWNER_NONE, OWNER_CLIENT, OWNER_HOST };
|
||||
static enum owner g_owner;
|
||||
static uint32_t g_gen; /* bumps on every selection change */
|
||||
|
||||
struct source { /* a client's data source (either protocol) */
|
||||
struct wl_resource *res;
|
||||
int is_control;
|
||||
char *mimes[MAX_MIMES];
|
||||
int nmimes;
|
||||
};
|
||||
static struct source *g_src; /* current CLIENT selection */
|
||||
|
||||
static char *g_host_text; /* current HOST selection */
|
||||
static size_t g_host_len;
|
||||
static const char *const k_text_mimes[] = {
|
||||
"text/plain;charset=utf-8", "text/plain", "UTF8_STRING", "TEXT", "STRING", NULL
|
||||
};
|
||||
|
||||
struct device {
|
||||
struct wl_resource *res;
|
||||
int is_control;
|
||||
struct wl_list link;
|
||||
};
|
||||
static struct wl_list g_devices;
|
||||
static struct wl_client *g_kb_client; /* keyboard focus holder */
|
||||
|
||||
struct offer {
|
||||
struct wl_resource *res;
|
||||
int is_control;
|
||||
uint32_t gen; /* the selection this offer describes */
|
||||
};
|
||||
|
||||
static char *g_last_guest_text; /* echo guard: the last text handed to Android */
|
||||
static size_t g_last_guest_len;
|
||||
|
||||
/* ------------------------------------------------------------------ helpers */
|
||||
|
||||
static int is_text_mime(const char *m) {
|
||||
for (int i = 0; k_text_mimes[i]; i++) if (!strcmp(m, k_text_mimes[i])) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *source_text_mime(const struct source *s) {
|
||||
for (int i = 0; k_text_mimes[i]; i++)
|
||||
for (int j = 0; j < s->nmimes; j++)
|
||||
if (!strcmp(s->mimes[j], k_text_mimes[i])) return s->mimes[j];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void source_send_send(struct source *s, const char *mime, int fd) {
|
||||
if (s->is_control) zwlr_data_control_source_v1_send_send(s->res, mime, fd);
|
||||
else wl_data_source_send_send(s->res, mime, fd);
|
||||
}
|
||||
|
||||
static void source_send_cancelled(struct source *s) {
|
||||
if (s->is_control) zwlr_data_control_source_v1_send_cancelled(s->res);
|
||||
else wl_data_source_send_cancelled(s->res);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ host → client writer */
|
||||
|
||||
struct writer {
|
||||
int fd;
|
||||
char *data;
|
||||
size_t len, off;
|
||||
struct wl_event_source *src, *timer;
|
||||
};
|
||||
|
||||
static void writer_free(struct writer *w) {
|
||||
if (w->src) wl_event_source_remove(w->src);
|
||||
if (w->timer) wl_event_source_remove(w->timer);
|
||||
close(w->fd);
|
||||
free(w->data);
|
||||
free(w);
|
||||
}
|
||||
|
||||
static int writer_pump(struct writer *w) {
|
||||
while (w->off < w->len) {
|
||||
ssize_t n = write(w->fd, w->data + w->off, w->len - w->off);
|
||||
if (n > 0) { w->off += (size_t)n; continue; }
|
||||
if (n < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) return 0; /* wait */
|
||||
if (n < 0 && errno == EINTR) continue;
|
||||
break; /* gone */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int on_writer_writable(int fd, uint32_t mask, void *data) {
|
||||
struct writer *w = data;
|
||||
if (mask & (WL_EVENT_ERROR | WL_EVENT_HANGUP) || writer_pump(w)) writer_free(w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_writer_timeout(void *data) {
|
||||
struct writer *w = data;
|
||||
banner_log("clipboard", "a program never read the clipboard text it asked for; giving up");
|
||||
writer_free(w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void writer_start(int fd, const char *data, size_t len) {
|
||||
struct writer *w = calloc(1, sizeof(*w));
|
||||
if (!w) { close(fd); return; }
|
||||
w->fd = fd;
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
|
||||
if (len && !(w->data = malloc(len))) { close(fd); free(w); return; }
|
||||
if (len) memcpy(w->data, data, len);
|
||||
w->len = len;
|
||||
if (writer_pump(w)) { writer_free(w); return; }
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(g_disp);
|
||||
w->src = wl_event_loop_add_fd(loop, fd, WL_EVENT_WRITABLE, on_writer_writable, w);
|
||||
w->timer = wl_event_loop_add_timer(loop, on_writer_timeout, w);
|
||||
if (w->timer) wl_event_source_timer_update(w->timer, CLIP_WRITE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ client → host reader */
|
||||
|
||||
struct reader {
|
||||
int fd;
|
||||
char *buf;
|
||||
size_t len;
|
||||
const char *mime; /* points into the source's list */
|
||||
struct wl_event_source *src, *timer;
|
||||
};
|
||||
static struct reader *g_reader;
|
||||
|
||||
static void reader_free(struct reader *r) {
|
||||
if (r->src) wl_event_source_remove(r->src);
|
||||
if (r->timer) wl_event_source_remove(r->timer);
|
||||
close(r->fd);
|
||||
free(r->buf);
|
||||
free(r);
|
||||
if (g_reader == r) g_reader = NULL;
|
||||
}
|
||||
|
||||
static void reader_finish(struct reader *r) {
|
||||
if (r->len > 0) {
|
||||
char *copy = malloc(r->len + 1);
|
||||
if (copy) {
|
||||
memcpy(copy, r->buf, r->len);
|
||||
copy[r->len] = 0;
|
||||
free(g_last_guest_text);
|
||||
g_last_guest_text = copy;
|
||||
g_last_guest_len = r->len;
|
||||
banner_log("clipboard", "guest copied %zu bytes (%s)", r->len, r->mime);
|
||||
banner_on_clipboard_text(copy, (int)r->len);
|
||||
}
|
||||
} else {
|
||||
banner_log("clipboard", "guest copied an empty text; Android clipboard left alone");
|
||||
}
|
||||
reader_free(r);
|
||||
}
|
||||
|
||||
static int on_reader_readable(int fd, uint32_t mask, void *data) {
|
||||
struct reader *r = data;
|
||||
for (;;) {
|
||||
if (r->len >= CLIP_MAX_BYTES) {
|
||||
banner_log("clipboard", "guest text exceeds %d bytes; dropped", CLIP_MAX_BYTES);
|
||||
reader_free(r);
|
||||
return 0;
|
||||
}
|
||||
size_t room = CLIP_MAX_BYTES - r->len, chunk = room < 65536 ? room : 65536;
|
||||
char *nb = realloc(r->buf, r->len + chunk);
|
||||
if (!nb) { reader_free(r); return 0; }
|
||||
r->buf = nb;
|
||||
ssize_t n = read(fd, r->buf + r->len, chunk);
|
||||
if (n > 0) { r->len += (size_t)n; continue; }
|
||||
if (n == 0) { reader_finish(r); return 0; } /* EOF */
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
if (mask & WL_EVENT_HANGUP) { reader_finish(r); return 0; }
|
||||
return 0;
|
||||
}
|
||||
if (errno == EINTR) continue;
|
||||
reader_free(r);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int on_reader_timeout(void *data) {
|
||||
struct reader *r = data;
|
||||
banner_log("clipboard", "timed out reading the guest's clipboard text (%zu bytes so far)", r->len);
|
||||
reader_free(r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ask the current client source for its text, once. */
|
||||
static void read_client_text(void) {
|
||||
const char *mime;
|
||||
int p[2];
|
||||
if (g_reader) reader_free(g_reader);
|
||||
if (!g_src || !(mime = source_text_mime(g_src))) return;
|
||||
if (pipe2(p, O_CLOEXEC) != 0) return;
|
||||
fcntl(p[0], F_SETFL, fcntl(p[0], F_GETFL) | O_NONBLOCK); /* our end only; the client writes blocking */
|
||||
struct reader *r = calloc(1, sizeof(*r));
|
||||
if (!r) { close(p[0]); close(p[1]); return; }
|
||||
r->fd = p[0];
|
||||
r->mime = mime;
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(g_disp);
|
||||
r->src = wl_event_loop_add_fd(loop, p[0], WL_EVENT_READABLE, on_reader_readable, r);
|
||||
r->timer = wl_event_loop_add_timer(loop, on_reader_timeout, r);
|
||||
if (r->timer) wl_event_source_timer_update(r->timer, CLIP_READ_TIMEOUT_MS);
|
||||
g_reader = r;
|
||||
source_send_send(g_src, mime, p[1]);
|
||||
close(p[1]);
|
||||
wl_display_flush_clients(g_disp);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ offers */
|
||||
|
||||
static void offer_res_destroy(struct wl_resource *r) { free(wl_resource_get_user_data(r)); }
|
||||
|
||||
static void offer_receive(struct wl_client *c, struct wl_resource *r, const char *mime, int32_t fd) {
|
||||
struct offer *o = wl_resource_get_user_data(r);
|
||||
if (!o || o->gen != g_gen) { close(fd); return; } /* stale offer */
|
||||
if (g_owner == OWNER_HOST) {
|
||||
if (is_text_mime(mime)) {
|
||||
banner_log("clipboard", "Android clipboard → guest (%zu bytes) for %s", g_host_len, banner_client_name(c));
|
||||
writer_start(fd, g_host_text, g_host_len);
|
||||
} else {
|
||||
close(fd);
|
||||
}
|
||||
} else if (g_owner == OWNER_CLIENT && g_src) {
|
||||
source_send_send(g_src, mime, fd); /* libwayland dups the fd */
|
||||
close(fd);
|
||||
wl_display_flush_clients(g_disp);
|
||||
} else {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
static void offer_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void offer_accept(struct wl_client *c, struct wl_resource *r, uint32_t serial, const char *mime) {}
|
||||
static void offer_finish(struct wl_client *c, struct wl_resource *r) {}
|
||||
static void offer_set_actions(struct wl_client *c, struct wl_resource *r, uint32_t a, uint32_t p) {}
|
||||
|
||||
static const struct wl_data_offer_interface data_offer_impl = {
|
||||
.accept = offer_accept, .receive = offer_receive, .destroy = offer_destroy,
|
||||
.finish = offer_finish, .set_actions = offer_set_actions,
|
||||
};
|
||||
static const struct zwlr_data_control_offer_v1_interface control_offer_impl = {
|
||||
.receive = offer_receive, .destroy = offer_destroy,
|
||||
};
|
||||
|
||||
/* Tell one device what the selection is now (a fresh offer, or nothing). */
|
||||
static void device_send_selection(struct device *d) {
|
||||
struct wl_client *c = wl_resource_get_client(d->res);
|
||||
if (g_owner == OWNER_NONE) {
|
||||
if (d->is_control) zwlr_data_control_device_v1_send_selection(d->res, NULL);
|
||||
else wl_data_device_send_selection(d->res, NULL);
|
||||
return;
|
||||
}
|
||||
struct offer *o = calloc(1, sizeof(*o));
|
||||
if (!o) return;
|
||||
o->is_control = d->is_control;
|
||||
o->gen = g_gen;
|
||||
if (d->is_control) {
|
||||
o->res = wl_resource_create(c, &zwlr_data_control_offer_v1_interface, 1, 0);
|
||||
if (!o->res) { free(o); return; }
|
||||
wl_resource_set_implementation(o->res, &control_offer_impl, o, offer_res_destroy);
|
||||
zwlr_data_control_device_v1_send_data_offer(d->res, o->res);
|
||||
} else {
|
||||
o->res = wl_resource_create(c, &wl_data_offer_interface, wl_resource_get_version(d->res), 0);
|
||||
if (!o->res) { free(o); return; }
|
||||
wl_resource_set_implementation(o->res, &data_offer_impl, o, offer_res_destroy);
|
||||
wl_data_device_send_data_offer(d->res, o->res);
|
||||
}
|
||||
if (g_owner == OWNER_CLIENT && g_src) {
|
||||
for (int i = 0; i < g_src->nmimes; i++) {
|
||||
if (d->is_control) zwlr_data_control_offer_v1_send_offer(o->res, g_src->mimes[i]);
|
||||
else wl_data_offer_send_offer(o->res, g_src->mimes[i]);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; k_text_mimes[i]; i++) {
|
||||
if (d->is_control) zwlr_data_control_offer_v1_send_offer(o->res, k_text_mimes[i]);
|
||||
else wl_data_offer_send_offer(o->res, k_text_mimes[i]);
|
||||
}
|
||||
}
|
||||
if (d->is_control) zwlr_data_control_device_v1_send_selection(d->res, o->res);
|
||||
else wl_data_device_send_selection(d->res, o->res);
|
||||
}
|
||||
|
||||
/* The selection changed: every data-control device hears it; wl_data_devices only if their
|
||||
* client holds keyboard focus. */
|
||||
static void broadcast_selection(void) {
|
||||
struct device *d;
|
||||
g_gen++;
|
||||
wl_list_for_each(d, &g_devices, link) {
|
||||
if (d->is_control || (g_kb_client && wl_resource_get_client(d->res) == g_kb_client))
|
||||
device_send_selection(d);
|
||||
}
|
||||
wl_display_flush_clients(g_disp);
|
||||
}
|
||||
|
||||
void banner_clipboard_keyboard_focus(struct wl_client *client) {
|
||||
struct device *d;
|
||||
if (client == g_kb_client) return;
|
||||
g_kb_client = client;
|
||||
if (!client) return;
|
||||
wl_list_for_each(d, &g_devices, link)
|
||||
if (!d->is_control && wl_resource_get_client(d->res) == client) device_send_selection(d);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ sources */
|
||||
|
||||
static void source_res_destroy(struct wl_resource *r) {
|
||||
struct source *s = wl_resource_get_user_data(r);
|
||||
if (!s) return;
|
||||
if (g_src == s) {
|
||||
g_src = NULL;
|
||||
g_owner = OWNER_NONE;
|
||||
if (g_reader) reader_free(g_reader);
|
||||
banner_log("clipboard", "%s withdrew its clipboard contents", banner_client_name(wl_resource_get_client(r)));
|
||||
broadcast_selection();
|
||||
}
|
||||
for (int i = 0; i < s->nmimes; i++) free(s->mimes[i]);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static void source_offer(struct wl_client *c, struct wl_resource *r, const char *mime) {
|
||||
struct source *s = wl_resource_get_user_data(r);
|
||||
if (!s || s->nmimes >= MAX_MIMES) return;
|
||||
if (!(s->mimes[s->nmimes] = strdup(mime))) return;
|
||||
s->nmimes++;
|
||||
}
|
||||
static void source_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void source_set_actions(struct wl_client *c, struct wl_resource *r, uint32_t actions) {}
|
||||
|
||||
static const struct wl_data_source_interface data_source_impl = {
|
||||
.offer = source_offer, .destroy = source_destroy, .set_actions = source_set_actions,
|
||||
};
|
||||
static const struct zwlr_data_control_source_v1_interface control_source_impl = {
|
||||
.offer = source_offer, .destroy = source_destroy,
|
||||
};
|
||||
|
||||
static void create_source(struct wl_client *c, uint32_t id, int is_control, uint32_t ver) {
|
||||
struct source *s = calloc(1, sizeof(*s));
|
||||
if (!s) { wl_client_post_no_memory(c); return; }
|
||||
s->is_control = is_control;
|
||||
s->res = wl_resource_create(c, is_control ? &zwlr_data_control_source_v1_interface
|
||||
: &wl_data_source_interface, ver, id);
|
||||
if (!s->res) { free(s); wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(s->res, is_control ? (const void *)&control_source_impl
|
||||
: (const void *)&data_source_impl,
|
||||
s, source_res_destroy);
|
||||
}
|
||||
|
||||
/* A device set (or cleared) the selection. */
|
||||
static void set_selection(struct wl_client *c, struct wl_resource *source_res) {
|
||||
struct source *s = source_res ? wl_resource_get_user_data(source_res) : NULL;
|
||||
if (s && s == g_src) return;
|
||||
if (g_src && g_src != s) source_send_cancelled(g_src);
|
||||
if (g_reader) reader_free(g_reader);
|
||||
free(g_host_text); g_host_text = NULL; g_host_len = 0;
|
||||
g_src = s;
|
||||
g_owner = s ? OWNER_CLIENT : OWNER_NONE;
|
||||
if (s) {
|
||||
char list[200] = "";
|
||||
for (int i = 0; i < s->nmimes && strlen(list) < 150; i++) {
|
||||
if (!strncmp(s->mimes[i], "application/x.winewayland", 25)) continue;
|
||||
if (*list) strncat(list, ", ", sizeof(list) - strlen(list) - 1);
|
||||
strncat(list, s->mimes[i], sizeof(list) - strlen(list) - 1);
|
||||
}
|
||||
banner_log("clipboard", "selection set by %s (%s)", banner_client_name(c), *list ? list : "no mime types");
|
||||
} else {
|
||||
banner_log("clipboard", "%s cleared the clipboard", banner_client_name(c));
|
||||
}
|
||||
broadcast_selection();
|
||||
read_client_text();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ devices */
|
||||
|
||||
static void device_res_destroy(struct wl_resource *r) {
|
||||
struct device *d = wl_resource_get_user_data(r);
|
||||
if (!d) return;
|
||||
wl_list_remove(&d->link);
|
||||
free(d);
|
||||
}
|
||||
|
||||
static void device_start_drag(struct wl_client *c, struct wl_resource *r, struct wl_resource *source,
|
||||
struct wl_resource *origin, struct wl_resource *icon, uint32_t serial) {
|
||||
banner_log("clipboard", "%s started a drag and drop; not supported, cancelled", banner_client_name(c));
|
||||
if (source) {
|
||||
struct source *s = wl_resource_get_user_data(source);
|
||||
if (s && s != g_src) source_send_cancelled(s);
|
||||
}
|
||||
}
|
||||
static void device_set_selection(struct wl_client *c, struct wl_resource *r, struct wl_resource *source, uint32_t serial) {
|
||||
set_selection(c, source);
|
||||
}
|
||||
static void device_release(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void control_device_set_selection(struct wl_client *c, struct wl_resource *r, struct wl_resource *source) {
|
||||
set_selection(c, source);
|
||||
}
|
||||
static void control_device_set_primary(struct wl_client *c, struct wl_resource *r, struct wl_resource *source) {
|
||||
/* No primary selection on Android; a source given here just gets cancelled. */
|
||||
if (source) {
|
||||
struct source *s = wl_resource_get_user_data(source);
|
||||
if (s && s != g_src) source_send_cancelled(s);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_data_device_interface data_device_impl = {
|
||||
.start_drag = device_start_drag, .set_selection = device_set_selection, .release = device_release,
|
||||
};
|
||||
static const struct zwlr_data_control_device_v1_interface control_device_impl = {
|
||||
.set_selection = control_device_set_selection, .destroy = device_release,
|
||||
.set_primary_selection = control_device_set_primary,
|
||||
};
|
||||
|
||||
static void create_device(struct wl_client *c, uint32_t id, int is_control, uint32_t ver) {
|
||||
struct device *d = calloc(1, sizeof(*d));
|
||||
if (!d) { wl_client_post_no_memory(c); return; }
|
||||
d->is_control = is_control;
|
||||
d->res = wl_resource_create(c, is_control ? &zwlr_data_control_device_v1_interface
|
||||
: &wl_data_device_interface, ver, id);
|
||||
if (!d->res) { free(d); wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(d->res, is_control ? (const void *)&control_device_impl
|
||||
: (const void *)&data_device_impl,
|
||||
d, device_res_destroy);
|
||||
wl_list_insert(&g_devices, &d->link);
|
||||
/* Data-control devices see the selection at once; wl_data_devices when focus arrives. */
|
||||
if (is_control || (g_kb_client && c == g_kb_client)) device_send_selection(d);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ managers */
|
||||
|
||||
static void dm_create_source(struct wl_client *c, struct wl_resource *r, uint32_t id) {
|
||||
create_source(c, id, 0, wl_resource_get_version(r));
|
||||
}
|
||||
static void dm_get_device(struct wl_client *c, struct wl_resource *r, uint32_t id, struct wl_resource *seat) {
|
||||
create_device(c, id, 0, wl_resource_get_version(r));
|
||||
}
|
||||
static void dm_release(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static const struct wl_data_device_manager_interface dm_impl = {
|
||||
.create_data_source = dm_create_source, .get_data_device = dm_get_device, .release = dm_release,
|
||||
};
|
||||
static void bind_data_device_manager(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
struct wl_resource *r = wl_resource_create(c, &wl_data_device_manager_interface, ver, id);
|
||||
if (!r) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(r, &dm_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
static void cm_create_source(struct wl_client *c, struct wl_resource *r, uint32_t id) {
|
||||
create_source(c, id, 1, 1);
|
||||
}
|
||||
static void cm_get_device(struct wl_client *c, struct wl_resource *r, uint32_t id, struct wl_resource *seat) {
|
||||
create_device(c, id, 1, wl_resource_get_version(r));
|
||||
}
|
||||
static void cm_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static const struct zwlr_data_control_manager_v1_interface cm_impl = {
|
||||
.create_data_source = cm_create_source, .get_data_device = cm_get_device, .destroy = cm_destroy,
|
||||
};
|
||||
static void bind_data_control_manager(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
struct wl_resource *r = wl_resource_create(c, &zwlr_data_control_manager_v1_interface, ver, id);
|
||||
if (!r) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(r, &cm_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ host side */
|
||||
|
||||
/* Android's clipboard text (compositor thread, via the host queue). Takes the buffer. */
|
||||
void clipboard_host_text(char *utf8, size_t len) {
|
||||
if (len && g_last_guest_text && len == g_last_guest_len && !memcmp(utf8, g_last_guest_text, len)) {
|
||||
free(utf8); /* our own copy coming back: not a change */
|
||||
return;
|
||||
}
|
||||
if (len && g_owner == OWNER_HOST && g_host_len == len && !memcmp(utf8, g_host_text, len)) {
|
||||
free(utf8);
|
||||
return;
|
||||
}
|
||||
if (g_src) { source_send_cancelled(g_src); g_src = NULL; }
|
||||
if (g_reader) reader_free(g_reader);
|
||||
free(g_host_text);
|
||||
g_host_text = len ? utf8 : NULL;
|
||||
if (!len) free(utf8);
|
||||
g_host_len = len;
|
||||
g_owner = len ? OWNER_HOST : OWNER_NONE;
|
||||
banner_log("clipboard", len ? "Android clipboard → guest (%zu bytes)" : "Android clipboard cleared (%zu bytes)", len);
|
||||
broadcast_selection();
|
||||
}
|
||||
|
||||
void clipboard_init(struct wl_display *display) {
|
||||
g_disp = display;
|
||||
wl_list_init(&g_devices);
|
||||
wl_global_create(display, &wl_data_device_manager_interface, 3, NULL, bind_data_device_manager);
|
||||
wl_global_create(display, &zwlr_data_control_manager_v1_interface, 1, NULL, bind_data_control_manager);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Text input: zwp_text_input_manager_v3 (advertised at version 1), the host input method
|
||||
* bridge winewayland.drv uses for IME text (our soft keyboard).
|
||||
*
|
||||
* Focus model. winewayland enables its text input as soon as our `enter` names a surface and
|
||||
* routes every IME update to that surface's window — inside that window's process (the update
|
||||
* list is per process). Keyboard focus in this compositor sits on the desktop surface (the
|
||||
* desktop owner's process), so text input can't follow it; it follows banner_ime_target():
|
||||
* the program window last clicked, else the topmost program window. Clicking into notepad
|
||||
* moves the text-input focus to notepad's process, which is where the edit control lives.
|
||||
*
|
||||
* Protocol state. Requests between commits are pending; `commit` bumps the serial and applies
|
||||
* them (enable resets the state as the protocol says). We answer with `done(serial)` only when
|
||||
* we sent events (preedit/commit strings), never for every commit.
|
||||
*
|
||||
* Host side. banner_on_text_input(enabled, program, cursor rect in scene pixels) tells the app
|
||||
* when a program starts/stops accepting IME text or moves its caret (Wine reports the rect only
|
||||
* when an edit control positions its IME composition window, via ImmSetCompositionWindow).
|
||||
* Typed text arrives through text_input_host_*: preedit_string / commit_string + done.
|
||||
* delete_surrounding_text is NOT used: winewayland's handler for it is empty, so deletions
|
||||
* become Backspace/Delete key presses on the wl_keyboard path instead.
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "banner_ext.h"
|
||||
#include "text-input-unstable-v3-server-protocol.h"
|
||||
|
||||
#ifndef KEY_BACKSPACE
|
||||
#define KEY_BACKSPACE 14
|
||||
#endif
|
||||
#ifndef KEY_DELETE
|
||||
#define KEY_DELETE 111
|
||||
#endif
|
||||
|
||||
static struct wl_display *g_disp;
|
||||
|
||||
struct text_input {
|
||||
struct wl_resource *res;
|
||||
struct wl_client *client;
|
||||
struct wl_list link;
|
||||
struct wl_resource *entered; /* surface we sent enter for, or NULL */
|
||||
uint32_t serial; /* commits received */
|
||||
/* pending, applied on commit */
|
||||
int p_enable, p_disable, p_rect_set, p_content_set;
|
||||
int p_rect[4];
|
||||
uint32_t p_hint, p_purpose;
|
||||
/* current */
|
||||
int enabled;
|
||||
int rect[4];
|
||||
uint32_t hint, purpose;
|
||||
int has_preedit; /* we sent a non-empty preedit last */
|
||||
};
|
||||
static struct wl_list g_inputs;
|
||||
static struct wl_resource *g_target; /* surface text input is focused on */
|
||||
|
||||
/* What the app was last told. */
|
||||
static int g_told_enabled, g_told_rect[4];
|
||||
static struct text_input *g_told_ti;
|
||||
|
||||
static const char *ti_program(struct text_input *ti) { return banner_client_name(ti->client); }
|
||||
|
||||
/* The enabled text input focused on the current target, if any. */
|
||||
static struct text_input *active_input(void) {
|
||||
struct text_input *ti;
|
||||
if (!g_target) return NULL;
|
||||
wl_list_for_each(ti, &g_inputs, link)
|
||||
if (ti->entered == g_target && ti->enabled) return ti;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void tell_app(void) {
|
||||
struct text_input *ti = active_input();
|
||||
int enabled = ti != NULL, rect[4] = {0, 0, 0, 0};
|
||||
if (ti) {
|
||||
int ox = 0, oy = 0;
|
||||
banner_surface_scene_origin(ti->entered, &ox, &oy);
|
||||
rect[0] = ti->rect[0] + ox; rect[1] = ti->rect[1] + oy;
|
||||
rect[2] = ti->rect[2]; rect[3] = ti->rect[3];
|
||||
}
|
||||
if (enabled == g_told_enabled && ti == g_told_ti && !memcmp(rect, g_told_rect, sizeof(rect))) return;
|
||||
if (enabled && (!g_told_enabled || ti != g_told_ti))
|
||||
banner_log("text-input", "text input enabled by %s (cursor rect %d,%d %dx%d)", ti_program(ti),
|
||||
rect[0], rect[1], rect[2], rect[3]);
|
||||
else if (enabled)
|
||||
banner_log("text-input", "cursor rect from %s: %d,%d %dx%d", ti_program(ti), rect[0], rect[1], rect[2], rect[3]);
|
||||
else
|
||||
banner_log("text-input", "text input disabled%s%s", g_told_ti ? " by " : "", g_told_ti ? ti_program(g_told_ti) : "");
|
||||
g_told_enabled = enabled;
|
||||
g_told_ti = ti;
|
||||
memcpy(g_told_rect, rect, sizeof(rect));
|
||||
banner_on_text_input(enabled, enabled ? ti_program(ti) : "", rect[0], rect[1], rect[2], rect[3]);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ focus */
|
||||
|
||||
static void send_leave(struct text_input *ti) {
|
||||
if (!ti->entered) return;
|
||||
zwp_text_input_v3_send_leave(ti->res, ti->entered);
|
||||
ti->entered = NULL;
|
||||
ti->enabled = 0; /* the protocol disables on leave */
|
||||
ti->has_preedit = 0;
|
||||
}
|
||||
|
||||
void banner_text_input_refocus(void) {
|
||||
struct wl_resource *t = banner_ime_target();
|
||||
struct text_input *ti;
|
||||
if (t == g_target) return;
|
||||
wl_list_for_each(ti, &g_inputs, link)
|
||||
if (ti->entered && ti->entered != t) send_leave(ti);
|
||||
g_target = t;
|
||||
if (t) {
|
||||
struct wl_client *c = wl_resource_get_client(t);
|
||||
wl_list_for_each(ti, &g_inputs, link) {
|
||||
if (ti->client != c || ti->entered == t) continue;
|
||||
ti->entered = t;
|
||||
zwp_text_input_v3_send_enter(ti->res, t);
|
||||
}
|
||||
}
|
||||
tell_app();
|
||||
wl_display_flush_clients(g_disp);
|
||||
}
|
||||
|
||||
void banner_text_input_surface_gone(struct wl_resource *surface) {
|
||||
struct text_input *ti;
|
||||
wl_list_for_each(ti, &g_inputs, link)
|
||||
if (ti->entered == surface) { ti->entered = NULL; ti->enabled = 0; ti->has_preedit = 0; }
|
||||
if (g_target == surface) g_target = NULL;
|
||||
if (g_told_ti && g_told_ti->entered == NULL && g_told_enabled) tell_app();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ requests */
|
||||
|
||||
static void ti_res_destroy(struct wl_resource *r) {
|
||||
struct text_input *ti = wl_resource_get_user_data(r);
|
||||
if (!ti) return;
|
||||
wl_list_remove(&ti->link);
|
||||
if (g_told_ti == ti) { g_told_ti = NULL; g_told_enabled = 0; memset(g_told_rect, 0, sizeof(g_told_rect));
|
||||
banner_on_text_input(0, "", 0, 0, 0, 0); }
|
||||
free(ti);
|
||||
}
|
||||
|
||||
static void ti_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void ti_enable(struct wl_client *c, struct wl_resource *r) {
|
||||
struct text_input *ti = wl_resource_get_user_data(r);
|
||||
if (ti) { ti->p_enable = 1; ti->p_disable = 0; }
|
||||
}
|
||||
static void ti_disable(struct wl_client *c, struct wl_resource *r) {
|
||||
struct text_input *ti = wl_resource_get_user_data(r);
|
||||
if (ti) { ti->p_disable = 1; ti->p_enable = 0; }
|
||||
}
|
||||
static void ti_set_surrounding_text(struct wl_client *c, struct wl_resource *r, const char *text, int32_t cursor, int32_t anchor) {}
|
||||
static void ti_set_text_change_cause(struct wl_client *c, struct wl_resource *r, uint32_t cause) {}
|
||||
static void ti_set_content_type(struct wl_client *c, struct wl_resource *r, uint32_t hint, uint32_t purpose) {
|
||||
struct text_input *ti = wl_resource_get_user_data(r);
|
||||
if (ti) { ti->p_hint = hint; ti->p_purpose = purpose; ti->p_content_set = 1; }
|
||||
}
|
||||
static void ti_set_cursor_rectangle(struct wl_client *c, struct wl_resource *r, int32_t x, int32_t y, int32_t w, int32_t h) {
|
||||
struct text_input *ti = wl_resource_get_user_data(r);
|
||||
if (!ti) return;
|
||||
ti->p_rect[0] = x; ti->p_rect[1] = y; ti->p_rect[2] = w; ti->p_rect[3] = h;
|
||||
ti->p_rect_set = 1;
|
||||
}
|
||||
static void ti_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
struct text_input *ti = wl_resource_get_user_data(r);
|
||||
if (!ti) return;
|
||||
ti->serial++;
|
||||
if (ti->p_enable) {
|
||||
ti->enabled = ti->entered != NULL; /* enable only counts while focused */
|
||||
memset(ti->rect, 0, sizeof(ti->rect));
|
||||
ti->hint = 0; ti->purpose = 0;
|
||||
ti->has_preedit = 0;
|
||||
}
|
||||
if (ti->p_disable) { ti->enabled = 0; ti->has_preedit = 0; }
|
||||
if (ti->p_rect_set) memcpy(ti->rect, ti->p_rect, sizeof(ti->rect));
|
||||
if (ti->p_content_set) { ti->hint = ti->p_hint; ti->purpose = ti->p_purpose; }
|
||||
ti->p_enable = ti->p_disable = ti->p_rect_set = ti->p_content_set = 0;
|
||||
tell_app();
|
||||
}
|
||||
static void ti_set_available_actions(struct wl_client *c, struct wl_resource *r, struct wl_array *a) {}
|
||||
static void ti_show_input_panel(struct wl_client *c, struct wl_resource *r) {}
|
||||
static void ti_hide_input_panel(struct wl_client *c, struct wl_resource *r) {}
|
||||
|
||||
static const struct zwp_text_input_v3_interface ti_impl = {
|
||||
.destroy = ti_destroy, .enable = ti_enable, .disable = ti_disable,
|
||||
.set_surrounding_text = ti_set_surrounding_text, .set_text_change_cause = ti_set_text_change_cause,
|
||||
.set_content_type = ti_set_content_type, .set_cursor_rectangle = ti_set_cursor_rectangle,
|
||||
.commit = ti_commit, .set_available_actions = ti_set_available_actions,
|
||||
.show_input_panel = ti_show_input_panel, .hide_input_panel = ti_hide_input_panel,
|
||||
};
|
||||
|
||||
static void tim_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void tim_get_text_input(struct wl_client *c, struct wl_resource *r, uint32_t id, struct wl_resource *seat) {
|
||||
struct text_input *ti = calloc(1, sizeof(*ti));
|
||||
if (!ti) { wl_client_post_no_memory(c); return; }
|
||||
ti->res = wl_resource_create(c, &zwp_text_input_v3_interface, wl_resource_get_version(r), id);
|
||||
if (!ti->res) { free(ti); wl_client_post_no_memory(c); return; }
|
||||
ti->client = c;
|
||||
wl_resource_set_implementation(ti->res, &ti_impl, ti, ti_res_destroy);
|
||||
wl_list_insert(&g_inputs, &ti->link);
|
||||
if (g_target && wl_resource_get_client(g_target) == c) {
|
||||
ti->entered = g_target;
|
||||
zwp_text_input_v3_send_enter(ti->res, g_target);
|
||||
}
|
||||
}
|
||||
static const struct zwp_text_input_manager_v3_interface tim_impl = {
|
||||
.destroy = tim_destroy, .get_text_input = tim_get_text_input,
|
||||
};
|
||||
static void bind_text_input_manager(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
struct wl_resource *r = wl_resource_create(c, &zwp_text_input_manager_v3_interface, ver, id);
|
||||
if (!r) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(r, &tim_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ host side (compositor thread) */
|
||||
|
||||
static size_t utf8_chars(const char *s, size_t len) {
|
||||
size_t n = 0;
|
||||
for (size_t i = 0; i < len; i++) if (((unsigned char)s[i] & 0xC0) != 0x80) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Byte offset of UTF-8 character index `chars` (negative = end). */
|
||||
static int32_t utf8_offset(const char *s, size_t len, int chars) {
|
||||
if (chars < 0) return (int32_t)len;
|
||||
size_t i = 0;
|
||||
while (i < len && chars > 0) {
|
||||
i++;
|
||||
while (i < len && ((unsigned char)s[i] & 0xC0) == 0x80) i++;
|
||||
chars--;
|
||||
}
|
||||
return (int32_t)i;
|
||||
}
|
||||
|
||||
void text_input_host_commit(const char *utf8, size_t len) {
|
||||
struct text_input *ti = active_input();
|
||||
if (!ti) {
|
||||
banner_log("text-input", "typed text (%zu chars) dropped: no program accepts text input", utf8_chars(utf8, len));
|
||||
return;
|
||||
}
|
||||
if (ti->has_preedit) { zwp_text_input_v3_send_preedit_string(ti->res, "", 0, 0); ti->has_preedit = 0; }
|
||||
zwp_text_input_v3_send_commit_string(ti->res, utf8);
|
||||
zwp_text_input_v3_send_done(ti->res, ti->serial);
|
||||
banner_log("text-input", "committed %zu chars to %s", utf8_chars(utf8, len), ti_program(ti));
|
||||
}
|
||||
|
||||
void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end) {
|
||||
struct text_input *ti = active_input();
|
||||
if (!ti) return;
|
||||
if (!len && !ti->has_preedit) return;
|
||||
zwp_text_input_v3_send_preedit_string(ti->res, len ? utf8 : "",
|
||||
utf8_offset(utf8, len, cursor_begin), utf8_offset(utf8, len, cursor_end));
|
||||
zwp_text_input_v3_send_done(ti->res, ti->serial);
|
||||
ti->has_preedit = len > 0;
|
||||
}
|
||||
|
||||
void text_input_host_delete(int before, int after) {
|
||||
if (before <= 0 && after <= 0) return;
|
||||
if (before > 64) before = 64;
|
||||
if (after > 64) after = 64;
|
||||
struct text_input *ti = active_input();
|
||||
if (ti && ti->has_preedit) { /* deleting inside a composition: clear it first */
|
||||
zwp_text_input_v3_send_preedit_string(ti->res, "", 0, 0);
|
||||
zwp_text_input_v3_send_done(ti->res, ti->serial);
|
||||
ti->has_preedit = 0;
|
||||
}
|
||||
for (int i = 0; i < before; i++) { banner_inject_key(KEY_BACKSPACE, 1); banner_inject_key(KEY_BACKSPACE, 0); }
|
||||
for (int i = 0; i < after; i++) { banner_inject_key(KEY_DELETE, 1); banner_inject_key(KEY_DELETE, 0); }
|
||||
banner_log("text-input", "deleted %d before / %d after the caret (as key presses)", before, after);
|
||||
}
|
||||
|
||||
void text_input_init(struct wl_display *display) {
|
||||
g_disp = display;
|
||||
wl_list_init(&g_inputs);
|
||||
wl_global_create(display, &zwp_text_input_manager_v3_interface, 1, NULL, bind_text_input_manager);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* xdg_toplevel_icon_manager_v1 (version 1): window icons are accepted and dropped. The scene
|
||||
* has no title bars to draw them in; winewayland only stops complaining that the global is
|
||||
* missing. We send no icon_size (any size is fine) and `done` at bind, as the protocol asks.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "banner_ext.h"
|
||||
#include "xdg-toplevel-icon-v1-server-protocol.h"
|
||||
|
||||
static void icon_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void icon_set_name(struct wl_client *c, struct wl_resource *r, const char *name) {}
|
||||
static void icon_add_buffer(struct wl_client *c, struct wl_resource *r, struct wl_resource *buffer, int32_t scale) {}
|
||||
static const struct xdg_toplevel_icon_v1_interface icon_impl = {
|
||||
.destroy = icon_destroy, .set_name = icon_set_name, .add_buffer = icon_add_buffer,
|
||||
};
|
||||
|
||||
static void mgr_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void mgr_create_icon(struct wl_client *c, struct wl_resource *r, uint32_t id) {
|
||||
struct wl_resource *icon = wl_resource_create(c, &xdg_toplevel_icon_v1_interface, wl_resource_get_version(r), id);
|
||||
if (!icon) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(icon, &icon_impl, NULL, NULL);
|
||||
}
|
||||
static void mgr_set_icon(struct wl_client *c, struct wl_resource *r, struct wl_resource *toplevel, struct wl_resource *icon) {}
|
||||
static const struct xdg_toplevel_icon_manager_v1_interface mgr_impl = {
|
||||
.destroy = mgr_destroy, .create_icon = mgr_create_icon, .set_icon = mgr_set_icon,
|
||||
};
|
||||
static void bind_icon_manager(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
struct wl_resource *r = wl_resource_create(c, &xdg_toplevel_icon_manager_v1_interface, ver, id);
|
||||
if (!r) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(r, &mgr_impl, NULL, NULL);
|
||||
xdg_toplevel_icon_manager_v1_send_done(r);
|
||||
}
|
||||
|
||||
void toplevel_icon_init(struct wl_display *display) {
|
||||
wl_global_create(display, &xdg_toplevel_icon_manager_v1_interface, 1, NULL, bind_icon_manager);
|
||||
}
|
||||
Reference in new issue
Block a user