((((c & 0x00ff00ff) * a + 0x00ff00ff) >> 8) & 0x00ff00ff));
}
-static inline uint32_t COLOR_INTERPOLATE(uint32_t c1, uint32_t a1, uint32_t c2, uint32_t a2)
+static inline uint32_t INTERPOLATE(uint32_t a, uint32_t c0, uint32_t c1)
{
- auto t = (((c1 & 0xff00ff) * a1 + (c2 & 0xff00ff) * a2) >> 8) & 0xff00ff;
- c1 = (((c1 >> 8) & 0xff00ff) * a1 + ((c2 >> 8) & 0xff00ff) * a2) & 0xff00ff00;
- return (c1 |= t);
+ return (((((((c0 >> 8) & 0xff00ff) - ((c1 >> 8) & 0xff00ff)) * a) + (c1 & 0xff00ff00)) & 0xff00ff00) + ((((((c0 & 0xff00ff) - (c1 & 0xff00ff)) * a) >> 8) + (c1 & 0xff00ff)) & 0xff00ff));
}
static inline SwCoord HALF_STROKE(float width)
}
-static inline uint32_t _interpolate(uint32_t a, uint32_t c0, uint32_t c1)
-{
- return (((((((c0 >> 8) & 0xff00ff) - ((c1 >> 8) & 0xff00ff)) * a) + (c1 & 0xff00ff00)) & 0xff00ff00) + ((((((c0 & 0xff00ff) - (c1 & 0xff00ff)) * a) >> 8) + (c1 & 0xff00ff)) & 0xff00ff));
-}
-
-
#include "tvgSwRasterTexmap.h"
#include "tvgSwRasterC.h"
#include "tvgSwRasterAvx.h"
auto c3 = img[(rx + 1) + ((ry + 1) * w)];
auto c4 = img[rx + ((ry + 1) * w)];
- return COLOR_INTERPOLATE(COLOR_INTERPOLATE(c1, 255 - dx, c2, dx), 255 - dy, COLOR_INTERPOLATE(c4, 255 - dx, c3, dx), dy);
+ return INTERPOLATE(dy, INTERPOLATE(dx, c3, c4), INTERPOLATE(dx, c2, c1));
}
fillFetchLinear(fill, surface->buffer + span->y * surface->stride + span->x, span->y, span->x, span->len);
} else {
fillFetchLinear(fill, buf, span->y, span->x, span->len);
- auto ialpha = 255 - span->coverage;
auto dst = &surface->buffer[span->y * surface->stride + span->x];
for (uint32_t i = 0; i < span->len; ++i) {
- dst[i] = ALPHA_BLEND(buf[i], span->coverage) + ALPHA_BLEND(dst[i], ialpha);
+ dst[i] = INTERPOLATE(span->coverage, buf[i], dst[i]);
}
}
}
*dst = tmp + ALPHA_BLEND(*dst, surface->blender.ialpha(tmp));
}
} else {
- auto ialpha = 255 - span->coverage;
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
- auto tmp = ALPHA_BLEND(*src, blendMethod(*cmp));
- tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
+ auto tmp = INTERPOLATE(span->coverage, ALPHA_BLEND(*src, blendMethod(*cmp)), *dst);
*dst = tmp + ALPHA_BLEND(*dst, surface->blender.ialpha(tmp));
}
}
if (iru < sw) {
/* right pixel */
int px2 = *(sbuf + (vv * sw) + iru);
- px = _interpolate(ar, px, px2);
+ px = INTERPOLATE(ar, px, px2);
}
/* vertical interpolate */
if (irv < sh) {
if (iru < sw) {
/* bottom right pixel */
int px3 = *(sbuf + (irv * sw) + iru);
- px2 = _interpolate(ar, px2, px3);
+ px2 = INTERPOLATE(ar, px2, px3);
}
- px = _interpolate(ab, px, px2);
+ px = INTERPOLATE(ab, px, px2);
}
#if defined(TEXMAP_MAKSING) && defined(TEXTMAP_TRANSLUCENT)
auto src = ALPHA_BLEND(px, _multiplyAlpha(opacity, blendMethod(*cmp)));