aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/backend.c2
-rw-r--r--backend/drm/drm.c35
-rw-r--r--backend/drm/renderer.c48
3 files changed, 37 insertions, 48 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 75b44210..43a8d017 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -173,7 +173,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
}
if (!wlr_egl_bind_display(&drm->renderer.egl, display)) {
- wlr_log(L_INFO, "Failed to bind egl/wl display: %s", egl_error());
+ wlr_log(L_INFO, "Failed to bind egl/wl display");
}
drm->display_destroy.notify = handle_display_destroy;
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 0d1d527d..524e80bb 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -15,9 +15,9 @@
#include <wayland-util.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
-#include <wlr/render.h>
#include <wlr/render/gles2.h>
-#include <wlr/render/matrix.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -582,13 +582,10 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
return false;
}
- // OpenGL will read the pixels out upside down,
- // so we need to flip the image vertically
- enum wl_output_transform transform = wlr_output_transform_compose(
- wlr_output_transform_invert(output->transform),
- WL_OUTPUT_TRANSFORM_FLIPPED_180);
- wlr_matrix_texture(plane->matrix, plane->surf.width, plane->surf.height,
- transform);
+ enum wl_output_transform transform =
+ wlr_output_transform_invert(output->transform);
+ wlr_matrix_projection(plane->matrix, plane->surf.width,
+ plane->surf.height, transform);
plane->wlr_tex =
wlr_render_texture_create(plane->surf.renderer->wlr_rend);
@@ -643,20 +640,14 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
wlr_texture_upload_pixels(plane->wlr_tex, WL_SHM_FORMAT_ARGB8888,
stride, width, height, buf);
- glViewport(0, 0, plane->surf.width, plane->surf.height);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ struct wlr_renderer *rend = plane->surf.renderer->wlr_rend;
+ wlr_renderer_begin(rend, plane->surf.width, plane->surf.height);
+ wlr_renderer_clear(rend, (float[]){ 0.0, 0.0, 0.0, 0.0 });
+ wlr_render_texture(rend, plane->wlr_tex, plane->matrix, 0, 0, 1.0f);
+ wlr_renderer_end(rend);
- float matrix[16];
- wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0);
- wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex,
- &matrix, 1.0f);
-
- glFinish();
- glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride);
- glReadPixels(0, 0, plane->surf.width, plane->surf.height, GL_BGRA_EXT,
- GL_UNSIGNED_BYTE, bo_data);
- glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
+ wlr_renderer_read_pixels(rend, WL_SHM_FORMAT_ARGB8888, bo_stride,
+ plane->surf.width, plane->surf.height, 0, 0, 0, 0, bo_data);
wlr_drm_surface_swap_buffers(&plane->surf, NULL);
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 7ee13843..b2998b5f 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -1,15 +1,15 @@
+#include <assert.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <gbm.h>
-#include <GLES2/gl2.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <wayland-util.h>
-#include <wlr/render.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
-#include <wlr/render/matrix.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
#include "backend/drm/drm.h"
#include "glapi.h"
@@ -106,9 +106,6 @@ void wlr_drm_surface_finish(struct wlr_drm_surface *surf) {
return;
}
- eglMakeCurrent(surf->renderer->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
- EGL_NO_CONTEXT);
-
if (surf->front) {
gbm_surface_release_buffer(surf->gbm, surf->front);
}
@@ -150,9 +147,10 @@ struct gbm_bo *wlr_drm_surface_get_front(struct wlr_drm_surface *surf) {
}
wlr_drm_surface_make_current(surf, NULL);
- glViewport(0, 0, surf->width, surf->height);
- glClearColor(0.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ struct wlr_renderer *renderer = surf->renderer->wlr_rend;
+ wlr_renderer_begin(renderer, surf->width, surf->height);
+ wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 });
+ wlr_renderer_end(renderer);
return wlr_drm_surface_swap_buffers(surf, NULL);
}
@@ -177,12 +175,15 @@ static void free_eglimage(struct gbm_bo *bo, void *data) {
free(tex);
}
-static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer, struct gbm_bo *bo) {
+static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer,
+ struct gbm_bo *bo) {
struct tex *tex = gbm_bo_get_user_data(bo);
if (tex) {
return tex->tex;
}
+ // TODO: use wlr_texture_upload_dmabuf instead
+
tex = malloc(sizeof(*tex));
if (!tex) {
wlr_log_errno(L_ERROR, "Allocation failed");
@@ -209,7 +210,7 @@ static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer, str
tex->img = eglCreateImageKHR(renderer->egl.display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT, NULL, attribs);
if (!tex->img) {
- wlr_log(L_ERROR, "Failed to create EGL image: %s", egl_error());
+ wlr_log(L_ERROR, "Failed to create EGL image");
abort();
}
@@ -226,26 +227,23 @@ struct gbm_bo *wlr_drm_surface_mgpu_copy(struct wlr_drm_surface *dest,
wlr_drm_surface_make_current(dest, NULL);
struct wlr_texture *tex = get_tex_for_bo(dest->renderer, src);
+ assert(tex);
- static const float matrix[16] = {
- [0] = 2.0f,
- [3] = -1.0f,
- [5] = 2.0f,
- [7] = -1.0f,
- [10] = 1.0f,
- [15] = 1.0f,
- };
+ float mat[9];
+ wlr_matrix_projection(mat, 1, 1, WL_OUTPUT_TRANSFORM_FLIPPED_180);
- glViewport(0, 0, dest->width, dest->height);
- glClearColor(0.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- wlr_render_with_matrix(dest->renderer->wlr_rend, tex, &matrix, 1.0f);
+ struct wlr_renderer *renderer = dest->renderer->wlr_rend;
+ wlr_renderer_begin(renderer, dest->width, dest->height);
+ wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 });
+ wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);
+ wlr_renderer_end(renderer);
return wlr_drm_surface_swap_buffers(dest, NULL);
}
-bool wlr_drm_plane_surfaces_init(struct wlr_drm_plane *plane, struct wlr_drm_backend *drm,
- int32_t width, uint32_t height, uint32_t format) {
+bool wlr_drm_plane_surfaces_init(struct wlr_drm_plane *plane,
+ struct wlr_drm_backend *drm, int32_t width, uint32_t height,
+ uint32_t format) {
if (!drm->parent) {
return wlr_drm_surface_init(&plane->surf, &drm->renderer, width, height,
format, GBM_BO_USE_SCANOUT);