Example #1
0
        public static void CreateContext(RasterBuffer renderingBuffer)
        {
            // set the rendering buffer and all the GL default states (this is also where you can new anything you need)
            s_RenderingBuffer = renderingBuffer;
            s_Rasterizer.SetVectorClipBox(M.Zero <T>(), M.Zero <T>(), M.New <T>(s_RenderingBuffer.Width), M.New <T>(s_RenderingBuffer.Height));
            s_PixelFormt = new FormatRGBA(s_RenderingBuffer, new BlenderBGRA());
            s_ClippingPixelFormatProxy = new FormatClippingProxy(s_PixelFormt);
            //s_ClippingPixelFormatProxy = s_PixelFormt;

            m_CurAccumulatedMatrix = MatrixFactory <T> .NewIdentity(VectorDimension.Three); // new Matrix4X4();

            m_ModelviewMatrix = MatrixFactory <T> .NewIdentity(VectorDimension.Three);      // new Matrix4X4();

            m_ProjectionMatrix = MatrixFactory <T> .NewIdentity(VectorDimension.Three);     //new Matrix4X4();

            m_pVertexCache = new VertexCachItem[m_MaxVertexCacheItems];
            for (int i = 0; i < m_MaxVertexCacheItems; i++)
            {
                m_pVertexCache[i] = new VertexCachItem();
            }

            m_LastSetColor  = new RGBA_Doubles(1, 1, 1, 1);
            m_LastSetNormal = MatrixFactory <T> .CreateZeroVector(VectorDimension.Three);          // new Vector3D();

            m_LastSetTextureCoordinate = MatrixFactory <T> .CreateZeroVector(VectorDimension.Two); // new Vector2D();
        }
Example #2
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 ///<param name="mask"></param>
 public AlphaMaskAdaptor(IPixelFormat pixf, IAlphaMask mask)
     : base(pixf)
 {
     PixelFormat = pixf;
     _alphaMask = mask;
     _span = new ArrayPOD<byte>(255);
 }
Example #3
0
 public AlphaMaskAdaptor(IPixelFormat pixf, IAlphaMask mask)
     : base(pixf)
 {
     m_pixf = pixf;
     m_mask = mask;
     m_span = new ArrayPOD <byte>(255);
 }
Example #4
0
        //========================================================render_all_paths
        public static void RenderSolidAllPaths(IPixelFormat pixFormat, 
            IRasterizer ras, 
            IScanline sl,
            IVertexSource vs, 
            RGBA_Bytes[] color_storage,
            uint[] path_id,
            uint num_paths)
        {
            for(uint i = 0; i < num_paths; i++)
            {
                ras.Reset();
                
#if use_timers
                AddPathTimer.Start();
#endif
                ras.AddPath(vs, path_id[i]);
#if use_timers
                AddPathTimer.Stop();
#endif

                
#if use_timers
                RenderSLTimer.Start();
#endif
                RenderSolid(pixFormat, ras, sl, color_storage[i]);
#if use_timers
                RenderSLTimer.Stop();
#endif
            }
        }
        //---------------------------------------------------------------------
        //typedef renderer_outline_image<BaseRenderer, ImagePattern> self_type;

        //---------------------------------------------------------------------
        public renderer_outline_image(IPixelFormat ren, line_image_pattern patt)
        {
            m_ren      = ren;
            m_pattern  = patt;
            m_start    = (0);
            m_scale_x  = (1.0);
            m_clip_box = new rect_i(0, 0, 0, 0);
            m_clipping = (false);
        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="PixelFormat"></param>
        /// <param name="Rasterizer"></param>
        /// <param name="Scanline"></param>
        public Renderer(IPixelFormat PixelFormat, AntiAliasedScanlineRasterizer Rasterizer, IScanline Scanline)
        {
        	m_PixelFormat = PixelFormat;
        	m_Rasterizer = Rasterizer;
        	m_Scanline = Scanline;

            TextPath = new GsvText();
            StrockedText = new StrokeConverter(TextPath);
            m_AffineTransformStack.Push(Affine.NewIdentity());
        }
 public RasterBufferAccessorClip(IPixelFormat pixf, RGBA_Doubles bk)
 {
     m_pixf = pixf;
     m_PixelWidthInBytes = m_pixf.PixelWidthInBytes;
     //pixfmt_alpha_blend_bgra32.make_pix(m_bk_buf, bk);
     unsafe
     {
         m_pBackBufferColor = (byte*)Marshal.AllocHGlobal(16);
     }
 }
Example #8
0
 public RasterBufferAccessorClip(IPixelFormat pixf, RGBA_Doubles bk)
 {
     m_pixf = pixf;
     m_PixelWidthInBytes = m_pixf.PixelWidthInBytes;
     //pixfmt_alpha_blend_bgra32.make_pix(m_bk_buf, bk);
     unsafe
     {
         m_pBackBufferColor = (byte *)Marshal.AllocHGlobal(16);
     }
 }
Example #9
0
        public void Render(IRasterizer rasterizer, IScanline scanline, IPixelFormat rendererBase)
        {
            uint i;

            for (i = 0; i < num_paths(); i++)
            {
                rasterizer.reset();
                rasterizer.add_path(this, i);
                Renderer.RenderSolid(rendererBase, rasterizer, scanline, color(i).Get_rgba8());
            }
        }
Example #10
0
        public PixMap(PixelFormat format, uint width, uint height)
            : this()
        {
            Guard.GreaterThan(width, 0u);
            Guard.GreaterThan(height, 0u);
            _pixelFormat = _injector.Resolve<IPixelFormatFactory>().CreatePixelFormat(format, width, height, out imageBytes);
            _buffer = _pixelFormat.GetRenderingBuffer();

            _renderer = this._injector.Resolve<RendererBase>();
            _scanlineCache = this._injector.Resolve<IScanlineCache>();
            _rasterizer = this._injector.Resolve<IRasterizer>();
        }
Example #11
0
        public PixMap(PixelFormat format, uint width, uint height)
            : this()
        {
            Guard.GreaterThan(width, 0u);
            Guard.GreaterThan(height, 0u);
            _pixelFormat = _injector.Resolve <IPixelFormatFactory>().CreatePixelFormat(format, width, height, out imageBytes);
            _buffer      = _pixelFormat.GetRenderingBuffer();

            _renderer      = this._injector.Resolve <RendererBase>();
            _scanlineCache = this._injector.Resolve <IScanlineCache>();
            _rasterizer    = this._injector.Resolve <IRasterizer>();
        }
Example #12
0
 //=====================================================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);
         }
     }
 }
Example #13
0
        //================================================render_scanline_aa_solid
        private static void RenderSolidSingleScanLine(IPixelFormat pixFormat, IScanline scanLine, RGBA_Bytes color)
        {
#if use_timers
            render_scanline_aa_solidTimer.Start();
#endif
            int y = scanLine.y();
            uint num_spans = scanLine.NumberOfSpans;
            ScanlineSpan scanlineSpan = scanLine.Begin;

            byte[] ManagedCoversArray = scanLine.GetCovers();
            unsafe
            {
                fixed (byte* pCovers = ManagedCoversArray)
                {
                    for (; ; )
                    {
                        int x = scanlineSpan.x;
                        if (scanlineSpan.len > 0)
                        {
#if use_timers
                            render_scanline_aa_solid_blend_solid_hspan.Start();
#endif
                            pixFormat.BlendSolidHorizontalSpan(x, y, (uint)scanlineSpan.len, color, &pCovers[scanlineSpan.cover_index]);
#if use_timers
                            render_scanline_aa_solid_blend_solid_hspan.Stop();
#endif
                        }
                        else
                        {
#if use_timers
                            render_scanline_aa_solid_blend_hline.Start();
#endif
                            pixFormat.BlendHorizontalLine(x, y, (x - (int)scanlineSpan.len - 1), color, pCovers[scanlineSpan.cover_index]);
#if use_timers
                            render_scanline_aa_solid_blend_hline.Stop();
#endif
                        }
                        if (--num_spans == 0) break;
                        scanlineSpan = scanLine.GetNextScanlineSpan();
                    }
                }
            }
#if use_timers
            render_scanline_aa_solidTimer.Stop();
#endif
        }
Example #14
0
        ///<summary>
        ///</summary>
        ///<param name="pixf"></param>
        ///<param name="x1"></param>
        ///<param name="y1"></param>
        ///<param name="x2"></param>
        ///<param name="y2"></param>
        ///<returns></returns>
        public bool Attach(IPixelFormat pixf, int x1, int y1, int x2, int y2)
        {
            RectI r = new RectI(x1, y1, x2, y2);

            if (r.Clip(new RectI(0, 0, (int)pixf.Width - 1, (int)pixf.Height - 1)))
            {
                int stride = pixf.Stride;
                unsafe
                {
                    _rasterBuffer.Attach(pixf.PixelPointer(r.x1, stride < 0 ? r.y2 : r.y1),
                                         (uint)(r.x2 - r.x1) + 1,
                                         (uint)(r.y2 - r.y1) + 1,
                                         stride, 3);
                }
                return(true);
            }
            return(false);
        }
Example #15
0
        //========================================================render_scanlines
        public static void RenderSolid(IPixelFormat pixFormat, IRasterizer rasterizer, IScanline scanLine, RGBA_Bytes color)
        {
            if(rasterizer.RewindScanlines())
            {
                scanLine.Reset(rasterizer.MinX(), rasterizer.MaxX());
#if use_timers
                PrepareTimer.Start();
#endif
                //renderer.Prepare();
#if use_timers
                PrepareTimer.Stop();
#endif
                while(rasterizer.SweepScanline(scanLine))
                {
                    Renderer.RenderSolidSingleScanLine(pixFormat, scanLine, color);
                }
            }
        }
Example #16
0
        //======================================================render_scanline_aa
        private static void GenerateAndRenderSingleScanline(IScanline sl, IPixelFormat ren,
                                SpanAllocator alloc, ISpanGenerator span_gen)
        {
            int y = sl.y();
            uint num_spans = sl.NumberOfSpans;
            ScanlineSpan scanlineSpan = sl.Begin;

            byte[] ManagedCoversArray = sl.GetCovers();
            unsafe
            {
                fixed (byte* pCovers = ManagedCoversArray)
                {
                    for (; ; )
                    {
                        int x = scanlineSpan.x;
                        int len = scanlineSpan.len;
                        if(len < 0) len = -len;

                        if(tempSpanColors.Capacity() < len)
                        {
                            tempSpanColors.Allocate((uint)(len));
                        }

                        fixed (RGBA_Bytes* pColors = tempSpanColors.Array)
                        {
                            span_gen.Generate(pColors, x, y, (uint)len);
#if use_timers
                            blend_color_hspan.Start();
#endif
                            ren.BlendHorizontalColorSpan(x, y, (uint)len, pColors, (scanlineSpan.len < 0) ? null : &pCovers[scanlineSpan.cover_index], pCovers[scanlineSpan.cover_index]);
#if use_timers
                            blend_color_hspan.Stop();
#endif
                        }

                        if (--num_spans == 0) break;
                        scanlineSpan = sl.GetNextScanlineSpan();
                    }
                }
            }
        }
 public void attach(IPixelFormat ren)
 {
     m_ren = ren;
 }
