Use wlr_output_configure_primary_swapchain()

This commit is contained in:
Simon Ser 2023-02-22 18:50:32 +01:00
parent 9498e4d261
commit 7c9e11e892
3 changed files with 21 additions and 5 deletions

View file

@ -28,6 +28,7 @@ struct sway_output {
struct timespec last_frame; struct timespec last_frame;
struct wlr_damage_ring damage_ring; struct wlr_damage_ring damage_ring;
struct wlr_swapchain *swapchain;
int lx, ly; // layout coords int lx, ly; // layout coords
int width, height; // transformed buffer size int width, height; // transformed buffer size
@ -112,7 +113,8 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output);
struct sway_workspace *output_get_active_workspace(struct sway_output *output); struct sway_workspace *output_get_active_workspace(struct sway_output *output);
void output_render(struct sway_output *output, pixman_region32_t *damage); void output_render(struct sway_output *output, struct wlr_buffer *buffer,
pixman_region32_t *damage);
void output_surface_for_each_surface(struct sway_output *output, void output_surface_for_each_surface(struct sway_output *output,
struct wlr_surface *surface, double ox, double oy, struct wlr_surface *surface, double ox, double oy,

View file

@ -6,6 +6,7 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/config.h> #include <wlr/config.h>
#include <wlr/backend/headless.h> #include <wlr/backend/headless.h>
#include <wlr/render/swapchain.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
@ -583,8 +584,14 @@ static int output_repaint_timer_handler(void *data) {
return 0; return 0;
} }
if (!wlr_output_configure_primary_swapchain(wlr_output, NULL,
&output->swapchain)) {
return 0;
}
int buffer_age; int buffer_age;
if (!wlr_output_attach_render(output->wlr_output, &buffer_age)) { struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain, &buffer_age);
if (buffer == NULL) {
return 0; return 0;
} }
@ -595,10 +602,13 @@ static int output_repaint_timer_handler(void *data) {
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
output_render(output, &damage); output_render(output, buffer, &damage);
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
wlr_output_attach_buffer(wlr_output, buffer);
wlr_buffer_unlock(buffer);
pixman_region32_t frame_damage; pixman_region32_t frame_damage;
get_frame_damage(output, &frame_damage); get_frame_damage(output, &frame_damage);
wlr_output_set_damage(wlr_output, &frame_damage); wlr_output_set_damage(wlr_output, &frame_damage);
@ -846,6 +856,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&output->needs_frame.link); wl_list_remove(&output->needs_frame.link);
wl_list_remove(&output->request_state.link); wl_list_remove(&output->request_state.link);
wlr_swapchain_destroy(output->swapchain);
output->swapchain = NULL;
wlr_damage_ring_finish(&output->damage_ring); wlr_damage_ring_finish(&output->damage_ring);
output->wlr_output->data = NULL; output->wlr_output->data = NULL;

View file

@ -1029,7 +1029,8 @@ static void render_seatops(struct sway_output *output,
} }
} }
void output_render(struct sway_output *output, pixman_region32_t *damage) { void output_render(struct sway_output *output, struct wlr_buffer *buffer,
pixman_region32_t *damage) {
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
struct wlr_renderer *renderer = output->server->renderer; struct wlr_renderer *renderer = output->server->renderer;
@ -1043,7 +1044,7 @@ void output_render(struct sway_output *output, pixman_region32_t *damage) {
fullscreen_con = workspace->current.fullscreen; fullscreen_con = workspace->current.fullscreen;
} }
if (!wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height)) { if (!wlr_renderer_begin_with_buffer(renderer, buffer)) {
return; return;
} }