sw_engine: code refactoring

just renamed internal variables (region -> bbox)
for the sake of a shorter name, no logical changes.
This commit is contained in:
Hermet Park 2025-05-27 14:02:44 +09:00 committed by Hermet Park
parent ff3eb052d1
commit f827d99d31
12 changed files with 302 additions and 302 deletions

View file

@ -489,15 +489,15 @@ SwFixed mathLength(const SwPoint& pt);
int mathCubicAngle(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut); int mathCubicAngle(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
SwFixed mathMean(SwFixed angle1, SwFixed angle2); SwFixed mathMean(SwFixed angle1, SwFixed angle2);
SwPoint mathTransform(const Point* to, const Matrix& transform); SwPoint mathTransform(const Point* to, const Matrix& transform);
bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipRegion, RenderRegion& renderRegion, bool fastTrack); bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipBox, RenderRegion& renderBox, bool fastTrack);
void shapeReset(SwShape* shape); void shapeReset(SwShape* shape);
bool shapePrepare(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid, bool hasComposite); bool shapePrepare(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid, bool hasComposite);
bool shapePrepared(const SwShape* shape); bool shapePrepared(const SwShape* shape);
bool shapeGenRle(SwShape* shape, const RenderShape* rshape, bool antiAlias); bool shapeGenRle(SwShape* shape, const RenderShape* rshape, bool antiAlias);
void shapeDelOutline(SwShape* shape, SwMpool* mpool, uint32_t tid); void shapeDelOutline(SwShape* shape, SwMpool* mpool, uint32_t tid);
void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& transform); void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& transform);
bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid); bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid);
void shapeFree(SwShape* shape); void shapeFree(SwShape* shape);
void shapeDelStroke(SwShape* shape); void shapeDelStroke(SwShape* shape);
bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix& transform, SwSurface* surface, uint8_t opacity, bool ctable); bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix& transform, SwSurface* surface, uint8_t opacity, bool ctable);
@ -512,8 +512,8 @@ bool strokeParseOutline(SwStroke* stroke, const SwOutline& outline);
SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid); SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid);
void strokeFree(SwStroke* stroke); void strokeFree(SwStroke* stroke);
bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid); bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid);
bool imageGenRle(SwImage* image, const RenderRegion& renderRegion, bool antiAlias); bool imageGenRle(SwImage* image, const RenderRegion& bbox, bool antiAlias);
void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid); void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid);
void imageReset(SwImage* image); void imageReset(SwImage* image);
void imageFree(SwImage* image); void imageFree(SwImage* image);
@ -536,7 +536,7 @@ void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint3
void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, SwBlender op, SwBlender op2, uint8_t a); //blending + BlendingMethod(op2) ver. void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, SwBlender op, SwBlender op2, uint8_t a); //blending + BlendingMethod(op2) ver.
void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, uint8_t* cmp, SwAlpha alpha, uint8_t csize, uint8_t opacity); //matting ver. void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, uint8_t* cmp, SwAlpha alpha, uint8_t csize, uint8_t opacity); //matting ver.
SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& renderRegion, bool antiAlias); SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& bbox, bool antiAlias);
SwRle* rleRender(const RenderRegion* bbox); SwRle* rleRender(const RenderRegion* bbox);
void rleFree(SwRle* rle); void rleFree(SwRle* rle);
void rleReset(SwRle* rle); void rleReset(SwRle* rle);

View file

@ -72,7 +72,7 @@ static bool _genOutline(SwImage* image, const Matrix& transform, SwMpool* mpool,
/* External Class Implementation */ /* External Class Implementation */
/************************************************************************/ /************************************************************************/
bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid) bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid)
{ {
image->direct = _onlyShifted(transform); image->direct = _onlyShifted(transform);
@ -91,13 +91,13 @@ bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& c
} }
if (!_genOutline(image, transform, mpool, tid)) return false; if (!_genOutline(image, transform, mpool, tid)) return false;
return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, image->direct); return mathUpdateOutlineBBox(image->outline, clipBox, renderBox, image->direct);
} }
bool imageGenRle(SwImage* image, const RenderRegion& renderRegion, bool antiAlias) bool imageGenRle(SwImage* image, const RenderRegion& renderBox, bool antiAlias)
{ {
if ((image->rle = rleRender(image->rle, image->outline, renderRegion, antiAlias))) return true; if ((image->rle = rleRender(image->rle, image->outline, renderBox, antiAlias))) return true;
return false; return false;
} }

View file

@ -271,12 +271,12 @@ SwPoint mathTransform(const Point* to, const Matrix& transform)
} }
bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipRegion, RenderRegion& renderRegion, bool fastTrack) bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipBox, RenderRegion& renderBox, bool fastTrack)
{ {
if (!outline) return false; if (!outline) return false;
if (outline->pts.empty() || outline->cntrs.empty()) { if (outline->pts.empty() || outline->cntrs.empty()) {
renderRegion.reset(); renderBox.reset();
return false; return false;
} }
@ -295,13 +295,13 @@ bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipReg
} }
if (fastTrack) { if (fastTrack) {
renderRegion.min = {int32_t(round(xMin / 64.0f)), int32_t(round(yMin / 64.0f))}; renderBox.min = {int32_t(round(xMin / 64.0f)), int32_t(round(yMin / 64.0f))};
renderRegion.max = {int32_t(round(xMax / 64.0f)), int32_t(round(yMax / 64.0f))}; renderBox.max = {int32_t(round(xMax / 64.0f)), int32_t(round(yMax / 64.0f))};
} else { } else {
renderRegion.min = {xMin >> 6, yMin >> 6}; renderBox.min = {xMin >> 6, yMin >> 6};
renderRegion.max = {(xMax + 63) >> 6, (yMax + 63) >> 6}; renderBox.max = {(xMax + 63) >> 6, (yMax + 63) >> 6};
} }
renderRegion.intersect(clipRegion); renderBox.intersect(clipBox);
return renderRegion.valid(); return renderBox.valid();
} }

View file

@ -136,17 +136,17 @@ static int _gaussianInit(SwGaussianBlur* data, float sigma, int quality)
bool effectGaussianBlurRegion(RenderEffectGaussianBlur* params) bool effectGaussianBlurRegion(RenderEffectGaussianBlur* params)
{ {
//bbox region expansion for feathering //region expansion for feathering
auto& region = params->extend; auto& bbox = params->extend;
auto extra = static_cast<SwGaussianBlur*>(params->rd)->extends; auto extra = static_cast<SwGaussianBlur*>(params->rd)->extends;
if (params->direction != 2) { if (params->direction != 2) {
region.min.x = -extra; bbox.min.x = -extra;
region.max.x = extra; bbox.max.x = extra;
} }
if (params->direction != 1) { if (params->direction != 1) {
region.min.y = -extra; bbox.min.y = -extra;
region.max.y = extra; bbox.max.y = extra;
} }
return true; return true;
@ -267,20 +267,20 @@ static void _dropShadowFilter(uint32_t* dst, uint32_t* src, int stride, int w, i
} }
static void _dropShadowShift(uint32_t* dst, uint32_t* src, int dstride, int sstride, RenderRegion& region, SwPoint& offset, uint8_t opacity, bool direct) static void _dropShadowShift(uint32_t* dst, uint32_t* src, int dstride, int sstride, RenderRegion& bbox, SwPoint& offset, uint8_t opacity, bool direct)
{ {
src += (region.min.y * sstride + region.min.x); src += (bbox.min.y * sstride + bbox.min.x);
dst += (region.min.y * dstride + region.min.x); dst += (bbox.min.y * dstride + bbox.min.x);
auto w = region.max.x - region.min.x; auto w = bbox.max.x - bbox.min.x;
auto h = region.max.y - region.min.y; auto h = bbox.max.y - bbox.min.y;
auto translucent = (direct || opacity < 255); auto translucent = (direct || opacity < 255);
//shift offset //shift offset
if (region.min.x + offset.x < 0) src -= offset.x; if (bbox.min.x + offset.x < 0) src -= offset.x;
else dst += offset.x; else dst += offset.x;
if (region.min.y + offset.y < 0) src -= (offset.y * sstride); if (bbox.min.y + offset.y < 0) src -= (offset.y * sstride);
else dst += (offset.y * dstride); else dst += (offset.y * dstride);
for (auto y = 0; y < h; ++y) { for (auto y = 0; y < h; ++y) {
@ -294,19 +294,19 @@ static void _dropShadowShift(uint32_t* dst, uint32_t* src, int dstride, int sstr
bool effectDropShadowRegion(RenderEffectDropShadow* params) bool effectDropShadowRegion(RenderEffectDropShadow* params)
{ {
//bbox region expansion for feathering //region expansion for feathering
auto& region = params->extend; auto& bbox = params->extend;
auto& offset = static_cast<SwDropShadow*>(params->rd)->offset; auto& offset = static_cast<SwDropShadow*>(params->rd)->offset;
auto extra = static_cast<SwDropShadow*>(params->rd)->extends; auto extra = static_cast<SwDropShadow*>(params->rd)->extends;
region.min = {-extra, -extra}; bbox.min = {-extra, -extra};
region.max = {extra, extra}; bbox.max = {extra, extra};
if (offset.x < 0) region.min.x += (int32_t) offset.x; if (offset.x < 0) bbox.min.x += (int32_t) offset.x;
else region.max.x += offset.x; else bbox.max.x += offset.x;
if (offset.y < 0) region.min.y += (int32_t) offset.y; if (offset.y < 0) bbox.min.y += (int32_t) offset.y;
else region.max.y += offset.y; else bbox.max.y += offset.y;
return true; return true;
} }

View file

@ -220,15 +220,15 @@ static inline SwMask _getMaskOp(MaskMethod method)
} }
static bool _compositeMaskImage(SwSurface* surface, const SwImage* image, const RenderRegion& region) static bool _compositeMaskImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox)
{ {
auto dbuffer = &surface->buf8[region.min.y * surface->stride + region.min.x]; auto dbuffer = &surface->buf8[bbox.min.y * surface->stride + bbox.min.x];
auto sbuffer = image->buf8 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); auto sbuffer = image->buf8 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox);
for (auto y = region.min.y; y < region.max.y; ++y) { for (auto y = bbox.min.y; y < bbox.max.y; ++y) {
auto dst = dbuffer; auto dst = dbuffer;
auto src = sbuffer; auto src = sbuffer;
for (auto x = region.min.x; x < region.max.x; x++, dst++, src++) { for (auto x = bbox.min.x; x < bbox.max.x; x++, dst++, src++) {
*dst = *src + MULTIPLY(*dst, ~*src); *dst = *src + MULTIPLY(*dst, ~*src);
} }
dbuffer += surface->stride; dbuffer += surface->stride;
@ -317,15 +317,15 @@ static uint32_t _interpDownScaler(const uint32_t *img, uint32_t stride, uint32_t
/* Rect */ /* Rect */
/************************************************************************/ /************************************************************************/
static bool _rasterCompositeMaskedRect(SwSurface* surface, const RenderRegion& region, SwMask maskOp, uint8_t a) static bool _rasterCompositeMaskedRect(SwSurface* surface, const RenderRegion& bbox, SwMask maskOp, uint8_t a)
{ {
auto cstride = surface->compositor->image.stride; auto cstride = surface->compositor->image.stride;
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * cstride + region.min.x); //compositor buffer auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * cstride + bbox.min.x); //compositor buffer
auto ialpha = 255 - a; auto ialpha = 255 - a;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto cmp = cbuffer; auto cmp = cbuffer;
for (uint32_t x = 0; x < region.w(); ++x, ++cmp) { for (uint32_t x = 0; x < bbox.w(); ++x, ++cmp) {
*cmp = maskOp(a, *cmp, ialpha); *cmp = maskOp(a, *cmp, ialpha);
} }
cbuffer += cstride; cbuffer += cstride;
@ -334,15 +334,15 @@ static bool _rasterCompositeMaskedRect(SwSurface* surface, const RenderRegion& r
} }
static bool _rasterDirectMaskedRect(SwSurface* surface, const RenderRegion& region, SwMask maskOp, uint8_t a) static bool _rasterDirectMaskedRect(SwSurface* surface, const RenderRegion& bbox, SwMask maskOp, uint8_t a)
{ {
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x); //compositor buffer auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x); //compositor buffer
auto dbuffer = surface->buf8 + (region.min.y * surface->stride + region.min.x); //destination buffer auto dbuffer = surface->buf8 + (bbox.min.y * surface->stride + bbox.min.x); //destination buffer
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto cmp = cbuffer; auto cmp = cbuffer;
auto dst = dbuffer; auto dst = dbuffer;
for (uint32_t x = 0; x < region.w(); ++x, ++cmp, ++dst) { for (uint32_t x = 0; x < bbox.w(); ++x, ++cmp, ++dst) {
auto tmp = maskOp(a, *cmp, 0); //not use alpha. auto tmp = maskOp(a, *cmp, 0); //not use alpha.
*dst = tmp + MULTIPLY(*dst, ~tmp); *dst = tmp + MULTIPLY(*dst, ~tmp);
} }
@ -353,47 +353,47 @@ static bool _rasterDirectMaskedRect(SwSurface* surface, const RenderRegion& regi
} }
static bool _rasterMaskedRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool _rasterMaskedRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
//8bit masking channels composition //8bit masking channels composition
if (surface->channelSize != sizeof(uint8_t)) return false; if (surface->channelSize != sizeof(uint8_t)) return false;
TVGLOG("SW_ENGINE", "Masked(%d) Rect [Region: %d %d %d %d]", (int)surface->compositor->method, region.min.x, region.min.y, region.max.x - region.min.x, region.max.y - region.min.y); TVGLOG("SW_ENGINE", "Masked(%d) Rect [Region: %d %d %d %d]", (int)surface->compositor->method, bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
auto maskOp = _getMaskOp(surface->compositor->method); auto maskOp = _getMaskOp(surface->compositor->method);
if (_direct(surface->compositor->method)) return _rasterDirectMaskedRect(surface, region, maskOp, c.a); if (_direct(surface->compositor->method)) return _rasterDirectMaskedRect(surface, bbox, maskOp, c.a);
else return _rasterCompositeMaskedRect(surface, region, maskOp, c.a); else return _rasterCompositeMaskedRect(surface, bbox, maskOp, c.a);
return false; return false;
} }
static bool _rasterMattedRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool _rasterMattedRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
auto csize = surface->compositor->image.channelSize; auto csize = surface->compositor->image.channelSize;
auto cbuffer = surface->compositor->image.buf8 + ((region.min.y * surface->compositor->image.stride + region.min.x) * csize); //compositor buffer auto cbuffer = surface->compositor->image.buf8 + ((bbox.min.y * surface->compositor->image.stride + bbox.min.x) * csize); //compositor buffer
auto alpha = surface->alpha(surface->compositor->method); auto alpha = surface->alpha(surface->compositor->method);
TVGLOG("SW_ENGINE", "Matted(%d) Rect [Region: %u %u %u %u]", (int)surface->compositor->method, region.x(), region.y(), region.w(), region.h()); TVGLOG("SW_ENGINE", "Matted(%d) Rect [Region: %u %u %u %u]", (int)surface->compositor->method, bbox.x(), bbox.y(), bbox.w(), bbox.h());
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto color = surface->join(c.r, c.g, c.b, c.a); auto color = surface->join(c.r, c.g, c.b, c.a);
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];
auto cmp = &cbuffer[y * surface->compositor->image.stride * csize]; auto cmp = &cbuffer[y * surface->compositor->image.stride * csize];
for (uint32_t x = 0; x < region.w(); ++x, ++dst, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, cmp += csize) {
auto tmp = ALPHA_BLEND(color, alpha(cmp)); auto tmp = ALPHA_BLEND(color, alpha(cmp));
*dst = tmp + ALPHA_BLEND(*dst, IA(tmp)); *dst = tmp + ALPHA_BLEND(*dst, IA(tmp));
} }
} }
//8bits grayscale //8bits grayscale
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];
auto cmp = &cbuffer[y * surface->compositor->image.stride * csize]; auto cmp = &cbuffer[y * surface->compositor->image.stride * csize];
for (uint32_t x = 0; x < region.w(); ++x, ++dst, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, cmp += csize) {
*dst = INTERPOLATE8(c.a, *dst, alpha(cmp)); *dst = INTERPOLATE8(c.a, *dst, alpha(cmp));
} }
} }
@ -402,16 +402,16 @@ static bool _rasterMattedRect(SwSurface* surface, const RenderRegion& region, co
} }
static bool _rasterBlendingRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool _rasterBlendingRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
if (surface->channelSize != sizeof(uint32_t)) return false; if (surface->channelSize != sizeof(uint32_t)) return false;
auto color = surface->join(c.r, c.g, c.b, c.a); auto color = surface->join(c.r, c.g, c.b, c.a);
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];
for (uint32_t x = 0; x < region.w(); ++x, ++dst) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst) {
*dst = surface->blender(color, *dst, 255); *dst = surface->blender(color, *dst, 255);
} }
} }
@ -419,33 +419,33 @@ static bool _rasterBlendingRect(SwSurface* surface, const RenderRegion& region,
} }
static bool _rasterTranslucentRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool _rasterTranslucentRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
#if defined(THORVG_AVX_VECTOR_SUPPORT) #if defined(THORVG_AVX_VECTOR_SUPPORT)
return avxRasterTranslucentRect(surface, region, c); return avxRasterTranslucentRect(surface, bbox, c);
#elif defined(THORVG_NEON_VECTOR_SUPPORT) #elif defined(THORVG_NEON_VECTOR_SUPPORT)
return neonRasterTranslucentRect(surface, region, c); return neonRasterTranslucentRect(surface, bbox, c);
#else #else
return cRasterTranslucentRect(surface, region, c); return cRasterTranslucentRect(surface, bbox, c);
#endif #endif
} }
static bool _rasterSolidRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool _rasterSolidRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto color = surface->join(c.r, c.g, c.b, 255); auto color = surface->join(c.r, c.g, c.b, 255);
auto buffer = surface->buf32 + (region.min.y * surface->stride); auto buffer = surface->buf32 + (bbox.min.y * surface->stride);
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
rasterPixel32(buffer + y * surface->stride, color, region.min.x, region.w()); rasterPixel32(buffer + y * surface->stride, color, bbox.min.x, bbox.w());
} }
return true; return true;
} }
//8bits grayscale //8bits grayscale
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
rasterGrayscale8(surface->buf8, 255, (y + region.min.y) * surface->stride + region.min.x, region.w()); rasterGrayscale8(surface->buf8, 255, (y + bbox.min.y) * surface->stride + bbox.min.x, bbox.w());
} }
return true; return true;
} }
@ -453,16 +453,16 @@ static bool _rasterSolidRect(SwSurface* surface, const RenderRegion& region, con
} }
static bool _rasterRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool _rasterRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
if (_compositing(surface)) { if (_compositing(surface)) {
if (_matting(surface)) return _rasterMattedRect(surface, region, c); if (_matting(surface)) return _rasterMattedRect(surface, bbox, c);
else return _rasterMaskedRect(surface, region, c); else return _rasterMaskedRect(surface, bbox, c);
} else if (_blending(surface)) { } else if (_blending(surface)) {
return _rasterBlendingRect(surface, region, c); return _rasterBlendingRect(surface, bbox, c);
} else { } else {
if (c.a == 255) return _rasterSolidRect(surface, region, c); if (c.a == 255) return _rasterSolidRect(surface, bbox, c);
else return _rasterTranslucentRect(surface, region, c); else return _rasterTranslucentRect(surface, bbox, c);
} }
return false; return false;
} }
@ -676,14 +676,14 @@ static bool _rasterRle(SwSurface* surface, SwRle* rle, const RenderColor& c)
auto sx = (x) * itransform->e11 + itransform->e13 - 0.49f; \ auto sx = (x) * itransform->e11 + itransform->e13 - 0.49f; \
if (sx <= -0.5f || (uint32_t)(sx + 0.5f) >= image->w) continue; \ if (sx <= -0.5f || (uint32_t)(sx + 0.5f) >= image->w) continue; \
static bool _rasterScaledMaskedRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledMaskedRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
TVGERR("SW_ENGINE", "Not Supported Scaled Masked(%d) Rle Image", (int)surface->compositor->method); TVGERR("SW_ENGINE", "Not Supported Scaled Masked(%d) Rle Image", (int)surface->compositor->method);
return false; return false;
} }
static bool _rasterScaledMattedRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledMattedRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
TVGLOG("SW_ENGINE", "Scaled Matted(%d) Rle Image", (int)surface->compositor->method); TVGLOG("SW_ENGINE", "Scaled Matted(%d) Rle Image", (int)surface->compositor->method);
@ -710,7 +710,7 @@ static bool _rasterScaledMattedRleImage(SwSurface* surface, const SwImage* image
} }
static bool _rasterScaledBlendingRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledBlendingRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
auto span = image->rle->spans; auto span = image->rle->spans;
auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler; auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler;
@ -741,7 +741,7 @@ static bool _rasterScaledBlendingRleImage(SwSurface* surface, const SwImage* ima
} }
static bool _rasterScaledRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledRleImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
auto span = image->rle->spans; auto span = image->rle->spans;
auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler; auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler;
@ -763,7 +763,7 @@ static bool _rasterScaledRleImage(SwSurface* surface, const SwImage* image, cons
} }
static bool _scaledRleImage(SwSurface* surface, const SwImage* image, const Matrix& transform, const RenderRegion& region, uint8_t opacity) static bool _scaledRleImage(SwSurface* surface, const SwImage* image, const Matrix& transform, const RenderRegion& bbox, uint8_t opacity)
{ {
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
TVGERR("SW_ENGINE", "Not supported scaled rle image!"); TVGERR("SW_ENGINE", "Not supported scaled rle image!");
@ -775,12 +775,12 @@ static bool _scaledRleImage(SwSurface* surface, const SwImage* image, const Matr
if (!inverse(&transform, &itransform)) return true; if (!inverse(&transform, &itransform)) return true;
if (_compositing(surface)) { if (_compositing(surface)) {
if (_matting(surface)) return _rasterScaledMattedRleImage(surface, image, &itransform, region, opacity); if (_matting(surface)) return _rasterScaledMattedRleImage(surface, image, &itransform, bbox, opacity);
else return _rasterScaledMaskedRleImage(surface, image, &itransform, region, opacity); else return _rasterScaledMaskedRleImage(surface, image, &itransform, bbox, opacity);
} else if (_blending(surface)) { } else if (_blending(surface)) {
return _rasterScaledBlendingRleImage(surface, image, &itransform, region, opacity); return _rasterScaledBlendingRleImage(surface, image, &itransform, bbox, opacity);
} else { } else {
return _rasterScaledRleImage(surface, image, &itransform, region, opacity); return _rasterScaledRleImage(surface, image, &itransform, bbox, opacity);
} }
return false; return false;
} }
@ -887,36 +887,36 @@ static bool _directRleImage(SwSurface* surface, const SwImage* image, uint8_t op
/*Scaled Image */ /*Scaled Image */
/************************************************************************/ /************************************************************************/
static bool _rasterScaledMaskedImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledMaskedImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
TVGERR("SW_ENGINE", "Not Supported Scaled Masked Image!"); TVGERR("SW_ENGINE", "Not Supported Scaled Masked Image!");
return false; return false;
} }
static bool _rasterScaledMattedImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledMattedImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
TVGERR("SW_ENGINE", "Not supported grayscale scaled matted image!"); TVGERR("SW_ENGINE", "Not supported grayscale scaled matted image!");
return false; return false;
} }
auto dbuffer = surface->buf32 + (region.min.y * surface->stride + region.min.x); auto dbuffer = surface->buf32 + (bbox.min.y * surface->stride + bbox.min.x);
auto csize = surface->compositor->image.channelSize; auto csize = surface->compositor->image.channelSize;
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x) * csize; auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x) * csize;
auto alpha = surface->alpha(surface->compositor->method); auto alpha = surface->alpha(surface->compositor->method);
TVGLOG("SW_ENGINE", "Scaled Matted(%d) Image [Region: %d %d %d %d]", (int)surface->compositor->method, region.min.x, region.min.y, region.max.x - region.min.x, region.max.y - region.min.y); TVGLOG("SW_ENGINE", "Scaled Matted(%d) Image [Region: %d %d %d %d]", (int)surface->compositor->method, bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler; auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler;
auto sampleSize = _sampleSize(image->scale); auto sampleSize = _sampleSize(image->scale);
int32_t miny = 0, maxy = 0; int32_t miny = 0, maxy = 0;
for (auto y = region.min.y; y < region.max.y; ++y) { for (auto y = bbox.min.y; y < bbox.max.y; ++y) {
SCALED_IMAGE_RANGE_Y(y) SCALED_IMAGE_RANGE_Y(y)
auto dst = dbuffer; auto dst = dbuffer;
auto cmp = cbuffer; auto cmp = cbuffer;
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, cmp += csize) { for (auto x = bbox.min.x; x < bbox.max.x; ++x, ++dst, cmp += csize) {
SCALED_IMAGE_RANGE_X SCALED_IMAGE_RANGE_X
auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize);
auto tmp = ALPHA_BLEND(src, opacity == 255 ? alpha(cmp) : MULTIPLY(opacity, alpha(cmp))); auto tmp = ALPHA_BLEND(src, opacity == 255 ? alpha(cmp) : MULTIPLY(opacity, alpha(cmp)));
@ -929,22 +929,22 @@ static bool _rasterScaledMattedImage(SwSurface* surface, const SwImage* image, c
} }
static bool _rasterScaledBlendingImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledBlendingImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
TVGERR("SW_ENGINE", "Not supported grayscale scaled blending image!"); TVGERR("SW_ENGINE", "Not supported grayscale scaled blending image!");
return false; return false;
} }
auto dbuffer = surface->buf32 + (region.min.y * surface->stride + region.min.x); auto dbuffer = surface->buf32 + (bbox.min.y * surface->stride + bbox.min.x);
auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler; auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler;
auto sampleSize = _sampleSize(image->scale); auto sampleSize = _sampleSize(image->scale);
int32_t miny = 0, maxy = 0; int32_t miny = 0, maxy = 0;
for (auto y = region.min.y; y < region.max.y; ++y, dbuffer += surface->stride) { for (auto y = bbox.min.y; y < bbox.max.y; ++y, dbuffer += surface->stride) {
SCALED_IMAGE_RANGE_Y(y) SCALED_IMAGE_RANGE_Y(y)
auto dst = dbuffer; auto dst = dbuffer;
for (auto x = region.min.x; x < region.max.x; ++x, ++dst) { for (auto x = bbox.min.x; x < bbox.max.x; ++x, ++dst) {
SCALED_IMAGE_RANGE_X SCALED_IMAGE_RANGE_X
auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize);
auto tmp = surface->blender(src, *dst, 255); auto tmp = surface->blender(src, *dst, 255);
@ -955,7 +955,7 @@ static bool _rasterScaledBlendingImage(SwSurface* surface, const SwImage* image,
} }
static bool _rasterScaledImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& region, uint8_t opacity) static bool _rasterScaledImage(SwSurface* surface, const SwImage* image, const Matrix* itransform, const RenderRegion& bbox, uint8_t opacity)
{ {
auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler; auto scaleMethod = image->scale < DOWN_SCALE_TOLERANCE ? _interpDownScaler : _interpUpScaler;
auto sampleSize = _sampleSize(image->scale); auto sampleSize = _sampleSize(image->scale);
@ -963,11 +963,11 @@ static bool _rasterScaledImage(SwSurface* surface, const SwImage* image, const M
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto buffer = surface->buf32 + (region.min.y * surface->stride + region.min.x); auto buffer = surface->buf32 + (bbox.min.y * surface->stride + bbox.min.x);
for (auto y = region.min.y; y < region.max.y; ++y, buffer += surface->stride) { for (auto y = bbox.min.y; y < bbox.max.y; ++y, buffer += surface->stride) {
SCALED_IMAGE_RANGE_Y(y) SCALED_IMAGE_RANGE_Y(y)
auto dst = buffer; auto dst = buffer;
for (auto x = region.min.x; x < region.max.x; ++x, ++dst) { for (auto x = bbox.min.x; x < bbox.max.x; ++x, ++dst) {
SCALED_IMAGE_RANGE_X SCALED_IMAGE_RANGE_X
auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize);
if (opacity < 255) src = ALPHA_BLEND(src, opacity); if (opacity < 255) src = ALPHA_BLEND(src, opacity);
@ -975,11 +975,11 @@ static bool _rasterScaledImage(SwSurface* surface, const SwImage* image, const M
} }
} }
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto buffer = surface->buf8 + (region.min.y * surface->stride + region.min.x); auto buffer = surface->buf8 + (bbox.min.y * surface->stride + bbox.min.x);
for (auto y = region.min.y; y < region.max.y; ++y, buffer += surface->stride) { for (auto y = bbox.min.y; y < bbox.max.y; ++y, buffer += surface->stride) {
SCALED_IMAGE_RANGE_Y(y) SCALED_IMAGE_RANGE_Y(y)
auto dst = buffer; auto dst = buffer;
for (auto x = region.min.x; x < region.max.x; ++x, ++dst) { for (auto x = bbox.min.x; x < bbox.max.x; ++x, ++dst) {
SCALED_IMAGE_RANGE_X SCALED_IMAGE_RANGE_X
auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize);
*dst = MULTIPLY(A(src), opacity); *dst = MULTIPLY(A(src), opacity);
@ -990,19 +990,19 @@ static bool _rasterScaledImage(SwSurface* surface, const SwImage* image, const M
} }
static bool _scaledImage(SwSurface* surface, const SwImage* image, const Matrix& transform, const RenderRegion& region, uint8_t opacity) static bool _scaledImage(SwSurface* surface, const SwImage* image, const Matrix& transform, const RenderRegion& bbox, uint8_t opacity)
{ {
Matrix itransform; Matrix itransform;
if (!inverse(&transform, &itransform)) return true; if (!inverse(&transform, &itransform)) return true;
if (_compositing(surface)) { if (_compositing(surface)) {
if (_matting(surface)) return _rasterScaledMattedImage(surface, image, &itransform, region, opacity); if (_matting(surface)) return _rasterScaledMattedImage(surface, image, &itransform, bbox, opacity);
else return _rasterScaledMaskedImage(surface, image, &itransform, region, opacity); else return _rasterScaledMaskedImage(surface, image, &itransform, bbox, opacity);
} else if (_blending(surface)) { } else if (_blending(surface)) {
return _rasterScaledBlendingImage(surface, image, &itransform, region, opacity); return _rasterScaledBlendingImage(surface, image, &itransform, bbox, opacity);
} else { } else {
return _rasterScaledImage(surface, image, &itransform, region, opacity); return _rasterScaledImage(surface, image, &itransform, bbox, opacity);
} }
return false; return false;
} }
@ -1012,36 +1012,36 @@ static bool _scaledImage(SwSurface* surface, const SwImage* image, const Matrix&
/* Direct Image */ /* Direct Image */
/************************************************************************/ /************************************************************************/
static bool _rasterDirectMaskedImage(SwSurface* surface, const SwImage* image, const RenderRegion& region, uint8_t opacity) static bool _rasterDirectMaskedImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox, uint8_t opacity)
{ {
TVGERR("SW_ENGINE", "Not Supported: Direct Masked Image"); TVGERR("SW_ENGINE", "Not Supported: Direct Masked Image");
return false; return false;
} }
static bool _rasterDirectMattedImage(SwSurface* surface, const SwImage* image, const RenderRegion& region, uint8_t opacity) static bool _rasterDirectMattedImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox, uint8_t opacity)
{ {
auto csize = surface->compositor->image.channelSize; auto csize = surface->compositor->image.channelSize;
auto alpha = surface->alpha(surface->compositor->method); auto alpha = surface->alpha(surface->compositor->method);
auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); auto sbuffer = image->buf32 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox);
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x) * csize; //compositor buffer auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x) * csize; //compositor buffer
TVGLOG("SW_ENGINE", "Direct Matted(%d) Image [Region: %u %u %u %u]", (int)surface->compositor->method, region.x(), region.y(), region.w(), region.h()); TVGLOG("SW_ENGINE", "Direct Matted(%d) Image [Region: %u %u %u %u]", (int)surface->compositor->method, bbox.x(), bbox.y(), bbox.w(), bbox.h());
//32 bits //32 bits
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = buffer; auto dst = buffer;
auto cmp = cbuffer; auto cmp = cbuffer;
auto src = sbuffer; auto src = sbuffer;
if (opacity == 255) { if (opacity == 255) {
for (uint32_t x = 0; x < region.w(); ++x, ++dst, ++src, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, ++src, cmp += csize) {
auto tmp = ALPHA_BLEND(*src, alpha(cmp)); auto tmp = ALPHA_BLEND(*src, alpha(cmp));
*dst = tmp + ALPHA_BLEND(*dst, IA(tmp)); *dst = tmp + ALPHA_BLEND(*dst, IA(tmp));
} }
} else { } else {
for (uint32_t x = 0; x < region.w(); ++x, ++dst, ++src, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, ++src, cmp += csize) {
auto tmp = ALPHA_BLEND(*src, MULTIPLY(opacity, alpha(cmp))); auto tmp = ALPHA_BLEND(*src, MULTIPLY(opacity, alpha(cmp)));
*dst = tmp + ALPHA_BLEND(*dst, IA(tmp)); *dst = tmp + ALPHA_BLEND(*dst, IA(tmp));
} }
@ -1052,18 +1052,18 @@ static bool _rasterDirectMattedImage(SwSurface* surface, const SwImage* image, c
} }
//8 bits //8 bits
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = buffer; auto dst = buffer;
auto cmp = cbuffer; auto cmp = cbuffer;
auto src = sbuffer; auto src = sbuffer;
if (opacity == 255) { if (opacity == 255) {
for (uint32_t x = 0; x < region.w(); ++x, ++dst, ++src, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, ++src, cmp += csize) {
auto tmp = MULTIPLY(A(*src), alpha(cmp)); auto tmp = MULTIPLY(A(*src), alpha(cmp));
*dst = tmp + MULTIPLY(*dst, 255 - tmp); *dst = tmp + MULTIPLY(*dst, 255 - tmp);
} }
} else { } else {
for (uint32_t x = 0; x < region.w(); ++x, ++dst, ++src, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, ++src, cmp += csize) {
auto tmp = MULTIPLY(A(*src), MULTIPLY(opacity, alpha(cmp))); auto tmp = MULTIPLY(A(*src), MULTIPLY(opacity, alpha(cmp)));
*dst = tmp + MULTIPLY(*dst, 255 - tmp); *dst = tmp + MULTIPLY(*dst, 255 - tmp);
} }
@ -1077,26 +1077,26 @@ static bool _rasterDirectMattedImage(SwSurface* surface, const SwImage* image, c
} }
static bool _rasterDirectBlendingImage(SwSurface* surface, const SwImage* image, const RenderRegion& region, uint8_t opacity) static bool _rasterDirectBlendingImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox, uint8_t opacity)
{ {
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
TVGERR("SW_ENGINE", "Not supported grayscale image!"); TVGERR("SW_ENGINE", "Not supported grayscale image!");
return false; return false;
} }
auto dbuffer = &surface->buf32[region.min.y * surface->stride + region.min.x]; auto dbuffer = &surface->buf32[bbox.min.y * surface->stride + bbox.min.x];
auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); auto sbuffer = image->buf32 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox);
for (auto y = region.min.y; y < region.max.y; ++y) { for (auto y = bbox.min.y; y < bbox.max.y; ++y) {
auto dst = dbuffer; auto dst = dbuffer;
auto src = sbuffer; auto src = sbuffer;
if (opacity == 255) { if (opacity == 255) {
for (auto x = region.min.x; x < region.max.x; x++, dst++, src++) { for (auto x = bbox.min.x; x < bbox.max.x; x++, dst++, src++) {
auto tmp = surface->blender(*src, *dst, 255); auto tmp = surface->blender(*src, *dst, 255);
*dst = INTERPOLATE(tmp, *dst, A(*src)); *dst = INTERPOLATE(tmp, *dst, A(*src));
} }
} else { } else {
for (auto x = region.min.x; x < region.max.x; x++, dst++, src++) { for (auto x = bbox.min.x; x < bbox.max.x; x++, dst++, src++) {
auto tmp = surface->blender(*src, *dst, 255); auto tmp = surface->blender(*src, *dst, 255);
*dst = INTERPOLATE(tmp, *dst, MULTIPLY(opacity, A(*src))); *dst = INTERPOLATE(tmp, *dst, MULTIPLY(opacity, A(*src)));
} }
@ -1108,30 +1108,30 @@ static bool _rasterDirectBlendingImage(SwSurface* surface, const SwImage* image,
} }
static bool _rasterDirectImage(SwSurface* surface, const SwImage* image, const RenderRegion& region, uint8_t opacity) static bool _rasterDirectImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox, uint8_t opacity)
{ {
auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); auto sbuffer = image->buf32 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox);
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto dbuffer = &surface->buf32[region.min.y * surface->stride + region.min.x]; auto dbuffer = &surface->buf32[bbox.min.y * surface->stride + bbox.min.x];
for (auto y = region.min.y; y < region.max.y; ++y) { for (auto y = bbox.min.y; y < bbox.max.y; ++y) {
rasterTranslucentPixel32(dbuffer, sbuffer, region.max.x - region.min.x, opacity); rasterTranslucentPixel32(dbuffer, sbuffer, bbox.max.x - bbox.min.x, opacity);
dbuffer += surface->stride; dbuffer += surface->stride;
sbuffer += image->stride; sbuffer += image->stride;
} }
//8bits grayscale //8bits grayscale
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto dbuffer = &surface->buf8[region.min.y * surface->stride + region.min.x]; auto dbuffer = &surface->buf8[bbox.min.y * surface->stride + bbox.min.x];
for (auto y = region.min.y; y < region.max.y; ++y, dbuffer += surface->stride, sbuffer += image->stride) { for (auto y = bbox.min.y; y < bbox.max.y; ++y, dbuffer += surface->stride, sbuffer += image->stride) {
auto dst = dbuffer; auto dst = dbuffer;
auto src = sbuffer; auto src = sbuffer;
if (opacity == 255) { if (opacity == 255) {
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, ++src) { for (auto x = bbox.min.x; x < bbox.max.x; ++x, ++dst, ++src) {
*dst = *src + MULTIPLY(*dst, IA(*src)); *dst = *src + MULTIPLY(*dst, IA(*src));
} }
} else { } else {
for (auto x = region.min.x; x < region.max.x; ++x, ++dst, ++src) { for (auto x = bbox.min.x; x < bbox.max.x; ++x, ++dst, ++src) {
*dst = INTERPOLATE8(A(*src), *dst, opacity); *dst = INTERPOLATE8(A(*src), *dst, opacity);
} }
} }
@ -1141,7 +1141,7 @@ static bool _rasterDirectImage(SwSurface* surface, const SwImage* image, const R
} }
static bool _rasterDirectMattedBlendingImage(SwSurface* surface, const SwImage* image, const RenderRegion& region, uint8_t opacity) static bool _rasterDirectMattedBlendingImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox, uint8_t opacity)
{ {
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
TVGERR("SW_ENGINE", "Not supported grayscale image!"); TVGERR("SW_ENGINE", "Not supported grayscale image!");
@ -1150,21 +1150,21 @@ static bool _rasterDirectMattedBlendingImage(SwSurface* surface, const SwImage*
auto csize = surface->compositor->image.channelSize; auto csize = surface->compositor->image.channelSize;
auto alpha = surface->alpha(surface->compositor->method); auto alpha = surface->alpha(surface->compositor->method);
auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); auto sbuffer = image->buf32 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox);
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x) * csize; //compositor buffer auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x) * csize; //compositor buffer
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = buffer; auto dst = buffer;
auto cmp = cbuffer; auto cmp = cbuffer;
auto src = sbuffer; auto src = sbuffer;
if (opacity == 255) { if (opacity == 255) {
for (uint32_t x = 0; x < region.w(); ++x, ++dst, ++src, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, ++src, cmp += csize) {
auto tmp = ALPHA_BLEND(*src, alpha(cmp)); auto tmp = ALPHA_BLEND(*src, alpha(cmp));
*dst = INTERPOLATE(surface->blender(tmp, *dst, 255), *dst, A(tmp)); *dst = INTERPOLATE(surface->blender(tmp, *dst, 255), *dst, A(tmp));
} }
} else { } else {
for (uint32_t x = 0; x < region.w(); ++x, ++dst, ++src, cmp += csize) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst, ++src, cmp += csize) {
auto tmp = ALPHA_BLEND(*src, alpha(cmp)); auto tmp = ALPHA_BLEND(*src, alpha(cmp));
*dst = INTERPOLATE(surface->blender(tmp, *dst, 255), *dst, MULTIPLY(opacity, A(tmp))); *dst = INTERPOLATE(surface->blender(tmp, *dst, 255), *dst, MULTIPLY(opacity, A(tmp)));
} }
@ -1178,35 +1178,35 @@ static bool _rasterDirectMattedBlendingImage(SwSurface* surface, const SwImage*
//Blenders for the following scenarios: [Composition / Non-Composition] * [Opaque / Translucent] //Blenders for the following scenarios: [Composition / Non-Composition] * [Opaque / Translucent]
static bool _directImage(SwSurface* surface, const SwImage* image, const RenderRegion& region, uint8_t opacity) static bool _directImage(SwSurface* surface, const SwImage* image, const RenderRegion& bbox, uint8_t opacity)
{ {
if (_compositing(surface)) { if (_compositing(surface)) {
if (_matting(surface)) { if (_matting(surface)) {
if (_blending(surface)) return _rasterDirectMattedBlendingImage(surface, image, region, opacity); if (_blending(surface)) return _rasterDirectMattedBlendingImage(surface, image, bbox, opacity);
else return _rasterDirectMattedImage(surface, image, region, opacity); else return _rasterDirectMattedImage(surface, image, bbox, opacity);
} else return _rasterDirectMaskedImage(surface, image, region, opacity); } else return _rasterDirectMaskedImage(surface, image, bbox, opacity);
} else if (_blending(surface)) { } else if (_blending(surface)) {
return _rasterDirectBlendingImage(surface, image, region, opacity); return _rasterDirectBlendingImage(surface, image, bbox, opacity);
} else { } else {
return _rasterDirectImage(surface, image, region, opacity); return _rasterDirectImage(surface, image, bbox, opacity);
} }
return false; return false;
} }
//Blenders for the following scenarios: [RLE / Whole] * [Direct / Scaled / Transformed] //Blenders for the following scenarios: [RLE / Whole] * [Direct / Scaled / Transformed]
static bool _rasterImage(SwSurface* surface, SwImage* image, const Matrix& transform, const RenderRegion& region, uint8_t opacity) static bool _rasterImage(SwSurface* surface, SwImage* image, const Matrix& transform, const RenderRegion& bbox, uint8_t opacity)
{ {
//RLE Image //RLE Image
if (image->rle) { if (image->rle) {
if (image->direct) return _directRleImage(surface, image, opacity); if (image->direct) return _directRleImage(surface, image, opacity);
else if (image->scaled) return _scaledRleImage(surface, image, transform, region, opacity); else if (image->scaled) return _scaledRleImage(surface, image, transform, bbox, opacity);
else return _rasterTexmapPolygon(surface, image, transform, nullptr, opacity); else return _rasterTexmapPolygon(surface, image, transform, nullptr, opacity);
//Whole Image //Whole Image
} else { } else {
if (image->direct) return _directImage(surface, image, region, opacity); if (image->direct) return _directImage(surface, image, bbox, opacity);
else if (image->scaled) return _scaledImage(surface, image, transform, region, opacity); else if (image->scaled) return _scaledImage(surface, image, transform, bbox, opacity);
else return _rasterTexmapPolygon(surface, image, transform, &region, opacity); else return _rasterTexmapPolygon(surface, image, transform, &bbox, opacity);
} }
} }
@ -1216,13 +1216,13 @@ static bool _rasterImage(SwSurface* surface, SwImage* image, const Matrix& trans
/************************************************************************/ /************************************************************************/
template<typename fillMethod> template<typename fillMethod>
static bool _rasterCompositeGradientMaskedRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill, SwMask maskOp) static bool _rasterCompositeGradientMaskedRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill, SwMask maskOp)
{ {
auto cstride = surface->compositor->image.stride; auto cstride = surface->compositor->image.stride;
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * cstride + region.min.x); auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * cstride + bbox.min.x);
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, cbuffer, region.min.y + y, region.min.x, region.w(), maskOp, 255); fillMethod()(fill, cbuffer, bbox.min.y + y, bbox.min.x, bbox.w(), maskOp, 255);
cbuffer += surface->stride; cbuffer += surface->stride;
} }
return _compositeMaskImage(surface, &surface->compositor->image, surface->compositor->bbox); return _compositeMaskImage(surface, &surface->compositor->image, surface->compositor->bbox);
@ -1230,14 +1230,14 @@ static bool _rasterCompositeGradientMaskedRect(SwSurface* surface, const RenderR
template<typename fillMethod> template<typename fillMethod>
static bool _rasterDirectGradientMaskedRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill, SwMask maskOp) static bool _rasterDirectGradientMaskedRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill, SwMask maskOp)
{ {
auto cstride = surface->compositor->image.stride; auto cstride = surface->compositor->image.stride;
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * cstride + region.min.x); auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * cstride + bbox.min.x);
auto dbuffer = surface->buf8 + (region.min.y * surface->stride + region.min.x); auto dbuffer = surface->buf8 + (bbox.min.y * surface->stride + bbox.min.x);
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, dbuffer, region.min.y + y, region.min.x, region.w(), cbuffer, maskOp, 255); fillMethod()(fill, dbuffer, bbox.min.y + y, bbox.min.x, bbox.w(), cbuffer, maskOp, 255);
cbuffer += cstride; cbuffer += cstride;
dbuffer += surface->stride; dbuffer += surface->stride;
} }
@ -1246,33 +1246,33 @@ static bool _rasterDirectGradientMaskedRect(SwSurface* surface, const RenderRegi
template<typename fillMethod> template<typename fillMethod>
static bool _rasterGradientMaskedRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterGradientMaskedRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
auto method = surface->compositor->method; auto method = surface->compositor->method;
TVGLOG("SW_ENGINE", "Masked(%d) Gradient [Region: %d %d %d %d]", (int)method, region.min.x, region.min.y, region.max.x - region.min.x, region.max.y - region.min.y); TVGLOG("SW_ENGINE", "Masked(%d) Gradient [Region: %d %d %d %d]", (int)method, bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
auto maskOp = _getMaskOp(method); auto maskOp = _getMaskOp(method);
if (_direct(method)) return _rasterDirectGradientMaskedRect<fillMethod>(surface, region, fill, maskOp); if (_direct(method)) return _rasterDirectGradientMaskedRect<fillMethod>(surface, bbox, fill, maskOp);
else return _rasterCompositeGradientMaskedRect<fillMethod>(surface, region, fill, maskOp); else return _rasterCompositeGradientMaskedRect<fillMethod>(surface, bbox, fill, maskOp);
return false; return false;
} }
template<typename fillMethod> template<typename fillMethod>
static bool _rasterGradientMattedRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterGradientMattedRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
auto csize = surface->compositor->image.channelSize; auto csize = surface->compositor->image.channelSize;
auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x) * csize; auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x) * csize;
auto alpha = surface->alpha(surface->compositor->method); auto alpha = surface->alpha(surface->compositor->method);
TVGLOG("SW_ENGINE", "Matted(%d) Gradient [Region: %u %u %u %u]", (int)surface->compositor->method, region.x(), region.y(), region.w(), region.h()); TVGLOG("SW_ENGINE", "Matted(%d) Gradient [Region: %u %u %u %u]", (int)surface->compositor->method, bbox.x(), bbox.y(), bbox.w(), bbox.h());
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), cbuffer, alpha, csize, 255); fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), cbuffer, alpha, csize, 255);
buffer += surface->stride; buffer += surface->stride;
cbuffer += surface->stride * csize; cbuffer += surface->stride * csize;
} }
@ -1281,37 +1281,37 @@ static bool _rasterGradientMattedRect(SwSurface* surface, const RenderRegion& re
template<typename fillMethod> template<typename fillMethod>
static bool _rasterBlendingGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterBlendingGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
if (fill->translucent) { if (fill->translucent) {
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer + y * surface->stride, region.min.y + y, region.min.x, region.w(), opBlendPreNormal, surface->blender, 255); fillMethod()(fill, buffer + y * surface->stride, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendPreNormal, surface->blender, 255);
} }
} else { } else {
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer + y * surface->stride, region.min.y + y, region.min.x, region.w(), opBlendSrcOver, surface->blender, 255); fillMethod()(fill, buffer + y * surface->stride, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendSrcOver, surface->blender, 255);
} }
} }
return true; return true;
} }
template<typename fillMethod> template<typename fillMethod>
static bool _rasterTranslucentGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterTranslucentGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
//32 bits //32 bits
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), opBlendPreNormal, 255); fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendPreNormal, 255);
buffer += surface->stride; buffer += surface->stride;
} }
//8 bits //8 bits
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), _opMaskAdd, 255); fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), _opMaskAdd, 255);
buffer += surface->stride; buffer += surface->stride;
} }
} }
@ -1320,20 +1320,20 @@ static bool _rasterTranslucentGradientRect(SwSurface* surface, const RenderRegio
template<typename fillMethod> template<typename fillMethod>
static bool _rasterSolidGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterSolidGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
//32 bits //32 bits
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), opBlendSrcOver, 255); fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendSrcOver, 255);
buffer += surface->stride; buffer += surface->stride;
} }
//8 bits //8 bits
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), _opMaskNone, 255); fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), _opMaskNone, 255);
buffer += surface->stride; buffer += surface->stride;
} }
} }
@ -1341,31 +1341,31 @@ static bool _rasterSolidGradientRect(SwSurface* surface, const RenderRegion& reg
} }
static bool _rasterLinearGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterLinearGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
if (_compositing(surface)) { if (_compositing(surface)) {
if (_matting(surface)) return _rasterGradientMattedRect<FillLinear>(surface, region, fill); if (_matting(surface)) return _rasterGradientMattedRect<FillLinear>(surface, bbox, fill);
else return _rasterGradientMaskedRect<FillLinear>(surface, region, fill); else return _rasterGradientMaskedRect<FillLinear>(surface, bbox, fill);
} else if (_blending(surface)) { } else if (_blending(surface)) {
return _rasterBlendingGradientRect<FillLinear>(surface, region, fill); return _rasterBlendingGradientRect<FillLinear>(surface, bbox, fill);
} else { } else {
if (fill->translucent) return _rasterTranslucentGradientRect<FillLinear>(surface, region, fill); if (fill->translucent) return _rasterTranslucentGradientRect<FillLinear>(surface, bbox, fill);
else _rasterSolidGradientRect<FillLinear>(surface, region, fill); else _rasterSolidGradientRect<FillLinear>(surface, bbox, fill);
} }
return false; return false;
} }
static bool _rasterRadialGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) static bool _rasterRadialGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill)
{ {
if (_compositing(surface)) { if (_compositing(surface)) {
if (_matting(surface)) return _rasterGradientMattedRect<FillRadial>(surface, region, fill); if (_matting(surface)) return _rasterGradientMattedRect<FillRadial>(surface, bbox, fill);
else return _rasterGradientMaskedRect<FillRadial>(surface, region, fill); else return _rasterGradientMaskedRect<FillRadial>(surface, bbox, fill);
} else if (_blending(surface)) { } else if (_blending(surface)) {
return _rasterBlendingGradientRect<FillRadial>(surface, region, fill); return _rasterBlendingGradientRect<FillRadial>(surface, bbox, fill);
} else { } else {
if (fill->translucent) return _rasterTranslucentGradientRect<FillRadial>(surface, region, fill); if (fill->translucent) return _rasterTranslucentGradientRect<FillRadial>(surface, bbox, fill);
else _rasterSolidGradientRect<FillRadial>(surface, region, fill); else _rasterSolidGradientRect<FillRadial>(surface, bbox, fill);
} }
return false; return false;
} }

