mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
Merge branch 'swapchain-cursor' into 'master'
wlr_cursor: Don't manage output cursor swapchain in wlr_output See merge request wlroots/wlroots!4360
This commit is contained in:
commit
ad2c368345
5 changed files with 16 additions and 14 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include <time.h>
|
||||
#include <wayland-server-protocol.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/render/swapchain.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include <wlr/util/addon.h>
|
||||
|
|
@ -36,6 +37,7 @@ struct wlr_output_mode {
|
|||
|
||||
struct wlr_output_cursor {
|
||||
struct wlr_output *output;
|
||||
struct wlr_swapchain *swapchain;
|
||||
double x, y;
|
||||
bool enabled;
|
||||
bool visible;
|
||||
|
|
@ -196,7 +198,6 @@ struct wlr_output {
|
|||
|
||||
struct wl_list cursors; // wlr_output_cursor.link
|
||||
struct wlr_output_cursor *hardware_cursor;
|
||||
struct wlr_swapchain *cursor_swapchain;
|
||||
struct wlr_buffer *cursor_front_buffer;
|
||||
int software_cursor_locks; // number of locks forcing software cursors
|
||||
|
||||
|
|
|
|||
|
|
@ -221,27 +221,28 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
|
|||
}
|
||||
}
|
||||
|
||||
if (output->cursor_swapchain == NULL ||
|
||||
output->cursor_swapchain->width != width ||
|
||||
output->cursor_swapchain->height != height) {
|
||||
if (cursor->swapchain == NULL ||
|
||||
cursor->swapchain->allocator != allocator ||
|
||||
cursor->swapchain->width != width ||
|
||||
cursor->swapchain->height != height) {
|
||||
struct wlr_drm_format format = {0};
|
||||
if (!output_pick_cursor_format(output, &format)) {
|
||||
wlr_log(WLR_DEBUG, "Failed to pick cursor format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wlr_swapchain_destroy(output->cursor_swapchain);
|
||||
output->cursor_swapchain = wlr_swapchain_create(allocator,
|
||||
wlr_swapchain_destroy(cursor->swapchain);
|
||||
cursor->swapchain = wlr_swapchain_create(allocator,
|
||||
width, height, &format);
|
||||
wlr_drm_format_finish(&format);
|
||||
if (output->cursor_swapchain == NULL) {
|
||||
if (cursor->swapchain == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to create cursor swapchain");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_buffer *buffer =
|
||||
wlr_swapchain_acquire(output->cursor_swapchain, NULL);
|
||||
wlr_swapchain_acquire(cursor->swapchain, NULL);
|
||||
if (buffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -471,6 +472,7 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) {
|
|||
if (cursor->own_texture) {
|
||||
wlr_texture_destroy(cursor->texture);
|
||||
}
|
||||
wlr_swapchain_destroy(cursor->swapchain);
|
||||
wl_list_remove(&cursor->link);
|
||||
free(cursor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,8 +252,6 @@ static void output_apply_state(struct wlr_output *output,
|
|||
if ((state->committed & WLR_OUTPUT_STATE_ENABLED) && !state->enabled) {
|
||||
wlr_swapchain_destroy(output->swapchain);
|
||||
output->swapchain = NULL;
|
||||
wlr_swapchain_destroy(output->cursor_swapchain);
|
||||
output->cursor_swapchain = NULL;
|
||||
}
|
||||
|
||||
if (state->committed & WLR_OUTPUT_STATE_LAYERS) {
|
||||
|
|
@ -405,7 +403,6 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
wlr_output_layer_destroy(layer);
|
||||
}
|
||||
|
||||
wlr_swapchain_destroy(output->cursor_swapchain);
|
||||
wlr_buffer_unlock(output->cursor_front_buffer);
|
||||
|
||||
wlr_swapchain_destroy(output->swapchain);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@ bool wlr_output_init_render(struct wlr_output *output,
|
|||
wlr_swapchain_destroy(output->swapchain);
|
||||
output->swapchain = NULL;
|
||||
|
||||
wlr_swapchain_destroy(output->cursor_swapchain);
|
||||
output->cursor_swapchain = NULL;
|
||||
|
||||
output->allocator = allocator;
|
||||
output->renderer = renderer;
|
||||
|
||||
|
|
|
|||
|
|
@ -602,6 +602,11 @@ static void output_cursor_output_handle_output_commit(
|
|||
(event->state->committed & WLR_OUTPUT_STATE_BUFFER)) {
|
||||
wlr_surface_send_frame_done(surface, event->when);
|
||||
}
|
||||
|
||||
if (event->committed & WLR_OUTPUT_STATE_ENABLED) {
|
||||
wlr_swapchain_destroy(output_cursor->output_cursor->swapchain);
|
||||
output_cursor->output_cursor->swapchain = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void cursor_update_outputs(struct wlr_cursor *cur) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue