mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 04:24:28 +00:00
sw_engine: code refactoring
Introduced a blender alpha() to maintain clean and organized code.
This commit is contained in:
parent
72f89fcf53
commit
5643ecabd8
4 changed files with 75 additions and 72 deletions
|
@ -238,10 +238,13 @@ struct SwImage
|
||||||
bool scaled = false; //draw scaled image
|
bool scaled = false; //draw scaled image
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef uint32_t(*SwJoin)(uint8_t r, uint8_t g, uint8_t b, uint8_t a); //color channel join
|
||||||
|
typedef uint8_t(*SwAlpha)(uint8_t*); //blending alpha
|
||||||
|
|
||||||
struct SwBlender
|
struct SwBlender
|
||||||
{
|
{
|
||||||
uint32_t (*join)(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
SwJoin join;
|
||||||
uint8_t (*alpha[(int)CompositeMethod::InvLumaMask + 1])(uint8_t*);
|
SwAlpha alpha[(int)CompositeMethod::InvLumaMask + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SwCompositor;
|
struct SwCompositor;
|
||||||
|
|
|
@ -177,7 +177,7 @@ void _rasterGrayscale8(uint8_t *dst, uint32_t val, uint32_t offset, int32_t len)
|
||||||
/* Rect */
|
/* Rect */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterMaskedRect(SwSurface* surface, const SwBBox& region, uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint8_t(*blender)(uint8_t*))
|
static bool _rasterMaskedRect(SwSurface* surface, const SwBBox& region, uint8_t r, uint8_t g, uint8_t b, uint8_t a, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
auto w = static_cast<uint32_t>(region.max.x - region.min.x);
|
auto w = static_cast<uint32_t>(region.max.x - region.min.x);
|
||||||
auto h = static_cast<uint32_t>(region.max.y - region.min.y);
|
auto h = static_cast<uint32_t>(region.max.y - region.min.y);
|
||||||
|
@ -194,7 +194,7 @@ static bool _rasterMaskedRect(SwSurface* surface, const SwBBox& region, uint8_t
|
||||||
auto dst = &buffer[y * surface->stride];
|
auto dst = &buffer[y * surface->stride];
|
||||||
auto cmp = &cbuffer[y * surface->stride * csize];
|
auto cmp = &cbuffer[y * surface->stride * csize];
|
||||||
for (uint32_t x = 0; x < w; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = 0; x < w; ++x, ++dst, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(color, blender(cmp));
|
auto tmp = ALPHA_BLEND(color, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ static bool _rasterMaskedRect(SwSurface* surface, const SwBBox& region, uint8_t
|
||||||
auto dst = &buffer[y * surface->stride];
|
auto dst = &buffer[y * surface->stride];
|
||||||
auto cmp = &cbuffer[y * surface->stride * csize];
|
auto cmp = &cbuffer[y * surface->stride * csize];
|
||||||
for (uint32_t x = 0; x < w; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = 0; x < w; ++x, ++dst, cmp += csize) {
|
||||||
auto tmp = _multiply<uint8_t>(a, blender(cmp));
|
auto tmp = _multiply<uint8_t>(a, alpha(cmp));
|
||||||
*dst = tmp + _multiply<uint8_t>(*dst, _ialpha(tmp));
|
*dst = tmp + _multiply<uint8_t>(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ static bool _rasterRect(SwSurface* surface, const SwBBox& region, uint8_t r, uin
|
||||||
/* Rle */
|
/* Rle */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterMaskedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint8_t(*blender)(uint8_t*))
|
static bool _rasterMaskedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Masked Rle");
|
TVGLOG("SW_ENGINE", "Masked Rle");
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ static bool _rasterMaskedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint
|
||||||
if (span->coverage == 255) src = color;
|
if (span->coverage == 255) src = color;
|
||||||
else src = ALPHA_BLEND(color, span->coverage);
|
else src = ALPHA_BLEND(color, span->coverage);
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(src, blender(cmp));
|
auto tmp = ALPHA_BLEND(src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ static bool _rasterMaskedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint
|
||||||
if (span->coverage == 255) src = a;
|
if (span->coverage == 255) src = a;
|
||||||
else src = _multiply<uint8_t>(a, span->coverage);
|
else src = _multiply<uint8_t>(a, span->coverage);
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, cmp += csize) {
|
||||||
auto tmp = _multiply<uint8_t>(src, blender(cmp));
|
auto tmp = _multiply<uint8_t>(src, alpha(cmp));
|
||||||
*dst = tmp + _multiply<uint8_t>(*dst, _ialpha(tmp));
|
*dst = tmp + _multiply<uint8_t>(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ static bool _transformedRleRGBAImage(SwSurface* surface, const SwImage* image, c
|
||||||
/* RLE Scaled RGBA Image */
|
/* RLE Scaled RGBA Image */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterScaledMaskedTranslucentRleRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t opacity, uint32_t halfScale, uint8_t(*blender)(uint8_t*))
|
static bool _rasterScaledMaskedTranslucentRleRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t opacity, uint32_t halfScale, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Scaled Masked Translucent Rle Image");
|
TVGLOG("SW_ENGINE", "Scaled Masked Translucent Rle Image");
|
||||||
|
|
||||||
|
@ -395,12 +395,12 @@ static bool _rasterScaledMaskedTranslucentRleRGBAImage(SwSurface* surface, const
|
||||||
if (sy >= image->h) continue;
|
if (sy >= image->h) continue;
|
||||||
auto dst = &surface->buf32[span->y * surface->stride + span->x];
|
auto dst = &surface->buf32[span->y * surface->stride + span->x];
|
||||||
auto cmp = &surface->compositor->image.buf8[(span->y * surface->compositor->image.stride + span->x) * csize];
|
auto cmp = &surface->compositor->image.buf8[(span->y * surface->compositor->image.stride + span->x) * csize];
|
||||||
auto alpha = _multiply<uint32_t>(span->coverage, opacity);
|
auto a = _multiply<uint32_t>(span->coverage, opacity);
|
||||||
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
||||||
if (sx >= image->w) continue;
|
if (sx >= image->w) continue;
|
||||||
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), alpha);
|
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), a);
|
||||||
auto tmp = ALPHA_BLEND(src, blender(cmp));
|
auto tmp = ALPHA_BLEND(src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,12 +411,12 @@ static bool _rasterScaledMaskedTranslucentRleRGBAImage(SwSurface* surface, const
|
||||||
if ((uint32_t)sy >= image->h) continue;
|
if ((uint32_t)sy >= image->h) continue;
|
||||||
auto dst = &surface->buf32[span->y * surface->stride + span->x];
|
auto dst = &surface->buf32[span->y * surface->stride + span->x];
|
||||||
auto cmp = &surface->compositor->image.buf8[(span->y * surface->compositor->image.stride + span->x) * csize];
|
auto cmp = &surface->compositor->image.buf8[(span->y * surface->compositor->image.stride + span->x) * csize];
|
||||||
auto alpha = _multiply<uint32_t>(span->coverage, opacity);
|
auto a = _multiply<uint32_t>(span->coverage, opacity);
|
||||||
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = x * itransform->e11 + itransform->e13;
|
auto sx = x * itransform->e11 + itransform->e13;
|
||||||
if ((uint32_t)sx >= image->w) continue;
|
if ((uint32_t)sx >= image->w) continue;
|
||||||
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), alpha);
|
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), a);
|
||||||
auto tmp = ALPHA_BLEND(src, blender(cmp));
|
auto tmp = ALPHA_BLEND(src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,7 +425,7 @@ static bool _rasterScaledMaskedTranslucentRleRGBAImage(SwSurface* surface, const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool _rasterScaledMaskedRleRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t halfScale, uint8_t(*blender)(uint8_t*))
|
static bool _rasterScaledMaskedRleRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t halfScale, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Scaled Masked Rle Image");
|
TVGLOG("SW_ENGINE", "Scaled Masked Rle Image");
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ static bool _rasterScaledMaskedRleRGBAImage(SwSurface* surface, const SwImage* i
|
||||||
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
||||||
if (sx >= image->w) continue;
|
if (sx >= image->w) continue;
|
||||||
auto tmp = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), blender(cmp));
|
auto tmp = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -451,7 +451,7 @@ static bool _rasterScaledMaskedRleRGBAImage(SwSurface* surface, const SwImage* i
|
||||||
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
||||||
if (sx >= image->w) continue;
|
if (sx >= image->w) continue;
|
||||||
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), span->coverage);
|
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), span->coverage);
|
||||||
auto tmp = ALPHA_BLEND(src, blender(cmp));
|
auto tmp = ALPHA_BLEND(src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ static bool _rasterScaledMaskedRleRGBAImage(SwSurface* surface, const SwImage* i
|
||||||
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
for (uint32_t x = static_cast<uint32_t>(span->x); x < static_cast<uint32_t>(span->x) + span->len; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = x * itransform->e11 + itransform->e13;
|
auto sx = x * itransform->e11 + itransform->e13;
|
||||||
if ((uint32_t)sx >= image->w) continue;
|
if ((uint32_t)sx >= image->w) continue;
|
||||||
auto tmp = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), blender(cmp));
|
auto tmp = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -475,7 +475,7 @@ static bool _rasterScaledMaskedRleRGBAImage(SwSurface* surface, const SwImage* i
|
||||||
auto sx = x * itransform->e11 + itransform->e13;
|
auto sx = x * itransform->e11 + itransform->e13;
|
||||||
if ((uint32_t)sx >= image->w) continue;
|
if ((uint32_t)sx >= image->w) continue;
|
||||||
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), span->coverage);
|
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), span->coverage);
|
||||||
auto tmp = ALPHA_BLEND(src, blender(cmp));
|
auto tmp = ALPHA_BLEND(src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -601,7 +601,7 @@ static bool _scaledRleRGBAImage(SwSurface* surface, const SwImage* image, const
|
||||||
/* RLE Direct RGBA Image */
|
/* RLE Direct RGBA Image */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterDirectMaskedTranslucentRleRGBAImage(SwSurface* surface, const SwImage* image, uint32_t opacity, uint8_t(*blender)(uint8_t*))
|
static bool _rasterDirectMaskedTranslucentRleRGBAImage(SwSurface* surface, const SwImage* image, uint32_t opacity, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Direct Masked Rle Image");
|
TVGLOG("SW_ENGINE", "Direct Masked Rle Image");
|
||||||
|
|
||||||
|
@ -613,15 +613,15 @@ static bool _rasterDirectMaskedTranslucentRleRGBAImage(SwSurface* surface, const
|
||||||
auto dst = &surface->buf32[span->y * surface->stride + span->x];
|
auto dst = &surface->buf32[span->y * surface->stride + span->x];
|
||||||
auto cmp = &cbuffer[(span->y * surface->compositor->image.stride + span->x) * csize];
|
auto cmp = &cbuffer[(span->y * surface->compositor->image.stride + span->x) * csize];
|
||||||
auto img = image->buf32 + (span->y + image->oy) * image->stride + (span->x + image->ox);
|
auto img = image->buf32 + (span->y + image->oy) * image->stride + (span->x + image->ox);
|
||||||
auto alpha = _multiply<uint32_t>(span->coverage, opacity);
|
auto a = _multiply<uint32_t>(span->coverage, opacity);
|
||||||
if (alpha == 255) {
|
if (a == 255) {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*img, blender(cmp));
|
auto tmp = ALPHA_BLEND(*img, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*img, _multiply<uint32_t>(alpha, blender(cmp)));
|
auto tmp = ALPHA_BLEND(*img, _multiply<uint32_t>(a, alpha(cmp)));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ static bool _rasterDirectMaskedTranslucentRleRGBAImage(SwSurface* surface, const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool _rasterDirectMaskedRleRGBAImage(SwSurface* surface, const SwImage* image, uint8_t(*blender)(uint8_t*))
|
static bool _rasterDirectMaskedRleRGBAImage(SwSurface* surface, const SwImage* image, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Direct Masked Rle Image");
|
TVGLOG("SW_ENGINE", "Direct Masked Rle Image");
|
||||||
|
|
||||||
|
@ -644,12 +644,12 @@ static bool _rasterDirectMaskedRleRGBAImage(SwSurface* surface, const SwImage* i
|
||||||
auto img = image->buf32 + (span->y + image->oy) * image->stride + (span->x + image->ox);
|
auto img = image->buf32 + (span->y + image->oy) * image->stride + (span->x + image->ox);
|
||||||
if (span->coverage == 255) {
|
if (span->coverage == 255) {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*img, blender(cmp));
|
auto tmp = ALPHA_BLEND(*img, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++img, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*img, _multiply<uint32_t>(span->coverage, blender(cmp)));
|
auto tmp = ALPHA_BLEND(*img, _multiply<uint32_t>(span->coverage, alpha(cmp)));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -742,7 +742,7 @@ static bool _transformedRGBAImageMesh(SwSurface* surface, const SwImage* image,
|
||||||
/*Scaled RGBA Image */
|
/*Scaled RGBA Image */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterScaledMaskedTranslucentRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t opacity, uint32_t halfScale, uint8_t(*blender)(uint8_t*))
|
static bool _rasterScaledMaskedTranslucentRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t opacity, uint32_t halfScale, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Scaled Masked Image");
|
TVGLOG("SW_ENGINE", "Scaled Masked Image");
|
||||||
|
|
||||||
|
@ -760,8 +760,8 @@ static bool _rasterScaledMaskedTranslucentRGBAImage(SwSurface* surface, const Sw
|
||||||
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
||||||
if (sx >= image->w) continue;
|
if (sx >= image->w) continue;
|
||||||
auto alpha = _multiply<uint32_t>(opacity, blender(cmp));
|
auto a = _multiply<uint32_t>(opacity, alpha(cmp));
|
||||||
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), alpha);
|
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), a);
|
||||||
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
||||||
}
|
}
|
||||||
dbuffer += surface->stride;
|
dbuffer += surface->stride;
|
||||||
|
@ -777,8 +777,8 @@ static bool _rasterScaledMaskedTranslucentRGBAImage(SwSurface* surface, const Sw
|
||||||
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = x * itransform->e11 + itransform->e13;
|
auto sx = x * itransform->e11 + itransform->e13;
|
||||||
if ((uint32_t)sx >= image->w) continue;
|
if ((uint32_t)sx >= image->w) continue;
|
||||||
auto alpha = _multiply<uint32_t>(opacity, blender(cmp));
|
auto a = _multiply<uint32_t>(opacity, alpha(cmp));
|
||||||
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), alpha);
|
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), a);
|
||||||
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
||||||
}
|
}
|
||||||
dbuffer += surface->stride;
|
dbuffer += surface->stride;
|
||||||
|
@ -789,7 +789,7 @@ static bool _rasterScaledMaskedTranslucentRGBAImage(SwSurface* surface, const Sw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool _rasterScaledMaskedRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t halfScale, uint8_t (*blender)(uint8_t*))
|
static bool _rasterScaledMaskedRGBAImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const SwBBox& region, uint32_t halfScale, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Scaled Masked Image");
|
TVGLOG("SW_ENGINE", "Scaled Masked Image");
|
||||||
|
|
||||||
|
@ -807,7 +807,7 @@ static bool _rasterScaledMaskedRGBAImage(SwSurface* surface, const SwImage* imag
|
||||||
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
auto sx = (uint32_t)(x * itransform->e11 + itransform->e13);
|
||||||
if (sx >= image->w) continue;
|
if (sx >= image->w) continue;
|
||||||
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), blender(cmp));
|
auto src = ALPHA_BLEND(_interpDownScaler(image->buf32, image->stride, image->w, image->h, sx, sy, halfScale), alpha(cmp));
|
||||||
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
||||||
}
|
}
|
||||||
dbuffer += surface->stride;
|
dbuffer += surface->stride;
|
||||||
|
@ -823,7 +823,7 @@ static bool _rasterScaledMaskedRGBAImage(SwSurface* surface, const SwImage* imag
|
||||||
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) {
|
||||||
auto sx = x * itransform->e11 + itransform->e13;
|
auto sx = x * itransform->e11 + itransform->e13;
|
||||||
if ((uint32_t)sx >= image->w) continue;
|
if ((uint32_t)sx >= image->w) continue;
|
||||||
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), blender(cmp));
|
auto src = ALPHA_BLEND(_interpUpScaler(image->buf32, image->w, image->h, sx, sy), alpha(cmp));
|
||||||
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
*dst = src + ALPHA_BLEND(*dst, _ialpha(src));
|
||||||
}
|
}
|
||||||
dbuffer += surface->stride;
|
dbuffer += surface->stride;
|
||||||
|
@ -930,7 +930,7 @@ static bool _scaledRGBAImage(SwSurface* surface, const SwImage* image, const Mat
|
||||||
/* Direct RGBA Image */
|
/* Direct RGBA Image */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterDirectMaskedRGBAImage(SwSurface* surface, const SwImage* image, const SwBBox& region, uint8_t (*blender)(uint8_t*))
|
static bool _rasterDirectMaskedRGBAImage(SwSurface* surface, const SwImage* image, const SwBBox& region, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Direct Masked Image");
|
TVGLOG("SW_ENGINE", "Direct Masked Image");
|
||||||
|
|
||||||
|
@ -947,7 +947,7 @@ static bool _rasterDirectMaskedRGBAImage(SwSurface* surface, const SwImage* imag
|
||||||
auto cmp = cbuffer;
|
auto cmp = cbuffer;
|
||||||
auto src = sbuffer;
|
auto src = sbuffer;
|
||||||
for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, blender(cmp));
|
auto tmp = ALPHA_BLEND(*src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
buffer += surface->stride;
|
buffer += surface->stride;
|
||||||
|
@ -958,7 +958,7 @@ static bool _rasterDirectMaskedRGBAImage(SwSurface* surface, const SwImage* imag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool _rasterDirectMaskedTranslucentRGBAImage(SwSurface* surface, const SwImage* image, const SwBBox& region, uint32_t opacity, uint8_t (*blender)(uint8_t*))
|
static bool _rasterDirectMaskedTranslucentRGBAImage(SwSurface* surface, const SwImage* image, const SwBBox& region, uint32_t opacity, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
TVGLOG("SW_ENGINE", "Direct Masked Translucent Image");
|
TVGLOG("SW_ENGINE", "Direct Masked Translucent Image");
|
||||||
|
|
||||||
|
@ -975,7 +975,7 @@ static bool _rasterDirectMaskedTranslucentRGBAImage(SwSurface* surface, const Sw
|
||||||
auto cmp = cbuffer;
|
auto cmp = cbuffer;
|
||||||
auto src = sbuffer;
|
auto src = sbuffer;
|
||||||
for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, _multiply<uint32_t>(opacity, blender(cmp)));
|
auto tmp = ALPHA_BLEND(*src, _multiply<uint32_t>(opacity, alpha(cmp)));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
buffer += surface->stride;
|
buffer += surface->stride;
|
||||||
|
@ -1059,7 +1059,7 @@ static bool _rasterRGBAImage(SwSurface* surface, SwImage* image, const Matrix* t
|
||||||
/* Rect Linear Gradient */
|
/* Rect Linear Gradient */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterLinearGradientMaskedRect(SwSurface* surface, const SwBBox& region, const SwFill* fill, uint8_t (*blender)(uint8_t*))
|
static bool _rasterLinearGradientMaskedRect(SwSurface* surface, const SwBBox& region, const SwFill* fill, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
if (fill->linear.len < FLT_EPSILON) return false;
|
if (fill->linear.len < FLT_EPSILON) return false;
|
||||||
|
|
||||||
|
@ -1078,7 +1078,7 @@ static bool _rasterLinearGradientMaskedRect(SwSurface* surface, const SwBBox& re
|
||||||
auto cmp = cbuffer;
|
auto cmp = cbuffer;
|
||||||
auto src = sbuffer;
|
auto src = sbuffer;
|
||||||
for (uint32_t x = 0; x < w; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < w; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, blender(cmp));
|
auto tmp = ALPHA_BLEND(*src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
buffer += surface->stride;
|
buffer += surface->stride;
|
||||||
|
@ -1143,7 +1143,7 @@ static bool _rasterLinearGradientRect(SwSurface* surface, const SwBBox& region,
|
||||||
/* Rle Linear Gradient */
|
/* Rle Linear Gradient */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterLinearGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill, uint8_t (*blender)(uint8_t*))
|
static bool _rasterLinearGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
if (fill->linear.len < FLT_EPSILON) return false;
|
if (fill->linear.len < FLT_EPSILON) return false;
|
||||||
|
|
||||||
|
@ -1160,13 +1160,13 @@ static bool _rasterLinearGradientMaskedRle(SwSurface* surface, const SwRleData*
|
||||||
auto src = buffer;
|
auto src = buffer;
|
||||||
if (span->coverage == 255) {
|
if (span->coverage == 255) {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, blender(cmp));
|
auto tmp = ALPHA_BLEND(*src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto ialpha = 255 - span->coverage;
|
auto ialpha = 255 - span->coverage;
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, blender(cmp));
|
auto tmp = ALPHA_BLEND(*src, alpha(cmp));
|
||||||
tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
|
tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
|
@ -1245,7 +1245,7 @@ static bool _rasterLinearGradientRle(SwSurface* surface, const SwRleData* rle, c
|
||||||
/* Rect Radial Gradient */
|
/* Rect Radial Gradient */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterRadialGradientMaskedRect(SwSurface* surface, const SwBBox& region, const SwFill* fill, uint8_t(*blender)(uint8_t*))
|
static bool _rasterRadialGradientMaskedRect(SwSurface* surface, const SwBBox& region, const SwFill* fill, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
if (fill->radial.a < FLT_EPSILON) return false;
|
if (fill->radial.a < FLT_EPSILON) return false;
|
||||||
|
|
||||||
|
@ -1264,7 +1264,7 @@ static bool _rasterRadialGradientMaskedRect(SwSurface* surface, const SwBBox& re
|
||||||
auto cmp = cbuffer;
|
auto cmp = cbuffer;
|
||||||
auto src = sbuffer;
|
auto src = sbuffer;
|
||||||
for (uint32_t x = 0; x < w; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < w; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, blender(cmp));
|
auto tmp = ALPHA_BLEND(*src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
buffer += surface->stride;
|
buffer += surface->stride;
|
||||||
|
@ -1330,7 +1330,7 @@ static bool _rasterRadialGradientRect(SwSurface* surface, const SwBBox& region,
|
||||||
/* RLE Radial Gradient */
|
/* RLE Radial Gradient */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
static bool _rasterRadialGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill, uint8_t(*blender)(uint8_t*))
|
static bool _rasterRadialGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
if (fill->radial.a < FLT_EPSILON) return false;
|
if (fill->radial.a < FLT_EPSILON) return false;
|
||||||
|
|
||||||
|
@ -1347,12 +1347,12 @@ static bool _rasterRadialGradientMaskedRle(SwSurface* surface, const SwRleData*
|
||||||
auto src = buffer;
|
auto src = buffer;
|
||||||
if (span->coverage == 255) {
|
if (span->coverage == 255) {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = ALPHA_BLEND(*src, blender(cmp));
|
auto tmp = ALPHA_BLEND(*src, alpha(cmp));
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src, cmp += csize) {
|
||||||
auto tmp = INTERPOLATE(span->coverage, ALPHA_BLEND(*src, blender(cmp)), *dst);
|
auto tmp = INTERPOLATE(span->coverage, ALPHA_BLEND(*src, alpha(cmp)), *dst);
|
||||||
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
*dst = tmp + ALPHA_BLEND(*dst, _ialpha(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ static bool _arrange(const SwImage* image, const SwBBox* region, int& yStart, in
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, const SwBBox* region, int yStart, int yEnd, uint32_t opacity, uint8_t(*blender)(uint8_t*), AASpans* aaSpans)
|
static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, const SwBBox* region, int yStart, int yEnd, uint32_t opacity, SwAlpha alpha, AASpans* aaSpans)
|
||||||
{
|
{
|
||||||
#define TEXMAP_TRANSLUCENT
|
#define TEXMAP_TRANSLUCENT
|
||||||
#define TEXMAP_MASKING
|
#define TEXMAP_MASKING
|
||||||
|
@ -79,7 +79,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, const SwBBox* region, int yStart, int yEnd, uint8_t(*blender)(uint8_t*), AASpans* aaSpans)
|
static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, const SwBBox* region, int yStart, int yEnd, SwAlpha alpha, AASpans* aaSpans)
|
||||||
{
|
{
|
||||||
#define TEXMAP_MASKING
|
#define TEXMAP_MASKING
|
||||||
#include "tvgSwRasterTexmapInternal.h"
|
#include "tvgSwRasterTexmapInternal.h"
|
||||||
|
@ -102,7 +102,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image,
|
||||||
|
|
||||||
|
|
||||||
/* This mapping algorithm is based on Mikael Kalms's. */
|
/* This mapping algorithm is based on Mikael Kalms's. */
|
||||||
static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const SwBBox* region, uint32_t opacity, Polygon& polygon, uint8_t(*blender)(uint8_t*), AASpans* aaSpans)
|
static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const SwBBox* region, uint32_t opacity, Polygon& polygon, SwAlpha alpha, AASpans* aaSpans)
|
||||||
{
|
{
|
||||||
float x[3] = {polygon.vertex[0].pt.x, polygon.vertex[1].pt.x, polygon.vertex[2].pt.x};
|
float x[3] = {polygon.vertex[0].pt.x, polygon.vertex[1].pt.x, polygon.vertex[2].pt.x};
|
||||||
float y[3] = {polygon.vertex[0].pt.y, polygon.vertex[1].pt.y, polygon.vertex[2].pt.y};
|
float y[3] = {polygon.vertex[0].pt.y, polygon.vertex[1].pt.y, polygon.vertex[2].pt.y};
|
||||||
|
@ -190,9 +190,9 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
|
||||||
dxdyb = dxdy[0];
|
dxdyb = dxdy[0];
|
||||||
xb = x[0] + dy * dxdyb + (off_y * dxdyb);
|
xb = x[0] + dy * dxdyb + (off_y * dxdyb);
|
||||||
|
|
||||||
if (blender) {
|
if (alpha) {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], blender, aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], alpha, aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, blender, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, alpha, aaSpans);
|
||||||
} else {
|
} else {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, aaSpans);
|
||||||
|
@ -211,9 +211,9 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
|
||||||
// Set right edge X-slope and perform subpixel pre-stepping
|
// Set right edge X-slope and perform subpixel pre-stepping
|
||||||
dxdyb = dxdy[2];
|
dxdyb = dxdy[2];
|
||||||
xb = x[1] + (1 - (y[1] - yi[1])) * dxdyb + (off_y * dxdyb);
|
xb = x[1] + (1 - (y[1] - yi[1])) * dxdyb + (off_y * dxdyb);
|
||||||
if (blender) {
|
if (alpha) {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], blender, aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], alpha, aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, blender, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, alpha, aaSpans);
|
||||||
} else {
|
} else {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, aaSpans);
|
||||||
|
@ -240,9 +240,9 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
|
||||||
ua = u[0] + dy * dudya + (off_y * dudya);
|
ua = u[0] + dy * dudya + (off_y * dudya);
|
||||||
va = v[0] + dy * dvdya + (off_y * dvdya);
|
va = v[0] + dy * dvdya + (off_y * dvdya);
|
||||||
|
|
||||||
if (blender) {
|
if (alpha) {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], blender, aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], alpha, aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, blender, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, alpha, aaSpans);
|
||||||
} else {
|
} else {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], opacity, aaSpans);
|
||||||
|
@ -264,9 +264,9 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
|
||||||
ua = u[1] + dy * dudya + (off_y * dudya);
|
ua = u[1] + dy * dudya + (off_y * dudya);
|
||||||
va = v[1] + dy * dvdya + (off_y * dvdya);
|
va = v[1] + dy * dvdya + (off_y * dvdya);
|
||||||
|
|
||||||
if (blender) {
|
if (alpha) {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], blender, aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], alpha, aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, blender, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, alpha, aaSpans);
|
||||||
} else {
|
} else {
|
||||||
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans);
|
if (opacity == 255) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans);
|
||||||
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, aaSpans);
|
else _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], opacity, aaSpans);
|
||||||
|
@ -545,7 +545,7 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans)
|
||||||
| / |
|
| / |
|
||||||
3 -- 2
|
3 -- 2
|
||||||
*/
|
*/
|
||||||
static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const Matrix* transform, const SwBBox* region, uint32_t opacity, uint8_t(*blender)(uint8_t*))
|
static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const Matrix* transform, const SwBBox* region, uint32_t opacity, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
//Exceptions: No dedicated drawing area?
|
//Exceptions: No dedicated drawing area?
|
||||||
if ((!image->rle && !region) || (image->rle && image->rle->size == 0)) return false;
|
if ((!image->rle && !region) || (image->rle && image->rle->size == 0)) return false;
|
||||||
|
@ -576,14 +576,14 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const
|
||||||
polygon.vertex[1] = vertices[1];
|
polygon.vertex[1] = vertices[1];
|
||||||
polygon.vertex[2] = vertices[3];
|
polygon.vertex[2] = vertices[3];
|
||||||
|
|
||||||
_rasterPolygonImage(surface, image, region, opacity, polygon, blender, aaSpans);
|
_rasterPolygonImage(surface, image, region, opacity, polygon, alpha, aaSpans);
|
||||||
|
|
||||||
//Draw the second polygon
|
//Draw the second polygon
|
||||||
polygon.vertex[0] = vertices[1];
|
polygon.vertex[0] = vertices[1];
|
||||||
polygon.vertex[1] = vertices[2];
|
polygon.vertex[1] = vertices[2];
|
||||||
polygon.vertex[2] = vertices[3];
|
polygon.vertex[2] = vertices[3];
|
||||||
|
|
||||||
_rasterPolygonImage(surface, image, region, opacity, polygon, blender, aaSpans);
|
_rasterPolygonImage(surface, image, region, opacity, polygon, alpha, aaSpans);
|
||||||
|
|
||||||
return _apply(surface, aaSpans);
|
return _apply(surface, aaSpans);
|
||||||
}
|
}
|
||||||
|
@ -602,7 +602,7 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const
|
||||||
Should provide two Polygons, one for each triangle.
|
Should provide two Polygons, one for each triangle.
|
||||||
// TODO: region?
|
// TODO: region?
|
||||||
*/
|
*/
|
||||||
static bool _rasterTexmapPolygonMesh(SwSurface* surface, const SwImage* image, const RenderMesh* mesh, const Matrix* transform, const SwBBox* region, uint32_t opacity, uint8_t(*blender)(uint8_t*))
|
static bool _rasterTexmapPolygonMesh(SwSurface* surface, const SwImage* image, const RenderMesh* mesh, const Matrix* transform, const SwBBox* region, uint32_t opacity, SwAlpha alpha)
|
||||||
{
|
{
|
||||||
//Exceptions: No dedicated drawing area?
|
//Exceptions: No dedicated drawing area?
|
||||||
if ((!image->rle && !region) || (image->rle && image->rle->size == 0)) return false;
|
if ((!image->rle && !region) || (image->rle && image->rle->size == 0)) return false;
|
||||||
|
@ -636,7 +636,7 @@ static bool _rasterTexmapPolygonMesh(SwSurface* surface, const SwImage* image, c
|
||||||
auto aaSpans = _AASpans(ys, ye, image, region);
|
auto aaSpans = _AASpans(ys, ye, image, region);
|
||||||
if (aaSpans) {
|
if (aaSpans) {
|
||||||
for (uint32_t i = 0; i < mesh->triangleCnt; i++) {
|
for (uint32_t i = 0; i < mesh->triangleCnt; i++) {
|
||||||
_rasterPolygonImage(surface, image, region, opacity, transformedTris[i], blender, aaSpans);
|
_rasterPolygonImage(surface, image, region, opacity, transformedTris[i], alpha, aaSpans);
|
||||||
}
|
}
|
||||||
// Apply to surface (note: frees the AA spans)
|
// Apply to surface (note: frees the AA spans)
|
||||||
_apply(surface, aaSpans);
|
_apply(surface, aaSpans);
|
||||||
|
|
|
@ -131,9 +131,9 @@
|
||||||
px = INTERPOLATE(ab, px, px2);
|
px = INTERPOLATE(ab, px, px2);
|
||||||
}
|
}
|
||||||
#if defined(TEXMAP_MASKING) && defined(TEXMAP_TRANSLUCENT)
|
#if defined(TEXMAP_MASKING) && defined(TEXMAP_TRANSLUCENT)
|
||||||
auto src = ALPHA_BLEND(px, _multiply<uint32_t>(opacity, blender(cmp)));
|
auto src = ALPHA_BLEND(px, _multiply<uint32_t>(opacity, alpha(cmp)));
|
||||||
#elif defined(TEXMAP_MASKING)
|
#elif defined(TEXMAP_MASKING)
|
||||||
auto src = ALPHA_BLEND(px, blender(cmp));
|
auto src = ALPHA_BLEND(px, alpha(cmp));
|
||||||
#elif defined(TEXMAP_TRANSLUCENT)
|
#elif defined(TEXMAP_TRANSLUCENT)
|
||||||
auto src = ALPHA_BLEND(px, opacity);
|
auto src = ALPHA_BLEND(px, opacity);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue