[Mono-dev] Broken rectangle drawing on Linux

Remigiusz Towalski rtowalski at forcom.com.pl
Tue May 13 09:02:33 EDT 2008


After more investigations, I've found something interesting:

This line fixed my problem:
	e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

Code that seems to be responsible (libgdiplus\src\graphics-cairo.cs):

GpStatus
cairo_SetSmoothingMode (GpGraphics *graphics, SmoothingMode mode)
{
	switch (mode) {
	case SmoothingModeAntiAlias:
	case SmoothingModeHighQuality:
		cairo_set_antialias (graphics->ct, CAIRO_ANTIALIAS_DEFAULT);
		graphics->aa_offset_x = 0.5;
		graphics->aa_offset_y = 0.5;
		break;

	case SmoothingModeNone:
	case SmoothingModeDefault:
	case SmoothingModeHighSpeed:
	default:
		cairo_set_antialias (graphics->ct, CAIRO_ANTIALIAS_NONE);
		graphics->aa_offset_x = CAIRO_AA_OFFSET_X;
		graphics->aa_offset_y = CAIRO_AA_OFFSET_Y;
		break;
	}
	return Ok;
}

What is interesting:

in 1.9.1:
	#define CAIRO_AA_OFFSET_X		1
	#define CAIRO_AA_OFFSET_Y		0.5

in 1.2.6:
	#ifdef CAIRO_HAS_QUARTZ_SURFACE
		#define CAIRO_AA_OFFSET_X		0.5
		#define CAIRO_AA_OFFSET_Y		0.5
	#else
		#define CAIRO_AA_OFFSET_X		1
		#define CAIRO_AA_OFFSET_Y		0.5
	#endif

But Quartz is AFAIR MacOS renderer...

RT

> Hi.
> 
> There is something wrong with reclangle drawing in Mono 1.9.
> 
> Rectangle seems to be off by 1 (or less) to the right.
> See attached test case.
> 
> It occures on:
>  - Mono 1.9 on Linux
> 
> It doesn't occure on:
>  - MS .Net
>  - Mono 1.2.6 on Linux
>  - Mono 1.2.6 on Windows
>  - Mono 1.9.1 on Windows
> 






More information about the Mono-devel-list mailing list