compositor/renderer: Only attach buffer to renderer in repaint

Instead of doing this in several places, just do it when we're updating
the paint nodes in the repaint loop, or when we're about to copy
content via weston_surface_copy_content().

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2024-06-05 14:50:27 -05:00 committed by Marius Vlad
parent da6622f1d6
commit c08a6ff8bd
3 changed files with 15 additions and 12 deletions

View File

@ -221,9 +221,11 @@ paint_node_update_early(struct weston_paint_node *pnode)
static void
paint_node_update_late(struct weston_paint_node *pnode)
{
struct weston_surface *surf = pnode->surface;
bool vis_dirty = pnode->status & PAINT_NODE_VISIBILITY_DIRTY;
bool plane_dirty = pnode->status & PAINT_NODE_PLANE_DIRTY;
bool content_dirty = pnode->status & PAINT_NODE_CONTENT_DIRTY;
bool buffer_dirty = pnode->status & PAINT_NODE_BUFFER_DIRTY;
/* The geoemtry may be shrinking, so we shouldn't just
* add the old visible region to our damage region, because
@ -264,6 +266,10 @@ paint_node_update_late(struct weston_paint_node *pnode)
pnode->plane_next = NULL;
}
if (buffer_dirty)
surf->compositor->renderer->attach(surf,
surf->buffer_ref.buffer);
pnode->status &= ~(PAINT_NODE_VISIBILITY_DIRTY |
PAINT_NODE_PLANE_DIRTY |
PAINT_NODE_CONTENT_DIRTY |
@ -2981,7 +2987,6 @@ weston_surface_attach_solid(struct weston_surface *surface,
assert(buffer->type == WESTON_BUFFER_SOLID);
weston_buffer_reference(&surface->buffer_ref, buffer,
BUFFER_MAY_BE_ACCESSED);
surface->compositor->renderer->attach(surface, buffer);
weston_surface_set_size(surface, w, h);
@ -3117,7 +3122,6 @@ weston_surface_attach(struct weston_surface *surface,
weston_buffer_reference(&surface->buffer_ref, NULL,
BUFFER_WILL_NOT_BE_ACCESSED);
surface->compositor->renderer->attach(surface, buffer);
surface->width_from_buffer = 0;
surface->height_from_buffer = 0;
@ -3162,7 +3166,6 @@ weston_surface_attach(struct weston_surface *surface,
old_buffer = NULL;
weston_buffer_reference(&surface->buffer_ref, buffer,
BUFFER_MAY_BE_ACCESSED);
surface->compositor->renderer->attach(surface, buffer);
return status;
}

View File

@ -897,6 +897,8 @@ pixman_renderer_surface_copy_content(struct weston_surface *surface,
if (!ps->image)
return -1;
pixman_renderer_attach(surface, surface->buffer_ref.buffer);
out_buf = pixman_image_create_bits(format, width, height,
target, width * bytespp);

View File

@ -3487,8 +3487,6 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
{
struct gl_surface_state *gs = get_surface_state(es);
/* If get_surface_state called gl_renderer_create_surface, it did
* attach the buffer */
if (gs->buffer_ref.buffer == buffer)
return;
@ -3593,15 +3591,19 @@ gl_renderer_surface_copy_content(struct weston_surface *surface,
const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
const GLenum gl_format = GL_RGBA; /* PIXMAN_a8b8g8r8 little-endian */
struct gl_renderer *gr = get_renderer(surface->compositor);
struct gl_surface_state *gs = get_surface_state(surface);
struct gl_buffer_state *gb = gs->buffer;
struct weston_buffer *buffer = gs->buffer_ref.buffer;
struct gl_surface_state *gs;
struct gl_buffer_state *gb;
struct weston_buffer *buffer;
int cw, ch;
GLuint fbo;
GLuint tex;
GLenum status;
int ret = -1;
gl_renderer_attach(surface, surface->buffer_ref.buffer);
gs = get_surface_state(surface);
gb = gs->buffer;
buffer = gs->buffer_ref.buffer;
assert(buffer);
cw = buffer->width;
@ -3750,10 +3752,6 @@ gl_renderer_create_surface(struct weston_surface *surface)
wl_signal_add(&gr->destroy_signal,
&gs->renderer_destroy_listener);
if (surface->buffer_ref.buffer) {
gl_renderer_attach(surface, surface->buffer_ref.buffer);
}
return 0;
}