mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
wayland: add support for single-pixel-buffer-v1 protocol (#17298)
* wayland: add support for single-pixel-buffer-v1 protocol * Create single pixel buffer instead of checkerboard if available * Fix identations
This commit is contained in:
parent
e3cc0341b9
commit
9ffb458626
2
.gitignore
vendored
2
.gitignore
vendored
@ -237,6 +237,8 @@ gfx/common/wayland/tablet-unstable-v2.h
|
||||
gfx/common/wayland/tablet-unstable-v2.c
|
||||
gfx/common/wayland/content-type-v1.h
|
||||
gfx/common/wayland/content-type-v1.c
|
||||
gfx/common/wayland/single-pixel-buffer-v1.h
|
||||
gfx/common/wayland/single-pixel-buffer-v1.c
|
||||
|
||||
# libretro-common samples
|
||||
libretro-common/samples/streams/rzip/rzip
|
||||
|
@ -1278,7 +1278,8 @@ ifeq ($(HAVE_WAYLAND), 1)
|
||||
gfx/common/wayland/relative-pointer-unstable-v1.o \
|
||||
gfx/common/wayland/cursor-shape-v1.o \
|
||||
gfx/common/wayland/tablet-unstable-v2.o \
|
||||
gfx/common/wayland/content-type-v1.o
|
||||
gfx/common/wayland/content-type-v1.o \
|
||||
gfx/common/wayland/single-pixel-buffer-v1.o
|
||||
|
||||
ifeq ($(HAVE_VULKAN), 1)
|
||||
OBJ += gfx/drivers_context/wayland_vk_ctx.o
|
||||
|
4
deps/wayland-protocols/staging/single-pixel-buffer/README
vendored
Normal file
4
deps/wayland-protocols/staging/single-pixel-buffer/README
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
Single-pixel buffer protocol
|
||||
|
||||
Maintainers:
|
||||
Simon Ser <contact@emersion.fr> (@emersion)
|
69
deps/wayland-protocols/staging/single-pixel-buffer/single-pixel-buffer-v1.xml
vendored
Normal file
69
deps/wayland-protocols/staging/single-pixel-buffer/single-pixel-buffer-v1.xml
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="single_pixel_buffer_v1">
|
||||
<copyright>
|
||||
Copyright © 2022 Simon Ser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="single pixel buffer factory">
|
||||
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.
|
||||
</description>
|
||||
|
||||
<interface name="wp_single_pixel_buffer_manager_v1" version="1">
|
||||
<description summary="global factory for single-pixel buffers">
|
||||
The wp_single_pixel_buffer_manager_v1 interface is a factory for
|
||||
single-pixel buffers.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the manager">
|
||||
Destroy the wp_single_pixel_buffer_manager_v1 object.
|
||||
|
||||
The child objects created via this interface are unaffected.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="create_u32_rgba_buffer">
|
||||
<description summary="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.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="wl_buffer"/>
|
||||
<arg name="r" type="uint" summary="value of the buffer's red channel"/>
|
||||
<arg name="g" type="uint" summary="value of the buffer's green channel"/>
|
||||
<arg name="b" type="uint" summary="value of the buffer's blue channel"/>
|
||||
<arg name="a" type="uint" summary="value of the buffer's alpha channel"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
@ -69,6 +69,7 @@ generate_source 'unstable/pointer-constraints' 'pointer-constraints-unstable-v1'
|
||||
generate_source 'unstable/relative-pointer' 'relative-pointer-unstable-v1'
|
||||
generate_source 'staging/fractional-scale' 'fractional-scale-v1'
|
||||
generate_source 'staging/cursor-shape' 'cursor-shape-v1'
|
||||
# Required by cursor-shape-v1
|
||||
# tablet-unstable-v1 is required by cursor-shape-v1
|
||||
generate_source 'unstable/tablet' 'tablet-unstable-v2'
|
||||
generate_source 'staging/content-type' 'content-type-v1'
|
||||
generate_source 'staging/single-pixel-buffer' 'single-pixel-buffer-v1'
|
||||
|
@ -323,6 +323,8 @@ void gfx_ctx_wl_destroy_resources_common(gfx_ctx_wayland_data_t *wl)
|
||||
wp_cursor_shape_manager_v1_destroy (wl->cursor_shape_manager);
|
||||
if (wl->cursor_shape_device)
|
||||
wp_cursor_shape_device_v1_destroy (wl->cursor_shape_device);
|
||||
if (wl->single_pixel_manager)
|
||||
wp_single_pixel_buffer_manager_v1_destroy (wl->single_pixel_manager);
|
||||
if (wl->seat)
|
||||
wl_seat_destroy(wl->seat);
|
||||
if (wl->xdg_shell)
|
||||
@ -376,6 +378,7 @@ void gfx_ctx_wl_destroy_resources_common(gfx_ctx_wayland_data_t *wl)
|
||||
wl->cursor_shape_device = NULL;
|
||||
wl->idle_inhibit_manager = NULL;
|
||||
wl->deco_manager = NULL;
|
||||
wl->single_pixel_manager = NULL;
|
||||
wl->surface = NULL;
|
||||
wl->xdg_surface = NULL;
|
||||
wl->xdg_toplevel = NULL;
|
||||
@ -548,7 +551,7 @@ static shm_buffer_t *create_shm_buffer(gfx_ctx_wayland_data_t *wl, int width,
|
||||
buffer->data = data;
|
||||
buffer->data_size = size;
|
||||
|
||||
return buffer;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void shm_buffer_paint_icon(
|
||||
@ -614,22 +617,37 @@ static void shm_buffer_paint_checkerboard(
|
||||
|
||||
static bool wl_draw_splash_screen(gfx_ctx_wayland_data_t *wl)
|
||||
{
|
||||
shm_buffer_t *buffer = create_shm_buffer(wl,
|
||||
wl->buffer_width,
|
||||
wl->buffer_height,
|
||||
WL_SHM_FORMAT_XRGB8888);
|
||||
if (wl->single_pixel_manager)
|
||||
{
|
||||
struct wl_buffer *buffer = NULL;
|
||||
buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer(
|
||||
wl->single_pixel_manager, 0, 0, 0, UINT32_MAX);
|
||||
|
||||
if (!buffer)
|
||||
return false;
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
shm_buffer_paint_checkerboard(buffer, wl->buffer_width,
|
||||
wl->buffer_height, 1,
|
||||
8, 0xffbcbcbc, 0xff8e8e8e);
|
||||
shm_buffer_paint_icon(buffer, wl->buffer_width,
|
||||
wl->buffer_height, 1,
|
||||
16);
|
||||
wl_surface_attach(wl->surface, buffer, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
shm_buffer_t *buffer = create_shm_buffer(wl,
|
||||
wl->buffer_width,
|
||||
wl->buffer_height,
|
||||
WL_SHM_FORMAT_XRGB8888);
|
||||
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
shm_buffer_paint_checkerboard(buffer, wl->buffer_width,
|
||||
wl->buffer_height, 1,
|
||||
8, 0xffbcbcbc, 0xff8e8e8e);
|
||||
shm_buffer_paint_icon(buffer, wl->buffer_width,
|
||||
wl->buffer_height, 1,
|
||||
16);
|
||||
|
||||
wl_surface_attach(wl->surface, buffer->wl_buffer, 0, 0);
|
||||
}
|
||||
|
||||
wl_surface_attach(wl->surface, buffer->wl_buffer, 0, 0);
|
||||
if (wl_surface_get_version(wl->surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
|
||||
wl_surface_damage_buffer(wl->surface, 0, 0,
|
||||
wl->buffer_width,
|
||||
@ -755,6 +773,11 @@ bool gfx_ctx_wl_init_common(
|
||||
RARCH_LOG("[Wayland]: Compositor doesn't support the %s protocol!\n", zwp_relative_pointer_manager_v1_interface.name);
|
||||
}
|
||||
|
||||
if (!wl->single_pixel_manager)
|
||||
{
|
||||
RARCH_LOG("[Wayland]: Compositor doesn't support the %s protocol!\n", wp_single_pixel_buffer_manager_v1_interface.name);
|
||||
}
|
||||
|
||||
wl->surface = wl_compositor_create_surface(wl->compositor);
|
||||
if (wl->viewporter)
|
||||
wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
|
||||
|
@ -802,6 +802,10 @@ static void wl_registry_handle_global(void *data, struct wl_registry *reg,
|
||||
wl->content_type_manager = (struct wp_content_type_manager_v1*)
|
||||
wl_registry_bind(
|
||||
reg, id, &wp_content_type_manager_v1_interface, MIN(version, 1));
|
||||
else if (string_is_equal(interface, wp_single_pixel_buffer_manager_v1_interface.name) && found++)
|
||||
wl->single_pixel_manager = (struct wp_single_pixel_buffer_manager_v1*)
|
||||
wl_registry_bind(
|
||||
reg, id, &wp_single_pixel_buffer_manager_v1_interface, MIN(version, 1));
|
||||
|
||||
if (found > 1)
|
||||
RARCH_LOG("[Wayland]: Registered interface %s at version %u\n",
|
||||
|
@ -37,12 +37,13 @@
|
||||
#include "../../gfx/common/wayland/content-type-v1.h"
|
||||
#include "../../gfx/common/wayland/cursor-shape-v1.h"
|
||||
#include "../../gfx/common/wayland/fractional-scale-v1.h"
|
||||
#include "../../gfx/common/wayland/viewporter.h"
|
||||
#include "../../gfx/common/wayland/idle-inhibit-unstable-v1.h"
|
||||
#include "../../gfx/common/wayland/xdg-shell.h"
|
||||
#include "../../gfx/common/wayland/xdg-decoration-unstable-v1.h"
|
||||
#include "../../gfx/common/wayland/pointer-constraints-unstable-v1.h"
|
||||
#include "../../gfx/common/wayland/relative-pointer-unstable-v1.h"
|
||||
#include "../../gfx/common/wayland/single-pixel-buffer-v1.h"
|
||||
#include "../../gfx/common/wayland/viewporter.h"
|
||||
#include "../../gfx/common/wayland/xdg-decoration-unstable-v1.h"
|
||||
#include "../../gfx/common/wayland/xdg-shell.h"
|
||||
|
||||
#define FRACTIONAL_SCALE_V1_DEN 120
|
||||
#define FRACTIONAL_SCALE_MULT(v, scale_num) \
|
||||
@ -187,6 +188,7 @@ typedef struct gfx_ctx_wayland_data
|
||||
struct wp_cursor_shape_device_v1 *cursor_shape_device;
|
||||
struct wp_content_type_manager_v1 *content_type_manager;
|
||||
struct wp_content_type_v1 *content_type;
|
||||
struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;
|
||||
output_info_t *current_output;
|
||||
#ifdef HAVE_VULKAN
|
||||
gfx_ctx_vulkan_data_t vk;
|
||||
|
Loading…
x
Reference in New Issue
Block a user