Ejemplo n.º 1
0
        // Sweeps one scanline with one style index. The style ID can be 
        // determined by calling style(). 
        //template<class Scanline> 
        public bool sweep_scanline(IScanlineCache sl, int style_idx)
        {
            int scan_y = m_scan_y - 1;
            if (scan_y > m_Rasterizer.max_y()) return false;

            sl.reset_spans();

            int master_alpha = aa_mask;

            if (style_idx < 0)
            {
                style_idx = 0;
            }
            else
            {
                style_idx++;
                master_alpha = m_master_alpha[(int)(m_ast[(int)style_idx] + m_min_style - 1)];
            }

            style_info st = m_styles[m_ast[style_idx]];

            int num_cells = (int)st.num_cells;
            int CellOffset = st.start_cell;
            cell_aa cell = m_cells[CellOffset];

            int cover = 0;
            while (num_cells-- != 0)
            {
                int alpha;
                int x = cell.x;
                int area = cell.area;

                cover += cell.cover;

                cell = m_cells[++CellOffset];

                if (area != 0)
                {
                    alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area,
                                            master_alpha);
                    sl.add_cell(x, alpha);
                    x++;
                }

                if (num_cells != 0 && cell.x > x)
                {
                    alpha = calculate_alpha(cover << (poly_subpixel_shift + 1),
                                            master_alpha);
                    if (alpha != 0)
                    {
                        sl.add_span(x, cell.x - x, alpha);
                    }
                }
            }

            if (sl.num_spans() == 0) return false;
            sl.finalize(scan_y);
            return true;
        }