Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-09-15 15:48:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-15 15:48:20 +0400
commit232571c61a0120e71d980e47351d0656475dcbb5 (patch)
tree1980460d86e5743306ce676f28c5feb399248469 /source/blender/blenlib/BLI_rect.h
parent219b748dfc556d9920434fc67a9d0e980e8e7fab (diff)
code cleanup: replace macro for BLI_rect size/center with inline functions.
Diffstat (limited to 'source/blender/blenlib/BLI_rect.h')
-rw-r--r--source/blender/blenlib/BLI_rect.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index eb9915d6c9b..e64fb1a72b3 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -75,14 +75,28 @@ void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
void print_rctf(const char *str, const struct rctf *rect);
void print_rcti(const char *str, const struct rcti *rect);
-#define BLI_RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin)
-#define BLI_RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin)
+/* hrmf, we need to work out this inline stuff */
+#if defined(_MSC_VER)
+# define BLI_INLINE static __forceinline
+#elif defined(__GNUC__)
+# define BLI_INLINE static inline __attribute((always_inline))
+#else
+/* #warning "MSC/GNUC defines not found, inline non-functional" */
+# define BLI_INLINE static
+#endif
-#define BLI_RCT_CENTER_X(rct) (((rct)->xmin + (rct)->xmax) / 2)
-#define BLI_RCT_CENTER_Y(rct) (((rct)->ymin + (rct)->ymax) / 2)
+#include "DNA_vec_types.h"
+BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct) { return (float)(rct->xmin + rct->xmax) / 2.0f; }
+BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct) { return (float)(rct->ymin + rct->ymax) / 2.0f; }
+BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct) { return (rct->xmin + rct->xmax) / 2; }
+BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct) { return (rct->ymin + rct->ymax) / 2; }
+BLI_INLINE int BLI_rctf_cent_x(const struct rctf *rct) { return (rct->xmin + rct->xmax) / 2.0f; }
+BLI_INLINE int BLI_rctf_cent_y(const struct rctf *rct) { return (rct->ymin + rct->ymax) / 2.0f; }
-#define BLI_RCT_CENTER_X_FL(rct) ((float)((rct)->xmin + (rct)->xmax) / 2.0f)
-#define BLI_RCT_CENTER_Y_FL(rct) ((float)((rct)->ymin + (rct)->ymax) / 2.0f)
+BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct) { return (rct->xmax - rct->xmin); }
+BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct) { return (rct->ymax - rct->ymin); }
+BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct) { return (rct->xmax - rct->xmin); }
+BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct) { return (rct->ymax - rct->ymin); }
#ifdef __cplusplus
}