From dc8c5bce50f3d108511e20ccde00b8accd3c8fd8 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 27 May 2025 14:02:44 +0900 Subject: [PATCH] sw_engine: code refactoring just renamed internal variables (region -> bbox) for the sake of a shorter name, no logical changes. --- src/renderer/sw_engine/tvgSwCommon.h | 12 +- src/renderer/sw_engine/tvgSwImage.cpp | 8 +- src/renderer/sw_engine/tvgSwMath.cpp | 18 +- src/renderer/sw_engine/tvgSwPostEffect.cpp | 42 +-- src/renderer/sw_engine/tvgSwRaster.cpp | 352 ++++++++++----------- src/renderer/sw_engine/tvgSwRasterAvx.h | 10 +- src/renderer/sw_engine/tvgSwRasterC.h | 14 +- src/renderer/sw_engine/tvgSwRasterNeon.h | 10 +- src/renderer/sw_engine/tvgSwRasterTexmap.h | 106 +++---- src/renderer/sw_engine/tvgSwRenderer.cpp | 14 +- src/renderer/sw_engine/tvgSwRle.cpp | 6 +- src/renderer/sw_engine/tvgSwShape.cpp | 12 +- 12 files changed, 302 insertions(+), 302 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwCommon.h b/src/renderer/sw_engine/tvgSwCommon.h index 6e13c25a..1b25521f 100644 --- a/src/renderer/sw_engine/tvgSwCommon.h +++ b/src/renderer/sw_engine/tvgSwCommon.h @@ -489,15 +489,15 @@ SwFixed mathLength(const SwPoint& pt); int mathCubicAngle(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut); SwFixed mathMean(SwFixed angle1, SwFixed angle2); 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); -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 shapeGenRle(SwShape* shape, const RenderShape* rshape, bool antiAlias); void shapeDelOutline(SwShape* shape, SwMpool* mpool, uint32_t tid); 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 shapeDelStroke(SwShape* shape); 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); void strokeFree(SwStroke* stroke); -bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& clipRegion, RenderRegion& renderRegion, SwMpool* mpool, unsigned tid); -bool imageGenRle(SwImage* image, const RenderRegion& renderRegion, bool antiAlias); +bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& clipBox, RenderRegion& renderBox, SwMpool* mpool, unsigned tid); +bool imageGenRle(SwImage* image, const RenderRegion& bbox, bool antiAlias); void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid); void imageReset(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, 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); void rleFree(SwRle* rle); void rleReset(SwRle* rle); diff --git a/src/renderer/sw_engine/tvgSwImage.cpp b/src/renderer/sw_engine/tvgSwImage.cpp index 11cc0f22..bcf54465 100644 --- a/src/renderer/sw_engine/tvgSwImage.cpp +++ b/src/renderer/sw_engine/tvgSwImage.cpp @@ -72,7 +72,7 @@ static bool _genOutline(SwImage* image, const Matrix& transform, SwMpool* mpool, /* 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); @@ -91,13 +91,13 @@ bool imagePrepare(SwImage* image, const Matrix& transform, const RenderRegion& c } 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; } diff --git a/src/renderer/sw_engine/tvgSwMath.cpp b/src/renderer/sw_engine/tvgSwMath.cpp index 76b39671..e72b798a 100644 --- a/src/renderer/sw_engine/tvgSwMath.cpp +++ b/src/renderer/sw_engine/tvgSwMath.cpp @@ -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->pts.empty() || outline->cntrs.empty()) { - renderRegion.reset(); + renderBox.reset(); return false; } @@ -295,13 +295,13 @@ bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipReg } if (fastTrack) { - renderRegion.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.min = {int32_t(round(xMin / 64.0f)), int32_t(round(yMin / 64.0f))}; + renderBox.max = {int32_t(round(xMax / 64.0f)), int32_t(round(yMax / 64.0f))}; } else { - renderRegion.min = {xMin >> 6, yMin >> 6}; - renderRegion.max = {(xMax + 63) >> 6, (yMax + 63) >> 6}; + renderBox.min = {xMin >> 6, yMin >> 6}; + renderBox.max = {(xMax + 63) >> 6, (yMax + 63) >> 6}; } - renderRegion.intersect(clipRegion); - return renderRegion.valid(); -} \ No newline at end of file + renderBox.intersect(clipBox); + return renderBox.valid(); +} diff --git a/src/renderer/sw_engine/tvgSwPostEffect.cpp b/src/renderer/sw_engine/tvgSwPostEffect.cpp index 1a1c8db8..1aa0c468 100644 --- a/src/renderer/sw_engine/tvgSwPostEffect.cpp +++ b/src/renderer/sw_engine/tvgSwPostEffect.cpp @@ -136,17 +136,17 @@ static int _gaussianInit(SwGaussianBlur* data, float sigma, int quality) bool effectGaussianBlurRegion(RenderEffectGaussianBlur* params) { - //bbox region expansion for feathering - auto& region = params->extend; + //region expansion for feathering + auto& bbox = params->extend; auto extra = static_cast(params->rd)->extends; if (params->direction != 2) { - region.min.x = -extra; - region.max.x = extra; + bbox.min.x = -extra; + bbox.max.x = extra; } if (params->direction != 1) { - region.min.y = -extra; - region.max.y = extra; + bbox.min.y = -extra; + bbox.max.y = extra; } 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); - dst += (region.min.y * dstride + region.min.x); + src += (bbox.min.y * sstride + bbox.min.x); + dst += (bbox.min.y * dstride + bbox.min.x); - auto w = region.max.x - region.min.x; - auto h = region.max.y - region.min.y; + auto w = bbox.max.x - bbox.min.x; + auto h = bbox.max.y - bbox.min.y; auto translucent = (direct || opacity < 255); //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; - 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); 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) { - //bbox region expansion for feathering - auto& region = params->extend; + //region expansion for feathering + auto& bbox = params->extend; auto& offset = static_cast(params->rd)->offset; auto extra = static_cast(params->rd)->extends; - region.min = {-extra, -extra}; - region.max = {extra, extra}; + bbox.min = {-extra, -extra}; + bbox.max = {extra, extra}; - if (offset.x < 0) region.min.x += (int32_t) offset.x; - else region.max.x += offset.x; + if (offset.x < 0) bbox.min.x += (int32_t) offset.x; + else bbox.max.x += offset.x; - if (offset.y < 0) region.min.y += (int32_t) offset.y; - else region.max.y += offset.y; + if (offset.y < 0) bbox.min.y += (int32_t) offset.y; + else bbox.max.y += offset.y; return true; } diff --git a/src/renderer/sw_engine/tvgSwRaster.cpp b/src/renderer/sw_engine/tvgSwRaster.cpp index 4ea1f783..f10885ea 100644 --- a/src/renderer/sw_engine/tvgSwRaster.cpp +++ b/src/renderer/sw_engine/tvgSwRaster.cpp @@ -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 sbuffer = image->buf8 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); + auto dbuffer = &surface->buf8[bbox.min.y * surface->stride + bbox.min.x]; + 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 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); } dbuffer += surface->stride; @@ -317,15 +317,15 @@ static uint32_t _interpDownScaler(const uint32_t *img, uint32_t stride, uint32_t /* 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 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; - for (uint32_t y = 0; y < region.h(); ++y) { + for (uint32_t y = 0; y < bbox.h(); ++y) { 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); } 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 dbuffer = surface->buf8 + (region.min.y * surface->stride + region.min.x); //destination buffer + auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x); //compositor 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 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. *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 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); - if (_direct(surface->compositor->method)) return _rasterDirectMaskedRect(surface, region, maskOp, c.a); - else return _rasterCompositeMaskedRect(surface, region, maskOp, c.a); + if (_direct(surface->compositor->method)) return _rasterDirectMaskedRect(surface, bbox, maskOp, c.a); + else return _rasterCompositeMaskedRect(surface, bbox, maskOp, c.a); 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 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); - 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 if (surface->channelSize == sizeof(uint32_t)) { auto color = surface->join(c.r, c.g, c.b, c.a); - auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { + auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { auto dst = &buffer[y * surface->stride]; 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)); *dst = tmp + ALPHA_BLEND(*dst, IA(tmp)); } } //8bits grayscale } else if (surface->channelSize == sizeof(uint8_t)) { - auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { + auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { auto dst = &buffer[y * surface->stride]; 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)); } } @@ -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; 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]; - 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); } } @@ -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) - return avxRasterTranslucentRect(surface, region, c); + return avxRasterTranslucentRect(surface, bbox, c); #elif defined(THORVG_NEON_VECTOR_SUPPORT) - return neonRasterTranslucentRect(surface, region, c); + return neonRasterTranslucentRect(surface, bbox, c); #else - return cRasterTranslucentRect(surface, region, c); + return cRasterTranslucentRect(surface, bbox, c); #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 if (surface->channelSize == sizeof(uint32_t)) { auto color = surface->join(c.r, c.g, c.b, 255); - auto buffer = surface->buf32 + (region.min.y * surface->stride); - for (uint32_t y = 0; y < region.h(); ++y) { - rasterPixel32(buffer + y * surface->stride, color, region.min.x, region.w()); + auto buffer = surface->buf32 + (bbox.min.y * surface->stride); + for (uint32_t y = 0; y < bbox.h(); ++y) { + rasterPixel32(buffer + y * surface->stride, color, bbox.min.x, bbox.w()); } return true; } //8bits grayscale if (surface->channelSize == sizeof(uint8_t)) { - for (uint32_t y = 0; y < region.h(); ++y) { - rasterGrayscale8(surface->buf8, 255, (y + region.min.y) * surface->stride + region.min.x, region.w()); + for (uint32_t y = 0; y < bbox.h(); ++y) { + rasterGrayscale8(surface->buf8, 255, (y + bbox.min.y) * surface->stride + bbox.min.x, bbox.w()); } 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 (_matting(surface)) return _rasterMattedRect(surface, region, c); - else return _rasterMaskedRect(surface, region, c); + if (_matting(surface)) return _rasterMattedRect(surface, bbox, c); + else return _rasterMaskedRect(surface, bbox, c); } else if (_blending(surface)) { - return _rasterBlendingRect(surface, region, c); + return _rasterBlendingRect(surface, bbox, c); } else { - if (c.a == 255) return _rasterSolidRect(surface, region, c); - else return _rasterTranslucentRect(surface, region, c); + if (c.a == 255) return _rasterSolidRect(surface, bbox, c); + else return _rasterTranslucentRect(surface, bbox, c); } 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; \ 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); 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); @@ -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 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 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)) { 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 (_compositing(surface)) { - if (_matting(surface)) return _rasterScaledMattedRleImage(surface, image, &itransform, region, opacity); - else return _rasterScaledMaskedRleImage(surface, image, &itransform, region, opacity); + if (_matting(surface)) return _rasterScaledMattedRleImage(surface, image, &itransform, bbox, opacity); + else return _rasterScaledMaskedRleImage(surface, image, &itransform, bbox, opacity); } else if (_blending(surface)) { - return _rasterScaledBlendingRleImage(surface, image, &itransform, region, opacity); + return _rasterScaledBlendingRleImage(surface, image, &itransform, bbox, opacity); } else { - return _rasterScaledRleImage(surface, image, &itransform, region, opacity); + return _rasterScaledRleImage(surface, image, &itransform, bbox, opacity); } return false; } @@ -887,36 +887,36 @@ static bool _directRleImage(SwSurface* surface, const SwImage* image, uint8_t op /*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!"); 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)) { TVGERR("SW_ENGINE", "Not supported grayscale scaled matted image!"); 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 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); - 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 sampleSize = _sampleSize(image->scale); 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) auto dst = dbuffer; 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 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))); @@ -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)) { TVGERR("SW_ENGINE", "Not supported grayscale scaled blending image!"); 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 sampleSize = _sampleSize(image->scale); 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) 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 auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); 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 sampleSize = _sampleSize(image->scale); @@ -963,11 +963,11 @@ static bool _rasterScaledImage(SwSurface* surface, const SwImage* image, const M //32bits channels if (surface->channelSize == sizeof(uint32_t)) { - auto buffer = surface->buf32 + (region.min.y * surface->stride + region.min.x); - for (auto y = region.min.y; y < region.max.y; ++y, buffer += surface->stride) { + auto buffer = surface->buf32 + (bbox.min.y * surface->stride + bbox.min.x); + for (auto y = bbox.min.y; y < bbox.max.y; ++y, buffer += surface->stride) { SCALED_IMAGE_RANGE_Y(y) 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 auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); 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)) { - auto buffer = surface->buf8 + (region.min.y * surface->stride + region.min.x); - for (auto y = region.min.y; y < region.max.y; ++y, buffer += surface->stride) { + auto buffer = surface->buf8 + (bbox.min.y * surface->stride + bbox.min.x); + for (auto y = bbox.min.y; y < bbox.max.y; ++y, buffer += surface->stride) { SCALED_IMAGE_RANGE_Y(y) 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 auto src = scaleMethod(image->buf32, image->stride, image->w, image->h, sx, sy, miny, maxy, sampleSize); *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; if (!inverse(&transform, &itransform)) return true; if (_compositing(surface)) { - if (_matting(surface)) return _rasterScaledMattedImage(surface, image, &itransform, region, opacity); - else return _rasterScaledMaskedImage(surface, image, &itransform, region, opacity); + if (_matting(surface)) return _rasterScaledMattedImage(surface, image, &itransform, bbox, opacity); + else return _rasterScaledMaskedImage(surface, image, &itransform, bbox, opacity); } else if (_blending(surface)) { - return _rasterScaledBlendingImage(surface, image, &itransform, region, opacity); + return _rasterScaledBlendingImage(surface, image, &itransform, bbox, opacity); } else { - return _rasterScaledImage(surface, image, &itransform, region, opacity); + return _rasterScaledImage(surface, image, &itransform, bbox, opacity); } return false; } @@ -1012,36 +1012,36 @@ static bool _scaledImage(SwSurface* surface, const SwImage* image, const Matrix& /* 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"); 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 alpha = surface->alpha(surface->compositor->method); - auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); - auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x) * csize; //compositor buffer + auto sbuffer = image->buf32 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox); + 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 if (surface->channelSize == sizeof(uint32_t)) { - auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { + auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { auto dst = buffer; auto cmp = cbuffer; auto src = sbuffer; 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)); *dst = tmp + ALPHA_BLEND(*dst, IA(tmp)); } } 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))); *dst = tmp + ALPHA_BLEND(*dst, IA(tmp)); } @@ -1052,18 +1052,18 @@ static bool _rasterDirectMattedImage(SwSurface* surface, const SwImage* image, c } //8 bits } else if (surface->channelSize == sizeof(uint8_t)) { - auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { + auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { auto dst = buffer; auto cmp = cbuffer; auto src = sbuffer; 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)); *dst = tmp + MULTIPLY(*dst, 255 - tmp); } } 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))); *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)) { TVGERR("SW_ENGINE", "Not supported grayscale image!"); return false; } - auto dbuffer = &surface->buf32[region.min.y * surface->stride + region.min.x]; - auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); + auto dbuffer = &surface->buf32[bbox.min.y * surface->stride + bbox.min.x]; + 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 src = sbuffer; 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); *dst = INTERPOLATE(tmp, *dst, A(*src)); } } 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); *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 if (surface->channelSize == sizeof(uint32_t)) { - auto dbuffer = &surface->buf32[region.min.y * surface->stride + region.min.x]; - for (auto y = region.min.y; y < region.max.y; ++y) { - rasterTranslucentPixel32(dbuffer, sbuffer, region.max.x - region.min.x, opacity); + auto dbuffer = &surface->buf32[bbox.min.y * surface->stride + bbox.min.x]; + for (auto y = bbox.min.y; y < bbox.max.y; ++y) { + rasterTranslucentPixel32(dbuffer, sbuffer, bbox.max.x - bbox.min.x, opacity); dbuffer += surface->stride; sbuffer += image->stride; } //8bits grayscale } else if (surface->channelSize == sizeof(uint8_t)) { - auto dbuffer = &surface->buf8[region.min.y * surface->stride + region.min.x]; - for (auto y = region.min.y; y < region.max.y; ++y, dbuffer += surface->stride, sbuffer += image->stride) { + auto dbuffer = &surface->buf8[bbox.min.y * surface->stride + bbox.min.x]; + for (auto y = bbox.min.y; y < bbox.max.y; ++y, dbuffer += surface->stride, sbuffer += image->stride) { auto dst = dbuffer; auto src = sbuffer; 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)); } } 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); } } @@ -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)) { 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 alpha = surface->alpha(surface->compositor->method); - auto sbuffer = image->buf32 + (region.min.y + image->oy) * image->stride + (region.min.x + image->ox); - auto cbuffer = surface->compositor->image.buf8 + (region.min.y * surface->compositor->image.stride + region.min.x) * csize; //compositor buffer - auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; + auto sbuffer = image->buf32 + (bbox.min.y + image->oy) * image->stride + (bbox.min.x + image->ox); + auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * surface->compositor->image.stride + bbox.min.x) * csize; //compositor buffer + 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 cmp = cbuffer; auto src = sbuffer; 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)); *dst = INTERPOLATE(surface->blender(tmp, *dst, 255), *dst, A(tmp)); } } 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)); *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] -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 (_matting(surface)) { - if (_blending(surface)) return _rasterDirectMattedBlendingImage(surface, image, region, opacity); - else return _rasterDirectMattedImage(surface, image, region, opacity); - } else return _rasterDirectMaskedImage(surface, image, region, opacity); + if (_blending(surface)) return _rasterDirectMattedBlendingImage(surface, image, bbox, opacity); + else return _rasterDirectMattedImage(surface, image, bbox, opacity); + } else return _rasterDirectMaskedImage(surface, image, bbox, opacity); } else if (_blending(surface)) { - return _rasterDirectBlendingImage(surface, image, region, opacity); + return _rasterDirectBlendingImage(surface, image, bbox, opacity); } else { - return _rasterDirectImage(surface, image, region, opacity); + return _rasterDirectImage(surface, image, bbox, opacity); } return false; } //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 if (image->rle) { 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); //Whole Image } else { - if (image->direct) return _directImage(surface, image, region, opacity); - else if (image->scaled) return _scaledImage(surface, image, transform, region, opacity); - else return _rasterTexmapPolygon(surface, image, transform, ®ion, opacity); + if (image->direct) return _directImage(surface, image, bbox, opacity); + else if (image->scaled) return _scaledImage(surface, image, transform, bbox, opacity); + else return _rasterTexmapPolygon(surface, image, transform, &bbox, opacity); } } @@ -1216,13 +1216,13 @@ static bool _rasterImage(SwSurface* surface, SwImage* image, const Matrix& trans /************************************************************************/ template -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 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) { - fillMethod()(fill, cbuffer, region.min.y + y, region.min.x, region.w(), maskOp, 255); + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, cbuffer, bbox.min.y + y, bbox.min.x, bbox.w(), maskOp, 255); cbuffer += surface->stride; } return _compositeMaskImage(surface, &surface->compositor->image, surface->compositor->bbox); @@ -1230,14 +1230,14 @@ static bool _rasterCompositeGradientMaskedRect(SwSurface* surface, const RenderR template -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 cbuffer = surface->compositor->image.buf8 + (region.min.y * cstride + region.min.x); - auto dbuffer = surface->buf8 + (region.min.y * surface->stride + region.min.x); + auto cbuffer = surface->compositor->image.buf8 + (bbox.min.y * cstride + bbox.min.x); + auto dbuffer = surface->buf8 + (bbox.min.y * surface->stride + bbox.min.x); - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, dbuffer, region.min.y + y, region.min.x, region.w(), cbuffer, maskOp, 255); + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, dbuffer, bbox.min.y + y, bbox.min.x, bbox.w(), cbuffer, maskOp, 255); cbuffer += cstride; dbuffer += surface->stride; } @@ -1246,33 +1246,33 @@ static bool _rasterDirectGradientMaskedRect(SwSurface* surface, const RenderRegi template -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; - 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); - if (_direct(method)) return _rasterDirectGradientMaskedRect(surface, region, fill, maskOp); - else return _rasterCompositeGradientMaskedRect(surface, region, fill, maskOp); + if (_direct(method)) return _rasterDirectGradientMaskedRect(surface, bbox, fill, maskOp); + else return _rasterCompositeGradientMaskedRect(surface, bbox, fill, maskOp); return false; } template -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 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); - 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) { - fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), cbuffer, alpha, csize, 255); + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), cbuffer, alpha, csize, 255); buffer += surface->stride; cbuffer += surface->stride * csize; } @@ -1281,37 +1281,37 @@ static bool _rasterGradientMattedRect(SwSurface* surface, const RenderRegion& re template -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) { - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, buffer + y * surface->stride, region.min.y + y, region.min.x, region.w(), opBlendPreNormal, surface->blender, 255); + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer + y * surface->stride, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendPreNormal, surface->blender, 255); } } else { - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, buffer + y * surface->stride, region.min.y + y, region.min.x, region.w(), opBlendSrcOver, surface->blender, 255); + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer + y * surface->stride, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendSrcOver, surface->blender, 255); } } return true; } template -static bool _rasterTranslucentGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) +static bool _rasterTranslucentGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill) { //32 bits if (surface->channelSize == sizeof(uint32_t)) { - auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), opBlendPreNormal, 255); + auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendPreNormal, 255); buffer += surface->stride; } //8 bits } else if (surface->channelSize == sizeof(uint8_t)) { - auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), _opMaskAdd, 255); + auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), _opMaskAdd, 255); buffer += surface->stride; } } @@ -1320,20 +1320,20 @@ static bool _rasterTranslucentGradientRect(SwSurface* surface, const RenderRegio template -static bool _rasterSolidGradientRect(SwSurface* surface, const RenderRegion& region, const SwFill* fill) +static bool _rasterSolidGradientRect(SwSurface* surface, const RenderRegion& bbox, const SwFill* fill) { //32 bits if (surface->channelSize == sizeof(uint32_t)) { - auto buffer = surface->buf32 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), opBlendSrcOver, 255); + auto buffer = surface->buf32 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), opBlendSrcOver, 255); buffer += surface->stride; } //8 bits } else if (surface->channelSize == sizeof(uint8_t)) { - auto buffer = surface->buf8 + (region.min.y * surface->stride) + region.min.x; - for (uint32_t y = 0; y < region.h(); ++y) { - fillMethod()(fill, buffer, region.min.y + y, region.min.x, region.w(), _opMaskNone, 255); + auto buffer = surface->buf8 + (bbox.min.y * surface->stride) + bbox.min.x; + for (uint32_t y = 0; y < bbox.h(); ++y) { + fillMethod()(fill, buffer, bbox.min.y + y, bbox.min.x, bbox.w(), _opMaskNone, 255); 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 (_matting(surface)) return _rasterGradientMattedRect(surface, region, fill); - else return _rasterGradientMaskedRect(surface, region, fill); + if (_matting(surface)) return _rasterGradientMattedRect(surface, bbox, fill); + else return _rasterGradientMaskedRect(surface, bbox, fill); } else if (_blending(surface)) { - return _rasterBlendingGradientRect(surface, region, fill); + return _rasterBlendingGradientRect(surface, bbox, fill); } else { - if (fill->translucent) return _rasterTranslucentGradientRect(surface, region, fill); - else _rasterSolidGradientRect(surface, region, fill); + if (fill->translucent) return _rasterTranslucentGradientRect(surface, bbox, fill); + else _rasterSolidGradientRect(surface, bbox, fill); } 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 (_matting(surface)) return _rasterGradientMattedRect(surface, region, fill); - else return _rasterGradientMaskedRect(surface, region, fill); + if (_matting(surface)) return _rasterGradientMattedRect(surface, bbox, fill); + else return _rasterGradientMaskedRect(surface, bbox, fill); } else if (_blending(surface)) { - return _rasterBlendingGradientRect(surface, region, fill); + return _rasterBlendingGradientRect(surface, bbox, fill); } else { - if (fill->translucent) return _rasterTranslucentGradientRect(surface, region, fill); - else _rasterSolidGradientRect(surface, region, fill); + if (fill->translucent) return _rasterTranslucentGradientRect(surface, bbox, fill); + else _rasterSolidGradientRect(surface, bbox, fill); } return false; } diff --git a/src/renderer/sw_engine/tvgSwRasterAvx.h b/src/renderer/sw_engine/tvgSwRasterAvx.h index 103f7dc5..6465243c 100644 --- a/src/renderer/sw_engine/tvgSwRasterAvx.h +++ b/src/renderer/sw_engine/tvgSwRasterAvx.h @@ -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 w = region.w(); + auto h = bbox.h(); + auto w = bbox.w(); //32bits channels if (surface->channelSize == sizeof(uint32_t)) { 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; @@ -145,7 +145,7 @@ static bool avxRasterTranslucentRect(SwSurface* surface, const RenderRegion& reg //8bit grayscale } else if (surface->channelSize == sizeof(uint8_t)) { 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; for (uint32_t y = 0; y < h; ++y) { auto dst = &buffer[y * surface->stride]; diff --git a/src/renderer/sw_engine/tvgSwRasterC.h b/src/renderer/sw_engine/tvgSwRasterC.h index 7d00929a..59ed98c0 100644 --- a/src/renderer/sw_engine/tvgSwRasterC.h +++ b/src/renderer/sw_engine/tvgSwRasterC.h @@ -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 if (surface->channelSize == sizeof(uint32_t)) { 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; - for (uint32_t y = 0; y < region.h(); ++y) { + for (uint32_t y = 0; y < bbox.h(); ++y) { 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); } } //8bit grayscale } 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; - for (uint32_t y = 0; y < region.h(); ++y) { + for (uint32_t y = 0; y < bbox.h(); ++y) { 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); } } diff --git a/src/renderer/sw_engine/tvgSwRasterNeon.h b/src/renderer/sw_engine/tvgSwRasterNeon.h index 37596250..387b81a6 100644 --- a/src/renderer/sw_engine/tvgSwRasterNeon.h +++ b/src/renderer/sw_engine/tvgSwRasterNeon.h @@ -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 w = region.w(); + auto h = bbox.h(); + auto w = bbox.w(); //32bits channels if (surface->channelSize == sizeof(uint32_t)) { 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 vColor = vdup_n_u32(color); @@ -185,7 +185,7 @@ static bool neonRasterTranslucentRect(SwSurface* surface, const RenderRegion& re //8bit grayscale } else if (surface->channelSize == sizeof(uint8_t)) { 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; for (uint32_t y = 0; y < h; ++y) { auto dst = &buffer[y * surface->stride]; diff --git a/src/renderer/sw_engine/tvgSwRasterTexmap.h b/src/renderer/sw_engine/tvgSwRasterTexmap.h index c9264798..4b777d6f 100644 --- a/src/renderer/sw_engine/tvgSwRasterTexmap.h +++ b/src/renderer/sw_engine/tvgSwRasterTexmap.h @@ -52,33 +52,33 @@ static float xa, xb, ua, va; //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) { - regionTop = region->min.y; - regionBottom = region->max.y; + if (bbox) { + bboxTop = bbox->min.y; + bboxBottom = bbox->max.y; } else { - regionTop = image->rle->spans->y; - regionBottom = image->rle->spans[image->rle->size - 1].y; + bboxTop = image->rle->spans->y; + bboxBottom = image->rle->spans[image->rle->size - 1].y; } - if (yStart < regionTop) yStart = regionTop; - if (yEnd > regionBottom) yEnd = regionBottom; + if (yStart < bboxTop) yStart = bboxTop; + if (yEnd > bboxBottom) yEnd = bboxBottom; 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()"); 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 _dxdya = dxdya, _dxdyb = dxdyb, _dudya = dudya, _dvdya = dvdya; @@ -94,14 +94,14 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage uint32_t* buf; 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 uint32_t spanIdx = 0; - if (region) { - minx = region->min.x; - maxx = region->max.x; + if (bbox) { + minx = bbox->min.x; + maxx = bbox->max.x; } else { span = image->rle->spans; while (span->y < yStart) { @@ -116,7 +116,7 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage x1 = (int32_t)_xa; x2 = (int32_t)_xb; - if (!region) { + if (!bbox) { minx = INT32_MAX; maxx = 0; //one single row, could be consisted of multiple spans. @@ -195,7 +195,7 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage _ua += _dudya; _va += _dvdya; - if (!region && spanIdx >= image->rle->size) break; + if (!bbox && spanIdx >= image->rle->size) break; ++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 _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; 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 uint32_t spanIdx = 0; - if (region) { - minx = region->min.x; - maxx = region->max.x; + if (bbox) { + minx = bbox->min.x; + maxx = bbox->max.x; } else { span = image->rle->spans; while (span->y < yStart) { @@ -249,7 +249,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, x1 = (int32_t)_xa; x2 = (int32_t)_xb; - if (!region) { + if (!bbox) { minx = INT32_MAX; maxx = 0; //one single row, could be consisted of multiple spans. @@ -387,7 +387,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, _ua += _dudya; _va += _dvdya; - if (!region && spanIdx >= image->rle->size) break; + if (!bbox && spanIdx >= image->rle->size) break; ++y; } @@ -399,7 +399,7 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, /* 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 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[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 blending = _blending(surface); //Blending required @@ -479,7 +479,7 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const //Draw upper segment if possibly visible 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); ua += (off_y * dudya); 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); if (compositing) { - if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, true); - else _rasterMaskedPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, 1); + if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, true); + else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, 1); } else if (blending) { - _rasterBlendingPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity); + _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity); } 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; } //Draw lower segment if possibly visible 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) { xa += (off_y * dxdya); ua += (off_y * dudya); @@ -510,12 +510,12 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const dxdyb = dxdy[2]; xb = x[1] + (1 - (y[1] - yi[1])) * dxdyb + (off_y * dxdyb); if (compositing) { - if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, true); - else _rasterMaskedPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, 2); + if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, true); + else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, 2); } else if (blending) { - _rasterBlendingPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity); + _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity); } 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 @@ -527,7 +527,7 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const //Draw upper segment if possibly visible 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); // 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); if (compositing) { - if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, true); - else _rasterMaskedPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity, 3); + if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, true); + else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity, 3); } else if (blending) { - _rasterBlendingPolygonImageSegment(surface, image, region, yi[0], yi[1], aaSpans, opacity); + _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[0], yi[1], aaSpans, opacity); } 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; } //Draw lower segment if possibly visible 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); // 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); if (compositing) { - if (_matting(surface)) _rasterPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, true); - else _rasterMaskedPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity, 4); + if (_matting(surface)) _rasterPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, true); + else _rasterMaskedPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity, 4); } else if (blending) { - _rasterBlendingPolygonImageSegment(surface, image, region, yi[1], yi[2], aaSpans, opacity); + _rasterBlendingPolygonImageSegment(surface, image, bbox, yi[1], yi[2], aaSpans, opacity); } 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(ymin); auto yEnd = static_cast(ymax); - if (!_arrange(image, region, yStart, yEnd)) return nullptr; + if (!_arrange(image, bbox, yStart, yEnd)) return nullptr; auto aaSpans = tvg::malloc(sizeof(AASpans)); aaSpans->yStart = yStart; @@ -863,7 +863,7 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans) | / | 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)) { 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? - 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. 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; } - auto aaSpans = _AASpans(ys, ye, image, region); + auto aaSpans = _AASpans(ys, ye, image, bbox); if (!aaSpans) return true; Polygon polygon; @@ -898,14 +898,14 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const polygon.vertex[1] = vertices[1]; polygon.vertex[2] = vertices[3]; - _rasterPolygonImage(surface, image, region, polygon, aaSpans, opacity); + _rasterPolygonImage(surface, image, bbox, polygon, aaSpans, opacity); //Draw the second polygon polygon.vertex[0] = vertices[1]; polygon.vertex[1] = vertices[2]; polygon.vertex[2] = vertices[3]; - _rasterPolygonImage(surface, image, region, polygon, aaSpans, opacity); + _rasterPolygonImage(surface, image, bbox, polygon, aaSpans, opacity); #if 0 if (_compositing(surface) && _masking(surface) && !_direct(surface->compositor->method)) { diff --git a/src/renderer/sw_engine/tvgSwRenderer.cpp b/src/renderer/sw_engine/tvgSwRenderer.cpp index f85e817a..c44f28cb 100644 --- a/src/renderer/sw_engine/tvgSwRenderer.cpp +++ b/src/renderer/sw_engine/tvgSwRenderer.cpp @@ -106,7 +106,7 @@ struct SwShapeTask : SwTask } auto strokeWidth = validStrokeWidth(clipper); - RenderRegion renderRegion{}; + RenderRegion renderBox{}; auto updateShape = flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform | RenderUpdateFlag::Clip); auto updateFill = false; @@ -115,11 +115,11 @@ struct SwShapeTask : SwTask updateFill = (MULTIPLY(rshape->color.a, opacity) || rshape->fill); if (updateShape) shapeReset(&shape); 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; } else { updateFill = false; - renderRegion.reset(); + renderBox.reset(); } } } @@ -135,7 +135,7 @@ struct SwShapeTask : SwTask if (updateShape || flags & RenderUpdateFlag::Stroke) { if (strokeWidth > 0.0f) { 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()) { auto ctable = (flags & RenderUpdateFlag::GradientStroke) ? true : false; if (ctable) shapeResetStrokeFill(&shape); @@ -157,7 +157,7 @@ struct SwShapeTask : SwTask if (!clipShapeRle && !clipStrokeRle) goto err; } - bbox = renderRegion; //sync + bbox = renderBox; //sync return; @@ -188,7 +188,7 @@ struct SwImageTask : SwTask void run(unsigned tid) override { - auto clipRegion = bbox; + auto clipBox = bbox; //Convert colorspace if it's not aligned. rasterConvertCS(source, surface->cs); @@ -205,7 +205,7 @@ struct SwImageTask : SwTask imageReset(&image); 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 (!imageGenRle(&image, bbox, false)) goto end; diff --git a/src/renderer/sw_engine/tvgSwRle.cpp b/src/renderer/sw_engine/tvgSwRle.cpp index 82d5ae23..48ad3f91 100644 --- a/src/renderer/sw_engine/tvgSwRle.cpp +++ b/src/renderer/sw_engine/tvgSwRle.cpp @@ -844,7 +844,7 @@ void _replaceClipSpan(SwRle *rle, SwSpan* clippedSpans, uint32_t size) /* 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; @@ -865,8 +865,8 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& rende rw.area = 0; rw.cover = 0; rw.invalid = true; - rw.cellMin = {renderRegion.min.x, renderRegion.min.y}; - rw.cellMax = {renderRegion.max.x, renderRegion.max.y}; + rw.cellMin = {bbox.min.x, bbox.min.y}; + rw.cellMax = {bbox.max.x, bbox.max.y}; rw.cellXCnt = rw.cellMax.x - rw.cellMin.x; rw.cellYCnt = rw.cellMax.y - rw.cellMin.y; rw.outline = const_cast(outline); diff --git a/src/renderer/sw_engine/tvgSwShape.cpp b/src/renderer/sw_engine/tvgSwShape.cpp index 44bd9a98..f69ff380 100644 --- a/src/renderer/sw_engine/tvgSwShape.cpp +++ b/src/renderer/sw_engine/tvgSwShape.cpp @@ -419,13 +419,13 @@ static SwOutline* _genOutline(SwShape* shape, const RenderShape* rshape, const M /* 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; 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; } @@ -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* strokeOutline = nullptr; @@ -528,12 +528,12 @@ bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix& strokeOutline = strokeExportOutline(shape->stroke, mpool, tid); - if (!mathUpdateOutlineBBox(strokeOutline, clipRegion, renderRegion, false)) { + if (!mathUpdateOutlineBBox(strokeOutline, clipBox, renderBox, false)) { ret = false; goto clear; } - shape->strokeRle = rleRender(shape->strokeRle, strokeOutline, renderRegion, true); + shape->strokeRle = rleRender(shape->strokeRle, strokeOutline, renderBox, true); clear: if (dashStroking) mpoolRetDashOutline(mpool, tid);