|
|
@ -48,47 +48,43 @@ void finish_drm_renderer(struct wlr_drm_renderer *renderer) {
|
|
|
|
wlr_renderer_destroy(renderer->wlr_rend);
|
|
|
|
wlr_renderer_destroy(renderer->wlr_rend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void finish_drm_surface(struct wlr_drm_surface *surf) {
|
|
|
|
|
|
|
|
if (!surf || !surf->renderer) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_swapchain_destroy(surf->swapchain);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(surf, 0, sizeof(*surf));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool init_drm_surface(struct wlr_drm_surface *surf,
|
|
|
|
bool init_drm_surface(struct wlr_drm_surface *surf,
|
|
|
|
struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height,
|
|
|
|
struct wlr_drm_renderer *renderer, int width, int height,
|
|
|
|
const struct wlr_drm_format *drm_format) {
|
|
|
|
const struct wlr_drm_format *drm_format) {
|
|
|
|
if (surf->width == width && surf->height == height) {
|
|
|
|
if (surf->swapchain->width == width && surf->swapchain->height == height) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
surf->renderer = renderer;
|
|
|
|
finish_drm_surface(surf);
|
|
|
|
surf->width = width;
|
|
|
|
|
|
|
|
surf->height = height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_swapchain_destroy(surf->swapchain);
|
|
|
|
|
|
|
|
surf->swapchain = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surf->swapchain = wlr_swapchain_create(renderer->allocator, width, height,
|
|
|
|
surf->swapchain = wlr_swapchain_create(renderer->allocator, width, height,
|
|
|
|
drm_format);
|
|
|
|
drm_format);
|
|
|
|
if (surf->swapchain == NULL) {
|
|
|
|
if (surf->swapchain == NULL) {
|
|
|
|
wlr_log(WLR_ERROR, "Failed to create swapchain");
|
|
|
|
wlr_log(WLR_ERROR, "Failed to create swapchain");
|
|
|
|
memset(surf, 0, sizeof(*surf));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
surf->renderer = renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void finish_drm_surface(struct wlr_drm_surface *surf) {
|
|
|
|
|
|
|
|
if (!surf || !surf->renderer) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_swapchain_destroy(surf->swapchain);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(surf, 0, sizeof(*surf));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
|
|
|
|
struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
|
|
|
|
struct wlr_buffer *buffer) {
|
|
|
|
struct wlr_buffer *buffer) {
|
|
|
|
struct wlr_renderer *renderer = surf->renderer->wlr_rend;
|
|
|
|
struct wlr_renderer *renderer = surf->renderer->wlr_rend;
|
|
|
|
|
|
|
|
|
|
|
|
if (surf->width != (uint32_t)buffer->width ||
|
|
|
|
if (surf->swapchain->width != buffer->width ||
|
|
|
|
surf->height != (uint32_t)buffer->height) {
|
|
|
|
surf->swapchain->height != buffer->height) {
|
|
|
|
wlr_log(WLR_ERROR, "Surface size doesn't match buffer size");
|
|
|
|
wlr_log(WLR_ERROR, "Surface size doesn't match buffer size");
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -106,7 +102,7 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf,
|
|
|
|
|
|
|
|
|
|
|
|
float mat[9];
|
|
|
|
float mat[9];
|
|
|
|
wlr_matrix_identity(mat);
|
|
|
|
wlr_matrix_identity(mat);
|
|
|
|
wlr_matrix_scale(mat, surf->width, surf->height);
|
|
|
|
wlr_matrix_scale(mat, surf->swapchain->width, surf->swapchain->height);
|
|
|
|
|
|
|
|
|
|
|
|
if (!wlr_renderer_begin_with_buffer(renderer, dst)) {
|
|
|
|
if (!wlr_renderer_begin_with_buffer(renderer, dst)) {
|
|
|
|
wlr_buffer_unlock(dst);
|
|
|
|
wlr_buffer_unlock(dst);
|
|
|
|