mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Introduce factor and bit count constants for subpixels
Providing that tiny bit of additional readability. Part of P0182, funded by Lmocinemod and [Anonymous].
This commit is contained in:
parent
70cbf4bbe1
commit
1fd9b6a0c1
|
@ -7,18 +7,21 @@
|
|||
|
||||
typedef int subpixel_t;
|
||||
|
||||
static const subpixel_t SUBPIXEL_FACTOR = 16;
|
||||
static const char SUBPIXEL_BITS = 4;
|
||||
|
||||
#define TO_SP(v) \
|
||||
(v << 4)
|
||||
(v << SUBPIXEL_BITS)
|
||||
|
||||
#define TO_PIXEL(v) \
|
||||
(v >> 4)
|
||||
(v >> SUBPIXEL_BITS)
|
||||
|
||||
// In-place conversion to a pixel. Ugly, and should not exist.
|
||||
#define TO_PIXEL_INPLACE(v) \
|
||||
(v >>= 4)
|
||||
(v >>= SUBPIXEL_BITS)
|
||||
|
||||
inline subpixel_t to_sp(float pixel_v) {
|
||||
return static_cast<subpixel_t>(pixel_v * 16.0f);
|
||||
return static_cast<subpixel_t>(pixel_v * SUBPIXEL_FACTOR);
|
||||
}
|
||||
|
||||
inline unsigned char to_sp8(float pixel_v) {
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
PIXEL_NONE = -999
|
||||
SUBPIXEL_NONE = (PIXEL_NONE shl 4)
|
||||
|
||||
SUBPIXEL_FACTOR = 16
|
||||
SUBPIXEL_BITS = 4
|
||||
|
|
Loading…
Reference in New Issue