Skip to content
Commits on Source (5)
......@@ -37,6 +37,7 @@
#include <libweston/backend-headless.h>
#include "shared/helpers.h"
#include "linux-explicit-synchronization.h"
#include "pixel-formats.h"
#include "pixman-renderer.h"
#include "renderer-gl/gl-renderer.h"
#include "shared/weston-drm-fourcc.h"
......@@ -70,12 +71,11 @@ struct headless_output {
struct weston_mode mode;
struct wl_event_source *finish_frame_timer;
uint32_t *image_buf;
pixman_image_t *image;
};
static const uint32_t headless_formats[] = {
DRM_FORMAT_XRGB8888,
DRM_FORMAT_XRGB8888, /* default for pixman-renderer */
DRM_FORMAT_ARGB8888,
};
......@@ -165,7 +165,6 @@ headless_output_disable_pixman(struct headless_output *output)
{
pixman_renderer_output_destroy(&output->base);
pixman_image_unref(output->image);
free(output->image_buf);
}
static int
......@@ -233,20 +232,20 @@ headless_output_enable_gl(struct headless_output *output)
static int
headless_output_enable_pixman(struct headless_output *output)
{
const struct pixel_format_info *pfmt;
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
output->image_buf = malloc(output->base.current_mode->width *
output->base.current_mode->height * 4);
if (!output->image_buf)
return -1;
pfmt = pixel_format_get_info(headless_formats[0]);
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
output->base.current_mode->width,
output->base.current_mode->height,
output->image_buf,
output->base.current_mode->width * 4);
output->image =
pixman_image_create_bits_no_clear(pfmt->pixman_format,
output->base.current_mode->width,
output->base.current_mode->height,
NULL, 0);
if (!output->image)
return -1;
if (pixman_renderer_output_create(&output->base, &options) < 0)
goto err_renderer;
......@@ -257,7 +256,6 @@ headless_output_enable_pixman(struct headless_output *output)
err_renderer:
pixman_image_unref(output->image);
free(output->image_buf);
return -1;
}
......
......@@ -831,64 +831,54 @@ wayland_output_init_pixman_renderer(struct wayland_output *output)
static void
wayland_output_resize_surface(struct wayland_output *output)
{
struct wayland_backend *b =
to_wayland_backend(output->base.compositor);
int32_t ix, iy, iwidth, iheight;
int32_t width, height;
struct wayland_backend *b = to_wayland_backend(output->base.compositor);
/* Defaults for without frame: */
struct weston_size fb_size = {
.width = output->base.current_mode->width,
.height = output->base.current_mode->height
};
struct weston_geometry area = {
.x = 0,
.y = 0,
.width = fb_size.width,
.height = fb_size.height
};
struct weston_geometry inp = area;
struct weston_geometry opa = area;
struct wl_region *region;
width = output->base.current_mode->width;
height = output->base.current_mode->height;
if (output->frame) {
frame_resize_inside(output->frame, width, height);
frame_input_rect(output->frame, &ix, &iy, &iwidth, &iheight);
region = wl_compositor_create_region(b->parent.compositor);
wl_region_add(region, ix, iy, iwidth, iheight);
wl_surface_set_input_region(output->parent.surface, region);
wl_region_destroy(region);
if (output->parent.xdg_surface) {
xdg_surface_set_window_geometry(output->parent.xdg_surface,
ix,
iy,
iwidth,
iheight);
}
frame_resize_inside(output->frame, area.width, area.height);
frame_interior(output->frame, &area.x, &area.y, NULL, NULL);
fb_size.width = frame_width(output->frame);
fb_size.height = frame_height(output->frame);
frame_opaque_rect(output->frame, &ix, &iy, &iwidth, &iheight);
region = wl_compositor_create_region(b->parent.compositor);
wl_region_add(region, ix, iy, iwidth, iheight);
wl_surface_set_opaque_region(output->parent.surface, region);
wl_region_destroy(region);
frame_input_rect(output->frame, &inp.x, &inp.y,
&inp.width, &inp.height);
frame_opaque_rect(output->frame, &opa.x, &opa.y,
&opa.width, &opa.height);
}
width = frame_width(output->frame);
height = frame_height(output->frame);
} else {
region = wl_compositor_create_region(b->parent.compositor);
wl_region_add(region, 0, 0, width, height);
wl_surface_set_input_region(output->parent.surface, region);
wl_region_destroy(region);
region = wl_compositor_create_region(b->parent.compositor);
wl_region_add(region, 0, 0, width, height);
wl_surface_set_opaque_region(output->parent.surface, region);
wl_region_destroy(region);
if (output->parent.xdg_surface) {
xdg_surface_set_window_geometry(output->parent.xdg_surface,
0,
0,
width,
height);
}
region = wl_compositor_create_region(b->parent.compositor);
wl_region_add(region, inp.x, inp.y, inp.width, inp.height);
wl_surface_set_input_region(output->parent.surface, region);
wl_region_destroy(region);
if (output->parent.xdg_surface) {
xdg_surface_set_window_geometry(output->parent.xdg_surface,
inp.x, inp.y,
inp.width, inp.height);
}
region = wl_compositor_create_region(b->parent.compositor);
wl_region_add(region, opa.x, opa.y, opa.width, opa.height);
wl_surface_set_opaque_region(output->parent.surface, region);
wl_region_destroy(region);
#ifdef ENABLE_EGL
if (output->gl.egl_window) {
wl_egl_window_resize(output->gl.egl_window,
width, height, 0, 0);
fb_size.width, fb_size.height, 0, 0);
/* These will need to be re-created due to the resize */
gl_renderer->output_set_border(&output->base,
......
......@@ -945,6 +945,7 @@ static int
x11_output_enable(struct weston_output *base)
{
struct x11_output *output = to_x11_output(base);
const struct weston_mode *mode = output->base.current_mode;
struct x11_backend *b;
assert(output);
......@@ -988,8 +989,7 @@ x11_output_enable(struct weston_output *base)
output->window,
screen->root,
0, 0,
output->base.current_mode->width,
output->base.current_mode->height,
mode->width, mode->height,
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual,
......@@ -1054,8 +1054,7 @@ x11_output_enable(struct weston_output *base)
.use_shadow = true,
};
if (x11_output_init_shm(b, output,
output->base.current_mode->width,
output->base.current_mode->height) < 0) {
mode->width, mode->height) < 0) {
weston_log("Failed to initialize SHM for the X11 output\n");
goto err;
}
......@@ -1096,9 +1095,7 @@ x11_output_enable(struct weston_output *base)
wl_event_loop_add_timer(loop, finish_frame_handler, output);
weston_log("x11 output %dx%d, window id %d\n",
output->base.current_mode->width,
output->base.current_mode->height,
output->window);
mode->width, mode->height, output->window);
return 0;
......
......@@ -41,7 +41,6 @@
#include <linux/input.h>
struct pixman_output_state {
void *shadow_buffer;
pixman_image_t *shadow_image;
pixman_image_t *hw_buffer;
pixman_region32_t *hw_extra_damage;
......@@ -951,19 +950,11 @@ pixman_renderer_output_create(struct weston_output *output,
w = output->current_mode->width;
h = output->current_mode->height;
po->shadow_buffer = malloc(w * h * 4);
if (!po->shadow_buffer) {
free(po);
return -1;
}
po->shadow_image =
pixman_image_create_bits(PIXMAN_x8r8g8b8, w, h,
po->shadow_buffer, w * 4);
pixman_image_create_bits_no_clear(PIXMAN_x8r8g8b8,
w, h, NULL, 0);
if (!po->shadow_image) {
free(po->shadow_buffer);
free(po);
return -1;
}
......@@ -985,9 +976,6 @@ pixman_renderer_output_destroy(struct weston_output *output)
if (po->hw_buffer)
pixman_image_unref(po->hw_buffer);
free(po->shadow_buffer);
po->shadow_buffer = NULL;
po->shadow_image = NULL;
po->hw_buffer = NULL;
......