gdi32: Use NtGdiExtTextOutW for ExtTextOutW implementation.

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:
Jacek Caban 2021-07-23 10:49:42 +02:00 committed by Alexandre Julliard
parent aca66fb503
commit cc7e7002ef
9 changed files with 61 additions and 46 deletions

View File

@ -658,19 +658,6 @@ static BOOL CDECL emfpathdrv_EndPath( PHYSDEV dev )
return next->funcs->pEndPath( next );
}
/***********************************************************************
* emfpathdrv_ExtTextOut
*/
static BOOL CDECL emfpathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect,
LPCWSTR str, UINT count, const INT *dx )
{
PHYSDEV emfdev = get_emfdev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pExtTextOut );
return (emfdev->funcs->pExtTextOut( emfdev, x, y, flags, rect, str, count, dx ) &&
next->funcs->pExtTextOut( next, x, y, flags, rect, str, count, dx ));
}
static const struct gdi_dc_funcs emfpath_driver =
{
@ -700,7 +687,7 @@ static const struct gdi_dc_funcs emfpath_driver =
NULL, /* pExtEscape */
NULL, /* pExtFloodFill */
NULL, /* pExtSelectClipRgn */
emfpathdrv_ExtTextOut, /* pExtTextOut */
NULL, /* pExtTextOut */
NULL, /* pFillPath */
NULL, /* pFillRgn */
NULL, /* pFlattenPath */

View File

@ -929,15 +929,24 @@ BOOL CDECL EMFDRV_InvertRgn( PHYSDEV dev, HRGN hrgn )
BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect,
LPCWSTR str, UINT count, const INT *lpDx )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
/* FIXME: update bounding rect */
return TRUE;
}
/**********************************************************************
* EMFDC_ExtTextOut
*/
BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *lprect,
const WCHAR *str, UINT count, const INT *lpDx )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMREXTTEXTOUTW *pemr;
DWORD nSize;
BOOL ret;
int textHeight = 0;
int textWidth = 0;
const UINT textAlign = dc->attr->text_align;
const INT graphicsMode = dc->attr->graphics_mode;
const UINT textAlign = dc_attr->text_align;
const INT graphicsMode = dc_attr->graphics_mode;
FLOAT exScale, eyScale;
nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT);
@ -948,14 +957,14 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
if (graphicsMode == GM_COMPATIBLE)
{
const INT horzSize = GetDeviceCaps( dev->hdc, HORZSIZE );
const INT horzRes = GetDeviceCaps( dev->hdc, HORZRES );
const INT vertSize = GetDeviceCaps( dev->hdc, VERTSIZE );
const INT vertRes = GetDeviceCaps( dev->hdc, VERTRES );
const INT horzSize = GetDeviceCaps( emf->dev.hdc, HORZSIZE );
const INT horzRes = GetDeviceCaps( emf->dev.hdc, HORZRES );
const INT vertSize = GetDeviceCaps( emf->dev.hdc, VERTSIZE );
const INT vertRes = GetDeviceCaps( emf->dev.hdc, VERTRES );
SIZE wndext, vportext;
GetViewportExtEx( dev->hdc, &vportext );
GetWindowExtEx( dev->hdc, &wndext );
GetViewportExtEx( emf->dev.hdc, &vportext );
GetWindowExtEx( emf->dev.hdc, &wndext );
exScale = 100.0 * ((FLOAT)horzSize / (FLOAT)horzRes) /
((FLOAT)wndext.cx / (FLOAT)vportext.cx);
eyScale = 100.0 * ((FLOAT)vertSize / (FLOAT)vertRes) /
@ -996,7 +1005,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
for (i = 0; i < count; i++) {
textWidth += lpDx[i];
}
if (GetTextExtentPoint32W( dev->hdc, str, count, &strSize ))
if (GetTextExtentPoint32W( emf->dev.hdc, str, count, &strSize ))
textHeight = strSize.cy;
}
else {
@ -1004,7 +1013,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx);
SIZE charSize;
for (i = 0; i < count; i++) {
if (GetTextExtentPoint32W( dev->hdc, str + i, 1, &charSize )) {
if (GetTextExtentPoint32W( emf->dev.hdc, str + i, 1, &charSize )) {
dx[i] = charSize.cx;
textWidth += charSize.cx;
textHeight = max(textHeight, charSize.cy);
@ -1012,7 +1021,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
}
}
if (physDev->path)
if (emf->path)
{
pemr->rclBounds.left = pemr->rclBounds.top = 0;
pemr->rclBounds.right = pemr->rclBounds.bottom = -1;
@ -1040,7 +1049,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
switch (textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE)) {
case TA_BASELINE: {
TEXTMETRICW tm;
if (!GetTextMetricsW( dev->hdc, &tm ))
if (!GetTextMetricsW( emf->dev.hdc, &tm ))
tm.tmDescent = 0;
/* Play safe here... it's better to have a bounding box */
/* that is too big than too small. */
@ -1058,10 +1067,10 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
pemr->rclBounds.bottom = y + textHeight + 1;
}
}
EMFDRV_UpdateBBox( dev, &pemr->rclBounds );
EMFDRV_UpdateBBox( &emf->dev, &pemr->rclBounds );
no_bounds:
ret = EMFDRV_WriteRecord( dev, &pemr->emr );
ret = EMFDRV_WriteRecord( &emf->dev, &pemr->emr );
HeapFree( GetProcessHeap(), 0, pemr );
return ret;
}

