aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-07-07 23:02:48 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-07-08 14:44:42 -0400
commitc1b27cc499d06c0aa3d02228dd6e2905e08e2436 (patch)
tree4e6e9cb08ee1a4fa2858205fd0f34291cb8789a4
parentd71ed635b90a12c1f1d096817aec9d00b2ad6a3d (diff)
backend/drm: stop using drm_surface_make_current in drm_surface_blit
drm_surface_make_current and drm_surface_unset_current set implicit state and are an unnecessary mid-layer. Prefer to use directly wlr_renderer_begin_with_buffer, which automatically unsets the back buffer on wlr_renderer_end. I'd like to get rid of drm_surface_make_current once we stop using it for the primary swapchain.
-rw-r--r--backend/drm/renderer.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index d6da8606..60dd9c77 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -141,7 +141,8 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
return NULL;
}
- if (!drm_surface_make_current(surf, NULL)) {
+ struct wlr_buffer *dst = wlr_swapchain_acquire(surf->swapchain, NULL);
+ if (!dst) {
wlr_texture_destroy(tex);
return NULL;
}
@@ -150,19 +151,20 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
wlr_matrix_identity(mat);
wlr_matrix_scale(mat, surf->width, surf->height);
- wlr_renderer_begin(renderer, surf->width, surf->height);
+ if (!wlr_renderer_begin_with_buffer(renderer, dst)) {
+ wlr_buffer_unlock(dst);
+ wlr_texture_destroy(tex);
+ return NULL;
+ }
+
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 0.0 });
wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);
- wlr_renderer_end(renderer);
- assert(surf->back_buffer != NULL);
- struct wlr_buffer *out = wlr_buffer_lock(surf->back_buffer);
-
- drm_surface_unset_current(surf);
+ wlr_renderer_end(renderer);
wlr_texture_destroy(tex);
- return out;
+ return dst;
}