sw_engine: code refactoring.

just renamed internal name shorter.
This commit is contained in:
Hermet Park 2024-07-10 17:14:45 +09:00 committed by Hermet Park
parent 065a8f5eb3
commit 837cf32bcb
5 changed files with 53 additions and 53 deletions

View file

@ -113,7 +113,7 @@ struct SwSpan
uint8_t coverage; uint8_t coverage;
}; };
struct SwRleData struct SwRle
{ {
SwSpan *spans; SwSpan *spans;
uint32_t alloc; uint32_t alloc;
@ -207,8 +207,8 @@ struct SwShape
SwOutline* outline = nullptr; SwOutline* outline = nullptr;
SwStroke* stroke = nullptr; SwStroke* stroke = nullptr;
SwFill* fill = nullptr; SwFill* fill = nullptr;
SwRleData* rle = nullptr; SwRle* rle = nullptr;
SwRleData* strokeRle = nullptr; SwRle* strokeRle = nullptr;
SwBBox bbox; //Keep it boundary without stroke region. Using for optimal filling. SwBBox bbox; //Keep it boundary without stroke region. Using for optimal filling.
bool fastTrack = false; //Fast Track: axis-aligned rectangle without any clips? bool fastTrack = false; //Fast Track: axis-aligned rectangle without any clips?
@ -217,7 +217,7 @@ struct SwShape
struct SwImage struct SwImage
{ {
SwOutline* outline = nullptr; SwOutline* outline = nullptr;
SwRleData* rle = nullptr; SwRle* rle = nullptr;
union { union {
pixel_t* data; //system based data pointer pixel_t* data; //system based data pointer
uint32_t* buf32; //for explicit 32bits channels uint32_t* buf32; //for explicit 32bits channels
@ -538,13 +538,13 @@ 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.
SwRleData* rleRender(SwRleData* rle, const SwOutline* outline, const SwBBox& renderRegion, bool antiAlias); SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegion, bool antiAlias);
SwRleData* rleRender(const SwBBox* bbox); SwRle* rleRender(const SwBBox* bbox);
void rleFree(SwRleData* rle); void rleFree(SwRle* rle);
void rleReset(SwRleData* rle); void rleReset(SwRle* rle);
void rleMerge(SwRleData* rle, SwRleData* clip1, SwRleData* clip2); void rleMerge(SwRle* rle, SwRle* clip1, SwRle* clip2);
void rleClipPath(SwRleData* rle, const SwRleData* clip); void rleClipPath(SwRle* rle, const SwRle* clip);
void rleClipRect(SwRleData* rle, const SwBBox* clip); void rleClipRect(SwRle* rle, const SwBBox* clip);
SwMpool* mpoolInit(uint32_t threads); SwMpool* mpoolInit(uint32_t threads);
bool mpoolTerm(SwMpool* mpool); bool mpoolTerm(SwMpool* mpool);

View file

@ -478,7 +478,7 @@ static bool _rasterRect(SwSurface* surface, const SwBBox& region, uint8_t r, uin
/* Rle */ /* Rle */
/************************************************************************/ /************************************************************************/
static bool _rasterCompositeMaskedRle(SwSurface* surface, SwRleData* rle, SwMask maskOp, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterCompositeMaskedRle(SwSurface* surface, SwRle* rle, SwMask maskOp, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
auto span = rle->spans; auto span = rle->spans;
auto cbuffer = surface->compositor->image.buf8; auto cbuffer = surface->compositor->image.buf8;
@ -498,7 +498,7 @@ static bool _rasterCompositeMaskedRle(SwSurface* surface, SwRleData* rle, SwMask
} }
static bool _rasterDirectMaskedRle(SwSurface* surface, SwRleData* rle, SwMask maskOp, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterDirectMaskedRle(SwSurface* surface, SwRle* rle, SwMask maskOp, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
auto span = rle->spans; auto span = rle->spans;
auto cbuffer = surface->compositor->image.buf8; auto cbuffer = surface->compositor->image.buf8;
@ -519,7 +519,7 @@ static bool _rasterDirectMaskedRle(SwSurface* surface, SwRleData* rle, SwMask ma
} }
static bool _rasterMaskedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterMaskedRle(SwSurface* surface, SwRle* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
TVGLOG("SW_ENGINE", "Masked(%d) Rle", (int)surface->compositor->method); TVGLOG("SW_ENGINE", "Masked(%d) Rle", (int)surface->compositor->method);
@ -533,7 +533,7 @@ static bool _rasterMaskedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint
} }
static bool _rasterMattedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterMattedRle(SwSurface* surface, SwRle* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
TVGLOG("SW_ENGINE", "Matted(%d) Rle", (int)surface->compositor->method); TVGLOG("SW_ENGINE", "Matted(%d) Rle", (int)surface->compositor->method);
@ -576,7 +576,7 @@ static bool _rasterMattedRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint
} }
static bool _rasterBlendingRle(SwSurface* surface, const SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterBlendingRle(SwSurface* surface, const SwRle* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
if (surface->channelSize != sizeof(uint32_t)) return false; if (surface->channelSize != sizeof(uint32_t)) return false;
@ -601,7 +601,7 @@ static bool _rasterBlendingRle(SwSurface* surface, const SwRleData* rle, uint8_t
} }
static bool _rasterTranslucentRle(SwSurface* surface, const SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterTranslucentRle(SwSurface* surface, const SwRle* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
#if defined(THORVG_AVX_VECTOR_SUPPORT) #if defined(THORVG_AVX_VECTOR_SUPPORT)
return avxRasterTranslucentRle(surface, rle, r, g, b, a); return avxRasterTranslucentRle(surface, rle, r, g, b, a);
@ -613,7 +613,7 @@ static bool _rasterTranslucentRle(SwSurface* surface, const SwRleData* rle, uint
} }
static bool _rasterSolidRle(SwSurface* surface, const SwRleData* rle, uint8_t r, uint8_t g, uint8_t b) static bool _rasterSolidRle(SwSurface* surface, const SwRle* rle, uint8_t r, uint8_t g, uint8_t b)
{ {
auto span = rle->spans; auto span = rle->spans;
@ -650,7 +650,7 @@ static bool _rasterSolidRle(SwSurface* surface, const SwRleData* rle, uint8_t r,
} }
static bool _rasterRle(SwSurface* surface, SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool _rasterRle(SwSurface* surface, SwRle* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
if (!rle) return false; if (!rle) return false;
@ -1609,7 +1609,7 @@ static bool _rasterRadialGradientRect(SwSurface* surface, const SwBBox& region,
/************************************************************************/ /************************************************************************/
template<typename fillMethod> template<typename fillMethod>
static bool _rasterCompositeGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill, SwMask maskOp) static bool _rasterCompositeGradientMaskedRle(SwSurface* surface, const SwRle* rle, const SwFill* fill, SwMask maskOp)
{ {
auto span = rle->spans; auto span = rle->spans;
auto cstride = surface->compositor->image.stride; auto cstride = surface->compositor->image.stride;
@ -1624,7 +1624,7 @@ static bool _rasterCompositeGradientMaskedRle(SwSurface* surface, const SwRleDat
template<typename fillMethod> template<typename fillMethod>
static bool _rasterDirectGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill, SwMask maskOp) static bool _rasterDirectGradientMaskedRle(SwSurface* surface, const SwRle* rle, const SwFill* fill, SwMask maskOp)
{ {
auto span = rle->spans; auto span = rle->spans;
auto cstride = surface->compositor->image.stride; auto cstride = surface->compositor->image.stride;
@ -1641,7 +1641,7 @@ static bool _rasterDirectGradientMaskedRle(SwSurface* surface, const SwRleData*
template<typename fillMethod> template<typename fillMethod>
static bool _rasterGradientMaskedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterGradientMaskedRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
auto method = surface->compositor->method; auto method = surface->compositor->method;
@ -1656,7 +1656,7 @@ static bool _rasterGradientMaskedRle(SwSurface* surface, const SwRleData* rle, c
template<typename fillMethod> template<typename fillMethod>
static bool _rasterGradientMattedRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterGradientMattedRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
TVGLOG("SW_ENGINE", "Matted(%d) Rle Linear Gradient", (int)surface->compositor->method); TVGLOG("SW_ENGINE", "Matted(%d) Rle Linear Gradient", (int)surface->compositor->method);
@ -1675,7 +1675,7 @@ static bool _rasterGradientMattedRle(SwSurface* surface, const SwRleData* rle, c
template<typename fillMethod> template<typename fillMethod>
static bool _rasterBlendingGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterBlendingGradientRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
auto span = rle->spans; auto span = rle->spans;
@ -1688,7 +1688,7 @@ static bool _rasterBlendingGradientRle(SwSurface* surface, const SwRleData* rle,
template<typename fillMethod> template<typename fillMethod>
static bool _rasterTranslucentGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterTranslucentGradientRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
auto span = rle->spans; auto span = rle->spans;
@ -1711,7 +1711,7 @@ static bool _rasterTranslucentGradientRle(SwSurface* surface, const SwRleData* r
template<typename fillMethod> template<typename fillMethod>
static bool _rasterSolidGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterSolidGradientRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
auto span = rle->spans; auto span = rle->spans;
@ -1735,7 +1735,7 @@ static bool _rasterSolidGradientRle(SwSurface* surface, const SwRleData* rle, co
} }
static bool _rasterLinearGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterLinearGradientRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
if (!rle) return false; if (!rle) return false;
@ -1752,7 +1752,7 @@ static bool _rasterLinearGradientRle(SwSurface* surface, const SwRleData* rle, c
} }
static bool _rasterRadialGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill) static bool _rasterRadialGradientRle(SwSurface* surface, const SwRle* rle, const SwFill* fill)
{ {
if (!rle) return false; if (!rle) return false;

View file

@ -60,7 +60,7 @@ static void inline cRasterPixels(PIXEL_T* dst, PIXEL_T val, uint32_t offset, int
} }
static bool inline cRasterTranslucentRle(SwSurface* surface, const SwRleData* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a) static bool inline cRasterTranslucentRle(SwSurface* surface, const SwRle* rle, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
auto span = rle->spans; auto span = rle->spans;

View file

@ -65,8 +65,8 @@ struct SwTask : Task
} }
virtual void dispose() = 0; virtual void dispose() = 0;
virtual bool clip(SwRleData* target) = 0; virtual bool clip(SwRle* target) = 0;
virtual SwRleData* rle() = 0; virtual SwRle* rle() = 0;
virtual ~SwTask() virtual ~SwTask()
{ {
@ -105,7 +105,7 @@ struct SwShapeTask : SwTask
} }
bool clip(SwRleData* target) override bool clip(SwRle* target) override
{ {
if (shape.fastTrack) rleClipRect(target, &bbox); if (shape.fastTrack) rleClipRect(target, &bbox);
else if (shape.rle) rleClipPath(target, shape.rle); else if (shape.rle) rleClipPath(target, shape.rle);
@ -114,7 +114,7 @@ struct SwShapeTask : SwTask
return true; return true;
} }
SwRleData* rle() override SwRle* rle() override
{ {
if (!shape.rle && shape.fastTrack) { if (!shape.rle && shape.fastTrack) {
shape.rle = rleRender(&shape.bbox); shape.rle = rleRender(&shape.bbox);
@ -206,9 +206,9 @@ struct SwShapeTask : SwTask
struct SwSceneTask : SwTask struct SwSceneTask : SwTask
{ {
Array<RenderData> scene; //list of paints render data (SwTask) Array<RenderData> scene; //list of paints render data (SwTask)
SwRleData* sceneRle = nullptr; SwRle* sceneRle = nullptr;
bool clip(SwRleData* target) override bool clip(SwRle* target) override
{ {
//Only one shape //Only one shape
if (scene.count == 1) { if (scene.count == 1) {
@ -222,7 +222,7 @@ struct SwSceneTask : SwTask
return true; return true;
} }
SwRleData* rle() override SwRle* rle() override
{ {
return sceneRle; return sceneRle;
} }
@ -230,7 +230,7 @@ struct SwSceneTask : SwTask
void run(unsigned tid) override void run(unsigned tid) override
{ {
//TODO: Skip the run if the scene hasn't changed. //TODO: Skip the run if the scene hasn't changed.
if (!sceneRle) sceneRle = static_cast<SwRleData*>(calloc(1, sizeof(SwRleData))); if (!sceneRle) sceneRle = static_cast<SwRle*>(calloc(1, sizeof(SwRle)));
else rleReset(sceneRle); else rleReset(sceneRle);
//Merge shapes if it has more than one shapes //Merge shapes if it has more than one shapes
@ -262,13 +262,13 @@ struct SwImageTask : SwTask
Surface* source; //Image source Surface* source; //Image source
const RenderMesh* mesh = nullptr; //Should be valid ptr in action const RenderMesh* mesh = nullptr; //Should be valid ptr in action
bool clip(SwRleData* target) override bool clip(SwRle* target) override
{ {
TVGERR("SW_ENGINE", "Image is used as ClipPath?"); TVGERR("SW_ENGINE", "Image is used as ClipPath?");
return true; return true;
} }
SwRleData* rle() override SwRle* rle() override
{ {
TVGERR("SW_ENGINE", "Image is used as Scene ClipPath?"); TVGERR("SW_ENGINE", "Image is used as Scene ClipPath?");
return nullptr; return nullptr;

View file

@ -217,7 +217,7 @@ struct Cell
struct RleWorker struct RleWorker
{ {
SwRleData* rle; SwRle* rle;
SwPoint cellPos; SwPoint cellPos;
SwPoint cellMin; SwPoint cellMin;
@ -731,7 +731,7 @@ static int _genRle(RleWorker& rw)
} }
static SwSpan* _intersectSpansRegion(const SwRleData *clip, const SwRleData *target, SwSpan *outSpans, uint32_t outSpansCnt) static SwSpan* _intersectSpansRegion(const SwRle *clip, const SwRle *target, SwSpan *outSpans, uint32_t outSpansCnt)
{ {
auto out = outSpans; auto out = outSpans;
auto spans = target->spans; auto spans = target->spans;
@ -783,7 +783,7 @@ static SwSpan* _intersectSpansRegion(const SwRleData *clip, const SwRleData *tar
} }
static SwSpan* _intersectSpansRect(const SwBBox *bbox, const SwRleData *targetRle, SwSpan *outSpans, uint32_t outSpansCnt) static SwSpan* _intersectSpansRect(const SwBBox *bbox, const SwRle *targetRle, SwSpan *outSpans, uint32_t outSpansCnt)
{ {
auto out = outSpans; auto out = outSpans;
auto spans = targetRle->spans; auto spans = targetRle->spans;
@ -822,7 +822,7 @@ static SwSpan* _intersectSpansRect(const SwBBox *bbox, const SwRleData *targetRl
} }
static SwSpan* _mergeSpansRegion(const SwRleData *clip1, const SwRleData *clip2, SwSpan *outSpans) static SwSpan* _mergeSpansRegion(const SwRle *clip1, const SwRle *clip2, SwSpan *outSpans)
{ {
auto out = outSpans; auto out = outSpans;
auto spans1 = clip1->spans; auto spans1 = clip1->spans;
@ -862,7 +862,7 @@ static SwSpan* _mergeSpansRegion(const SwRleData *clip1, const SwRleData *clip2,
} }
void _replaceClipSpan(SwRleData *rle, SwSpan* clippedSpans, uint32_t size) void _replaceClipSpan(SwRle *rle, SwSpan* clippedSpans, uint32_t size)
{ {
free(rle->spans); free(rle->spans);
rle->spans = clippedSpans; rle->spans = clippedSpans;
@ -874,7 +874,7 @@ void _replaceClipSpan(SwRleData *rle, SwSpan* clippedSpans, uint32_t size)
/* External Class Implementation */ /* External Class Implementation */
/************************************************************************/ /************************************************************************/
SwRleData* rleRender(SwRleData* rle, const SwOutline* outline, const SwBBox& renderRegion, bool antiAlias) SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegion, bool antiAlias)
{ {
constexpr auto RENDER_POOL_SIZE = 16384L; constexpr auto RENDER_POOL_SIZE = 16384L;
constexpr auto BAND_SIZE = 40; constexpr auto BAND_SIZE = 40;
@ -902,7 +902,7 @@ SwRleData* rleRender(SwRleData* rle, const SwOutline* outline, const SwBBox& ren
rw.bandShoot = 0; rw.bandShoot = 0;
rw.antiAlias = antiAlias; rw.antiAlias = antiAlias;
if (!rle) rw.rle = reinterpret_cast<SwRleData*>(calloc(1, sizeof(SwRleData))); if (!rle) rw.rle = reinterpret_cast<SwRle*>(calloc(1, sizeof(SwRle)));
else rw.rle = rle; else rw.rle = rle;
//Generate RLE //Generate RLE
@ -993,12 +993,12 @@ error:
} }
SwRleData* rleRender(const SwBBox* bbox) SwRle* rleRender(const SwBBox* bbox)
{ {
auto width = static_cast<uint16_t>(bbox->max.x - bbox->min.x); auto width = static_cast<uint16_t>(bbox->max.x - bbox->min.x);
auto height = static_cast<uint16_t>(bbox->max.y - bbox->min.y); auto height = static_cast<uint16_t>(bbox->max.y - bbox->min.y);
auto rle = static_cast<SwRleData*>(malloc(sizeof(SwRleData))); auto rle = static_cast<SwRle*>(malloc(sizeof(SwRle)));
rle->spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * height)); rle->spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * height));
rle->size = height; rle->size = height;
rle->alloc = height; rle->alloc = height;
@ -1015,14 +1015,14 @@ SwRleData* rleRender(const SwBBox* bbox)
} }
void rleReset(SwRleData* rle) void rleReset(SwRle* rle)
{ {
if (!rle) return; if (!rle) return;
rle->size = 0; rle->size = 0;
} }
void rleFree(SwRleData* rle) void rleFree(SwRle* rle)
{ {
if (!rle) return; if (!rle) return;
if (rle->spans) free(rle->spans); if (rle->spans) free(rle->spans);
@ -1030,7 +1030,7 @@ void rleFree(SwRleData* rle)
} }
void rleMerge(SwRleData* rle, SwRleData* clip1, SwRleData* clip2) void rleMerge(SwRle* rle, SwRle* clip1, SwRle* clip2)
{ {
if (!rle || (!clip1 && !clip2)) return; if (!rle || (!clip1 && !clip2)) return;
if (clip1 && clip1->size == 0 && clip2 && clip2->size == 0) return; if (clip1 && clip1->size == 0 && clip2 && clip2->size == 0) return;
@ -1069,7 +1069,7 @@ void rleMerge(SwRleData* rle, SwRleData* clip1, SwRleData* clip2)
} }
void rleClipPath(SwRleData *rle, const SwRleData *clip) void rleClipPath(SwRle *rle, const SwRle *clip)
{ {
if (rle->size == 0 || clip->size == 0) return; if (rle->size == 0 || clip->size == 0) return;
auto spanCnt = rle->size > clip->size ? rle->size : clip->size; auto spanCnt = rle->size > clip->size ? rle->size : clip->size;
@ -1082,7 +1082,7 @@ void rleClipPath(SwRleData *rle, const SwRleData *clip)
} }
void rleClipRect(SwRleData *rle, const SwBBox* clip) void rleClipRect(SwRle *rle, const SwBBox* clip)
{ {
if (rle->size == 0) return; if (rle->size == 0) return;
auto spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * (rle->size))); auto spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * (rle->size)));