aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-04-23 19:26:21 +0300
committerDrew DeVault <sir@cmpwn.com>2019-04-23 14:34:30 -0600
commit9a0f8a194caa35173a7f590208a64a5526290935 (patch)
tree2acebd17a1de27d3d616b2bd13a65301cff9fca5 /backend
parent23e37e7b1d8004fb5361c147239d2e628efbd5e8 (diff)
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.
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/drm.c24
-rw-r--r--backend/headless/output.c10
-rw-r--r--backend/noop/output.c10
-rw-r--r--backend/rdp/output.c51
-rw-r--r--backend/wayland/output.c14
-rw-r--r--backend/x11/backend.c2
-rw-r--r--backend/x11/output.c16
7 files changed, 78 insertions, 49 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index f86f63b8..f97166f1 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -238,14 +238,13 @@ static struct wlr_drm_connector *get_drm_connector_from_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) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
return make_drm_surface_current(&conn->crtc->primary->surf, buffer_age);
}
-static bool drm_connector_swap_buffers(struct wlr_output *output,
- pixman_region32_t *damage) {
+static bool drm_connector_commit(struct wlr_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);
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;
+ 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);
if (drm->parent) {
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);
if (ok) {
- wlr_output_update_needs_swap(output);
+ wlr_output_update_needs_commit(output);
free(conn->crtc->gamma_table);
conn->crtc->gamma_table = gamma_table;
@@ -673,7 +677,7 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
return false;
}
- wlr_output_update_needs_swap(output);
+ wlr_output_update_needs_commit(output);
}
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);
if (ok) {
- wlr_output_update_needs_swap(output);
+ wlr_output_update_needs_commit(output);
}
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);
if (ok) {
- wlr_output_update_needs_swap(output);
+ wlr_output_update_needs_commit(output);
}
return ok;
}
@@ -832,8 +836,8 @@ static const struct wlr_output_impl output_impl = {
.set_cursor = drm_connector_set_cursor,
.move_cursor = drm_connector_move_cursor,
.destroy = drm_connector_destroy,
- .make_current = drm_connector_make_current,
- .swap_buffers = drm_connector_swap_buffers,
+ .attach_render = drm_connector_attach_render,
+ .commit = drm_connector_commit,
.set_gamma = set_drm_connector_gamma,
.get_gamma_size = drm_connector_get_gamma_size,
.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);
conn->output.idle_frame = NULL;
}
- conn->output.needs_swap = false;
+ conn->output.needs_commit = false;
conn->output.frame_pending = false;
/* Fallthrough */
diff --git a/backend/headless/output.c b/backend/headless/output.c
index 6d3b6f96..0073cb33 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -56,15 +56,15 @@ static void output_transform(struct wlr_output *wlr_output,
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 =
headless_output_from_output(wlr_output);
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
buffer_age);
}
-static bool output_swap_buffers(struct wlr_output *wlr_output,
- pixman_region32_t *damage) {
+static bool output_commit(struct wlr_output *wlr_output) {
// Nothing needs to be done for pbuffers
wlr_output_send_present(wlr_output, NULL);
return true;
@@ -86,8 +86,8 @@ static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.transform = output_transform,
.destroy = output_destroy,
- .make_current = output_make_current,
- .swap_buffers = output_swap_buffers,
+ .attach_render = output_attach_render,
+ .commit = output_commit,
};
bool wlr_output_is_headless(struct wlr_output *wlr_output) {
diff --git a/backend/noop/output.c b/backend/noop/output.c
index 5d9aa90d..7273095d 100644
--- a/backend/noop/output.c
+++ b/backend/noop/output.c
@@ -23,12 +23,12 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
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;
}
-static bool output_swap_buffers(struct wlr_output *wlr_output,
- pixman_region32_t *damage) {
+static bool output_commit(struct wlr_output *wlr_output) {
return true;
}
@@ -45,8 +45,8 @@ static const struct wlr_output_impl output_impl = {
.transform = output_transform,
.set_custom_mode = output_set_custom_mode,
.destroy = output_destroy,
- .make_current = output_make_current,
- .swap_buffers = output_swap_buffers,
+ .attach_render = output_attach_render,
+ .commit = output_commit,
};
bool wlr_output_is_noop(struct wlr_output *wlr_output) {
diff --git a/backend/rdp/output.c b/backend/rdp/output.c
index 4d5d259d..5e20dda4 100644
--- a/backend/rdp/output.c
+++ b/backend/rdp/output.c
@@ -69,7 +69,8 @@ static void output_transform(struct wlr_output *wlr_output,
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 =
rdp_output_from_output(wlr_output);
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
@@ -169,31 +170,39 @@ static bool nsc_swap_buffers(
return true;
}
-static bool output_swap_buffers(
- struct wlr_output *wlr_output, pixman_region32_t *damage) {
- if (!pixman_region32_not_empty(damage)) {
- return true;
- }
-
+static bool output_commit(struct wlr_output *wlr_output) {
struct wlr_rdp_output *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 height = damage->extents.y2 - damage->extents.y1;
+
+ // Update shadow buffer
struct wlr_renderer *renderer =
wlr_backend_get_renderer(&output->backend->backend);
// TODO performance: add support for flags
- if (!wlr_renderer_read_pixels(renderer, WL_SHM_FORMAT_XRGB8888,
- NULL, pixman_image_get_stride(output->shadow_surface),
- width, height, damage->extents.x1, damage->extents.y1,
- damage->extents.x1, damage->extents.y1,
- pixman_image_get_data(output->shadow_surface))) {
- return false;
+ ret = wlr_renderer_read_pixels(renderer, WL_SHM_FORMAT_XRGB8888,
+ NULL, pixman_image_get_stride(output->shadow_surface),
+ width, height, x, y, x, y,
+ pixman_image_get_data(output->shadow_surface));
+ if (!ret) {
+ goto out;
}
// Send along to clients
- bool ret = false;
rdpSettings *settings = output->context->peer->settings;
if (settings->RemoteFxCodec) {
ret = rfx_swap_buffers(output, damage);
@@ -202,8 +211,16 @@ static bool output_swap_buffers(
} else {
// This would perform like ass so why bother
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);
+
+out:
+ pixman_region32_fini(&output_region);
return ret;
}
@@ -224,8 +241,8 @@ static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.transform = output_transform,
.destroy = output_destroy,
- .make_current = output_make_current,
- .swap_buffers = output_swap_buffers,
+ .attach_render = output_attach_render,
+ .commit = output_commit,
};
bool wlr_output_is_rdp(struct wlr_output *wlr_output) {
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 64ead4ac..2eaaaf9c 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -50,7 +50,7 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
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) {
struct wlr_wl_output *output =
get_wl_output_from_output(wlr_output);
@@ -58,8 +58,7 @@ static bool output_make_current(struct wlr_output *wlr_output,
buffer_age);
}
-static bool output_swap_buffers(struct wlr_output *wlr_output,
- pixman_region32_t *damage) {
+static bool output_commit(struct wlr_output *wlr_output) {
struct wlr_wl_output *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);
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,
output->egl_surface, damage)) {
return false;
@@ -220,8 +224,8 @@ static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.transform = output_transform,
.destroy = output_destroy,
- .make_current = output_make_current,
- .swap_buffers = output_swap_buffers,
+ .attach_render = output_attach_render,
+ .commit = output_commit,
.set_cursor = output_set_cursor,
.move_cursor = output_move_cursor,
.schedule_frame = output_schedule_frame,
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 38715631..ddd8ab77 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -46,7 +46,7 @@ static void handle_x11_event(struct wlr_x11_backend *x11,
struct wlr_x11_output *output =
get_x11_output_from_window_id(x11, ev->window);
if (output != NULL) {
- wlr_output_update_needs_swap(&output->wlr_output);
+ wlr_output_update_needs_commit(&output->wlr_output);
}
break;
}
diff --git a/backend/x11/output.c b/backend/x11/output.c
index a9bd5c0a..8ee15d51 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -95,7 +95,7 @@ static void output_destroy(struct wlr_output *wlr_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) {
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
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);
}
-static bool output_swap_buffers(struct wlr_output *wlr_output,
- pixman_region32_t *damage) {
- struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
+static bool output_commit(struct wlr_output *wlr_output) {
+ struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
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)) {
return false;
}
@@ -120,8 +124,8 @@ static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.transform = output_transform,
.destroy = output_destroy,
- .make_current = output_make_current,
- .swap_buffers = output_swap_buffers,
+ .attach_render = output_attach_render,
+ .commit = output_commit,
};
struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {