aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-12-02 13:17:24 -0500
committerGitHub <noreply@github.com>2018-12-02 13:17:24 -0500
commit273e110b742337142a90f9485b9592467209d1bd (patch)
tree7ba0d70303f223d0a71373392ea27d040e36d9d1
parent8887508fed89d59486a4abcff7a2071326ca8207 (diff)
parent6aaefad40db8b4c972d30a5841c1ff819bb0da09 (diff)
Merge pull request #1403 from emersion/swap-buffers-damage-coords
output: switch swap_buffers damage to output-buffer-local coords
-rw-r--r--include/wlr/types/wlr_output.h5
-rw-r--r--rootston/output.c9
-rw-r--r--types/wlr_output.c12
3 files changed, 12 insertions, 14 deletions
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 6d38152a..22822b11 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -121,7 +121,7 @@ struct wlr_output {
struct wlr_output_event_swap_buffers {
struct wlr_output *output;
struct timespec *when;
- pixman_region32_t *damage;
+ pixman_region32_t *damage; // output-buffer-local coordinates
};
enum wlr_output_present_flag {
@@ -203,6 +203,9 @@ bool wlr_output_preferred_read_format(struct wlr_output *output,
* NULL. If the compositor doesn't support damage tracking, set `damage` to
* NULL.
*
+ * Damage is given in output-buffer-local coordinates (ie. scaled and
+ * transformed).
+ *
* Swapping buffers schedules a `frame` event.
*/
bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
diff --git a/rootston/output.c b/rootston/output.c
index 9ca55447..7017bd1f 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -522,12 +522,17 @@ renderer_end:
wlr_renderer_scissor(renderer, NULL);
wlr_renderer_end(renderer);
+ int width, height;
+ wlr_output_transformed_resolution(wlr_output, &width, &height);
+
if (server->config->debug_damage_tracking) {
- int width, height;
- wlr_output_transformed_resolution(wlr_output, &width, &height);
pixman_region32_union_rect(&damage, &damage, 0, 0, width, height);
}
+ enum wl_output_transform transform =
+ wlr_output_transform_invert(wlr_output->transform);
+ wlr_region_transform(&damage, &damage, transform, width, height);
+
if (!wlr_output_damage_swap_buffers(output->damage, &now, &damage)) {
goto damage_finish;
}
diff --git a/types/wlr_output.c b/types/wlr_output.c
index dc8e34b8..a778e5f2 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -365,9 +365,6 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
output->idle_frame = NULL;
}
- int width, height;
- wlr_output_transformed_resolution(output, &width, &height);
-
struct timespec now;
if (when == NULL) {
clock_gettime(CLOCK_MONOTONIC, &now);
@@ -384,19 +381,12 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
pixman_region32_t render_damage;
pixman_region32_init(&render_damage);
pixman_region32_union_rect(&render_damage, &render_damage, 0, 0,
- width, height);
+ output->width, output->height);
if (damage != NULL) {
// Damage tracking supported
pixman_region32_intersect(&render_damage, &render_damage, damage);
}
- // Transform damage into renderer coordinates, ie. upside down
- // TODO: take transformed coords, make the renderer flip the damage
- enum wl_output_transform transform =
- wlr_output_transform_invert(output->transform);
- wlr_region_transform(&render_damage, &render_damage, transform,
- width, height);
-
if (!output->impl->swap_buffers(output, damage ? &render_damage : NULL)) {
pixman_region32_fini(&render_damage);
return false;