Beispiel #1
0
        //--------------------------------------------------------------------
        internal bool SweepScanline(GLScanline 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);
                                }
                            }
                        }
                    }
                }

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

                ++m_scan_y;
            }

            scline.CloseLine(m_scan_y);
            ++m_scan_y;
            return true;
        }
Beispiel #2
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
                                //-----------------------------------------------
                                //calculate alpha from coverage value
                                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
                                //-----------------------------------------------
                                //calculate alpha from coverage value
                                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);
        }