aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-26 18:16:37 +0100
committeremersion <contact@emersion.fr>2017-12-26 18:16:37 +0100
commite737f65e38a8be7e9f5f1f82131699555aea81ff (patch)
tree0c3519bcbbc3d65e226b3deb075f730e751d7c9b
parent4d744aeb230f36d990c102a89314f95ff802ca75 (diff)
Fix cursor on transformed output with DRM backend
-rw-r--r--backend/drm/drm.c7
-rw-r--r--include/wlr/types/wlr_output.h5
-rw-r--r--types/wlr_output.c21
3 files changed, 24 insertions, 9 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 06f012a3..dd5c97f5 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -543,10 +543,11 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
// OpenGL will read the pixels out upside down,
// so we need to flip the image vertically
+ enum wl_output_transform transform = wlr_output_transform_compose(
+ wlr_output_transform_invert(output->transform),
+ WL_OUTPUT_TRANSFORM_FLIPPED_180);
wlr_matrix_texture(plane->matrix, plane->surf.width, plane->surf.height,
- conn->output.transform ^ WL_OUTPUT_TRANSFORM_FLIPPED_180);
-
- // TODO the image needs to be rotated depending on the output rotation
+ transform);
plane->wlr_tex =
wlr_render_texture_create(plane->surf.renderer->wlr_rend);
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index a974a154..06d733a1 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -118,6 +118,9 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y);
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
-enum wl_output_transform wlr_output_transform_invert(enum wl_output_transform);
+enum wl_output_transform wlr_output_transform_invert(
+ enum wl_output_transform tr);
+enum wl_output_transform wlr_output_transform_compose(
+ enum wl_output_transform tr_a, enum wl_output_transform tr_b);
#endif
diff --git a/types/wlr_output.c b/types/wlr_output.c
index f319905c..115f3e8b 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -726,11 +726,22 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) {
free(cursor);
}
+
enum wl_output_transform wlr_output_transform_invert(
- enum wl_output_transform transform) {
- if ((transform & WL_OUTPUT_TRANSFORM_90) &&
- !(transform & WL_OUTPUT_TRANSFORM_FLIPPED)) {
- transform ^= WL_OUTPUT_TRANSFORM_180;
+ enum wl_output_transform tr) {
+ if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED)) {
+ tr ^= WL_OUTPUT_TRANSFORM_180;
+ }
+ return tr;
+}
+
+enum wl_output_transform wlr_output_transform_compose(
+ enum wl_output_transform tr_a, enum wl_output_transform tr_b) {
+ uint32_t flipped = (tr_a ^ tr_b) & WL_OUTPUT_TRANSFORM_FLIPPED;
+ uint32_t rotated =
+ (tr_a + tr_b) & (WL_OUTPUT_TRANSFORM_90 | WL_OUTPUT_TRANSFORM_180);
+ if ((tr_a & WL_OUTPUT_TRANSFORM_FLIPPED) && (tr_b & WL_OUTPUT_TRANSFORM_FLIPPED)) {
+ rotated = wlr_output_transform_invert(rotated);
}
- return transform;
+ return flipped | rotated;
}