Example #18
0
 public override void Attach(IPixelFormat ren)
 {
     base.Attach(ren);
     m_clip_box = new RectI(0, 0, (int)ren.Width - 1, (int)ren.Height - 1);
 }
        //---------------------------------------------------------------------
        public line_interpolator_image(IPixelFormat ren, line_parameters lp,
                                       int sx, int sy, int ex, int ey,
                                       int pattern_start,
                                       double scale_x)
        {
            m_lp = (lp);
            m_li = new dda2_line_interpolator(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) :
                                              line_dbl_hr(lp.y2 - lp.y1),
                                              lp.vertical ? abs(lp.y2 - lp.y1) :
                                              abs(lp.x2 - lp.x1) + 1);
            m_di = new distance_interpolator4(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x,
                                              lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask);
            m_ren   = (ren);
            m_x     = (lp.x1 >> line_subpixel_shift);
            m_y     = (lp.y1 >> line_subpixel_shift);
            m_old_x = (m_x);
            m_old_y = (m_y);
            m_count = ((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) :
                        abs((lp.x2 >> line_subpixel_shift) - m_x)));
            m_width = (ren.subpixel_width());
            //m_max_extent(m_width >> (line_subpixel_shift - 2));
            m_max_extent = ((m_width + LineAABasics.line_subpixel_scale) >> line_subpixel_shift);
            m_start      = (pattern_start + (m_max_extent + 2) * ren.pattern_width());
            m_step       = (0);

            dda2_line_interpolator li = new dda2_line_interpolator(0, lp.vertical ?
                                                                   (lp.dy << LineAABasics.line_subpixel_shift) :
                                                                   (lp.dx << LineAABasics.line_subpixel_shift),
                                                                   lp.len);

            uint i;
            int  stop = m_width + LineAABasics.line_subpixel_scale * 2;

            for (i = 0; i < max_half_width; ++i)
            {
                m_dist_pos[i] = li.y();
                if (m_dist_pos[i] >= stop)
                {
                    break;
                }
                ++li;
            }
            m_dist_pos[i] = 0x7FFF0000;

            int dist1_start;
            int dist2_start;
            int npix = 1;

            if (lp.vertical)
            {
                do
                {
                    --m_li;
                    m_y -= lp.inc;
                    m_x  = (m_lp.x1 + m_li.y()) >> line_subpixel_shift;

                    if (lp.inc > 0)
                    {
                        m_di.dec_y(m_x - m_old_x);
                    }
                    else
                    {
                        m_di.inc_y(m_x - m_old_x);
                    }

                    m_old_x = m_x;

                    dist1_start = dist2_start = m_di.dist_start();

                    int dx = 0;
                    if (dist1_start < 0)
                    {
                        ++npix;
                    }
                    do
                    {
                        dist1_start += m_di.dy_start();
                        dist2_start -= m_di.dy_start();
                        if (dist1_start < 0)
                        {
                            ++npix;
                        }
                        if (dist2_start < 0)
                        {
                            ++npix;
                        }
                        ++dx;
                    }while(m_dist_pos[dx] <= m_width);
                    if (npix == 0)
                    {
                        break;
                    }

                    npix = 0;
                }while(--m_step >= -m_max_extent);
            }
            else
            {
                do
                {
                    --m_li;

                    m_x -= lp.inc;
                    m_y  = (m_lp.y1 + m_li.y()) >> line_subpixel_shift;

                    if (lp.inc > 0)
                    {
                        m_di.dec_x(m_y - m_old_y);
                    }
                    else
                    {
                        m_di.inc_x(m_y - m_old_y);
                    }

                    m_old_y = m_y;

                    dist1_start = dist2_start = m_di.dist_start();

                    int dy = 0;
                    if (dist1_start < 0)
                    {
                        ++npix;
                    }
                    do
                    {
                        dist1_start -= m_di.dx_start();
                        dist2_start += m_di.dx_start();
                        if (dist1_start < 0)
                        {
                            ++npix;
                        }
                        if (dist2_start < 0)
                        {
                            ++npix;
                        }
                        ++dy;
                    }while(m_dist_pos[dy] <= m_width);
                    if (npix == 0)
                    {
                        break;
                    }

                    npix = 0;
                }while(--m_step >= -m_max_extent);
            }
            m_li.adjust_forward();
            m_step -= m_max_extent;
        }
 public RendererOpenGL(IPixelFormat PixelFormat, rasterizer_scanline_aa Rasterizer)
     : base(PixelFormat, Rasterizer)
 {
     TextPath = new gsv_text();
     StrockedText = new conv_stroke(TextPath);
 }
Example #21
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 public PixelFormatProxy(IPixelFormat pixf)
 {
     PixelFormat = pixf;
 }
Example #22
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 public void AttachPixelFormat(IPixelFormat pixf)
 {
     PixelFormat = pixf;
 }
Example #23
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 ///<param name="x1"></param>
 ///<param name="y1"></param>
 ///<param name="x2"></param>
 ///<param name="y2"></param>
 ///<returns></returns>
 public bool Attach(IPixelFormat pixf, int x1, int y1, int x2, int y2)
 {
     RectI r = new RectI(x1, y1, x2, y2);
     if (r.Clip(new RectI(0, 0, (int)pixf.Width - 1, (int)pixf.Height - 1)))
     {
         int stride = pixf.Stride;
         unsafe
         {
             _rasterBuffer.Attach(pixf.PixelPointer(r.x1, stride < 0 ? r.y2 : r.y1),
                 (uint)(r.x2 - r.x1) + 1,
                 (uint)(r.y2 - r.y1) + 1,
                 stride, 3);
         }
         return true;
     }
     return false;
 }
        //---------------------------------------------------------------------
        public line_interpolator_image(IPixelFormat ren, line_parameters lp,
								int sx, int sy, int ex, int ey,
								int pattern_start,
								double scale_x)
        {
            m_lp=(lp);
            m_li = new dda2_line_interpolator(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) :
                               line_dbl_hr(lp.y2 - lp.y1),
                 lp.vertical ? abs(lp.y2 - lp.y1) :
                               abs(lp.x2 - lp.x1) + 1);
            m_di = new distance_interpolator4(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x,
                 lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask);
            m_ren=(ren);
            m_x=(lp.x1 >> line_subpixel_shift);
            m_y=(lp.y1 >> line_subpixel_shift);
            m_old_x=(m_x);
            m_old_y=(m_y);
            m_count=((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) :
                                   abs((lp.x2 >> line_subpixel_shift) - m_x)));
            m_width=(ren.subpixel_width());

            //m_max_extent(m_width >> (line_subpixel_shift - 2));
            m_max_extent=((m_width + LineAABasics.line_subpixel_scale) >> line_subpixel_shift);
            m_start=(pattern_start + (m_max_extent + 2) * ren.pattern_width());
            m_step=(0);

            dda2_line_interpolator li = new dda2_line_interpolator(0, lp.vertical ?
                                              (lp.dy << LineAABasics.line_subpixel_shift) :
                                              (lp.dx << LineAABasics.line_subpixel_shift),
                                           lp.len);

            uint i;
            int stop = m_width + LineAABasics.line_subpixel_scale * 2;
            for(i = 0; i < max_half_width; ++i)
            {
                m_dist_pos[i] = li.y();
                if(m_dist_pos[i] >= stop) break;
                ++li;
            }
            m_dist_pos[i] = 0x7FFF0000;

            int dist1_start;
            int dist2_start;
            int npix = 1;

            if(lp.vertical)
            {
                do
                {
                    --m_li;
                    m_y -= lp.inc;
                    m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift;

                    if(lp.inc > 0) m_di.dec_y(m_x - m_old_x);
                    else           m_di.inc_y(m_x - m_old_x);

                    m_old_x = m_x;

                    dist1_start = dist2_start = m_di.dist_start();

                    int dx = 0;
                    if(dist1_start < 0) ++npix;
                    do
                    {
                        dist1_start += m_di.dy_start();
                        dist2_start -= m_di.dy_start();
                        if(dist1_start < 0) ++npix;
                        if(dist2_start < 0) ++npix;
                        ++dx;
                    }
                    while(m_dist_pos[dx] <= m_width);
                    if(npix == 0) break;

                    npix = 0;
                }
                while(--m_step >= -m_max_extent);
            }
            else
            {
                do
                {
                    --m_li;

                    m_x -= lp.inc;
                    m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift;

                    if(lp.inc > 0) m_di.dec_x(m_y - m_old_y);
                    else           m_di.inc_x(m_y - m_old_y);

                    m_old_y = m_y;

                    dist1_start = dist2_start = m_di.dist_start();

                    int dy = 0;
                    if(dist1_start < 0) ++npix;
                    do
                    {
                        dist1_start -= m_di.dx_start();
                        dist2_start += m_di.dx_start();
                        if(dist1_start < 0) ++npix;
                        if(dist2_start < 0) ++npix;
                        ++dy;
                    }
                    while(m_dist_pos[dy] <= m_width);
                    if(npix == 0) break;

                    npix = 0;
                }
                while(--m_step >= -m_max_extent);
            }
            m_li.adjust_forward();
            m_step -= m_max_extent;
        }
 //---------------------------------------------------------------------
 //typedef renderer_outline_image<BaseRenderer, ImagePattern> self_type;
 //---------------------------------------------------------------------
 public renderer_outline_image(IPixelFormat ren, line_image_pattern patt)
 {
     m_ren=ren;
     m_pattern=patt;
     m_start=(0);
     m_scale_x=(1.0);
     m_clip_box=new rect_i(0,0,0,0);
     m_clipping=(false);
 }
Example #26
0
 public void Blur(IPixelFormat img, double radius)
 {
     BlurX(img, radius);
     BlurY(img, radius);
 }
Example #27
0
        public void BlurX(IPixelFormat img, double radius)
        {
            if(radius < 0.62) return;
            if(img.Width < 3) return;

            double s = (double)(radius * 0.5);
            double q = (double)((s < 2.5) ?
                                    3.97156 - 4.14554 * Math.Sqrt(1 - 0.26891 * s) :
                                    0.98711 * s - 0.96330);

            double q2 = (double)(q * q);
            double q3 = (double)(q2 * q);

            double b0 = (double)(1.0 / (1.578250 +
                                            2.444130 * q +
                                            1.428100 * q2 +
                                            0.422205 * q3));

            double b1 = (double)(2.44413 * q +
                                      2.85619 * q2 +
                                      1.26661 * q3);

            double b2 = (double)(-1.42810 * q2 +
                                     -1.26661 * q3);

            double b3 = (double)(0.422205 * q3);

            double b = (double)(1 - (b1 + b2 + b3) * b0);

            b1 *= b0;
            b2 *= b0;
            b3 *= b0;

            uint w = img.Width;
            uint h = img.Height;
            int wm = (int)w-1;
            int x, y;

            int StartCreatingAt = (int)m_sum1.Size();
            m_sum1.Resize(w);
            m_sum2.Resize(w);
            m_buf.Allocate(w);

            RecursizeBlurCalculator[] Sum1Array = m_sum1.Array;
            RecursizeBlurCalculator[] Sum2Array = m_sum2.Array;
            RGBA_Bytes[] BufferArray = m_buf.Array;

            for (int i = StartCreatingAt; i < w; i++)
            {
                Sum1Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew();
                Sum2Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew();
            }

            for (y = 0; y < h; y++)
            {
                RecursizeBlurCalculator c = m_RecursizeBlurCalculatorFactory;
                c.FromPixel(img.Pixel(0, y));
                Sum1Array[0].Calculate(b, b1, b2, b3, c, c, c, c);
                c.FromPixel(img.Pixel(1, y));
                Sum1Array[1].Calculate(b, b1, b2, b3, c, Sum1Array[0], Sum1Array[0], Sum1Array[0]);
                c.FromPixel(img.Pixel(2, y));
                Sum1Array[2].Calculate(b, b1, b2, b3, c, Sum1Array[1], Sum1Array[0], Sum1Array[0]);

                for (x = 3; x < w; ++x)
                {
                    c.FromPixel(img.Pixel(x, y));
                    Sum1Array[x].Calculate(b, b1, b2, b3, c, Sum1Array[x - 1], Sum1Array[x - 2], Sum1Array[x - 3]);
                }

                Sum2Array[wm].Calculate(b, b1, b2, b3, Sum1Array[wm], Sum1Array[wm], Sum1Array[wm], Sum1Array[wm]);
                Sum2Array[wm - 1].Calculate(b, b1, b2, b3, Sum1Array[wm - 1], Sum2Array[wm], Sum2Array[wm], Sum2Array[wm]);
                Sum2Array[wm - 2].Calculate(b, b1, b2, b3, Sum1Array[wm - 2], Sum2Array[wm - 1], Sum2Array[wm], Sum2Array[wm]);
                Sum2Array[wm].ToPixel(ref BufferArray[wm]);
                Sum2Array[wm - 1].ToPixel(ref BufferArray[wm - 1]);
                Sum2Array[wm - 2].ToPixel(ref BufferArray[wm - 2]);

                for (x = wm - 3; x >= 0; --x)
                {
                    Sum2Array[x].Calculate(b, b1, b2, b3, Sum1Array[x], Sum2Array[x + 1], Sum2Array[x + 2], Sum2Array[x + 3]);
                    Sum2Array[x].ToPixel(ref BufferArray[x]);
                }

                unsafe
                {
                    fixed (RGBA_Bytes* pBuffer = BufferArray)
                    {
                        img.CopyHorizontalColorSpan(0, y, w, pBuffer);
                    }
                }
            }
        }
Example #28
0
 public void BlurY(IPixelFormat img, double radius)
 {
     FormatTransposer img2 = new FormatTransposer(img);
     BlurX(img2, radius);
 }
 void attach(IPixelFormat pixf)
 {
     m_pixf = pixf;
 }
Example #30
0
File: Blur.cs Project: djlw78/Mosa
 public void Blur(IPixelFormat img, double radius)
 {
     BlurX(img, radius);
     BlurY(img, radius);
 }
Example #31
0
 public override void Attach(IPixelFormat ren)
 {
     base.Attach(ren);
     m_clip_box = new RectI(0, 0, (int)ren.Width - 1, (int)ren.Height - 1);
 }
 public void attach(IPixelFormat ren)
 {
     m_ren = ren;
 }
 public void Attach(IPixelFormat pixf)
 {
     m_pixf = pixf;
 }
Example #34
0
 public PixMap(IPixelFormat pixFormat)
 {
     _pixelFormat = pixFormat;
     _buffer = pixFormat.GetRenderingBuffer();
 }
Example #35
0
 public PixMap(IPixelFormat pixFormat)
 {
     _pixelFormat = pixFormat;
     _buffer      = pixFormat.GetRenderingBuffer();
 }
Example #36
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 public virtual void Attach(IPixelFormat pixf)
 {
     PixelFormat = pixf;
 }
Example #37
0
File: Blur.cs Project: djlw78/Mosa
        public void BlurX(IPixelFormat img, double radius)
        {
            if (radius < 0.62)
            {
                return;
            }
            if (img.Width < 3)
            {
                return;
            }

            double s = (double)(radius * 0.5);
            double q = (double)((s < 2.5) ?
                                3.97156 - 4.14554 * Math.Sqrt(1 - 0.26891 * s) :
                                0.98711 * s - 0.96330);

            double q2 = (double)(q * q);
            double q3 = (double)(q2 * q);

            double b0 = (double)(1.0 / (1.578250 +
                                        2.444130 * q +
                                        1.428100 * q2 +
                                        0.422205 * q3));

            double b1 = (double)(2.44413 * q +
                                 2.85619 * q2 +
                                 1.26661 * q3);

            double b2 = (double)(-1.42810 * q2 +
                                 -1.26661 * q3);

            double b3 = (double)(0.422205 * q3);

            double b = (double)(1 - (b1 + b2 + b3) * b0);

            b1 *= b0;
            b2 *= b0;
            b3 *= b0;

            uint w = img.Width;
            uint h = img.Height;
            int  wm = (int)w - 1;
            int  x, y;

            int StartCreatingAt = (int)m_sum1.Size();

            m_sum1.Resize(w);
            m_sum2.Resize(w);
            m_buf.Allocate(w);

            RecursizeBlurCalculator[] Sum1Array = m_sum1.Array;
            RecursizeBlurCalculator[] Sum2Array = m_sum2.Array;
            RGBA_Bytes[] BufferArray            = m_buf.Array;

            for (int i = StartCreatingAt; i < w; i++)
            {
                Sum1Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew();
                Sum2Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew();
            }

            for (y = 0; y < h; y++)
            {
                RecursizeBlurCalculator c = m_RecursizeBlurCalculatorFactory;
                c.FromPixel(img.Pixel(0, y));
                Sum1Array[0].Calculate(b, b1, b2, b3, c, c, c, c);
                c.FromPixel(img.Pixel(1, y));
                Sum1Array[1].Calculate(b, b1, b2, b3, c, Sum1Array[0], Sum1Array[0], Sum1Array[0]);
                c.FromPixel(img.Pixel(2, y));
                Sum1Array[2].Calculate(b, b1, b2, b3, c, Sum1Array[1], Sum1Array[0], Sum1Array[0]);

                for (x = 3; x < w; ++x)
                {
                    c.FromPixel(img.Pixel(x, y));
                    Sum1Array[x].Calculate(b, b1, b2, b3, c, Sum1Array[x - 1], Sum1Array[x - 2], Sum1Array[x - 3]);
                }

                Sum2Array[wm].Calculate(b, b1, b2, b3, Sum1Array[wm], Sum1Array[wm], Sum1Array[wm], Sum1Array[wm]);
                Sum2Array[wm - 1].Calculate(b, b1, b2, b3, Sum1Array[wm - 1], Sum2Array[wm], Sum2Array[wm], Sum2Array[wm]);
                Sum2Array[wm - 2].Calculate(b, b1, b2, b3, Sum1Array[wm - 2], Sum2Array[wm - 1], Sum2Array[wm], Sum2Array[wm]);
                Sum2Array[wm].ToPixel(ref BufferArray[wm]);
                Sum2Array[wm - 1].ToPixel(ref BufferArray[wm - 1]);
                Sum2Array[wm - 2].ToPixel(ref BufferArray[wm - 2]);

                for (x = wm - 3; x >= 0; --x)
                {
                    Sum2Array[x].Calculate(b, b1, b2, b3, Sum1Array[x], Sum2Array[x + 1], Sum2Array[x + 2], Sum2Array[x + 3]);
                    Sum2Array[x].ToPixel(ref BufferArray[x]);
                }

                unsafe
                {
                    fixed(RGBA_Bytes *pBuffer = BufferArray)
                    {
                        img.CopyHorizontalColorSpan(0, y, w, pBuffer);
                    }
                }
            }
        }
Example #38
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 public PixelFormatProxy(IPixelFormat pixf)
 {
     PixelFormat = pixf;
 }
Example #39
0
 public bool Attach(IPixelFormat pixf, int x1, int y1, int x2, int y2)
 {
     RectInt r = new RectInt(x1, y1, x2, y2);
     if (r.Clip(new RectInt(0, 0, (int)pixf.Width - 1, (int)pixf.Height - 1)))
     {
         int stride = pixf.Stride;
         unsafe
         {
             m_rbuf.attach(pixf.PixPtr(r.X1, stride < 0 ? r.Y2 : r.Y1),
                 (uint)(r.X2 - r.X1) + 1,
                 (uint)(r.Y2 - r.Y1) + 1,
                 stride, 3);
         }
         return true;
     }
     return false;
 }
Example #40
0
 public PixelFormatProxy(IPixelFormat pixf)
 {
     m_pixf = pixf;
 }
Example #41
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 public virtual void Attach(IPixelFormat pixf)
 {
     PixelFormat = pixf;
 }
 public PixelFormatOutputOption(IPixelFormat pixelFormat) => _pixelFormat = pixelFormat;
Example #43
0
 //--------------------------------------------------------------------
 public FormatTransposer(IPixelFormat pixelFormat)
     : base(pixelFormat)
 {
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="PixelFormat"></param>
        /// <param name="Rasterizer"></param>
        /// <param name="Scanline"></param>
        public Renderer(IPixelFormat PixelFormat, AntiAliasedScanlineRasterizer Rasterizer, IScanline Scanline)
        {
            m_PixelFormat = PixelFormat;
            m_Rasterizer = Rasterizer;
            m_Scanline = Scanline;

            TextPath = new GsvText();
            StrockedText = new StrokeConverter(TextPath);
            m_AffineTransformStack.Push(Affine.NewIdentity());
        }
Example #45
0
 //--------------------------------------------------------------------
 public FormatClippingProxy(IPixelFormat ren)
     : base(ren)
 {
     m_clip_box = new RectI(0, 0, (int)ren.Width - 1, (int)ren.Height - 1);
 }
        public static void RenderCompound(AntiAliasedCompundRasterizer ras,
                                       IScanline sl_aa,
                                       IScanline sl_bin,
                                       IPixelFormat pixelFormat,
                                       SpanAllocator alloc,
                                       IStyleHandler sh)
        {
            #if true
            unsafe
            {
                if (ras.RewindScanlines())
                {
                    int min_x = ras.MinX();
                    int len = ras.MaxX() - min_x + 2;
                    sl_aa.Reset(min_x, ras.MaxX());
                    sl_bin.Reset(min_x, ras.MaxX());

                    //typedef typename BaseRenderer::color_type color_type;
                    ArrayPOD<RGBA_Bytes> color_span = alloc.Allocate((uint)len * 2);
                    byte[] ManagedCoversArray = sl_aa.GetCovers();
                    fixed (byte* pCovers = ManagedCoversArray)
                    {
                        fixed (RGBA_Bytes* pColorSpan = color_span.Array)
                        {
                            int mix_bufferOffset = len;
                            uint num_spans;

                            uint num_styles;
                            uint style;
                            bool solid;
                            while ((num_styles = ras.SweepStyles()) > 0)
                            {
                                if (num_styles == 1)
                                {
                                    // Optimization for a single Style. Happens often
                                    //-------------------------
                                    if (ras.SweepScanline(sl_aa, 0))
                                    {
                                        style = ras.Style(0);
                                        if (sh.IsSolid(style))
                                        {
                                            // Just solid fill
                                            //-----------------------
                                            RenderSolidSingleScanLine(pixelFormat, sl_aa, sh.Color(style));
                                        }
                                        else
                                        {
                                            // Arbitrary Span Generator
                                            //-----------------------
                                            ScanlineSpan span_aa = sl_aa.Begin;
                                            num_spans = sl_aa.NumberOfSpans;

                                            for (; ; )
                                            {
                                                len = span_aa.len;
                                                sh.GenerateSpan(pColorSpan,
                                                                 span_aa.x,
                                                                 sl_aa.y(),
                                                                 (uint)len,
                                                                 style);

                                                pixelFormat.BlendHorizontalColorSpan(span_aa.x,
                                                                      sl_aa.y(),
                                                                      (uint)span_aa.len,
                                                                      pColorSpan,
                                                                      &pCovers[span_aa.cover_index], 0);
                                                if (--num_spans == 0) break;
                                                span_aa = sl_aa.GetNextScanlineSpan();
                                            }
                                        }
                                    }
                                }
                                else // there are multiple Styles
                                {
                                    if (ras.SweepScanline(sl_bin, -1))
                                    {
                                        // Clear the spans of the mix_buffer
                                        //--------------------
                                        ScanlineSpan span_bin = sl_bin.Begin;
                                        num_spans = sl_bin.NumberOfSpans;
                                        for (; ; )
                                        {
                                            Basics.MemClear((byte*)&pColorSpan[mix_bufferOffset + span_bin.x - min_x],
                                                   span_bin.len * sizeof(RGBA_Bytes));

                                            if (--num_spans == 0) break;
                                            span_bin = sl_bin.GetNextScanlineSpan();
                                        }

                                        for (uint i = 0; i < num_styles; i++)
                                        {
                                            style = ras.Style(i);
                                            solid = sh.IsSolid(style);

                                            if (ras.SweepScanline(sl_aa, (int)i))
                                            {
                                                //IColorType* Colors;
                                                //IColorType* cspan;
                                                //typename ScanlineAA::cover_type* covers;
                                                ScanlineSpan span_aa = sl_aa.Begin;
                                                num_spans = sl_aa.NumberOfSpans;
                                                if (solid)
                                                {
                                                    // Just solid fill
                                                    //-----------------------
                                                    for (; ; )
                                                    {
                                                        RGBA_Bytes c = sh.Color(style);
                                                        len = span_aa.len;
                                                        RGBA_Bytes* colors = &pColorSpan[mix_bufferOffset + span_aa.x - min_x];
                                                        byte* covers = &pCovers[span_aa.cover_index];
                                                        do
                                                        {
                                                            if (*covers == cover_full)
                                                            {
                                                                *colors = c;
                                                            }
                                                            else
                                                            {
                                                                colors->add(c, *covers);
                                                            }
                                                            ++colors;
                                                            ++covers;
                                                        }
                                                        while (--len != 0);
                                                        if (--num_spans == 0) break;
                                                        span_aa = sl_aa.GetNextScanlineSpan();
                                                    }
                                                }
                                                else
                                                {
                                                    // Arbitrary Span Generator
                                                    //-----------------------
                                                    for (; ; )
                                                    {
                                                        len = span_aa.len;
                                                        RGBA_Bytes* colors = &pColorSpan[mix_bufferOffset + span_aa.x - min_x];
                                                        RGBA_Bytes* cspan = pColorSpan;
                                                        sh.GenerateSpan(cspan,
                                                                         span_aa.x,
                                                                         sl_aa.y(),
                                                                         (uint)len,
                                                                         style);
                                                        byte* covers = &pCovers[span_aa.cover_index];
                                                        do
                                                        {
                                                            if (*covers == cover_full)
                                                            {
                                                                *colors = *cspan;
                                                            }
                                                            else
                                                            {
                                                                colors->add(*cspan, *covers);
                                                            }
                                                            ++cspan;
                                                            ++colors;
                                                            ++covers;
                                                        }
                                                        while (--len != 0);
                                                        if (--num_spans == 0) break;
                                                        span_aa = sl_aa.GetNextScanlineSpan();
                                                    }
                                                }
                                            }
                                        }

                                        // Emit the blended result as a Color hspan
                                        //-------------------------
                                        span_bin = sl_bin.Begin;
                                        num_spans = sl_bin.NumberOfSpans;
                                        for (; ; )
                                        {
                                            pixelFormat.BlendHorizontalColorSpan(span_bin.x,
                                                                  sl_bin.y(),
                                                                  (uint)span_bin.len,
                                                                  &pColorSpan[mix_bufferOffset + span_bin.x - min_x],
                                                                  null,
                                                                  cover_full);
                                            if (--num_spans == 0) break;
                                            span_bin = sl_bin.GetNextScanlineSpan();
                                        }
                                    } // if(ras.SweepScanline(sl_bin, -1))
                                } // if(num_styles == 1) ... else
                            } // while((num_styles = ras.SweepStyles()) > 0)
                        }
                    }
                } // if(ras.RewindScanlines())
            #endif
            }
        }
Example #47
0
 //--------------------------------------------------------------------
 public FormatClippingProxy(IPixelFormat ren)
     : base(ren)
 {
     m_clip_box = new RectI(0, 0, (int)ren.Width - 1, (int)ren.Height - 1);
 }
        //========================================================render_all_paths
        public static void RenderSolidAllPaths(IPixelFormat pixFormat, 
            IRasterizer ras, 
            IScanline sl,
            IVertexSource vs, 
            RGBA_Bytes[] color_storage,
            uint[] path_id,
            uint num_paths)
        {
            for(uint i = 0; i < num_paths; i++)
            {
                ras.Reset();

            #if use_timers
                AddPathTimer.Start();
            #endif
                ras.AddPath(vs, path_id[i]);
            #if use_timers
                AddPathTimer.Stop();
            #endif

            #if use_timers
                RenderSLTimer.Start();
            #endif
                RenderSolid(pixFormat, ras, sl, color_storage[i]);
            #if use_timers
                RenderSLTimer.Stop();
            #endif
            }
        }
 public RasterBufferAccessorClamp(IPixelFormat pixf)
 {
     m_pixf = pixf;
     m_PixelWidthInBytes = m_pixf.PixelWidthInBytes;
 }
Example #50
0
 public Renderer(IPixelFormat PixelFormat, RasterizerScanlineAA<T> Rasterizer, IScanlineCache ScanlineCache)
     : base(PixelFormat, Rasterizer)
 {
     m_ScanlineCache = ScanlineCache;
 }
Example #51
0
 public void attach(IPixelFormat pixf)
 {
     m_pixf = pixf;
 }
Example #52
0
 public RendererOpenGL(IPixelFormat PixelFormat, RasterizerScanlineAA <T> Rasterizer)
     : base(PixelFormat, Rasterizer)
 {
     TextPath     = new GsvText <T>();
     StrockedText = new ConvStroke <T>(TextPath);
 }
        //================================================render_scanline_aa_solid
        private static void RenderSolidSingleScanLine(IPixelFormat pixFormat, IScanline scanLine, RGBA_Bytes color)
        {
            #if use_timers
            render_scanline_aa_solidTimer.Start();
            #endif
            int y = scanLine.y();
            uint num_spans = scanLine.NumberOfSpans;
            ScanlineSpan scanlineSpan = scanLine.Begin;

            byte[] ManagedCoversArray = scanLine.GetCovers();
            unsafe
            {
                fixed (byte* pCovers = ManagedCoversArray)
                {
                    for (; ; )
                    {
                        int x = scanlineSpan.x;
                        if (scanlineSpan.len > 0)
                        {
            #if use_timers
                            render_scanline_aa_solid_blend_solid_hspan.Start();
            #endif
                            pixFormat.BlendSolidHorizontalSpan(x, y, (uint)scanlineSpan.len, color, &pCovers[scanlineSpan.cover_index]);
            #if use_timers
                            render_scanline_aa_solid_blend_solid_hspan.Stop();
            #endif
                        }
                        else
                        {
            #if use_timers
                            render_scanline_aa_solid_blend_hline.Start();
            #endif
                            pixFormat.BlendHorizontalLine(x, y, (x - (int)scanlineSpan.len - 1), color, pCovers[scanlineSpan.cover_index]);
            #if use_timers
                            render_scanline_aa_solid_blend_hline.Stop();
            #endif
                        }
                        if (--num_spans == 0) break;
                        scanlineSpan = scanLine.GetNextScanlineSpan();
                    }
                }
            }
            #if use_timers
            render_scanline_aa_solidTimer.Stop();
            #endif
        }
Example #54
0
 public void AttachPixFmt(IPixelFormat pixf)
 {
     m_pixf = pixf;
 }
 //=====================================================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);
         }
     }
 }
Example #56
0
        public static void RenderCompound(AntiAliasedCompundRasterizer ras,
                                       IScanline sl_aa,
                                       IScanline sl_bin,
                                       IPixelFormat pixelFormat,
                                       SpanAllocator alloc,
                                       IStyleHandler sh)
        {
#if true
            unsafe
            {
                if (ras.RewindScanlines())
                {
                    int min_x = ras.MinX();
                    int len = ras.MaxX() - min_x + 2;
                    sl_aa.Reset(min_x, ras.MaxX());
                    sl_bin.Reset(min_x, ras.MaxX());

                    //typedef typename BaseRenderer::color_type color_type;
                    ArrayPOD<RGBA_Bytes> color_span = alloc.Allocate((uint)len * 2);
                    byte[] ManagedCoversArray = sl_aa.GetCovers();
                    fixed (byte* pCovers = ManagedCoversArray)
                    {
                        fixed (RGBA_Bytes* pColorSpan = color_span.Array)
                        {
                            int mix_bufferOffset = len;
                            uint num_spans;

                            uint num_styles;
                            uint style;
                            bool solid;
                            while ((num_styles = ras.SweepStyles()) > 0)
                            {
                                if (num_styles == 1)
                                {
                                    // Optimization for a single Style. Happens often
                                    //-------------------------
                                    if (ras.SweepScanline(sl_aa, 0))
                                    {
                                        style = ras.Style(0);
                                        if (sh.IsSolid(style))
                                        {
                                            // Just solid fill
                                            //-----------------------
                                            RenderSolidSingleScanLine(pixelFormat, sl_aa, sh.Color(style));
                                        }
                                        else
                                        {
                                            // Arbitrary Span Generator
                                            //-----------------------
                                            ScanlineSpan span_aa = sl_aa.Begin;
                                            num_spans = sl_aa.NumberOfSpans;

                                            for (; ; )
                                            {
                                                len = span_aa.len;
                                                sh.GenerateSpan(pColorSpan,
                                                                 span_aa.x,
                                                                 sl_aa.y(),
                                                                 (uint)len,
                                                                 style);

                                                pixelFormat.BlendHorizontalColorSpan(span_aa.x,
                                                                      sl_aa.y(),
                                                                      (uint)span_aa.len,
                                                                      pColorSpan,
                                                                      &pCovers[span_aa.cover_index], 0);
                                                if (--num_spans == 0) break;
                                                span_aa = sl_aa.GetNextScanlineSpan();
                                            }
                                        }
                                    }
                                }
                                else // there are multiple Styles
                                {
                                    if (ras.SweepScanline(sl_bin, -1))
                                    {
                                        // Clear the spans of the mix_buffer
                                        //--------------------
                                        ScanlineSpan span_bin = sl_bin.Begin;
                                        num_spans = sl_bin.NumberOfSpans;
                                        for (; ; )
                                        {
                                            Basics.MemClear((byte*)&pColorSpan[mix_bufferOffset + span_bin.x - min_x],
                                                   span_bin.len * sizeof(RGBA_Bytes));

                                            if (--num_spans == 0) break;
                                            span_bin = sl_bin.GetNextScanlineSpan();
                                        }

                                        for (uint i = 0; i < num_styles; i++)
                                        {
                                            style = ras.Style(i);
                                            solid = sh.IsSolid(style);

                                            if (ras.SweepScanline(sl_aa, (int)i))
                                            {
                                                //IColorType* Colors;
                                                //IColorType* cspan;
                                                //typename ScanlineAA::cover_type* covers;
                                                ScanlineSpan span_aa = sl_aa.Begin;
                                                num_spans = sl_aa.NumberOfSpans;
                                                if (solid)
                                                {
                                                    // Just solid fill
                                                    //-----------------------
                                                    for (; ; )
                                                    {
                                                        RGBA_Bytes c = sh.Color(style);
                                                        len = span_aa.len;
                                                        RGBA_Bytes* colors = &pColorSpan[mix_bufferOffset + span_aa.x - min_x];
                                                        byte* covers = &pCovers[span_aa.cover_index];
                                                        do
                                                        {
                                                            if (*covers == cover_full)
                                                            {
                                                                *colors = c;
                                                            }
                                                            else
                                                            {
                                                                colors->add(c, *covers);
                                                            }
                                                            ++colors;
                                                            ++covers;
                                                        }
                                                        while (--len != 0);
                                                        if (--num_spans == 0) break;
                                                        span_aa = sl_aa.GetNextScanlineSpan();
                                                    }
                                                }
                                                else
                                                {
                                                    // Arbitrary Span Generator
                                                    //-----------------------
                                                    for (; ; )
                                                    {
                                                        len = span_aa.len;
                                                        RGBA_Bytes* colors = &pColorSpan[mix_bufferOffset + span_aa.x - min_x];
                                                        RGBA_Bytes* cspan = pColorSpan;
                                                        sh.GenerateSpan(cspan,
                                                                         span_aa.x,
                                                                         sl_aa.y(),
                                                                         (uint)len,
                                                                         style);
                                                        byte* covers = &pCovers[span_aa.cover_index]; 
                                                        do
                                                        {
                                                            if (*covers == cover_full)
                                                            {
                                                                *colors = *cspan;
                                                            }
                                                            else
                                                            {
                                                                colors->add(*cspan, *covers);
                                                            }
                                                            ++cspan;
                                                            ++colors;
                                                            ++covers;
                                                        }
                                                        while (--len != 0);
                                                        if (--num_spans == 0) break;
                                                        span_aa = sl_aa.GetNextScanlineSpan();
                                                    }
                                                }
                                            }
                                        }

                                        // Emit the blended result as a Color hspan
                                        //-------------------------
                                        span_bin = sl_bin.Begin;
                                        num_spans = sl_bin.NumberOfSpans;
                                        for (; ; )
                                        {
                                            pixelFormat.BlendHorizontalColorSpan(span_bin.x,
                                                                  sl_bin.y(),
                                                                  (uint)span_bin.len,
                                                                  &pColorSpan[mix_bufferOffset + span_bin.x - min_x],
                                                                  null,
                                                                  cover_full);
                                            if (--num_spans == 0) break;
                                            span_bin = sl_bin.GetNextScanlineSpan();
                                        }
                                    } // if(ras.SweepScanline(sl_bin, -1))
                                } // if(num_styles == 1) ... else
                            } // while((num_styles = ras.SweepStyles()) > 0)
                        }
                    }
                } // if(ras.RewindScanlines())
#endif
            }
        }
 //========================================================render_scanlines
 public static void RenderSolid(IPixelFormat pixFormat, IRasterizer rasterizer, IScanline scanLine, RGBA_Bytes color)
 {
     if(rasterizer.RewindScanlines())
     {
         scanLine.Reset(rasterizer.MinX(), rasterizer.MaxX());
     #if use_timers
         PrepareTimer.Start();
     #endif
         //renderer.Prepare();
     #if use_timers
         PrepareTimer.Stop();
     #endif
         while(rasterizer.SweepScanline(scanLine))
         {
             Renderer.RenderSolidSingleScanLine(pixFormat, scanLine, color);
         }
     }
 }
