move non-shared drawing helper functions to qdrawhelper source file

also mark comp_func_Plus_one_pixel() as static while at it

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-03-19 02:43:37 +00:00
parent 3ccf93bac6
commit 32bce7bc71
2 changed files with 60 additions and 68 deletions

View file

@ -733,12 +733,6 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
#define FIXPT_BITS 8
#define FIXPT_SIZE (1<<FIXPT_BITS)
static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos)
{
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
return data->colorTable[qt_gradient_clamp(data, ipos)];
}
static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data)
{
v->dx = data->gradient.linear.end.x - data->gradient.linear.origin.x;
@ -752,6 +746,43 @@ static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const Q
}
}
static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
{
if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {
if (data->spread == QGradient::RepeatSpread) {
ipos = ipos % GRADIENT_STOPTABLE_SIZE;
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
} else if (data->spread == QGradient::ReflectSpread) {
const int limit = GRADIENT_STOPTABLE_SIZE * 2;
ipos = ipos % limit;
ipos = ipos < 0 ? limit + ipos : ipos;
ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos;
} else {
if (ipos < 0)
ipos = 0;
else if (ipos >= GRADIENT_STOPTABLE_SIZE)
ipos = GRADIENT_STOPTABLE_SIZE-1;
}
}
Q_ASSERT(ipos >= 0);
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);
return ipos;
}
static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
{
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
return data->colorTable[qt_gradient_clamp(data, ipos)];
}
static inline uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos)
{
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
return data->colorTable[qt_gradient_clamp(data, ipos)];
}
static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length)
{
@ -865,6 +896,11 @@ static inline void radial_fetch_plain(uint *buffer, uint *end, const Operator *o
}
}
static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
{
return (b * b) - (4 * a * c);
}
static const uint * QT_FASTCALL qt_fetch_radial_gradient(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length)
{
@ -1423,6 +1459,23 @@ static inline int mix_alpha(int da, int sa)
return 255 - ((255 - sa) * (255 - da) >> 8);
}
#if QT_POINTER_SIZE == 8 // 64-bit versions
#define AMIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
#define MIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
#else // 32 bits
// The mask for alpha can overflow over 32 bits
#define AMIX(mask) quint32(qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
#define MIX(mask) (qMin(((quint32(s)&mask) + (quint32(d)&mask)), quint32(mask)))
#endif
static inline int comp_func_Plus_one_pixel(uint d, const uint s)
{
return (AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
}
#undef MIX
#undef AMIX
/*
Dca' = Sca.Da + Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
= Sca + Dca

View file

@ -272,46 +272,6 @@ struct QSpanData
void adjustSpanMethods();
};
static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
{
if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {
if (data->spread == QGradient::RepeatSpread) {
ipos = ipos % GRADIENT_STOPTABLE_SIZE;
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
} else if (data->spread == QGradient::ReflectSpread) {
const int limit = GRADIENT_STOPTABLE_SIZE * 2;
ipos = ipos % limit;
ipos = ipos < 0 ? limit + ipos : ipos;
ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos;
} else {
if (ipos < 0)
ipos = 0;
else if (ipos >= GRADIENT_STOPTABLE_SIZE)
ipos = GRADIENT_STOPTABLE_SIZE-1;
}
}
Q_ASSERT(ipos >= 0);
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);
return ipos;
}
static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
{
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
return data->colorTable[qt_gradient_clamp(data, ipos)];
}
static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
{
return (b * b) - (4 * a * c);
}
template <class DST, class SRC>
void qt_memfill(DST *dest, SRC value, int count);
static inline uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
@ -325,7 +285,6 @@ static inline uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
}
#if QT_POINTER_SIZE == 8 // 64-bit versions
static inline uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
@ -386,8 +345,7 @@ static inline uint PREMUL(uint x) {
x |= t | (a << 24);
return x;
}
#endif
#endif // QT_POINTER_SIZE
static inline uint BYTE_MUL_RGB16(uint x, uint a) {
a += 1;
@ -410,7 +368,6 @@ inline DST qt_colorConvert(const SRC color, const DST dummy)
return DST(color);
}
template <>
inline quint32 qt_colorConvert(const quint16 color, const quint32 dummy)
{
@ -1697,24 +1654,6 @@ const uint qt_bayer_matrix[16][16] = {
#define ARGB_COMBINE_ALPHA(argb, alpha) \
((((argb >> 24) * alpha) >> 8) << 24) | (argb & 0x00ffffff)
#if QT_POINTER_SIZE == 8 // 64-bit versions
#define AMIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
#define MIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
#else // 32 bits
// The mask for alpha can overflow over 32 bits
#define AMIX(mask) quint32(qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
#define MIX(mask) (qMin(((quint32(s)&mask) + (quint32(d)&mask)), quint32(mask)))
#endif
inline int comp_func_Plus_one_pixel(uint d, const uint s)
{
return (AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
}
#undef MIX
#undef AMIX
QT_END_NAMESPACE
#endif // QDRAWHELPER_P_H