- code cleanup

This commit is contained in:
Christoph Oelckers 2023-08-25 20:05:52 +02:00
commit ccd39d6df7
13 changed files with 60 additions and 33 deletions

View file

@ -36,8 +36,6 @@
#ifndef __BITMAP_H__
#define __BITMAP_H__
#include "basics.h"
#include "palentry.h"
struct FCopyInfo;
@ -320,9 +318,9 @@ struct cCMYK
struct cYCbCr
{
static __forceinline unsigned char R(const unsigned char * p) { return clamp((int)(p[0] + 1.40200 * (int(p[2]) - 0x80)), 0, 255); }
static __forceinline unsigned char G(const unsigned char * p) { return clamp((int)(p[0] - 0.34414 * (int(p[1] - 0x80)) - 0.71414 * (int(p[2]) - 0x80)), 0, 255); }
static __forceinline unsigned char B(const unsigned char * p) { return clamp((int)(p[0] + 1.77200 * (int(p[1]) - 0x80)), 0, 255); }
static __forceinline unsigned char R(const unsigned char * p) { return std::clamp((int)(p[0] + 1.40200 * (int(p[2]) - 0x80)), 0, 255); }
static __forceinline unsigned char G(const unsigned char * p) { return std::clamp((int)(p[0] - 0.34414 * (int(p[1] - 0x80)) - 0.71414 * (int(p[2]) - 0x80)), 0, 255); }
static __forceinline unsigned char B(const unsigned char * p) { return std::clamp((int)(p[0] + 1.77200 * (int(p[1]) - 0x80)), 0, 255); }
static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (R(p) * 77 + G(p) * 143 + B(p) * 36) >> 8; }
};
@ -470,7 +468,7 @@ struct bCopyAlpha
struct bOverlay
{
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = max(s,d); }
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = std::max(s,d); }
static __forceinline bool ProcessAlpha0() { return false; }
};
@ -483,21 +481,21 @@ struct bBlend
struct bAdd
{
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = min<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = std::min<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; }
};
struct bSubtract
{
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = std::max<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; }
};
struct bReverseSubtract
{
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = std::max<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; }
};