transform-util: Add dimensions transform function

dmabuf-import
Andri Yngvason 2021-09-19 21:11:54 +00:00
parent 02559a7f7e
commit 0d4ab56568
2 changed files with 29 additions and 0 deletions

View File

@ -22,3 +22,6 @@
void nvnc_transform_to_pixman_transform(pixman_transform_t* dst, void nvnc_transform_to_pixman_transform(pixman_transform_t* dst,
enum nvnc_transform src, int width, int height); enum nvnc_transform src, int width, int height);
void nvnc_transform_dimensions(enum nvnc_transform transform, uint32_t* width,
uint32_t* height);

View File

@ -14,6 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "transform-util.h"
#include "neatvnc.h" #include "neatvnc.h"
#include <stdlib.h> #include <stdlib.h>
@ -112,3 +113,28 @@ void nvnc_transform_to_pixman_transform(pixman_transform_t* dst,
abort(); 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;
}
}