aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-12-27 05:48:45 -0500
committerGitHub <noreply@github.com>2017-12-27 05:48:45 -0500
commit6c2242e66be2dddb38559717e1a9054a55b8e6d1 (patch)
tree64518dfcb1e7eb9696716869535aed9f05d7b27d
parent47f9f91d157c9f650afe1172b3bb2d52def66a10 (diff)
parent43435d49150b87bbfafbae398dbde7ebfd9360dc (diff)
Merge pull request #522 from emersion/fix-drm-output-transform-cursor
Fix cursor on transformed output with DRM backend
-rw-r--r--backend/drm/drm.c7
-rw-r--r--include/wlr/types/wlr_output.h15
-rw-r--r--types/wlr_output.c21
3 files changed, 34 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..8e4f5446 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -118,6 +118,19 @@ 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);
+
+/**
+ * Returns the transform that, when composed with `tr`, gives
+ * `WL_OUTPUT_TRANSFORM_NORMAL`.
+ */
+enum wl_output_transform wlr_output_transform_invert(
+ enum wl_output_transform tr);
+
+/**
+ * Returns a transform that, when applied, has the same effect as applying
+ * sequentially `tr_a` and `tr_b`.
+ */
+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;
}