View File

@ -5895,7 +5895,7 @@ static inline int get_line_width( DC *dc, int metric_size )
}
/***********************************************************************
* ExtTextOutW (GDI32.@)
* NtGdiExtTextOutW (win32u.@)
*
* Draws text using the currently selected font, background color, and text color.
*
@ -5924,8 +5924,8 @@ static inline int get_line_width( DC *dc, int metric_size )
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx )
BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lprect,
const WCHAR *str, UINT count, const INT *lpDx, DWORD cp )
{
BOOL ret = FALSE;
LPWSTR reordered_str = (LPWSTR)str;

View File

@ -47,6 +47,8 @@ extern BOOL METADC_Arc( HDC hdc, INT left, INT top, INT right, INT bottom,
extern BOOL METADC_Chord( HDC hdc, INT left, INT top, INT right, INT bottom, INT xstart,
INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL METADC_Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL METADC_ExtTextOut( HDC hdc, INT x, INT y, UINT flags, const RECT *rect,
const WCHAR *str, UINT count, const INT *dx ) DECLSPEC_HIDDEN;
extern BOOL METADC_LineTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL METADC_MoveTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL METADC_Pie( HDC hdc, INT left, INT top, INT right, INT bottom,
@ -67,6 +69,8 @@ extern BOOL EMFDC_ArcChordPie( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT yend, DWORD type ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_Ellipse( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *rect,
const WCHAR *str, UINT count, const INT *dx ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_LineTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_MoveTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyBezier( DC_ATTR *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;

View File

@ -360,3 +360,18 @@ BOOL WINAPI PolyDraw( HDC hdc, const POINT *points, const BYTE *types, DWORD cou
if (dc_attr->emf && !EMFDC_PolyDraw( dc_attr, points, types, count )) return FALSE;
return NtGdiPolyDraw( hdc, points, types, count );
}
/***********************************************************************
* ExtTextOutW (GDI32.@)
*/
BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *rect,
const WCHAR *str, UINT count, const INT *dx )
{
DC_ATTR *dc_attr;
if (is_meta_dc( hdc )) return METADC_ExtTextOut( hdc, x, y, flags, rect, str, count, dx );
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_ExtTextOut( dc_attr, x, y, flags, rect, str, count, dx ))
return FALSE;
return NtGdiExtTextOutW( hdc, x, y, flags, rect, str, count, dx, 0 );
}

View File

