mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
backend/wayland: remove swapchain
Rely on wlr_output's generic swapchain handling.
This commit is contained in:
parent
5f8092b045
commit
543f5b35d0
3 changed files with 5 additions and 116 deletions
|
|
@ -15,7 +15,6 @@
|
|||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "backend/backend.h"
|
||||
#include "backend/wayland.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/swapchain.h"
|
||||
|
|
@ -100,40 +99,7 @@ static const struct wp_presentation_feedback_listener
|
|||
|
||||
static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||
int32_t width, int32_t height, int32_t refresh) {
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
struct wlr_allocator *allocator = backend_get_allocator(wlr_output->backend);
|
||||
|
||||
if (wlr_output->width != width || wlr_output->height != height) {
|
||||
struct wlr_swapchain *swapchain = wlr_swapchain_create(allocator,
|
||||
width, height, output->backend->format);
|
||||
if (swapchain == NULL) {
|
||||
return false;
|
||||
}
|
||||
wlr_swapchain_destroy(output->swapchain);
|
||||
output->swapchain = swapchain;
|
||||
}
|
||||
|
||||
wlr_output_update_custom_mode(&output->wlr_output, width, height, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||
int *buffer_age) {
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
wlr_buffer_unlock(output->back_buffer);
|
||||
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
||||
if (!output->back_buffer) {
|
||||
wlr_log(WLR_ERROR, "Failed to acquire swapchain buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wlr_renderer_bind_buffer(renderer, output->back_buffer)) {
|
||||
wlr_log(WLR_ERROR, "Failed to bind buffer to renderer");
|
||||
return false;
|
||||
}
|
||||
|
||||
wlr_output_update_custom_mode(wlr_output, width, height, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +265,6 @@ static bool output_test(struct wlr_output *wlr_output) {
|
|||
static bool output_commit(struct wlr_output *wlr_output) {
|
||||
struct wlr_wl_output *output =
|
||||
get_wl_output_from_output(wlr_output);
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
if (!output_test(wlr_output)) {
|
||||
return false;
|
||||
|
|
@ -315,6 +280,9 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
|||
}
|
||||
|
||||
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||
assert(wlr_output->pending.buffer_type ==
|
||||
WLR_OUTPUT_STATE_BUFFER_SCANOUT);
|
||||
|
||||
struct wp_presentation_feedback *wp_feedback = NULL;
|
||||
if (output->backend->presentation != NULL) {
|
||||
wp_feedback = wp_presentation_feedback(output->backend->presentation,
|
||||
|
|
@ -334,19 +302,7 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
|||
output->frame_callback = wl_surface_frame(output->surface);
|
||||
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
||||
|
||||
struct wlr_buffer *wlr_buffer = NULL;
|
||||
switch (wlr_output->pending.buffer_type) {
|
||||
case WLR_OUTPUT_STATE_BUFFER_RENDER:
|
||||
assert(output->back_buffer != NULL);
|
||||
wlr_buffer = output->back_buffer;
|
||||
|
||||
wlr_renderer_bind_buffer(renderer, NULL);
|
||||
break;
|
||||
case WLR_OUTPUT_STATE_BUFFER_SCANOUT:;
|
||||
wlr_buffer = wlr_output->pending.buffer;
|
||||
break;
|
||||
}
|
||||
|
||||
struct wlr_buffer *wlr_buffer = wlr_output->pending.buffer;
|
||||
struct wlr_wl_buffer *buffer =
|
||||
get_or_create_wl_buffer(output->backend, wlr_buffer);
|
||||
if (buffer == NULL) {
|
||||
|
|
@ -371,11 +327,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
|||
|
||||
wl_surface_commit(output->surface);
|
||||
|
||||
wlr_buffer_unlock(output->back_buffer);
|
||||
output->back_buffer = NULL;
|
||||
|
||||
wlr_swapchain_set_buffer_submitted(output->swapchain, wlr_buffer);
|
||||
|
||||
if (wp_feedback != NULL) {
|
||||
struct wlr_wl_presentation_feedback *feedback =
|
||||
calloc(1, sizeof(*feedback));
|
||||
|
|
@ -400,11 +351,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void output_rollback_render(struct wlr_output *wlr_output) {
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
wlr_renderer_bind_buffer(renderer, NULL);
|
||||
}
|
||||
|
||||
static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||
struct wlr_buffer *wlr_buffer, int hotspot_x, int hotspot_y) {
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
|
|
@ -472,8 +418,6 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
|||
presentation_feedback_destroy(feedback);
|
||||
}
|
||||
|
||||
wlr_buffer_unlock(output->back_buffer);
|
||||
wlr_swapchain_destroy(output->swapchain);
|
||||
if (output->zxdg_toplevel_decoration_v1) {
|
||||
zxdg_toplevel_decoration_v1_destroy(output->zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
|
@ -502,10 +446,8 @@ static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
|
|||
|
||||
static const struct wlr_output_impl output_impl = {
|
||||
.destroy = output_destroy,
|
||||
.attach_render = output_attach_render,
|
||||
.test = output_test,
|
||||
.commit = output_commit,
|
||||
.rollback_render = output_rollback_render,
|
||||
.set_cursor = output_set_cursor,
|
||||
.move_cursor = output_move_cursor,
|
||||
.get_cursor_formats = output_get_formats,
|
||||
|
|
@ -626,13 +568,6 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
|||
&xdg_toplevel_listener, output);
|
||||
wl_surface_commit(output->surface);
|
||||
|
||||
struct wlr_allocator *allocator = backend_get_allocator(&backend->backend);
|
||||
output->swapchain = wlr_swapchain_create(allocator,
|
||||
wlr_output->width, wlr_output->height, output->backend->format);
|
||||
if (output->swapchain == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
wl_display_roundtrip(output->backend->remote_display);
|
||||
|
||||
wl_list_insert(&backend->outputs, &output->link);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue