[mutter/wip/texture-purge-on-nvidia: 6/17] boxes: Add helper to scale rectangles by a double
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/texture-purge-on-nvidia: 6/17] boxes: Add helper to scale rectangles by a double
- Date: Fri, 11 Jan 2019 23:50:49 +0000 (UTC)
commit b78ab01edab03888cea21464ea555322dd1cfd48
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Dec 20 16:58:03 2018 +0100
boxes: Add helper to scale rectangles by a double
And change the similar region scaling helper to use this one.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
src/core/boxes-private.h | 10 ++++++++++
src/core/boxes.c | 22 ++++++++++++++++++++++
2 files changed, 32 insertions(+)
---
diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h
index bf019b4d6..793f39527 100644
--- a/src/core/boxes-private.h
+++ b/src/core/boxes-private.h
@@ -38,6 +38,12 @@ typedef enum
FIXED_DIRECTION_Y = 1 << 1,
} FixedDirections;
+typedef enum _MetaRoundingStrategy
+{
+ META_ROUNDING_STRATEGY_SHRINK,
+ META_ROUNDING_STRATEGY_GROW,
+} MetaRoundingStrategy;
+
/* Output functions -- note that the output buffer had better be big enough:
* rect_to_string: RECT_LENGTH
* region_to_string: (RECT_LENGTH+strlen(separator_string)) *
@@ -218,6 +224,10 @@ GList* meta_rectangle_find_nonintersected_monitor_edges (
gboolean meta_rectangle_is_adjecent_to (MetaRectangle *rect,
MetaRectangle *other);
+void meta_rectangle_scale_double (MetaRectangle *rect,
+ double scale,
+ MetaRoundingStrategy rounding_strategy);
+
static inline ClutterRect
meta_rectangle_to_clutter_rect (MetaRectangle *rect)
{
diff --git a/src/core/boxes.c b/src/core/boxes.c
index 35e9ac3cd..0854ecf94 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -2036,3 +2036,25 @@ meta_rectangle_is_adjecent_to (MetaRectangle *rect,
else
return FALSE;
}
+
+void
+meta_rectangle_scale_double (MetaRectangle *rect,
+ double scale,
+ MetaRoundingStrategy rounding_strategy)
+{
+ switch (rounding_strategy)
+ {
+ case META_ROUNDING_STRATEGY_SHRINK:
+ rect->x = (int) ceil (rect->x * scale);
+ rect->y = (int) ceil (rect->y * scale);
+ rect->width = (int) floor (rect->width * scale);
+ rect->height = (int) floor (rect->height * scale);
+ break;
+ case META_ROUNDING_STRATEGY_GROW:
+ rect->x = (int) floor (rect->x * scale);
+ rect->y = (int) floor (rect->y * scale);
+ rect->width = (int) ceil (rect->width * scale);
+ rect->height = (int) ceil (rect->height * scale);
+ break;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]