mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
cleanup (#764)
This commit is contained in:
1 parent
5fd47421f9
commit
aecd2ebe1d
852 files changed
+4844
-46144
No files matched your search
@@ -1,9 +1,3 @@
|
||||
# ── 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(droiddeckwayland SHARED
|
||||
src/compositor.c
|
||||
src/vk_present.c
|
||||
@@ -38,25 +32,15 @@ add_library(droiddeckwayland SHARED
|
||||
src/framegen_bridge.c
|
||||
src/framegen_jni.c
|
||||
)
|
||||
# Warnings on for the compositor's own C. They do not fail the build; they are there to be read.
|
||||
target_compile_options(droiddeckwayland PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:C>:-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers>)
|
||||
target_include_directories(droiddeckwayland PRIVATE
|
||||
generated
|
||||
prebuilt/include
|
||||
src
|
||||
# The X11 Vulkan renderer's committed SPIR-V headers (*_frag.h / upscale_vert.h, made by
|
||||
# Bannerlator's 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: framegen/lsfg, Win-FG Native:
|
||||
# framegen/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
|
||||
# framegen 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(DROIDDECK_FRAMEGEN_LSFG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../framegen/lsfg)
|
||||
set(DROIDDECK_FRAMEGEN_WINFG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../framegen/winfg)
|
||||
if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
@@ -80,15 +64,14 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_pacer.cpp
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_governor.cpp
|
||||
# The Lossless.dll import (validate / extract / cache) for the app's LsfgNative.
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_jni.cpp
|
||||
${DROIDDECK_FRAMEGEN_WINFG_DIR}/framegen.cpp
|
||||
${DROIDDECK_FRAMEGEN_WINFG_DIR}/winfg_vkd.cpp
|
||||
${DROIDDECK_FRAMEGEN_WINFG_DIR}/winfg_engine.cpp
|
||||
)
|
||||
target_include_directories(droiddeckwayland PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/.. # <thirdparty/...> as the frame-generation engines see it
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../framegen # VulkanRendererContext.h (VkTable), lsfg/, winfg/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../framegen
|
||||
)
|
||||
target_compile_options(droiddeckwayland PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17 -fvisibility=hidden>)
|
||||
@@ -104,8 +87,6 @@ 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(droiddeckwayland
|
||||
wayland-server
|
||||
adrenotools
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
@@ -29,7 +27,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef BANNER_AHB_V1_SERVER_PROTOCOL_H
|
||||
#define BANNER_AHB_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,12 +13,8 @@ extern "C" {
|
||||
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
|
||||
*
|
||||
@@ -41,132 +36,23 @@ struct wl_resource;
|
||||
* 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,
|
||||
@@ -181,26 +67,11 @@ struct banner_ahb_v1_interface {
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
@@ -29,7 +27,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
#define BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,12 +13,8 @@ extern "C" {
|
||||
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
|
||||
*
|
||||
@@ -41,98 +36,41 @@ struct wl_resource;
|
||||
* 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
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2019 Sebastian Wick
|
||||
* Copyright 2019 Erwin Burema
|
||||
@@ -34,7 +32,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2014, 2015 Collabora, Ltd.
|
||||
*
|
||||
@@ -29,7 +27,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef LINUX_DMABUF_V1_SERVER_PROTOCOL_H
|
||||
#define LINUX_DMABUF_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,14 +13,8 @@ extern "C" {
|
||||
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.
|
||||
*
|
||||
@@ -43,8 +36,14 @@ struct wl_resource;
|
||||
* 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;
|
||||
@@ -53,322 +52,26 @@ 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,
|
||||
@@ -378,52 +81,20 @@ struct zwp_linux_dmabuf_v1_interface {
|
||||
#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)
|
||||
{
|
||||
@@ -433,54 +104,20 @@ zwp_linux_dmabuf_v1_send_modifier(struct wl_resource *resource_, uint32_t format
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -506,35 +143,19 @@ zwp_linux_buffer_params_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#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;
|
||||
@@ -546,51 +167,11 @@ zwp_linux_buffer_params_v1_flags_is_valid(uint32_t value, uint32_t version) {
|
||||
valid |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST;
|
||||
return (value & ~valid) == 0;
|
||||
}
|
||||
#endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
@@ -599,112 +180,12 @@ struct zwp_linux_buffer_params_v1_interface {
|
||||
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,
|
||||
@@ -712,26 +193,6 @@ struct zwp_linux_buffer_params_v1_interface {
|
||||
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);
|
||||
@@ -740,53 +201,21 @@ struct zwp_linux_buffer_params_v1_interface {
|
||||
#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_)
|
||||
{
|
||||
@@ -796,48 +225,15 @@ zwp_linux_buffer_params_v1_send_failed(struct wl_resource *resource_)
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#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;
|
||||
@@ -847,19 +243,9 @@ zwp_linux_dmabuf_feedback_v1_tranche_flags_is_valid(uint32_t value, uint32_t ver
|
||||
valid |= ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SAMPLING;
|
||||
return (value & ~valid) == 0;
|
||||
}
|
||||
#endif /* ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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);
|
||||
};
|
||||
@@ -872,117 +258,52 @@ struct zwp_linux_dmabuf_feedback_v1_interface {
|
||||
#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)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2014 Jonas Ådahl
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
@@ -30,7 +28,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
+35
-429
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef POINTER_CONSTRAINTS_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
#define POINTER_CONSTRAINTS_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,37 +13,8 @@ extern "C" {
|
||||
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.
|
||||
@@ -67,8 +37,37 @@ struct wl_resource;
|
||||
* 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;
|
||||
@@ -78,180 +77,26 @@ 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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -261,49 +106,18 @@ zwp_pointer_constraints_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -315,67 +129,11 @@ zwp_pointer_constraints_v1_lifetime_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
@@ -383,32 +141,6 @@ struct zwp_pointer_constraints_v1_interface {
|
||||
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,
|
||||
@@ -419,65 +151,17 @@ struct zwp_pointer_constraints_v1_interface {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
@@ -486,84 +170,28 @@ struct zwp_locked_pointer_v1_interface {
|
||||
#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);
|
||||
@@ -572,40 +200,18 @@ struct zwp_confined_pointer_v1_interface {
|
||||
#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_)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2013-2014 Collabora, Ltd.
|
||||
*
|
||||
@@ -29,7 +27,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef PRESENTATION_TIME_SERVER_PROTOCOL_H
|
||||
#define PRESENTATION_TIME_SERVER_PROTOCOL_H
|
||||
@@ -14,13 +13,8 @@ extern "C" {
|
||||
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.
|
||||
*
|
||||
@@ -42,8 +36,13 @@ struct wl_resource;
|
||||
* 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;
|
||||
@@ -51,131 +50,23 @@ 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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -187,37 +78,11 @@ wp_presentation_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* WP_PRESENTATION_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
@@ -226,26 +91,11 @@ struct wp_presentation_interface {
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -254,66 +104,16 @@ wp_presentation_send_clock_id(struct wl_resource *resource_, uint32_t 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 */
|
||||
#endif
|
||||
|
||||
#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;
|
||||
@@ -327,61 +127,29 @@ wp_presentation_feedback_kind_is_valid(uint32_t value, uint32_t version) {
|
||||
valid |= WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY;
|
||||
return (value & ~valid) == 0;
|
||||
}
|
||||
#endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
#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_)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2014 Jonas Ådahl
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
@@ -30,7 +28,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
+34
-117
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef RELATIVE_POINTER_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
#define RELATIVE_POINTER_UNSTABLE_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,40 +13,8 @@ extern "C" {
|
||||
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.
|
||||
@@ -70,74 +37,56 @@ struct wl_resource;
|
||||
* 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,
|
||||
@@ -145,52 +94,20 @@ struct zwp_relative_pointer_manager_v1_interface {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.26.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2022 Simon Ser
|
||||
*
|
||||
@@ -29,7 +27,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.26.0 */
|
||||
|
||||
#ifndef SINGLE_PIXEL_BUFFER_V1_SERVER_PROTOCOL_H
|
||||
#define SINGLE_PIXEL_BUFFER_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,27 +13,8 @@ extern "C" {
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_single_pixel_buffer_v1 The single_pixel_buffer_v1 protocol
|
||||
* single pixel buffer factory
|
||||
*
|
||||
* @section page_desc_single_pixel_buffer_v1 Description
|
||||
*
|
||||
* This protocol extension allows clients to create single-pixel buffers.
|
||||
*
|
||||
* Compositors supporting this protocol extension should also support the
|
||||
* viewporter protocol extension. Clients may use viewporter to scale a
|
||||
* single-pixel buffer to a desired size.
|
||||
*
|
||||
* 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_single_pixel_buffer_v1 Interfaces
|
||||
* - @subpage page_iface_wp_single_pixel_buffer_manager_v1 - global factory for single-pixel buffers
|
||||
/*
|
||||
* @section page_copyright_single_pixel_buffer_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2022 Simon Ser
|
||||
*
|
||||
@@ -56,66 +36,38 @@ struct wl_resource;
|
||||
* 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 wp_single_pixel_buffer_manager_v1;
|
||||
|
||||
#ifndef WP_SINGLE_PIXEL_BUFFER_MANAGER_V1_INTERFACE
|
||||
#define WP_SINGLE_PIXEL_BUFFER_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_single_pixel_buffer_manager_v1 wp_single_pixel_buffer_manager_v1
|
||||
* @section page_iface_wp_single_pixel_buffer_manager_v1_desc Description
|
||||
*
|
||||
* The wp_single_pixel_buffer_manager_v1 interface is a factory for
|
||||
* single-pixel buffers.
|
||||
* @section page_iface_wp_single_pixel_buffer_manager_v1_api API
|
||||
* See @ref iface_wp_single_pixel_buffer_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_single_pixel_buffer_manager_v1 The wp_single_pixel_buffer_manager_v1 interface
|
||||
*
|
||||
* The wp_single_pixel_buffer_manager_v1 interface is a factory for
|
||||
* single-pixel buffers.
|
||||
*/
|
||||
extern const struct wl_interface wp_single_pixel_buffer_manager_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_single_pixel_buffer_manager_v1
|
||||
* @struct wp_single_pixel_buffer_manager_v1_interface
|
||||
*/
|
||||
struct wp_single_pixel_buffer_manager_v1_interface {
|
||||
/**
|
||||
* destroy the manager
|
||||
*
|
||||
* Destroy the wp_single_pixel_buffer_manager_v1 object.
|
||||
*
|
||||
* The child objects created via this interface are unaffected.
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* create a 1×1 buffer from 32-bit RGBA values
|
||||
*
|
||||
* Create a single-pixel buffer from four 32-bit RGBA values.
|
||||
*
|
||||
* Unless specified in another protocol extension, the RGBA values
|
||||
* use pre-multiplied alpha.
|
||||
*
|
||||
* The width and height of the buffer are 1.
|
||||
*
|
||||
* The r, g, b and a arguments valid range is from UINT32_MIN (0)
|
||||
* to UINT32_MAX (0xffffffff).
|
||||
*
|
||||
* These arguments should be interpreted as a percentage, i.e. -
|
||||
* UINT32_MIN = 0% of the given color component - UINT32_MAX = 100%
|
||||
* of the given color component
|
||||
* @param r value of the buffer's red channel
|
||||
* @param g value of the buffer's green channel
|
||||
* @param b value of the buffer's blue channel
|
||||
* @param a value of the buffer's alpha channel
|
||||
*/
|
||||
void (*create_u32_rgba_buffer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
@@ -126,13 +78,7 @@ struct wp_single_pixel_buffer_manager_v1_interface {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_single_pixel_buffer_manager_v1
|
||||
*/
|
||||
#define WP_SINGLE_PIXEL_BUFFER_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_single_pixel_buffer_manager_v1
|
||||
*/
|
||||
#define WP_SINGLE_PIXEL_BUFFER_MANAGER_V1_CREATE_U32_RGBA_BUFFER_SINCE_VERSION 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2012, 2013 Intel Corporation
|
||||
* Copyright © 2015, 2016 Jan Arne Petersen
|
||||
@@ -34,7 +32,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
@@ -29,7 +27,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef VIEWPORTER_SERVER_PROTOCOL_H
|
||||
#define VIEWPORTER_SERVER_PROTOCOL_H
|
||||
@@ -14,13 +13,8 @@ extern "C" {
|
||||
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.
|
||||
*
|
||||
@@ -42,184 +36,35 @@ struct wl_resource;
|
||||
* 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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -229,32 +74,11 @@ wp_viewporter_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* WP_VIEWPORTER_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
@@ -262,46 +86,21 @@ struct wp_viewporter_interface {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -317,63 +116,17 @@ wp_viewport_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* WP_VIEWPORT_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
@@ -381,17 +134,8 @@ struct wp_viewport_interface {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2018 Simon Ser
|
||||
* Copyright © 2019 Ivan Molodetskikh
|
||||
@@ -32,7 +30,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
+33
-319
@@ -1,4 +1,3 @@
|
||||
/* 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
|
||||
@@ -14,35 +13,8 @@ extern "C" {
|
||||
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
|
||||
@@ -67,8 +39,35 @@ struct wl_resource;
|
||||
* 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;
|
||||
@@ -77,158 +76,47 @@ 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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -238,51 +126,14 @@ zwlr_data_control_device_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWLR_DATA_CONTROL_DEVICE_V1_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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);
|
||||
@@ -293,74 +144,33 @@ struct zwlr_data_control_device_v1_interface {
|
||||
#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)
|
||||
{
|
||||
@@ -370,22 +180,12 @@ zwlr_data_control_device_v1_send_primary_selection(struct wl_resource *resource_
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -395,32 +195,12 @@ zwlr_data_control_source_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ZWLR_DATA_CONTROL_SOURCE_V1_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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);
|
||||
};
|
||||
@@ -428,106 +208,40 @@ struct zwlr_data_control_source_v1_interface {
|
||||
#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)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2008-2013 Kristian Høgsberg
|
||||
* Copyright © 2013 Rafael Antognolli
|
||||
@@ -34,7 +32,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2023-2024 Matthias Klumpp
|
||||
* Copyright © 2024 David Edmundson
|
||||
@@ -30,7 +28,7 @@
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_SERVER_PROTOCOL_H
|
||||
#define XDG_TOPLEVEL_ICON_V1_SERVER_PROTOCOL_H
|
||||
@@ -14,33 +13,8 @@ extern "C" {
|
||||
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
|
||||
@@ -63,8 +37,33 @@ struct wl_resource;
|
||||
* 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;
|
||||
@@ -72,104 +71,19 @@ 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,
|
||||
@@ -179,45 +93,19 @@ struct xdg_toplevel_icon_manager_v1_interface {
|
||||
#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_)
|
||||
{
|
||||
@@ -227,30 +115,14 @@ xdg_toplevel_icon_manager_v1_send_done(struct wl_resource *resource_)
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#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) {
|
||||
@@ -264,77 +136,14 @@ xdg_toplevel_icon_v1_error_is_valid(uint32_t value, uint32_t version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* XDG_TOPLEVEL_ICON_V1_ERROR_ENUM_IS_VALID */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
@@ -342,17 +151,8 @@ struct xdg_toplevel_icon_v1_interface {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
||||
@@ -43,87 +43,15 @@ enum {
|
||||
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);
|
||||
@@ -266,21 +194,6 @@ wl_global_set_withdrawn_listener(struct wl_global *global,
|
||||
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);
|
||||
@@ -321,7 +234,6 @@ 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); \
|
||||
@@ -370,7 +282,6 @@ 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);
|
||||
@@ -393,112 +304,28 @@ 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)
|
||||
{
|
||||
@@ -511,13 +338,6 @@ wl_signal_get(struct wl_signal *signal, wl_notify_func_t notify)
|
||||
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)
|
||||
{
|
||||
@@ -532,22 +352,6 @@ 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, ...);
|
||||
@@ -723,7 +527,6 @@ struct wl_protocol_logger_message {
|
||||
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);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,15 +23,6 @@
|
||||
* 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
|
||||
@@ -43,16 +34,6 @@
|
||||
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 {
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/** \file wayland-util.h
|
||||
*
|
||||
* \brief Utility classes, functions, and macros.
|
||||
*/
|
||||
|
||||
#ifndef WAYLAND_UTIL_H
|
||||
#define WAYLAND_UTIL_H
|
||||
@@ -40,14 +36,12 @@
|
||||
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
|
||||
@@ -56,14 +50,6 @@ extern "C" {
|
||||
#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
|
||||
@@ -76,405 +62,57 @@ extern "C" {
|
||||
#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); \
|
||||
@@ -482,37 +120,11 @@ wl_list_insert_list(struct wl_list *list, struct wl_list *other);
|
||||
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); \
|
||||
@@ -520,244 +132,75 @@ wl_list_insert_list(struct wl_list *list, struct wl_list *other);
|
||||
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` */
|
||||
int32_t i;
|
||||
uint32_t u;
|
||||
wl_fixed_t f;
|
||||
const char *s;
|
||||
struct wl_object *o;
|
||||
uint32_t n;
|
||||
struct wl_array *a;
|
||||
int32_t h;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
};
|
||||
|
||||
|
||||
@@ -1481,7 +1481,6 @@
|
||||
|
||||
<arg name="icc" type="fd" summary="ICC profile file descriptor"/>
|
||||
<arg name="icc_size" type="uint" summary="ICC profile size, in bytes"/>
|
||||
<!-- Offset always 0, compositor must not expose unnecessary data. -->
|
||||
</event>
|
||||
|
||||
<event name="primaries">
|
||||
|
||||
@@ -158,7 +158,6 @@
|
||||
summary="low 32 bits of layout modifier"/>
|
||||
</event>
|
||||
|
||||
<!-- Version 4 additions -->
|
||||
|
||||
<request name="get_default_feedback" since="4">
|
||||
<description summary="get default feedback">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="presentation_time">
|
||||
<!-- wrap:70 -->
|
||||
|
||||
<copyright>
|
||||
Copyright © 2013-2014 Collabora, Ltd.
|
||||
@@ -28,7 +27,6 @@
|
||||
<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
|
||||
@@ -41,7 +39,6 @@
|
||||
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
|
||||
|
||||
@@ -458,7 +458,6 @@
|
||||
<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>
|
||||
|
||||
@@ -142,7 +142,6 @@
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<event name="primary_selection" since="2">
|
||||
<description summary="advertise new primary selection">
|
||||
|
||||
@@ -366,7 +366,6 @@
|
||||
<arg name="y" type="int" summary="surface position y offset"/>
|
||||
</request>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
|
||||
<request name="set_reactive" since="3">
|
||||
<description summary="continuously reconstrain the surface">
|
||||
@@ -1115,7 +1114,6 @@
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 4 additions -->
|
||||
|
||||
<event name="configure_bounds" since="4">
|
||||
<description summary="recommended window geometry bounds">
|
||||
@@ -1139,7 +1137,6 @@
|
||||
<arg name="height" type="int"/>
|
||||
</event>
|
||||
|
||||
<!-- Version 5 additions -->
|
||||
|
||||
<enum name="wm_capabilities" since="5">
|
||||
<entry name="window_menu" value="1" summary="show_window_menu is available"/>
|
||||
@@ -1294,7 +1291,6 @@
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
|
||||
<request name="reposition" since="3">
|
||||
<description summary="recalculate the popup's location">
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* 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 "droiddeck_color.h"
|
||||
@@ -19,9 +17,8 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MOD_QCOM_COMPRESSED 0x0500000000000001ULL /* DRM_FORMAT_MOD_QCOM_COMPRESSED (UBWC) */
|
||||
#define MOD_QCOM_COMPRESSED 0x0500000000000001ULL
|
||||
|
||||
/* linux/dma-buf.h (not in the NDK sysroot's older headers): sync_file export / import. */
|
||||
struct droiddeck_dma_buf_sync_file { uint32_t flags; int32_t fd; };
|
||||
#define DROIDDECK_DMA_BUF_SYNC_READ 1u
|
||||
#define DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR('b', 2, struct droiddeck_dma_buf_sync_file)
|
||||
@@ -29,47 +26,43 @@ struct droiddeck_dma_buf_sync_file { uint32_t flags; int32_t fd; };
|
||||
|
||||
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 */
|
||||
uint64_t id;
|
||||
struct dmabuf_buffer *b;
|
||||
AHardwareBuffer *ahb;
|
||||
int w, h;
|
||||
uint32_t stride, image_count;
|
||||
uint32_t format; /* AHARDWAREBUFFER_FORMAT_* gralloc gave it (10-bit for HDR10) */
|
||||
uint32_t format;
|
||||
uint64_t modifier;
|
||||
struct wl_client *client;
|
||||
struct wl_resource *resource; /* the wl_buffer; NULL once the client destroyed it */
|
||||
struct wl_resource *resource;
|
||||
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 on_layer;
|
||||
int release_pending;
|
||||
int64_t deferred_ns;
|
||||
struct surface *surface;
|
||||
struct wl_event_source *fence_src;
|
||||
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 struct wl_list g_clients;
|
||||
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 */
|
||||
static int g_advertised;
|
||||
static int g_mode_sent = -1;
|
||||
static struct surface *g_announced;
|
||||
static volatile int64_t g_last_zero_copy_ns;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -96,7 +89,6 @@ static void buf_free(struct ahb_buf *ab) {
|
||||
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);
|
||||
}
|
||||
@@ -105,11 +97,10 @@ 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 */
|
||||
ab->release_pending = 0;
|
||||
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)
|
||||
@@ -129,10 +120,6 @@ static int on_fence_readable(int fd, uint32_t mask, void *data) {
|
||||
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; }
|
||||
@@ -148,7 +135,6 @@ static void handle_released(uint64_t id, int fd) {
|
||||
droiddeck_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);
|
||||
@@ -156,7 +142,7 @@ static void handle_released(uint64_t id, int fd) {
|
||||
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 */
|
||||
else return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +165,6 @@ static int on_release_pipe(int fd, uint32_t mask, void *data) {
|
||||
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) {
|
||||
@@ -193,7 +178,6 @@ void ahb_swapchain_layer_released(void *token, int release_fd) {
|
||||
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 && *droiddeck_dmabuf_ahb_slot((struct dmabuf_buffer *)b) != NULL;
|
||||
@@ -203,8 +187,6 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_
|
||||
struct ahb_buf *ab = b ? *droiddeck_dmabuf_ahb_slot(b) : NULL;
|
||||
if (!ab) return -1;
|
||||
int dmabuf_fd = droiddeck_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 droiddeck_dma_buf_sync_file exp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = -1};
|
||||
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) {
|
||||
@@ -215,14 +197,14 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_
|
||||
droiddeck_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 */
|
||||
struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN};
|
||||
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 ? droiddeck_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 (r == 1) return 0;
|
||||
if (!ab->on_layer) {
|
||||
ab->on_layer = 1;
|
||||
g_stat_zero_copy++;
|
||||
@@ -272,7 +254,6 @@ uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b) {
|
||||
return ab ? ab->format : 0;
|
||||
}
|
||||
|
||||
/* ---- banner_ahb_v1 */
|
||||
|
||||
static void ahb_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
|
||||
@@ -287,10 +268,8 @@ static void ahb_attach(struct wl_client *c, struct wl_resource *r, struct wl_res
|
||||
return;
|
||||
}
|
||||
void **slot = droiddeck_dmabuf_ahb_slot(b);
|
||||
if (*slot) { close(sock); return; } /* once per buffer */
|
||||
if (*slot) { close(sock); return; }
|
||||
|
||||
/* 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);
|
||||
@@ -357,10 +336,7 @@ static void bind_ahb(struct wl_client *c, void *data, uint32_t ver, uint32_t 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;
|
||||
droiddeck_log("layer", "zero-copy: %s bound banner_ahb_v1 version %u (%s)", droiddeck_client_name(c), ver,
|
||||
@@ -386,7 +362,6 @@ void ahb_swapchain_set_mode(int on, int live) {
|
||||
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)
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
#ifndef AHB_SWAPCHAIN_H
|
||||
#define AHB_SWAPCHAIN_H
|
||||
/*
|
||||
* Zero-copy game frames (layer mode, DROIDDECK_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>
|
||||
@@ -30,53 +7,28 @@
|
||||
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 *droiddeck_dmabuf_from_resource(struct wl_resource *buffer);
|
||||
int droiddeck_dmabuf_fd(const struct dmabuf_buffer *b); /* plane 0's dma-buf */
|
||||
int droiddeck_dmabuf_fd(const struct dmabuf_buffer *b);
|
||||
void droiddeck_dmabuf_size(const struct dmabuf_buffer *b, int *w, int *h);
|
||||
void **droiddeck_dmabuf_ahb_slot(struct dmabuf_buffer *b); /* this module's per-buffer state */
|
||||
void **droiddeck_dmabuf_ahb_slot(struct dmabuf_buffer *b);
|
||||
void droiddeck_dmabuf_ref(struct dmabuf_buffer *b);
|
||||
void droiddeck_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 droiddeck_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 droiddeck_request_redraw(void);
|
||||
/* "<title>" (program) of the window a surface belongs to, for the log. */
|
||||
void droiddeck_surface_describe(const struct surface *s, char *out, size_t size);
|
||||
/* The surface's current image description (droiddeck_color.h), NULL = none / HDR gate closed. */
|
||||
struct droiddeck_color;
|
||||
const struct droiddeck_color *droiddeck_surface_color(const struct surface *s);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#version 450
|
||||
// Wayland buffers carry premultiplied alpha; the pipeline blends ONE, ONE_MINUS_SRC_ALPHA.
|
||||
layout(binding = 0) uniform sampler2D Surface;
|
||||
layout(location = 0) in vec2 uv;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#version 450
|
||||
// One surface as a quad: dst = the target rectangle in NDC, src = the buffer rectangle in UV.
|
||||
layout(push_constant) uniform PC { vec4 dst; vec4 src; } pc;
|
||||
layout(location = 0) out vec2 uv;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// 1115.1.0
|
||||
#pragma once
|
||||
const uint32_t blend_frag_code[] = {
|
||||
0x07230203,0x00010000,0x0008000b,0x00000014,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
/* Alpha composition: one surface drawn source-over onto the scene - see blend_pass.h. Compositor thread. */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "blend_pass.h"
|
||||
#include "vk_loader.h"
|
||||
#include "vk_present.h" /* droiddeck_log, vkp_gpu_name */
|
||||
#include "vk_present.h"
|
||||
#include <string.h>
|
||||
|
||||
/* SPIR-V, pre-compiled (glslangValidator -V blend.vert --vn blend_vert_code, the same for blend.frag)
|
||||
* and committed next to the GLSL: the NDK build compiles no shaders. */
|
||||
#include "blend_vert.h"
|
||||
#include "blend_frag.h"
|
||||
|
||||
struct pc_blend { float dst[4]; float src[4]; };
|
||||
|
||||
static VkDevice g_dev;
|
||||
static int g_ready; /* 0 = not built, 1 = ok, -1 = unavailable (said once) */
|
||||
static int g_ready;
|
||||
static VkSampler g_sampler;
|
||||
static VkDescriptorSetLayout g_dsl;
|
||||
static VkPipelineLayout g_pl;
|
||||
@@ -21,8 +18,6 @@ static VkDescriptorPool g_dpool;
|
||||
static VkShaderModule g_vert, g_frag;
|
||||
static unsigned g_frame = 1;
|
||||
|
||||
/* One render pass + pipeline per target format: the screen swapchain's, the scene image's, the HDR
|
||||
* composition's. */
|
||||
#define NFMT 4
|
||||
static struct { VkFormat fmt; VkRenderPass rp; VkPipeline pipe; } g_out[NFMT];
|
||||
|
||||
@@ -60,8 +55,6 @@ static VkShaderModule shader(const uint32_t *code, size_t size) {
|
||||
return m;
|
||||
}
|
||||
|
||||
/* The target keeps what the blits put there (LOAD) and stays in TRANSFER_DST_OPTIMAL for the blits
|
||||
* that follow. The dependencies order the pass between them. */
|
||||
static VkRenderPass make_rp(VkFormat fmt) {
|
||||
VkAttachmentDescription att = {.format = fmt, .samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
@@ -111,7 +104,6 @@ static VkPipeline make_pipe(VkRenderPass rp) {
|
||||
.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};
|
||||
/* The target's alpha is left alone: the screen is opaque whatever is drawn onto it. */
|
||||
VkPipelineColorBlendAttachmentState ba = {
|
||||
.blendEnable = VK_TRUE, .srcColorBlendFactor = VK_BLEND_FACTOR_ONE,
|
||||
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, .colorBlendOp = VK_BLEND_OP_ADD,
|
||||
@@ -201,8 +193,6 @@ static VkImageView make_view(VkImage img, VkFormat fmt) {
|
||||
return v;
|
||||
}
|
||||
|
||||
/* The slot to recycle: a free one, else the one unused for longest - never one this command buffer
|
||||
* already refers to. -1 = every slot is in this frame. */
|
||||
#define OLDEST(arr, n, out) do { \
|
||||
unsigned age_ = 0; \
|
||||
(out) = -1; \
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
#ifndef BLEND_PASS_H
|
||||
#define BLEND_PASS_H
|
||||
/*
|
||||
* Alpha composition. The scene is composed with blits, which replace what is under them; a surface
|
||||
* with translucent pixels (gamescope's overlay and notification planes over a game, a toolkit's
|
||||
* shadowed popup) is drawn through this pass instead, source-over with premultiplied alpha.
|
||||
*
|
||||
* Compositor thread. Objects are built on the first use; if the driver refuses them the pass is
|
||||
* unavailable for the session (logged once) and the caller keeps blitting.
|
||||
*/
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
/* Called from dev_init (device up). */
|
||||
void blendp_bind_device(VkDevice dev);
|
||||
/* A source or target image is about to be destroyed: drop what is cached for it. Frames are fenced,
|
||||
* so nothing submitted still uses it. */
|
||||
void blendp_forget_image(VkImage img);
|
||||
/* A new command buffer is being recorded: what the previous one used may be recycled again. */
|
||||
void blendp_begin_frame(void);
|
||||
|
||||
/* Record one surface over `dst`. `dst` is in TRANSFER_DST_OPTIMAL before and after. `src` was created
|
||||
* with SAMPLED usage and is in GENERAL (src_general) or TRANSFER_SRC_OPTIMAL, and is left there.
|
||||
* `blit` is the draw as the blit path maps it. 0 = recorded, -1 = unavailable (nothing recorded). */
|
||||
int blendp_draw(VkCommandBuffer cmd, VkImage src, VkFormat src_fmt, int src_w, int src_h, int src_general,
|
||||
VkImage dst, VkFormat dst_fmt, int dst_w, int dst_h, const VkImageBlit *blit);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// 1115.1.0
|
||||
#pragma once
|
||||
const uint32_t blend_vert_code[] = {
|
||||
0x07230203,0x00010000,0x0008000b,0x0000003a,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
/* Cardboard pass - see cardboard.h. Compositor thread unless noted.
|
||||
*
|
||||
* The shader is cardboard.frag, pre-compiled like the rest of the compositor's SPIR-V:
|
||||
* glslangValidator -V --vn cardboard_frag_code -o cardboard_frag.h cardboard.frag
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "cardboard.h"
|
||||
#include <math.h>
|
||||
@@ -20,15 +15,14 @@
|
||||
|
||||
#ifndef CARDBOARD_HOST_TEST
|
||||
#include "vk_loader.h"
|
||||
#include "vk_present.h" /* droiddeck_log */
|
||||
/* upscale_vert.h defines its array non-static, and effects_chain.c includes it too: a private name here. */
|
||||
#include "vk_present.h"
|
||||
|
||||
#define upscale_vert_code cardboard_upscale_vert_code
|
||||
#include "upscale_vert.h"
|
||||
#undef upscale_vert_code
|
||||
#include "cardboard_frag.h"
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------ pure helpers */
|
||||
|
||||
static float clampf(float v, float lo, float hi) { return v < lo ? lo : v > hi ? hi : v; }
|
||||
|
||||
@@ -47,29 +41,25 @@ void cardboard_clamp(struct cardboard_params *p) {
|
||||
|
||||
void cardboard_push_constants(const struct cardboard_params *p, const float pose[9],
|
||||
int src_w, int src_h, int out_w, int out_h, float out[24]) {
|
||||
/* rot0..rot2: the pose's rows, each with one scalar riding in w. */
|
||||
for (int r = 0; r < 3; r++)
|
||||
for (int c = 0; c < 3; c++) out[r * 4 + c] = pose[r * 3 + c];
|
||||
out[3] = p->ipd_m * 0.5f;
|
||||
out[7] = p->screen_dist_m;
|
||||
out[11] = p->screen_width_m * 0.5f;
|
||||
/* lens */
|
||||
out[12] = p->k1;
|
||||
out[13] = p->k2;
|
||||
out[14] = tanf(p->fov_deg * 0.5f * (float)M_PI / 180.0f);
|
||||
out[15] = p->chroma;
|
||||
/* view */
|
||||
out[16] = p->lens_inset;
|
||||
out[17] = (src_w > 0 && src_h > 0) ? (float)src_w / (float)src_h : 16.0f / 9.0f;
|
||||
if (p->source == CARDBOARD_SOURCE_SBS) out[17] *= 0.5f; /* one eye's half */
|
||||
if (p->source == CARDBOARD_SOURCE_SBS) out[17] *= 0.5f;
|
||||
out[18] = (float)p->source;
|
||||
out[19] = (out_w > 0 && out_h > 0) ? ((float)out_w * 0.5f) / (float)out_h : 1.0f;
|
||||
out[20] = out[21] = out[22] = out[23] = 0.0f; /* reserved */
|
||||
out[20] = out[21] = out[22] = out[23] = 0.0f;
|
||||
}
|
||||
|
||||
#ifndef CARDBOARD_HOST_TEST
|
||||
|
||||
/* ------------------------------------------------------------------ settings + pose */
|
||||
|
||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct cardboard_params g_set = {
|
||||
@@ -78,8 +68,8 @@ static struct cardboard_params g_set = {
|
||||
static float g_pose[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
||||
static volatile int g_changed = 1;
|
||||
|
||||
static int g_live; /* the last pose came from a sensor */
|
||||
static void shm_publish(int live); /* below: the guest's copy of the pose */
|
||||
static int g_live;
|
||||
static void shm_publish(int live);
|
||||
|
||||
void vkp_cardboard_set(const struct cardboard_params *p) {
|
||||
struct cardboard_params c = *p;
|
||||
@@ -96,9 +86,8 @@ void vkp_cardboard_set(const struct cardboard_params *p) {
|
||||
c.ipd_m * 1000.0f, c.screen_width_m, c.screen_dist_m, c.k1, c.k2, c.fov_deg, c.lens_inset, c.chroma);
|
||||
}
|
||||
|
||||
/* The guest's copy of the pose (headpose_shm.h), mapped once a path is known. */
|
||||
static struct droiddeck_headpose *g_shm;
|
||||
static int g_eye_w, g_eye_h; /* the last eye viewport drawn, for the guest */
|
||||
static int g_eye_w, g_eye_h;
|
||||
|
||||
void vkp_cardboard_set_pose_file(const char *path) {
|
||||
pthread_mutex_lock(&g_lock);
|
||||
@@ -120,7 +109,6 @@ void vkp_cardboard_set_pose_file(const char *path) {
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
}
|
||||
|
||||
/* Under g_lock. */
|
||||
static void shm_publish(int live) {
|
||||
if (!g_shm) return;
|
||||
struct timespec ts;
|
||||
@@ -174,15 +162,14 @@ int vkp_cardboard_pose_changed(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ Vulkan objects */
|
||||
|
||||
#define CB_FORMAT VK_FORMAT_R8G8B8A8_UNORM
|
||||
#define CB_PC_SIZE (4 * 4 + 24 * 4) /* ndc + the 24 floats: 112 bytes, under the 128 guaranteed */
|
||||
#define CB_MAX_SOURCES 8 /* source views per frame: the real frame + generated ones */
|
||||
#define CB_PC_SIZE (4 * 4 + 24 * 4)
|
||||
#define CB_MAX_SOURCES 8
|
||||
|
||||
static VkDevice g_dev;
|
||||
static VkPhysicalDeviceMemoryProperties g_mp;
|
||||
static int g_ready; /* 0 = not built, 1 = ok, -1 = failed (said once) */
|
||||
static int g_ready;
|
||||
static VkRenderPass g_rp;
|
||||
static VkDescriptorSetLayout g_dsl;
|
||||
static VkPipelineLayout g_pl;
|
||||
@@ -234,9 +221,6 @@ static VkImageView make_view(VkImage img) {
|
||||
return v;
|
||||
}
|
||||
|
||||
/* The panel-sized output: rendered into, then blitted 1:1 to the swapchain. Kept uncompressed
|
||||
* (mutable format) like the effect chain's targets: UBWC render-then-blit targets corrupt on
|
||||
* Adreno 740. */
|
||||
static int target_ensure(int w, int h) {
|
||||
if (g_t.img && g_t.w == w && g_t.h == h) return 0;
|
||||
target_destroy();
|
||||
@@ -295,7 +279,6 @@ static int objects_ensure(void) {
|
||||
if (g_ready) return g_ready == 1 ? 0 : -1;
|
||||
if (!g_dev || !g_vk.CreateGraphicsPipelines) goto fail;
|
||||
{
|
||||
/* One colour target, overwritten whole, left GENERAL for the 1:1 blit that follows. */
|
||||
VkAttachmentDescription att = {.format = CB_FORMAT, .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,
|
||||
@@ -444,4 +427,4 @@ VkImage vkp_cardboard_run(VkCommandBuffer cmd, VkImage src, int src_w, int src_h
|
||||
return g_t.img;
|
||||
}
|
||||
|
||||
#endif /* CARDBOARD_HOST_TEST */
|
||||
#endif
|
||||
@@ -1,55 +1,36 @@
|
||||
#version 450
|
||||
// Cardboard pass (cardboard.c): the finished frame -> two eye viewports, side by side, each
|
||||
// barrel-distorted for a phone-in-a-viewer lens. Runs on upscale.vert's full quad, so uv covers
|
||||
// the whole panel with (0,0) at the top left.
|
||||
//
|
||||
// Source modes:
|
||||
// 0 = virtual screen: the frame is a flat screen hanging in front of the viewer. Each eye casts
|
||||
// a ray through its lens, rotated by the head pose, from its own position (half the IPD to
|
||||
// either side), so the screen has real stereo depth and stays put while the head turns.
|
||||
// 1 = side by side: the frame already holds a left and a right eye image (SteamVR, an SBS 3D
|
||||
// game or video); each eye samples its own half. The head pose belongs to whoever rendered
|
||||
// it, so none is applied here.
|
||||
//
|
||||
// Regenerate cardboard_frag.h after editing (glslangValidator, see cardboard.c).
|
||||
layout(binding = 0) uniform sampler2D Source;
|
||||
layout(location = 0) in vec2 uv;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(push_constant) uniform PC {
|
||||
vec4 ndc; // upscale.vert's quad
|
||||
vec4 rot0; // xyz: head -> world rotation, row 0; w: half the IPD (m)
|
||||
vec4 rot1; // xyz: row 1; w: distance to the virtual screen (m)
|
||||
vec4 rot2; // xyz: row 2; w: half the virtual screen's width (m)
|
||||
vec4 lens; // x: k1, y: k2, z: tan of half the eye's vertical field of view, w: chromatic spread
|
||||
vec4 view; // x: lens centre inset (fraction of an eye viewport), y: source aspect w/h,
|
||||
// z: source mode, w: eye viewport aspect w/h
|
||||
vec4 ndc;
|
||||
vec4 rot0;
|
||||
vec4 rot1;
|
||||
vec4 rot2;
|
||||
vec4 lens;
|
||||
vec4 view;
|
||||
|
||||
} pc;
|
||||
|
||||
const vec3 BACKDROP = vec3(0.015, 0.015, 0.02);
|
||||
|
||||
// Lens: a point on the panel at tangent-space offset t (from the lens centre) shows the ray that
|
||||
// leaves the eye at t * (1 + k1 r^2 + k2 r^4). Sampling outwards like this draws the picture
|
||||
// barrel-shaped; the viewer's lens pincushions it back.
|
||||
vec2 undistort(vec2 t, float scale) {
|
||||
float r2 = dot(t, t);
|
||||
return t * scale * (1.0 + pc.lens.x * r2 + pc.lens.y * r2 * r2);
|
||||
}
|
||||
|
||||
// What one eye sees along tangent direction tan (x right, y down): colour, or the backdrop.
|
||||
vec3 eyeSample(vec2 tan, float eye) {
|
||||
if (pc.view.z > 0.5) {
|
||||
// Side by side: this eye's half of the source covers the eye's field of view.
|
||||
float tanH = pc.lens.z;
|
||||
vec2 s = vec2(tan.x / (tanH * pc.view.w), tan.y / tanH) * 0.5 + 0.5;
|
||||
if (any(lessThan(s, vec2(0.0))) || any(greaterThan(s, vec2(1.0)))) return vec3(0.0);
|
||||
return texture(Source, vec2((s.x + eye) * 0.5, s.y)).rgb;
|
||||
}
|
||||
// mat3() takes columns; the push constants carry rows.
|
||||
mat3 R = transpose(mat3(pc.rot0.xyz, pc.rot1.xyz, pc.rot2.xyz));
|
||||
vec3 d = R * normalize(vec3(tan.x, -tan.y, -1.0));
|
||||
vec3 o = R * vec3((eye < 0.5 ? -1.0 : 1.0) * pc.rot0.w, 0.0, 0.0);
|
||||
if (d.z > -1e-4) return BACKDROP; // looking away from the screen
|
||||
if (d.z > -1e-4) return BACKDROP;
|
||||
float t = (-pc.rot1.w - o.z) / d.z;
|
||||
vec3 hit = o + d * t;
|
||||
float halfW = pc.rot2.w, halfH = halfW / pc.view.y;
|
||||
@@ -61,7 +42,6 @@ vec3 eyeSample(vec2 tan, float eye) {
|
||||
void main() {
|
||||
float eye = uv.x < 0.5 ? 0.0 : 1.0;
|
||||
vec2 local = vec2(uv.x * 2.0 - eye, uv.y);
|
||||
// Lens centres sit inset towards the nose by view.x of a viewport.
|
||||
float cx = 0.5 + (eye < 0.5 ? pc.view.x : -pc.view.x);
|
||||
vec2 p = local - vec2(cx, 0.5);
|
||||
float tanH = pc.lens.z;
|
||||
@@ -69,14 +49,12 @@ void main() {
|
||||
|
||||
vec3 c;
|
||||
if (pc.lens.w > 0.0) {
|
||||
// Chromatic aberration: the lens bends red least and blue most; pre-spread to match.
|
||||
c.r = eyeSample(undistort(t, 1.0 - pc.lens.w), eye).r;
|
||||
c.g = eyeSample(undistort(t, 1.0), eye).g;
|
||||
c.b = eyeSample(undistort(t, 1.0 + pc.lens.w), eye).b;
|
||||
} else {
|
||||
c = eyeSample(undistort(t, 1.0), eye);
|
||||
}
|
||||
// Fade out towards each viewport's edge so the lens rim never shows a hard cut.
|
||||
vec2 e = min(local, 1.0 - local);
|
||||
float fade = smoothstep(0.0, 0.03, min(e.x * pc.view.w, e.y));
|
||||
outColor = vec4(c * fade, 1.0);
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
#ifndef CARDBOARD_H
|
||||
#define CARDBOARD_H
|
||||
/*
|
||||
* Cardboard mode: the last stage of the compositor pass. The finished frame (after the effects and
|
||||
* frame generation) is drawn twice, once per eye, side by side on the panel, barrel-distorted for a
|
||||
* phone-in-a-viewer lens (cardboard.frag). The frame either hangs as a flat virtual screen in front
|
||||
* of the viewer, world-locked by the phone's rotation sensor (3DoF), or is already a side-by-side
|
||||
* stereo pair (SteamVR, SBS 3D content) that only gets the lens treatment.
|
||||
*
|
||||
* Present-pass order with Cardboard on (vk_present.c, render_impl):
|
||||
* scene -> effects -> frame generation -> vkp_cardboard_run (whole panel) -> 1:1 blit -> present
|
||||
* The Fullscreen Mode mapping does not apply: the pass fills the output itself.
|
||||
*
|
||||
* Settings and the head pose come from any thread (JNI, the sensor thread); the compositor thread
|
||||
* snapshots them per frame. A new pose redraws even a static scene (vkp_cardboard_pose_changed), so
|
||||
* the virtual screen stays put while the head turns.
|
||||
*/
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
@@ -22,41 +7,27 @@ enum { CARDBOARD_SOURCE_SCREEN = 0, CARDBOARD_SOURCE_SBS = 1 };
|
||||
|
||||
struct cardboard_params {
|
||||
int enabled;
|
||||
int source; /* CARDBOARD_SOURCE_* */
|
||||
float ipd_m; /* distance between the eyes, metres */
|
||||
float screen_dist_m; /* virtual screen distance, metres */
|
||||
float screen_width_m;/* virtual screen width, metres */
|
||||
float k1, k2; /* lens distortion coefficients */
|
||||
float fov_deg; /* vertical field of view of one eye before distortion */
|
||||
float lens_inset; /* lens centre inset towards the nose, fraction of an eye viewport */
|
||||
float chroma; /* chromatic aberration pre-correction (0 = off) */
|
||||
int source;
|
||||
float ipd_m;
|
||||
float screen_dist_m;
|
||||
float screen_width_m;
|
||||
float k1, k2;
|
||||
float fov_deg;
|
||||
float lens_inset;
|
||||
float chroma;
|
||||
};
|
||||
|
||||
/* Any thread. Values are clamped to sane ranges. */
|
||||
void vkp_cardboard_set(const struct cardboard_params *p);
|
||||
/* Any thread: the head -> world rotation, row-major 3x3. Identity = looking straight at the screen.
|
||||
* live = a sensor produced it. Also published to the guest (headpose_shm.h) once a file is set. */
|
||||
void vkp_cardboard_set_pose(const float m[9], int live);
|
||||
/* Any thread, once: where the guest's copy of the pose lives (<files>/.wayland-rt/droiddeck-headpose). */
|
||||
void vkp_cardboard_set_pose_file(const char *path);
|
||||
|
||||
/* Compositor thread. */
|
||||
void vkp_cardboard_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops);
|
||||
/* 1 while Cardboard mode is on (the frame must take the compositor pass). */
|
||||
int vkp_cardboard_active(void);
|
||||
/* 1 when the settings or the pose changed since the last call: the caller redraws. */
|
||||
int vkp_cardboard_pose_changed(void);
|
||||
/* Called once per frame before any vkp_cardboard_run: releases the previous frame's source views
|
||||
* (that frame is fenced by now). */
|
||||
void vkp_cardboard_begin_frame(void);
|
||||
/* Records the pass into cmd: src (src_w x src_h, R8G8B8A8, in GENERAL) -> a panel-sized image
|
||||
* (out_w x out_h), returned in GENERAL. VK_NULL_HANDLE when the pass is unavailable (the caller
|
||||
* presents the frame the usual way). */
|
||||
VkImage vkp_cardboard_run(VkCommandBuffer cmd, VkImage src, int src_w, int src_h, int out_w, int out_h);
|
||||
|
||||
/* Pure helpers, shared with the host test (tools/tests). */
|
||||
void cardboard_clamp(struct cardboard_params *p);
|
||||
/* The 24 floats after the quad's ndc in the shader's push constants. */
|
||||
void cardboard_push_constants(const struct cardboard_params *p, const float pose[9],
|
||||
int src_w, int src_h, int out_w, int out_h, float out[24]);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// 1116.2.0
|
||||
#pragma once
|
||||
const uint32_t cardboard_frag_code[] = {
|
||||
0x07230203,0x00010000,0x0008000b,0x0000016d,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,8 +1,3 @@
|
||||
/*
|
||||
* What compositor.c shares with the protocol modules split out of it (wl_dmabuf.c): the dma-buf
|
||||
* buffer records, the per-client bookkeeping and the few functions and globals both sides use.
|
||||
* Everything declared here is hidden: it is internal to libdroiddeckwayland, not part of its ABI.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
@@ -16,7 +11,6 @@
|
||||
#define WLOGE(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------ dmabuf buffers */
|
||||
|
||||
#define FOURCC(a, b, c, d) \
|
||||
((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
@@ -41,39 +35,29 @@ struct dmabuf_buffer {
|
||||
int32_t width, height;
|
||||
uint32_t format;
|
||||
uint64_t modifier;
|
||||
struct vkp_image *img; /* imported once, reused for every frame */
|
||||
struct vkp_image *img;
|
||||
int import_failed;
|
||||
/* One reference for the wl_buffer resource, one per surface showing the buffer. Mesa destroys
|
||||
* a swapchain's wl_buffers the moment the game rebuilds its swapchain, i.e. while the last
|
||||
* committed one is still what is on screen: the import (and the dma-buf memory it pins) stays
|
||||
* until the surface commits something newer, so the picture never blinks to black. */
|
||||
int refs;
|
||||
void *ahb_state; /* zero-copy: ahb_swapchain.c's record (the game's AHardwareBuffer) */
|
||||
void *ahb_state;
|
||||
};
|
||||
|
||||
/* Which program each Wayland client is (from /proc/<pid>/cmdline), for the session log. */
|
||||
struct client_info {
|
||||
struct wl_client *client;
|
||||
struct wl_listener destroy;
|
||||
pid_t pid;
|
||||
char name[64];
|
||||
/* An OpenGL program whose EGL gave up on the GPU: it asked for dma-buf feedback (EGL's
|
||||
* Wayland GPU path always does), never made a dma-buf buffer, and draws wl_shm frames. */
|
||||
unsigned asked_feedback : 1, shm_gl_said : 1;
|
||||
/* Clients that describe opaque regions can use alpha outside those regions. Wine windows
|
||||
* never describe them, and their unused alpha channel must not make them translucent. */
|
||||
unsigned declares_opaque : 1;
|
||||
unsigned dmabuf_buffers, shm_frames;
|
||||
struct client_info *next;
|
||||
};
|
||||
|
||||
/* ---- compositor.c */
|
||||
COMPOSITOR_INTERNAL struct client_info *client_info_of(struct wl_client *client);
|
||||
COMPOSITOR_INTERNAL void dmabuf_buffer_unref(struct dmabuf_buffer *b);
|
||||
COMPOSITOR_INTERNAL extern const struct wl_buffer_interface dbuf_buffer_impl;
|
||||
extern volatile int g_ubwc; /* DROIDDECK_WAYLAND_UBWC (waylandcomp_jni.c sets it) */
|
||||
extern volatile int g_no_render_node; /* DROIDDECK_WAYLAND_NO_RENDER_NODE */
|
||||
extern volatile int g_ubwc;
|
||||
extern volatile int g_no_render_node;
|
||||
|
||||
/* ---- wl_dmabuf.c */
|
||||
COMPOSITOR_INTERNAL extern dev_t g_main_device; /* the render node clients are told to allocate on */
|
||||
|
||||
COMPOSITOR_INTERNAL extern dev_t g_main_device;
|
||||
COMPOSITOR_INTERNAL void bind_dmabuf(struct wl_client *c, void *data, uint32_t ver, uint32_t id);
|
||||
@@ -1,150 +1,63 @@
|
||||
#ifndef DROIDDECK_COLOR_H
|
||||
#define DROIDDECK_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 DROIDDECK_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 (droiddeck_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.
|
||||
* DROIDDECK_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 DROIDDECK_ADATASPACE_UNKNOWN 0
|
||||
#define DROIDDECK_ADATASPACE_BT2020_PQ 163971072 /* STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_FULL = 0x09c60000 */
|
||||
#define DROIDDECK_ADATASPACE_BT2020_HLG 168165376 /* STANDARD_BT2020 | TRANSFER_HLG | RANGE_FULL */
|
||||
#define DROIDDECK_ADATASPACE_BT2020_PQ 163971072
|
||||
#define DROIDDECK_ADATASPACE_BT2020_HLG 168165376
|
||||
|
||||
/* 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 droiddeck_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 */
|
||||
uint32_t identity;
|
||||
uint32_t primaries, tf;
|
||||
int32_t dataspace;
|
||||
int has_st2086;
|
||||
float red[2], green[2], blue[2], white[2];
|
||||
float max_lum, min_lum;
|
||||
int has_cta861;
|
||||
float max_cll, max_fall;
|
||||
char text[256];
|
||||
};
|
||||
|
||||
/* ---- app -> compositor (JNI, any thread) */
|
||||
/* mode 0 = off, 1 = DROIDDECK_WAYLAND_HDR=1, 2 = DROIDDECK_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 droiddeck_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 droiddeck_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 droiddeck_color_ratio_sample(float ratio, int listener);
|
||||
/* Milliseconds since an HDR frame last went onto a display layer; -1 = none this session. */
|
||||
int droiddeck_color_last_frame_age_ms(void);
|
||||
/* -1 = the compositor has not decided yet, 0 = closed, 1 = open. */
|
||||
int droiddeck_color_gate_state(void);
|
||||
/* The session is ending: write the summary line ("HDR on screen: …"). */
|
||||
void droiddeck_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 droiddeck_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 droiddeck_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 droiddeck_color_hdr_state(void);
|
||||
/* Nits SDR content is placed at inside an HDR picture (default 203, BT.2408); any thread. */
|
||||
void droiddeck_color_set_sdr_white(float nits);
|
||||
float droiddeck_color_sdr_white(void);
|
||||
/* The HDR session was asked for (DROIDDECK_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 droiddeck_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 droiddeck_host_hdr_output); logs the flip and redraws. */
|
||||
void droiddeck_color_set_output(int on);
|
||||
/* 1 = HDR output on (any thread). */
|
||||
int droiddeck_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 droiddeck_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 droiddeck_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 droiddeck_color_desired_headroom(const struct droiddeck_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 droiddeck_color_note_headroom_request(float ratio);
|
||||
/* Display.getHighestHdrSdrRatio() (Android 16+; <= 0 = not reported). Any thread; logged when it arrives. */
|
||||
void droiddeck_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 droiddeck_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 droiddeck_color_init(struct wl_display *display);
|
||||
/* The gate is open: the 10-bit dma-buf formats may be advertised, descriptions may exist. */
|
||||
int droiddeck_color_hdr_open(void);
|
||||
/* wl_surface.commit: the pending image description (if any request touched it) becomes current. */
|
||||
void droiddeck_color_commit(struct wl_resource *surface);
|
||||
/* The surface's current image description; NULL = none (sRGB, today's default). */
|
||||
const struct droiddeck_color *droiddeck_color_of(struct wl_resource *surface);
|
||||
/* A program disconnected: if it presented HDR, its part of the summary is written now. */
|
||||
void droiddeck_color_client_gone(struct wl_client *client);
|
||||
/* The 10 s summary tick (one `color` line when anything HDR happened in the window). */
|
||||
void droiddeck_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 droiddeck_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 droiddeck_hdr_path {
|
||||
DROIDDECK_HDR_ZERO_COPY = 0, /* the game's own gralloc buffer on its display layer, tagged */
|
||||
DROIDDECK_HDR_LAYER_COPY, /* one 8-bit copy of the game's frame on its layer, tagged */
|
||||
DROIDDECK_HDR_COMPOSED, /* the whole scene composed into one PQ picture on the game layer (hdr_compose.h) */
|
||||
DROIDDECK_HDR_SWAPCHAIN, /* composed into PQ and presented through an HDR10 swapchain (frame generation) */
|
||||
DROIDDECK_HDR_TONEMAPPED, /* composed and tone-mapped to SDR (HDR output switched off, or a present that
|
||||
* cannot carry HDR) - NOT HDR */
|
||||
DROIDDECK_HDR_ZERO_COPY = 0,
|
||||
DROIDDECK_HDR_LAYER_COPY,
|
||||
DROIDDECK_HDR_COMPOSED,
|
||||
DROIDDECK_HDR_SWAPCHAIN,
|
||||
DROIDDECK_HDR_TONEMAPPED,
|
||||
|
||||
};
|
||||
/* ahb_format = the buffer's AHARDWAREBUFFER_FORMAT_* where one exists (0 otherwise). */
|
||||
void droiddeck_color_frame_shown(const struct droiddeck_color *c, int path, uint32_t ahb_format);
|
||||
/* "RGBA1010102 (10-bit)" etc. for an AHARDWAREBUFFER_FORMAT_* value (static buffer). */
|
||||
const char *droiddeck_ahb_format_name(uint32_t format);
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,3 @@
|
||||
/*
|
||||
* 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
|
||||
* droiddeck_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>
|
||||
@@ -83,7 +75,7 @@ static int on_wake(int fd, uint32_t mask, void *data) {
|
||||
if (!m) break;
|
||||
switch (m->kind) {
|
||||
case HOST_CLIPBOARD:
|
||||
clipboard_host_text(m->text, m->len); /* takes the buffer */
|
||||
clipboard_host_text(m->text, m->len);
|
||||
m->text = NULL;
|
||||
break;
|
||||
case HOST_TEXT_COMMIT:
|
||||
@@ -114,7 +106,7 @@ void droiddeck_ext_init(struct wl_display *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) */
|
||||
int queued = g_head != NULL;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
if (queued) { char c = 1; ssize_t n = write(g_wake[1], &c, 1); (void)n; }
|
||||
} else
|
||||
|
||||
@@ -1,53 +1,38 @@
|
||||
/*
|
||||
* 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)
|
||||
* droiddeck_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 droiddeck_log(const char *tag, const char *fmt, ...);
|
||||
|
||||
/* ---- compositor.c → modules */
|
||||
void droiddeck_ext_init(struct wl_display *display); /* creates the globals + host queue */
|
||||
void droiddeck_clipboard_keyboard_focus(struct wl_client *client); /* keyboard focus moved; NULL = none */
|
||||
void droiddeck_text_input_refocus(void); /* the text-input target may have changed */
|
||||
|
||||
void droiddeck_ext_init(struct wl_display *display);
|
||||
void droiddeck_clipboard_keyboard_focus(struct wl_client *client);
|
||||
void droiddeck_text_input_refocus(void);
|
||||
void droiddeck_text_input_surface_gone(struct wl_resource *surface);
|
||||
|
||||
/* ---- modules → compositor.c */
|
||||
const char *droiddeck_client_name(struct wl_client *client);
|
||||
struct wl_display *droiddeck_get_display(void);
|
||||
/* The surface text input follows (the last clicked window, else the topmost program window). */
|
||||
struct wl_resource *droiddeck_ime_target(void);
|
||||
/* Scene (virtual desktop) origin of a toplevel surface; 0,0 when unknown. */
|
||||
void droiddeck_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 droiddeck_inject_key(uint32_t evdev, int pressed);
|
||||
|
||||
/* ---- modules → app (JNI upcalls; waylandcomp_jni.c) */
|
||||
void droiddeck_on_clipboard_text(const char *utf8, int len);
|
||||
void droiddeck_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 droiddeck_host_clipboard_text(const char *utf8, int len); /* len 0 = clear */
|
||||
|
||||
void droiddeck_host_clipboard_text(const char *utf8, int len);
|
||||
void droiddeck_host_text_commit(const char *utf8, int len);
|
||||
void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end);
|
||||
void droiddeck_host_text_delete(int before, int after);
|
||||
void droiddeck_host_zero_copy(int on, int live); /* the drawer's zero-copy switch (ahb_swapchain_set_mode) */
|
||||
void droiddeck_host_hdr_output(int on); /* the drawer's HDR output switch (droiddeck_color_set_output) */
|
||||
void droiddeck_host_zero_copy(int on, int live);
|
||||
void droiddeck_host_hdr_output(int on);
|
||||
|
||||
/* ---- module internals reached through the queue (droiddeck_ext.c → modules) */
|
||||
void clipboard_init(struct wl_display *display);
|
||||
void clipboard_host_text(char *utf8, size_t len); /* takes ownership of utf8 */
|
||||
void clipboard_host_text(char *utf8, size_t len);
|
||||
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);
|
||||
void single_pixel_init(struct wl_display *display);
|
||||
/* A wp_single_pixel_buffer_manager_v1 buffer: 1 and its pixel (B, G, R, A, premultiplied), else 0. */
|
||||
int single_pixel_buffer_get(struct wl_resource *buffer, uint8_t bgra[4]);
|
||||
@@ -1,16 +1,12 @@
|
||||
/* 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" /* droiddeck_log */
|
||||
#include "vk_present.h"
|
||||
#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/framegen/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"
|
||||
@@ -26,25 +22,24 @@
|
||||
#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). */
|
||||
#define FX_FORMAT VK_FORMAT_R8G8B8A8_UNORM
|
||||
|
||||
|
||||
|
||||
|
||||
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 */
|
||||
#define FX_MAX_DIM 4096
|
||||
|
||||
/* ------------------------------------------------------------------ settings */
|
||||
|
||||
struct fx_settings {
|
||||
int scaling; /* 0..8 */
|
||||
int sharp_pct; /* 0..100, the upscaler's own slider */
|
||||
int scaling;
|
||||
int sharp_pct;
|
||||
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 deband_on, deband_pct;
|
||||
int color_on;
|
||||
float brightness, contrast, gamma, saturation;
|
||||
float b_raw, c_raw, s_raw;
|
||||
int fxaa, toon, crt, ntsc;
|
||||
char look[48];
|
||||
};
|
||||
@@ -54,7 +49,7 @@ 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 struct fx_settings g_cur;
|
||||
static int g_cur_valid;
|
||||
|
||||
static void set_begin(void) { pthread_mutex_lock(&g_lock); }
|
||||
@@ -83,7 +78,6 @@ void vkp_effects_set_deband(int enabled, int pct) {
|
||||
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;
|
||||
@@ -157,18 +151,17 @@ VkFilter vkp_effects_blit_filter(void) {
|
||||
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_sgsr { float ndc[4]; float vp[4]; float edge; };
|
||||
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_res { float ndc[4]; float res[2]; float extra; float pad; };
|
||||
struct pc_color { float ndc[4]; float b, c, g, s; };
|
||||
#define PC_MAX_SIZE sizeof(struct pc_easu) /* 88 bytes, the largest */
|
||||
#define PC_MAX_SIZE sizeof(struct pc_easu)
|
||||
|
||||
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);
|
||||
@@ -183,7 +176,6 @@ 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;
|
||||
@@ -193,16 +185,16 @@ struct fx_target {
|
||||
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 int g_ready;
|
||||
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 */
|
||||
static VkSampler g_sampler;
|
||||
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 fx_target g_t[2], g_mid;
|
||||
|
||||
static struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } g_scene;
|
||||
static uint32_t g_ntsc_frame;
|
||||
|
||||
@@ -249,15 +241,9 @@ static void target_destroy(struct fx_target *t) {
|
||||
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);
|
||||
/* Unrestricted mutable views keep these render-then-blit targets uncompressed on Turnip.
|
||||
* UBWC targets corrupt even a constant-colour pass on Adreno 740 (FSR becomes black).
|
||||
* Only the chain's intermediate images need this; the scene and guest images stay unchanged. */
|
||||
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, .imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = g_fx_fmt, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1,
|
||||
@@ -316,8 +302,6 @@ static VkShaderModule shader(const uint32_t *code, size_t size) {
|
||||
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) { droiddeck_log("error", "effects: %s: vkCreateShaderModule failed", name); return VK_NULL_HANDLE; }
|
||||
@@ -370,7 +354,6 @@ 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;
|
||||
@@ -387,14 +370,9 @@ void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_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; droiddeck_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,
|
||||
@@ -465,7 +443,6 @@ fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ recording */
|
||||
|
||||
static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to,
|
||||
VkPipelineStageFlags src_stage, VkAccessFlags src_access,
|
||||
@@ -477,7 +454,6 @@ static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImag
|
||||
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,
|
||||
@@ -504,36 +480,26 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
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 */
|
||||
struct fx_target *cur = NULL;
|
||||
#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,
|
||||
@@ -544,20 +510,17 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
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. */
|
||||
} else {
|
||||
|
||||
|
||||
struct pc_easu e = {0};
|
||||
struct pc_rcas r = {0};
|
||||
SET_NDC(e);
|
||||
@@ -571,8 +534,6 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
}
|
||||
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,
|
||||
@@ -588,16 +549,12 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
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;
|
||||
@@ -626,7 +583,6 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
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;
|
||||
@@ -638,23 +594,18 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
|
||||
#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);
|
||||
|
||||
@@ -1,85 +1,33 @@
|
||||
#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/framegen, 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: release the cached source view/descriptor before its owner destroys img.
|
||||
* A later image can reuse the same Vulkan handle and dimensions; that is not the same resource. */
|
||||
void vkp_effects_forget_image(VkImage img);
|
||||
|
||||
/* 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
|
||||
@@ -1,4 +1,3 @@
|
||||
/* Frame generation on the Wayland backend - see framegen_bridge.h. */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "framegen_bridge.h"
|
||||
#include "framegen_engine.h"
|
||||
@@ -15,20 +14,18 @@ void droiddeck_log(const char *tag, const char *fmt, ...) __attribute__((format(
|
||||
#define FGLOG(...) droiddeck_log("framegen", __VA_ARGS__)
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "DroidDeckWayland", __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_target; /* LSFG adaptive fps, 0 = fixed multiplier */
|
||||
static _Atomic int g_target;
|
||||
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 float g_flow = 0.8f, g_refresh_hz;
|
||||
static char *g_cache_path;
|
||||
static _Atomic int g_cache_gen;
|
||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* ---- device -------------------------------------------------------------------------- */
|
||||
static VkDevice g_dev;
|
||||
static VkInstance g_inst;
|
||||
static PFN_vkGetInstanceProcAddr g_gipa;
|
||||
@@ -50,12 +47,10 @@ static struct {
|
||||
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_cache_gen = -1; /* the LSFG cache it loaded */
|
||||
|
||||
static int g_engine_kind = -1;
|
||||
static int g_engine_cache_gen = -1;
|
||||
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;
|
||||
|
||||
@@ -65,11 +60,10 @@ 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 uint32_t g_planned;
|
||||
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) {
|
||||
@@ -77,10 +71,10 @@ static int format_refused(VkFormat f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---- stats ------------------------------------------------------------------------- */
|
||||
static _Atomic unsigned g_stat_generated; /* since the last stats_take */
|
||||
|
||||
static _Atomic unsigned g_stat_generated;
|
||||
static uint64_t g_total_generated;
|
||||
static float g_presented_rate, g_source_rate; /* smoothed, 0.5 s windows */
|
||||
static float g_presented_rate, g_source_rate;
|
||||
static uint32_t g_present_accum, g_source_accum;
|
||||
static int64_t g_window_start_ns;
|
||||
|
||||
@@ -89,7 +83,6 @@ static int64_t now_ns(void) {
|
||||
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;
|
||||
@@ -100,7 +93,6 @@ void vkp_framegen_set_engine(int kind) {
|
||||
|
||||
void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) {
|
||||
if (target_fps < 0) target_fps = 0;
|
||||
/* Adaptive sizes the ring and the swapchain for the most it may ever generate. */
|
||||
if (target_fps) multiplier = VKP_FG_MAX_GENERATIONS + 1;
|
||||
if (multiplier < 2) multiplier = 2;
|
||||
if (multiplier > VKP_FG_MAX_GENERATIONS + 1) multiplier = VKP_FG_MAX_GENERATIONS + 1;
|
||||
@@ -147,8 +139,6 @@ static void mark_failed(int kind) {
|
||||
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);
|
||||
@@ -162,8 +152,6 @@ 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;
|
||||
@@ -174,7 +162,6 @@ void vkp_framegen_stats(float out[6]) {
|
||||
|
||||
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) {
|
||||
@@ -199,7 +186,6 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
|
||||
|
||||
void vkp_framegen_device_lost(void) { g_dev_lost = 1; }
|
||||
|
||||
/* ====================================================================== ring */
|
||||
|
||||
static void destroy_ring(void) {
|
||||
if (!g_ring_n) return;
|
||||
@@ -220,9 +206,6 @@ static int memory_type(uint32_t bits, VkMemoryPropertyFlags want) {
|
||||
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;
|
||||
@@ -257,7 +240,6 @@ static int ensure_ring(uint32_t w, uint32_t h, VkFormat fmt, uint32_t n) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ====================================================================== present path */
|
||||
|
||||
static int engine_usable(void) {
|
||||
int kind = atomic_load(&g_kind);
|
||||
@@ -270,8 +252,6 @@ int vkp_framegen_format_ok(VkFormat fmt) {
|
||||
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 "
|
||||
@@ -321,7 +301,6 @@ static int ensure_engine(int kind) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* "x3 (2 interpolated frames per game frame)" or "adaptive to 90 fps (up to 3 ...)". */
|
||||
static const char *describe_mode(char *buf, size_t n, int mult, int target) {
|
||||
if (target) snprintf(buf, n, "adaptive to %d fps (up to %d interpolated frames per game frame)", target, mult - 1);
|
||||
else snprintf(buf, n, "x%d (%d interpolated frame%s per game frame)", mult, mult - 1, mult == 2 ? "" : "s");
|
||||
@@ -397,9 +376,6 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
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){
|
||||
@@ -425,15 +401,12 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
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){
|
||||
@@ -466,7 +439,7 @@ void vkp_framegen_presented(int 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 */
|
||||
if (elapsed < 0.5f) return;
|
||||
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;
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
#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 Bannerlator's X11 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
|
||||
@@ -29,63 +7,28 @@
|
||||
#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, or target_fps > 0 for LSFG's adaptive mode (up to 4x, as the target needs);
|
||||
* armed = 0 stops generating (the ring and the engine stay for a re-arm). */
|
||||
void vkp_framegen_set_armed(int armed, int multiplier, int target_fps);
|
||||
/* LSFG Native: the SPIR-V cache built from the user's Lossless.dll (Lossless.sync); a new path reloads the engine. */
|
||||
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
|
||||
@@ -1,9 +1,3 @@
|
||||
// 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 framegen/lsfg or framegen/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>
|
||||
@@ -14,7 +8,7 @@
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "VulkanRendererContext.h" // VkTable
|
||||
#include "VulkanRendererContext.h"
|
||||
#include "lsfg/lsfg_engine.h"
|
||||
#include "lsfg/lsfg_probe.h"
|
||||
#include "lsfg/lsfg_vkd.h"
|
||||
@@ -40,13 +34,10 @@ 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) \
|
||||
@@ -78,7 +69,7 @@ void fill_device(VkDevice dev) {
|
||||
#undef X
|
||||
}
|
||||
|
||||
} // namespace
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -96,9 +87,9 @@ const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
||||
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.features = lsfg::queryFeatures(g_table, pd, exts, false);
|
||||
g_caps.probedFormat = ring_fmt;
|
||||
g_caps.storageOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||
? lsfg::probeStorageFormat(g_table, pd, ring_fmt) : false;
|
||||
@@ -110,7 +101,6 @@ const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
||||
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;
|
||||
@@ -207,8 +197,6 @@ void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, f
|
||||
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;
|
||||
}
|
||||
@@ -247,4 +235,4 @@ void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
||||
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"
|
||||
}
|
||||
@@ -1,16 +1,5 @@
|
||||
#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 (framegen/lsfg) and winfg::Engine (framegen/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 framegen 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
|
||||
@@ -21,49 +10,27 @@
|
||||
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);
|
||||
/* target_fps > 0: LSFG picks 0..3 generations per frame to reach it (Win-FG ignores it). */
|
||||
void fge_configure(uint32_t multiplier, uint32_t target_fps, 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
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* Stand-in for framegen_engine.cpp when the compositor is built on its own (standalone/, no
|
||||
* framegen 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,
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
/* 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"
|
||||
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
/* 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" /* droiddeck_log, vkp_gpu_name */
|
||||
#include "vk_present.h"
|
||||
#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/framegen). */
|
||||
/* 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
|
||||
@@ -18,24 +12,20 @@
|
||||
|
||||
#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 */
|
||||
struct pc_encode { float ndc[4]; float params[4]; float rects[HDRC_MAX_RECTS][4]; };
|
||||
|
||||
static VkDevice g_dev;
|
||||
static int g_ready; /* 0 = not built, 1 = ok, -1 = unavailable (said once) */
|
||||
static int g_ready;
|
||||
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];
|
||||
@@ -92,9 +82,6 @@ static VkShaderModule shader(const uint32_t *code, size_t size) {
|
||||
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,
|
||||
@@ -261,7 +248,6 @@ int hdrc_encode(VkCommandBuffer cmd, VkImage mixed, VkImage out, VkFormat out_fm
|
||||
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,
|
||||
|
||||
@@ -1,22 +1,5 @@
|
||||
#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>
|
||||
|
||||
@@ -26,26 +9,17 @@ 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 */
|
||||
float sdr_white_nits;
|
||||
float peak_nits;
|
||||
int count;
|
||||
unsigned hdr_mask;
|
||||
float rects[HDRC_MAX_RECTS][4];
|
||||
};
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
@@ -1,38 +1,12 @@
|
||||
#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
|
||||
vec4 ndc;
|
||||
vec4 params;
|
||||
vec4 rects[6];
|
||||
} pc;
|
||||
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
@@ -44,7 +18,6 @@ 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);
|
||||
@@ -64,25 +37,21 @@ vec3 linearToSrgb(vec3 c) {
|
||||
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
|
||||
float rate = max(span / 3.912, 1.0 - knee);
|
||||
return knee + (1.0 - knee) * (1.0 - exp(-(x - knee) / rate));
|
||||
}
|
||||
|
||||
@@ -107,7 +76,6 @@ void main() {
|
||||
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 {
|
||||
@@ -115,7 +83,6 @@ void main() {
|
||||
outc = linearToPq(nits / 10000.0);
|
||||
}
|
||||
} else {
|
||||
// SDR out: sRGB BT.709, HDR tone-mapped.
|
||||
if (!hdr) {
|
||||
outc = c;
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// 1116.5.0
|
||||
#pragma once
|
||||
const uint32_t hdr_encode_code[] = {
|
||||
0x07230203,0x00010000,0x0008000b,0x0000018e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
#ifndef HEADPOSE_SHM_H
|
||||
#define HEADPOSE_SHM_H
|
||||
/*
|
||||
* The head pose Cardboard mode tracks, shared with the guest: a 128-byte file the compositor maps
|
||||
* at <files>/.wayland-rt/droiddeck-headpose, which the guest sees as /run/droiddeck/droiddeck-headpose.
|
||||
* Written by the app (cardboard.c) at the sensor's rate; read by guest VR code (the SteamVR driver in
|
||||
* tools/vr) without any call into the app.
|
||||
*
|
||||
* Seqlock: the writer makes seq odd, writes the rest, then makes it even again. A reader copies the
|
||||
* struct and keeps the copy only if seq was even and unchanged across the copy.
|
||||
*
|
||||
* Axes are OpenVR's (and the cardboard shader's): x right, y up, z back (-z is straight ahead).
|
||||
* rot maps head directions to the recentred world, row-major. time_ns is CLOCK_MONOTONIC, the same
|
||||
* clock inside the guest (one kernel).
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
#define DROIDDECK_HEADPOSE_MAGIC 0x50484444u /* "DDHP" */
|
||||
#define DROIDDECK_HEADPOSE_MAGIC 0x50484444u
|
||||
#define DROIDDECK_HEADPOSE_VERSION 1u
|
||||
#define DROIDDECK_HEADPOSE_FILE "droiddeck-headpose"
|
||||
|
||||
enum {
|
||||
DROIDDECK_HEADPOSE_LIVE = 1u << 0, /* a rotation sensor is feeding it (else identity) */
|
||||
DROIDDECK_HEADPOSE_ENABLED = 1u << 1, /* Cardboard mode is on */
|
||||
DROIDDECK_HEADPOSE_LIVE = 1u << 0,
|
||||
DROIDDECK_HEADPOSE_ENABLED = 1u << 1,
|
||||
};
|
||||
|
||||
struct droiddeck_headpose {
|
||||
@@ -32,11 +19,9 @@ struct droiddeck_headpose {
|
||||
float rot[9];
|
||||
float ipd_m;
|
||||
int64_t time_ns;
|
||||
/* What the lens pass expects of a side-by-side source, so a VR renderer can match it: one eye's
|
||||
* half of the frame covers tan_half_fov up and down and eye_aspect times that left and right. */
|
||||
float tan_half_fov;
|
||||
float eye_aspect;
|
||||
uint32_t eye_w, eye_h; /* one eye's viewport on the panel, pixels (0 = not drawn yet) */
|
||||
uint32_t eye_w, eye_h;
|
||||
uint32_t reserved[12];
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/* Layer mode: the scene on a small set of ASurfaceControl layers - see sc_layer.h and
|
||||
* ZERO_COPY_SPIKE.md. The ASurfaceControl/ASurfaceTransaction API is dlsym'd from libandroid.so
|
||||
* (API 29+), the same way the X11 renderers' scanout code does it, so the library still loads on
|
||||
* older devices and the prototype stays off every other path. */
|
||||
#define _GNU_SOURCE
|
||||
#include "sc_layer.h"
|
||||
#include "ahb_swapchain.h"
|
||||
@@ -25,25 +21,21 @@
|
||||
|
||||
#define FOURCC(a, b, c, d) \
|
||||
((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
#define DRM_ABGR8888 FOURCC('A', 'B', '2', '4') /* R,G,B,A in memory = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM */
|
||||
#define DRM_ABGR2101010 FOURCC('A', 'B', '3', '0') /* = AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM (VK A2B10G10R10) */
|
||||
#define DRM_ABGR8888 FOURCC('A', 'B', '2', '4')
|
||||
#define DRM_ABGR2101010 FOURCC('A', 'B', '3', '0')
|
||||
#define AHB_RGBA8 AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM
|
||||
#define AHB_RGB10A2 AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM
|
||||
#define MOD_LINEAR 0ULL
|
||||
#define MOD_QCOM_COMPRESSED 0x0500000000000001ULL /* DRM_FORMAT_MOD_QCOM_COMPRESSED (UBWC) */
|
||||
#define MOD_QCOM_COMPRESSED 0x0500000000000001ULL
|
||||
|
||||
/* The gralloc buffer handle behind an AHardwareBuffer (AOSP cutils/native_handle.h, which the NDK
|
||||
* does not ship; the layout is a stable ABI: fds first, then ints). */
|
||||
struct droiddeck_native_handle { int version; int numFds; int numInts; int data[]; };
|
||||
|
||||
/* ---- libandroid SurfaceControl API (dlsym) ---------------------------------------------------- */
|
||||
|
||||
typedef struct ASurfaceControl ASurfaceControl;
|
||||
typedef struct ASurfaceTransaction ASurfaceTransaction;
|
||||
typedef struct ASurfaceTransactionStats ASurfaceTransactionStats;
|
||||
typedef void (*sc_complete_fn)(void *context, ASurfaceTransactionStats *stats);
|
||||
|
||||
/* <android/hdr_metadata.h> (NDK, API 29), declared here like the rest of this table: stable ABI. */
|
||||
struct droiddeck_color_xy { float x, y; };
|
||||
struct droiddeck_hdr_smpte2086 {
|
||||
struct droiddeck_color_xy displayPrimaryRed, displayPrimaryGreen, displayPrimaryBlue, whitePoint;
|
||||
@@ -65,22 +57,14 @@ static struct {
|
||||
void (*reparent)(ASurfaceTransaction *, ASurfaceControl *, ASurfaceControl *);
|
||||
void (*setOnComplete)(ASurfaceTransaction *, void *, sc_complete_fn);
|
||||
int (*prevReleaseFence)(ASurfaceTransactionStats *, ASurfaceControl *);
|
||||
/* Display frame-rate vote for the layer (API 30 / 31). Optional: absent on older Android, where
|
||||
* the layer simply carries no vote and the app's surface vote is all there is. */
|
||||
void (*setFrameRate)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t);
|
||||
void (*setFrameRateStrategy)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t, int8_t);
|
||||
/* Colour (API 29), optional: only an HDR session ever calls them (droiddeck_color.h's gate needs
|
||||
* setBufferDataSpace; the metadata calls are sent when present). */
|
||||
void (*setBufferDataSpace)(ASurfaceTransaction *, ASurfaceControl *, int32_t);
|
||||
void (*setHdrMetadata_smpte2086)(ASurfaceTransaction *, ASurfaceControl *, const struct droiddeck_hdr_smpte2086 *);
|
||||
void (*setHdrMetadata_cta861_3)(ASurfaceTransaction *, ASurfaceControl *, const struct droiddeck_hdr_cta861_3 *);
|
||||
/* Not in the public NDK headers (vndk/hardware_buffer.h) but exported by libnativewindow.so on
|
||||
* every device; Mesa's Android WSI calls it for every gralloc buffer it imports. */
|
||||
const void *(*getNativeHandle)(const AHardwareBuffer *);
|
||||
/* API 35: the HDR headroom this layer asks the display for (0 = no preference). Round 2e asks
|
||||
* explicitly for every PQ layer - some phones only boost HDR when a layer asks. */
|
||||
void (*setDesiredHdrHeadroom)(ASurfaceTransaction *, ASurfaceControl *, float);
|
||||
int state; /* 0 = untried, 1 = loaded, -1 = unavailable */
|
||||
int state;
|
||||
} api;
|
||||
|
||||
#define ASC_VISIBILITY_HIDE 0
|
||||
@@ -132,83 +116,74 @@ static int load_api(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---- display frame-rate vote (VRR / refresh-rate matching) ------------------------------------ */
|
||||
/* The app votes a panel cadence with Surface.setFrameRate on the compositor's SurfaceView, but a
|
||||
* zero-copy game's frames never touch that surface - they go straight onto the GAME layer - so
|
||||
* SurfaceFlinger needs the same vote there or the layer's cadence is invisible to it. The vote
|
||||
* belongs to the layer the game is actually presenting on and to no other: the overlay layer
|
||||
* carries a window that updates on its own (slow) schedule and is explicitly voted 0, so it never
|
||||
* drags the panel. The rate is set from the app thread and applied on the compositor thread with
|
||||
* the next transaction, so no transaction is ever created off-thread. 0 = no vote (panel free). */
|
||||
#define ASC_FRAME_RATE_COMPAT_DEFAULT 0 /* == ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT */
|
||||
#define ASC_CHANGE_FRAME_RATE_ALWAYS 1 /* == ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS */
|
||||
|
||||
static _Atomic float g_fps_want; /* what the app asked for (the game's cadence) */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define ASC_FRAME_RATE_COMPAT_DEFAULT 0
|
||||
#define ASC_CHANGE_FRAME_RATE_ALWAYS 1
|
||||
|
||||
static _Atomic float g_fps_want;
|
||||
|
||||
void sc_layer_set_frame_rate(float fps) {
|
||||
atomic_store(&g_fps_want, fps > 0.0f ? fps : 0.0f);
|
||||
}
|
||||
|
||||
/* ---- the layers and their buffer pools -------------------------------------------------------- */
|
||||
|
||||
/* Five for the game layer: one on screen, one queued, and the ones SurfaceFlinger has not reported
|
||||
* back yet (its OnComplete for a transaction arrives only after the NEXT frame is presented), with
|
||||
* room to spare, so a free buffer is nearly always one the display already let go of. With three,
|
||||
* a late callback left none free ("no free layer buffer … frame dropped"). */
|
||||
#define POOL_MAX 5
|
||||
|
||||
struct slot {
|
||||
AHardwareBuffer *ahb;
|
||||
struct vkp_image *img; /* the AHB imported into the compositor's Turnip as a blit target */
|
||||
struct vkp_image *img;
|
||||
int w, h;
|
||||
uint32_t fmt; /* AHARDWAREBUFFER_FORMAT_*: RGBA8888, or RGBA1010102 for an HDR picture */
|
||||
int release_fd; /* SurfaceFlinger's release fence: signals when it stopped reading; -1 = none */
|
||||
int busy; /* set on the layer, or still referenced by SurfaceFlinger */
|
||||
uint32_t fmt;
|
||||
int release_fd;
|
||||
int busy;
|
||||
};
|
||||
|
||||
/* One Android display layer: its SurfaceControl, its own buffer pool and its own lifetime. The
|
||||
* z-order is fixed by the id (game below, overlay above); nothing is ever re-ordered at runtime. */
|
||||
struct layer {
|
||||
const char *name;
|
||||
int32_t z;
|
||||
int pool_n; /* buffers in this layer's pool (the game cycles more) */
|
||||
int pool_n;
|
||||
struct slot slots[POOL_MAX];
|
||||
ASurfaceControl *sc;
|
||||
ANativeWindow *win; /* the output window sc was created on */
|
||||
ANativeWindow *win;
|
||||
int shown;
|
||||
int cur_slot; /* pool slot of the buffer on the layer, -1 = none / not ours */
|
||||
void *cur_token; /* zero-copy: the game's buffer on the layer (NULL = a pool slot) */
|
||||
int cur_slot;
|
||||
void *cur_token;
|
||||
ARect geo_src, geo_dst;
|
||||
int geo_valid;
|
||||
int alloc_tier; /* how pool buffers are asked of gralloc (TIER_*), lowered on failure */
|
||||
int alloc_tier;
|
||||
uint64_t pool_modifier;
|
||||
int first_logged;
|
||||
int64_t drop_logged_ns;
|
||||
unsigned drops_unlogged; /* frames dropped since the last "no free layer buffer" line */
|
||||
/* The last pool layout written to the log, so a line is written per change, not per buffer. */
|
||||
unsigned drops_unlogged;
|
||||
|
||||
int logged_w, logged_h, logged_tier;
|
||||
uint32_t logged_fmt;
|
||||
uint64_t logged_mod;
|
||||
int votes_rate; /* 1: this layer carries the game's cadence (the game layer) */
|
||||
float fps_applied; /* the vote the live SurfaceControl already carries (-1 = none yet) */
|
||||
int recreate_pending; /* composition recovery: swap this layer's SurfaceControl for a fresh
|
||||
* one inside the next frame's transaction (see swap_sc_begin) */
|
||||
int32_t ds_applied; /* dataspace the live SurfaceControl carries; -1 = never set on it
|
||||
* (untouched, today's UNKNOWN), see apply_colour */
|
||||
uint32_t md_applied; /* identity of the image description whose metadata it carries, 0 = none */
|
||||
float hr_applied; /* desired HDR headroom the live SurfaceControl carries; < 0 = never set */
|
||||
int votes_rate;
|
||||
float fps_applied;
|
||||
int recreate_pending;
|
||||
|
||||
int32_t ds_applied;
|
||||
|
||||
uint32_t md_applied;
|
||||
float hr_applied;
|
||||
};
|
||||
|
||||
static struct layer g_layers[SC_LAYER_COUNT];
|
||||
static void apply_frame_rate(ASurfaceTransaction *tx, struct layer *l);
|
||||
static void coverage_text(const struct layer *l, char *out, size_t n);
|
||||
static int g_layers_ready;
|
||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; /* pools + callback state */
|
||||
static int g_pending_cb; /* OnComplete callbacks not yet delivered */
|
||||
static unsigned g_stat_layer_frames; /* frames put on a layer through our own buffers */
|
||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int g_pending_cb;
|
||||
static unsigned g_stat_layer_frames;
|
||||
static int g_two_logged;
|
||||
/* A small buffer set on a layer when it is hidden or retired, so SurfaceFlinger replaces (and
|
||||
* releases, with a fence) the game's buffer instead of holding it while the layer is invisible. */
|
||||
static AHardwareBuffer *g_blank;
|
||||
|
||||
static void layers_init(void) {
|
||||
@@ -231,10 +206,10 @@ static struct layer *layer_of(int id) {
|
||||
|
||||
struct complete_ctx {
|
||||
ASurfaceControl *sc;
|
||||
int layer; /* which layer's pool prev_slot belongs to */
|
||||
int prev_slot; /* pool buffer this transaction replaced: free once its release fence is known */
|
||||
void *prev_token; /* or the game's buffer it replaced: ahb_swapchain gets its release fence */
|
||||
int retire; /* release sc after this transaction (hide + reparent) */
|
||||
int layer;
|
||||
int prev_slot;
|
||||
void *prev_token;
|
||||
int retire;
|
||||
};
|
||||
|
||||
static int64_t now_ns(void) {
|
||||
@@ -242,7 +217,6 @@ static int64_t now_ns(void) {
|
||||
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||
}
|
||||
|
||||
/* Binder thread. */
|
||||
static void on_complete(void *context, ASurfaceTransactionStats *stats) {
|
||||
struct complete_ctx *ctx = context;
|
||||
pthread_mutex_lock(&g_lock);
|
||||
@@ -257,15 +231,12 @@ static void on_complete(void *context, ASurfaceTransactionStats *stats) {
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
if (ctx->prev_token) {
|
||||
int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1;
|
||||
ahb_swapchain_layer_released(ctx->prev_token, fd); /* takes the fd */
|
||||
ahb_swapchain_layer_released(ctx->prev_token, fd);
|
||||
}
|
||||
if (ctx->retire && ctx->sc) api.release(ctx->sc);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
/* `sc` is the SurfaceControl the REPLACED buffer sits on, which is not always l->sc: during a
|
||||
* composition-recovery swap the outgoing buffer belongs to the old SurfaceControl, and both its
|
||||
* release fence and its release must be taken from that one. */
|
||||
static int add_complete_on(ASurfaceTransaction *tx, struct layer *l, ASurfaceControl *sc,
|
||||
int prev_slot, void *prev_token, int retire) {
|
||||
struct complete_ctx *ctx = calloc(1, sizeof(*ctx));
|
||||
@@ -283,7 +254,6 @@ static int add_complete(ASurfaceTransaction *tx, struct layer *l, int prev_slot,
|
||||
return add_complete_on(tx, l, l->sc, prev_slot, prev_token, retire);
|
||||
}
|
||||
|
||||
/* The stand-in buffer for a hidden/retired layer (allocated once, black, shared by both layers). */
|
||||
static AHardwareBuffer *blank_buffer(void) {
|
||||
if (g_blank) return g_blank;
|
||||
AHardwareBuffer_Desc d = {
|
||||
@@ -300,15 +270,11 @@ static AHardwareBuffer *blank_buffer(void) {
|
||||
return g_blank;
|
||||
}
|
||||
|
||||
/* Take the current buffer (pool slot or the game's) off the layer by putting the blank one on it,
|
||||
* so SurfaceFlinger releases it with a fence through this transaction's callback. */
|
||||
static void replace_with_blank(ASurfaceTransaction *tx, struct layer *l) {
|
||||
AHardwareBuffer *b = blank_buffer();
|
||||
if (b) api.setBuffer(tx, l->sc, b, -1);
|
||||
}
|
||||
|
||||
/* Everything a SurfaceControl needs on its way out, as transaction ops: give the buffer back (so
|
||||
* SurfaceFlinger releases the game's, with a fence), hide it, unparent it. */
|
||||
static void retire_ops(ASurfaceTransaction *tx, ASurfaceControl *sc) {
|
||||
AHardwareBuffer *b = blank_buffer();
|
||||
if (b) api.setBuffer(tx, sc, b, -1);
|
||||
@@ -316,8 +282,6 @@ static void retire_ops(ASurfaceTransaction *tx, ASurfaceControl *sc) {
|
||||
api.reparent(tx, sc, NULL);
|
||||
}
|
||||
|
||||
/* Hide + detach one layer; the SurfaceControl is released from the transaction's callback (the
|
||||
* buffer on it stays referenced by SurfaceFlinger until then). */
|
||||
static void retire_sc(struct layer *l) {
|
||||
if (!l->sc) return;
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
@@ -333,13 +297,11 @@ static void retire_sc(struct layer *l) {
|
||||
droiddeck_log("layer", "%s: SurfaceControl retired (window %p)", l->name, (void *)l->win);
|
||||
l->sc = NULL; l->win = NULL;
|
||||
l->shown = 0; l->cur_slot = -1; l->cur_token = NULL; l->geo_valid = 0;
|
||||
l->fps_applied = -1.0f; /* the next SurfaceControl carries no vote until it is re-applied */
|
||||
l->recreate_pending = 0; /* a fresh SurfaceControl is coming anyway */
|
||||
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f; /* ...and no colour tag either */
|
||||
l->fps_applied = -1.0f;
|
||||
l->recreate_pending = 0;
|
||||
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f;
|
||||
}
|
||||
|
||||
/* Wait (bounded) for SurfaceFlinger to finish with every pool buffer of every layer, then free
|
||||
* the pools. */
|
||||
static void drain_and_free_pools(void) {
|
||||
int64_t deadline = now_ns() + 300000000LL;
|
||||
for (;;) {
|
||||
@@ -360,14 +322,11 @@ static void drain_and_free_pools(void) {
|
||||
s->release_fd = -1;
|
||||
}
|
||||
g_layers[i].first_logged = 0;
|
||||
g_layers[i].logged_w = g_layers[i].logged_h = 0; /* the next pool's layout is logged again */
|
||||
g_layers[i].logged_w = g_layers[i].logged_h = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
}
|
||||
|
||||
/* Native-handle sniff, the same one Mesa's u_gralloc fallback uses (u_gralloc_fallback.c): a QTI
|
||||
* gralloc private_handle_t carries the magic 'gmsm' as its first int and the UBWC flag
|
||||
* (PRIV_FLAGS_UBWC_ALIGNED, 0x08000000) in the next one. Returns 0 when the layout is unknown. */
|
||||
static int sniff_modifier(const struct droiddeck_native_handle *h, uint64_t *mod) {
|
||||
const uint32_t gmsm = ('g' << 24) | ('m' << 16) | ('s' << 8) | 'm';
|
||||
if (!h || h->numFds < 1 || h->numInts < 2) return 0;
|
||||
@@ -376,18 +335,10 @@ static int sniff_modifier(const struct droiddeck_native_handle *h, uint64_t *mod
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int g_alloc_failed; /* set by alloc_slot when gralloc or the import refused a buffer */
|
||||
static int g_alloc_failed;
|
||||
|
||||
/* How a layer's pool buffers are asked of gralloc, best first; a layer only ever moves down.
|
||||
* TIER_UBWC GPU render target + sampled + composer overlay + AHARDWAREBUFFER_USAGE_VENDOR_0 (bit 28):
|
||||
* QTI gralloc's GRALLOC_USAGE_PRIVATE_ALLOC_UBWC. Without it QTI gralloc allocates LINEAR even
|
||||
* for a GPU render target (gr_allocator.cpp IsUBwcEnabled: an explicit UBWC format, the
|
||||
* private UBWC bit or CLIENT_TARGET, and no CPU bit). Whether gralloc really compressed the
|
||||
* buffer is read back from its handle (sniff_modifier), never assumed.
|
||||
* TIER_PLAIN the same without the vendor bit (a gralloc that refuses unknown bits; what we asked before).
|
||||
* TIER_LINEAR plus a CPU bit, so the layout is known to be linear even when the handle is unreadable. */
|
||||
enum { TIER_UBWC, TIER_PLAIN, TIER_LINEAR };
|
||||
#define DROIDDECK_AHB_USAGE_VENDOR_UBWC (1ULL << 28) /* AHARDWAREBUFFER_USAGE_VENDOR_0 */
|
||||
#define DROIDDECK_AHB_USAGE_VENDOR_UBWC (1ULL << 28)
|
||||
|
||||
static const char *tier_name(int tier) {
|
||||
return tier == TIER_UBWC ? "asked for UBWC" : tier == TIER_PLAIN ? "no UBWC request" : "linear by request (CPU bit)";
|
||||
@@ -400,8 +351,6 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
|
||||
AHardwareBuffer_Desc d = {
|
||||
.width = (uint32_t)w, .height = (uint32_t)h, .layers = 1,
|
||||
.format = fmt,
|
||||
/* GPU render target (the blit writes it) + sampled (SurfaceFlinger's GPU fallback reads it) +
|
||||
* composer overlay (the display scans it out). See the tiers above for the rest. */
|
||||
.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
|
||||
AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY |
|
||||
(tier == TIER_UBWC ? DROIDDECK_AHB_USAGE_VENDOR_UBWC : 0) |
|
||||
@@ -422,8 +371,6 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
|
||||
const struct droiddeck_native_handle *nh = api.getNativeHandle(ahb);
|
||||
uint64_t mod = MOD_LINEAR;
|
||||
if (!sniff_modifier(nh, &mod)) {
|
||||
/* Not a handle we can read: the only layout we can assume is linear, and only if the buffer
|
||||
* was asked for with a CPU bit (gralloc must not have compressed it). */
|
||||
if (tier < TIER_LINEAR) {
|
||||
AHardwareBuffer_release(ahb);
|
||||
l->alloc_tier = TIER_LINEAR;
|
||||
@@ -434,8 +381,6 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
|
||||
mod = MOD_LINEAR;
|
||||
}
|
||||
int fd = (nh && nh->numFds > 0) ? nh->data[0] : -1;
|
||||
/* The test create: vkp_image_import_dmabuf creates the image with gralloc's explicit layout, so a
|
||||
* layout the compositor's Turnip refuses falls back a tier instead of drawing garbage. */
|
||||
struct vkp_image *img = fd >= 0 ? vkp_image_import_dmabuf(fd, fmt == AHB_RGB10A2 ? DRM_ABGR2101010 : DRM_ABGR8888,
|
||||
mod, w, h, got.stride * 4, 0, 1) : NULL;
|
||||
if (!img) {
|
||||
@@ -462,7 +407,6 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 1 when a sync_file has signalled (the display has stopped reading that buffer). */
|
||||
static int fence_signalled(int fd) {
|
||||
struct pollfd p = {.fd = fd, .events = POLLIN};
|
||||
int r;
|
||||
@@ -470,12 +414,6 @@ static int fence_signalled(int fd) {
|
||||
return r > 0;
|
||||
}
|
||||
|
||||
/* A slot SurfaceFlinger has handed back, holding a w x h buffer of AHB format fmt. -1 = none free (or
|
||||
* the buffer could not be made). A free slot whose release fence has already signalled is preferred;
|
||||
* otherwise the fence of the first free one is handed back in *wait_fd for the copy to wait on ON THE
|
||||
* GPU (vkp_blit_image / vkp_pass_copy_to consume it), so the compositor thread no longer blocks here.
|
||||
* Only a driver without VK_KHR_external_semaphore_fd still waits on the CPU, bounded, as before.
|
||||
* *wait_fd is -1 whenever nothing needs waiting for (and on every failure). */
|
||||
static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait_fd) {
|
||||
int idx = -1, pending = -1, fd = -1;
|
||||
*wait_fd = -1;
|
||||
@@ -493,8 +431,6 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
|
||||
if (fd >= 0 && fence_signalled(fd)) { close(fd); fd = -1; }
|
||||
struct slot *s = &l->slots[idx];
|
||||
if (s->ahb && (s->w != w || s->h != h || s->fmt != fmt)) {
|
||||
/* Size or format change: this slot is free, so it can be replaced at once (the display keeps its
|
||||
* own reference to the old buffer for as long as it reads it; the new one needs no wait). */
|
||||
if (fd >= 0) { close(fd); fd = -1; }
|
||||
vkp_image_destroy(s->img); AHardwareBuffer_release(s->ahb);
|
||||
memset(s, 0, sizeof(*s)); s->release_fd = -1;
|
||||
@@ -504,7 +440,6 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
|
||||
int r;
|
||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
||||
if (r == 0) {
|
||||
/* Still read by the display: keep its fence with it (the next use waits again), drop this frame. */
|
||||
pthread_mutex_lock(&g_lock);
|
||||
if (s->release_fd < 0) s->release_fd = fd; else close(fd);
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
@@ -521,7 +456,6 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
|
||||
return idx;
|
||||
}
|
||||
|
||||
/* ---- public --------------------------------------------------------------------------------- */
|
||||
|
||||
int sc_layer_available(void) { return load_api() == 0; }
|
||||
|
||||
@@ -529,8 +463,8 @@ void sc_layer_probe_dmabuf_fd(int fd) {
|
||||
static int done;
|
||||
if (done || fd < 0) return;
|
||||
done = 1;
|
||||
struct { uint32_t flags; int32_t fd; } exp = {.flags = 1u /* DMA_BUF_SYNC_READ */, .fd = -1};
|
||||
/* DMA_BUF_IOCTL_EXPORT_SYNC_FILE = _IOWR('b', 2, struct dma_buf_export_sync_file) */
|
||||
struct { uint32_t flags; int32_t fd; } exp = {.flags = 1u , .fd = -1};
|
||||
|
||||
if (ioctl(fd, _IOWR('b', 2, exp), &exp) == 0) {
|
||||
droiddeck_log("layer", "kernel exports sync_file fences from the game's dma-buf: zero-copy acquire fences can come from the buffer itself");
|
||||
if (exp.fd >= 0) close(exp.fd);
|
||||
@@ -540,8 +474,6 @@ void sc_layer_probe_dmabuf_fd(int fd) {
|
||||
}
|
||||
}
|
||||
|
||||
/* One layer's SurfaceControl on the current output window (created on first use, re-created after
|
||||
* a window change). -1 = no window / no API. */
|
||||
static int ensure_sc(struct layer *l) {
|
||||
if (load_api() != 0) return -1;
|
||||
ANativeWindow *win = vkp_window();
|
||||
@@ -564,16 +496,11 @@ static int ensure_sc(struct layer *l) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Geometry of a w x h buffer covering the scene, through the same mapping the blit path and the
|
||||
* app's touch mapping use. 1 = r filled, 0 = nothing of it is on screen, -1 = no mapping. */
|
||||
static int layer_geometry(int w, int h, int scene_w, int scene_h, int r[8]) {
|
||||
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
|
||||
return vkp_map_rect(w, h, scene_w, scene_h, r) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* The GAME layer's last placement, kept across SurfaceControl retires and swaps (l->geo_valid is
|
||||
* per-SurfaceControl and is cleared by both). This is the src -> dst the display actually works
|
||||
* with, and it is what decides whether a second layer is affordable - see overlay_affordable(). */
|
||||
static ARect g_game_src, g_game_dst;
|
||||
static int g_game_geo_known;
|
||||
|
||||
@@ -581,7 +508,7 @@ static void apply_geometry(ASurfaceTransaction *tx, struct layer *l, const int r
|
||||
ARect srcR = {r[0], r[1], r[2], r[3]}, dstR = {r[4], r[5], r[6], r[7]};
|
||||
if (l == &g_layers[SC_LAYER_GAME]) { g_game_src = srcR; g_game_dst = dstR; g_game_geo_known = 1; }
|
||||
if (!l->geo_valid || memcmp(&srcR, &l->geo_src, sizeof(srcR)) || memcmp(&dstR, &l->geo_dst, sizeof(dstR))) {
|
||||
api.setGeometry(tx, l->sc, &srcR, &dstR, 0 /* no transform: the DPU scales, never rotates */);
|
||||
api.setGeometry(tx, l->sc, &srcR, &dstR, 0 );
|
||||
l->geo_src = srcR; l->geo_dst = dstR; l->geo_valid = 1;
|
||||
char cov[96] = "";
|
||||
if (l->ds_applied > 0) coverage_text(l, cov, sizeof(cov));
|
||||
@@ -590,16 +517,11 @@ static void apply_geometry(ASurfaceTransaction *tx, struct layer *l, const int r
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the vote to tx when it differs from what this layer carries (compositor thread). Only the
|
||||
* layer the game presents on carries the game's rate; every other layer is voted 0, so a slow
|
||||
* overlay window can never hold the panel at the game's cadence (or the game's at the overlay's). */
|
||||
static void apply_frame_rate(ASurfaceTransaction *tx, struct layer *l) {
|
||||
float want = l->votes_rate ? atomic_load(&g_fps_want) : 0.0f;
|
||||
if (want == l->fps_applied) return;
|
||||
if (!api.setFrameRateStrategy && !api.setFrameRate) return;
|
||||
if (api.setFrameRateStrategy) {
|
||||
/* ALWAYS, like the app's own surface vote: the seamless-only default is ignored by a panel
|
||||
* sitting at its peak rate, which is exactly the case we need to move. */
|
||||
api.setFrameRateStrategy(tx, l->sc, want, ASC_FRAME_RATE_COMPAT_DEFAULT, ASC_CHANGE_FRAME_RATE_ALWAYS);
|
||||
} else {
|
||||
api.setFrameRate(tx, l->sc, want, ASC_FRAME_RATE_COMPAT_DEFAULT);
|
||||
@@ -610,13 +532,6 @@ static void apply_frame_rate(ASurfaceTransaction *tx, struct layer *l) {
|
||||
else if (!first) droiddeck_log("layer", "display frame-rate vote on %s cleared (panel runs free)", l->name);
|
||||
}
|
||||
|
||||
/* ---- colour (HDR, droiddeck_color.h) -------------------------------------------------------------
|
||||
* The layer is told what its buffer's pixels MEAN - the dataspace (BT2020_PQ for an HDR10 frame) and
|
||||
* the game's mastering / content-light metadata - in the same transaction as the buffer, so the
|
||||
* display never shows an HDR frame decoded as sRGB or the other way round. A layer that has never been
|
||||
* tagged is never touched: sessions without an HDR description make no colour call at all. */
|
||||
/* How much of the screen the layer's picture covers ("covers 80% of the screen (1920x1080 of 2400x1080)"):
|
||||
* some phones only switch to HDR for an HDR layer above a minimum area. Empty when unknown. */
|
||||
static void coverage_text(const struct layer *l, char *out, size_t n) {
|
||||
int ow = 0, oh = 0;
|
||||
vkp_output_size(&ow, &oh);
|
||||
@@ -628,8 +543,6 @@ static void coverage_text(const struct layer *l, char *out, size_t n) {
|
||||
snprintf(out, n, "covers %.0f%% of the screen (%dx%d of %dx%d)", pct > 100.0 ? 100.0 : pct, w, h, ow, oh);
|
||||
}
|
||||
|
||||
/* API 35: ask the display for HDR headroom explicitly while the layer carries an HDR frame, and clear the
|
||||
* request (0 = no preference) when it stops. Only on change; a layer never tagged is never touched. */
|
||||
static void apply_headroom(ASurfaceTransaction *tx, struct layer *l, const struct droiddeck_color *c) {
|
||||
static int said_missing;
|
||||
if (!api.setDesiredHdrHeadroom) {
|
||||
@@ -642,7 +555,7 @@ static void apply_headroom(ASurfaceTransaction *tx, struct layer *l, const struc
|
||||
return;
|
||||
}
|
||||
const float want = (c && c->dataspace) ? droiddeck_color_desired_headroom(c, NULL, 0) : 0.0f;
|
||||
if (l->hr_applied < 0.0f && want == 0.0f && !(c && c->dataspace)) return; /* never asked: leave it be */
|
||||
if (l->hr_applied < 0.0f && want == 0.0f && !(c && c->dataspace)) return;
|
||||
if (l->hr_applied >= 0.0f && fabsf(want - l->hr_applied) < 0.005f) return;
|
||||
char why[200] = "";
|
||||
if (c && c->dataspace) droiddeck_color_desired_headroom(c, why, sizeof(why));
|
||||
@@ -662,7 +575,7 @@ static void apply_colour(ASurfaceTransaction *tx, struct layer *l, const struct
|
||||
int32_t want = c ? c->dataspace : DROIDDECK_ADATASPACE_UNKNOWN;
|
||||
uint32_t md = (c && c->dataspace) ? c->identity : 0;
|
||||
if (!api.setBufferDataSpace) return;
|
||||
if (l->ds_applied < 0 && want == DROIDDECK_ADATASPACE_UNKNOWN) return; /* never tagged: leave it be */
|
||||
if (l->ds_applied < 0 && want == DROIDDECK_ADATASPACE_UNKNOWN) return;
|
||||
apply_headroom(tx, l, want ? c : NULL);
|
||||
if (want == l->ds_applied && md == l->md_applied) return;
|
||||
api.setBufferDataSpace(tx, l->sc, want);
|
||||
@@ -676,7 +589,6 @@ static void apply_colour(ASurfaceTransaction *tx, struct layer *l, const struct
|
||||
.maxLuminance = c->max_lum, .minLuminance = c->min_lum};
|
||||
}
|
||||
if (cta_on) cta = (struct droiddeck_hdr_cta861_3){.maxContentLightLevel = c->max_cll, .maxFrameAverageLightLevel = c->max_fall};
|
||||
/* NULL clears what a previous description set: metadata never outlives the frame it belongs to. */
|
||||
if (api.setHdrMetadata_smpte2086) api.setHdrMetadata_smpte2086(tx, l->sc, st_on ? &st : NULL);
|
||||
if (api.setHdrMetadata_cta861_3) api.setHdrMetadata_cta861_3(tx, l->sc, cta_on ? &cta : NULL);
|
||||
if (want) {
|
||||
@@ -706,8 +618,6 @@ void sc_layer_hdr_symbols(char *out, size_t size) {
|
||||
api.setDesiredHdrHeadroom ? "yes (asked for per HDR frame: content peak / SDR white)" : "no (Android < 15)");
|
||||
}
|
||||
|
||||
/* Once, when a second layer first goes up: HWC only composes a few layers before SurfaceFlinger
|
||||
* falls back to GPU client composition, so the count is deliberately capped and said out loud. */
|
||||
static void log_layer_count(void) {
|
||||
if (g_two_logged) return;
|
||||
g_two_logged = 1;
|
||||
@@ -718,34 +628,12 @@ static void log_layer_count(void) {
|
||||
g_layers[SC_LAYER_OVERLAY].name, (int)g_layers[SC_LAYER_OVERLAY].z, SC_LAYER_COUNT);
|
||||
}
|
||||
|
||||
/* ---- composition recovery ---------------------------------------------------------------------
|
||||
* When the overlay is retired and the scene is one fullscreen window again, the game layer is
|
||||
* marked for a swap and the swap rides the NEXT frame: a fresh SurfaceControl is created here, the
|
||||
* frame is put on it, and the old one is hidden and unparented IN THE SAME TRANSACTION. Because
|
||||
* SurfaceFlinger applies a transaction atomically there is never a composited frame with neither
|
||||
* layer on it - no black frame, and no dropped frame beyond the one layer creation. The outgoing
|
||||
* buffer is released through the OLD SurfaceControl's callback, which also releases it.
|
||||
*
|
||||
* MEASURED 2026-09-14, and the news is bad: on the Pocket FIT this does NOT bring hardware
|
||||
* composition back. The swap fires 6 ms after the overlay goes, SurfaceFlinger really does hand out
|
||||
* a new layer (its id changes), the game never drops a frame - and the composer still reports
|
||||
* `DEVICE/CLIENT` 24 s later. Neither does dropping the layer path entirely and re-creating the
|
||||
* SurfaceControl after a gap. The ONE thing that clears it is HOME + resume, which re-creates the
|
||||
* app's whole window and SurfaceView (`VRI[XServerDisplayActivity]#0` becomes `#4`) - so the sticky
|
||||
* client-composition state belongs to the PARENT surface (or the display), not to this child layer.
|
||||
* The phase-4 note that "only re-creating the GAME layer's SurfaceControl clears it" was inferred
|
||||
* from HOME + resume and is wrong; see sc_layer.h. The swap is kept because it is free and correct
|
||||
* and the mechanism may differ on hardware that does not rotate every layer - but do not claim it
|
||||
* restores DEVICE composition, and do not log as if it did.
|
||||
*
|
||||
* Returns the old SurfaceControl (the caller must add retire_ops for it to the same transaction and
|
||||
* name it in add_complete_on), or NULL when no swap is due. Compositor thread. */
|
||||
static ASurfaceControl *swap_sc_begin(struct layer *l) {
|
||||
if (!l->recreate_pending) return NULL;
|
||||
l->recreate_pending = 0;
|
||||
if (!l->sc) return NULL; /* nothing to swap; ensure_sc made a fresh one already */
|
||||
if (!l->sc) return NULL;
|
||||
ANativeWindow *win = vkp_window();
|
||||
if (!win || win != l->win) return NULL; /* the window changed: ensure_sc re-creates it anyway */
|
||||
if (!win || win != l->win) return NULL;
|
||||
ASurfaceControl *fresh = api.createFromWindow(win, l->name);
|
||||
if (!fresh) {
|
||||
droiddeck_log("error", "layer: %s: composition recovery could not create a new SurfaceControl", l->name);
|
||||
@@ -753,9 +641,6 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) {
|
||||
}
|
||||
ASurfaceControl *old = l->sc;
|
||||
l->sc = fresh;
|
||||
/* These describe the SurfaceControl, not the layer: the new one carries none of them yet.
|
||||
* cur_slot / cur_token are deliberately NOT cleared - they name the buffer still on the OLD
|
||||
* SurfaceControl, which is what the caller passes to add_complete_on as the one being replaced. */
|
||||
l->shown = 0;
|
||||
l->geo_valid = 0;
|
||||
l->fps_applied = -1.0f;
|
||||
@@ -765,16 +650,13 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) {
|
||||
return old;
|
||||
}
|
||||
|
||||
/* The transaction that puts pool slot `idx` of layer `l` on screen at `r`, as `color` (NULL = no
|
||||
* description). 0 = applied. */
|
||||
static int present_slot(struct layer *l, int idx, const int r[8], const struct droiddeck_color *color,
|
||||
int translucent) {
|
||||
struct slot *s = &l->slots[idx];
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
if (!tx) return -1;
|
||||
ASurfaceControl *old = swap_sc_begin(l); /* this frame carries the recovery swap, if one is due */
|
||||
ASurfaceControl *old = swap_sc_begin(l);
|
||||
if (old) api.setZOrder(tx, l->sc, l->z);
|
||||
/* The blit was waited for on the CPU, so no acquire fence is needed (-1). */
|
||||
api.setBuffer(tx, l->sc, s->ahb, -1);
|
||||
api.setBufferTransparency(tx, l->sc,
|
||||
translucent ? ASC_TRANSPARENCY_TRANSLUCENT : ASC_TRANSPARENCY_OPAQUE);
|
||||
@@ -784,7 +666,7 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
|
||||
if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW);
|
||||
if (old) retire_ops(tx, old);
|
||||
if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0 && old)
|
||||
api.release(old); /* no callback to retire it from (out of memory): let it go here */
|
||||
api.release(old);
|
||||
pthread_mutex_lock(&g_lock);
|
||||
s->busy = 1;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
@@ -797,8 +679,6 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* No free buffer this frame: the display still holds all of them. Counted for the 10 s perf line, and
|
||||
* logged at most every 30 s with the number of frames dropped since the last line. */
|
||||
static unsigned g_pool_drops;
|
||||
static void log_drop(struct layer *l) {
|
||||
g_pool_drops++;
|
||||
@@ -828,8 +708,6 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi
|
||||
if (g < 0) goto unavailable;
|
||||
if (g == 0) { if (acquire_fd >= 0) close(acquire_fd); sc_layer_hide(); return 1; }
|
||||
if (token == l->cur_token && l->shown && !l->recreate_pending) {
|
||||
/* The same frame again (the scene was redrawn for another reason): the display already
|
||||
* has it; only the placement may have changed (or, rarely, its description). */
|
||||
if (acquire_fd >= 0) close(acquire_fd);
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
if (tx) {
|
||||
@@ -841,22 +719,20 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi
|
||||
}
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
if (!tx) goto unavailable;
|
||||
ASurfaceControl *old = swap_sc_begin(l); /* this frame carries the recovery swap, if one is due */
|
||||
ASurfaceControl *old = swap_sc_begin(l);
|
||||
if (old) api.setZOrder(tx, l->sc, l->z);
|
||||
api.setBuffer(tx, l->sc, ahb, acquire_fd); /* the transaction owns the fence */
|
||||
api.setBuffer(tx, l->sc, ahb, acquire_fd);
|
||||
api.setBufferTransparency(tx, l->sc, ASC_TRANSPARENCY_OPAQUE);
|
||||
apply_geometry(tx, l, r);
|
||||
apply_frame_rate(tx, l);
|
||||
apply_colour(tx, l, color);
|
||||
if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW);
|
||||
if (old) retire_ops(tx, old);
|
||||
/* Same buffer, new SurfaceControl: it is NOT free, so no release is reported for it - the swap
|
||||
* moved it rather than taking it off screen. */
|
||||
if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot,
|
||||
l->cur_token == token ? NULL : l->cur_token, old ? 1 : 0) != 0) {
|
||||
api.txDelete(tx); /* the fence went with the transaction */
|
||||
api.txDelete(tx);
|
||||
if (old) api.release(old);
|
||||
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f; /* the colour tag went with it too: re-send it next time */
|
||||
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f;
|
||||
return -1;
|
||||
}
|
||||
api.txApply(tx);
|
||||
@@ -864,8 +740,6 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi
|
||||
l->cur_slot = -1;
|
||||
l->cur_token = token;
|
||||
if (!l->shown) { l->shown = 1; droiddeck_log("layer", "%s: layer shown", l->name); }
|
||||
/* The notification is re-armed for each session; the layer and its logging flag can
|
||||
* outlive it. Let the notification's own one-shot decide whether to fire. */
|
||||
if (!l->first_logged) l->first_logged = 1;
|
||||
vkp_signal_first_frame();
|
||||
if (color && color->dataspace) droiddeck_color_frame_shown(color, DROIDDECK_HDR_ZERO_COPY, ahb_format);
|
||||
@@ -882,7 +756,7 @@ int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const stru
|
||||
int r[8];
|
||||
int g = layer_geometry(sw, sh, scene_w, scene_h, r);
|
||||
if (g < 0) return -1;
|
||||
if (g == 0) { sc_layer_hide(); return 0; } /* nothing of it is on screen */
|
||||
if (g == 0) { sc_layer_hide(); return 0; }
|
||||
|
||||
int wait_fd;
|
||||
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
|
||||
@@ -905,15 +779,13 @@ int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int
|
||||
int rw = 0, rh = 0, r[8];
|
||||
if (!draws || n <= 0 || ensure_sc(l) != 0) return -1;
|
||||
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
|
||||
/* Compose + run the effects chain first: the chain's result size (a scaling mode resizes to
|
||||
* the scene's mapped output size) decides how big the layer buffer has to be. */
|
||||
if (vkp_pass_begin(scene_w, scene_h, draws, n, &rw, &rh) != 0) return -1;
|
||||
if (!vkp_map_rect(rw, rh, scene_w, scene_h, r)) { vkp_pass_abort(); sc_layer_hide(); return 0; }
|
||||
int wait_fd;
|
||||
int idx = take_free_slot(l, rw, rh, AHB_RGBA8, &wait_fd);
|
||||
if (idx < 0) { vkp_pass_abort(); log_drop(l); return 0; }
|
||||
if (vkp_pass_copy_to(l->slots[idx].img, wait_fd) != 0) return -1;
|
||||
if (present_slot(l, idx, r, NULL, 0) != 0) return -1; /* the effects chain's result is 8-bit sRGB */
|
||||
if (present_slot(l, idx, r, NULL, 0) != 0) return -1;
|
||||
if (!l->first_logged) {
|
||||
l->first_logged = 1;
|
||||
droiddeck_log("layer", "presenting %dx%d frames on their own SurfaceControl layer (%s pool, %d buffers); "
|
||||
@@ -924,14 +796,6 @@ int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---- the HDR picture (hdr_compose.h) ------------------------------------------------------------
|
||||
* An HDR game that cannot be alone on its layer: the WHOLE scene, composed into one 10-bit PQ BT.2020
|
||||
* picture with the effects applied, goes onto the game layer - one layer, tagged BT2020_PQ with the
|
||||
* game's metadata, so the display composes it as HDR (and a window above the game never needs the
|
||||
* second layer that costs this panel its hardware composition). 10-bit buffers; if gralloc or the
|
||||
* import refuses those, 8-bit ones carry the same tagged picture (colours right, precision less).
|
||||
* With the drawer's HDR output switch off (hf->tonemap) the same picture is composed tone-mapped to
|
||||
* sRGB instead and goes on the ordinary 8-bit buffers, UNtagged - an SDR frame like any other. */
|
||||
static uint32_t g_hdr_pool_fmt = AHB_RGB10A2;
|
||||
|
||||
int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf,
|
||||
@@ -955,7 +819,7 @@ int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct
|
||||
}
|
||||
if (idx < 0) { vkp_pass_abort(); log_drop(l); return 0; }
|
||||
if (vkp_pass_copy_to(l->slots[idx].img, wait_fd) != 0) return -1;
|
||||
if (present_slot(l, idx, r, tm ? NULL : color, 0) != 0) return -1; /* tone-mapped = plain sRGB: no tag */
|
||||
if (present_slot(l, idx, r, tm ? NULL : color, 0) != 0) return -1;
|
||||
if (color && color->dataspace)
|
||||
droiddeck_color_frame_shown(color, tm ? DROIDDECK_HDR_TONEMAPPED : DROIDDECK_HDR_COMPOSED, tm ? AHB_RGBA8 : g_hdr_pool_fmt);
|
||||
static int said = -1;
|
||||
@@ -980,40 +844,17 @@ int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---- is a SECOND display layer affordable on this display? -----------------------------------
|
||||
* MEASURED on the Pocket FIT (2026-09-14, three times): while a second layer is up, this hardware
|
||||
* composer hands the WHOLE frame back to the GPU (`DEVICE/CLIENT`), and nothing short of re-creating
|
||||
* the app's window brings it back - so on this display the overlay layer costs more than it saves,
|
||||
* every time, for the rest of the session. Where it costs nothing it is still the better path (the
|
||||
* game keeps copy-free frames with a window on top), so this is a GATE, not a removal.
|
||||
*
|
||||
* The gate is read from what the layer path actually knows, never from a device or panel list:
|
||||
* - rotation: vkp_surface_rotation_degrees(), i.e. VkSurfaceCapabilitiesKHR::currentTransform -
|
||||
* what the presentation engine says it does to every layer we hand it;
|
||||
* - scale: the GAME layer's own src -> dst rectangles, the ones passed to setGeometry.
|
||||
* Rotated AND scaled is the combination that was measured to cost composition (the DPU's rotator
|
||||
* has to take a scaled source); either alone, or neither, is left as it was.
|
||||
*
|
||||
* Why not just measure the composition type after raising the layer and back out if it comes back
|
||||
* CLIENT - which would beat predicting? Because no app can read it. The composition type lives in
|
||||
* the Composer HAL; ASurfaceTransactionStats exposes latch time and fences and nothing else, and
|
||||
* the only place the value is published is `dumpsys android.hardware.graphics.composer3.IComposer`,
|
||||
* which needs android.permission.DUMP and string-parsing. It would also arrive at least a frame
|
||||
* late, so backing out would itself be the visible change we are avoiding. Hence the rule. */
|
||||
static int overlay_affordable(int *deg, int sw[2], int dw[2]) {
|
||||
*deg = vkp_surface_rotation_degrees();
|
||||
sw[0] = sw[1] = dw[0] = dw[1] = 0;
|
||||
if (!g_game_geo_known) return 1; /* the game has never been placed: nothing to weigh against */
|
||||
if (*deg <= 0) return 1; /* unknown (-1) or upright: leave today's behaviour alone */
|
||||
if (!g_game_geo_known) return 1;
|
||||
if (*deg <= 0) return 1;
|
||||
sw[0] = g_game_src.right - g_game_src.left; sw[1] = g_game_src.bottom - g_game_src.top;
|
||||
dw[0] = g_game_dst.right - g_game_dst.left; dw[1] = g_game_dst.bottom - g_game_dst.top;
|
||||
if (sw[0] <= 0 || sw[1] <= 0) return 1;
|
||||
return !(dw[0] != sw[0] || dw[1] != sw[1]); /* rotated AND scaled -> not affordable */
|
||||
return !(dw[0] != sw[0] || dw[1] != sw[1]);
|
||||
}
|
||||
|
||||
/* -1 = not decided yet, 0 = raising the overlay, 1 = declining it. Logged on every change, so a
|
||||
* tester's log says why they are seeing the copy path instead of two layers - and says it again if
|
||||
* the placement changes the answer (e.g. a fullscreen mode that stops scaling the game). */
|
||||
static int g_overlay_declined = -1;
|
||||
|
||||
int sc_layer_overlay_affordable(void) {
|
||||
@@ -1040,8 +881,6 @@ int sc_layer_overlay_affordable(void) {
|
||||
int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int translucent) {
|
||||
struct layer *l = layer_of(SC_LAYER_OVERLAY);
|
||||
if (!src || !geo) return -1;
|
||||
/* The caller decides with sc_layer_overlay_affordable() BEFORE it commits the game to a layer;
|
||||
* this is only a guard so the layer can never go up behind that decision's back. */
|
||||
if (!sc_layer_overlay_affordable()) return -1;
|
||||
if (ensure_sc(l) != 0) return -1;
|
||||
int sw = vkp_image_width(src), sh = vkp_image_height(src);
|
||||
@@ -1049,8 +888,6 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl
|
||||
int wait_fd;
|
||||
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
|
||||
if (idx < 0) { log_drop(l); return 0; }
|
||||
/* The window is copied into the layer buffer 1:1; `geo` crops it and places it, so the layer
|
||||
* is exactly the window's rectangle on screen and nothing else is blended anywhere. */
|
||||
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
|
||||
if (present_slot(l, idx, geo, NULL, translucent) != 0) return -1;
|
||||
if (!l->first_logged) {
|
||||
@@ -1060,8 +897,6 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Hide one layer: the buffer comes off with it (a hidden layer would keep the game's buffer - or
|
||||
* the pool slot - referenced, and the game needs it back to keep presenting the other way). */
|
||||
static void hide_layer(struct layer *l) {
|
||||
if (!l->sc || !l->shown || api.state != 1) return;
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
@@ -1076,10 +911,6 @@ static void hide_layer(struct layer *l) {
|
||||
void sc_layer_hide(void) {
|
||||
layers_init();
|
||||
int said = g_layers[SC_LAYER_GAME].shown || g_layers[SC_LAYER_OVERLAY].sc;
|
||||
/* Top down, so nothing of the scene is ever uncovered for a frame. The overlay layer is let go
|
||||
* of entirely rather than hidden (same reason as sc_layer_hide_overlay: a live second
|
||||
* SurfaceControl keeps SurfaceFlinger composing on the GPU); the game layer keeps its
|
||||
* SurfaceControl, since it goes up and down with every effects/frame-generation toggle. */
|
||||
if (g_layers[SC_LAYER_OVERLAY].sc) sc_layer_hide_overlay();
|
||||
if (g_layers[SC_LAYER_GAME].shown) hide_layer(&g_layers[SC_LAYER_GAME]);
|
||||
if (said) droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)");
|
||||
@@ -1089,18 +920,9 @@ void sc_layer_hide_overlay(void) {
|
||||
layers_init();
|
||||
struct layer *l = &g_layers[SC_LAYER_OVERLAY];
|
||||
if (!l->sc) return;
|
||||
/* RETIRED, not just hidden, so the overlay layer lives exactly as long as the window above the
|
||||
* game: a live second SurfaceControl is what puts SurfaceFlinger into GPU client composition
|
||||
* on this hardware (see sc_layer.h), and a hidden one is still live. Measured caveat: letting
|
||||
* it go does NOT by itself bring hardware composition back - on the Pocket FIT the fallback
|
||||
* outlives the overlay and only clears when the GAME layer's SurfaceControl is re-created
|
||||
* (HOME + resume). Retiring is still the right thing; it just is not the whole cure. The pool
|
||||
* buffers stay allocated for the next window. */
|
||||
if (l->shown) hide_layer(l);
|
||||
retire_sc(l);
|
||||
droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name);
|
||||
/* ...and that is the half the measurement said is not enough: arm the game layer's
|
||||
* SurfaceControl swap, which the next frame performs (swap_sc_begin). */
|
||||
if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,70 +1,5 @@
|
||||
#ifndef SC_LAYER_H
|
||||
#define SC_LAYER_H
|
||||
/*
|
||||
* Layer mode (DROIDDECK_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 "droiddeck_wayland_game" ...... the one fullscreen game window
|
||||
* +-- z=2 "droiddeck_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>
|
||||
@@ -73,103 +8,39 @@ struct vkp_image;
|
||||
struct vkp_draw;
|
||||
struct droiddeck_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 (droiddeck_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 droiddeck_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 droiddeck_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 droiddeck_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.
|
||||
* `translucent` preserves a client's alpha over the game for Steam notifications and overlays.
|
||||
* 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], int translucent);
|
||||
|
||||
/* 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
|
||||
@@ -1,4 +1,3 @@
|
||||
/* See vk_loader.h. */
|
||||
#define _GNU_SOURCE
|
||||
#include "vk_loader.h"
|
||||
#include "../../adrenotools/include/adrenotools/driver.h"
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
#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>
|
||||
|
||||
@@ -29,7 +23,7 @@
|
||||
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) \
|
||||
@@ -37,7 +31,7 @@
|
||||
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 {
|
||||
@@ -47,14 +41,10 @@ struct vk_api {
|
||||
};
|
||||
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
@@ -2,70 +2,34 @@
|
||||
#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);
|
||||
|
||||
@@ -73,117 +37,61 @@ 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;
|
||||
int blend; /* translucent: composed over what is under it (blend_pass.h) */
|
||||
int blend;
|
||||
};
|
||||
|
||||
// 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 */
|
||||
int64_t acquire_ns, acquire_max_ns;
|
||||
int64_t present_ns, present_max_ns;
|
||||
int64_t wait_ns, wait_max_ns;
|
||||
unsigned base_presents;
|
||||
unsigned base_kept;
|
||||
unsigned gpu_release_waits;
|
||||
};
|
||||
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 droiddeck_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 droiddeck_color *color; /* the topmost HDR draw's description: an HDR10 swapchain's metadata */
|
||||
const unsigned char *is_hdr;
|
||||
float peak_nits;
|
||||
int tonemap;
|
||||
const struct droiddeck_color *color;
|
||||
};
|
||||
/* 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);
|
||||
/* A client's GPU cursor (an imported dma-buf, often UBWC) read back as w*h 0xAARRGGBB pixels through a
|
||||
* linear host-visible copy; waited for on the CPU. Compositor thread, between frames. 0 = ok. */
|
||||
int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px);
|
||||
/* 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 droiddeck_log(const char *tag, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* 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 <stdbool.h>
|
||||
@@ -44,15 +38,15 @@ extern volatile int g_output_w, g_output_h;
|
||||
#define TAG "DroidDeckWayland"
|
||||
|
||||
static JavaVM *g_jvm;
|
||||
static volatile pid_t g_comp_tid; /* the compositor thread, for the app's ADPF hint session */
|
||||
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) */
|
||||
static volatile pid_t g_comp_tid;
|
||||
static jclass g_compositor_cls;
|
||||
static jmethodID g_on_first_frame;
|
||||
static jmethodID g_on_game_surface;
|
||||
static jmethodID g_on_game_frame;
|
||||
static jmethodID g_on_game_program;
|
||||
static jmethodID g_on_pointer_lock;
|
||||
static jmethodID g_on_clipboard;
|
||||
static jmethodID g_on_text_input;
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
(void)reserved;
|
||||
@@ -79,9 +73,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
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 droiddeck_on_first_frame(void) {
|
||||
if (!g_jvm || !g_compositor_cls || !g_on_first_frame) return;
|
||||
JNIEnv *env = NULL;
|
||||
@@ -96,8 +87,6 @@ void droiddeck_on_first_frame(void) {
|
||||
__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;
|
||||
|
||||
@@ -112,7 +101,6 @@ static JNIEnv *thread_env(void) {
|
||||
return t_env = env;
|
||||
}
|
||||
|
||||
/* A window started presenting GPU frames (window = its description), or NULL when it closed. */
|
||||
void droiddeck_on_game_surface(const char *window, const char *gpu) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_game_surface || !(env = thread_env())) return;
|
||||
@@ -124,8 +112,6 @@ void droiddeck_on_game_surface(const char *window, const char *gpu) {
|
||||
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 droiddeck_on_game_program(int pid, const char *program) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_game_program || !(env = thread_env())) return;
|
||||
@@ -135,7 +121,6 @@ void droiddeck_on_game_program(int pid, const char *program) {
|
||||
if (jp) (*env)->DeleteLocalRef(env, jp);
|
||||
}
|
||||
|
||||
/* One GPU frame from that window. */
|
||||
void droiddeck_on_game_frame(void) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_game_frame || !(env = thread_env())) return;
|
||||
@@ -143,9 +128,6 @@ void droiddeck_on_game_frame(void) {
|
||||
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 droiddeck_on_pointer_lock(int locked, int x, int y) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_pointer_lock || !(env = thread_env())) return;
|
||||
@@ -153,8 +135,6 @@ void droiddeck_on_pointer_lock(int locked, int x, int 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 droiddeck_on_clipboard_text(const char *utf8, int len) {
|
||||
JNIEnv *env;
|
||||
if (!g_compositor_cls || !g_on_clipboard || !(env = thread_env())) return;
|
||||
@@ -166,8 +146,6 @@ void droiddeck_on_clipboard_text(const char *utf8, int len) {
|
||||
(*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 droiddeck_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;
|
||||
@@ -178,16 +156,11 @@ void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int
|
||||
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();
|
||||
g_comp_tid = (pid_t)tid;
|
||||
@@ -225,15 +198,12 @@ static void start_thread(void) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, TAG, "pthread_create failed");
|
||||
}
|
||||
|
||||
/* The compositor thread's tid, or 0 before it starts. The app opens a PerformanceHintManager session
|
||||
* on it and reports each presented frame's interval, so the governor sees a frame that ran long. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCompositorTid(JNIEnv *env, jclass clazz) {
|
||||
(void)env; (void)clazz;
|
||||
return (jint)g_comp_tid;
|
||||
}
|
||||
|
||||
/* Headless start (no output window) - used for bring-up tests. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStart(JNIEnv *env, jclass clazz,
|
||||
jstring xdgRuntimeDir) {
|
||||
@@ -249,8 +219,6 @@ static char *dup_jstr(JNIEnv *env, jstring s) {
|
||||
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_droiddeck_launcher_wayland_WaylandCompositor_nativeStartWithSurface(
|
||||
JNIEnv *env, jclass clazz, jobject surface, jstring xdgRuntimeDir,
|
||||
@@ -263,14 +231,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStartWithSurface(
|
||||
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) */
|
||||
vk_present_set_window(win);
|
||||
__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_droiddeck_launcher_wayland_WaylandCompositor_nativeSendPointer(
|
||||
JNIEnv *env, jclass clazz, jint action, jint x, jint y) {
|
||||
@@ -283,9 +249,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendTouch(
|
||||
droiddeck_wayland_send_touch(action, pointer_id, x, y);
|
||||
}
|
||||
|
||||
/* The client's pointer image and whether it wants one at all (wl_pointer.set_cursor).
|
||||
* out = [serial, hidden, w, h, hotspotX, hotspotY, ARGB pixels...]; returns ints written, 0 if the
|
||||
* array is too small. The app polls the serial and only rebuilds its overlay when it changes. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCursorSnapshot(
|
||||
JNIEnv *env, jclass clazz, jintArray out) {
|
||||
@@ -298,98 +261,75 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCursorSnapshot(
|
||||
return n;
|
||||
}
|
||||
|
||||
/* The serial nativeCursorSnapshot would return, without copying anything. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCursorSerial(JNIEnv *env, jclass clazz) {
|
||||
(void)env; (void)clazz;
|
||||
return droiddeck_cursor_serial();
|
||||
}
|
||||
|
||||
/* Inject a key event. evdev = Linux input keycode (KEY_A=30…); state 1=down 0=up. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendKey(
|
||||
JNIEnv *env, jclass clazz, jint evdev, jint state) {
|
||||
droiddeck_wayland_send_key(evdev, state);
|
||||
}
|
||||
|
||||
/* App X-server input in scene (virtual desktop) coordinates; see droiddeck_wayland_send_scene_input. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendSceneInput(
|
||||
JNIEnv *env, jclass clazz, jint type, jint a, jint b) {
|
||||
droiddeck_wayland_send_scene_input(type, a, b);
|
||||
}
|
||||
|
||||
/* One screen refresh (Choreographer frame callback, UI thread): the compositor draws once. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeVsync(JNIEnv *env, jclass clazz, jlong frameTimeNanos) {
|
||||
droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHideShell(JNIEnv *env, jclass clazz, jboolean hide) {
|
||||
g_hide_shell = hide ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Zero-copy layer mode (DROIDDECK_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_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZeroCopy(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
int live = droiddeck_get_display() != NULL;
|
||||
if (!live) g_zero_copy = on ? 1 : 0; /* read by ahb_swapchain_init before the queue drains */
|
||||
if (!live) g_zero_copy = on ? 1 : 0;
|
||||
droiddeck_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_droiddeck_launcher_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_droiddeck_launcher_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; DROIDDECK_WAYLAND_UBWC=0 = off). Set before the compositor
|
||||
* starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_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 (DROIDDECK_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_droiddeck_launcher_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_droiddeck_launcher_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_droiddeck_launcher_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. */
|
||||
extern void vkp_reset_first_frame(void);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeResetFirstFrame(JNIEnv *env, jclass clazz) {
|
||||
@@ -403,8 +343,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetOutputSize(JNIEnv
|
||||
g_output_h = h > 0 ? h : 0;
|
||||
}
|
||||
|
||||
/* The output's size changed while the compositor runs (a foldable opening or closing with the
|
||||
* session following the screen): store it and have the compositor thread tell the clients. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeResizeOutput(JNIEnv *env, jclass clazz, jint w, jint h) {
|
||||
(void)env; (void)clazz;
|
||||
@@ -414,57 +352,44 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeResizeOutput(JNIEnv
|
||||
droiddeck_wayland_output_resized();
|
||||
}
|
||||
|
||||
/* 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_droiddeck_launcher_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_droiddeck_launcher_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_droiddeck_launcher_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_droiddeck_launcher_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_droiddeck_launcher_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_droiddeck_launcher_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_droiddeck_launcher_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);
|
||||
}
|
||||
|
||||
/* Cardboard mode - WaylandCompositor.nativeSetCardboard. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboard(JNIEnv *env, jclass clazz, jboolean enabled,
|
||||
jint source, jfloat ipd, jfloat dist, jfloat width, jfloat k1, jfloat k2, jfloat fov, jfloat inset, jfloat chroma) {
|
||||
@@ -474,7 +399,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboard(JNIEnv
|
||||
vkp_cardboard_set(&p);
|
||||
}
|
||||
|
||||
/* The head pose (row-major 3x3, head -> world), from the sensor thread. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboardPose(JNIEnv *env, jclass clazz, jfloatArray rot,
|
||||
jboolean live) {
|
||||
@@ -484,7 +408,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboardPose(JNI
|
||||
vkp_cardboard_set_pose(m, live ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Where the head pose is shared with the guest - WaylandCompositor.nativeSetCardboardPoseFile. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboardPoseFile(JNIEnv *env, jclass clazz, jstring path) {
|
||||
if (!path) return;
|
||||
@@ -494,9 +417,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboardPoseFile
|
||||
(*env)->ReleaseStringUTFChars(env, path, p);
|
||||
}
|
||||
|
||||
/* 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. droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeLogDisplay(JNIEnv *env, jclass clazz, jstring message) {
|
||||
char *s = dup_jstr(env, message);
|
||||
@@ -504,8 +424,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeLogDisplay(JNIEnv *e
|
||||
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_droiddeck_launcher_wayland_WaylandCompositor_nativeLogPerf(JNIEnv *env, jclass clazz, jstring message) {
|
||||
char *s = dup_jstr(env, message);
|
||||
@@ -513,9 +431,7 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeLogPerf(JNIEnv *env,
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* ---- HDR10 output, round 1 (droiddeck_color.h / wl_color_mgmt.c) ---- */
|
||||
|
||||
/* The opt-in: mode 0 off, 1 DROIDDECK_WAYLAND_HDR=1, 2 =force (testing). Before the compositor starts. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrRequest(JNIEnv *env, jclass clazz, jint mode,
|
||||
jstring source, jboolean dxvkHdr, jboolean zeroCopyForced) {
|
||||
@@ -524,7 +440,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrRequest(JNIEnv
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* The game's display as android.view.Display reports it (before the start; again on every change). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrDisplay(JNIEnv *env, jclass clazz, jint id, jstring name,
|
||||
jstring formats, jboolean hdr10, jfloat maxLum, jfloat maxAvg, jfloat minLum, jboolean ratioAvailable,
|
||||
@@ -535,38 +450,32 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrDisplay(JNIEnv
|
||||
free(n); free(f);
|
||||
}
|
||||
|
||||
/* One Display.getHdrSdrRatio() reading (listener = from the display's ratio listener). Any thread. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrSdrRatioSample(JNIEnv *env, jclass clazz, jfloat ratio,
|
||||
jboolean listener) {
|
||||
droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrLastFrameAgeMs(JNIEnv *env, jclass clazz) {
|
||||
return (jint)droiddeck_color_last_frame_age_ms();
|
||||
}
|
||||
|
||||
/* -1 = not decided yet, 0 = closed, 1 = open. Any thread. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrGateState(JNIEnv *env, jclass clazz) {
|
||||
return (jint)droiddeck_color_gate_state();
|
||||
}
|
||||
|
||||
/* The session is ending: the "HDR on screen: ..." summary line. Any thread, once. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrSessionEnd(JNIEnv *env, jclass clazz) {
|
||||
droiddeck_color_session_end();
|
||||
}
|
||||
|
||||
/* HDR frames really on screen right now (the HUD badge). Any thread. */
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrOnScreen(JNIEnv *env, jclass clazz) {
|
||||
return droiddeck_color_hdr_on_screen() ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/* One "color" line in the session log from Java. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeLogColor(JNIEnv *env, jclass clazz, jstring message) {
|
||||
char *s = dup_jstr(env, message);
|
||||
@@ -574,8 +483,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeLogColor(JNIEnv *env
|
||||
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_droiddeck_launcher_wayland_WaylandCompositor_nativeLog(JNIEnv *env, jclass clazz, jstring area, jstring message) {
|
||||
char *a = dup_jstr(env, area), *s = dup_jstr(env, message);
|
||||
@@ -584,18 +491,15 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeLog(JNIEnv *env, jcl
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* SDR content's level inside an HDR picture, in nits (default 203). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrSdrWhite(JNIEnv *env, jclass clazz, jfloat nits) {
|
||||
droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrOutput(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
if (droiddeck_get_display()) droiddeck_host_hdr_output(on ? 1 : 0);
|
||||
else droiddeck_color_set_output(on ? 1 : 0); /* no compositor thread yet: nothing is drawing either */
|
||||
else droiddeck_color_set_output(on ? 1 : 0);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
@@ -603,7 +507,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrOutput(JNIEnv *en
|
||||
return droiddeck_color_output() ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/* Device evidence for the HDR lines: thermal status + headroom, brightness + mode. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrEnvSample(JNIEnv *env, jclass clazz, jint thermal,
|
||||
jfloat headroom, jint brightness, jint mode) {
|
||||
@@ -611,13 +514,11 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrEnvSample(JNIEnv
|
||||
(int)brightness, (int)mode);
|
||||
}
|
||||
|
||||
/* Display.getHighestHdrSdrRatio() (Android 16+), <= 0 = not reported. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHdrHighestRatio(JNIEnv *env, jclass clazz, jfloat ratio) {
|
||||
droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrScreenHeadroom(JNIEnv *env, jclass clazz) {
|
||||
return (jfloat)droiddeck_color_screen_headroom(NULL, 0);
|
||||
@@ -630,25 +531,21 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrScreenHeadroomWhy
|
||||
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_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrNoteHeadroomRequest(JNIEnv *env, jclass clazz, jfloat ratio) {
|
||||
droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrState(JNIEnv *env, jclass clazz) {
|
||||
return (jint)droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeHdrToneMappedOnScreen(JNIEnv *env, jclass clazz) {
|
||||
return droiddeck_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_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLookName(JNIEnv *env, jclass clazz, jstring name) {
|
||||
char *s = dup_jstr(env, name);
|
||||
@@ -656,14 +553,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLookName(JNIEnv *
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* The in-game FPS limiter: frames per second, 0 = unlimited. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_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_droiddeck_launcher_wayland_WaylandCompositor_nativeSetSurface(
|
||||
JNIEnv *env, jclass clazz, jobject surface) {
|
||||
@@ -674,8 +569,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetSurface(
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- 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;
|
||||
@@ -689,7 +582,6 @@ static char *dup_bytes(JNIEnv *env, jbyteArray arr, int *len) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Android's clipboard text becomes the guest's selection (empty/null = clear). */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetClipboardText(JNIEnv *env, jclass clazz, jbyteArray utf8) {
|
||||
int len;
|
||||
@@ -698,7 +590,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetClipboardText(JNI
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* Soft-keyboard text committed to the program accepting text input. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputCommit(JNIEnv *env, jclass clazz, jbyteArray utf8) {
|
||||
int len;
|
||||
@@ -707,7 +598,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputCommit(JNIE
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* Composing (pre-edit) text; cursorBegin/cursorEnd are character indexes into it, -1 = end. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputPreedit(JNIEnv *env, jclass clazz, jbyteArray utf8,
|
||||
jint cursorBegin, jint cursorEnd) {
|
||||
@@ -717,15 +607,11 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputPreedit(JNI
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* The IME deleted characters around the caret. */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputDelete(JNIEnv *env, jclass clazz, jint before, jint after) {
|
||||
droiddeck_host_text_delete(before, after);
|
||||
}
|
||||
|
||||
/* KGSL's power control, off (the GPU held at its top clock) or back on. The property is the
|
||||
* device's, not this process's: it outlives the fd and the app, so the caller clears it at stop
|
||||
* and again at every app start. No root; the kernel's thermal limits still apply. */
|
||||
extern void adrenotools_set_turbo(bool turbo);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
@@ -733,10 +619,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *
|
||||
adrenotools_set_turbo(on == JNI_TRUE);
|
||||
}
|
||||
|
||||
/* Raises one of our own processes or threads to `nice` with a bare setpriority(), never lowering
|
||||
* it. android.os.Process.setThreadPriority is not used for this: it also moves the thread between
|
||||
* scheduling groups by priority, and a guest process must stay where Android put the app. Returns
|
||||
* the nice value it is left at, or 100 when it could not be read. */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeRaisePriority(JNIEnv *env, jclass clazz, jint tid, jint nice) {
|
||||
(void)env; (void)clazz;
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*
|
||||
* 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 (droiddeck_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>
|
||||
@@ -37,17 +16,17 @@ 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 */
|
||||
static uint32_t g_gen;
|
||||
|
||||
struct source { /* a client's data source (either protocol) */
|
||||
struct source {
|
||||
struct wl_resource *res;
|
||||
int is_control;
|
||||
char *mimes[MAX_MIMES];
|
||||
int nmimes;
|
||||
};
|
||||
static struct source *g_src; /* current CLIENT selection */
|
||||
static struct source *g_src;
|
||||
|
||||
static char *g_host_text; /* current HOST selection */
|
||||
static char *g_host_text;
|
||||
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
|
||||
@@ -59,18 +38,17 @@ struct device {
|
||||
struct wl_list link;
|
||||
};
|
||||
static struct wl_list g_devices;
|
||||
static struct wl_client *g_kb_client; /* keyboard focus holder */
|
||||
static struct wl_client *g_kb_client;
|
||||
|
||||
struct offer {
|
||||
struct wl_resource *res;
|
||||
int is_control;
|
||||
uint32_t gen; /* the selection this offer describes */
|
||||
uint32_t gen;
|
||||
};
|
||||
|
||||
static char *g_last_guest_text; /* echo guard: the last text handed to Android */
|
||||
static char *g_last_guest_text;
|
||||
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;
|
||||
@@ -94,7 +72,6 @@ static void source_send_cancelled(struct source *s) {
|
||||
else wl_data_source_send_cancelled(s->res);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ host → client writer */
|
||||
|
||||
struct writer {
|
||||
int fd;
|
||||
@@ -115,9 +92,9 @@ 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 == EAGAIN || errno == EWOULDBLOCK)) return 0;
|
||||
if (n < 0 && errno == EINTR) continue;
|
||||
break; /* gone */
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -150,13 +127,12 @@ static void writer_start(int fd, const char *data, size_t len) {
|
||||
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 */
|
||||
const char *mime;
|
||||
struct wl_event_source *src, *timer;
|
||||
};
|
||||
static struct reader *g_reader;
|
||||
@@ -202,7 +178,7 @@ static int on_reader_readable(int fd, uint32_t mask, void *data) {
|
||||
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 (n == 0) { reader_finish(r); return 0; }
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
if (mask & WL_EVENT_HANGUP) { reader_finish(r); return 0; }
|
||||
return 0;
|
||||
@@ -220,14 +196,13 @@ static int on_reader_timeout(void *data) {
|
||||
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 */
|
||||
fcntl(p[0], F_SETFL, fcntl(p[0], F_GETFL) | O_NONBLOCK);
|
||||
struct reader *r = calloc(1, sizeof(*r));
|
||||
if (!r) { close(p[0]); close(p[1]); return; }
|
||||
r->fd = p[0];
|
||||
@@ -242,13 +217,12 @@ static void read_client_text(void) {
|
||||
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 (!o || o->gen != g_gen) { close(fd); return; }
|
||||
if (g_owner == OWNER_HOST) {
|
||||
if (is_text_mime(mime)) {
|
||||
droiddeck_log("clipboard", "Android clipboard → guest (%zu bytes) for %s", g_host_len, droiddeck_client_name(c));
|
||||
@@ -257,7 +231,7 @@ static void offer_receive(struct wl_client *c, struct wl_resource *r, const char
|
||||
close(fd);
|
||||
}
|
||||
} else if (g_owner == OWNER_CLIENT && g_src) {
|
||||
source_send_send(g_src, mime, fd); /* libwayland dups the fd */
|
||||
source_send_send(g_src, mime, fd);
|
||||
close(fd);
|
||||
wl_display_flush_clients(g_disp);
|
||||
} else {
|
||||
@@ -277,7 +251,6 @@ 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) {
|
||||
@@ -315,8 +288,6 @@ static void device_send_selection(struct device *d) {
|
||||
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++;
|
||||
@@ -336,7 +307,6 @@ void droiddeck_clipboard_keyboard_focus(struct wl_client *client) {
|
||||
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);
|
||||
@@ -380,7 +350,6 @@ static void create_source(struct wl_client *c, uint32_t id, int is_control, uint
|
||||
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;
|
||||
@@ -404,7 +373,6 @@ static void set_selection(struct wl_client *c, struct wl_resource *source_res) {
|
||||
read_client_text();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ devices */
|
||||
|
||||
static void device_res_destroy(struct wl_resource *r) {
|
||||
struct device *d = wl_resource_get_user_data(r);
|
||||
@@ -429,7 +397,6 @@ static void control_device_set_selection(struct wl_client *c, struct wl_resource
|
||||
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);
|
||||
@@ -455,11 +422,9 @@ static void create_device(struct wl_client *c, uint32_t id, int is_control, uint
|
||||
: (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));
|
||||
@@ -493,12 +458,10 @@ static void bind_data_control_manager(struct wl_client *c, void *data, uint32_t
|
||||
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 */
|
||||
free(utf8);
|
||||
return;
|
||||
}
|
||||
if (len && g_owner == OWNER_HOST && g_host_len == len && !memcmp(utf8, g_host_text, len)) {
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
/*
|
||||
* wp_color_manager_v1 (wayland-protocols staging color-management-v1, version 1) - the subset Mesa's
|
||||
* Wayland WSI binds - plus the HDR gate, the per-surface image descriptions and the session log's
|
||||
* HDR evidence. See droiddeck_color.h for the design and HDR_RECON.md for why it is shaped this way.
|
||||
*
|
||||
* Strictness policy. A protocol error disconnects the client, and the client here is a GAME, so
|
||||
* errors are only raised where the protocol leaves no choice and a conforming client can never hit
|
||||
* them: a request gated on a feature we did not advertise, a property set twice, an incomplete
|
||||
* parameter set, a description that is not ready, an intent we did not advertise. Everything a
|
||||
* conforming client CAN produce on a bad day is accepted and logged instead: out-of-range HDR
|
||||
* metadata is dropped (Android gets none rather than nonsense), a second colour-management object
|
||||
* for the same surface replaces the first, a request on an inert object is ignored.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include "droiddeck_color.h"
|
||||
#include "droiddeck_ext.h"
|
||||
@@ -29,7 +16,6 @@ extern volatile int g_zero_copy;
|
||||
|
||||
#define TAG "color"
|
||||
|
||||
/* AHARDWAREBUFFER_FORMAT_* (android/hardware_buffer.h), for the log only. */
|
||||
const char *droiddeck_ahb_format_name(uint32_t f) {
|
||||
static char other[32];
|
||||
switch (f) {
|
||||
@@ -80,24 +66,24 @@ static const char *dataspace_name(int32_t ds) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- request (app) + gate */
|
||||
|
||||
static pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER; /* g_req, g_hdr (app threads + compositor) */
|
||||
|
||||
static pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct {
|
||||
int mode; /* 0 off, 1 on, 2 forced */
|
||||
int mode;
|
||||
char source[64];
|
||||
int dxvk_hdr, zero_copy_forced;
|
||||
int display_known;
|
||||
int display_id, hdr10, ratio_available, api;
|
||||
char display_name[96], formats[96];
|
||||
float max_lum, max_avg, min_lum, ratio;
|
||||
float highest_ratio; /* Display.getHighestHdrSdrRatio() (Android 16+), < 0 = not reported */
|
||||
float highest_ratio;
|
||||
} g_req = {.highest_ratio = -1.0f};
|
||||
|
||||
static _Atomic int g_gate = -1; /* -1 undecided, 0 closed, 1 open */
|
||||
static char g_gate_why[320]; /* the closed gate's reason (for the summary) */
|
||||
static _Atomic int g_output_on = 1; /* the drawer's HDR output switch (per session, starts on) */
|
||||
static _Atomic int g_gate = -1;
|
||||
static char g_gate_why[320];
|
||||
static _Atomic int g_output_on = 1;
|
||||
|
||||
void droiddeck_color_set_request(int mode, const char *source, int dxvk_hdr, int zero_copy_forced) {
|
||||
pthread_mutex_lock(&g_mu);
|
||||
@@ -106,7 +92,7 @@ void droiddeck_color_set_request(int mode, const char *source, int dxvk_hdr, int
|
||||
g_req.dxvk_hdr = dxvk_hdr ? 1 : 0;
|
||||
g_req.zero_copy_forced = zero_copy_forced ? 1 : 0;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
atomic_store(&g_output_on, 1); /* the drawer's switch is per session and starts on */
|
||||
atomic_store(&g_output_on, 1);
|
||||
}
|
||||
|
||||
void droiddeck_color_set_display(int id, const char *name, const char *formats, int hdr10, float max_lum,
|
||||
@@ -123,8 +109,6 @@ void droiddeck_color_set_display(int id, const char *name, const char *formats,
|
||||
g_req.ratio = ratio;
|
||||
g_req.api = api;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
/* The gate is decided once, when the compositor starts: a display that changes under a running
|
||||
* session is recorded, and what it means is said out loud. */
|
||||
if (was_known && atomic_load(&g_gate) >= 0 && (was_hdr10 != (hdr10 ? 1 : 0) || was_id != id)) {
|
||||
if (atomic_load(&g_gate) == 1 && !hdr10)
|
||||
droiddeck_log(TAG, "the game is now on \"%s\" (display %d), which reports no HDR10: HDR frames stay tagged "
|
||||
@@ -139,48 +123,39 @@ void droiddeck_color_set_display(int id, const char *name, const char *formats,
|
||||
int droiddeck_color_gate_state(void) { return atomic_load(&g_gate); }
|
||||
int droiddeck_color_hdr_open(void) { return atomic_load(&g_gate) == 1; }
|
||||
|
||||
/* ---------------------------------------------------------------- HDR evidence (summary) */
|
||||
|
||||
static struct {
|
||||
unsigned descs; /* HDR image descriptions made ready */
|
||||
unsigned applied; /* commits that made one current on a surface */
|
||||
char applied_who[160]; /* the last surface that got one */
|
||||
uint64_t layer_frames, layer_10bit, layer_copy8, copy_frames; /* layer_frames = every frame shown AS HDR */
|
||||
unsigned descs;
|
||||
unsigned applied;
|
||||
char applied_who[160];
|
||||
uint64_t layer_frames, layer_10bit, layer_copy8, copy_frames;
|
||||
uint64_t composed, swapchain, tonemapped;
|
||||
uint64_t tm_off; /* of `tonemapped`: while the drawer's HDR output switch was off */
|
||||
unsigned output_offs; /* times the switch was turned off */
|
||||
uint64_t tm_off;
|
||||
unsigned output_offs;
|
||||
unsigned win_layer, win_copy, win_copy8, win_zc, win_composed, win_swapchain, win_tonemapped;
|
||||
char copy_reason[160];
|
||||
char layer_fmt[48];
|
||||
int ratio_n, win_ratio_n, ratio_live_n;
|
||||
float ratio_min, ratio_max, ratio_last, win_ratio_min, win_ratio_max, ratio_logged;
|
||||
float ratio_live_max; /* highest reading taken WHILE HDR frames were on screen (the verdict's) */
|
||||
float ratio_live_max;
|
||||
int64_t ratio_logged_ns, ratio_periodic_ns;
|
||||
/* Live headroom. The display may grant HDR frames no headroom at all while they are on screen - seen
|
||||
* on the Fold while the screen was being RECORDED (Android turns HDR headroom off for a recording,
|
||||
* which is SDR), and plausibly with the brightness slider at maximum (SDR white already at the panel's
|
||||
* limit) - so "the ratio rose once" is not enough for a reader at minute 3: time with HDR frames on
|
||||
* screen, the part of it with the ratio above 1, and the current no-headroom streak. */
|
||||
int64_t prev_sample_ns; int prev_live; float prev_ratio;
|
||||
int64_t live_ns, headroom_ns;
|
||||
int64_t nohead_since_ns; /* HDR frames on screen and ratio <= 1.01 since then (0 = not now) */
|
||||
int nohead_said; /* the streak's "no headroom" line is written */
|
||||
int64_t nohead_since_ns;
|
||||
int nohead_said;
|
||||
char verdict[512];
|
||||
} g_hdr;
|
||||
static _Atomic int64_t g_last_frame_ns;
|
||||
static _Atomic int64_t g_last_tm_ns; /* the last HDR frame shown tone-mapped to SDR */
|
||||
static _Atomic int64_t g_last_tm_ns;
|
||||
|
||||
/* What the device says beside the headroom (the app, non-root APIs; droiddeck_color_env_*). The Fold showed
|
||||
* three ways to lose HDR headroom with HDR frames on screen - a screen recording, heat under load, and
|
||||
* (plausibly) the brightness slider at maximum - so every no-headroom line carries this. Under g_mu. */
|
||||
static struct {
|
||||
int known;
|
||||
int thermal; /* PowerManager THERMAL_STATUS_* (0 none .. 6 shutdown), -1 unknown */
|
||||
float headroom; /* PowerManager.getThermalHeadroom(10), < 0 = not available */
|
||||
int brightness; /* Settings.System.SCREEN_BRIGHTNESS (0..255), -1 unknown */
|
||||
int bmode; /* SCREEN_BRIGHTNESS_MODE: 1 automatic, 0 manual, -1 unknown */
|
||||
float requested; /* the last HDR headroom asked for (layer or screen surface): > 0 the ratio,
|
||||
* 0 none asked, -1 the API is missing on this Android (< 15) */
|
||||
int thermal;
|
||||
float headroom;
|
||||
int brightness;
|
||||
int bmode;
|
||||
float requested;
|
||||
|
||||
} g_env = {0, -1, -1.0f, -1, -1, 0.0f};
|
||||
|
||||
static const char *thermal_name(int t) {
|
||||
@@ -190,7 +165,6 @@ static const char *thermal_name(int t) {
|
||||
}
|
||||
}
|
||||
|
||||
/* "thermal MODERATE (headroom 0.83), brightness 180/255 manual". Caller holds g_mu. */
|
||||
static void env_text_locked(char *out, size_t n) {
|
||||
char t[48], b[40];
|
||||
if (g_env.thermal < 0) snprintf(t, sizeof(t), "thermal ?");
|
||||
@@ -203,9 +177,6 @@ static void env_text_locked(char *out, size_t n) {
|
||||
snprintf(out, n, "%s, %s", t, b);
|
||||
}
|
||||
|
||||
/* What the evidence says about headroom lost with HDR frames on screen. A screenshot or a screen recording
|
||||
* is not detected in this build (that needs extra permissions), so it is named as a possibility when
|
||||
* nothing the app can measure explains the loss. Caller holds g_mu. */
|
||||
static void nohead_causes_locked(char *out, size_t n, int brief) {
|
||||
const char *parts[2];
|
||||
char hot[48];
|
||||
@@ -214,7 +185,6 @@ static void nohead_causes_locked(char *out, size_t n, int brief) {
|
||||
snprintf(hot, sizeof(hot), "the device is hot (thermal %s)", thermal_name(g_env.thermal));
|
||||
parts[np++] = hot;
|
||||
}
|
||||
/* Maximum brightness only counts when it is MANUAL: the Fold kept 3.00 of headroom at 255 auto. */
|
||||
if (g_env.brightness >= 250 && g_env.bmode == 0) parts[np++] = "brightness at maximum (manual)";
|
||||
if (np == 1) snprintf(out, n, "likely %s", parts[0]);
|
||||
else if (np == 2) snprintf(out, n, "likely %s and %s", parts[0], parts[1]);
|
||||
@@ -235,11 +205,11 @@ static void nohead_causes_locked(char *out, size_t n, int brief) {
|
||||
snprintf(out, n, "a screenshot or screen recording, heat, or manual brightness at maximum");
|
||||
}
|
||||
|
||||
/* ---- the explicit HDR headroom request (API 35; sc_layer.c for the game layer, the app for the screen
|
||||
* surface): content peak / SDR white, capped at the display's highest ratio when it reports one. */
|
||||
static _Atomic int g_screen_hr_x1000; /* the screen surface's wanted headroom x1000 (HDR10 swapchain) */
|
||||
static _Atomic int64_t g_screen_hr_ns; /* the last HDR10-swapchain frame */
|
||||
static char g_screen_hr_why[200]; /* under g_mu */
|
||||
|
||||
|
||||
static _Atomic int g_screen_hr_x1000;
|
||||
static _Atomic int64_t g_screen_hr_ns;
|
||||
static char g_screen_hr_why[200];
|
||||
|
||||
static float peak_of(const struct droiddeck_color *c, float disp_max, const char **src) {
|
||||
if (c->max_cll > 0.0f) { *src = "max CLL"; return c->max_cll; }
|
||||
@@ -308,15 +278,12 @@ int droiddeck_color_last_frame_age_ms(void) {
|
||||
return age > 0x7fffffff ? 0x7fffffff : (int)age;
|
||||
}
|
||||
|
||||
/* The one-line answer a tester quotes. Caller holds g_mu. */
|
||||
static void verdict_locked(char *out, size_t size) {
|
||||
int gate = atomic_load(&g_gate);
|
||||
if (gate < 0) { snprintf(out, size, "not decided yet (the compositor has not started)"); return; }
|
||||
if (gate == 0) { snprintf(out, size, "no, because %s", g_gate_why); return; }
|
||||
if (g_hdr.layer_frames) {
|
||||
const char *who = g_hdr.applied_who[0] ? g_hdr.applied_who : "the game";
|
||||
/* Only the paths that carried frames, so the ratio, the share and the device evidence still fit
|
||||
* the log line. */
|
||||
char paths[200] = "";
|
||||
size_t pp = 0;
|
||||
const uint64_t zc_other = g_hdr.layer_frames - g_hdr.layer_10bit - g_hdr.layer_copy8 - g_hdr.composed -
|
||||
@@ -336,12 +303,7 @@ static void verdict_locked(char *out, size_t size) {
|
||||
(unsigned long long)g_hdr.layer_frames, who, paths);
|
||||
char env[128] = "", causes[256] = "";
|
||||
if (g_env.known) env_text_locked(env, sizeof(env));
|
||||
/* Brief: the verdict has to fit one log line with everything else in it. */
|
||||
if (g_hdr.nohead_said) nohead_causes_locked(causes, sizeof(causes), 1);
|
||||
/* Only readings taken while HDR frames were on screen count: the ratio says what the display did
|
||||
* with THEM, not with whatever else was up at another moment. And the share of that time with any
|
||||
* headroom, plus where it stands now: a ratio that rose once and then fell to 1.00 for minutes is
|
||||
* not the same answer. */
|
||||
char share[384] = "";
|
||||
const long long live_s = (long long)(g_hdr.live_ns / 1000000000LL);
|
||||
if (g_hdr.live_ns >= 1000000000LL)
|
||||
@@ -351,7 +313,6 @@ static void verdict_locked(char *out, size_t size) {
|
||||
(long long)(g_hdr.headroom_ns / 1000000000LL), live_s, g_hdr.ratio_last,
|
||||
g_hdr.nohead_said ? " - no headroom now: " : "", g_hdr.nohead_said ? causes : "",
|
||||
env[0] ? " [" : "", env, env[0] ? "]" : "");
|
||||
/* The display's own ceiling (Android 16+) and what was asked for, where known. */
|
||||
char ceil[80] = "", req[48] = "";
|
||||
if (g_req.highest_ratio > 0.0f) snprintf(ceil, sizeof(ceil), ", highest possible %.2f", g_req.highest_ratio);
|
||||
if (g_env.requested > 0.0f) snprintf(req, sizeof(req), ", %.1fx requested", g_env.requested);
|
||||
@@ -400,7 +361,6 @@ static void verdict_locked(char *out, size_t size) {
|
||||
"image description (is DXVK_HDR=1 set, and is HDR switched on in the game's own display options?)");
|
||||
}
|
||||
|
||||
/* Log the verdict when it changed (force = log it even if not). */
|
||||
static void log_verdict(int force) {
|
||||
char v[512];
|
||||
pthread_mutex_lock(&g_mu);
|
||||
@@ -435,7 +395,7 @@ void droiddeck_color_frame_shown(const struct droiddeck_color *c, int path, uint
|
||||
snprintf(g_hdr.layer_fmt, sizeof(g_hdr.layer_fmt), "HDR10 swapchain");
|
||||
atomic_store(&g_screen_hr_ns, now_ns());
|
||||
break;
|
||||
default: /* DROIDDECK_HDR_TONEMAPPED: shown, but not as HDR */
|
||||
default:
|
||||
g_hdr.tonemapped++; g_hdr.win_tonemapped++;
|
||||
if (!atomic_load(&g_output_on)) g_hdr.tm_off++;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
@@ -447,8 +407,6 @@ void droiddeck_color_frame_shown(const struct droiddeck_color *c, int path, uint
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
atomic_store(&g_last_frame_ns, now_ns());
|
||||
if (path == DROIDDECK_HDR_SWAPCHAIN) {
|
||||
/* The screen surface's headroom request (the app applies it): worked out again when the
|
||||
* description changes, else once a second. */
|
||||
static uint32_t ident;
|
||||
static int64_t calc_ns;
|
||||
const int64_t t = now_ns();
|
||||
@@ -494,7 +452,6 @@ void droiddeck_color_ratio_sample(float ratio, int listener) {
|
||||
pthread_mutex_lock(&g_mu);
|
||||
was = g_hdr.ratio_logged;
|
||||
if (ratio > 0.0f) {
|
||||
/* Time with HDR frames on screen, credited to the reading that stood over it. */
|
||||
if (g_hdr.prev_sample_ns && g_hdr.prev_live) {
|
||||
int64_t dt = t - g_hdr.prev_sample_ns;
|
||||
if (dt > 0 && dt < 3000000000LL) {
|
||||
@@ -520,8 +477,6 @@ void droiddeck_color_ratio_sample(float ratio, int listener) {
|
||||
if (!g_hdr.ratio_live_n || ratio > g_hdr.ratio_live_max) g_hdr.ratio_live_max = ratio;
|
||||
g_hdr.ratio_live_n++;
|
||||
}
|
||||
/* A change is logged at once (at most 4 lines a second); while HDR frames are on screen the
|
||||
* steady value is restated every 5 s, so a tester's log shows it holding, not just moving. */
|
||||
float moved = ratio - g_hdr.ratio_logged;
|
||||
if (moved < 0.0f) moved = -moved;
|
||||
if ((g_hdr.ratio_n == 1 || moved >= 0.02f) && t - g_hdr.ratio_logged_ns > 250000000LL)
|
||||
@@ -562,7 +517,7 @@ void droiddeck_color_stats_tick(void) {
|
||||
char line[512];
|
||||
int any;
|
||||
pthread_mutex_lock(&g_mu);
|
||||
any = g_hdr.win_layer || g_hdr.win_copy || g_hdr.win_tonemapped; /* the ratio alone is logged when it moves */
|
||||
any = g_hdr.win_layer || g_hdr.win_copy || g_hdr.win_tonemapped;
|
||||
if (any) {
|
||||
char ratio[256] = "no HDR/SDR ratio reading", env[128] = "", causes[256] = "";
|
||||
if (g_env.known) env_text_locked(env, sizeof(env));
|
||||
@@ -591,7 +546,7 @@ int droiddeck_color_hdr_state(void) {
|
||||
int age = droiddeck_color_last_frame_age_ms();
|
||||
if (age < 0 || age >= 1500) return 0;
|
||||
pthread_mutex_lock(&g_mu);
|
||||
int confirmed = !g_hdr.ratio_n || g_hdr.ratio_last > 1.01f; /* no ratio on this display: the tag is all there is */
|
||||
int confirmed = !g_hdr.ratio_n || g_hdr.ratio_last > 1.01f;
|
||||
int nohead = g_hdr.nohead_said;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
return confirmed ? 1 : nohead ? 2 : 0;
|
||||
@@ -617,7 +572,7 @@ int droiddeck_color_requested(void) {
|
||||
int droiddeck_color_output(void) { return atomic_load(&g_output_on); }
|
||||
|
||||
void droiddeck_color_env_sample(int thermal, float headroom, int brightness, int bmode) {
|
||||
if (atomic_load(&g_gate) != 1) return; /* evidence for the HDR lines only */
|
||||
if (atomic_load(&g_gate) != 1) return;
|
||||
char msg[2][200];
|
||||
int nmsg = 0;
|
||||
pthread_mutex_lock(&g_mu);
|
||||
@@ -656,7 +611,6 @@ int droiddeck_color_tonemapped_on_screen(void) {
|
||||
void droiddeck_color_set_output(int on) {
|
||||
on = on ? 1 : 0;
|
||||
if (atomic_load(&g_gate) != 1) {
|
||||
/* The drawer only shows the switch in sessions whose gate is open; say so if it ever gets here. */
|
||||
droiddeck_log(TAG, "HDR output switch (%s) ignored: HDR is not open in this session", on ? "on" : "off");
|
||||
return;
|
||||
}
|
||||
@@ -674,7 +628,7 @@ void droiddeck_color_set_output(int on) {
|
||||
droiddeck_log(TAG, "HDR output switched OFF in the drawer: HDR frames are tone-mapped to SDR from the next frame "
|
||||
"(%s; %s). The game is not told - it keeps rendering HDR; its own HDR setting and DXVK_HDR are "
|
||||
"untouched", who, age >= 0 && age < 1500 ? "HDR frames were on screen" : "no HDR frames on screen just now");
|
||||
droiddeck_request_redraw(); /* a paused game commits nothing: show the change now */
|
||||
droiddeck_request_redraw();
|
||||
}
|
||||
|
||||
static _Atomic int g_session_ended;
|
||||
@@ -685,19 +639,16 @@ void droiddeck_color_session_end(void) {
|
||||
pthread_mutex_lock(&g_mu);
|
||||
int asked = g_req.mode != 0;
|
||||
pthread_mutex_unlock(&g_mu);
|
||||
if (asked) log_verdict(1); /* nobody asked for HDR: no summary to write */
|
||||
if (asked) log_verdict(1);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- image descriptions */
|
||||
|
||||
struct cm_desc {
|
||||
int refs; /* protocol objects + surfaces (pending / current) */
|
||||
int refs;
|
||||
struct droiddeck_color c;
|
||||
/* Set on the output / preferred descriptions the compositor serves (never on one a game built
|
||||
* from parameters): get_information is answered rather than refused, with these as the target. */
|
||||
int informative;
|
||||
float ref_lum; /* nits: PQ reference white */
|
||||
float disp_min_lum, disp_max_lum; /* nits: the display's own volume, from the app */
|
||||
float ref_lum;
|
||||
float disp_min_lum, disp_max_lum;
|
||||
};
|
||||
|
||||
static uint32_t g_next_identity = 1;
|
||||
@@ -705,11 +656,10 @@ static uint32_t g_next_identity = 1;
|
||||
static struct cm_desc *desc_ref(struct cm_desc *d) { if (d) d->refs++; return d; }
|
||||
static void desc_unref(struct cm_desc *d) { if (d && --d->refs <= 0) free(d); }
|
||||
|
||||
/* The parametric creator's collected properties. 0 / has_* = 0 means unset. */
|
||||
struct cm_params {
|
||||
uint32_t tf, primaries;
|
||||
int has_mprim; int32_t mprim[8];
|
||||
int has_mlum; uint32_t mlum_min, mlum_max; /* min is cd/m² * 10000, max is cd/m² */
|
||||
int has_mlum; uint32_t mlum_min, mlum_max;
|
||||
int has_cll; uint32_t cll;
|
||||
int has_fall; uint32_t fall;
|
||||
};
|
||||
@@ -718,7 +668,6 @@ static void image_description_destroy_req(struct wl_client *c, struct wl_resourc
|
||||
static void image_description_get_information(struct wl_client *c, struct wl_resource *r, uint32_t id) {
|
||||
struct cm_desc *d = wl_resource_get_user_data(r);
|
||||
if (!d || !d->informative) {
|
||||
/* Built by the game from parameters: the protocol says it knows what it asked for. */
|
||||
wl_resource_post_error(r, WP_IMAGE_DESCRIPTION_V1_ERROR_NO_INFORMATION,
|
||||
"get_information is not allowed on this image description");
|
||||
return;
|
||||
@@ -726,7 +675,7 @@ static void image_description_get_information(struct wl_client *c, struct wl_res
|
||||
struct wl_resource *info = wl_resource_create(c, &wp_image_description_info_v1_interface,
|
||||
wl_resource_get_version(r), id);
|
||||
if (!info) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(info, NULL, NULL, NULL); /* events only */
|
||||
wl_resource_set_implementation(info, NULL, NULL, NULL);
|
||||
const struct droiddeck_color *col = &d->c;
|
||||
int32_t xy[8] = { (int32_t)(col->red[0] * 1e6f + 0.5f), (int32_t)(col->red[1] * 1e6f + 0.5f),
|
||||
(int32_t)(col->green[0] * 1e6f + 0.5f), (int32_t)(col->green[1] * 1e6f + 0.5f),
|
||||
@@ -735,13 +684,11 @@ static void image_description_get_information(struct wl_client *c, struct wl_res
|
||||
wp_image_description_info_v1_send_primaries(info, xy[0], xy[1], xy[2], xy[3], xy[4], xy[5], xy[6], xy[7]);
|
||||
wp_image_description_info_v1_send_primaries_named(info, col->primaries);
|
||||
wp_image_description_info_v1_send_tf_named(info, col->tf);
|
||||
/* min is cd/m² * 10000, max and reference are cd/m² */
|
||||
wp_image_description_info_v1_send_luminances(info, (uint32_t)(col->min_lum * 10000.0f + 0.5f),
|
||||
(uint32_t)(col->max_lum + 0.5f), (uint32_t)(d->ref_lum + 0.5f));
|
||||
wp_image_description_info_v1_send_target_primaries(info, xy[0], xy[1], xy[2], xy[3], xy[4], xy[5], xy[6], xy[7]);
|
||||
wp_image_description_info_v1_send_target_luminance(info, (uint32_t)(d->disp_min_lum * 10000.0f + 0.5f),
|
||||
(uint32_t)(d->disp_max_lum + 0.5f));
|
||||
/* done is a destructor event: the client's proxy is gone once it arrives, so the resource goes too. */
|
||||
wp_image_description_info_v1_send_done(info);
|
||||
wl_resource_destroy(info);
|
||||
}
|
||||
@@ -753,15 +700,6 @@ static void image_description_resource_destroy(struct wl_resource *r) {
|
||||
desc_unref(wl_resource_get_user_data(r));
|
||||
}
|
||||
|
||||
/* What the display layer shows while the gate is open - BT.2020 + PQ over the display's own
|
||||
* volume - served as the output's image description and as every surface's preferred one. It is
|
||||
* ready at once and open to get_information, and that is not optional: gamescope asks for the
|
||||
* preferred description and for its information in the same breath, before any roundtrip
|
||||
* (WaylandBackend.cpp, UpdateWPPreferredColorManagement). Answering 'failed' and then refusing
|
||||
* get_information with a protocol error severs its connection mid-roundtrip - the Fold 8 on r5:
|
||||
* "Broken pipe", signal 6 - while a device with the gate closed never offers colour management
|
||||
* and never gets here. gamescope reads only the luminances from the answer (reference white vs
|
||||
* the display's peak) to decide whether it exposes HDR to what it hosts. */
|
||||
static void make_output_description(struct wl_client *c, struct wl_resource *parent, uint32_t id, const char *what) {
|
||||
struct cm_desc *d = calloc(1, sizeof(*d));
|
||||
if (!d) { wl_client_post_no_memory(c); return; }
|
||||
@@ -774,9 +712,9 @@ static void make_output_description(struct wl_client *c, struct wl_resource *par
|
||||
col->has_st2086 = 1;
|
||||
col->red[0] = 0.708f; col->red[1] = 0.292f; col->green[0] = 0.170f; col->green[1] = 0.797f;
|
||||
col->blue[0] = 0.131f; col->blue[1] = 0.046f; col->white[0] = 0.3127f; col->white[1] = 0.3290f;
|
||||
col->min_lum = 0.005f; col->max_lum = 10000.0f; /* the PQ volume */
|
||||
col->min_lum = 0.005f; col->max_lum = 10000.0f;
|
||||
d->informative = 1;
|
||||
d->ref_lum = 203.0f; /* PQ reference white */
|
||||
d->ref_lum = 203.0f;
|
||||
pthread_mutex_lock(&g_mu);
|
||||
d->disp_min_lum = g_req.min_lum > 0.0f ? g_req.min_lum : 0.0f;
|
||||
d->disp_max_lum = g_req.max_lum > 0.0f ? g_req.max_lum : 1000.0f;
|
||||
@@ -811,8 +749,6 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
|
||||
else if (p->primaries == WP_COLOR_MANAGER_V1_PRIMARIES_BT2020 && p->tf == WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_HLG)
|
||||
c->dataspace = DROIDDECK_ADATASPACE_BT2020_HLG;
|
||||
|
||||
/* HDR metadata, kept only when it makes sense. The PQ defaults stand in for what was not given
|
||||
* (0.005 - 10000 cd/m², the target volume = the primary one); CTA-861.3 treats 0 as unknown. */
|
||||
char dropped[160] = "";
|
||||
float mlum_min = 0.005f, mlum_max = 10000.0f;
|
||||
if (p->has_mlum) {
|
||||
@@ -827,7 +763,7 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
|
||||
c->green[0] = p->mprim[2] / 1e6f; c->green[1] = p->mprim[3] / 1e6f;
|
||||
c->blue[0] = p->mprim[4] / 1e6f; c->blue[1] = p->mprim[5] / 1e6f;
|
||||
c->white[0] = p->mprim[6] / 1e6f; c->white[1] = p->mprim[7] / 1e6f;
|
||||
} else { /* the container's own primaries (BT.2020, D65) */
|
||||
} else {
|
||||
c->red[0] = 0.708f; c->red[1] = 0.292f; c->green[0] = 0.170f; c->green[1] = 0.797f;
|
||||
c->blue[0] = 0.131f; c->blue[1] = 0.046f; c->white[0] = 0.3127f; c->white[1] = 0.3290f;
|
||||
}
|
||||
@@ -862,8 +798,6 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
|
||||
if (!out) { free(d); wl_client_post_no_memory(client); return; }
|
||||
d->refs = 1;
|
||||
wl_resource_set_implementation(out, &image_description_impl, d, image_description_resource_destroy);
|
||||
/* Sent from inside the request: Mesa blocks its swapchain on this event (it dispatches its queue
|
||||
* until ready/failed arrives), and the event loop flushes it before it sleeps again. */
|
||||
wp_image_description_v1_send_ready(out, c->identity);
|
||||
if (c->dataspace) {
|
||||
pthread_mutex_lock(&g_mu);
|
||||
@@ -878,7 +812,7 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
|
||||
droiddeck_log(TAG, "image description #%u: dropped HDR metadata that breaks the protocol's rules:%s "
|
||||
"(Android gets the rest)", c->identity, dropped);
|
||||
}
|
||||
wl_resource_destroy(r); /* create is the creator's destructor */
|
||||
wl_resource_destroy(r);
|
||||
}
|
||||
|
||||
#define PARAMS_ONCE(field, what) \
|
||||
@@ -958,14 +892,11 @@ static const struct wp_image_description_creator_params_v1_interface params_impl
|
||||
};
|
||||
static void params_resource_destroy(struct wl_resource *r) { free(wl_resource_get_user_data(r)); }
|
||||
|
||||
/* ---------------------------------------------------------------- per-surface state */
|
||||
|
||||
/* One per wl_surface that ever had a colour-management object. Lives until the wl_surface goes (a
|
||||
* swapchain rebuild destroys the object and makes a new one for the same surface). */
|
||||
struct cm_surf {
|
||||
struct wl_resource *surface; /* the wl_surface */
|
||||
struct wl_resource *surface;
|
||||
struct wl_listener surface_destroy;
|
||||
struct wl_resource *owner; /* the live wp_color_management_surface_v1, NULL = none */
|
||||
struct wl_resource *owner;
|
||||
struct cm_desc *pending, *current;
|
||||
int pending_dirty;
|
||||
};
|
||||
@@ -989,7 +920,7 @@ static void describe_surface(struct wl_resource *surface, char *out, size_t size
|
||||
static void cm_surface_destroyed(struct wl_listener *l, void *data) {
|
||||
struct cm_surf *cs = wl_container_of(l, cs, surface_destroy);
|
||||
wl_list_remove(&cs->surface_destroy.link);
|
||||
if (cs->owner) wl_resource_set_user_data(cs->owner, NULL); /* inert from now on */
|
||||
if (cs->owner) wl_resource_set_user_data(cs->owner, NULL);
|
||||
desc_unref(cs->pending);
|
||||
desc_unref(cs->current);
|
||||
free(cs);
|
||||
@@ -1035,7 +966,6 @@ static const struct wp_color_management_surface_v1_interface cm_surface_impl = {
|
||||
.unset_image_description = cm_surface_unset_image_description,
|
||||
};
|
||||
|
||||
/* Destroying the object does what unset_image_description does (double-buffered, like it). */
|
||||
static void cm_surface_resource_destroy(struct wl_resource *r) {
|
||||
struct cm_surf *cs = wl_resource_get_user_data(r);
|
||||
if (!cs || cs->owner != r) return;
|
||||
@@ -1079,7 +1009,6 @@ const struct droiddeck_color *droiddeck_color_of(struct wl_resource *surface) {
|
||||
return cs && cs->current ? &cs->current->c : NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- output + feedback */
|
||||
|
||||
static void cm_output_destroy_req(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static void cm_output_get_image_description(struct wl_client *c, struct wl_resource *r, uint32_t id) {
|
||||
@@ -1100,7 +1029,6 @@ static const struct wp_color_management_surface_feedback_v1_interface cm_feedbac
|
||||
.get_preferred_parametric = cm_feedback_get_preferred,
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- wp_color_manager_v1 */
|
||||
|
||||
static void cm_destroy_req(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
|
||||
@@ -1124,7 +1052,6 @@ static void cm_get_surface(struct wl_client *c, struct wl_resource *r, uint32_t
|
||||
char who[160];
|
||||
describe_surface(surface, who, sizeof(who));
|
||||
if (cs->owner) {
|
||||
/* The protocol says surface_exists; a game would be disconnected for it. The newer object wins. */
|
||||
droiddeck_log(TAG, "%s: a second colour-management object for the same surface - the newer one takes over "
|
||||
"(protocol error surface_exists not raised)", who);
|
||||
wl_resource_set_user_data(cs->owner, NULL);
|
||||
@@ -1174,16 +1101,12 @@ static void bind_cm(struct wl_client *c, void *data, uint32_t ver, uint32_t id)
|
||||
struct wl_resource *r = wl_resource_create(c, &wp_color_manager_v1_interface, ver > 1 ? 1 : (int)ver, id);
|
||||
if (!r) { wl_client_post_no_memory(c); return; }
|
||||
wl_resource_set_implementation(r, &cm_impl, NULL, NULL);
|
||||
/* All at bind, then done: Mesa reads them in the registry roundtrip that follows the bind and
|
||||
* lists VK_COLOR_SPACE_HDR10_ST2084_EXT from exactly this pair (bt2020 + st2084_pq). Only what
|
||||
* the display layer can honour is offered. */
|
||||
wp_color_manager_v1_send_supported_intent(r, WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
|
||||
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC);
|
||||
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES);
|
||||
wp_color_manager_v1_send_supported_primaries_named(r, WP_COLOR_MANAGER_V1_PRIMARIES_BT2020);
|
||||
wp_color_manager_v1_send_supported_tf_named(r, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ);
|
||||
wp_color_manager_v1_send_done(r);
|
||||
/* One line per program: Mesa binds again for every surface-format query. */
|
||||
if (last_named != c) {
|
||||
last_named = c;
|
||||
droiddeck_log(TAG, "%s bound wp_color_manager_v1 version %u (offered: perceptual intent; parametric descriptions "
|
||||
@@ -1194,7 +1117,6 @@ static void bind_cm(struct wl_client *c, void *data, uint32_t ver, uint32_t id)
|
||||
|
||||
void droiddeck_color_client_gone(struct wl_client *client) {
|
||||
if (atomic_load(&g_gate) != 1 || atomic_load(&g_session_ended)) return;
|
||||
/* A program that presented HDR has left: say where the session stands now, while it is fresh. */
|
||||
const char *name = droiddeck_client_name(client);
|
||||
int mine;
|
||||
pthread_mutex_lock(&g_mu);
|
||||
@@ -1203,7 +1125,6 @@ void droiddeck_color_client_gone(struct wl_client *client) {
|
||||
if (mine) log_verdict(1);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- the gate */
|
||||
|
||||
void droiddeck_color_init(struct wl_display *display) {
|
||||
char why[320] = "";
|
||||
@@ -1227,7 +1148,6 @@ void droiddeck_color_init(struct wl_display *display) {
|
||||
else
|
||||
snprintf(disp, sizeof(disp), "the app could not read the display's HDR capability");
|
||||
|
||||
/* What asked for HDR, in the words the user knows it by: the editors' setting, or the env override. */
|
||||
char asked[128];
|
||||
if (mode == 2) snprintf(asked, sizeof(asked), "DROIDDECK_WAYLAND_HDR=force (%s)", source);
|
||||
else if (strstr(source, "env")) snprintf(asked, sizeof(asked), "DROIDDECK_WAYLAND_HDR=1 (%s)", source);
|
||||
@@ -1262,8 +1182,6 @@ void droiddeck_color_init(struct wl_display *display) {
|
||||
"(games that check fall back to SDR; some show washed-out colours) - remove it on this display");
|
||||
log_verdict(1);
|
||||
} else if (dxvk_hdr || (known && hdr10)) {
|
||||
/* Off, and silent unless it is worth a line: a display that could show HDR10, or a DXVK
|
||||
* switch that promises games an HDR display they cannot get. */
|
||||
droiddeck_log(TAG, "HDR output off for this session (%s)%s%s", off_why,
|
||||
(known && hdr10) ? " - this display lists HDR10, so switching HDR output on for this game would "
|
||||
"offer it to games" : "",
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
/*
|
||||
* zwp_linux_dmabuf_v1: the buffer params a client builds a dma-buf wl_buffer from, the format and
|
||||
* modifier table the renderer can import, and dma-buf feedback (version 4). Split out of
|
||||
* compositor.c; the buffer records themselves are in compositor_internal.h.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -20,7 +15,6 @@
|
||||
#include "droiddeck_color.h"
|
||||
#include "compositor_internal.h"
|
||||
|
||||
/* ------------------------------------------------------------ zwp_linux_dmabuf_v1 */
|
||||
|
||||
static void dbuf_buffer_resource_destroy(struct wl_resource *r) {
|
||||
dmabuf_buffer_unref(wl_resource_get_user_data(r));
|
||||
@@ -44,7 +38,7 @@ static struct wl_resource *params_do_create(struct wl_client *c, struct wl_resou
|
||||
struct dmabuf_buffer *b = calloc(1, sizeof(*b));
|
||||
if (!b) return NULL;
|
||||
b->n_planes = p->n_planes;
|
||||
b->refs = 1; /* the wl_buffer resource's */
|
||||
b->refs = 1;
|
||||
b->width = w; b->height = h; b->format = format;
|
||||
b->modifier = p->modifier[0];
|
||||
for (int i = 0; i < MAX_PLANES; i++) b->fd[i] = -1;
|
||||
@@ -52,7 +46,7 @@ static struct wl_resource *params_do_create(struct wl_client *c, struct wl_resou
|
||||
b->fd[i] = p->fd[i];
|
||||
b->offset[i] = p->offset[i];
|
||||
b->stride[i] = p->stride[i];
|
||||
p->fd[i] = -1; /* ownership moves to the buffer */
|
||||
p->fd[i] = -1;
|
||||
}
|
||||
struct wl_resource *buf = wl_resource_create(c, &wl_buffer_interface, 1, id);
|
||||
if (!buf) {
|
||||
@@ -109,14 +103,6 @@ static const struct zwp_linux_dmabuf_v1_interface dmabuf_impl = {
|
||||
.get_default_feedback = dmabuf_get_default_feedback,
|
||||
.get_surface_feedback = dmabuf_get_surface_feedback,
|
||||
};
|
||||
/* The advertised format/modifier table, built at the first bind from what the renderer's driver
|
||||
* can import (vkp_dmabuf_modifiers). INVALID is always offered too (Mesa drops it; other clients
|
||||
* may use it for the implicit path). Without a renderer the list is LINEAR + INVALID, as before. */
|
||||
/* The last two rows are HDR10's (droiddeck_color.h): A2B10G10R10 as AB30 (alpha) + XB30 (opaque) - Mesa
|
||||
* lists a VkFormat only when both are advertised, and it is the one 10-bit layout our zero-copy WSI
|
||||
* can put in a gralloc buffer (AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM). They are advertised ONLY
|
||||
* while the HDR gate is open, and after the 8-bit rows, so every other session - and every client that
|
||||
* takes the first format it sees - gets exactly the table it always had. */
|
||||
#define DMABUF_NFMT_MAX 6
|
||||
#define DMABUF_NFMT_SDR 4
|
||||
#define DMABUF_NMOD 4
|
||||
@@ -124,7 +110,7 @@ static const struct zwp_linux_dmabuf_v1_interface dmabuf_impl = {
|
||||
#define DRM_XBGR2101010 FOURCC('X', 'B', '3', '0')
|
||||
static struct { uint32_t fmt; uint64_t mods[DMABUF_NMOD]; int n; } g_dmabuf_fmts[DMABUF_NFMT_MAX] = {
|
||||
{DRM_ARGB8888}, {DRM_XRGB8888}, {DRM_ABGR8888}, {DRM_XBGR8888}, {DRM_ABGR2101010}, {DRM_XBGR2101010}};
|
||||
static int g_dmabuf_nfmt = DMABUF_NFMT_SDR; /* rows advertised: the SDR four, + 2 with the HDR gate open */
|
||||
static int g_dmabuf_nfmt = DMABUF_NFMT_SDR;
|
||||
static int g_dmabuf_fmts_ready;
|
||||
static void dmabuf_build_feedback(void);
|
||||
|
||||
@@ -136,8 +122,6 @@ static void dmabuf_build_formats(void) {
|
||||
for (int f = 0; f < g_dmabuf_nfmt; f++) {
|
||||
uint64_t got[DMABUF_NMOD];
|
||||
int n = vkp_dmabuf_modifiers(g_dmabuf_fmts[f].fmt, got, DMABUF_NMOD), k = 0;
|
||||
/* LINEAR first: it is the layout every client and the shm fallback agree on, and the one
|
||||
* we advertised before this table existed. */
|
||||
g_dmabuf_fmts[f].mods[k++] = MOD_LINEAR;
|
||||
for (int i = 0; i < n && k < DMABUF_NMOD - 1; i++) {
|
||||
if (got[i] == MOD_LINEAR) continue;
|
||||
@@ -161,8 +145,6 @@ static void dmabuf_build_formats(void) {
|
||||
droiddeck_log("dmabuf", "the compositor's driver (%s) reports no importable qcom_compressed layout: "
|
||||
"game swapchains stay linear", vkp_gpu_name());
|
||||
if (g_dmabuf_nfmt > DMABUF_NFMT_SDR) {
|
||||
/* The rows above always carry LINEAR; say what the compositor's own driver can really import
|
||||
* for 10-bit, since a gralloc buffer it cannot import is shown on the display layer only. */
|
||||
uint64_t got[DMABUF_NMOD];
|
||||
int n = vkp_dmabuf_modifiers(DRM_XBGR2101010, got, DMABUF_NMOD), ubwc10 = 0;
|
||||
for (int i = 0; i < n; i++) if (got[i] == VKP_MOD_QCOM_COMPRESSED) ubwc10 = 1;
|
||||
@@ -174,19 +156,6 @@ static void dmabuf_build_formats(void) {
|
||||
dmabuf_build_feedback();
|
||||
}
|
||||
|
||||
/* ---- dmabuf feedback (zwp_linux_dmabuf_v1 version 4)
|
||||
*
|
||||
* Turnip's Vulkan WSI is happy with the version 3 format/modifier events, so every Vulkan game
|
||||
* worked while we only advertised 3. Mesa's EGL is not: its Wayland platform only takes the GPU
|
||||
* (kopper/Zink) path when it can bind this interface with FEEDBACK, and with 3 it silently drops
|
||||
* to its wl_shm software path. On this Proton layer that path has no software rasteriser to fall
|
||||
* back to (the gallium build is zink+kopper+swrast, no llvmpipe), so the shm buffer it commits is
|
||||
* never written: a native OpenGL window came out solid black, ~30 shm commits/s and no GPU frame
|
||||
* at all (Wizardry: The Labyrinth of Lost Souls). Feedback is what makes that path work.
|
||||
*
|
||||
* What a client needs from us is one tranche describing "everything the compositor can import":
|
||||
* a format table it mmaps read-only, the device to allocate on, and the indices it may use.
|
||||
* Clients binding versions 1-3 keep getting the old format/modifier events instead. */
|
||||
|
||||
#ifndef MFD_CLOEXEC
|
||||
#define MFD_CLOEXEC 0x0001U
|
||||
@@ -202,17 +171,13 @@ static void dmabuf_build_formats(void) {
|
||||
#define F_SEAL_WRITE 0x0008
|
||||
#endif
|
||||
|
||||
struct dmabuf_fmt_entry { uint32_t format; uint32_t pad; uint64_t modifier; }; /* the wire layout */
|
||||
struct dmabuf_fmt_entry { uint32_t format; uint32_t pad; uint64_t modifier; };
|
||||
|
||||
static int g_fmt_table_fd = -1; /* sealed read-only memfd of dmabuf_fmt_entry[] */
|
||||
static int g_fmt_table_fd = -1;
|
||||
static size_t g_fmt_table_size;
|
||||
static uint16_t g_fmt_table_n; /* entries, == the indices a tranche may name */
|
||||
dev_t g_main_device; /* the render node clients should allocate on */
|
||||
static uint16_t g_fmt_table_n;
|
||||
dev_t g_main_device;
|
||||
|
||||
/* The GPU we import through is reached with KGSL, not DRM, so there is no render node of our own
|
||||
* to name. Clients only use main_device to match "the same device as the compositor" and to pick
|
||||
* a driver; the one DRM render node this platform has is the right answer, and Zink ignores it
|
||||
* anyway (it renders on the Vulkan device it already has). 0 if the platform has none. */
|
||||
static dev_t dmabuf_render_node(void) {
|
||||
static const char *nodes[] = {"/dev/dri/renderD128", "/dev/dri/renderD129", "/dev/dri/card0"};
|
||||
struct stat st;
|
||||
@@ -229,7 +194,7 @@ static void dmabuf_build_feedback(void) {
|
||||
g_main_device = dmabuf_render_node();
|
||||
for (int f = 0; f < g_dmabuf_nfmt; f++)
|
||||
for (int m = 0; m < g_dmabuf_fmts[f].n; m++) {
|
||||
if (g_dmabuf_fmts[f].mods[m] == MOD_INVALID) continue; /* never offer INVALID here */
|
||||
if (g_dmabuf_fmts[f].mods[m] == MOD_INVALID) continue;
|
||||
entries[n].format = g_dmabuf_fmts[f].fmt;
|
||||
entries[n].pad = 0;
|
||||
entries[n].modifier = g_dmabuf_fmts[f].mods[m];
|
||||
@@ -246,15 +211,12 @@ static void dmabuf_build_feedback(void) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
/* The client mmaps this read-only and trusts it not to change under it. */
|
||||
fcntl(fd, F_ADD_SEALS, F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE);
|
||||
g_fmt_table_fd = fd;
|
||||
g_fmt_table_size = size;
|
||||
g_fmt_table_n = (uint16_t)n;
|
||||
droiddeck_log("dmabuf", "feedback ready: %d format/modifier pairs, main device %u:%u",
|
||||
n, (unsigned)major(g_main_device), (unsigned)minor(g_main_device));
|
||||
/* Vulkan games never need the node. Mesa's EGL did until Wayland layer versionCode 9: without
|
||||
* one it fell back to a software path that draws nothing here (black window, sound plays). */
|
||||
if (!g_main_device)
|
||||
droiddeck_log("dmabuf", "%s: OpenGL games need Wayland layer versionCode 9 or newer, "
|
||||
"which runs OpenGL on the GPU without a DRM node; older layers show a black window",
|
||||
@@ -262,7 +224,6 @@ static void dmabuf_build_feedback(void) {
|
||||
: "this device gives apps no display (DRM) device (/dev/dri)");
|
||||
}
|
||||
|
||||
/* One tranche: our device, every pair in the table, no scanout flag. */
|
||||
static void dmabuf_feedback_send(struct wl_resource *fb) {
|
||||
struct wl_array dev, idx;
|
||||
uint16_t *ind;
|
||||
@@ -309,8 +270,6 @@ static void dmabuf_get_default_feedback(struct wl_client *c, struct wl_resource
|
||||
if (ci) ci->asked_feedback = 1;
|
||||
dmabuf_new_feedback(c, r, id);
|
||||
}
|
||||
/* Per-surface feedback would let us hint a different tranche for a window on its own display
|
||||
* layer; we have nothing better to say per surface, so it is the default one. */
|
||||
static void dmabuf_get_surface_feedback(struct wl_client *c, struct wl_resource *r, uint32_t id,
|
||||
struct wl_resource *surface) {
|
||||
dmabuf_new_feedback(c, r, id);
|
||||
@@ -320,8 +279,6 @@ void bind_dmabuf(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
struct wl_resource *r = wl_resource_create(c, &zwp_linux_dmabuf_v1_interface, ver, id);
|
||||
wl_resource_set_implementation(r, &dmabuf_impl, NULL, NULL);
|
||||
if (!g_dmabuf_fmts_ready) dmabuf_build_formats();
|
||||
/* From version 4 the format and modifier events are gone: the client asks for feedback
|
||||
* instead, and sending both would only confuse it about which list is authoritative. */
|
||||
if (ver >= 4) return;
|
||||
for (int f = 0; f < g_dmabuf_nfmt; f++) {
|
||||
zwp_linux_dmabuf_v1_send_format(r, g_dmabuf_fmts[f].fmt);
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
/*
|
||||
* wp_single_pixel_buffer_manager_v1 (version 1): a wl_buffer of one pixel of one colour, which a
|
||||
* client stretches over a surface with wp_viewporter. KWin's Wayland backend - the desktop's KWin
|
||||
* nested in this compositor - refuses to start without it. The surface takes the pixel as a 1x1
|
||||
* image, the way it takes a wl_shm buffer (compositor.c, take_pixel).
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "droiddeck_ext.h"
|
||||
#include "single-pixel-buffer-v1-server-protocol.h"
|
||||
|
||||
struct single_pixel {
|
||||
uint8_t bgra[4]; /* premultiplied, as wl_shm's ARGB8888 lies in memory */
|
||||
uint8_t bgra[4];
|
||||
};
|
||||
|
||||
static void buffer_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
@@ -30,7 +24,6 @@ static void mgr_create_buffer(struct wl_client *c, struct wl_resource *r, uint32
|
||||
struct single_pixel *p = calloc(1, sizeof(*p));
|
||||
struct wl_resource *buffer = p ? wl_resource_create(c, &wl_buffer_interface, 1, id) : NULL;
|
||||
if (!buffer) { free(p); wl_client_post_no_memory(c); return; }
|
||||
/* The protocol's values span the whole u32 range; the top byte is the 8-bit channel. */
|
||||
p->bgra[0] = blue >> 24;
|
||||
p->bgra[1] = green >> 24;
|
||||
p->bgra[2] = red >> 24;
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
/*
|
||||
* 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 droiddeck_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. droiddeck_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>
|
||||
@@ -39,28 +17,25 @@ 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 */
|
||||
struct wl_resource *entered;
|
||||
uint32_t serial;
|
||||
|
||||
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 */
|
||||
int has_preedit;
|
||||
};
|
||||
static struct wl_list g_inputs;
|
||||
static struct wl_resource *g_target; /* surface text input is focused on */
|
||||
static struct wl_resource *g_target;
|
||||
|
||||
/* 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 droiddeck_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;
|
||||
@@ -92,13 +67,12 @@ static void tell_app(void) {
|
||||
droiddeck_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->enabled = 0;
|
||||
ti->has_preedit = 0;
|
||||
}
|
||||
|
||||
@@ -129,7 +103,6 @@ void droiddeck_text_input_surface_gone(struct wl_resource *surface) {
|
||||
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);
|
||||
@@ -166,7 +139,7 @@ static void ti_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
if (!ti) return;
|
||||
ti->serial++;
|
||||
if (ti->p_enable) {
|
||||
ti->enabled = ti->entered != NULL; /* enable only counts while focused */
|
||||
ti->enabled = ti->entered != NULL;
|
||||
memset(ti->rect, 0, sizeof(ti->rect));
|
||||
ti->hint = 0; ti->purpose = 0;
|
||||
ti->has_preedit = 0;
|
||||
@@ -212,7 +185,6 @@ static void bind_text_input_manager(struct wl_client *c, void *data, uint32_t ve
|
||||
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;
|
||||
@@ -220,7 +192,6 @@ static size_t utf8_chars(const char *s, size_t len) {
|
||||
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;
|
||||
@@ -259,7 +230,7 @@ void text_input_host_delete(int before, int after) {
|
||||
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 */
|
||||
if (ti && ti->has_preedit) {
|
||||
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;
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
/*
|
||||
* 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 "droiddeck_ext.h"
|
||||
#include "xdg-toplevel-icon-v1-server-protocol.h"
|
||||
|
||||
Reference in new issue
Block a user