output: refactor backend API
This updates the backend part of the output API. This is mostly renaming: make_current becomes attach_render and swap_buffers becomes commit. This also fixes the RDP backend to support NULL damage.
This commit is contained in:
parent
23e37e7b1d
commit
9a0f8a194c
|
@ -238,14 +238,13 @@ static struct wlr_drm_connector *get_drm_connector_from_output(
|
||||||
return (struct wlr_drm_connector *)wlr_output;
|
return (struct wlr_drm_connector *)wlr_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool drm_connector_make_current(struct wlr_output *output,
|
static bool drm_connector_attach_render(struct wlr_output *output,
|
||||||
int *buffer_age) {
|
int *buffer_age) {
|
||||||
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
||||||
return make_drm_surface_current(&conn->crtc->primary->surf, buffer_age);
|
return make_drm_surface_current(&conn->crtc->primary->surf, buffer_age);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool drm_connector_swap_buffers(struct wlr_output *output,
|
static bool drm_connector_commit(struct wlr_output *output) {
|
||||||
pixman_region32_t *damage) {
|
|
||||||
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
||||||
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
|
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
|
||||||
if (!drm->session->active) {
|
if (!drm->session->active) {
|
||||||
|
@ -258,6 +257,11 @@ static bool drm_connector_swap_buffers(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
struct wlr_drm_plane *plane = crtc->primary;
|
struct wlr_drm_plane *plane = crtc->primary;
|
||||||
|
|
||||||
|
pixman_region32_t *damage = NULL;
|
||||||
|
if (output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
|
||||||
|
damage = &output->pending.damage;
|
||||||
|
}
|
||||||
|
|
||||||
struct gbm_bo *bo = swap_drm_surface_buffers(&plane->surf, damage);
|
struct gbm_bo *bo = swap_drm_surface_buffers(&plane->surf, damage);
|
||||||
if (drm->parent) {
|
if (drm->parent) {
|
||||||
bo = copy_drm_surface_mgpu(&plane->mgpu_surf, bo);
|
bo = copy_drm_surface_mgpu(&plane->mgpu_surf, bo);
|
||||||
|
@ -334,7 +338,7 @@ bool set_drm_connector_gamma(struct wlr_output *output, size_t size,
|
||||||
|
|
||||||
bool ok = drm->iface->crtc_set_gamma(drm, conn->crtc, size, _r, _g, _b);
|
bool ok = drm->iface->crtc_set_gamma(drm, conn->crtc, size, _r, _g, _b);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
wlr_output_update_needs_swap(output);
|
wlr_output_update_needs_commit(output);
|
||||||
|
|
||||||
free(conn->crtc->gamma_table);
|
free(conn->crtc->gamma_table);
|
||||||
conn->crtc->gamma_table = gamma_table;
|
conn->crtc->gamma_table = gamma_table;
|
||||||
|
@ -673,7 +677,7 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_output_update_needs_swap(output);
|
wlr_output_update_needs_commit(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!update_texture) {
|
if (!update_texture) {
|
||||||
|
@ -733,7 +737,7 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo);
|
bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
wlr_output_update_needs_swap(output);
|
wlr_output_update_needs_commit(output);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -770,7 +774,7 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
|
||||||
|
|
||||||
bool ok = drm->iface->crtc_move_cursor(drm, conn->crtc, box.x, box.y);
|
bool ok = drm->iface->crtc_move_cursor(drm, conn->crtc, box.x, box.y);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
wlr_output_update_needs_swap(output);
|
wlr_output_update_needs_commit(output);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -832,8 +836,8 @@ static const struct wlr_output_impl output_impl = {
|
||||||
.set_cursor = drm_connector_set_cursor,
|
.set_cursor = drm_connector_set_cursor,
|
||||||
.move_cursor = drm_connector_move_cursor,
|
.move_cursor = drm_connector_move_cursor,
|
||||||
.destroy = drm_connector_destroy,
|
.destroy = drm_connector_destroy,
|
||||||
.make_current = drm_connector_make_current,
|
.attach_render = drm_connector_attach_render,
|
||||||
.swap_buffers = drm_connector_swap_buffers,
|
.commit = drm_connector_commit,
|
||||||
.set_gamma = set_drm_connector_gamma,
|
.set_gamma = set_drm_connector_gamma,
|
||||||
.get_gamma_size = drm_connector_get_gamma_size,
|
.get_gamma_size = drm_connector_get_gamma_size,
|
||||||
.export_dmabuf = drm_connector_export_dmabuf,
|
.export_dmabuf = drm_connector_export_dmabuf,
|
||||||
|
@ -1431,7 +1435,7 @@ static void drm_connector_cleanup(struct wlr_drm_connector *conn) {
|
||||||
wl_event_source_remove(conn->output.idle_frame);
|
wl_event_source_remove(conn->output.idle_frame);
|
||||||
conn->output.idle_frame = NULL;
|
conn->output.idle_frame = NULL;
|
||||||
}
|
}
|
||||||
conn->output.needs_swap = false;
|
conn->output.needs_commit = false;
|
||||||
conn->output.frame_pending = false;
|
conn->output.frame_pending = false;
|
||||||
|
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
|
|
|
@ -56,15 +56,15 @@ static void output_transform(struct wlr_output *wlr_output,
|
||||||
output->wlr_output.transform = transform;
|
output->wlr_output.transform = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_make_current(struct wlr_output *wlr_output, int *buffer_age) {
|
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
|
int *buffer_age) {
|
||||||
struct wlr_headless_output *output =
|
struct wlr_headless_output *output =
|
||||||
headless_output_from_output(wlr_output);
|
headless_output_from_output(wlr_output);
|
||||||
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||||
buffer_age);
|
buffer_age);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_swap_buffers(struct wlr_output *wlr_output,
|
static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
pixman_region32_t *damage) {
|
|
||||||
// Nothing needs to be done for pbuffers
|
// Nothing needs to be done for pbuffers
|
||||||
wlr_output_send_present(wlr_output, NULL);
|
wlr_output_send_present(wlr_output, NULL);
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,8 +86,8 @@ static const struct wlr_output_impl output_impl = {
|
||||||
.set_custom_mode = output_set_custom_mode,
|
.set_custom_mode = output_set_custom_mode,
|
||||||
.transform = output_transform,
|
.transform = output_transform,
|
||||||
.destroy = output_destroy,
|
.destroy = output_destroy,
|
||||||
.make_current = output_make_current,
|
.attach_render = output_attach_render,
|
||||||
.swap_buffers = output_swap_buffers,
|
.commit = output_commit,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool wlr_output_is_headless(struct wlr_output *wlr_output) {
|
bool wlr_output_is_headless(struct wlr_output *wlr_output) {
|
||||||
|
|
|
@ -23,12 +23,12 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_make_current(struct wlr_output *wlr_output, int *buffer_age) {
|
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
|
int *buffer_age) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_swap_buffers(struct wlr_output *wlr_output,
|
static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
pixman_region32_t *damage) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ static const struct wlr_output_impl output_impl = {
|
||||||
.transform = output_transform,
|
.transform = output_transform,
|
||||||
.set_custom_mode = output_set_custom_mode,
|
.set_custom_mode = output_set_custom_mode,
|
||||||
.destroy = output_destroy,
|
.destroy = output_destroy,
|
||||||
.make_current = output_make_current,
|
.attach_render = output_attach_render,
|
||||||
.swap_buffers = output_swap_buffers,
|
.commit = output_commit,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool wlr_output_is_noop(struct wlr_output *wlr_output) {
|
bool wlr_output_is_noop(struct wlr_output *wlr_output) {
|
||||||
|
|
|
@ -69,7 +69,8 @@ static void output_transform(struct wlr_output *wlr_output,
|
||||||
output->wlr_output.transform = transform;
|
output->wlr_output.transform = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_make_current(struct wlr_output *wlr_output, int *buffer_age) {
|
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
|
int *buffer_age) {
|
||||||
struct wlr_rdp_output *output =
|
struct wlr_rdp_output *output =
|
||||||
rdp_output_from_output(wlr_output);
|
rdp_output_from_output(wlr_output);
|
||||||
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||||
|
@ -169,31 +170,39 @@ static bool nsc_swap_buffers(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_swap_buffers(
|
static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
struct wlr_output *wlr_output, pixman_region32_t *damage) {
|
|
||||||
if (!pixman_region32_not_empty(damage)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_rdp_output *output =
|
struct wlr_rdp_output *output =
|
||||||
rdp_output_from_output(wlr_output);
|
rdp_output_from_output(wlr_output);
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
// Update shadow buffer
|
pixman_region32_t output_region;
|
||||||
|
pixman_region32_init(&output_region);
|
||||||
|
pixman_region32_union_rect(&output_region, &output_region,
|
||||||
|
0, 0, wlr_output->width, wlr_output->height);
|
||||||
|
|
||||||
|
pixman_region32_t *damage = &output_region;
|
||||||
|
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
|
||||||
|
damage = &wlr_output->pending.damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = damage->extents.x1;
|
||||||
|
int y = damage->extents.y1;
|
||||||
int width = damage->extents.x2 - damage->extents.x1;
|
int width = damage->extents.x2 - damage->extents.x1;
|
||||||
int height = damage->extents.y2 - damage->extents.y1;
|
int height = damage->extents.y2 - damage->extents.y1;
|
||||||
|
|
||||||
|
// Update shadow buffer
|
||||||
struct wlr_renderer *renderer =
|
struct wlr_renderer *renderer =
|
||||||
wlr_backend_get_renderer(&output->backend->backend);
|
wlr_backend_get_renderer(&output->backend->backend);
|
||||||
// TODO performance: add support for flags
|
// TODO performance: add support for flags
|
||||||
if (!wlr_renderer_read_pixels(renderer, WL_SHM_FORMAT_XRGB8888,
|
ret = wlr_renderer_read_pixels(renderer, WL_SHM_FORMAT_XRGB8888,
|
||||||
NULL, pixman_image_get_stride(output->shadow_surface),
|
NULL, pixman_image_get_stride(output->shadow_surface),
|
||||||
width, height, damage->extents.x1, damage->extents.y1,
|
width, height, x, y, x, y,
|
||||||
damage->extents.x1, damage->extents.y1,
|
pixman_image_get_data(output->shadow_surface));
|
||||||
pixman_image_get_data(output->shadow_surface))) {
|
if (!ret) {
|
||||||
return false;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send along to clients
|
// Send along to clients
|
||||||
bool ret = false;
|
|
||||||
rdpSettings *settings = output->context->peer->settings;
|
rdpSettings *settings = output->context->peer->settings;
|
||||||
if (settings->RemoteFxCodec) {
|
if (settings->RemoteFxCodec) {
|
||||||
ret = rfx_swap_buffers(output, damage);
|
ret = rfx_swap_buffers(output, damage);
|
||||||
|
@ -202,8 +211,16 @@ static bool output_swap_buffers(
|
||||||
} else {
|
} else {
|
||||||
// This would perform like ass so why bother
|
// This would perform like ass so why bother
|
||||||
wlr_log(WLR_ERROR, "Raw updates are not supported; use rfx or nsc");
|
wlr_log(WLR_ERROR, "Raw updates are not supported; use rfx or nsc");
|
||||||
|
ret = false;
|
||||||
}
|
}
|
||||||
|
if (!ret) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
wlr_output_send_present(wlr_output, NULL);
|
wlr_output_send_present(wlr_output, NULL);
|
||||||
|
|
||||||
|
out:
|
||||||
|
pixman_region32_fini(&output_region);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,8 +241,8 @@ static const struct wlr_output_impl output_impl = {
|
||||||
.set_custom_mode = output_set_custom_mode,
|
.set_custom_mode = output_set_custom_mode,
|
||||||
.transform = output_transform,
|
.transform = output_transform,
|
||||||
.destroy = output_destroy,
|
.destroy = output_destroy,
|
||||||
.make_current = output_make_current,
|
.attach_render = output_attach_render,
|
||||||
.swap_buffers = output_swap_buffers,
|
.commit = output_commit,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool wlr_output_is_rdp(struct wlr_output *wlr_output) {
|
bool wlr_output_is_rdp(struct wlr_output *wlr_output) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_make_current(struct wlr_output *wlr_output,
|
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
int *buffer_age) {
|
int *buffer_age) {
|
||||||
struct wlr_wl_output *output =
|
struct wlr_wl_output *output =
|
||||||
get_wl_output_from_output(wlr_output);
|
get_wl_output_from_output(wlr_output);
|
||||||
|
@ -58,8 +58,7 @@ static bool output_make_current(struct wlr_output *wlr_output,
|
||||||
buffer_age);
|
buffer_age);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_swap_buffers(struct wlr_output *wlr_output,
|
static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
pixman_region32_t *damage) {
|
|
||||||
struct wlr_wl_output *output =
|
struct wlr_wl_output *output =
|
||||||
get_wl_output_from_output(wlr_output);
|
get_wl_output_from_output(wlr_output);
|
||||||
|
|
||||||
|
@ -71,6 +70,11 @@ static bool output_swap_buffers(struct wlr_output *wlr_output,
|
||||||
output->frame_callback = wl_surface_frame(output->surface);
|
output->frame_callback = wl_surface_frame(output->surface);
|
||||||
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
||||||
|
|
||||||
|
pixman_region32_t *damage = NULL;
|
||||||
|
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
|
||||||
|
damage = &wlr_output->pending.damage;
|
||||||
|
}
|
||||||
|
|
||||||
if (!wlr_egl_swap_buffers(&output->backend->egl,
|
if (!wlr_egl_swap_buffers(&output->backend->egl,
|
||||||
output->egl_surface, damage)) {
|
output->egl_surface, damage)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -220,8 +224,8 @@ static const struct wlr_output_impl output_impl = {
|
||||||
.set_custom_mode = output_set_custom_mode,
|
.set_custom_mode = output_set_custom_mode,
|
||||||
.transform = output_transform,
|
.transform = output_transform,
|
||||||
.destroy = output_destroy,
|
.destroy = output_destroy,
|
||||||
.make_current = output_make_current,
|
.attach_render = output_attach_render,
|
||||||
.swap_buffers = output_swap_buffers,
|
.commit = output_commit,
|
||||||
.set_cursor = output_set_cursor,
|
.set_cursor = output_set_cursor,
|
||||||
.move_cursor = output_move_cursor,
|
.move_cursor = output_move_cursor,
|
||||||
.schedule_frame = output_schedule_frame,
|
.schedule_frame = output_schedule_frame,
|
||||||
|
|
|
@ -46,7 +46,7 @@ static void handle_x11_event(struct wlr_x11_backend *x11,
|
||||||
struct wlr_x11_output *output =
|
struct wlr_x11_output *output =
|
||||||
get_x11_output_from_window_id(x11, ev->window);
|
get_x11_output_from_window_id(x11, ev->window);
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
wlr_output_update_needs_swap(&output->wlr_output);
|
wlr_output_update_needs_commit(&output->wlr_output);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_make_current(struct wlr_output *wlr_output,
|
static bool output_attach_render(struct wlr_output *wlr_output,
|
||||||
int *buffer_age) {
|
int *buffer_age) {
|
||||||
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
@ -103,11 +103,15 @@ static bool output_make_current(struct wlr_output *wlr_output,
|
||||||
return wlr_egl_make_current(&x11->egl, output->surf, buffer_age);
|
return wlr_egl_make_current(&x11->egl, output->surf, buffer_age);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_swap_buffers(struct wlr_output *wlr_output,
|
static bool output_commit(struct wlr_output *wlr_output) {
|
||||||
pixman_region32_t *damage) {
|
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
||||||
struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
|
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
|
||||||
|
pixman_region32_t *damage = NULL;
|
||||||
|
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
|
||||||
|
damage = &wlr_output->pending.damage;
|
||||||
|
}
|
||||||
|
|
||||||
if (!wlr_egl_swap_buffers(&x11->egl, output->surf, damage)) {
|
if (!wlr_egl_swap_buffers(&x11->egl, output->surf, damage)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -120,8 +124,8 @@ static const struct wlr_output_impl output_impl = {
|
||||||
.set_custom_mode = output_set_custom_mode,
|
.set_custom_mode = output_set_custom_mode,
|
||||||
.transform = output_transform,
|
.transform = output_transform,
|
||||||
.destroy = output_destroy,
|
.destroy = output_destroy,
|
||||||
.make_current = output_make_current,
|
.attach_render = output_attach_render,
|
||||||
.swap_buffers = output_swap_buffers,
|
.commit = output_commit,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
|
|
|
@ -26,8 +26,8 @@ struct wlr_output_impl {
|
||||||
int32_t hotspot_x, int32_t hotspot_y, bool update_texture);
|
int32_t hotspot_x, int32_t hotspot_y, bool update_texture);
|
||||||
bool (*move_cursor)(struct wlr_output *output, int x, int y);
|
bool (*move_cursor)(struct wlr_output *output, int x, int y);
|
||||||
void (*destroy)(struct wlr_output *output);
|
void (*destroy)(struct wlr_output *output);
|
||||||
bool (*make_current)(struct wlr_output *output, int *buffer_age);
|
bool (*attach_render)(struct wlr_output *output, int *buffer_age);
|
||||||
bool (*swap_buffers)(struct wlr_output *output, pixman_region32_t *damage);
|
bool (*commit)(struct wlr_output *output);
|
||||||
bool (*set_gamma)(struct wlr_output *output, size_t size,
|
bool (*set_gamma)(struct wlr_output *output, size_t size,
|
||||||
const uint16_t *r, const uint16_t *g, const uint16_t *b);
|
const uint16_t *r, const uint16_t *g, const uint16_t *b);
|
||||||
size_t (*get_gamma_size)(struct wlr_output *output);
|
size_t (*get_gamma_size)(struct wlr_output *output);
|
||||||
|
@ -43,7 +43,7 @@ void wlr_output_update_mode(struct wlr_output *output,
|
||||||
void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width,
|
void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width,
|
||||||
int32_t height, int32_t refresh);
|
int32_t height, int32_t refresh);
|
||||||
void wlr_output_update_enabled(struct wlr_output *output, bool enabled);
|
void wlr_output_update_enabled(struct wlr_output *output, bool enabled);
|
||||||
void wlr_output_update_needs_swap(struct wlr_output *output);
|
void wlr_output_update_needs_commit(struct wlr_output *output);
|
||||||
void wlr_output_damage_whole(struct wlr_output *output);
|
void wlr_output_damage_whole(struct wlr_output *output);
|
||||||
void wlr_output_send_frame(struct wlr_output *output);
|
void wlr_output_send_frame(struct wlr_output *output);
|
||||||
void wlr_output_send_present(struct wlr_output *output,
|
void wlr_output_send_present(struct wlr_output *output,
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct wlr_output {
|
||||||
enum wl_output_subpixel subpixel;
|
enum wl_output_subpixel subpixel;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
|
|
||||||
bool needs_swap;
|
bool needs_commit;
|
||||||
// damage for cursors and fullscreen surface, in output-local coordinates
|
// damage for cursors and fullscreen surface, in output-local coordinates
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
bool frame_pending;
|
bool frame_pending;
|
||||||
|
@ -110,7 +110,7 @@ struct wlr_output {
|
||||||
struct wl_signal frame;
|
struct wl_signal frame;
|
||||||
// Emitted when buffers need to be swapped (because software cursors or
|
// Emitted when buffers need to be swapped (because software cursors or
|
||||||
// fullscreen damage or because of backend-specific logic)
|
// fullscreen damage or because of backend-specific logic)
|
||||||
struct wl_signal needs_swap;
|
struct wl_signal needs_commit;
|
||||||
// Emitted right before buffer swap
|
// Emitted right before buffer swap
|
||||||
struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
|
struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
|
||||||
// Emitted right after the buffer has been presented to the user
|
// Emitted right after the buffer has been presented to the user
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct wlr_output_damage {
|
||||||
struct wl_listener output_mode;
|
struct wl_listener output_mode;
|
||||||
struct wl_listener output_transform;
|
struct wl_listener output_transform;
|
||||||
struct wl_listener output_scale;
|
struct wl_listener output_scale;
|
||||||
struct wl_listener output_needs_swap;
|
struct wl_listener output_needs_commit;
|
||||||
struct wl_listener output_frame;
|
struct wl_listener output_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||||
const struct wlr_output_impl *impl, struct wl_display *display) {
|
const struct wlr_output_impl *impl, struct wl_display *display) {
|
||||||
assert(impl->make_current && impl->swap_buffers && impl->transform);
|
assert(impl->attach_render && impl->commit && impl->transform);
|
||||||
if (impl->set_cursor || impl->move_cursor) {
|
if (impl->set_cursor || impl->move_cursor) {
|
||||||
assert(impl->set_cursor && impl->move_cursor);
|
assert(impl->set_cursor && impl->move_cursor);
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||||
wl_list_init(&output->cursors);
|
wl_list_init(&output->cursors);
|
||||||
wl_list_init(&output->resources);
|
wl_list_init(&output->resources);
|
||||||
wl_signal_init(&output->events.frame);
|
wl_signal_init(&output->events.frame);
|
||||||
wl_signal_init(&output->events.needs_swap);
|
wl_signal_init(&output->events.needs_commit);
|
||||||
wl_signal_init(&output->events.swap_buffers);
|
wl_signal_init(&output->events.swap_buffers);
|
||||||
wl_signal_init(&output->events.present);
|
wl_signal_init(&output->events.present);
|
||||||
wl_signal_init(&output->events.enable);
|
wl_signal_init(&output->events.enable);
|
||||||
|
@ -363,7 +363,7 @@ struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_attach_render(struct wlr_output *output, int *buffer_age) {
|
bool wlr_output_attach_render(struct wlr_output *output, int *buffer_age) {
|
||||||
if (!output->impl->make_current(output, buffer_age)) {
|
if (!output->impl->attach_render(output, buffer_age)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ bool wlr_output_attach_render(struct wlr_output *output, int *buffer_age) {
|
||||||
|
|
||||||
bool wlr_output_preferred_read_format(struct wlr_output *output,
|
bool wlr_output_preferred_read_format(struct wlr_output *output,
|
||||||
enum wl_shm_format *fmt) {
|
enum wl_shm_format *fmt) {
|
||||||
if (!output->impl->make_current(output, NULL)) {
|
if (!output->impl->attach_render(output, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,11 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
output->idle_frame = NULL;
|
output->idle_frame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
if (!(output->pending.committed & WLR_OUTPUT_STATE_BUFFER)) {
|
||||||
|
wlr_log(WLR_ERROR, "Tried to commit without attaching a buffer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
@ -423,7 +427,7 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
};
|
};
|
||||||
wlr_signal_emit_safe(&output->events.swap_buffers, &event);
|
wlr_signal_emit_safe(&output->events.swap_buffers, &event);
|
||||||
|
|
||||||
if (!output->impl->swap_buffers(output, damage)) {
|
if (!output->impl->commit(output)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,14 +440,8 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output->frame_pending = true;
|
output->frame_pending = true;
|
||||||
output->needs_swap = false;
|
output->needs_commit = false;
|
||||||
output_state_clear(&output->pending);
|
output_state_clear(&output->pending);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_ERROR, "Tried to commit without attaching a buffer");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,9 +520,9 @@ bool wlr_output_export_dmabuf(struct wlr_output *output,
|
||||||
return output->impl->export_dmabuf(output, attribs);
|
return output->impl->export_dmabuf(output, attribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_update_needs_swap(struct wlr_output *output) {
|
void wlr_output_update_needs_commit(struct wlr_output *output) {
|
||||||
output->needs_swap = true;
|
output->needs_commit = true;
|
||||||
wlr_signal_emit_safe(&output->events.needs_swap, output);
|
wlr_signal_emit_safe(&output->events.needs_commit, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_damage_whole(struct wlr_output *output) {
|
void wlr_output_damage_whole(struct wlr_output *output) {
|
||||||
|
@ -533,7 +531,7 @@ void wlr_output_damage_whole(struct wlr_output *output) {
|
||||||
|
|
||||||
pixman_region32_union_rect(&output->damage, &output->damage, 0, 0,
|
pixman_region32_union_rect(&output->damage, &output->damage, 0, 0,
|
||||||
width, height);
|
width, height);
|
||||||
wlr_output_update_needs_swap(output);
|
wlr_output_update_needs_commit(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource) {
|
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource) {
|
||||||
|
@ -679,7 +677,7 @@ static void output_cursor_damage_whole(struct wlr_output_cursor *cursor) {
|
||||||
output_cursor_get_box(cursor, &box);
|
output_cursor_get_box(cursor, &box);
|
||||||
pixman_region32_union_rect(&cursor->output->damage, &cursor->output->damage,
|
pixman_region32_union_rect(&cursor->output->damage, &cursor->output->damage,
|
||||||
box.x, box.y, box.width, box.height);
|
box.x, box.y, box.width, box.height);
|
||||||
wlr_output_update_needs_swap(cursor->output);
|
wlr_output_update_needs_commit(cursor->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_cursor_reset(struct wlr_output_cursor *cursor) {
|
static void output_cursor_reset(struct wlr_output_cursor *cursor) {
|
||||||
|
|
|
@ -31,9 +31,10 @@ static void output_handle_scale(struct wl_listener *listener, void *data) {
|
||||||
wlr_output_damage_add_whole(output_damage);
|
wlr_output_damage_add_whole(output_damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_handle_needs_swap(struct wl_listener *listener, void *data) {
|
static void output_handle_needs_commit(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
struct wlr_output_damage *output_damage =
|
struct wlr_output_damage *output_damage =
|
||||||
wl_container_of(listener, output_damage, output_needs_swap);
|
wl_container_of(listener, output_damage, output_needs_commit);
|
||||||
pixman_region32_union(&output_damage->current, &output_damage->current,
|
pixman_region32_union(&output_damage->current, &output_damage->current,
|
||||||
&output_damage->output->damage);
|
&output_damage->output->damage);
|
||||||
wlr_output_schedule_frame(output_damage->output);
|
wlr_output_schedule_frame(output_damage->output);
|
||||||
|
@ -75,8 +76,8 @@ struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output) {
|
||||||
output_damage->output_transform.notify = output_handle_transform;
|
output_damage->output_transform.notify = output_handle_transform;
|
||||||
wl_signal_add(&output->events.scale, &output_damage->output_scale);
|
wl_signal_add(&output->events.scale, &output_damage->output_scale);
|
||||||
output_damage->output_scale.notify = output_handle_scale;
|
output_damage->output_scale.notify = output_handle_scale;
|
||||||
wl_signal_add(&output->events.needs_swap, &output_damage->output_needs_swap);
|
wl_signal_add(&output->events.needs_commit, &output_damage->output_needs_commit);
|
||||||
output_damage->output_needs_swap.notify = output_handle_needs_swap;
|
output_damage->output_needs_commit.notify = output_handle_needs_commit;
|
||||||
wl_signal_add(&output->events.frame, &output_damage->output_frame);
|
wl_signal_add(&output->events.frame, &output_damage->output_frame);
|
||||||
output_damage->output_frame.notify = output_handle_frame;
|
output_damage->output_frame.notify = output_handle_frame;
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ void wlr_output_damage_destroy(struct wlr_output_damage *output_damage) {
|
||||||
wl_list_remove(&output_damage->output_mode.link);
|
wl_list_remove(&output_damage->output_mode.link);
|
||||||
wl_list_remove(&output_damage->output_transform.link);
|
wl_list_remove(&output_damage->output_transform.link);
|
||||||
wl_list_remove(&output_damage->output_scale.link);
|
wl_list_remove(&output_damage->output_scale.link);
|
||||||
wl_list_remove(&output_damage->output_needs_swap.link);
|
wl_list_remove(&output_damage->output_needs_commit.link);
|
||||||
wl_list_remove(&output_damage->output_frame.link);
|
wl_list_remove(&output_damage->output_frame.link);
|
||||||
pixman_region32_fini(&output_damage->current);
|
pixman_region32_fini(&output_damage->current);
|
||||||
for (size_t i = 0; i < WLR_OUTPUT_DAMAGE_PREVIOUS_LEN; ++i) {
|
for (size_t i = 0; i < WLR_OUTPUT_DAMAGE_PREVIOUS_LEN; ++i) {
|
||||||
|
@ -102,7 +103,7 @@ void wlr_output_damage_destroy(struct wlr_output_damage *output_damage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage,
|
bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage,
|
||||||
bool *needs_swap, pixman_region32_t *damage) {
|
bool *needs_commit, pixman_region32_t *damage) {
|
||||||
struct wlr_output *output = output_damage->output;
|
struct wlr_output *output = output_damage->output;
|
||||||
|
|
||||||
int buffer_age = -1;
|
int buffer_age = -1;
|
||||||
|
@ -136,7 +137,7 @@ bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*needs_swap = output->needs_swap || pixman_region32_not_empty(damage);
|
*needs_commit = output->needs_commit || pixman_region32_not_empty(damage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ static void frame_handle_copy(struct wl_client *client,
|
||||||
wl_resource_add_destroy_listener(buffer_resource, &frame->buffer_destroy);
|
wl_resource_add_destroy_listener(buffer_resource, &frame->buffer_destroy);
|
||||||
frame->buffer_destroy.notify = frame_handle_buffer_destroy;
|
frame->buffer_destroy.notify = frame_handle_buffer_destroy;
|
||||||
|
|
||||||
// Schedule a buffer swap
|
// Schedule a buffer commit
|
||||||
output->needs_swap = true;
|
output->needs_commit = true;
|
||||||
wlr_output_schedule_frame(output);
|
wlr_output_schedule_frame(output);
|
||||||
|
|
||||||
if (frame->overlay_cursor) {
|
if (frame->overlay_cursor) {
|
||||||
|
|
|
@ -145,8 +145,8 @@ static void screenshooter_shoot(struct wl_client *client,
|
||||||
state->frame_listener.notify = output_handle_frame;
|
state->frame_listener.notify = output_handle_frame;
|
||||||
wl_signal_add(&output->events.swap_buffers, &state->frame_listener);
|
wl_signal_add(&output->events.swap_buffers, &state->frame_listener);
|
||||||
|
|
||||||
// Schedule a buffer swap
|
// Schedule a buffer commit
|
||||||
output->needs_swap = true;
|
output->needs_commit = true;
|
||||||
wlr_output_schedule_frame(output);
|
wlr_output_schedule_frame(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue