Exemplo n.º 1
0
        public void Render(RowIterator row, int x, int count, CoverageIterator covers, Color c)
        {
            byte dst = c.A;

            row.Move(x);
            for (int i = 0; i < count; i++)
            {
                int  alpha = covers.Current * c.A;
                uint src   = row[i];
                row[i] = (byte)((((dst - src) * alpha) + (src << 16)) >> 16);

                covers.MoveNext();
            }
        }
Exemplo n.º 2
0
        public void Render(RowIterator row, int x, int count, CoverageIterator covers, Color c)
        {
            row.Move(x + x + x);
            for (int i = 0; i < 3 * count; i += 3)
            {
                int alpha = covers.Current * c.A;
                int b     = row[i + 0];
                int g     = row[i + 1];
                int r     = row[i + 2];
                row[i + 0] = (byte)((((c.B - b) * alpha) + (b << 16)) >> 16);
                row[i + 1] = (byte)((((c.G - g) * alpha) + (g << 16)) >> 16);
                row[i + 2] = (byte)((((c.R - r) * alpha) + (r << 16)) >> 16);

                covers.MoveNext();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Renders the specified scanline in the specified color into the
        /// rendering buffer.
        /// </summary>
        /// <param name="scanline">The scanline to render.</param>
        /// <param name="color">The color to render the scanline.</param>
        public void Render(Scanline scanline, Color color)
        {
            if (scanline.Y < 0 || scanline.Y >= m_rbuf.Height)
            {
                return;
            }

            int         base_x = scanline.BaseX;
            int         y      = scanline.Y;
            RowIterator row    = m_rbuf.Row(y);

            Scanline.Iterator span = new Scanline.Iterator(scanline);
            for (int num_spans = scanline.SpanCount; num_spans > 0; num_spans--)
            {
                int x = span.Next() + base_x;
                CoverageIterator covers = span.Covers();
                int num_pix             = span.PixelCount();
                if (x < 0)
                {
                    num_pix += x;
                    if (num_pix <= 0)
                    {
                        continue;
                    }

                    covers -= x;
                    x       = 0;
                }

                if (x + num_pix >= m_rbuf.Width)
                {
                    num_pix = m_rbuf.Width - x;
                    if (num_pix <= 0)
                    {
                        continue;
                    }
                }

                m_span.Render(row, x, num_pix, covers, color);
            }
        }
Exemplo n.º 4
0
        public void Render(RowIterator row, int x, int count, CoverageIterator covers, Color c)
        {
            row.Move(x << 1);
            for (int i = 0; i < count << 1; i += 2)
            {
                ushort rgb   = (ushort)(row[i + 0] | row[i + 1]);
                int    alpha = covers.Current * c.A;

                int r = (rgb >> 7) & 0xF8;
                int g = (rgb >> 2) & 0xF8;
                int b = (rgb << 3) & 0xF8;

                int v =
                    (((((c.R - r) * alpha) + (r << 16)) >> 9) & 0x7C00) |
                    (((((c.G - g) * alpha) + (g << 16)) >> 14) & 0x3E0) |
                    ((((c.B - b) * alpha) + (b << 16)) >> 19);

                row[i + 0] = (byte)(v >> 8);
                row[i + 1] = (byte)(v & 0xFF);

                covers.MoveNext();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the Iterator class using the
 /// specified scanline.
 /// </summary>
 /// <param name="scanline">The scanline.</param>
 public Iterator(Scanline scanline)
 {
     m_covers        = new CoverageIterator(scanline.m_covers);
     m_counts        = scanline.m_counts;
     m_start_indeces = scanline.m_start_indeces;
 }