winex11.drv: draw dashed lines for extended pens

Alexandre Julliard julliard at winehq.org
Tue Jul 17 06:08:19 CDT 2007


"Evan Stade" <estade at gmail.com> writes:

> I'm only pretty sure this patch is correct.  Specifically, note that
> there are now HeapAlloc()s in X11DRV_SelectPen that rely on
> X11DRV_SelectPen being called again to free.  So what is supposed to
> happen is that X11DRV_SelectPen called with some dash style will free
> the last "dashes" array, and possibly allocate a new one. So this
> method requires DeleteDC to call something along the lines of
>
> SelectObject( hdc, GetStockObject(BLACK_PEN) );

The dash array is always small, there's no reason to allocate it on
the heap, you can store an array in the pen object. Also there
shouldn't be any need to store the 'ext' flag if you take it into
account when building the array.

> +#define COPY_DASHDATA(ext, name) \
> +    if(ext){ \
> +        physDev->pen.dash_len = sizeof(EXTPEN_##name)/sizeof(*EXTPEN_##name); \
> +        physDev->pen.dashes = HeapAlloc(GetProcessHeap(), 0, physDev->pen.dash_len); \
> +        memcpy(physDev->pen.dashes, EXTPEN_##name, physDev->pen.dash_len);} \
> +    else { \
> +        physDev->pen.dash_len = sizeof(PEN_##name)/sizeof(*PEN_##name); \
> +        physDev->pen.dashes = HeapAlloc(GetProcessHeap(), 0, physDev->pen.dash_len);\
> +        memcpy(physDev->pen.dashes, PEN_##name, physDev->pen.dash_len);}
> +

That macro is ugly, please avoid it.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list