[Mono-dev] libgdiplus drawing performance

Sebastien Pouliot sebastien.pouliot at gmail.com
Mon Sep 27 08:21:47 EDT 2010


On Sun, 2010-09-26 at 01:33 -0700, oken wrote:
> #define VS(fun) \
> do{\
> 	GpStatus status = fun; \
> 	if (Ok != status) \
> 	{\
> 		assert(!"invalid status");\
> 		return status;\
> 	}\
> }while(0)
> int width = 1000;
> 	int height = 1000;
> 	GpStatus status = Ok;
> 	BYTE *scan0 = NULL;
> 
> 	VS(GdipCreateBitmapFromScan0(width, height, width * 4,
> PixelFormat32bppARGB, scan0, &m_bmp));
> 	VS(GdipGetImageGraphicsContext(m_bmp, &m_pGraphics));
> 	VS(GdipGraphicsClear(m_pGraphics, 0xffffffff));
> 
> 	VS(GdipCreatePen1(0xa0f0a000, (REAL)2.0, UnitPixel, &m_pPen));
> 	VS(GdipCreateSolidFill(0xa00000ff, &m_pSolidBrush));
> 
> VS(GdipSetPenColor(m_pPen, 0xff0000ff));
> 
> 	for (int i = 0; i < nTimes ; i++)
> 	{
> 		VS(GdipDrawLine(m_pGraphics, m_pPen, 100, 100, 500, 500));
> 	}
> 
> I also find that libgdiplus's performance is slow.

libgdiplus main goal is compatibility, it's an extra layer on top of
cairo and will never be a racing horse. OTOH your contributions to help
performance, without hurting compatibility, is welcome.

> In my example, drawing 1000 lines takes me 5,000ms!
> I find it that most of the time is consumed by "cairo_stroke" in
> stroke_graphics_with_pen (GpGraphics *graphics, GpPen *pen).
> I am calling libgdiplus's API under wine!
> How to improve the performance?

Does not wine ship its own libgdiplus ? If you're using their version
then you should ask them about their performance advice.

If you're using Mono's libgdiplus then make sure you're using the latest
(not the embedded) cairo. That will bring you all the performance work
done by the cairo folks since cairo 1.6.

Sebastien



More information about the Mono-devel-list mailing list