mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
sw_engine: optimize span generation.
there are unnecessary partial spans generated in orthogonal rectangle. we can merge those partial spans to others if they are on the same scanline... Change-Id: I35a437a4f2eec106bd50f46f0390c652e617311d
This commit is contained in:
parent
86300c5fc0
commit
55e215e6ea
3 changed files with 11 additions and 10 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "tvgCommon.h"
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
#include <sys/time.h>
|
||||
static double timeStamp()
|
||||
{
|
||||
|
|
|
@ -189,7 +189,7 @@ void fillFetchRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
|
|||
{
|
||||
if (fill->radial.a < FLT_EPSILON) return;
|
||||
|
||||
//TODO: Rotation???
|
||||
//Rotation
|
||||
auto rx = x + 0.5f - fill->radial.cx;
|
||||
auto ry = y + 0.5f - fill->radial.cy;
|
||||
auto inv2a = fill->radial.inv2a;
|
||||
|
@ -199,13 +199,12 @@ void fillFetchRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
|
|||
auto detDelta = (4 * fill->radial.a * (rxryPlus + 1.0f)) * inv2a;
|
||||
auto detDelta2 = (4 * fill->radial.a * 2.0f) * inv2a;
|
||||
|
||||
for (uint32_t i = 0 ; i < len ; ++i)
|
||||
{
|
||||
for (uint32_t i = 0 ; i < len ; ++i) {
|
||||
*dst = _pixel(fill, sqrt(det));
|
||||
++dst;
|
||||
det += detDelta;
|
||||
detDelta += detDelta2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -213,7 +212,7 @@ void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
|
|||
{
|
||||
if (fill->linear.len < FLT_EPSILON) return;
|
||||
|
||||
//TODO: Rotation???
|
||||
//Rotation
|
||||
auto rx = x + 0.5f;
|
||||
auto ry = y + 0.5f;
|
||||
auto t = (fill->linear.dx * rx + fill->linear.dy * ry + fill->linear.offset) * (GRADIENT_STOP_SIZE - 1);
|
||||
|
|
|
@ -195,7 +195,7 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
|
|||
y = SHRT_MAX;
|
||||
}
|
||||
|
||||
if (coverage) {
|
||||
if (coverage > 0) {
|
||||
auto count = rw.spansCnt;
|
||||
auto span = rw.spans + count - 1;
|
||||
assert(span);
|
||||
|
@ -209,13 +209,15 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
|
|||
if (x + acount >= rw.clip.w) xOver -= (x + acount - rw.clip.w);
|
||||
if (x < 0) xOver += x;
|
||||
|
||||
span->len += (acount + xOver) - 1;
|
||||
//span->len += (acount + xOver) - 1;
|
||||
span->len += (acount + xOver);
|
||||
return;
|
||||
}
|
||||
|
||||
if (count >= MAX_SPANS) {
|
||||
_genSpan(rw.rle, rw.spans, count);
|
||||
rw.spansCnt = 0;
|
||||
rw.ySpan = 0;
|
||||
span = rw.spans;
|
||||
assert(span);
|
||||
} else {
|
||||
|
@ -240,6 +242,7 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
|
|||
span->len = (acount + xOver);
|
||||
span->coverage = coverage;
|
||||
++rw.spansCnt;
|
||||
rw.ySpan = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,6 +252,7 @@ static void _sweep(RleWorker& rw)
|
|||
if (rw.cellsCnt == 0) return;
|
||||
|
||||
rw.spansCnt = 0;
|
||||
rw.ySpan = 0;
|
||||
|
||||
for (int y = 0; y < rw.yCnt; ++y) {
|
||||
auto cover = 0;
|
||||
|
@ -775,6 +779,4 @@ void rleFree(SwRleData* rle)
|
|||
free(rle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* _TVG_SW_RLE_H_ */
|
||||
|
|
Loading…
Add table
Reference in a new issue