View file

@ -99,15 +99,15 @@ static void avxRasterPixel32(uint32_t *dst, uint32_t val, uint32_t offset, int32
} }
static bool avxRasterTranslucentRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool avxRasterTranslucentRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
auto h = region.h(); auto h = bbox.h();
auto w = region.w(); auto w = bbox.w();
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto color = surface->join(c.r, c.g, c.b, c.a); auto color = surface->join(c.r, c.g, c.b, c.a);
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
uint32_t ialpha = 255 - c.a; uint32_t ialpha = 255 - c.a;
@ -145,7 +145,7 @@ static bool avxRasterTranslucentRect(SwSurface* surface, const RenderRegion& reg
//8bit grayscale //8bit grayscale
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
TVGLOG("SW_ENGINE", "Require AVX Optimization, Channel Size = %d", surface->channelSize); TVGLOG("SW_ENGINE", "Require AVX Optimization, Channel Size = %d", surface->channelSize);
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
auto ialpha = ~c.a; auto ialpha = ~c.a;
for (uint32_t y = 0; y < h; ++y) { for (uint32_t y = 0; y < h; ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];

View file

@ -126,26 +126,26 @@ static bool inline cRasterTranslucentRle(SwSurface* surface, const SwRle* rle, c
} }
static bool inline cRasterTranslucentRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool inline cRasterTranslucentRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto color = surface->join(c.r, c.g, c.b, c.a); auto color = surface->join(c.r, c.g, c.b, c.a);
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
auto ialpha = 255 - c.a; auto ialpha = 255 - c.a;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];
for (uint32_t x = 0; x < region.w(); ++x, ++dst) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst) {
*dst = color + ALPHA_BLEND(*dst, ialpha); *dst = color + ALPHA_BLEND(*dst, ialpha);
} }
} }
//8bit grayscale //8bit grayscale
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
auto ialpha = ~c.a; auto ialpha = ~c.a;
for (uint32_t y = 0; y < region.h(); ++y) { for (uint32_t y = 0; y < bbox.h(); ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];
for (uint32_t x = 0; x < region.w(); ++x, ++dst) { for (uint32_t x = 0; x < bbox.w(); ++x, ++dst) {
*dst = c.a + MULTIPLY(*dst, ialpha); *dst = c.a + MULTIPLY(*dst, ialpha);
} }
} }

