mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-25 06:59:42 -05:00
surface: remove wlr_surface.texture
The texture is managed by the surface's wlr_buffer now. In particular, the buffer can destroy the texture early if it becomes invalid.
This commit is contained in:
parent
d643361c48
commit
0378d143d9
5 changed files with 38 additions and 15 deletions
|
|
@ -367,7 +367,8 @@ static void output_fullscreen_surface_render(struct wlr_output *output,
|
|||
struct wlr_renderer *renderer = wlr_backend_get_renderer(output->backend);
|
||||
assert(renderer);
|
||||
|
||||
if (!wlr_surface_has_buffer(surface)) {
|
||||
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||
if (texture == NULL) {
|
||||
wlr_renderer_clear(renderer, (float[]){0, 0, 0, 1});
|
||||
return;
|
||||
}
|
||||
|
|
@ -386,8 +387,7 @@ static void output_fullscreen_surface_render(struct wlr_output *output,
|
|||
for (int i = 0; i < nrects; ++i) {
|
||||
output_scissor(output, &rects[i]);
|
||||
wlr_renderer_clear(renderer, (float[]){0, 0, 0, 1});
|
||||
wlr_render_texture_with_matrix(surface->renderer, surface->texture,
|
||||
matrix, 1.0f);
|
||||
wlr_render_texture_with_matrix(surface->renderer, texture, matrix, 1.0f);
|
||||
}
|
||||
wlr_renderer_scissor(renderer, NULL);
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ static void output_cursor_render(struct wlr_output_cursor *cursor,
|
|||
|
||||
struct wlr_texture *texture = cursor->texture;
|
||||
if (cursor->surface != NULL) {
|
||||
texture = cursor->surface->texture;
|
||||
texture = wlr_surface_get_texture(cursor->surface);
|
||||
}
|
||||
if (texture == NULL) {
|
||||
return;
|
||||
|
|
@ -700,7 +700,7 @@ static bool output_cursor_attempt_hardware(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 = cursor->surface->texture;
|
||||
texture = wlr_surface_get_texture(cursor->surface);
|
||||
scale = cursor->surface->current->scale;
|
||||
transform = cursor->surface->current->transform;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,6 @@ static void surface_apply_damage(struct wlr_surface *surface,
|
|||
// NULL commit
|
||||
wlr_buffer_unref(surface->buffer);
|
||||
surface->buffer = NULL;
|
||||
surface->texture = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -362,7 +361,6 @@ static void surface_apply_damage(struct wlr_surface *surface,
|
|||
|
||||
wlr_buffer_unref(surface->buffer);
|
||||
surface->buffer = NULL;
|
||||
surface->texture = NULL;
|
||||
|
||||
struct wlr_buffer *buffer = wlr_buffer_create(surface->renderer, resource);
|
||||
if (buffer == NULL) {
|
||||
|
|
@ -371,7 +369,6 @@ static void surface_apply_damage(struct wlr_surface *surface,
|
|||
}
|
||||
|
||||
surface->buffer = buffer;
|
||||
surface->texture = buffer->texture;
|
||||
}
|
||||
|
||||
static void surface_commit_pending(struct wlr_surface *surface) {
|
||||
|
|
@ -660,8 +657,15 @@ struct wlr_surface *wlr_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 surface->texture != NULL;
|
||||
return wlr_surface_get_texture(surface) != NULL;
|
||||
}
|
||||
|
||||
int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue