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
Provenance
- Commit
82b0558- Tree
9f022c9- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
70ee26b
2 files changed+42 added−0 removed
modified:meson.build+1 added
150 unmodified lines151 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 ]157 158 foreach prot : wl_proto_xml159 wl_proto_headers += custom_target(116 unmodified linesmodified:wayland.c+41 added
28 unmodified lines29 #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 lines189 bool have_tf_ext_linear;190 bool have_primaries_srgb;191 } color_management;192 193+ struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;194+195 tll(struct monitor) monitors;196 const struct monitor *monitor;197 198 tll(struct seat) seats;2115 unmodified lines2314 wp_color_manager_v1_add_listener(2315 wayl->color_management.manager, &color_manager_listener, wayl);2316 }2317 2318+ 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;2322+2323+ wayl->single_pixel_manager = wl_registry_bind(2324+ wayl->registry, name,2325+ &wp_single_pixel_buffer_manager_v1_interface, required);2326+ }2327+2328 }2329 2330 static void2331 monitor_destroy(struct monitor *mon)191 unmodified lines2523 if (wayl->chain == NULL)2524 abort();2525 }2526 2527+ /*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);2538+2539+ struct buffer buf = {2540+ .width = wayl->width,2541+ .height = wayl->height,2542+ .wl_buf = single,2543+ };2544+2545+ commit_buffer(wayl, &buf);2546+ wl_buffer_destroy(single);2547+ goto done;2548+ }2549+2550 struct buffer *buf = shm_get_buffer(wayl->chain, wayl->width, wayl->height, true);2551 2552 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);2556 2557 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});2563+2564 goto commit;2565 }2566 2567 render_set_subpixel(wayl->render, wayl->subpixel);27 unmodified lines2595 /* No pending frames - render immediately */2596 assert(!wayl->need_refresh);2597 commit_buffer(wayl, buf);2598 2599+done: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 lines3020 tll_foreach(wayl->monitors, it)3021 monitor_destroy(&it->item);3022 tll_free(wayl->monitors);3023 3024+ 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