monitor-transform: Add generic function to get relative transform

It takes transforms A and B and returns the transform to get from
A to B.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
This commit is contained in:
Robert Mader 2019-06-24 21:26:31 +02:00 committed by Jonas Ådahl
parent 1fc7935858
commit d600cd9aee
2 changed files with 30 additions and 0 deletions

View File

@ -53,3 +53,30 @@ meta_monitor_transform_transform (MetaMonitorTransform transform,
return new_transform;
}
/**
* meta_monitor_transform_relative_transform:
* @transform: The transform to start from
* @other: The transform to go to
*
* Return value: a transform to get from @transform to @other
*/
MetaMonitorTransform
meta_monitor_transform_relative_transform (MetaMonitorTransform transform,
MetaMonitorTransform other)
{
MetaMonitorTransform relative_transform;
relative_transform = ((other % META_MONITOR_TRANSFORM_FLIPPED -
transform % META_MONITOR_TRANSFORM_FLIPPED) %
META_MONITOR_TRANSFORM_FLIPPED);
if (meta_monitor_transform_is_flipped (transform) !=
meta_monitor_transform_is_flipped (other))
{
relative_transform = (meta_monitor_transform_invert (relative_transform) +
META_MONITOR_TRANSFORM_FLIPPED);
}
return relative_transform;
}

View File

@ -58,4 +58,7 @@ META_EXPORT_TEST
MetaMonitorTransform meta_monitor_transform_transform (MetaMonitorTransform transform,
MetaMonitorTransform other);
MetaMonitorTransform meta_monitor_transform_relative_transform (MetaMonitorTransform transform,
MetaMonitorTransform other);
#endif /* META_MONITOR_TRANSFORM_H */