aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-07-18 21:38:12 +0300
committerDrew DeVault <sir@cmpwn.com>2019-08-02 10:01:29 -0400
commitee5f98ad49fed0439f3313ec685307831d1d1d05 (patch)
tree13df7c4d845fd586e62e39a47e0af6bf60376a0d /backend/drm
parentd20aee6c9de12c8949b4ce7775b53dbc5f3896a6 (diff)
downloadwlroots-ee5f98ad49fed0439f3313ec685307831d1d1d05.tar.xz
output: atomic mode, enabled, scale and transform
This commit makes more output properties (mode, enabled, scale and transform) atomic. This means that they are double-buffered and only applied on commit. Compositors now need to call wlr_output_commit after setting any of those properties. Internally, backends still apply properties sequentially. The behaviour should be exactly the same as before. Future commits will update some backends to take advantage of the atomic interface. Some backends are non-atomic by design, e.g. the X11 backend or the legacy DRM backend. Updates: https://github.com/swaywm/wlroots/issues/1640
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/drm.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index eef7beb5..730240c8 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -328,12 +328,9 @@ static bool drm_connector_attach_render(struct wlr_output *output,
return make_drm_surface_current(&conn->crtc->primary->surf, buffer_age);
}
-static bool drm_connector_commit(struct wlr_output *output) {
+static bool drm_connector_commit_buffer(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) {
- return false;
- }
struct wlr_drm_crtc *crtc = conn->crtc;
if (!crtc) {
@@ -404,6 +401,37 @@ static bool drm_connector_commit(struct wlr_output *output) {
return true;
}
+static bool drm_connector_commit(struct wlr_output *output) {
+ struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
+
+ if (!drm->session->active) {
+ return false;
+ }
+
+ if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
+ if (!enable_drm_connector(output, output->pending.enabled)) {
+ return false;
+ }
+ }
+
+ if (output->pending.committed & WLR_OUTPUT_STATE_MODE) {
+ if (output->pending.mode_type != WLR_OUTPUT_STATE_MODE_FIXED) {
+ return false;
+ }
+ if (!drm_connector_set_mode(output, output->pending.mode)) {
+ return false;
+ }
+ }
+
+ if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
+ if (!drm_connector_commit_buffer(output)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
static void fill_empty_gamma_table(size_t size,
uint16_t *r, uint16_t *g, uint16_t *b) {
for (uint32_t i = 0; i < size; ++i) {
@@ -922,8 +950,6 @@ static void drm_connector_destroy(struct wlr_output *output) {
}
static const struct wlr_output_impl output_impl = {
- .enable = enable_drm_connector,
- .set_mode = drm_connector_set_mode,
.set_cursor = drm_connector_set_cursor,
.move_cursor = drm_connector_move_cursor,
.destroy = drm_connector_destroy,