From 0d4ab56568dee9a3eff9ff1a1df6687d4288d41f Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 19 Sep 2021 21:11:54 +0000 Subject: [PATCH] transform-util: Add dimensions transform function --- include/transform-util.h | 3 +++ src/transform-util.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/transform-util.h b/include/transform-util.h index 86e66de..7322f9d 100644 --- a/include/transform-util.h +++ b/include/transform-util.h @@ -22,3 +22,6 @@ void nvnc_transform_to_pixman_transform(pixman_transform_t* dst, enum nvnc_transform src, int width, int height); + +void nvnc_transform_dimensions(enum nvnc_transform transform, uint32_t* width, + uint32_t* height); diff --git a/src/transform-util.c b/src/transform-util.c index a5bfb32..2cf85c2 100644 --- a/src/transform-util.c +++ b/src/transform-util.c @@ -14,6 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "transform-util.h" #include "neatvnc.h" #include @@ -112,3 +113,28 @@ void nvnc_transform_to_pixman_transform(pixman_transform_t* dst, abort(); } + +static bool is_transform_90_degrees(enum nvnc_transform transform) +{ + switch (transform) { + case NVNC_TRANSFORM_90: + case NVNC_TRANSFORM_270: + case NVNC_TRANSFORM_FLIPPED_90: + case NVNC_TRANSFORM_FLIPPED_270: + return true; + default: + break; + } + + return false; +} + +void nvnc_transform_dimensions(enum nvnc_transform transform, uint32_t* width, + uint32_t* height) +{ + if (is_transform_90_degrees(transform)) { + uint32_t tmp = *width; + *width = *height; + *height = tmp; + } +}