gdi32: Don't use MulDiv in ntgdi functions.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5e481ab965
commit
9ca7966aed
|
@ -237,8 +237,8 @@ INT WINAPI NtGdiOffsetClipRgn( HDC hdc, INT x, INT y )
|
||||||
|
|
||||||
if (dc->hClipRgn)
|
if (dc->hClipRgn)
|
||||||
{
|
{
|
||||||
x = MulDiv( x, dc->attr->vport_ext.cx, dc->attr->wnd_ext.cx );
|
x = muldiv( x, dc->attr->vport_ext.cx, dc->attr->wnd_ext.cx );
|
||||||
y = MulDiv( y, dc->attr->vport_ext.cy, dc->attr->wnd_ext.cy );
|
y = muldiv( y, dc->attr->vport_ext.cy, dc->attr->wnd_ext.cy );
|
||||||
if (dc->attr->layout & LAYOUT_RTL) x = -x;
|
if (dc->attr->layout & LAYOUT_RTL) x = -x;
|
||||||
ret = NtGdiOffsetRgn( dc->hClipRgn, x, y );
|
ret = NtGdiOffsetRgn( dc->hClipRgn, x, y );
|
||||||
update_dc_clipping( dc );
|
update_dc_clipping( dc );
|
||||||
|
|
|
@ -382,9 +382,9 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
|
||||||
{
|
{
|
||||||
case DRIVERVERSION: return 0x4000;
|
case DRIVERVERSION: return 0x4000;
|
||||||
case TECHNOLOGY: return DT_RASDISPLAY;
|
case TECHNOLOGY: return DT_RASDISPLAY;
|
||||||
case HORZSIZE: return MulDiv( NtGdiGetDeviceCaps( dev->hdc, HORZRES ), 254,
|
case HORZSIZE: return muldiv( NtGdiGetDeviceCaps( dev->hdc, HORZRES ), 254,
|
||||||
NtGdiGetDeviceCaps( dev->hdc, LOGPIXELSX ) * 10 );
|
NtGdiGetDeviceCaps( dev->hdc, LOGPIXELSX ) * 10 );
|
||||||
case VERTSIZE: return MulDiv( NtGdiGetDeviceCaps( dev->hdc, VERTRES ), 254,
|
case VERTSIZE: return muldiv( NtGdiGetDeviceCaps( dev->hdc, VERTRES ), 254,
|
||||||
NtGdiGetDeviceCaps( dev->hdc, LOGPIXELSY ) * 10 );
|
NtGdiGetDeviceCaps( dev->hdc, LOGPIXELSY ) * 10 );
|
||||||
case HORZRES:
|
case HORZRES:
|
||||||
{
|
{
|
||||||
|
|
|
@ -2874,9 +2874,9 @@ static BOOL get_face_enum_data( struct gdi_font_face *face, ENUMLOGFONTEXW *elf,
|
||||||
UINT cell_height;
|
UINT cell_height;
|
||||||
|
|
||||||
#define TM font->otm.otmTextMetrics
|
#define TM font->otm.otmTextMetrics
|
||||||
#define SCALE_NTM(value) (MulDiv( ntm->ntmTm.tmHeight, (value), TM.tmHeight ))
|
#define SCALE_NTM(value) (muldiv( ntm->ntmTm.tmHeight, (value), TM.tmHeight ))
|
||||||
cell_height = TM.tmHeight / ( -lf.lfHeight / font->otm.otmEMSquare );
|
cell_height = TM.tmHeight / ( -lf.lfHeight / font->otm.otmEMSquare );
|
||||||
ntm->ntmTm.tmHeight = MulDiv( ntm_ppem, cell_height, font->otm.otmEMSquare );
|
ntm->ntmTm.tmHeight = muldiv( ntm_ppem, cell_height, font->otm.otmEMSquare );
|
||||||
ntm->ntmTm.tmAscent = SCALE_NTM( TM.tmAscent );
|
ntm->ntmTm.tmAscent = SCALE_NTM( TM.tmAscent );
|
||||||
ntm->ntmTm.tmDescent = ntm->ntmTm.tmHeight - ntm->ntmTm.tmAscent;
|
ntm->ntmTm.tmDescent = ntm->ntmTm.tmHeight - ntm->ntmTm.tmAscent;
|
||||||
ntm->ntmTm.tmInternalLeading = SCALE_NTM( TM.tmInternalLeading );
|
ntm->ntmTm.tmInternalLeading = SCALE_NTM( TM.tmInternalLeading );
|
||||||
|
|
|
@ -592,7 +592,7 @@ static HFONT create_scaled_font( const LOGFONTW *deffont )
|
||||||
}
|
}
|
||||||
|
|
||||||
lf = *deffont;
|
lf = *deffont;
|
||||||
lf.lfHeight = MulDiv( lf.lfHeight, dpi, 96 );
|
lf.lfHeight = muldiv( lf.lfHeight, dpi, 96 );
|
||||||
return create_font( &lf );
|
return create_font( &lf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,30 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(dc);
|
WINE_DEFAULT_DEBUG_CHANNEL(dc);
|
||||||
|
|
||||||
|
|
||||||
|
/* copied from kernelbase */
|
||||||
|
int muldiv( int a, int b, int c )
|
||||||
|
{
|
||||||
|
LONGLONG ret;
|
||||||
|
|
||||||
|
if (!c) return -1;
|
||||||
|
|
||||||
|
/* We want to deal with a positive divisor to simplify the logic. */
|
||||||
|
if (c < 0)
|
||||||
|
{
|
||||||
|
a = -a;
|
||||||
|
c = -c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||||
|
if ((a < 0 && b < 0) || (a >= 0 && b >= 0))
|
||||||
|
ret = (((LONGLONG)a * b) + (c / 2)) / c;
|
||||||
|
else
|
||||||
|
ret = (((LONGLONG)a * b) - (c / 2)) / c;
|
||||||
|
|
||||||
|
if (ret > 2147483647 || ret < -2147483647) return -1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static SIZE get_dc_virtual_size( DC *dc )
|
static SIZE get_dc_virtual_size( DC *dc )
|
||||||
{
|
{
|
||||||
SIZE ret = dc->attr->virtual_size;
|
SIZE ret = dc->attr->virtual_size;
|
||||||
|
@ -113,20 +137,20 @@ BOOL set_map_mode( DC *dc, int mode )
|
||||||
dc->attr->vport_ext.cy = -virtual_res.cy;
|
dc->attr->vport_ext.cy = -virtual_res.cy;
|
||||||
break;
|
break;
|
||||||
case MM_LOENGLISH:
|
case MM_LOENGLISH:
|
||||||
dc->attr->wnd_ext.cx = MulDiv(1000, virtual_size.cx, 254);
|
dc->attr->wnd_ext.cx = muldiv(1000, virtual_size.cx, 254);
|
||||||
dc->attr->wnd_ext.cy = MulDiv(1000, virtual_size.cy, 254);
|
dc->attr->wnd_ext.cy = muldiv(1000, virtual_size.cy, 254);
|
||||||
dc->attr->vport_ext.cx = virtual_res.cx;
|
dc->attr->vport_ext.cx = virtual_res.cx;
|
||||||
dc->attr->vport_ext.cy = -virtual_res.cy;
|
dc->attr->vport_ext.cy = -virtual_res.cy;
|
||||||
break;
|
break;
|
||||||
case MM_HIENGLISH:
|
case MM_HIENGLISH:
|
||||||
dc->attr->wnd_ext.cx = MulDiv(10000, virtual_size.cx, 254);
|
dc->attr->wnd_ext.cx = muldiv(10000, virtual_size.cx, 254);
|
||||||
dc->attr->wnd_ext.cy = MulDiv(10000, virtual_size.cy, 254);
|
dc->attr->wnd_ext.cy = muldiv(10000, virtual_size.cy, 254);
|
||||||
dc->attr->vport_ext.cx = virtual_res.cx;
|
dc->attr->vport_ext.cx = virtual_res.cx;
|
||||||
dc->attr->vport_ext.cy = -virtual_res.cy;
|
dc->attr->vport_ext.cy = -virtual_res.cy;
|
||||||
break;
|
break;
|
||||||
case MM_TWIPS:
|
case MM_TWIPS:
|
||||||
dc->attr->wnd_ext.cx = MulDiv(14400, virtual_size.cx, 254);
|
dc->attr->wnd_ext.cx = muldiv(14400, virtual_size.cx, 254);
|
||||||
dc->attr->wnd_ext.cy = MulDiv(14400, virtual_size.cy, 254);
|
dc->attr->wnd_ext.cy = muldiv(14400, virtual_size.cy, 254);
|
||||||
dc->attr->vport_ext.cx = virtual_res.cx;
|
dc->attr->vport_ext.cx = virtual_res.cx;
|
||||||
dc->attr->vport_ext.cy = -virtual_res.cy;
|
dc->attr->vport_ext.cy = -virtual_res.cy;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -391,6 +391,7 @@ extern void lp_to_dp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN;
|
||||||
extern BOOL set_map_mode( DC *dc, int mode ) DECLSPEC_HIDDEN;
|
extern BOOL set_map_mode( DC *dc, int mode ) DECLSPEC_HIDDEN;
|
||||||
extern void combine_transform( XFORM *result, const XFORM *xform1,
|
extern void combine_transform( XFORM *result, const XFORM *xform1,
|
||||||
const XFORM *xform2 ) DECLSPEC_HIDDEN;
|
const XFORM *xform2 ) DECLSPEC_HIDDEN;
|
||||||
|
extern int muldiv( int a, int b, int c ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* driver.c */
|
/* driver.c */
|
||||||
extern BOOL is_display_device( LPCWSTR name ) DECLSPEC_HIDDEN;
|
extern BOOL is_display_device( LPCWSTR name ) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue