mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-23 16:35:59 +00:00
sw_engine: small optimization with a fast-clipping region access
Now the engine can access intermidate rle sections with a specific y ranges, It doesn't need full iterations.
This commit is contained in:
parent
4e495d3c81
commit
a4849d40b3
1 changed files with 14 additions and 7 deletions
|
@ -881,12 +881,18 @@ bool rleClip(SwRle *rle, const SwRle *clip)
|
||||||
Array<SwSpan> out;
|
Array<SwSpan> out;
|
||||||
out.reserve(std::max(rle->spans.count, clip->spans.count));
|
out.reserve(std::max(rle->spans.count, clip->spans.count));
|
||||||
|
|
||||||
auto spans = rle->data();
|
const SwSpan *end;
|
||||||
auto end = rle->spans.end();
|
auto spans = rle->fetch(clip->spans.first().y, clip->spans.last().y, &end);
|
||||||
auto cspans = clip->data();
|
|
||||||
auto cend = clip->spans.end();
|
|
||||||
|
|
||||||
while(spans < end && cspans < cend) {
|
if (spans >= end) {
|
||||||
|
rle->spans.clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SwSpan *cend;
|
||||||
|
auto cspans = clip->fetch(spans->y, (end - 1)->y, &cend);
|
||||||
|
|
||||||
|
while (spans < end && cspans < cend) {
|
||||||
//align y-coordinates.
|
//align y-coordinates.
|
||||||
if (cspans->y > spans->y) {
|
if (cspans->y > spans->y) {
|
||||||
++spans;
|
++spans;
|
||||||
|
@ -928,9 +934,10 @@ bool rleClip(SwRle *rle, const RenderRegion* clip)
|
||||||
Array<SwSpan> out;
|
Array<SwSpan> out;
|
||||||
out.reserve(rle->spans.count);
|
out.reserve(rle->spans.count);
|
||||||
auto data = out.data;
|
auto data = out.data;
|
||||||
|
const SwSpan* end;
|
||||||
uint16_t x, len;
|
uint16_t x, len;
|
||||||
|
|
||||||
ARRAY_FOREACH(p, rle->spans) {
|
for (auto p = rle->fetch(*clip, &end); p < end; ++p) {
|
||||||
if (p->y >= max.y) break;
|
if (p->y >= max.y) break;
|
||||||
if (p->y < min.y || p->x >= max.x || (p->x + p->len) <= min.x) continue;
|
if (p->y < min.y || p->x >= max.x || (p->x + p->len) <= min.x) continue;
|
||||||
if (p->x < min.x) {
|
if (p->x < min.x) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue