Skip to content
Commits on Source (6)
......@@ -33,6 +33,7 @@ srcs_drm = [
]
deps_drm = [
dep_egl, # optional
dep_libm,
dep_libdl,
dep_libweston_private,
......@@ -55,10 +56,6 @@ if get_option('renderer-gl')
config_h.set('HAVE_GBM_FD_IMPORT', '1')
endif
deps_drm += dep_gbm
if not dep_egl.found()
error('drm-backend + gl-renderer requires egl which was not found. Or, you can use \'-Dbackend-drm=false\' or \'-Drenderer-gl=false\'.')
endif
deps_drm += dep_egl
srcs_drm += 'drm-gbm.c'
config_h.set('BUILD_DRM_GBM', '1')
endif
......
......@@ -42,6 +42,7 @@
#include "pixel-formats.h"
#include "pixman-renderer.h"
#include "renderer-gl/gl-renderer.h"
#include "gl-borders.h"
#include "shared/weston-drm-fourcc.h"
#include "shared/weston-egl-ext.h"
#include "shared/cairo-util.h"
......@@ -73,12 +74,7 @@ struct headless_output {
struct frame *frame;
struct {
struct {
cairo_surface_t *top;
cairo_surface_t *left;
cairo_surface_t *right;
cairo_surface_t *bottom;
} border;
struct weston_gl_borders borders;
} gl;
};
......@@ -142,72 +138,14 @@ static void
headless_output_update_gl_border(struct headless_output *output)
{
struct headless_backend *backend = to_headless_backend(output->base.compositor);
struct gl_renderer_interface *glri = backend->glri;
int32_t ix, iy, iwidth, iheight, fwidth, fheight;
cairo_t *cr;
if (!output->frame)
return;
if (!(frame_status(output->frame) & FRAME_STATUS_REPAINT))
return;
fwidth = frame_width(output->frame);
fheight = frame_height(output->frame);
frame_interior(output->frame, &ix, &iy, &iwidth, &iheight);
if (!output->gl.border.top)
output->gl.border.top =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
fwidth, iy);
cr = cairo_create(output->gl.border.top);
frame_repaint(output->frame, cr);
cairo_destroy(cr);
glri->output_set_border(&output->base, GL_RENDERER_BORDER_TOP,
fwidth, iy,
cairo_image_surface_get_stride(output->gl.border.top) / 4,
cairo_image_surface_get_data(output->gl.border.top));
if (!output->gl.border.left)
output->gl.border.left =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
ix, 1);
cr = cairo_create(output->gl.border.left);
cairo_translate(cr, 0, -iy);
frame_repaint(output->frame, cr);
cairo_destroy(cr);
glri->output_set_border(&output->base, GL_RENDERER_BORDER_LEFT,
ix, 1,
cairo_image_surface_get_stride(output->gl.border.left) / 4,
cairo_image_surface_get_data(output->gl.border.left));
if (!output->gl.border.right)
output->gl.border.right =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
fwidth - (ix + iwidth), 1);
cr = cairo_create(output->gl.border.right);
cairo_translate(cr, -(iwidth + ix), -iy);
frame_repaint(output->frame, cr);
cairo_destroy(cr);
glri->output_set_border(&output->base, GL_RENDERER_BORDER_RIGHT,
fwidth - (ix + iwidth), 1,
cairo_image_surface_get_stride(output->gl.border.right) / 4,
cairo_image_surface_get_data(output->gl.border.right));
if (!output->gl.border.bottom)
output->gl.border.bottom =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
fwidth, fheight - (iy + iheight));
cr = cairo_create(output->gl.border.bottom);
cairo_translate(cr, 0, -(iy + iheight));
frame_repaint(output->frame, cr);
cairo_destroy(cr);
glri->output_set_border(&output->base, GL_RENDERER_BORDER_BOTTOM,
fwidth, fheight - (iy + iheight),
cairo_image_surface_get_stride(output->gl.border.bottom) / 4,
cairo_image_surface_get_data(output->gl.border.bottom));
weston_gl_borders_update(&output->gl.borders, output->frame,
&output->base, backend->glri);
}
static int
......@@ -239,21 +177,14 @@ headless_output_disable_gl(struct headless_output *output)
struct weston_compositor *compositor = output->base.compositor;
struct headless_backend *b = to_headless_backend(compositor);
weston_gl_borders_fini(&output->gl.borders, &output->base, b->glri);
b->glri->output_destroy(&output->base);
if (output->frame) {
frame_destroy(output->frame);
output->frame = NULL;
}
cairo_surface_destroy(output->gl.border.top);
cairo_surface_destroy(output->gl.border.left);
cairo_surface_destroy(output->gl.border.right);
cairo_surface_destroy(output->gl.border.bottom);
output->gl.border.top = NULL;
output->gl.border.left = NULL;
output->gl.border.right = NULL;
output->gl.border.bottom = NULL;
}
static void
......
......@@ -16,6 +16,7 @@ plugin_headless = shared_library(
dep_libweston_private,
dep_libdrm_headers,
dep_lib_cairo_shared,
dep_lib_gl_borders,
],
name_prefix: '',
install: true,
......
......@@ -21,6 +21,7 @@ deps_wlwl = [
dep_libweston_private,
dep_libdrm_headers,
dep_lib_cairo_shared,
dep_lib_gl_borders,
]
if get_option('renderer-gl')
......
......@@ -48,6 +48,7 @@
#include <libweston/libweston.h>
#include <libweston/backend-wayland.h>
#include "renderer-gl/gl-renderer.h"
#include "gl-borders.h"
#include "shared/weston-drm-fourcc.h"
#include "shared/weston-egl-ext.h"
#include "pixman-renderer.h"
......@@ -123,12 +124,7 @@ struct wayland_output {
struct {
struct wl_egl_window *egl_window;
struct {
cairo_surface_t *top;
cairo_surface_t *left;
cairo_surface_t *right;
cairo_surface_t *bottom;
} border;
struct weston_gl_borders borders;
} gl;
struct {
......@@ -443,71 +439,13 @@ draw_initial_frame(struct wayland_output *output)
static void
wayland_output_update_gl_border(struct wayland_output *output)
{
int32_t ix, iy, iwidth, iheight, fwidth, fheight;
cairo_t *cr;
if (!output->frame)
return;
if (!(frame_status(output->frame) & FRAME_STATUS_REPAINT))
return;
fwidth = frame_width(output->frame);
fheight = frame_height(output->frame);
frame_interior(output->frame, &ix, &iy, &iwidth, &iheight);
if (!output->gl.border.top)
output->gl.border.top =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
fwidth, iy);
cr = cairo_create(output->gl.border.top);
frame_repaint(output->frame, cr);
cairo_destroy(cr);
gl_renderer->output_set_border(&output->base, GL_RENDERER_BORDER_TOP,
fwidth, iy,
cairo_image_surface_get_stride(output->gl.border.top) / 4,
cairo_image_surface_get_data(output->gl.border.top));
if (!output->gl.border.left)
output->gl.border.left =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
ix, 1);
cr = cairo_create(output->gl.border.left);
cairo_translate(cr, 0, -iy);
frame_repaint(output->frame, cr);
cairo_destroy(cr);
gl_renderer->output_set_border(&output->base, GL_RENDERER_BORDER_LEFT,
ix, 1,
cairo_image_surface_get_stride(output->gl.border.left) / 4,
cairo_image_surface_get_data(output->gl.border.left));
if (!output->gl.border.right)
output->gl.border.right =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
fwidth - (ix + iwidth), 1);
cr = cairo_create(output->gl.border.right);
cairo_translate(cr, -(iwidth + ix), -iy);
frame_repaint(output->frame, cr);
cairo_destroy(cr);
gl_renderer->output_set_border(&output->base, GL_RENDERER_BORDER_RIGHT,
fwidth - (ix + iwidth), 1,
cairo_image_surface_get_stride(output->gl.border.right) / 4,
cairo_image_surface_get_data(output->gl.border.right));
if (!output->gl.border.bottom)
output->gl.border.bottom =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
fwidth, fheight - (iy + iheight));
cr = cairo_create(output->gl.border.bottom);
cairo_translate(cr, 0, -(iy + iheight));
frame_repaint(output->frame, cr);
cairo_destroy(cr);
gl_renderer->output_set_border(&output->base, GL_RENDERER_BORDER_BOTTOM,
fwidth, fheight - (iy + iheight),
cairo_image_surface_get_stride(output->gl.border.bottom) / 4,
cairo_image_surface_get_data(output->gl.border.bottom));
weston_gl_borders_update(&output->gl.borders, output->frame,
&output->base, gl_renderer);
}
#endif
......@@ -737,6 +675,9 @@ wayland_output_disable(struct weston_output *base)
pixman_renderer_output_destroy(&output->base);
#ifdef ENABLE_EGL
} else {
weston_gl_borders_fini(&output->gl.borders,
&output->base, gl_renderer);
gl_renderer->output_destroy(&output->base);
wl_egl_window_destroy(output->gl.egl_window);
#endif
......@@ -749,11 +690,6 @@ wayland_output_disable(struct weston_output *base)
if (output->frame)
frame_destroy(output->frame);
cairo_surface_destroy(output->gl.border.top);
cairo_surface_destroy(output->gl.border.left);
cairo_surface_destroy(output->gl.border.right);
cairo_surface_destroy(output->gl.border.bottom);
return 0;
}
......@@ -888,26 +824,8 @@ wayland_output_resize_surface(struct wayland_output *output)
weston_renderer_resize_output(&output->base, &fb_size, &area);
/* These will need to be re-created due to the resize */
gl_renderer->output_set_border(&output->base,
GL_RENDERER_BORDER_TOP,
0, 0, 0, NULL);
cairo_surface_destroy(output->gl.border.top);
output->gl.border.top = NULL;
gl_renderer->output_set_border(&output->base,
GL_RENDERER_BORDER_LEFT,
0, 0, 0, NULL);
cairo_surface_destroy(output->gl.border.left);
output->gl.border.left = NULL;
gl_renderer->output_set_border(&output->base,
GL_RENDERER_BORDER_RIGHT,
0, 0, 0, NULL);
cairo_surface_destroy(output->gl.border.right);
output->gl.border.right = NULL;
gl_renderer->output_set_border(&output->base,
GL_RENDERER_BORDER_BOTTOM,
0, 0, 0, NULL);
cairo_surface_destroy(output->gl.border.bottom);
output->gl.border.bottom = NULL;
weston_gl_borders_fini(&output->gl.borders,
&output->base, gl_renderer);
} else
#endif
{
......
......@@ -16,6 +16,7 @@ if not dep_x11_xcb.found()
endif
deps_x11 = [
dep_egl, # optional
dep_libweston_private,
dep_libdrm_headers,
dep_x11_xcb,
......@@ -37,13 +38,6 @@ if dep_xcb_xkb.found()
config_h.set('HAVE_XCB_XKB', '1')
endif
if get_option('renderer-gl')
if not dep_egl.found()
error('x11-backend + gl-renderer requires egl which was not found. Or, you can use \'-Dbackend-x11=false\' or \'-Drenderer-gl=false\'.')
endif
deps_x11 += dep_egl
endif
plugin_x11 = shared_library(
'x11-backend',
srcs_x11,
......
/*
* Copyright © 2010-2011 Benjamin Franzke
* Copyright © 2012 Intel Corporation
* Copyright © 2013 Jason Ekstrand
* Copyright 2022 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include "gl-borders.h"
#include "shared/helpers.h"
void
weston_gl_borders_update(struct weston_gl_borders *borders,
struct frame *frame,
struct weston_output *output,
struct gl_renderer_interface *glri)
{
int32_t ix, iy, iwidth, iheight, fwidth, fheight;
fwidth = frame_width(frame);
fheight = frame_height(frame);
frame_interior(frame, &ix, &iy, &iwidth, &iheight);
struct weston_geometry border_area[4] = {
[GL_RENDERER_BORDER_TOP] = {
.x = 0, .y = 0,
.width = fwidth, .height = iy
},
[GL_RENDERER_BORDER_LEFT] = {
.x = 0, .y = iy,
.width = ix, .height = 1
},
[GL_RENDERER_BORDER_RIGHT] = {
.x = iwidth + ix, .y = iy,
.width = fwidth - (ix + iwidth), .height = 1
},
[GL_RENDERER_BORDER_BOTTOM] = {
.x = 0, .y = iy + iheight,
.width = fwidth, .height = fheight - (iy + iheight)
},
};
for (unsigned i = 0; i < ARRAY_LENGTH(border_area); i++) {
const struct weston_geometry *g = &border_area[i];
int tex_width;
cairo_t *cr;
if (!borders->tile[i]) {
borders->tile[i] =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
g->width, g->height);
}
tex_width = cairo_image_surface_get_stride(borders->tile[i]) / 4;
cr = cairo_create(borders->tile[i]);
cairo_translate(cr, -g->x, -g->y);
frame_repaint(frame, cr);
cairo_destroy(cr);
glri->output_set_border(output, i, g->width, g->height, tex_width,
cairo_image_surface_get_data(borders->tile[i]));
}
}
void
weston_gl_borders_fini(struct weston_gl_borders *borders,
struct weston_output *output,
struct gl_renderer_interface *glri)
{
for (unsigned i = 0; i < ARRAY_LENGTH(borders->tile); i++) {
glri->output_set_border(output, i, 0, 0, 0, NULL);
cairo_surface_destroy(borders->tile[i]);
borders->tile[i] = NULL;
}
}
/*
* Copyright 2022 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include "renderer-gl/gl-renderer.h"
#include "shared/cairo-util.h"
struct weston_gl_borders {
cairo_surface_t *tile[4]; /* enum gl_renderer_border_side */
};
void
weston_gl_borders_update(struct weston_gl_borders *borders,
struct frame *frame,
struct weston_output *output,
struct gl_renderer_interface *glri);
void
weston_gl_borders_fini(struct weston_gl_borders *borders,
struct weston_output *output,
struct gl_renderer_interface *glri);
......@@ -81,6 +81,8 @@ if get_option('renderer-gl')
error('libweston + gl-renderer requires egl which was not found. Or, you can use \'-Drenderer-gl=false\'.')
endif
deps_libweston += dep_egl
else
dep_egl = dependency('', required: false)
endif
if get_option('backend-vnc')
......@@ -240,6 +242,22 @@ dep_vertex_clipping = declare_dependency(
include_directories: include_directories('.')
)
lib_gl_borders = static_library(
'gl-borders',
'gl-borders.c',
include_directories: common_inc,
dependencies: [
dep_lib_cairo_shared,
dep_egl, # for gl-renderer.h
],
build_by_default: false,
install: false
)
dep_lib_gl_borders = declare_dependency(
link_with: lib_gl_borders,
dependencies: dep_lib_cairo_shared
)
subdir('color-lcms')
subdir('renderer-gl')
subdir('backend-drm')
......
......@@ -23,6 +23,8 @@
* SOFTWARE.
*/
#pragma once
#include "config.h"
#include <stdint.h>
......