예제 #1
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            IImageByte backBuffer = widgetsSubImage;

            IImageByte         destImage     = backBuffer;
            ImageClippingProxy clippingProxy = new ImageClippingProxy(destImage);

            clippingProxy.clear(new RGBA_Floats(0, 0, 0));

            ScanlineRasterizer  ras    = new ScanlineRasterizer();
            scanline_unpacked_8 sl     = new scanline_unpacked_8();
            scanline_bin        sl_bin = new scanline_bin();

            rasterizer_compound_aa rasc  = new rasterizer_compound_aa();
            span_allocator         alloc = new span_allocator();

            int            i;
            styles_gouraud styles = new styles_gouraud(m_mesh, m_gamma);

            stopwatch.Restart();
            rasc.reset();
            //rasc.clip_box(40, 40, width() - 40, height() - 40);
            for (i = 0; i < m_mesh.num_edges(); i++)
            {
                mesh_edge  e  = m_mesh.edge(i);
                mesh_point p1 = m_mesh.vertex(e.p1);
                mesh_point p2 = m_mesh.vertex(e.p2);
                rasc.styles(e.tl, e.tr);
                rasc.move_to_d(p1.x, p1.y);
                rasc.line_to_d(p2.x, p2.y);
            }

            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            scanlineRenderer.RenderCompound(rasc, sl, sl_bin, clippingProxy, alloc, styles);
            double tm = stopwatch.ElapsedMilliseconds;

            gsv_text t = new gsv_text();

            t.SetFontSize(10.0);

            Stroke pt = new Stroke(t);

            pt.width(1.5);
            pt.line_cap(LineCap.Round);
            pt.line_join(LineJoin.Round);

            string buf = string.Format("{0:F2} ms, {1} triangles, {2:F0} tri/sec",
                                       tm,
                                       m_mesh.num_triangles(),
                                       m_mesh.num_triangles() / tm * 1000.0);

            t.start_point(10.0, 10.0);
            t.text(buf);

            ras.add_path(pt);
            scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(255, 255, 255));

            if (m_gamma.GetGamma() != 1.0)
            {
                ((ImageBuffer)destImage).apply_gamma_inv(m_gamma);
            }

            base.OnDraw(graphics2D);
        }
예제 #2
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			IImageByte backBuffer = widgetsSubImage;

			IImageByte destImage = backBuffer;
			ImageClippingProxy clippingProxy = new ImageClippingProxy(destImage);
			clippingProxy.clear(new RGBA_Floats(0, 0, 0));

			ScanlineRasterizer ras = new ScanlineRasterizer();
			scanline_unpacked_8 sl = new scanline_unpacked_8();
			scanline_bin sl_bin = new scanline_bin();

			rasterizer_compound_aa rasc = new rasterizer_compound_aa();
			span_allocator alloc = new span_allocator();

			int i;
			styles_gouraud styles = new styles_gouraud(m_mesh, m_gamma);
			stopwatch.Restart();
			rasc.reset();
			//rasc.clip_box(40, 40, width() - 40, height() - 40);
			for (i = 0; i < m_mesh.num_edges(); i++)
			{
				mesh_edge e = m_mesh.edge(i);
				mesh_point p1 = m_mesh.vertex(e.p1);
				mesh_point p2 = m_mesh.vertex(e.p2);
				rasc.styles(e.tl, e.tr);
				rasc.move_to_d(p1.x, p1.y);
				rasc.line_to_d(p2.x, p2.y);
			}

			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.RenderCompound(rasc, sl, sl_bin, clippingProxy, alloc, styles);
			double tm = stopwatch.ElapsedMilliseconds;

			gsv_text t = new gsv_text();
			t.SetFontSize(10.0);

			Stroke pt = new Stroke(t);
			pt.width(1.5);
			pt.line_cap(LineCap.Round);
			pt.line_join(LineJoin.Round);

			string buf = string.Format("{0:F2} ms, {1} triangles, {2:F0} tri/sec",
				tm,
				m_mesh.num_triangles(),
				m_mesh.num_triangles() / tm * 1000.0);
			t.start_point(10.0, 10.0);
			t.text(buf);

			ras.add_path(pt);
			scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(255, 255, 255));

			if (m_gamma.GetGamma() != 1.0)
			{
				((ImageBuffer)destImage).apply_gamma_inv(m_gamma);
			}

			base.OnDraw(graphics2D);
		}