mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -04:00
Nuke wlr_client_buffer
This abstraction is incompatible with wlr_raster in every way, let's just use the client submitted buffers directly. This will regress a couple of things until wlr_raster has been fully integrated.
This commit is contained in:
parent
d8def1aa65
commit
ba8230b00a
9 changed files with 21 additions and 203 deletions
|
|
@ -94,9 +94,6 @@ static void output_cursor_render(struct wlr_output_cursor *cursor,
|
|||
assert(renderer);
|
||||
|
||||
struct wlr_texture *texture = cursor->texture;
|
||||
if (cursor->surface != NULL) {
|
||||
texture = wlr_surface_get_texture(cursor->surface);
|
||||
}
|
||||
if (texture == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -236,7 +233,6 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
|
|||
enum wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
struct wlr_texture *texture = cursor->texture;
|
||||
if (cursor->surface != NULL) {
|
||||
texture = wlr_surface_get_texture(cursor->surface);
|
||||
scale = cursor->surface->current.scale;
|
||||
transform = cursor->surface->current.transform;
|
||||
}
|
||||
|
|
@ -337,11 +333,8 @@ static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: try using the surface buffer directly
|
||||
struct wlr_texture *texture = cursor->texture;
|
||||
if (cursor->surface != NULL) {
|
||||
// TODO: try using the surface buffer directly
|
||||
texture = wlr_surface_get_texture(cursor->surface);
|
||||
}
|
||||
|
||||
// If the cursor was hidden or was a software cursor, the hardware
|
||||
// cursor position is outdated
|
||||
|
|
@ -445,6 +438,17 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor,
|
|||
struct wlr_surface *surface = cursor->surface;
|
||||
assert(surface != NULL);
|
||||
|
||||
wlr_texture_destroy(cursor->texture);
|
||||
cursor->texture = NULL;
|
||||
|
||||
if (surface->current.buffer) {
|
||||
cursor->texture = wlr_texture_from_buffer(cursor->output->renderer,
|
||||
surface->current.buffer);
|
||||
if (cursor->texture == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Some clients commit a cursor surface with a NULL buffer to hide it.
|
||||
cursor->enabled = wlr_surface_has_buffer(surface);
|
||||
cursor->width = surface->current.width * cursor->output->scale;
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ static void set_buffer_with_surface_state(struct wlr_scene_buffer *scene_buffer,
|
|||
wlr_scene_buffer_set_dest_size(scene_buffer, state->width, state->height);
|
||||
wlr_scene_buffer_set_transform(scene_buffer, state->transform);
|
||||
|
||||
if (surface->buffer) {
|
||||
if (surface->current.buffer) {
|
||||
wlr_scene_buffer_set_buffer_with_damage(scene_buffer,
|
||||
&surface->buffer->base, &surface->buffer_damage);
|
||||
surface->current.buffer, &surface->buffer_damage);
|
||||
} else {
|
||||
wlr_scene_buffer_set_buffer(scene_buffer, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -477,12 +477,6 @@ void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer,
|
|||
|
||||
static struct wlr_texture *scene_buffer_get_texture(
|
||||
struct wlr_scene_buffer *scene_buffer, struct wlr_renderer *renderer) {
|
||||
struct wlr_client_buffer *client_buffer =
|
||||
wlr_client_buffer_get(scene_buffer->buffer);
|
||||
if (client_buffer != NULL) {
|
||||
return client_buffer->texture;
|
||||
}
|
||||
|
||||
if (scene_buffer->texture != NULL) {
|
||||
return scene_buffer->texture;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,54 +109,6 @@ bool wlr_resource_is_buffer(struct wl_resource *resource) {
|
|||
return strcmp(wl_resource_get_class(resource), wl_buffer_interface.name) == 0;
|
||||
}
|
||||
|
||||
static const struct wlr_buffer_impl client_buffer_impl;
|
||||
|
||||
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer) {
|
||||
if (buffer->impl != &client_buffer_impl) {
|
||||
return NULL;
|
||||
}
|
||||
return (struct wlr_client_buffer *)buffer;
|
||||
}
|
||||
|
||||
static struct wlr_client_buffer *client_buffer_from_buffer(
|
||||
struct wlr_buffer *buffer) {
|
||||
struct wlr_client_buffer *client_buffer = wlr_client_buffer_get(buffer);
|
||||
assert(client_buffer != NULL);
|
||||
return client_buffer;
|
||||
}
|
||||
|
||||
static void client_buffer_destroy(struct wlr_buffer *buffer) {
|
||||
struct wlr_client_buffer *client_buffer = client_buffer_from_buffer(buffer);
|
||||
wl_list_remove(&client_buffer->source_destroy.link);
|
||||
wlr_texture_destroy(client_buffer->texture);
|
||||
free(client_buffer);
|
||||
}
|
||||
|
||||
static bool client_buffer_get_dmabuf(struct wlr_buffer *buffer,
|
||||
struct wlr_dmabuf_attributes *attribs) {
|
||||
struct wlr_client_buffer *client_buffer = client_buffer_from_buffer(buffer);
|
||||
|
||||
if (client_buffer->source == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return wlr_buffer_get_dmabuf(client_buffer->source, attribs);
|
||||
}
|
||||
|
||||
static const struct wlr_buffer_impl client_buffer_impl = {
|
||||
.destroy = client_buffer_destroy,
|
||||
.get_dmabuf = client_buffer_get_dmabuf,
|
||||
};
|
||||
|
||||
static void client_buffer_handle_source_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_client_buffer *client_buffer =
|
||||
wl_container_of(listener, client_buffer, source_destroy);
|
||||
wl_list_remove(&client_buffer->source_destroy.link);
|
||||
wl_list_init(&client_buffer->source_destroy.link);
|
||||
client_buffer->source = NULL;
|
||||
}
|
||||
|
||||
static struct wlr_shm_client_buffer *shm_client_buffer_get_or_create(
|
||||
struct wl_resource *resource);
|
||||
static bool buffer_is_shm_client_buffer(struct wlr_buffer *buffer);
|
||||
|
|
@ -263,45 +215,6 @@ bool buffer_is_opaque(struct wlr_buffer *buffer) {
|
|||
return !format_info->has_alpha;
|
||||
}
|
||||
|
||||
struct wlr_client_buffer *wlr_client_buffer_create(struct wlr_buffer *buffer,
|
||||
struct wlr_renderer *renderer) {
|
||||
struct wlr_texture *texture = wlr_texture_from_buffer(renderer, buffer);
|
||||
if (texture == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to create texture");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_client_buffer *client_buffer =
|
||||
calloc(1, sizeof(struct wlr_client_buffer));
|
||||
if (client_buffer == NULL) {
|
||||
wlr_texture_destroy(texture);
|
||||
return NULL;
|
||||
}
|
||||
wlr_buffer_init(&client_buffer->base, &client_buffer_impl,
|
||||
texture->width, texture->height);
|
||||
client_buffer->source = buffer;
|
||||
client_buffer->texture = texture;
|
||||
|
||||
wl_signal_add(&buffer->events.destroy, &client_buffer->source_destroy);
|
||||
client_buffer->source_destroy.notify = client_buffer_handle_source_destroy;
|
||||
|
||||
// Ensure the buffer will be released before being destroyed
|
||||
wlr_buffer_lock(&client_buffer->base);
|
||||
wlr_buffer_drop(&client_buffer->base);
|
||||
|
||||
return client_buffer;
|
||||
}
|
||||
|
||||
bool wlr_client_buffer_apply_damage(struct wlr_client_buffer *client_buffer,
|
||||
struct wlr_buffer *next, pixman_region32_t *damage) {
|
||||
if (client_buffer->base.n_locks > 1) {
|
||||
// Someone else still has a reference to the buffer
|
||||
return false;
|
||||
}
|
||||
|
||||
return wlr_texture_update_from_buffer(client_buffer->texture, next, damage);
|
||||
}
|
||||
|
||||
static const struct wlr_buffer_impl shm_client_buffer_impl;
|
||||
|
||||
static bool buffer_is_shm_client_buffer(struct wlr_buffer *buffer) {
|
||||
|
|
|
|||
|
|
@ -333,45 +333,15 @@ static void surface_state_move(struct wlr_surface_state *state,
|
|||
static void surface_apply_damage(struct wlr_surface *surface) {
|
||||
if (surface->current.buffer == NULL) {
|
||||
// NULL commit
|
||||
if (surface->buffer != NULL) {
|
||||
wlr_buffer_unlock(&surface->buffer->base);
|
||||
}
|
||||
surface->buffer = NULL;
|
||||
surface->opaque = false;
|
||||
return;
|
||||
}
|
||||
|
||||
surface->opaque = buffer_is_opaque(surface->current.buffer);
|
||||
|
||||
if (surface->buffer != NULL) {
|
||||
if (wlr_client_buffer_apply_damage(surface->buffer,
|
||||
surface->current.buffer, &surface->buffer_damage)) {
|
||||
wlr_buffer_unlock(surface->current.buffer);
|
||||
surface->current.buffer = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_client_buffer *buffer = wlr_client_buffer_create(
|
||||
surface->current.buffer, surface->renderer);
|
||||
|
||||
wlr_buffer_unlock(surface->current.buffer);
|
||||
surface->current.buffer = NULL;
|
||||
|
||||
if (buffer == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to upload buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (surface->buffer != NULL) {
|
||||
wlr_buffer_unlock(&surface->buffer->base);
|
||||
}
|
||||
surface->buffer = buffer;
|
||||
}
|
||||
|
||||
static void surface_update_opaque_region(struct wlr_surface *surface) {
|
||||
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||
if (texture == NULL) {
|
||||
if (!wlr_surface_has_buffer(surface)) {
|
||||
pixman_region32_clear(&surface->opaque_region);
|
||||
return;
|
||||
}
|
||||
|
|
@ -660,9 +630,6 @@ static void surface_handle_resource_destroy(struct wl_resource *resource) {
|
|||
pixman_region32_fini(&surface->external_damage);
|
||||
pixman_region32_fini(&surface->opaque_region);
|
||||
pixman_region32_fini(&surface->input_region);
|
||||
if (surface->buffer != NULL) {
|
||||
wlr_buffer_unlock(&surface->buffer->base);
|
||||
}
|
||||
free(surface);
|
||||
}
|
||||
|
||||
|
|
@ -716,15 +683,8 @@ static struct wlr_surface *surface_create(struct wl_client *client,
|
|||
return surface;
|
||||
}
|
||||
|
||||
struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface) {
|
||||
if (surface->buffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return surface->buffer->texture;
|
||||
}
|
||||
|
||||
bool wlr_surface_has_buffer(struct wlr_surface *surface) {
|
||||
return wlr_surface_get_texture(surface) != NULL;
|
||||
return surface->current.buffer != NULL;
|
||||
}
|
||||
|
||||
bool wlr_surface_set_role(struct wlr_surface *surface,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue