[mutter] boxes: Add API to transform a MetaRectangle
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] boxes: Add API to transform a MetaRectangle
- Date: Sat, 5 Jan 2019 13:35:41 +0000 (UTC)
commit 686b7f8baa467faf855f413350c0c407d2a306af
Author: Robert Mader <robert mader posteo de>
Date: Fri Dec 21 17:12:49 2018 +0100
boxes: Add API to transform a MetaRectangle
To be used if not a whole region needs to get transformed.
It also has an argument for reverse-transforms.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/366
src/compositor/region-utils.c | 49 ++++-----------------------
src/core/boxes-private.h | 7 ++++
src/core/boxes.c | 77 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 90 insertions(+), 43 deletions(-)
---
diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c
index 1719a4500..3a5839695 100644
--- a/src/compositor/region-utils.c
+++ b/src/compositor/region-utils.c
@@ -22,6 +22,7 @@
#include "backends/meta-monitor-transform.h"
#include "compositor/region-utils.h"
+#include "core/boxes-private.h"
#include <math.h>
@@ -392,51 +393,13 @@ meta_region_transform (cairo_region_t *region,
rects = g_new0 (cairo_rectangle_int_t, n_rects);
for (i = 0; i < n_rects; i++)
{
- cairo_rectangle_int_t rect;
-
cairo_region_get_rectangle (region, i, &rects[i]);
- rect = rects[i];
-
- switch (transform)
- {
- case META_MONITOR_TRANSFORM_90:
- rects[i].x = width - (rect.y + rect.height);
- rects[i].y = rect.x;
- rects[i].width = rect.height;
- rects[i].height = rect.width;
- break;
- case META_MONITOR_TRANSFORM_180:
- rects[i].x = width - (rect.x + rect.width);
- rects[i].y = height - (rect.y + rect.height);
- break;
- case META_MONITOR_TRANSFORM_270:
- rects[i].x = rect.y;
- rects[i].y = height - (rect.x + rect.width);
- rects[i].width = rect.height;
- rects[i].height = rect.width;
- break;
- case META_MONITOR_TRANSFORM_FLIPPED:
- rects[i].x = width - (rect.x + rect.width);
- break;
- case META_MONITOR_TRANSFORM_FLIPPED_90:
- rects[i].x = width - (rect.y + rect.height);
- rects[i].y = height - (rect.x + rect.width);
- rects[i].width = rect.height;
- rects[i].height = rect.width;
- break;
- case META_MONITOR_TRANSFORM_FLIPPED_180:
- rects[i].y = height - (rect.y + rect.height);
- break;
- case META_MONITOR_TRANSFORM_FLIPPED_270:
- rects[i].x = rect.y;
- rects[i].y = rect.x;
- rects[i].width = rect.height;
- rects[i].height = rect.width;
- break;
- case META_MONITOR_TRANSFORM_NORMAL:
- g_assert_not_reached ();
- }
+ meta_rectangle_transform (&rects[i],
+ transform,
+ width,
+ height,
+ &rects[i]);
}
transformed_region = cairo_region_create_rectangles (rects, n_rects);
diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h
index 4c6fd08ab..fba9021c9 100644
--- a/src/core/boxes-private.h
+++ b/src/core/boxes-private.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
+#include "backends/meta-backend-types.h"
#include "meta/boxes.h"
#include "meta/common.h"
@@ -245,4 +246,10 @@ meta_rectangle_to_clutter_rect (MetaRectangle *rect)
};
}
+void meta_rectangle_transform (const MetaRectangle *rect,
+ MetaMonitorTransform transform,
+ int width,
+ int height,
+ MetaRectangle *dest);
+
#endif /* META_BOXES_PRIVATE_H */
diff --git a/src/core/boxes.c b/src/core/boxes.c
index 98a8d3586..471258f40 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -30,6 +30,7 @@
#include "config.h"
+#include "backends/meta-monitor-transform.h"
#include "core/boxes-private.h"
#include <X11/Xutil.h>
@@ -2071,3 +2072,79 @@ meta_rectangle_scale_double (const MetaRectangle *rect,
break;
}
}
+
+void
+meta_rectangle_transform (const MetaRectangle *rect,
+ MetaMonitorTransform transform,
+ int width,
+ int height,
+ MetaRectangle *dest)
+{
+ switch (transform)
+ {
+ case META_MONITOR_TRANSFORM_NORMAL:
+ *dest = (MetaRectangle) {
+ .x = rect->x,
+ .y = rect->y,
+ .width = rect->width,
+ .height = rect->height,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_90:
+ *dest = (MetaRectangle) {
+ .x = width - (rect->y + rect->height),
+ .y = rect->x,
+ .width = rect->height,
+ .height = rect->width,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_180:
+ *dest = (MetaRectangle) {
+ .x = width - (rect->x + rect->width),
+ .y = height - (rect->y + rect->height),
+ .width = rect->width,
+ .height = rect->height,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_270:
+ *dest = (MetaRectangle) {
+ .x = rect->y,
+ .y = height - (rect->x + rect->width),
+ .width = rect->height,
+ .height = rect->width,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_FLIPPED:
+ *dest = (MetaRectangle) {
+ .x = width - (rect->x + rect->width),
+ .y = rect->y,
+ .width = rect->width,
+ .height = rect->height,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_FLIPPED_90:
+ *dest = (MetaRectangle) {
+ .x = width - (rect->y + rect->height),
+ .y = height - (rect->x + rect->width),
+ .width = rect->height,
+ .height = rect->width,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_FLIPPED_180:
+ *dest = (MetaRectangle) {
+ .x = rect->x,
+ .y = height - (rect->y + rect->height),
+ .width = rect->width,
+ .height = rect->height,
+ };
+ break;
+ case META_MONITOR_TRANSFORM_FLIPPED_270:
+ *dest = (MetaRectangle) {
+ .x = rect->y,
+ .y = rect->x,
+ .width = rect->height,
+ .height = rect->width,
+ };
+ break;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]