Make GLES2 optional

This commit is contained in:
Simon Ser 2022-11-26 20:13:31 +01:00 committed by Simon Zeni
parent 456f49db35
commit 5b64e2fc31
2 changed files with 26 additions and 16 deletions

View file

@ -43,6 +43,24 @@ subproject(
required: false,
version: wlroots_version,
)
wlroots = dependency('wlroots', version: wlroots_version)
wlroots_features = {
'xwayland': false,
'libinput_backend': false,
'gles2_renderer': false,
'session': false,
}
foreach name, _ : wlroots_features
var_name = 'have_' + name.underscorify()
have = wlroots.get_variable(pkgconfig: var_name, internal: var_name) == 'true'
wlroots_features += { name: have }
endforeach
if get_option('xwayland').enabled() and not wlroots_features['xwayland']
error('Cannot enable Xwayland in sway: wlroots has been built without Xwayland support')
endif
null_dep = dependency('', required: false)
jsonc = dependency('json-c', version: '>=0.13')
pcre2 = dependency('libpcre2-8')
@ -50,14 +68,13 @@ wayland_server = dependency('wayland-server', version: '>=1.21.0')
wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
wayland_protos = dependency('wayland-protocols', version: '>=1.24')
wlroots = dependency('wlroots', version: wlroots_version)
xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo')
pango = dependency('pango')
pangocairo = dependency('pangocairo')
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
pixman = dependency('pixman-1')
glesv2 = dependency('glesv2')
glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep
libevdev = dependency('libevdev')
libinput = dependency('libinput', version: '>=1.21.0')
xcb = dependency('xcb', required: get_option('xwayland'))
@ -71,18 +88,6 @@ rt = cc.find_library('rt')
xcb_icccm = dependency('xcb-icccm', required: get_option('xwayland'))
threads = dependency('threads') # for pthread_setschedparam
wlroots_features = {
'xwayland': false,
}
foreach name, _ : wlroots_features
var_name = 'have_' + name.underscorify()
have = wlroots.get_variable(pkgconfig: var_name, internal: var_name) == 'true'
wlroots_features += { name: have }
endforeach
if get_option('xwayland').enabled() and not wlroots_features['xwayland']
error('Cannot enable Xwayland in sway: wlroots has been built without Xwayland support')
endif
have_xwayland = xcb.found() and wlroots_features['xwayland']
if get_option('sd-bus-provider') == 'auto'

View file

@ -1,11 +1,10 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <GLES2/gl2.h>
#include <stdlib.h>
#include <strings.h>
#include <time.h>
#include <wayland-server-core.h>
#include <wlr/render/gles2.h>
#include <wlr/config.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_damage_ring.h>
@ -28,6 +27,10 @@
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#if WLR_HAS_GLES2_RENDERER
#include <wlr/render/gles2.h>
#endif
struct render_data {
pixman_region32_t *damage;
float alpha;
@ -74,6 +77,7 @@ static void scissor_output(struct wlr_output *wlr_output,
static void set_scale_filter(struct wlr_output *wlr_output,
struct wlr_texture *texture, enum scale_filter_mode scale_filter) {
#if WLR_HAS_GLES2_RENDERER
if (!wlr_texture_is_gles2(texture)) {
return;
}
@ -94,6 +98,7 @@ static void set_scale_filter(struct wlr_output *wlr_output,
case SCALE_FILTER_SMART:
assert(false); // unreachable
}
#endif
}
static void render_texture(struct wlr_output *wlr_output,