Example #58
0
File: Blur.cs Project: djlw78/Mosa
        public void BlurY(IPixelFormat img, double radius)
        {
            FormatTransposer img2 = new FormatTransposer(img);

            BlurX(img2, radius);
        }
        //======================================================render_scanline_aa
        private static void GenerateAndRenderSingleScanline(IScanline sl, IPixelFormat ren,
                                SpanAllocator alloc, ISpanGenerator span_gen)
        {
            int y = sl.y();
            uint num_spans = sl.NumberOfSpans;
            ScanlineSpan scanlineSpan = sl.Begin;

            byte[] ManagedCoversArray = sl.GetCovers();
            unsafe
            {
                fixed (byte* pCovers = ManagedCoversArray)
                {
                    for (; ; )
                    {
                        int x = scanlineSpan.x;
                        int len = scanlineSpan.len;
                        if(len < 0) len = -len;

                        if(tempSpanColors.Capacity() < len)
                        {
                            tempSpanColors.Allocate((uint)(len));
                        }

                        fixed (RGBA_Bytes* pColors = tempSpanColors.Array)
                        {
                            span_gen.Generate(pColors, x, y, (uint)len);
            #if use_timers
                            blend_color_hspan.Start();
            #endif
                            ren.BlendHorizontalColorSpan(x, y, (uint)len, pColors, (scanlineSpan.len < 0) ? null : &pCovers[scanlineSpan.cover_index], pCovers[scanlineSpan.cover_index]);
            #if use_timers
                            blend_color_hspan.Stop();
            #endif
                        }

                        if (--num_spans == 0) break;
                        scanlineSpan = sl.GetNextScanlineSpan();
                    }
                }
            }
        }
Example #60
0
 public PixelFormatFilter(IPixelFormat pixelFormat) => _pixelFormat = pixelFormat;