Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void _RasterizeSortedEdges(float tx, float ty, float scale, SvgRasterizerCachedPaint cache, SvgFillRule fillRule)
- {
- SvgRasterizerActiveEdge active = null;
- int y, s;
- int e = 0;
- int maxWeight = (255 / SVG_SUBSAMPLES); // weight per vertical scanline
- int xmin, xmax;
- for (y = 0; y < height; y++)
- {
- Array.Clear(scanline, 0, width);
- xmin = width;
- xmax = 0;
- for (s = 0; s < SVG_SUBSAMPLES; ++s)
- {
- // find center of pixel for this scanline
- float scany = (float)(y * SVG_SUBSAMPLES + s) + 0.5f;
- SvgRasterizerActiveEdge step = active;
- // update all active edges;
- // remove all active edges that terminate before the center of this scanline
- while (step!=null)
- {
- SvgRasterizerActiveEdge z = step;
- if (z.ey <= scany)
- {
- step = z.next; // delete from list
- // NSVG__assert(z->valid);
- _FreeActive(z);
- }
- else
- {
- z.x += z.dx; // advance to position for current scanline
- step = step.next; // advance through list
- }
- }
- // resort the list if needed
- for (; ; )
- {
- bool changed = false;
- step = active;
- while (step!=null && step.next!=null)
- {
- if (step.x > step.next.x)
- {
- SvgRasterizerActiveEdge te = step;
- SvgRasterizerActiveEdge q = te.next;
- te.next = q.next;
- q.next = te;
- step = q;
- changed = true;
- }
- step = step.next;
- }
- if (!changed) break;
- }
- // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
- while (e < edges.Count && edges[e].y0 <= scany)
- {
- if (edges[e].y1 > scany)
- {
- SvgRasterizerEdge edge = edges[e];
- SvgRasterizerActiveEdge z = _AddActive(ref edge, scany);
- edges[e] = edge;
- if (z == null) break;
- // find insertion point
- if (active == null)
- {
- active = z;
- }
- else if (z.x < active.x)
- {
- // insert at front
- z.next = active;
- active = z;
- }
- else
- {
- // find thing to insert AFTER
- SvgRasterizerActiveEdge p = active;
- while (p.next!=null && p.next.x < z.x)
- p = p.next;
- // at this point, p->next->x is NOT < z->x
- z.next = p.next;
- p.next = z;
- }
- }
- ++e;
- }
- // now process all active edges in non-zero fashion
- if (active != null)
- _FillActiveEdges(scanline, width, active, maxWeight, ref xmin, ref xmax, fillRule);
- }
- // Blit
- if (xmin < 0) xmin = 0;
- if (xmax > width - 1) xmax = width - 1;
- if (xmin <= xmax)
- {
- _ScanlineSolid(null,0, readCallback, writeCallback, xmax - xmin + 1, scanline,xmin, xmin, y, tx, ty, scale, cache);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement