ResetSpans() public abstract method

public abstract ResetSpans ( ) : void
return void
        public void RenderWithColor(IImageReaderWriter dest,
                                    ScanlineRasterizer sclineRas,
                                    Scanline scline,
                                    Color color)
        {
            if (!sclineRas.RewindScanlines())
            {
                return;
            }                                             //early exit
            //-----------------------------------------------
            scline.ResetSpans(sclineRas.MinX, sclineRas.MaxX);
            switch (this.ScanlineRenderMode)
            {
            default:
            {
                while (sclineRas.SweepScanline(scline))
                {
                    //render solid single scanline
                    int    y         = scline.Y;
                    int    num_spans = scline.SpanCount;
                    byte[] covers    = scline.GetCovers();
                    //render each span in the scanline
                    for (int i = 1; i <= num_spans; ++i)
                    {
                        ScanlineSpan span = scline.GetSpan(i);
                        if (span.len > 0)
                        {
                            //positive len
                            dest.BlendSolidHSpan(span.x, y, span.len, color, covers, span.cover_index);
                        }
                        else
                        {
                            //fill the line, same coverage area
                            int x  = span.x;
                            int x2 = (x - span.len - 1);
                            dest.BlendHL(x, y, x2, color, covers[span.cover_index]);
                        }
                    }
                }
            }
            break;

            case Agg.ScanlineRenderMode.SubPixelRendering:
            {
                scSubPixRas.RenderScanline(dest, sclineRas, scline, color);
            }
            break;

            case Agg.ScanlineRenderMode.Custom:
            {
                while (sclineRas.SweepScanline(scline))
                {
                    CustomRenderSingleScanLine(dest, scline, color);
                }
            }
            break;
            }
        }
        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);
                }
            }
        }
        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);
                }
            }
        }
        public void RenderWithColor(IImageReaderWriter dest,
                ScanlineRasterizer sclineRas,
                Scanline scline,
                Color color)
        {
            if (!sclineRas.RewindScanlines()) { return; } //early exit
            //----------------------------------------------- 
            scline.ResetSpans(sclineRas.MinX, sclineRas.MaxX);
            switch (this.ScanlineRenderMode)
            {
                default:
                    {
                        //prev mode  
                        //this mode 
                        while (sclineRas.SweepScanline(scline))
                        {
                            //render solid single scanline
                            int y = scline.Y;
                            int num_spans = scline.SpanCount;
                            byte[] covers = scline.GetCovers();
                            //render each span in the scanline
                            for (int i = 1; i <= num_spans; ++i)
                            {
                                ScanlineSpan span = scline.GetSpan(i);
                                if (span.len > 0)
                                {
                                    //positive len 
                                    dest.BlendSolidHSpan(span.x, y, span.len, color, covers, span.cover_index);
                                }
                                else
                                {
                                    //fill the line, same coverage area
                                    int x = span.x;
                                    int x2 = (x - span.len - 1);
                                    dest.BlendHL(x, y, x2, color, covers[span.cover_index]);
                                }
                            }
                        }
                    }
                    break;
                case Agg.ScanlineRenderMode.SubPixelRendering:
                    {
#if DEBUG
                        int dbugMinScanlineCount = 0;
#endif

                        while (sclineRas.SweepScanline(scline))
                        {
                            SubPixRender(dest, scline, color);
#if DEBUG
                            dbugMinScanlineCount++;
#endif
                        }
                    }
                    break;
                case Agg.ScanlineRenderMode.Custom:
                    {
                        while (sclineRas.SweepScanline(scline))
                        {
                            CustomRenderSingleScanLine(dest, scline, color);
                        }
                    }
                    break;
            }
        }
Esempio n. 5
0
        //--------------------------------------------------------------------
        internal bool SweepScanline(Scanline scline)
        {
            for (;;)
            {
                if (m_scan_y > m_cellAARas.MaxY)
                {
                    return(false);
                }

                scline.ResetSpans();
                //-------------------------
                CellAA[] cells;
                int      offset;
                int      num_cells;
                m_cellAARas.GetCells(m_scan_y, out cells, out offset, out num_cells);
                int cover = 0;
                while (num_cells != 0)
                {
                    unsafe
                    {
                        fixed(CellAA *cur_cell_h = &cells[0])
                        {
                            CellAA *cur_cell_ptr = cur_cell_h + offset;
                            int     x            = cur_cell_ptr->x;
                            int     area         = cur_cell_ptr->area;

                            cover += cur_cell_ptr->cover;
                            //accumulate all cells with the same X
                            while (--num_cells != 0)
                            {
                                offset++;       //move next
                                cur_cell_ptr++; //move next
                                if (cur_cell_ptr->x != x)
                                {
                                    break;
                                }
                                area  += cur_cell_ptr->area;
                                cover += cur_cell_ptr->cover;
                            }

                            if (area != 0)
                            {
                                //-----------------------------------------------
                                //single cell, for antialias look
                                //-----------------------------------------------
                                int alpha = CalculateAlpha((cover << (poly_subpix.SHIFT + 1)) - area);
                                if (alpha != 0)
                                {
                                    scline.AddCell(x, alpha);
                                }

                                x++;
                            }

                            if ((num_cells != 0) && (cur_cell_ptr->x > x))
                            {
                                //-----------------------------------------------
                                //this is long span , continuous color, solid look
                                //-----------------------------------------------
                                int alpha = CalculateAlpha(cover << (poly_subpix.SHIFT + 1));
                                if (alpha != 0)
                                {
                                    scline.AddSpan(x, (cur_cell_ptr->x - x), alpha);
                                }
                            }
                        }
                    }
                }

                if (scline.SpanCount != 0)
                {
                    break;
                }

                ++m_scan_y;
            }

            scline.CloseLine(m_scan_y);
            ++m_scan_y;
            return(true);
        }
Esempio n. 6
0
        //--------------------------------------------------------------------
        internal bool SweepScanline(Scanline scline)
        {
            for (;;)
            {
                if (m_scan_y > m_cellAARas.MaxY)
                {
                    return(false);
                }

                scline.ResetSpans();
                CellAA[] cells;
                int      offset;
                int      num_cells;
                m_cellAARas.GetCells(m_scan_y, out cells, out offset, out num_cells);
                int cover = 0;
                while (num_cells != 0)
                {
                    unsafe
                    {
                        fixed(CellAA *cur_cell_h = &cells[0])
                        {
                            CellAA *cur_cell_ptr = cur_cell_h + offset;
                            int     alpha;
                            int     x    = cur_cell_ptr->x;
                            int     area = cur_cell_ptr->area;

                            cover += cur_cell_ptr->cover;
                            //accumulate all cells with the same X
                            while (--num_cells != 0)
                            {
                                offset++;       //move next
                                cur_cell_ptr++; //move next
                                if (cur_cell_ptr->x != x)
                                {
                                    break;
                                }

                                area  += cur_cell_ptr->area;
                                cover += cur_cell_ptr->cover;
                            }

                            if (area != 0)
                            {
                                alpha = CalculateAlpha((cover << (poly_subpix.SHIFT + 1)) - area);
                                if (alpha != 0)
                                {
                                    scline.AddCell(x, alpha);
                                }
                                x++;
                            }

                            if ((num_cells != 0) && (cur_cell_ptr->x > x))
                            {
                                alpha = CalculateAlpha(cover << (poly_subpix.SHIFT + 1));
                                if (alpha != 0)
                                {
                                    scline.AddSpan(x, (cur_cell_ptr->x - x), alpha);
                                }
                            }
                        }

                        //CellAA cur_cell = cells[offset];
                        //int x = cur_cell.x;
                        //int area = cur_cell.area;
                        //int alpha;

                        //cover += cur_cell.cover;

                        ////accumulate all cells with the same X
                        //while (--num_cells != 0)
                        //{
                        //    offset++;
                        //    cur_cell = cells[offset];
                        //    if (cur_cell.x != x)
                        //    {
                        //        break;
                        //    }

                        //    area += cur_cell.area;
                        //    cover += cur_cell.cover;
                        //}

                        //if (area != 0)
                        //{
                        //    alpha = CalculateAlpha((cover << (poly_subpix.SHIFT + 1)) - area);
                        //    if (alpha != 0)
                        //    {
                        //        scline.AddCell(x, alpha);
                        //    }
                        //    x++;
                        //}

                        //if ((num_cells != 0) && (cur_cell.x > x))
                        //{
                        //    alpha = CalculateAlpha(cover << (poly_subpix.SHIFT + 1));
                        //    if (alpha != 0)
                        //    {
                        //        scline.AddSpan(x, (cur_cell.x - x), alpha);
                        //    }
                        //}
                    }
                }

                if (scline.SpanCount != 0)
                {
                    break;
                }

                ++m_scan_y;
            }

            scline.CloseLine(m_scan_y);
            ++m_scan_y;
            return(true);
        }
        //--------------------------------------------------------------------
        internal bool SweepScanline(Scanline scline)
        {
            for (; ; )
            {
                if (m_scan_y > m_cellAARas.MaxY)
                {
                    return false;
                }

                scline.ResetSpans();
                //-------------------------
                CellAA[] cells;
                int offset;
                int num_cells;
                m_cellAARas.GetCells(m_scan_y, out cells, out offset, out num_cells);
                int cover = 0;
                while (num_cells != 0)
                {
                    unsafe
                    {
                        fixed (CellAA* cur_cell_h = &cells[0])
                        {
                            CellAA* cur_cell_ptr = cur_cell_h + offset;
                            int x = cur_cell_ptr->x;
                            int area = cur_cell_ptr->area;
                            cover += cur_cell_ptr->cover;
                            //accumulate all cells with the same X
                            while (--num_cells != 0)
                            {
                                offset++; //move next
                                cur_cell_ptr++; //move next
                                if (cur_cell_ptr->x != x)
                                {
                                    break;
                                }
                                area += cur_cell_ptr->area;
                                cover += cur_cell_ptr->cover;
                            }

                            if (area != 0)
                            {
                                //-----------------------------------------------
                                //single cell, for antialias look
                                //-----------------------------------------------
                                int alpha = CalculateAlpha((cover << (poly_subpix.SHIFT + 1)) - area);
                                if (alpha != 0)
                                {
                                    scline.AddCell(x, alpha);
                                }

                                x++;
                            }

                            if ((num_cells != 0) && (cur_cell_ptr->x > x))
                            {
                                //-----------------------------------------------
                                //this is long span , continuous color, solid look
                                //-----------------------------------------------
                                int alpha = CalculateAlpha(cover << (poly_subpix.SHIFT + 1));
                                if (alpha != 0)
                                {
                                    scline.AddSpan(x, (cur_cell_ptr->x - x), alpha);
                                }
                            }
                        }
                    }
                }

                if (scline.SpanCount != 0) { break; }

                ++m_scan_y;
            }

            scline.CloseLine(m_scan_y);
            ++m_scan_y;
            return true;
        }