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; + } +}