public void RenderWithSpan(IImageReaderWriter dest, ScanlineRasterizer sclineRas, Scanline scline, ISpanGenerator spanGenerator) { if (!sclineRas.RewindScanlines()) { return; } //early exit //----------------------------------------------- scline.ResetSpans(sclineRas.MinX, sclineRas.MaxX); spanGenerator.Prepare(); if (dest.Stride / 4 > (tempSpanColors.AllocatedSize)) { //if not enough -> alloc more tempSpanColors.Clear(dest.Stride / 4); } ColorRGBA[] colorArray = tempSpanColors.Array; while (sclineRas.SweepScanline(scline)) { //render single scanline int y = scline.Y; int num_spans = scline.SpanCount; byte[] covers = scline.GetCovers(); for (int i = 1; i <= num_spans; ++i) { ScanlineSpan span = scline.GetSpan(i); int x = span.x; int span_len = span.len; bool firstCoverForAll = false; if (span_len < 0) { span_len = -span_len; firstCoverForAll = true; } //make absolute value //1. generate colors -> store in colorArray spanGenerator.GenerateColors(colorArray, 0, x, y, span_len); //2. blend color in colorArray to destination image dest.BlendColorHSpan(x, y, span_len, colorArray, 0, covers, span.cover_index, firstCoverForAll); } } }
//=====================================================render_scanlines_aa public static void GenerateAndRender(IRasterizer ras, IScanline sl, IPixelFormat ren, SpanAllocator alloc, ISpanGenerator span_gen) { if(ras.RewindScanlines()) { sl.Reset(ras.MinX(), ras.MaxX()); span_gen.Prepare(); while(ras.SweepScanline(sl)) { GenerateAndRenderSingleScanline(sl, ren, alloc, span_gen); } } }
public void RenderWithSpan(IImageReaderWriter dest, ScanlineRasterizer sclineRas, Scanline scline, ISpanGenerator spanGenerator) { if (!sclineRas.RewindScanlines()) { return; } //early exit //----------------------------------------------- scline.ResetSpans(sclineRas.MinX, sclineRas.MaxX); spanGenerator.Prepare(); if (dest.Stride / 4 > (tempSpanColors.AllocatedSize)) { //if not enough -> alloc more tempSpanColors.Clear(dest.Stride / 4); } Color[] colorArray = tempSpanColors.Array; while (sclineRas.SweepScanline(scline)) { //render single scanline int y = scline.Y; int num_spans = scline.SpanCount; byte[] covers = scline.GetCovers(); for (int i = 1; i <= num_spans; ++i) { ScanlineSpan span = scline.GetSpan(i); int x = span.x; int span_len = span.len; bool firstCoverForAll = false; if (span_len < 0) { span_len = -span_len; firstCoverForAll = true; } //make absolute value //1. generate colors -> store in colorArray spanGenerator.GenerateColors(colorArray, 0, x, y, span_len); //2. blend color in colorArray to destination image dest.BlendColorHSpan(x, y, span_len, colorArray, 0, covers, span.cover_index, firstCoverForAll); } } }