boxes: Add API to crop and scale a MetaRectangle
https://gitlab.gnome.org/GNOME/mutter/merge_requests/323
This commit is contained in:
parent
47402d848d
commit
d574cf59f1
@ -274,4 +274,10 @@ void meta_rectangle_transform (const MetaRectangle *rect,
|
||||
int height,
|
||||
MetaRectangle *dest);
|
||||
|
||||
void meta_rectangle_crop_and_scale (const MetaRectangle *rect,
|
||||
ClutterRect *src_rect,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
MetaRectangle *dest);
|
||||
|
||||
#endif /* META_BOXES_PRIVATE_H */
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "backends/meta-monitor-transform.h"
|
||||
#include "core/boxes-private.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "meta/util.h"
|
||||
@ -2149,3 +2150,18 @@ meta_rectangle_transform (const MetaRectangle *rect,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_rectangle_crop_and_scale (const MetaRectangle *rect,
|
||||
ClutterRect *src_rect,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
MetaRectangle *dest)
|
||||
{
|
||||
dest->x = floorf (rect->x * (src_rect->size.width / dst_width) +
|
||||
src_rect->origin.x);
|
||||
dest->y = floorf (rect->y * (src_rect->size.height / dst_height) +
|
||||
src_rect->origin.y);
|
||||
dest->width = ceilf (rect->width * (src_rect->size.width / dst_width));
|
||||
dest->height = ceilf (rect->height * (src_rect->size.height / dst_height));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user