@ -125,7 +125,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_ExtEscape, /* pExtEscape */
MFDRV_ExtFloodFill, /* pExtFloodFill */
MFDRV_ExtSelectClipRgn, /* pExtSelectClipRgn */
MFDRV_ExtTextOut, /* pExtTextOut */
NULL, /* pExtTextOut */
MFDRV_FillPath, /* pFillPath */
MFDRV_FillRgn, /* pFillRgn */
MFDRV_FlattenPath, /* pFlattenPath */

View File

@ -81,8 +81,6 @@ extern BOOL CDECL MFDRV_EndPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT fillType ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect, LPCWSTR str,
UINT count, const INT *lpDx ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_FillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_FlattenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;

View File

@ -31,11 +31,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(metafile);
/******************************************************************
* MFDRV_MetaExtTextOut
* metadc_text
*/
static BOOL MFDRV_MetaExtTextOut( PHYSDEV dev, short x, short y, UINT16 flags,
const RECT16 *rect, LPCSTR str, short count,
const INT16 *lpDx)
static BOOL metadc_text( HDC hdc, short x, short y, UINT16 flags,
const RECT16 *rect, LPCSTR str, short count,
const INT16 *lpDx)
{
BOOL ret;
DWORD len;
@ -62,7 +62,7 @@ static BOOL MFDRV_MetaExtTextOut( PHYSDEV dev, short x, short y, UINT16 flags,
if (lpDx)
memcpy(mr->rdParm + (isrect ? 8 : 4) + ((count + 1) >> 1),lpDx,
count*sizeof(INT16));
ret = MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
ret = metadc_record( hdc, mr, mr->rdSize * 2);
HeapFree( GetProcessHeap(), 0, mr);
return ret;
}
@ -70,10 +70,10 @@ static BOOL MFDRV_MetaExtTextOut( PHYSDEV dev, short x, short y, UINT16 flags,
/***********************************************************************
* MFDRV_ExtTextOut
* METADC_ExtTextOut
*/
BOOL CDECL MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx )
BOOL METADC_ExtTextOut( HDC hdc, INT x, INT y, UINT flags, const RECT *lprect,
const WCHAR *str, UINT count, const INT *lpDx )
{
RECT16 rect16;
LPINT16 lpdx16 = NULL;
@ -82,7 +82,7 @@ BOOL CDECL MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
LPSTR ascii;
DWORD len;
CHARSETINFO csi;
int charset = GetTextCharset( dev->hdc );
int charset = GetTextCharset( hdc );
UINT cp = CP_ACP;
if(TranslateCharsetInfo(ULongToPtr(charset), &csi, TCI_SRCCHARSET))
@ -146,7 +146,7 @@ BOOL CDECL MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
lpdx16[i++] = lpDx[j++];
}
ret = MFDRV_MetaExtTextOut(dev,x,y,flags,lprect?&rect16:NULL,ascii,len,lpdx16);
ret = metadc_text( hdc, x, y, flags, lprect ? &rect16 : NULL, ascii, len, lpdx16 );
HeapFree( GetProcessHeap(), 0, ascii );
HeapFree( GetProcessHeap(), 0, lpdx16 );
return ret;

View File

@ -160,6 +160,8 @@ BOOL WINAPI NtGdiGetDCDword( HDC hdc, UINT method, DWORD *result );
BOOL WINAPI NtGdiGetDCPoint( HDC hdc, UINT method, POINT *result );
INT WINAPI NtGdiGetDeviceCaps( HDC hdc, INT cap );
BOOL WINAPI NtGdiGetDeviceGammaRamp( HDC hdc, void *ptr );
BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *rect,
const WCHAR *str, UINT count, const INT *dx, DWORD cp );
BOOL WINAPI NtGdiGetMiterLimit( HDC hdc, FLOAT *limit );
COLORREF WINAPI NtGdiGetNearestColor( HDC hdc, COLORREF color );
UINT WINAPI NtGdiGetNearestPaletteIndex( HPALETTE hpalette, COLORREF color );