backend-wayland: use gl-borders
Use the gl-renderer border code shared with headless-backend. We can drop all this open-coded stuff. In the output disable path, make sure to call this only when gl-renderer is used. It will also reset the border state in gl-renderer, which is harmless here, and it's necessary in the resize path. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
e619a65b09
commit
212c666ab5
|
@ -21,6 +21,7 @@ deps_wlwl = [
|
||||||
dep_libweston_private,
|
dep_libweston_private,
|
||||||
dep_libdrm_headers,
|
dep_libdrm_headers,
|
||||||
dep_lib_cairo_shared,
|
dep_lib_cairo_shared,
|
||||||
|
dep_lib_gl_borders,
|
||||||
]
|
]
|
||||||
|
|
||||||
if get_option('renderer-gl')
|
if get_option('renderer-gl')
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include <libweston/libweston.h>
|
#include <libweston/libweston.h>
|
||||||
#include <libweston/backend-wayland.h>
|
#include <libweston/backend-wayland.h>
|
||||||
#include "renderer-gl/gl-renderer.h"
|
#include "renderer-gl/gl-renderer.h"
|
||||||
|
#include "gl-borders.h"
|
||||||
#include "shared/weston-drm-fourcc.h"
|
#include "shared/weston-drm-fourcc.h"
|
||||||
#include "shared/weston-egl-ext.h"
|
#include "shared/weston-egl-ext.h"
|
||||||
#include "pixman-renderer.h"
|
#include "pixman-renderer.h"
|
||||||
|
@ -123,12 +124,7 @@ struct wayland_output {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_egl_window *egl_window;
|
struct wl_egl_window *egl_window;
|
||||||
struct {
|
struct weston_gl_borders borders;
|
||||||
cairo_surface_t *top;
|
|
||||||
cairo_surface_t *left;
|
|
||||||
cairo_surface_t *right;
|
|
||||||
cairo_surface_t *bottom;
|
|
||||||
} border;
|
|
||||||
} gl;
|
} gl;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -443,71 +439,13 @@ draw_initial_frame(struct wayland_output *output)
|
||||||
static void
|
static void
|
||||||
wayland_output_update_gl_border(struct wayland_output *output)
|
wayland_output_update_gl_border(struct wayland_output *output)
|
||||||
{
|
{
|
||||||
int32_t ix, iy, iwidth, iheight, fwidth, fheight;
|
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
if (!output->frame)
|
if (!output->frame)
|
||||||
return;
|
return;
|
||||||
if (!(frame_status(output->frame) & FRAME_STATUS_REPAINT))
|
if (!(frame_status(output->frame) & FRAME_STATUS_REPAINT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fwidth = frame_width(output->frame);
|
weston_gl_borders_update(&output->gl.borders, output->frame,
|
||||||
fheight = frame_height(output->frame);
|
&output->base, gl_renderer);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -737,6 +675,9 @@ wayland_output_disable(struct weston_output *base)
|
||||||
pixman_renderer_output_destroy(&output->base);
|
pixman_renderer_output_destroy(&output->base);
|
||||||
#ifdef ENABLE_EGL
|
#ifdef ENABLE_EGL
|
||||||
} else {
|
} else {
|
||||||
|
weston_gl_borders_fini(&output->gl.borders,
|
||||||
|
&output->base, gl_renderer);
|
||||||
|
|
||||||
gl_renderer->output_destroy(&output->base);
|
gl_renderer->output_destroy(&output->base);
|
||||||
wl_egl_window_destroy(output->gl.egl_window);
|
wl_egl_window_destroy(output->gl.egl_window);
|
||||||
#endif
|
#endif
|
||||||
|
@ -749,11 +690,6 @@ wayland_output_disable(struct weston_output *base)
|
||||||
if (output->frame)
|
if (output->frame)
|
||||||
frame_destroy(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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,26 +824,8 @@ wayland_output_resize_surface(struct wayland_output *output)
|
||||||
weston_renderer_resize_output(&output->base, &fb_size, &area);
|
weston_renderer_resize_output(&output->base, &fb_size, &area);
|
||||||
|
|
||||||
/* These will need to be re-created due to the resize */
|
/* These will need to be re-created due to the resize */
|
||||||
gl_renderer->output_set_border(&output->base,
|
weston_gl_borders_fini(&output->gl.borders,
|
||||||
GL_RENDERER_BORDER_TOP,
|
&output->base, gl_renderer);
|
||||||
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;
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue