[gnome-builder] cairo: use static inlines instead of macros
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] cairo: use static inlines instead of macros
- Date: Wed, 16 Sep 2015 07:10:41 +0000 (UTC)
commit d713daf689ded2041c176e0e3ef9cc440497b759
Author: Christian Hergert <christian hergert me>
Date: Wed Sep 16 00:10:31 2015 -0700
cairo: use static inlines instead of macros
Little bit of cleanup while I'm looking at it.
libide/ide-source-view.c | 14 +++++---------
libide/util/ide-cairo.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 3445f53..cac0448 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -70,15 +70,11 @@
#define FIXIT_LABEL_LEN_MAX 30
#define SCROLL_REPLAY_DELAY 1000
-#define _GDK_RECTANGLE_X2(rect) ((rect)->x + (rect)->width)
-#define _GDK_RECTANGLE_Y2(rect) ((rect)->y + (rect)->height)
-#define _GDK_RECTANGLE_CONTAINS(rect,other) \
- (((rect)->x <= (other)->x) && \
- (_GDK_RECTANGLE_X2(rect) >= _GDK_RECTANGLE_X2(other)) && \
- ((rect)->y <= (other)->y) && \
- (_GDK_RECTANGLE_Y2(rect) >= _GDK_RECTANGLE_Y2(other)))
-#define _GDK_RECTANGLE_CENTER_X(rect) ((rect)->x + ((rect)->width/2))
-#define _GDK_RECTANGLE_CENTER_Y(rect) ((rect)->y + ((rect)->height/2))
+#define _GDK_RECTANGLE_X2(rect) _ide_cairo_rectangle_x2(rect)
+#define _GDK_RECTANGLE_Y2(rect) _ide_cairo_rectangle_y2(rect)
+#define _GDK_RECTANGLE_CONTAINS(rect,other) _ide_cairo_rectangle_contains_rectangle(rect,other)
+#define _GDK_RECTANGLE_CENTER_X(rect) _ide_cairo_rectangle_center(rect)
+#define _GDK_RECTANGLE_CENTER_Y(rect) _ide_cairo_rectangle_middle(rect)
#define TRACE_RECTANGLE(name, rect) \
IDE_TRACE_MSG ("%s = Rectangle(x=%d, y=%d, width=%d, height=%d)", \
name, (rect)->x, (rect)->y, (rect)->width, (rect)->height)
diff --git a/libide/util/ide-cairo.h b/libide/util/ide-cairo.h
index 7245594..703821b 100644
--- a/libide/util/ide-cairo.h
+++ b/libide/util/ide-cairo.h
@@ -29,6 +29,40 @@ void ide_cairo_rounded_rectangle (cairo_t *c
gint x_radius,
gint y_radius);
+static inline gboolean
+_ide_cairo_rectangle_x2 (const cairo_rectangle_int_t *rect)
+{
+ return rect->x + rect->width;
+}
+
+static inline gboolean
+_ide_cairo_rectangle_y2 (const cairo_rectangle_int_t *rect)
+{
+ return rect->y + rect->height;
+}
+
+static inline gboolean
+_ide_cairo_rectangle_center (const cairo_rectangle_int_t *rect)
+{
+ return rect->x + (rect->width/2);
+}
+
+static inline gboolean
+_ide_cairo_rectangle_middle (const cairo_rectangle_int_t *rect)
+{
+ return rect->y + (rect->height/2);
+}
+
+static inline cairo_bool_t
+_ide_cairo_rectangle_contains_rectangle (const cairo_rectangle_int_t *a,
+ const cairo_rectangle_int_t *b)
+{
+ return (a->x <= b->x &&
+ a->x + (int) a->width >= b->x + (int) b->width &&
+ a->y <= b->y &&
+ a->y + (int) a->height >= b->y + (int) b->height);
+}
+
G_END_DECLS
#endif /* IDE_CAIRO_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]