Fix C extension build warnings the painful way
Some bad distributions (Debian) apparently are not good enough to have a Pillow version from this decade packaged. Therefore, we need to do it the painful way of prefixing our symbols and refactoring everything to use them. A new header file called "utils.h" has been added for this purpose, and it is included in "overviewer.h". The following macros have been prefixed with "OV_": - MIN - MAX - CLAMP - BLEND - MULDIV255 Additionally, the C extension version was bumped to 56 because 55 was reverted back to 54.
This commit is contained in:
17
overviewer_core/src/utils.h
Normal file
17
overviewer_core/src/utils.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef __OV_UTILS_H_INCLUDED__
|
||||
#define __OV_UTILS_H_INCLUDED__
|
||||
|
||||
/* generally useful MAX / MIN macros */
|
||||
#define OV_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define OV_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define OV_CLAMP(x, a, b) (OV_MIN(OV_MAX(x, a), b))
|
||||
|
||||
/* like (a * b + 127) / 255), but much faster on most platforms
|
||||
from PIL's _imaging.c */
|
||||
#define OV_MULDIV255(a, b, tmp)\
|
||||
(tmp = (a) * (b) + 128, ((((tmp) >> 8) + (tmp)) >> 8))
|
||||
|
||||
#define OV_BLEND(mask, in1, in2, tmp1, tmp2)\
|
||||
(OV_MULDIV255(in1, 255 - mask, tmp1) + OV_MULDIV255(in2, mask, tmp2))
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user