View file

@ -146,15 +146,15 @@ static bool neonRasterTranslucentRle(SwSurface* surface, const SwRle* rle, const
} }
static bool neonRasterTranslucentRect(SwSurface* surface, const RenderRegion& region, const RenderColor& c) static bool neonRasterTranslucentRect(SwSurface* surface, const RenderRegion& bbox, const RenderColor& c)
{ {
auto h = region.h(); auto h = bbox.h();
auto w = region.w(); auto w = bbox.w();
//32bits channels //32bits channels
if (surface->channelSize == sizeof(uint32_t)) { if (surface->channelSize == sizeof(uint32_t)) {
auto color = surface->join(c.r, c.g, c.b, c.a); auto color = surface->join(c.r, c.g, c.b, c.a);
auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x;
auto ialpha = 255 - c.a; auto ialpha = 255 - c.a;
auto vColor = vdup_n_u32(color); auto vColor = vdup_n_u32(color);
@ -185,7 +185,7 @@ static bool neonRasterTranslucentRect(SwSurface* surface, const RenderRegion& re
//8bit grayscale //8bit grayscale
} else if (surface->channelSize == sizeof(uint8_t)) { } else if (surface->channelSize == sizeof(uint8_t)) {
TVGLOG("SW_ENGINE", "Require Neon Optimization, Channel Size = %d", surface->channelSize); TVGLOG("SW_ENGINE", "Require Neon Optimization, Channel Size = %d", surface->channelSize);
auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x;
auto ialpha = ~c.a; auto ialpha = ~c.a;
for (uint32_t y = 0; y < h; ++y) { for (uint32_t y = 0; y < h; ++y) {
auto dst = &buffer[y * surface->stride]; auto dst = &buffer[y * surface->stride];

View file

@ -52,33 +52,33 @@ static float xa, xb, ua, va;
//Y Range exception handling //Y Range exception handling
static bool _arrange(const SwImage* image, const RenderRegion* region, int& yStart, int& yEnd) static bool _arrange(const SwImage* image, const RenderRegion* bbox, int& yStart, int& yEnd)
{ {
int32_t regionTop, regionBottom; int32_t bboxTop, bboxBottom;
if (region) { if (bbox) {
regionTop = region->min.y; bboxTop = bbox->min.y;
regionBottom = region->max.y; bboxBottom = bbox->max.y;
} else { } else {
regionTop = image->rle->spans->y; bboxTop = image->rle->spans->y;
regionBottom = image->rle->spans[image->rle->size - 1].y; bboxBottom = image->rle->spans[image->rle->size - 1].y;
} }
if (yStart < regionTop) yStart = regionTop; if (yStart < bboxTop) yStart = bboxTop;
if (yEnd > regionBottom) yEnd = regionBottom; if (yEnd > bboxBottom) yEnd = bboxBottom;
return yEnd > yStart; return yEnd > yStart;
} }
static bool _rasterMaskedPolygonImageSegment(SwSurface* surface, const SwImage* image, const RenderRegion* region, int yStart, int yEnd, AASpans* aaSpans, uint8_t opacity, uint8_t dirFlag = 0) static bool _rasterMaskedPolygonImageSegment(SwSurface* surface, const SwImage* image, const RenderRegion* bbox, int yStart, int yEnd, AASpans* aaSpans, uint8_t opacity, uint8_t dirFlag = 0)
{ {
TVGERR("SW_ENGINE", "TODO: _rasterMaskedPolygonImageSegment()"); TVGERR("SW_ENGINE", "TODO: _rasterMaskedPolygonImageSegment()");
return false; return false;
} }
static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage* image, const RenderRegion* region, int yStart, int yEnd, AASpans* aaSpans, uint8_t opacity) static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage* image, const RenderRegion* bbox, int yStart, int yEnd, AASpans* aaSpans, uint8_t opacity)
{ {
float _dudx = dudx, _dvdx = dvdx; float _dudx = dudx, _dvdx = dvdx;
float _dxdya = dxdya, _dxdyb = dxdyb, _dudya = dudya, _dvdya = dvdya; float _dxdya = dxdya, _dxdyb = dxdyb, _dudya = dudya, _dvdya = dvdya;
@ -94,14 +94,14 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage
uint32_t* buf; uint32_t* buf;
SwSpan* span = nullptr; //used only when rle based. SwSpan* span = nullptr; //used only when rle based.
if (!_arrange(image, region, yStart, yEnd)) return; if (!_arrange(image, bbox, yStart, yEnd)) return;
//Loop through all lines in the segment //Loop through all lines in the segment
uint32_t spanIdx = 0; uint32_t spanIdx = 0;
if (region) { if (bbox) {
minx = region->min.x; minx = bbox->min.x;
maxx = region->max.x; maxx = bbox->max.x;
} else { } else {
span = image->rle->spans; span = image->rle->spans;
while (span->y < yStart) { while (span->y < yStart) {
@ -116,7 +116,7 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage
x1 = (int32_t)_xa; x1 = (int32_t)_xa;
x2 = (int32_t)_xb; x2 = (int32_t)_xb;
if (!region) { if (!bbox) {
minx = INT32_MAX; minx = INT32_MAX;
maxx = 0; maxx = 0;
//one single row, could be consisted of multiple spans. //one single row, could be consisted of multiple spans.
@ -195,7 +195,7 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage
_ua += _dudya; _ua += _dudya;
_va += _dvdya; _va += _dvdya;
if (!region && spanIdx >= image->rle->size) break; if (!bbox && spanIdx >= image->rle->size) break;
++y; ++y;
} }
@ -206,7 +206,7 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage
} }
static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, const RenderRegion* region, int yStart, int yEnd, AASpans* aaSpans, uint8_t opacity, bool matting) static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, const RenderRegion* bbox, int yStart, int yEnd, AASpans* aaSpans, uint8_t opacity, bool matting)
{ {
float _dudx = dudx, _dvdx = dvdx; float _dudx = dudx, _dvdx = dvdx;
float _dxdya = dxdya, _dxdyb = dxdyb, _dudya = dudya, _dvdya = dvdya; float _dxdya = dxdya, _dxdyb = dxdyb, _dudya = dudya, _dvdya = dvdya;
@ -227,14 +227,14 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image,
auto alpha = matting ? surface->alpha(surface->compositor->method) : nullptr; auto alpha = matting ? surface->alpha(surface->compositor->method) : nullptr;
uint8_t* cmp = nullptr; uint8_t* cmp = nullptr;
if (!_arrange(image, region, yStart, yEnd)) return; if (!_arrange(image, bbox, yStart, yEnd)) return;
//Loop through all lines in the segment //Loop through all lines in the segment
uint32_t spanIdx = 0; uint32_t spanIdx = 0;
if (region) { if (bbox) {
minx = region->min.x; minx = bbox->min.x;
maxx = region->max.x; maxx = bbox->max.x;
} else { } else {
span = image->rle->spans; span = image->rle->spans;
while (span->y < yStart) { while (span->y < yStart) {
@ -249,7 +249,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image,
x1 = (int32_t)_xa; x1 = (int32_t)_xa;
x2 = (int32_t)_xb; x2 = (int32_t)_xb;
if (!region) { if (!bbox) {
minx = INT32_MAX; minx = INT32_MAX;
maxx = 0; maxx = 0;
//one single row, could be consisted of multiple spans. //one single row, could be consisted of multiple spans.
@ -387,7 +387,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image,
_ua += _dudya; _ua += _dudya;
_va += _dvdya; _va += _dvdya;
if (!region && spanIdx >= image->rle->size) break; if (!bbox && spanIdx >= image->rle->size) break;
++y; ++y;
} }
@ -399,7 +399,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 RenderRegion* region, Polygon& polygon, AASpans* aaSpans, uint8_t opacity) static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const RenderRegion* bbox, Polygon& polygon, AASpans* aaSpans, uint8_t opacity)
{ {
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};
@ -460,7 +460,7 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
if (tvg::equal(y[0], y[1])) side = x[0] > x[1]; if (tvg::equal(y[0], y[1])) side = x[0] > x[1];
if (tvg::equal(y[1], y[2])) side = x[2] > x[1]; if (tvg::equal(y[1], y[2])) side = x[2] > x[1];
auto regionTop = region ? region->min.y : image->rle->spans->y; //Normal Image or Rle Image? auto bboxTop = bbox ? bbox->min.y : image->rle->spans->y; //Normal Image or Rle Image?
auto compositing = _compositing(surface); //Composition required auto compositing = _compositing(surface); //Composition required
auto blending = _blending(surface); //Blending required auto blending = _blending(surface); //Blending required
@ -479,7 +479,7 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
//Draw upper segment if possibly visible //Draw upper segment if possibly visible
if (yi[0] < yi[1]) { if (yi[0] < yi[1]) {
off_y = y[0] < regionTop ? (regionTop - y[0]) : 0; off_y = y[0] < bboxTop ? (bboxTop - y[0]) : 0;
xa += (off_y * dxdya); xa += (off_y * dxdya);
ua += (off_y * dudya); ua += (off_y * dudya);
va += (off_y * dvdya); va += (off_y * dvdya);
@ -489,18 +489,18 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
xb = x[0] + dy * dxdyb + (off_y * dxdyb); xb = x[0] + dy * dxdyb + (off_y * dxdyb);
if (compositing) { if (compositing) {
if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, true); if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, true);
else _rasterMaskedPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, 1); else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, 1);
} else if (blending) { } else if (blending) {
_rasterBlendingPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity); _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity);
} else { } else {
_rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, false); _rasterPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, false);
} }
upper = true; upper = true;
} }
//Draw lower segment if possibly visible //Draw lower segment if possibly visible
if (yi[1] < yi[2]) { if (yi[1] < yi[2]) {
off_y = y[1] < regionTop ? (regionTop - y[1]) : 0; off_y = y[1] < bboxTop ? (bboxTop - y[1]) : 0;
if (!upper) { if (!upper) {
xa += (off_y * dxdya); xa += (off_y * dxdya);
ua += (off_y * dudya); ua += (off_y * dudya);
@ -510,12 +510,12 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
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 (compositing) { if (compositing) {
if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, true); if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, true);
else _rasterMaskedPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, 2); else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, 2);
} else if (blending) { } else if (blending) {
_rasterBlendingPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity); _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity);
} else { } else {
_rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, false); _rasterPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, false);
} }
} }
//Longer edge is on the right side //Longer edge is on the right side
@ -527,7 +527,7 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
//Draw upper segment if possibly visible //Draw upper segment if possibly visible
if (yi[0] < yi[1]) { if (yi[0] < yi[1]) {
off_y = y[0] < regionTop ? (regionTop - y[0]) : 0; off_y = y[0] < bboxTop ? (bboxTop - y[0]) : 0;
xb += (off_y *dxdyb); xb += (off_y *dxdyb);
// Set slopes along left edge and perform subpixel pre-stepping // Set slopes along left edge and perform subpixel pre-stepping
@ -540,18 +540,18 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
va = v[0] + dy * dvdya + (off_y * dvdya); va = v[0] + dy * dvdya + (off_y * dvdya);
if (compositing) { if (compositing) {
if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, true); if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, true);
else _rasterMaskedPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, 3); else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, 3);
} else if (blending) { } else if (blending) {
_rasterBlendingPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity); _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity);
} else { } else {
_rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, false); _rasterPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, false);
} }
upper = true; upper = true;
} }
//Draw lower segment if possibly visible //Draw lower segment if possibly visible
if (yi[1] < yi[2]) { if (yi[1] < yi[2]) {
off_y = y[1] < regionTop ? (regionTop - y[1]) : 0; off_y = y[1] < bboxTop ? (bboxTop - y[1]) : 0;
if (!upper) xb += (off_y *dxdyb); if (!upper) xb += (off_y *dxdyb);
// Set slopes along left edge and perform subpixel pre-stepping // Set slopes along left edge and perform subpixel pre-stepping
@ -564,24 +564,24 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
va = v[1] + dy * dvdya + (off_y * dvdya); va = v[1] + dy * dvdya + (off_y * dvdya);
if (compositing) { if (compositing) {
if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, true); if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, true);
else _rasterMaskedPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, 4); else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, 4);
} else if (blending) { } else if (blending) {
_rasterBlendingPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity); _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity);
} else { } else {
_rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, false); _rasterPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, false);
} }
} }
} }
} }
static AASpans* _AASpans(float ymin, float ymax, const SwImage* image, const RenderRegion* region) static AASpans* _AASpans(float ymin, float ymax, const SwImage* image, const RenderRegion* bbox)
{ {
auto yStart = static_cast<int>(ymin); auto yStart = static_cast<int>(ymin);
auto yEnd = static_cast<int>(ymax); auto yEnd = static_cast<int>(ymax);
if (!_arrange(image, region, yStart, yEnd)) return nullptr; if (!_arrange(image, bbox, yStart, yEnd)) return nullptr;
auto aaSpans = tvg::malloc<AASpans*>(sizeof(AASpans)); auto aaSpans = tvg::malloc<AASpans*>(sizeof(AASpans));
aaSpans->yStart = yStart; aaSpans->yStart = yStart;
@ -863,7 +863,7 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans)
| / | | / |
3 -- 2 3 -- 2
*/ */
static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const Matrix& transform, const RenderRegion* region, uint8_t opacity) static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const Matrix& transform, const RenderRegion* bbox, uint8_t opacity)
{ {
if (surface->channelSize == sizeof(uint8_t)) { if (surface->channelSize == sizeof(uint8_t)) {
TVGERR("SW_ENGINE", "Not supported grayscale Textmap polygon!"); TVGERR("SW_ENGINE", "Not supported grayscale Textmap polygon!");
@ -871,7 +871,7 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const
} }
//Exceptions: No dedicated drawing area? //Exceptions: No dedicated drawing area?
if ((!image->rle && !region) || (image->rle && image->rle->size == 0)) return true; if ((!image->rle && !bbox) || (image->rle && image->rle->size == 0)) return true;
/* Prepare vertices. /* Prepare vertices.
shift XY coordinates to match the sub-pixeling technique. */ shift XY coordinates to match the sub-pixeling technique. */
@ -888,7 +888,7 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const
if (vertices[i].pt.y > ye) ye = vertices[i].pt.y; if (vertices[i].pt.y > ye) ye = vertices[i].pt.y;
} }
auto aaSpans = _AASpans(ys, ye, image, region); auto aaSpans = _AASpans(ys, ye, image, bbox);
if (!aaSpans) return true; if (!aaSpans) return true;
Polygon polygon; Polygon polygon;
@ -898,14 +898,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, polygon, aaSpans, opacity); _rasterPolygonImage(surface, image, bbox, polygon, aaSpans, opacity);
//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, polygon, aaSpans, opacity); _rasterPolygonImage(surface, image, bbox, polygon, aaSpans, opacity);
#if 0 #if 0
if (_compositing(surface) && _masking(surface) && !_direct(surface->compositor->method)) { if (_compositing(surface) && _masking(surface) && !_direct(surface->compositor->method)) {

View file

@ -106,7 +106,7 @@ struct SwShapeTask : SwTask
} }
auto strokeWidth = validStrokeWidth(clipper); auto strokeWidth = validStrokeWidth(clipper);
RenderRegion renderRegion{}; RenderRegion renderBox{};
auto updateShape = flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform | RenderUpdateFlag::Clip); auto updateShape = flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform | RenderUpdateFlag::Clip);
auto updateFill = false; auto updateFill = false;
@ -115,11 +115,11 @@ struct SwShapeTask : SwTask
updateFill = (MULTIPLY(rshape->color.a, opacity) || rshape->fill); updateFill = (MULTIPLY(rshape->color.a, opacity) || rshape->fill);
if (updateShape) shapeReset(&shape); if (updateShape) shapeReset(&shape);
if (updateFill || clipper) { if (updateFill || clipper) {
if (shapePrepare(&shape, rshape, transform, bbox, renderRegion, mpool, tid, clips.count > 0 ? true : false)) { if (shapePrepare(&shape, rshape, transform, bbox, renderBox, mpool, tid, clips.count > 0 ? true : false)) {
if (!shapeGenRle(&shape, rshape, antialiasing(strokeWidth))) goto err; if (!shapeGenRle(&shape, rshape, antialiasing(strokeWidth))) goto err;
} else { } else {
updateFill = false; updateFill = false;
renderRegion.reset(); renderBox.reset();
} }
} }
} }
@ -135,7 +135,7 @@ struct SwShapeTask : SwTask
if (updateShape || flags & RenderUpdateFlag::Stroke) { if (updateShape || flags & RenderUpdateFlag::Stroke) {
if (strokeWidth > 0.0f) { if (strokeWidth > 0.0f) {
shapeResetStroke(&shape, rshape, transform); shapeResetStroke(&shape, rshape, transform);
if (!shapeGenStrokeRle(&shape, rshape, transform, bbox, renderRegion, mpool, tid)) goto err; if (!shapeGenStrokeRle(&shape, rshape, transform, bbox, renderBox, mpool, tid)) goto err;
if (auto fill = rshape->strokeFill()) { if (auto fill = rshape->strokeFill()) {
auto ctable = (flags & RenderUpdateFlag::GradientStroke) ? true : false; auto ctable = (flags & RenderUpdateFlag::GradientStroke) ? true : false;
if (ctable) shapeResetStrokeFill(&shape); if (ctable) shapeResetStrokeFill(&shape);
@ -157,7 +157,7 @@ struct SwShapeTask : SwTask
if (!clipShapeRle && !clipStrokeRle) goto err; if (!clipShapeRle && !clipStrokeRle) goto err;
} }
bbox = renderRegion; //sync bbox = renderBox; //sync
return; return;
@ -188,7 +188,7 @@ struct SwImageTask : SwTask
void run(unsigned tid) override void run(unsigned tid) override
{ {
auto clipRegion = bbox; auto clipBox = bbox;
//Convert colorspace if it's not aligned. //Convert colorspace if it's not aligned.
rasterConvertCS(source, surface->cs); rasterConvertCS(source, surface->cs);
@ -205,7 +205,7 @@ struct SwImageTask : SwTask
imageReset(&image); imageReset(&image);
if (!image.data || image.w == 0 || image.h == 0) goto end; if (!image.data || image.w == 0 || image.h == 0) goto end;
if (!imagePrepare(&image, transform, clipRegion, bbox, mpool, tid)) goto end; if (!imagePrepare(&image, transform, clipBox, bbox, mpool, tid)) goto end;
if (clips.count > 0) { if (clips.count > 0) {
if (!imageGenRle(&image, bbox, false)) goto end; if (!imageGenRle(&image, bbox, false)) goto end;

View file

@ -844,7 +844,7 @@ void _replaceClipSpan(SwRle *rle, SwSpan* clippedSpans, uint32_t size)
/* External Class Implementation */ /* External Class Implementation */
/************************************************************************/ /************************************************************************/
SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& renderRegion, bool antiAlias) SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& bbox, bool antiAlias)
{ {
if (!outline) return nullptr; if (!outline) return nullptr;
@ -865,8 +865,8 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& rende
rw.area = 0; rw.area = 0;
rw.cover = 0; rw.cover = 0;
rw.invalid = true; rw.invalid = true;
rw.cellMin = {renderRegion.min.x, renderRegion.min.y}; rw.cellMin = {bbox.min.x, bbox.min.y};
rw.cellMax = {renderRegion.max.x, renderRegion.max.y}; rw.cellMax = {bbox.max.x, bbox.max.y};
rw.cellXCnt = rw.cellMax.x - rw.cellMin.x; rw.cellXCnt = rw.cellMax.x - rw.cellMin.x;
rw.cellYCnt = rw.cellMax.y - rw.cellMin.y; rw.cellYCnt = rw.cellMax.y - rw.cellMin.y;
rw.outline = const_cast<SwOutline*>(outline); rw.outline = const_cast<SwOutline*>(outline);

View file

@ -419,13 +419,13 @@ static SwOutline* _genOutline(SwShape* shape, const RenderShape* rshape, const M
/* External Class Implementation */ /* External Class Implementation */
/************************************************************************/ /************************************************************************/
bool shapePrepare(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid, bool hasComposite) bool shapePrepare(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid, bool hasComposite)
{ {
if (auto out = _genOutline(shape, rshape, transform, mpool, tid, hasComposite, rshape->trimpath())) shape->outline = out; if (auto out = _genOutline(shape, rshape, transform, mpool, tid, hasComposite, rshape->trimpath())) shape->outline = out;
else return false; else return false;
if (!mathUpdateOutlineBBox(shape->outline, clipRegion, renderRegion, shape->fastTrack)) return false; if (!mathUpdateOutlineBBox(shape->outline, clipBox, renderBox, shape->fastTrack)) return false;
shape->bbox = renderRegion; shape->bbox = renderBox;
return true; return true;
} }
@ -500,7 +500,7 @@ void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& t
} }
bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid) bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid)
{ {
SwOutline* shapeOutline = nullptr; SwOutline* shapeOutline = nullptr;
SwOutline* strokeOutline = nullptr; SwOutline* strokeOutline = nullptr;
@ -528,12 +528,12 @@ bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix&
strokeOutline = strokeExportOutline(shape->stroke, mpool, tid); strokeOutline = strokeExportOutline(shape->stroke, mpool, tid);
if (!mathUpdateOutlineBBox(strokeOutline, clipRegion, renderRegion, false)) { if (!mathUpdateOutlineBBox(strokeOutline, clipBox, renderBox, false)) {
ret = false; ret = false;
goto clear; goto clear;
} }
shape->strokeRle = rleRender(shape->strokeRle, strokeOutline, renderRegion, true); shape->strokeRle = rleRender(shape->strokeRle, strokeOutline, renderBox, true);
clear: clear:
if (dashStroking) mpoolRetDashOutline(mpool, tid); if (dashStroking) mpoolRetDashOutline(mpool, tid);