BLI_bitmap: typecheck maco
This commit is contained in:
@@ -153,10 +153,12 @@ static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
|
|||||||
/* If prev_hidden is available, copy it to
|
/* If prev_hidden is available, copy it to
|
||||||
* subd, except when the equivalent element in
|
* subd, except when the equivalent element in
|
||||||
* lo_hidden is different */
|
* lo_hidden is different */
|
||||||
if (lo_val != prev_hidden[hi_ndx])
|
if (lo_val != prev_hidden[hi_ndx]) {
|
||||||
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
|
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
BLI_BITMAP_MODIFY(subd, hi_ndx, prev_hidden[hi_ndx]);
|
BLI_BITMAP_MODIFY(subd, hi_ndx, prev_hidden[hi_ndx]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
|
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
|
||||||
|
@@ -37,17 +37,17 @@ typedef unsigned int BLI_bitmap;
|
|||||||
|
|
||||||
/* internal use */
|
/* internal use */
|
||||||
/* 2^5 = 32 (bits) */
|
/* 2^5 = 32 (bits) */
|
||||||
#define BLI_BITMAP_POWER 5
|
#define _BITMAP_POWER 5
|
||||||
/* 0b11111 */
|
/* 0b11111 */
|
||||||
#define BLI_BITMAP_MASK 31
|
#define _BITMAP_MASK 31
|
||||||
|
|
||||||
/* number of blocks needed to hold '_tot' bits */
|
/* number of blocks needed to hold '_tot' bits */
|
||||||
#define BLI_BITMAP_NUM_BLOCKS(_tot) \
|
#define _BITMAP_NUM_BLOCKS(_tot) \
|
||||||
(((_tot) >> BLI_BITMAP_POWER) + 1)
|
(((_tot) >> _BITMAP_POWER) + 1)
|
||||||
|
|
||||||
/* size (in bytes) used to hold '_tot' bits */
|
/* size (in bytes) used to hold '_tot' bits */
|
||||||
#define BLI_BITMAP_SIZE(_tot) \
|
#define BLI_BITMAP_SIZE(_tot) \
|
||||||
(BLI_BITMAP_NUM_BLOCKS(_tot) * sizeof(unsigned int))
|
(_BITMAP_NUM_BLOCKS(_tot) * sizeof(unsigned int))
|
||||||
|
|
||||||
/* allocate memory for a bitmap with '_tot' bits; free
|
/* allocate memory for a bitmap with '_tot' bits; free
|
||||||
* with MEM_freeN() */
|
* with MEM_freeN() */
|
||||||
@@ -61,33 +61,41 @@ typedef unsigned int BLI_bitmap;
|
|||||||
|
|
||||||
/* get the value of a single bit at '_index' */
|
/* get the value of a single bit at '_index' */
|
||||||
#define BLI_BITMAP_GET(_bitmap, _index) \
|
#define BLI_BITMAP_GET(_bitmap, _index) \
|
||||||
((_bitmap)[(_index) >> BLI_BITMAP_POWER] & \
|
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
|
||||||
(1u << ((_index) & BLI_BITMAP_MASK)))
|
((_bitmap)[(_index) >> _BITMAP_POWER] & \
|
||||||
|
(1u << ((_index) & _BITMAP_MASK))))
|
||||||
|
|
||||||
#define BLI_BITMAP_GET_BOOL(_bitmap, _index) \
|
#define BLI_BITMAP_GET_BOOL(_bitmap, _index) \
|
||||||
(BLI_BITMAP_GET(_bitmap, _index) != 0)
|
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
|
||||||
|
(BLI_BITMAP_GET(_bitmap, _index) != 0))
|
||||||
|
|
||||||
/* set the value of a single bit at '_index' */
|
/* set the value of a single bit at '_index' */
|
||||||
#define BLI_BITMAP_SET(_bitmap, _index) \
|
#define BLI_BITMAP_SET(_bitmap, _index) \
|
||||||
((_bitmap)[(_index) >> BLI_BITMAP_POWER] |= \
|
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
|
||||||
(1u << ((_index) & BLI_BITMAP_MASK)))
|
((_bitmap)[(_index) >> _BITMAP_POWER] |= \
|
||||||
|
(1u << ((_index) & _BITMAP_MASK))))
|
||||||
|
|
||||||
/* clear the value of a single bit at '_index' */
|
/* clear the value of a single bit at '_index' */
|
||||||
#define BLI_BITMAP_CLEAR(_bitmap, _index) \
|
#define BLI_BITMAP_CLEAR(_bitmap, _index) \
|
||||||
((_bitmap)[(_index) >> BLI_BITMAP_POWER] &= \
|
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
|
||||||
~(1u << ((_index) & BLI_BITMAP_MASK)))
|
((_bitmap)[(_index) >> _BITMAP_POWER] &= \
|
||||||
|
~(1u << ((_index) & _BITMAP_MASK))))
|
||||||
|
|
||||||
/* set or clear the value of a single bit at '_index' */
|
/* set or clear the value of a single bit at '_index' */
|
||||||
#define BLI_BITMAP_MODIFY(_bitmap, _index, _set) \
|
#define BLI_BITMAP_MODIFY(_bitmap, _index, _set) \
|
||||||
do { \
|
{ \
|
||||||
|
CHECK_TYPE(_bitmap, BLI_bitmap *); \
|
||||||
if (_set) \
|
if (_set) \
|
||||||
BLI_BITMAP_SET(_bitmap, _index); \
|
BLI_BITMAP_SET(_bitmap, _index); \
|
||||||
else \
|
else \
|
||||||
BLI_BITMAP_CLEAR(_bitmap, _index); \
|
BLI_BITMAP_CLEAR(_bitmap, _index); \
|
||||||
} while (0)
|
} (void)0
|
||||||
|
|
||||||
/* resize bitmap to have space for '_tot' bits */
|
/* resize bitmap to have space for '_tot' bits */
|
||||||
#define BLI_BITMAP_RESIZE(_bitmap, _tot) \
|
#define BLI_BITMAP_RESIZE(_bitmap, _tot) \
|
||||||
(_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot))
|
{ \
|
||||||
|
CHECK_TYPE(_bitmap, BLI_bitmap *); \
|
||||||
|
(_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
|
||||||
|
} (void)0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user