mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
backend: remove wlr_egl from all backends
This commit is contained in:
parent
5773794baf
commit
b899a412e3
14 changed files with 65 additions and 33 deletions
|
@ -30,8 +30,8 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer->wlr_rend = wlr_renderer_autocreate(&renderer->egl,
|
renderer->wlr_rend = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR,
|
||||||
EGL_PLATFORM_GBM_KHR, renderer->gbm);
|
renderer->gbm);
|
||||||
if (!renderer->wlr_rend) {
|
if (!renderer->wlr_rend) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create EGL/WLR renderer");
|
wlr_log(WLR_ERROR, "Failed to create EGL/WLR renderer");
|
||||||
goto error_gbm;
|
goto error_gbm;
|
||||||
|
@ -66,7 +66,6 @@ void finish_drm_renderer(struct wlr_drm_renderer *renderer) {
|
||||||
|
|
||||||
wlr_allocator_destroy(&renderer->allocator->base);
|
wlr_allocator_destroy(&renderer->allocator->base);
|
||||||
wlr_renderer_destroy(renderer->wlr_rend);
|
wlr_renderer_destroy(renderer->wlr_rend);
|
||||||
wlr_egl_finish(&renderer->egl);
|
|
||||||
gbm_device_destroy(renderer->gbm);
|
gbm_device_destroy(renderer->gbm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +116,8 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wlr_egl_make_current(&surf->renderer->egl, EGL_NO_SURFACE, NULL)) {
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(surf->renderer->wlr_rend);
|
||||||
|
if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!wlr_renderer_bind_buffer(surf->renderer->wlr_rend, surf->back_buffer)) {
|
if (!wlr_renderer_bind_buffer(surf->renderer->wlr_rend, surf->back_buffer)) {
|
||||||
|
@ -130,9 +130,10 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf,
|
||||||
|
|
||||||
void drm_surface_unset_current(struct wlr_drm_surface *surf) {
|
void drm_surface_unset_current(struct wlr_drm_surface *surf) {
|
||||||
assert(surf->back_buffer != NULL);
|
assert(surf->back_buffer != NULL);
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(surf->renderer->wlr_rend);
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(surf->renderer->wlr_rend, NULL);
|
wlr_renderer_bind_buffer(surf->renderer->wlr_rend, NULL);
|
||||||
wlr_egl_unset_current(&surf->renderer->egl);
|
wlr_egl_unset_current(egl);
|
||||||
|
|
||||||
wlr_buffer_unlock(surf->back_buffer);
|
wlr_buffer_unlock(surf->back_buffer);
|
||||||
surf->back_buffer = NULL;
|
surf->back_buffer = NULL;
|
||||||
|
|
|
@ -71,10 +71,11 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
|
||||||
wlr_signal_emit_safe(&wlr_backend->events.destroy, backend);
|
wlr_signal_emit_safe(&wlr_backend->events.destroy, backend);
|
||||||
|
|
||||||
free(backend->format);
|
free(backend->format);
|
||||||
if (backend->egl == &backend->priv_egl) {
|
|
||||||
|
if (!backend->has_parent_renderer) {
|
||||||
wlr_renderer_destroy(backend->renderer);
|
wlr_renderer_destroy(backend->renderer);
|
||||||
wlr_egl_finish(&backend->priv_egl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_allocator_destroy(backend->allocator);
|
wlr_allocator_destroy(backend->allocator);
|
||||||
free(backend);
|
free(backend);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +115,6 @@ static bool backend_init(struct wlr_headless_backend *backend,
|
||||||
|
|
||||||
backend->allocator = allocator;
|
backend->allocator = allocator;
|
||||||
backend->renderer = renderer;
|
backend->renderer = renderer;
|
||||||
backend->egl = wlr_gles2_renderer_get_egl(renderer);
|
|
||||||
|
|
||||||
const struct wlr_drm_format_set *formats =
|
const struct wlr_drm_format_set *formats =
|
||||||
wlr_renderer_get_dmabuf_render_formats(backend->renderer);
|
wlr_renderer_get_dmabuf_render_formats(backend->renderer);
|
||||||
|
@ -206,7 +206,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
|
||||||
goto error_backend;
|
goto error_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_renderer *renderer = wlr_renderer_autocreate(&backend->priv_egl,
|
struct wlr_renderer *renderer = wlr_renderer_autocreate(
|
||||||
EGL_PLATFORM_GBM_KHR, gbm_alloc->gbm_device);
|
EGL_PLATFORM_GBM_KHR, gbm_alloc->gbm_device);
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create renderer");
|
wlr_log(WLR_ERROR, "Failed to create renderer");
|
||||||
|
@ -257,6 +257,8 @@ struct wlr_backend *wlr_headless_backend_create_with_renderer(
|
||||||
goto error_backend;
|
goto error_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backend->has_parent_renderer = true;
|
||||||
|
|
||||||
if (!backend_init(backend, display, &gbm_alloc->base, renderer)) {
|
if (!backend_init(backend, display, &gbm_alloc->base, renderer)) {
|
||||||
goto error_init;
|
goto error_init;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wlr/interfaces/wlr_output.h>
|
#include <wlr/interfaces/wlr_output.h>
|
||||||
|
#include <wlr/render/gles2.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "backend/headless.h"
|
#include "backend/headless.h"
|
||||||
|
@ -42,6 +43,8 @@ static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
int *buffer_age) {
|
int *buffer_age) {
|
||||||
struct wlr_headless_output *output =
|
struct wlr_headless_output *output =
|
||||||
headless_output_from_output(wlr_output);
|
headless_output_from_output(wlr_output);
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
wlr_buffer_unlock(output->back_buffer);
|
||||||
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
||||||
|
@ -49,7 +52,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wlr_egl_make_current(output->backend->egl, EGL_NO_SURFACE, NULL)) {
|
if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!wlr_renderer_bind_buffer(output->backend->renderer,
|
if (!wlr_renderer_bind_buffer(output->backend->renderer,
|
||||||
|
@ -97,7 +100,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
assert(output->back_buffer != NULL);
|
assert(output->back_buffer != NULL);
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
||||||
wlr_egl_unset_current(output->backend->egl);
|
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
|
wlr_egl_unset_current(egl);
|
||||||
|
|
||||||
buffer = output->back_buffer;
|
buffer = output->back_buffer;
|
||||||
output->back_buffer = NULL;
|
output->back_buffer = NULL;
|
||||||
|
@ -122,10 +128,12 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
static void output_rollback_render(struct wlr_output *wlr_output) {
|
static void output_rollback_render(struct wlr_output *wlr_output) {
|
||||||
struct wlr_headless_output *output =
|
struct wlr_headless_output *output =
|
||||||
headless_output_from_output(wlr_output);
|
headless_output_from_output(wlr_output);
|
||||||
assert(wlr_egl_is_current(output->backend->egl));
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
|
assert(wlr_egl_is_current(egl));
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
||||||
wlr_egl_unset_current(output->backend->egl);
|
wlr_egl_unset_current(egl);
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
wlr_buffer_unlock(output->back_buffer);
|
||||||
output->back_buffer = NULL;
|
output->back_buffer = NULL;
|
||||||
|
|
|
@ -206,7 +206,6 @@ static void backend_destroy(struct wlr_backend *backend) {
|
||||||
wl_event_source_remove(wl->remote_display_src);
|
wl_event_source_remove(wl->remote_display_src);
|
||||||
|
|
||||||
wlr_renderer_destroy(wl->renderer);
|
wlr_renderer_destroy(wl->renderer);
|
||||||
wlr_egl_finish(&wl->egl);
|
|
||||||
|
|
||||||
wlr_drm_format_set_finish(&wl->linux_dmabuf_v1_formats);
|
wlr_drm_format_set_finish(&wl->linux_dmabuf_v1_formats);
|
||||||
|
|
||||||
|
@ -314,7 +313,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||||
}
|
}
|
||||||
wl_event_source_check(wl->remote_display_src);
|
wl_event_source_check(wl->remote_display_src);
|
||||||
|
|
||||||
wl->renderer = wlr_renderer_autocreate(&wl->egl, EGL_PLATFORM_WAYLAND_EXT,
|
wl->renderer = wlr_renderer_autocreate(EGL_PLATFORM_WAYLAND_EXT,
|
||||||
wl->remote_display);
|
wl->remote_display);
|
||||||
if (!wl->renderer) {
|
if (!wl->renderer) {
|
||||||
wlr_log(WLR_ERROR, "Could not create renderer");
|
wlr_log(WLR_ERROR, "Could not create renderer");
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
||||||
#include <wlr/interfaces/wlr_output.h>
|
#include <wlr/interfaces/wlr_output.h>
|
||||||
|
#include <wlr/render/gles2.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/types/wlr_matrix.h>
|
#include <wlr/types/wlr_matrix.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
@ -115,6 +116,8 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||||
static bool output_attach_render(struct wlr_output *wlr_output,
|
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
int *buffer_age) {
|
int *buffer_age) {
|
||||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
wlr_buffer_unlock(output->back_buffer);
|
||||||
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
||||||
|
@ -122,7 +125,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wlr_egl_make_current(&output->backend->egl, EGL_NO_SURFACE, NULL)) {
|
if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!wlr_renderer_bind_buffer(output->backend->renderer,
|
if (!wlr_renderer_bind_buffer(output->backend->renderer,
|
||||||
|
@ -309,7 +312,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
wlr_buffer = output->back_buffer;
|
wlr_buffer = output->back_buffer;
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
||||||
wlr_egl_unset_current(&output->backend->egl);
|
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
|
wlr_egl_unset_current(egl);
|
||||||
break;
|
break;
|
||||||
case WLR_OUTPUT_STATE_BUFFER_SCANOUT:;
|
case WLR_OUTPUT_STATE_BUFFER_SCANOUT:;
|
||||||
wlr_buffer = wlr_output->pending.buffer;
|
wlr_buffer = wlr_output->pending.buffer;
|
||||||
|
@ -369,8 +375,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
|
|
||||||
static void output_rollback_render(struct wlr_output *wlr_output) {
|
static void output_rollback_render(struct wlr_output *wlr_output) {
|
||||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
||||||
wlr_egl_unset_current(&output->backend->egl);
|
wlr_egl_unset_current(egl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_set_cursor(struct wlr_output *wlr_output,
|
static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||||
|
@ -402,6 +410,8 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||||
struct wl_surface *surface = output->cursor.surface;
|
struct wl_surface *surface = output->cursor.surface;
|
||||||
|
|
||||||
if (texture != NULL) {
|
if (texture != NULL) {
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
|
||||||
|
output->backend->renderer);
|
||||||
int width = texture->width * wlr_output->scale / scale;
|
int width = texture->width * wlr_output->scale / scale;
|
||||||
int height = texture->height * wlr_output->scale / scale;
|
int height = texture->height * wlr_output->scale / scale;
|
||||||
|
|
||||||
|
@ -423,7 +433,7 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wlr_egl_make_current(&output->backend->egl, EGL_NO_SURFACE, NULL)) {
|
if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!wlr_renderer_bind_buffer(output->backend->renderer, wlr_buffer)) {
|
if (!wlr_renderer_bind_buffer(output->backend->renderer, wlr_buffer)) {
|
||||||
|
@ -447,7 +457,7 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||||
wlr_renderer_end(backend->renderer);
|
wlr_renderer_end(backend->renderer);
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
|
||||||
wlr_egl_unset_current(&output->backend->egl);
|
wlr_egl_unset_current(egl);
|
||||||
|
|
||||||
struct wlr_wl_buffer *buffer =
|
struct wlr_wl_buffer *buffer =
|
||||||
get_or_create_wl_buffer(output->backend, wlr_buffer);
|
get_or_create_wl_buffer(output->backend, wlr_buffer);
|
||||||
|
|
|
@ -181,7 +181,6 @@ static void backend_destroy(struct wlr_backend *backend) {
|
||||||
wl_list_remove(&x11->display_destroy.link);
|
wl_list_remove(&x11->display_destroy.link);
|
||||||
|
|
||||||
wlr_renderer_destroy(x11->renderer);
|
wlr_renderer_destroy(x11->renderer);
|
||||||
wlr_egl_finish(&x11->egl);
|
|
||||||
wlr_allocator_destroy(x11->allocator);
|
wlr_allocator_destroy(x11->allocator);
|
||||||
wlr_drm_format_set_finish(&x11->dri3_formats);
|
wlr_drm_format_set_finish(&x11->dri3_formats);
|
||||||
free(x11->drm_format);
|
free(x11->drm_format);
|
||||||
|
@ -535,7 +534,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
}
|
}
|
||||||
x11->allocator = &gbm_alloc->base;
|
x11->allocator = &gbm_alloc->base;
|
||||||
|
|
||||||
x11->renderer = wlr_renderer_autocreate(&x11->egl, EGL_PLATFORM_GBM_KHR,
|
x11->renderer = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR,
|
||||||
gbm_alloc->gbm_device);
|
gbm_alloc->gbm_device);
|
||||||
if (x11->renderer == NULL) {
|
if (x11->renderer == NULL) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create renderer");
|
wlr_log(WLR_ERROR, "Failed to create renderer");
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <wlr/interfaces/wlr_output.h>
|
#include <wlr/interfaces/wlr_output.h>
|
||||||
#include <wlr/interfaces/wlr_pointer.h>
|
#include <wlr/interfaces/wlr_pointer.h>
|
||||||
#include <wlr/interfaces/wlr_touch.h>
|
#include <wlr/interfaces/wlr_touch.h>
|
||||||
|
#include <wlr/render/gles2.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
#include "backend/x11.h"
|
#include "backend/x11.h"
|
||||||
|
@ -97,6 +98,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
int *buffer_age) {
|
int *buffer_age) {
|
||||||
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(x11->renderer);
|
||||||
|
|
||||||
wlr_buffer_unlock(output->back_buffer);
|
wlr_buffer_unlock(output->back_buffer);
|
||||||
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
|
||||||
|
@ -104,7 +106,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wlr_egl_make_current(&x11->egl, EGL_NO_SURFACE, NULL)) {
|
if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!wlr_renderer_bind_buffer(x11->renderer, output->back_buffer)) {
|
if (!wlr_renderer_bind_buffer(x11->renderer, output->back_buffer)) {
|
||||||
|
@ -204,11 +206,12 @@ static struct wlr_x11_buffer *get_or_create_x11_buffer(
|
||||||
|
|
||||||
static bool output_commit_buffer(struct wlr_x11_output *output) {
|
static bool output_commit_buffer(struct wlr_x11_output *output) {
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(x11->renderer);
|
||||||
|
|
||||||
assert(output->back_buffer != NULL);
|
assert(output->back_buffer != NULL);
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(x11->renderer, NULL);
|
wlr_renderer_bind_buffer(x11->renderer, NULL);
|
||||||
wlr_egl_unset_current(&x11->egl);
|
wlr_egl_unset_current(egl);
|
||||||
|
|
||||||
struct wlr_x11_buffer *x11_buffer =
|
struct wlr_x11_buffer *x11_buffer =
|
||||||
get_or_create_x11_buffer(output, output->back_buffer);
|
get_or_create_x11_buffer(output, output->back_buffer);
|
||||||
|
@ -315,8 +318,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
static void output_rollback_render(struct wlr_output *wlr_output) {
|
static void output_rollback_render(struct wlr_output *wlr_output) {
|
||||||
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(x11->renderer);
|
||||||
|
|
||||||
wlr_renderer_bind_buffer(x11->renderer, NULL);
|
wlr_renderer_bind_buffer(x11->renderer, NULL);
|
||||||
wlr_egl_unset_current(&x11->egl);
|
wlr_egl_unset_current(egl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wlr_output_impl output_impl = {
|
static const struct wlr_output_impl output_impl = {
|
||||||
|
|
|
@ -15,7 +15,6 @@ struct wlr_buffer;
|
||||||
struct wlr_drm_renderer {
|
struct wlr_drm_renderer {
|
||||||
struct wlr_drm_backend *backend;
|
struct wlr_drm_backend *backend;
|
||||||
struct gbm_device *gbm;
|
struct gbm_device *gbm;
|
||||||
struct wlr_egl egl;
|
|
||||||
|
|
||||||
struct wlr_renderer *wlr_rend;
|
struct wlr_renderer *wlr_rend;
|
||||||
struct wlr_gbm_allocator *allocator;
|
struct wlr_gbm_allocator *allocator;
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
struct wlr_headless_backend {
|
struct wlr_headless_backend {
|
||||||
struct wlr_backend backend;
|
struct wlr_backend backend;
|
||||||
struct wlr_egl priv_egl; // may be uninitialized
|
|
||||||
struct wlr_egl *egl;
|
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
struct wlr_allocator *allocator;
|
struct wlr_allocator *allocator;
|
||||||
struct wlr_drm_format *format;
|
struct wlr_drm_format *format;
|
||||||
|
@ -19,6 +17,7 @@ struct wlr_headless_backend {
|
||||||
struct wl_list input_devices;
|
struct wl_list input_devices;
|
||||||
struct wl_listener display_destroy;
|
struct wl_listener display_destroy;
|
||||||
struct wl_listener renderer_destroy;
|
struct wl_listener renderer_destroy;
|
||||||
|
bool has_parent_renderer;
|
||||||
bool started;
|
bool started;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ struct wlr_wl_backend {
|
||||||
struct wl_display *local_display;
|
struct wl_display *local_display;
|
||||||
struct wl_list devices;
|
struct wl_list devices;
|
||||||
struct wl_list outputs;
|
struct wl_list outputs;
|
||||||
struct wlr_egl egl;
|
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
struct wlr_drm_format *format;
|
struct wlr_drm_format *format;
|
||||||
struct wlr_allocator *allocator;
|
struct wlr_allocator *allocator;
|
||||||
|
|
|
@ -77,7 +77,6 @@ struct wlr_x11_backend {
|
||||||
struct wlr_keyboard keyboard;
|
struct wlr_keyboard keyboard;
|
||||||
struct wlr_input_device keyboard_dev;
|
struct wlr_input_device keyboard_dev;
|
||||||
|
|
||||||
struct wlr_egl egl;
|
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
struct wlr_drm_format_set dri3_formats;
|
struct wlr_drm_format_set dri3_formats;
|
||||||
const struct wlr_x11_format *x11_format;
|
const struct wlr_x11_format *x11_format;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct wlr_renderer {
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_egl *egl, EGLenum platform,
|
struct wlr_renderer *wlr_renderer_autocreate(EGLenum platform,
|
||||||
void *remote_display);
|
void *remote_display);
|
||||||
|
|
||||||
void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
|
void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
|
||||||
|
|
|
@ -674,6 +674,7 @@ static void gles2_destroy(struct wlr_renderer *wlr_renderer) {
|
||||||
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
||||||
|
|
||||||
wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL);
|
wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL);
|
||||||
|
wlr_egl_finish(renderer->egl);
|
||||||
|
|
||||||
struct wlr_gles2_buffer *buffer, *buffer_tmp;
|
struct wlr_gles2_buffer *buffer, *buffer_tmp;
|
||||||
wl_list_for_each_safe(buffer, buffer_tmp, &renderer->buffers, link) {
|
wl_list_for_each_safe(buffer, buffer_tmp, &renderer->buffers, link) {
|
||||||
|
|
|
@ -247,13 +247,24 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_egl *egl,
|
struct wlr_renderer *wlr_renderer_autocreate(EGLenum platform,
|
||||||
EGLenum platform, void *remote_display) {
|
void *remote_display) {
|
||||||
|
struct wlr_egl *egl = calloc(1, sizeof(*egl));
|
||||||
|
if (egl == NULL) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!wlr_egl_init(egl, platform, remote_display, NULL, 0)) {
|
if (!wlr_egl_init(egl, platform, remote_display, NULL, 0)) {
|
||||||
wlr_log(WLR_ERROR, "Could not initialize EGL");
|
wlr_log(WLR_ERROR, "Could not initialize EGL");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wlr_renderer becomes the owner of the previously wlr_egl, and will
|
||||||
|
* take care of freeing the allocated memory
|
||||||
|
* TODO: move the wlr_egl logic to wlr_gles2_renderer
|
||||||
|
*/
|
||||||
struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl);
|
struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl);
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
wlr_egl_finish(egl);
|
wlr_egl_finish(egl);
|
||||||
|
|
Loading…
Reference in a new issue