diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 22cd81fc..76784a4f 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -926,7 +926,8 @@ struct weston_renderer { uint32_t width, uint32_t height); void (*repaint_output)(struct weston_output *output, pixman_region32_t *output_damage); - void (*flush_damage)(struct weston_surface *surface); + void (*flush_damage)(struct weston_surface *surface, + struct weston_buffer *buffer); void (*attach)(struct weston_surface *es, struct weston_buffer *buffer); void (*surface_set_color)(struct weston_surface *surface, float red, float green, diff --git a/libweston/compositor.c b/libweston/compositor.c index cabd0d45..27d46c02 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2553,9 +2553,10 @@ weston_output_damage(struct weston_output *output) static void surface_flush_damage(struct weston_surface *surface) { - if (surface->buffer_ref.buffer && - wl_shm_buffer_get(surface->buffer_ref.buffer->resource)) - surface->compositor->renderer->flush_damage(surface); + struct weston_buffer *buffer = surface->buffer_ref.buffer; + + if (buffer && wl_shm_buffer_get(buffer->resource)) + surface->compositor->renderer->flush_damage(surface, buffer); if (pixman_region32_not_empty(&surface->damage)) TL_POINT(surface->compositor, "core_flush_damage", TLP_SURFACE(surface), diff --git a/libweston/noop-renderer.c b/libweston/noop-renderer.c index d86e7f0b..0c9964f3 100644 --- a/libweston/noop-renderer.c +++ b/libweston/noop-renderer.c @@ -47,7 +47,8 @@ noop_renderer_repaint_output(struct weston_output *output, } static void -noop_renderer_flush_damage(struct weston_surface *surface) +noop_renderer_flush_damage(struct weston_surface *surface, + struct weston_buffer *buffer) { } diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 754adce2..271bc198 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -598,7 +598,8 @@ pixman_renderer_repaint_output(struct weston_output *output, } static void -pixman_renderer_flush_damage(struct weston_surface *surface) +pixman_renderer_flush_damage(struct weston_surface *surface, + struct weston_buffer *buffer) { /* No-op for pixman renderer */ } diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 321e67a8..800de5ec 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1832,12 +1832,12 @@ gl_format_from_internal(GLenum internal_format) } static void -gl_renderer_flush_damage(struct weston_surface *surface) +gl_renderer_flush_damage(struct weston_surface *surface, + struct weston_buffer *buffer) { const struct weston_testsuite_quirks *quirks = &surface->compositor->test_data.test_quirks; struct gl_surface_state *gs = get_surface_state(surface); - struct weston_buffer *buffer = gs->buffer_ref.buffer; struct weston_view *view; bool texture_used; pixman_box32_t *rectangles; @@ -3081,7 +3081,7 @@ gl_renderer_surface_copy_content(struct weston_surface *surface, *(uint32_t *)target = pack_color(format, gs->color); return 0; case BUFFER_TYPE_SHM: - gl_renderer_flush_damage(surface); + gl_renderer_flush_damage(surface, gs->buffer_ref.buffer); /* fall through */ case BUFFER_TYPE_EGL: break; @@ -3228,7 +3228,11 @@ gl_renderer_create_surface(struct weston_surface *surface) if (surface->buffer_ref.buffer) { gl_renderer_attach(surface, surface->buffer_ref.buffer); - gl_renderer_flush_damage(surface); + if (surface->buffer_ref.buffer->resource && + wl_shm_buffer_get(surface->buffer_ref.buffer->resource)) { + gl_renderer_flush_damage(surface, + surface->buffer_ref.buffer); + } } return 0;