render: make GLES2 renderer optional

Allow selecting whether the GLES2 renderer gets enabled.

Co-authored-by: Simon Ser <contact@emersion.fr>
master
ayaka 4 years ago committed by Simon Ser
parent 122d6c6988
commit ed1924800d

@ -23,6 +23,11 @@ if libavutil.found() and not cc.has_header('libavutil/hwcontext_drm.h', dependen
libavutil = disabler() libavutil = disabler()
endif endif
wlr_gles2_renderer = []
if not features['gles2-renderer']
wlr_gles2_renderer = disabler()
endif
compositors = { compositors = {
'simple': { 'simple': {
'src': 'simple.c', 'src': 'simple.c',
@ -32,18 +37,23 @@ compositors = {
}, },
'touch': { 'touch': {
'src': ['touch.c', 'cat.c'], 'src': ['touch.c', 'cat.c'],
'dep': [wlr_gles2_renderer],
}, },
'tablet': { 'tablet': {
'src': 'tablet.c', 'src': 'tablet.c',
'dep': [wlr_gles2_renderer],
}, },
'rotation': { 'rotation': {
'src': ['rotation.c', 'cat.c'], 'src': ['rotation.c', 'cat.c'],
'dep': [wlr_gles2_renderer],
}, },
'multi-pointer': { 'multi-pointer': {
'src': 'multi-pointer.c', 'src': 'multi-pointer.c',
'dep': [wlr_gles2_renderer],
}, },
'output-layout': { 'output-layout': {
'src': ['output-layout.c', 'cat.c'], 'src': ['output-layout.c', 'cat.c'],
'dep': [wlr_gles2_renderer],
}, },
'fullscreen-shell': { 'fullscreen-shell': {
'src': 'fullscreen-shell.c', 'src': 'fullscreen-shell.c',
@ -193,7 +203,7 @@ foreach name, info : compositors
executable( executable(
name, name,
[info.get('src'), extra_src], [info.get('src'), extra_src],
dependencies: [wlroots, libdrm], dependencies: [wlroots, libdrm, info.get('dep', [])],
include_directories: [wlr_inc, proto_inc], include_directories: [wlr_inc, proto_inc],
build_by_default: get_option('examples'), build_by_default: get_option('examples'),
) )

@ -9,6 +9,9 @@ if not features.get('xwayland')
else else
subdir('xwayland') subdir('xwayland')
endif endif
if not features.get('gles2-renderer')
exclude_files += ['render/egl.h', 'render/gles2.h']
endif
install_subdir('wlr', install_subdir('wlr',
install_dir: get_option('includedir'), install_dir: get_option('includedir'),

@ -3,6 +3,8 @@
#mesondefine WLR_HAS_X11_BACKEND #mesondefine WLR_HAS_X11_BACKEND
#mesondefine WLR_HAS_GLES2_RENDERER
#mesondefine WLR_HAS_XWAYLAND #mesondefine WLR_HAS_XWAYLAND
#endif #endif

@ -88,6 +88,7 @@ endif
features = { features = {
'x11-backend': false, 'x11-backend': false,
'xwayland': false, 'xwayland': false,
'gles2-renderer': false,
} }
internal_features = { internal_features = {
'xcb-errors': false, 'xcb-errors': false,
@ -96,8 +97,6 @@ internal_features = {
wayland_server = dependency('wayland-server', version: '>=1.19') wayland_server = dependency('wayland-server', version: '>=1.19')
wayland_client = dependency('wayland-client') wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols', version: '>=1.17') wayland_protos = dependency('wayland-protocols', version: '>=1.17')
egl = dependency('egl')
glesv2 = dependency('glesv2')
drm = dependency('libdrm', version: '>=2.4.95') drm = dependency('libdrm', version: '>=2.4.95')
gbm = dependency('gbm', version: '>=17.1.0') gbm = dependency('gbm', version: '>=17.1.0')
libinput = dependency('libinput', version: '>=1.14.0') libinput = dependency('libinput', version: '>=1.14.0')
@ -113,8 +112,6 @@ wlr_deps = [
wayland_server, wayland_server,
wayland_client, wayland_client,
wayland_protos, wayland_protos,
egl,
glesv2,
drm, drm,
gbm, gbm,
libinput, libinput,

@ -3,3 +3,4 @@ option('xwayland', type: 'feature', value: 'auto', yield: true, description: 'En
option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend') option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend')
option('examples', type: 'boolean', value: true, description: 'Build example applications') option('examples', type: 'boolean', value: true, description: 'Build example applications')
option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '') option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '')
option('renderers', type: 'array', choices: ['auto', 'gles2'], value: ['auto'], description: 'Select built-in renderers')

@ -1,3 +1,12 @@
glesv2 = dependency('glesv2', required: 'gles2' in renderers)
if not (glesv2.found() and egl.found())
subdir_done()
endif
features += { 'gles2-renderer': true }
wlr_deps += glesv2
wlr_files += files( wlr_files += files(
'pixel_format.c', 'pixel_format.c',
'renderer.c', 'renderer.c',

@ -1,7 +1,13 @@
renderers = get_option('renderers')
if 'auto' in renderers and get_option('auto_features').enabled()
renderers = ['gles2']
elif 'auto' in renderers and get_option('auto_features').disabled()
renderers = []
endif
wlr_files += files( wlr_files += files(
'allocator.c', 'allocator.c',
'dmabuf.c', 'dmabuf.c',
'egl.c',
'drm_format_set.c', 'drm_format_set.c',
'gbm_allocator.c', 'gbm_allocator.c',
'pixel_format.c', 'pixel_format.c',
@ -11,5 +17,14 @@ wlr_files += files(
'wlr_texture.c', 'wlr_texture.c',
) )
subdir('gles2') egl = dependency('egl', required: 'gles2' in renderers)
if egl.found()
wlr_deps += egl
wlr_files += files('egl.c')
endif
if 'gles2' in renderers or 'auto' in renderers
subdir('gles2')
endif
subdir('pixman') subdir('pixman')

@ -1,4 +1,5 @@
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
wlr_deps += pixman wlr_deps += pixman
wlr_files += files( wlr_files += files(

@ -2,13 +2,19 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <gbm.h> #include <gbm.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/render/pixman.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
#include <wlr/render/pixman.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>
#include <wlr/config.h>
#if WLR_HAS_GLES2_RENDERER
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#endif
#include "util/signal.h" #include "util/signal.h"
#include "render/pixel_format.h" #include "render/pixel_format.h"
#include "render/wlr_renderer.h" #include "render/wlr_renderer.h"
@ -222,6 +228,7 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
} }
struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) { struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
#if WLR_HAS_GLES2_RENDERER
struct gbm_device *gbm_device = gbm_create_device(drm_fd); struct gbm_device *gbm_device = gbm_create_device(drm_fd);
if (!gbm_device) { if (!gbm_device) {
wlr_log(WLR_ERROR, "Failed to create GBM device"); wlr_log(WLR_ERROR, "Failed to create GBM device");
@ -241,9 +248,14 @@ struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
if (!renderer) { if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create GLES2 renderer"); wlr_log(WLR_ERROR, "Failed to create GLES2 renderer");
wlr_egl_destroy(egl); wlr_egl_destroy(egl);
return NULL;
} }
return renderer; return renderer;
#endif
wlr_log(WLR_ERROR, "Failed to initialize any renderer");
return NULL;
} }
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) { struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {

Loading…
Cancel
Save