Skip to content
Myr

wayland: use the single-pixel protocol for the initial, transparent frame

Before adoption: this commit came in with the history the project adopted, so no landing records it.

On my laptop, rendering the initial transparent frame goes from ~1000µs to 10µs.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 70ee26b · Browse files · 2 files+42 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+42 added−0 removed

  • other:+42 added−0 removed

2 files+42 added−0 removed

modified:meson.build+1 added
150 unmodified lines
151 wayland_protocols_datadir + '/stable/viewporter/viewporter.xml',152 wayland_protocols_datadir + '/staging/fractional-scale/fractional-scale-v1.xml',153 wayland_protocols_datadir / 'unstable/primary-selection/primary-selection-unstable-v1.xml',154 wayland_protocols_datadir / 'staging/color-management/color-management-v1.xml',155 wayland_protocols_datadir / 'staging/single-pixel-buffer/single-pixel-buffer-v1.xml',156]157158foreach prot : wl_proto_xml159 wl_proto_headers += custom_target(
116 unmodified lines
modified:wayland.c+41 added
28 unmodified lines
29#include <color-management-v1.h>30#include <cursor-shape-v1.h>31#include <fractional-scale-v1.h>32#include <primary-selection-unstable-v1.h>33#include <single-pixel-buffer-v1.h>34#include <viewporter.h>35#include <wlr-layer-shell-unstable-v1.h>36#include <xdg-activation-v1.h>37#include <xdg-output-unstable-v1.h>
151 unmodified lines
189 bool have_tf_ext_linear;190 bool have_primaries_srgb;191 } color_management;192193 struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;194195 tll(struct monitor) monitors;196 const struct monitor *monitor;197198 tll(struct seat) seats;
2115 unmodified lines
2314 wp_color_manager_v1_add_listener(2315 wayl->color_management.manager, &color_manager_listener, wayl);2316 }23172318 else if (strcmp(interface, wp_single_pixel_buffer_manager_v1_interface.name) == 0) {2319 const uint32_t required = 1;2320 if (!verify_iface_version(interface, version, required))2321 return;23222323 wayl->single_pixel_manager = wl_registry_bind(2324 wayl->registry, name,2325 &wp_single_pixel_buffer_manager_v1_interface, required);2326 }23272328}23292330static void2331monitor_destroy(struct monitor *mon)
191 unmodified lines
2523 if (wayl->chain == NULL)2524 abort();2525 }25262527 /*2528 * Optimized version of transparent frame, using the single-pixel2529 * protocol. Fallback version below, after shm_get_buffer().2530 */2531 if (wayl->render_first_frame_transparent &&2532 wayl->single_pixel_manager != NULL &&2533 wayl->viewport != NULL)2534 {2535 struct wl_buffer *single =2536 wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer(2537 wayl->single_pixel_manager, 0, 0, 0, 0);25382539 struct buffer buf = {2540 .width = wayl->width,2541 .height = wayl->height,2542 .wl_buf = single,2543 };25442545 commit_buffer(wayl, &buf);2546 wl_buffer_destroy(single);2547 goto done;2548 }25492550 struct buffer *buf = shm_get_buffer(wayl->chain, wayl->width, wayl->height, true);25512552 pixman_region32_t clip;2553 pixman_region32_init_rect(&clip, 0, 0, buf->width, buf->height);2554 pixman_image_set_clip_region32(buf->pix[0], &clip);2555 pixman_region32_fini(&clip);25562557 if (wayl->render_first_frame_transparent) {2558 /* Fallback version of transparent frame */2559 pixman_color_t transparent = {0};2560 pixman_image_fill_rectangles(2561 PIXMAN_OP_SRC, buf->pix[0], &transparent,2562 1, &(pixman_rectangle16_t){0, 0, wayl->width, wayl->height});25632564 goto commit;2565 }25662567 render_set_subpixel(wayl->render, wayl->subpixel);
27 unmodified lines
2595 /* No pending frames - render immediately */2596 assert(!wayl->need_refresh);2597 commit_buffer(wayl, buf);25982599done:2600 if (wayl->conf->print_timing_info) {2601 gettimeofday(&stop, NULL);2602 timersub(&stop, &start, &diff);2603 LOG_WARN("%sframe rendered in %llus %lluµs",
416 unmodified lines
3020 tll_foreach(wayl->monitors, it)3021 monitor_destroy(&it->item);3022 tll_free(wayl->monitors);30233024 if (wayl->single_pixel_manager != NULL)3025 wp_single_pixel_buffer_manager_v1_destroy(wayl->single_pixel_manager);3026 if (wayl->color_management_surface != NULL)3027 wp_color_management_surface_v1_destroy(wayl->color_management_surface);3028 if (wayl->color_management.img_description != NULL)3029 wp_image_description_v1_destroy(wayl->color_management.img_description);
133 unmodified lines