aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-10-21 18:08:58 -0400
committerGitHub <noreply@github.com>2017-10-21 18:08:58 -0400
commit24ae081001a5a244a76d87e05af832940d78545f (patch)
tree46e919d43f03aadc0262f17bf9a4028b76c676ae
parentce2f945441155fa9d98935dabd6979304f2d2fbc (diff)
parent37b8a096a9907ea9c9991750c75d9fb15e445681 (diff)
Merge pull request #308 from ascent12/render-fixups
Render fixups
-rw-r--r--backend/drm/backend.c2
-rw-r--r--backend/drm/drm.c34
-rw-r--r--backend/drm/renderer.c2
-rw-r--r--backend/wayland/backend.c2
-rw-r--r--backend/wayland/output.c2
-rw-r--r--backend/x11/backend.c4
-rw-r--r--include/backend/drm/drm.h4
-rw-r--r--include/backend/wayland.h2
-rw-r--r--include/backend/x11.h2
-rw-r--r--include/render/gles2.h2
-rw-r--r--include/wlr/backend.h2
-rw-r--r--include/wlr/backend/interface.h2
-rw-r--r--include/wlr/interfaces/wlr_output.h6
-rw-r--r--include/wlr/render/egl.h (renamed from include/wlr/egl.h)0
-rw-r--r--include/wlr/types/wlr_output.h4
-rw-r--r--render/egl.c2
-rw-r--r--render/gles2/renderer.c9
-rw-r--r--render/gles2/texture.c2
-rw-r--r--types/wlr_output.c6
-rw-r--r--types/wlr_surface.c2
20 files changed, 42 insertions, 49 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index d7e2e616..ab66adf5 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -11,7 +11,7 @@
#include <wlr/interfaces/wlr_output.h>
#include <wlr/util/list.h>
#include <wlr/util/log.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include "backend/drm/drm.h"
static bool wlr_drm_backend_start(struct wlr_backend *backend) {
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index ff4dc7f6..04d7ea77 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -177,9 +177,6 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) {
if (plane->wlr_tex) {
wlr_texture_destroy(plane->wlr_tex);
}
- if (plane->wlr_rend) {
- wlr_renderer_destroy(plane->wlr_rend);
- }
}
free(drm->crtcs);
@@ -193,7 +190,7 @@ static void wlr_drm_connector_make_current(struct wlr_output *output) {
static void wlr_drm_connector_swap_buffers(struct wlr_output *output) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
struct wlr_drm_crtc *crtc = conn->crtc;
struct wlr_drm_plane *plane = crtc->primary;
@@ -216,7 +213,8 @@ static void wlr_drm_connector_swap_buffers(struct wlr_output *output) {
static void wlr_drm_connector_set_gamma(struct wlr_output *output,
uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
- drmModeCrtcSetGamma(conn->drm->fd, conn->crtc->id, size, r, g, b);
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
+ drmModeCrtcSetGamma(drm->fd, conn->crtc->id, size, r, g, b);
}
static uint16_t wlr_drm_connector_get_gamma_size(struct wlr_output *output) {
@@ -230,7 +228,7 @@ void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn) {
return;
}
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend;
struct wlr_drm_crtc *crtc = conn->crtc;
struct wlr_drm_plane *plane = crtc->primary;
@@ -253,7 +251,7 @@ static void wlr_drm_connector_enable(struct wlr_output *output, bool enable) {
return;
}
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
drm->iface->conn_enable(drm, conn, enable);
if (enable) {
@@ -406,7 +404,7 @@ error_conn:
static bool wlr_drm_connector_set_mode(struct wlr_output *output,
struct wlr_output_mode *mode) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
wlr_log(L_INFO, "Modesetting '%s' with '%ux%u@%u mHz'", conn->output.name,
mode->width, mode->height, mode->refresh);
@@ -472,7 +470,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y, bool update_pixels) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
struct wlr_drm_renderer *renderer = &drm->renderer;
struct wlr_drm_crtc *crtc = conn->crtc;
@@ -525,12 +523,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
// TODO the image needs to be rotated depending on the output rotation
- plane->wlr_rend = wlr_gles2_renderer_create(&drm->backend);
- if (!plane->wlr_rend) {
- return false;
- }
-
- plane->wlr_tex = wlr_render_texture_create(plane->wlr_rend);
+ plane->wlr_tex = wlr_render_texture_create(plane->surf.renderer->wlr_rend);
if (!plane->wlr_tex) {
return false;
}
@@ -595,7 +588,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
float matrix[16];
wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0);
- wlr_render_with_matrix(plane->wlr_rend, plane->wlr_tex, &matrix);
+ wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex, &matrix);
glFinish();
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride);
@@ -612,7 +605,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
int x, int y) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
int width, height, tmp;
wlr_output_effective_resolution(output, &width, &height);
@@ -715,14 +708,13 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
drmModeFreeConnector(drm_conn);
continue;
}
- wlr_output_init(&wlr_conn->output, &output_impl);
+ wlr_output_init(&wlr_conn->output, &drm->backend, &output_impl);
struct wl_event_loop *ev = wl_display_get_event_loop(drm->display);
wlr_conn->retry_pageflip = wl_event_loop_add_timer(ev, retry_pageflip,
wlr_conn);
- wlr_conn->drm = drm;
wlr_conn->state = WLR_DRM_CONN_DISCONNECTED;
wlr_conn->id = drm_conn->connector_id;
@@ -828,7 +820,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
static void page_flip_handler(int fd, unsigned seq,
unsigned tv_sec, unsigned tv_usec, void *user) {
struct wlr_drm_connector *conn = user;
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend;
conn->pageflip_pending = false;
if (conn->state != WLR_DRM_CONN_CONNECTED) {
@@ -899,7 +891,7 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
return;
}
- struct wlr_drm_backend *drm = conn->drm;
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend;
switch (conn->state) {
case WLR_DRM_CONN_CONNECTED:
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 0d338490..d53acaa8 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -8,8 +8,8 @@
#include <EGL/eglext.h>
#include <wayland-util.h>
-#include <wlr/egl.h>
#include <wlr/util/log.h>
+#include <wlr/render/egl.h>
#include <wlr/render/matrix.h>
#include <wlr/render/gles2.h>
#include <wlr/render.h>
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index e57f3583..5018eeb0 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -4,7 +4,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <wayland-server.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index e1138ee1..0216823e 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -241,7 +241,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
wlr_log(L_ERROR, "Failed to allocate wlr_wl_backend_output");
return NULL;
}
- wlr_output_init(&output->wlr_output, &output_impl);
+ wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
struct wlr_output *wlr_output = &output->wlr_output;
wlr_output->width = 640;
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 11dd8568..d30ec376 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -15,7 +15,7 @@
#endif
#include <wlr/backend/interface.h>
#include <wlr/backend/x11.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
@@ -264,7 +264,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
output->x11 = x11;
- wlr_output_init(&output->wlr_output, &output_impl);
+ wlr_output_init(&output->wlr_output, &x11->backend, &output_impl);
snprintf(output->wlr_output.name, sizeof(output->wlr_output.name), "X11-1");
output->win = xcb_generate_id(x11->xcb_conn);
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 6106a85a..b0f5838e 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -12,7 +12,7 @@
#include <wlr/backend/session.h>
#include <wlr/backend/drm.h>
#include <wlr/types/wlr_output.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include <wlr/util/list.h>
#include "iface.h"
@@ -30,7 +30,6 @@ struct wlr_drm_plane {
// Only used by cursor
float matrix[16];
- struct wlr_renderer *wlr_rend;
struct wlr_texture *wlr_tex;
struct gbm_bo *cursor_bo;
@@ -113,7 +112,6 @@ struct wlr_drm_mode {
struct wlr_drm_connector {
struct wlr_output output;
- struct wlr_drm_backend *drm;
enum wlr_drm_connector_state state;
uint32_t id;
diff --git a/include/backend/wayland.h b/include/backend/wayland.h
index 508a7f52..88aeabca 100644
--- a/include/backend/wayland.h
+++ b/include/backend/wayland.h
@@ -5,7 +5,7 @@
#include <wayland-client.h>
#include <wayland-server.h>
#include <wayland-egl.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include <wlr/backend/wayland.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_input_device.h>
diff --git a/include/backend/x11.h b/include/backend/x11.h
index b4284b63..f5ec56bc 100644
--- a/include/backend/x11.h
+++ b/include/backend/x11.h
@@ -5,7 +5,7 @@
#include <xcb/xcb.h>
#include <X11/Xlib-xcb.h>
#include <wayland-server.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_input_device.h>
diff --git a/include/render/gles2.h b/include/render/gles2.h
index 688a51dd..0b7032cc 100644
--- a/include/render/gles2.h
+++ b/include/render/gles2.h
@@ -8,9 +8,9 @@
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <wlr/egl.h>
#include <wlr/backend.h>
#include <wlr/render.h>
+#include <wlr/render/egl.h>
#include <wlr/render/interface.h>
#include <wlr/util/log.h>
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index 6c11152f..78d01edf 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -3,7 +3,7 @@
#include <wayland-server.h>
#include <wlr/backend/session.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
struct wlr_backend_impl;
diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h
index ea41400a..3f0aaadb 100644
--- a/include/wlr/backend/interface.h
+++ b/include/wlr/backend/interface.h
@@ -3,7 +3,7 @@
#include <stdbool.h>
#include <wlr/backend.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
struct wlr_backend_impl {
bool (*start)(struct wlr_backend *backend);
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index b7927569..17dd5538 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -1,8 +1,9 @@
#ifndef WLR_INTERFACES_WLR_OUTPUT_H
#define WLR_INTERFACES_WLR_OUTPUT_H
-#include <wlr/types/wlr_output.h>
#include <stdbool.h>
+#include <wlr/types/wlr_output.h>
+#include <wlr/backend.h>
struct wlr_output_impl {
void (*enable)(struct wlr_output *output, bool enable);
@@ -21,7 +22,8 @@ struct wlr_output_impl {
uint16_t (*get_gamma_size)(struct wlr_output *output);
};
-void wlr_output_init(struct wlr_output *output, const struct wlr_output_impl *impl);
+void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
+ const struct wlr_output_impl *impl);
void wlr_output_free(struct wlr_output *output);
void wlr_output_update_matrix(struct wlr_output *output);
struct wl_global *wlr_output_create_global(
diff --git a/include/wlr/egl.h b/include/wlr/render/egl.h
index 9ab4d9ce..9ab4d9ce 100644
--- a/include/wlr/egl.h
+++ b/include/wlr/render/egl.h
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 312b51f8..a2d595ea 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -1,9 +1,10 @@
#ifndef WLR_TYPES_WLR_OUTPUT_H
#define WLR_TYPES_WLR_OUTPUT_H
+#include <stdbool.h>
#include <wayland-server.h>
+#include <wlr/backend.h>
#include <wlr/util/list.h>
-#include <stdbool.h>
struct wlr_output_mode {
uint32_t flags; // enum wl_output_mode
@@ -15,6 +16,7 @@ struct wlr_output_impl;
struct wlr_output {
const struct wlr_output_impl *impl;
+ struct wlr_backend *backend;
struct wl_global *wl_global;
struct wl_list wl_resources;
diff --git a/render/egl.c b/render/egl.c
index 9815b923..08612125 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -3,7 +3,7 @@
#include <GLES2/gl2.h>
#include <stdlib.h>
#include <wlr/util/log.h>
-#include <wlr/egl.h>
+#include <wlr/render/egl.h>
#include "render/glapi.h"
// Extension documentation
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 94c50b9a..646d69ec 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -5,9 +5,9 @@
#include <GLES2/gl2ext.h>
#include <wayland-util.h>
#include <wayland-server-protocol.h>
-#include <wlr/egl.h>
#include <wlr/backend.h>
#include <wlr/render.h>
+#include <wlr/render/egl.h>
#include <wlr/render/interface.h>
#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
@@ -246,9 +246,8 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) {
return NULL;
}
wlr_renderer_init(&renderer->wlr_renderer, &wlr_renderer_impl);
- if (backend) {
- struct wlr_egl *egl = wlr_backend_get_egl(backend);
- renderer->egl = egl;
- }
+
+ renderer->egl = wlr_backend_get_egl(backend);
+
return &renderer->wlr_renderer;
}
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 5e934aa4..ff71cb08 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -5,8 +5,8 @@
#include <GLES2/gl2ext.h>
#include <wayland-util.h>
#include <wayland-server-protocol.h>
-#include <wlr/egl.h>
#include <wlr/render.h>
+#include <wlr/render/egl.h>
#include <wlr/render/interface.h>
#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 5e10509e..03cff0bb 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -153,8 +153,7 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf,
output->cursor.height = height;
if (!output->cursor.renderer) {
- /* NULL egl is okay given that we are only using pixel buffers */
- output->cursor.renderer = wlr_gles2_renderer_create(NULL);
+ output->cursor.renderer = wlr_gles2_renderer_create(output->backend);
if (!output->cursor.renderer) {
return false;
}
@@ -307,8 +306,9 @@ bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
return output->impl->move_cursor(output, x, y);
}
-void wlr_output_init(struct wlr_output *output,
+void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
const struct wlr_output_impl *impl) {
+ output->backend = backend;
output->impl = impl;
output->modes = list_create();
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 9e38d701..68c21468 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -2,9 +2,9 @@
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/util/log.h>
-#include <wlr/egl.h>
#include <wlr/render/interface.h>
#include <wlr/types/wlr_surface.h>
+#include <wlr/render/egl.h>
#include <wlr/render/matrix.h>
static void wlr_surface_state_reset_buffer(struct wlr_surface_state *state) {