Commit 3433676f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Move a bunch of common code from the drivers into gdi.

parent 86892164
......@@ -78,7 +78,7 @@ extern BOOL EMFDRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color,
extern INT EMFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode );
extern BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y,
UINT flags, const RECT *lprect, LPCWSTR str,
UINT count, const INT *lpDx, INT breakExtra );
UINT count, const INT *lpDx );
extern BOOL EMFDRV_FillPath( PHYSDEV dev );
extern BOOL EMFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush );
extern BOOL EMFDRV_FlattenPath( PHYSDEV dev );
......
......@@ -710,7 +710,7 @@ EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
*/
BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count,
const INT *lpDx, INT breakExtra )
const INT *lpDx )
{
EMREXTTEXTOUTW *pemr;
DWORD nSize;
......
......@@ -82,7 +82,7 @@ typedef struct tagDC_FUNCS
INT (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
BOOL (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
INT (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
BOOL (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*,INT);
BOOL (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
BOOL (*pFillPath)(PHYSDEV);
BOOL (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
BOOL (*pFlattenPath)(PHYSDEV);
......
......@@ -84,7 +84,7 @@ extern BOOL MFDRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT
extern INT MFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode );
extern BOOL MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y,
UINT flags, const RECT *lprect, LPCWSTR str,
UINT count, const INT *lpDx, INT breakExtra );
UINT count, const INT *lpDx );
extern BOOL MFDRV_FillPath( PHYSDEV dev );
extern BOOL MFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush );
extern BOOL MFDRV_FlattenPath( PHYSDEV dev );
......
......@@ -74,7 +74,7 @@ static BOOL MFDRV_MetaExtTextOut( PHYSDEV dev, short x, short y, UINT16 flags,
BOOL
MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count,
const INT *lpDx, INT breakExtra )
const INT *lpDx )
{
RECT16 rect16;
LPINT16 lpdx16 = NULL;
......
......@@ -338,14 +338,12 @@ BOOL TTYDRV_DC_StretchBlt(TTYDRV_PDEVICE *physDevDst, INT xDst, INT yDst,
*/
BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
const RECT *lpRect, LPCWSTR str, UINT count,
const INT *lpDx, INT breakExtra )
const INT *lpDx )
{
#ifdef WINE_CURSES
INT row, col;
LPSTR ascii;
DWORD len;
POINT pt;
UINT text_align = GetTextAlign( physDev->hdc );
TRACE("(%p, %d, %d, 0x%08x, %p, %s, %d, %p)\n",
physDev->hdc, x, y, flags, lpRect, debugstr_wn(str, count), count, lpDx);
......@@ -353,14 +351,8 @@ BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
if(!physDev->window)
return FALSE;
pt.x = x;
pt.y = y;
/* FIXME: Is this really correct? */
if(text_align & TA_UPDATECP) GetCurrentPositionEx( physDev->hdc, &pt );
LPtoDP( physDev->hdc, &pt, 1 );
row = (physDev->org.y + pt.y) / physDev->cellHeight;
col = (physDev->org.x + pt.x) / physDev->cellWidth;
row = (physDev->org.y + y) / physDev->cellHeight;
col = (physDev->org.x + x) / physDev->cellWidth;
len = WideCharToMultiByte( CP_ACP, 0, str, count, NULL, 0, NULL, NULL );
ascii = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, str, count, ascii, len, NULL, NULL );
......@@ -368,14 +360,6 @@ BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
HeapFree( GetProcessHeap(), 0, ascii );
wrefresh(physDev->window);
if(text_align & TA_UPDATECP)
{
pt.x += count * physDev->cellWidth;
pt.y += physDev->cellHeight;
DPtoLP( physDev->hdc, &pt, 1 );
MoveToEx( physDev->hdc, pt.x, pt.y, NULL );
}
return TRUE;
#else /* defined(WINE_CURSES) */
FIXME("(%p, %d, %d, 0x%08x, %p, %s, %d, %p): stub\n",
......
......@@ -76,7 +76,7 @@ extern BOOL TTYDRV_DC_BitBlt(TTYDRV_PDEVICE *physDevDst, INT xDst, INT yDst, INT
extern BOOL TTYDRV_DC_Chord(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend);
extern BOOL TTYDRV_DC_Ellipse(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom);
extern BOOL TTYDRV_DC_ExtFloodFill(TTYDRV_PDEVICE *physDev, INT x, INT y, COLORREF color, UINT fillType);
extern BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags, const RECT *lpRect, LPCWSTR str, UINT count, const INT *lpDx, INT breakExtra);
extern BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags, const RECT *lpRect, LPCWSTR str, UINT count, const INT *lpDx);
extern BOOL TTYDRV_DC_GetCharWidth(TTYDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar, LPINT buffer);
extern COLORREF TTYDRV_DC_GetPixel(TTYDRV_PDEVICE *physDev, INT x, INT y);
......
......@@ -8,7 +8,7 @@
@ cdecl Ellipse(ptr long long long long) TTYDRV_DC_Ellipse
@ cdecl ExtEscape(ptr long long ptr long ptr) TTYDRV_ExtEscape
@ cdecl ExtFloodFill(ptr long long long long) TTYDRV_DC_ExtFloodFill
@ cdecl ExtTextOut(ptr long long long ptr ptr long ptr long) TTYDRV_DC_ExtTextOut
@ cdecl ExtTextOut(ptr long long long ptr ptr long ptr) TTYDRV_DC_ExtTextOut
@ cdecl GetBitmapBits(long ptr long) TTYDRV_GetBitmapBits
@ cdecl GetCharWidth(ptr long long ptr) TTYDRV_DC_GetCharWidth
@ cdecl GetDCOrgEx(ptr ptr) TTYDRV_GetDCOrgEx
......
......@@ -469,7 +469,7 @@ extern INT PSDRV_EndDoc( PSDRV_PDEVICE *physDev );
extern INT PSDRV_EndPage( PSDRV_PDEVICE *physDev );
extern BOOL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count,
const INT *lpDx, INT breakExtra );
const INT *lpDx );
extern BOOL PSDRV_GetCharWidth( PSDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar,
LPINT buffer );
extern BOOL PSDRV_GetTextExtentPoint( PSDRV_PDEVICE *physDev, LPCWSTR str, INT count,
......
......@@ -40,12 +40,11 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
*/
BOOL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count,
const INT *lpDx, INT breakExtra )
const INT *lpDx )
{
BOOL bResult = TRUE;
BOOL bClipped = FALSE;
BOOL bOpaque = FALSE;
RECT rect;
TRACE("(x=%d, y=%d, flags=0x%08x, str=%s, count=%d, lpDx=%p)\n", x, y,
flags, debugstr_wn(str, count), count, lpDx);
......@@ -58,11 +57,9 @@ BOOL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
/* set clipping and/or draw background */
if ((flags & (ETO_CLIPPED | ETO_OPAQUE)) && (lprect != NULL))
{
rect = *lprect;
LPtoDP( physDev->hdc, (POINT *)&rect, 2 );
PSDRV_WriteGSave(physDev);
PSDRV_WriteRectangle(physDev, rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top);
PSDRV_WriteRectangle(physDev, lprect->left, lprect->top, lprect->right - lprect->left,
lprect->bottom - lprect->top);
if (flags & ETO_OPAQUE)
{
......@@ -97,14 +94,7 @@ BOOL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR str,
UINT count, BOOL bDrawBackground, const INT *lpDx)
{
SIZE sz;
TEXTMETRICW tm;
POINT pt;
INT ascent, descent;
WORD *glyphs = NULL;
UINT align = GetTextAlign( physDev->hdc );
INT char_extra;
INT *deltas = NULL;
double cosEsc, sinEsc;
LOGFONTW lf;
......@@ -120,127 +110,12 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR
sinEsc = 0;
}
if(physDev->font.fontloc == Download) {
if(flags & ETO_GLYPH_INDEX)
glyphs = (LPWORD)str;
else {
glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WORD));
GetGlyphIndicesW(physDev->hdc, str, count, glyphs, 0);
}
}
pt.x = x;
pt.y = y;
if(align & TA_UPDATECP) GetCurrentPositionEx( physDev->hdc, &pt );
LPtoDP(physDev->hdc, &pt, 1);
x = pt.x;
y = pt.y;
if(physDev->font.fontloc == Download)
GetTextExtentPointI(physDev->hdc, glyphs, count, &sz);
else
GetTextExtentPoint32W(physDev->hdc, str, count, &sz);
if((char_extra = GetTextCharacterExtra(physDev->hdc)) != 0) {
UINT i;
SIZE tmpsz;
deltas = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
for(i = 0; i < count; i++) {
if(lpDx)
deltas[i] = lpDx[i] + char_extra;
else {
if(physDev->font.fontloc == Download)
GetTextExtentPointI(physDev->hdc, glyphs + i, 1, &tmpsz);
else
GetTextExtentPoint32W(physDev->hdc, str + i, 1, &tmpsz);
deltas[i] = tmpsz.cx;
}
}
} else if(lpDx)
deltas = (INT*)lpDx;
if(deltas) {
SIZE tmpsz;
UINT i;
/* Get the width of the last char and add on all the offsets */
if(physDev->font.fontloc == Download)
GetTextExtentPointI(physDev->hdc, glyphs + count - 1, 1, &tmpsz);
else
GetTextExtentPoint32W(physDev->hdc, str + count - 1, 1, &tmpsz);
for(i = 0; i < count-1; i++)
tmpsz.cx += deltas[i];
sz.cx = tmpsz.cx; /* sz.cy remains untouched */
}
sz.cx = PSDRV_XWStoDS(physDev, sz.cx);
sz.cy = PSDRV_YWStoDS(physDev, sz.cy);
GetTextMetricsW(physDev->hdc, &tm);
ascent = abs(PSDRV_YWStoDS(physDev, tm.tmAscent));
descent = abs(PSDRV_YWStoDS(physDev, tm.tmDescent));
TRACE("textAlign = %x\n", align);
switch(align & (TA_LEFT | TA_CENTER | TA_RIGHT) ) {
case TA_LEFT:
if(align & TA_UPDATECP)
{
POINT pt;
pt.x = x + sz.cx * cosEsc;
pt.y = y - sz.cx * sinEsc;
DPtoLP( physDev->hdc, &pt, 1 );
MoveToEx( physDev->hdc, pt.x, pt.y, NULL );
}
break;
case TA_CENTER:
x -= sz.cx * cosEsc / 2;
y += sz.cx * sinEsc / 2;
break;
case TA_RIGHT:
x -= sz.cx * cosEsc;
y += sz.cx * sinEsc;
if(align & TA_UPDATECP)
{
POINT pt;
pt.x = x;
pt.y = y;
DPtoLP( physDev->hdc, &pt, 1 );
MoveToEx( physDev->hdc, pt.x, pt.y, NULL );
}
break;
}
switch(align & (TA_TOP | TA_BASELINE | TA_BOTTOM) ) {
case TA_TOP:
y += ascent * cosEsc;
x += ascent * sinEsc;
break;
case TA_BASELINE:
break;
case TA_BOTTOM:
y -= descent * cosEsc;
x -= descent * sinEsc;
break;
}
if ((GetBkMode( physDev->hdc ) != TRANSPARENT) && bDrawBackground)
{
PSDRV_WriteGSave(physDev);
PSDRV_WriteNewPath(physDev);
PSDRV_WriteRectangle(physDev, x, y - ascent, sz.cx,
ascent + descent);
PSDRV_WriteSetColor(physDev, &physDev->bkColor);
PSDRV_WriteFill(physDev);
PSDRV_WriteGRestore(physDev);
}
glyphs = (LPWORD)str;
PSDRV_WriteMoveTo(physDev, x, y);
if(!deltas) {
if(!lpDx) {
if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(physDev, glyphs, count);
else
......@@ -252,87 +127,20 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR
float cos_theta = cos(physDev->font.escapement * M_PI / 1800.0);
float sin_theta = sin(physDev->font.escapement * M_PI / 1800.0);
for(i = 0; i < count-1; i++) {
TRACE("lpDx[%d] = %d\n", i, deltas[i]);
TRACE("lpDx[%d] = %d\n", i, lpDx[i]);
if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1);
else
PSDRV_WriteBuiltinGlyphShow(physDev, str + i, 1);
dx += deltas[i] * cos_theta;
dy -= deltas[i] * sin_theta;
PSDRV_WriteMoveTo(physDev, x + PSDRV_XWStoDS(physDev, dx),
y + PSDRV_YWStoDS(physDev, dy));
dx += lpDx[i] * cos_theta;
dy -= lpDx[i] * sin_theta;
PSDRV_WriteMoveTo(physDev, x + dx, y + dy);
}
if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1);
else
PSDRV_WriteBuiltinGlyphShow(physDev, str + i, 1);
if(deltas != lpDx)
HeapFree(GetProcessHeap(), 0, deltas);
}
/*
* Underline and strikeout attributes.
*/
if ((tm.tmUnderlined) || (tm.tmStruckOut)) {
/* Get the thickness and the position for the underline attribute */
/* We'll use the same thickness for the strikeout attribute */
INT escapement = physDev->font.escapement;
/* Do the underline */
if (tm.tmUnderlined) {
PSDRV_WriteNewPath(physDev); /* will be closed by WriteRectangle */
if (escapement != 0) /* rotated text */
{
PSDRV_WriteGSave(physDev); /* save the graphics state */
PSDRV_WriteMoveTo(physDev, x, y); /* move to the start */
/* temporarily rotate the coord system */
PSDRV_WriteRotate(physDev, -escapement/10);
/* draw the underline relative to the starting point */
PSDRV_WriteRRectangle(physDev, 0, -physDev->font.underlinePosition,
sz.cx, physDev->font.underlineThickness);
}
else
PSDRV_WriteRectangle(physDev, x, y - physDev->font.underlinePosition,
sz.cx, physDev->font.underlineThickness);
PSDRV_WriteFill(physDev);
if (escapement != 0) /* rotated text */
PSDRV_WriteGRestore(physDev); /* restore the graphics state */
}
/* Do the strikeout */
if (tm.tmStruckOut) {
PSDRV_WriteNewPath(physDev); /* will be closed by WriteRectangle */
if (escapement != 0) /* rotated text */
{
PSDRV_WriteGSave(physDev); /* save the graphics state */
PSDRV_WriteMoveTo(physDev, x, y); /* move to the start */
/* temporarily rotate the coord system */
PSDRV_WriteRotate(physDev, -escapement/10);
/* draw the line relative to the starting point */
PSDRV_WriteRRectangle(physDev, 0, -physDev->font.strikeoutPosition,
sz.cx, physDev->font.strikeoutThickness);
}
else
PSDRV_WriteRectangle(physDev, x, y - physDev->font.strikeoutPosition,
sz.cx, physDev->font.strikeoutThickness);
PSDRV_WriteFill(physDev);
if (escapement != 0) /* rotated text */
PSDRV_WriteGRestore(physDev); /* restore the graphics state */
}
}
if(glyphs && glyphs != str) HeapFree(GetProcessHeap(), 0, glyphs);
return TRUE;
}
......@@ -11,7 +11,7 @@
@ cdecl EnumDeviceFonts(ptr ptr ptr long) PSDRV_EnumDeviceFonts
@ cdecl ExtDeviceMode(ptr long ptr ptr ptr ptr ptr long) PSDRV_ExtDeviceMode
@ cdecl ExtEscape(ptr long long ptr long ptr) PSDRV_ExtEscape
@ cdecl ExtTextOut(ptr long long long ptr ptr long ptr long) PSDRV_ExtTextOut
@ cdecl ExtTextOut(ptr long long long ptr ptr long ptr) PSDRV_ExtTextOut
@ cdecl GetCharWidth(ptr long long ptr) PSDRV_GetCharWidth
@ cdecl GetDeviceCaps(ptr long) PSDRV_GetDeviceCaps
@ cdecl GetTextExtentPoint(ptr ptr long ptr) PSDRV_GetTextExtentPoint
......
......@@ -15,7 +15,7 @@
@ cdecl EnumDeviceFonts(ptr ptr ptr long) X11DRV_EnumDeviceFonts
@ cdecl ExtEscape(ptr long long ptr long ptr) X11DRV_ExtEscape
@ cdecl ExtFloodFill(ptr long long long long) X11DRV_ExtFloodFill
@ cdecl ExtTextOut(ptr long long long ptr ptr long ptr long) X11DRV_ExtTextOut
@ cdecl ExtTextOut(ptr long long long ptr ptr long ptr) X11DRV_ExtTextOut
@ cdecl GetBitmapBits(long ptr long) X11DRV_GetBitmapBits
@ cdecl GetCharWidth(ptr long long ptr) X11DRV_GetCharWidth
@ cdecl GetDCOrgEx(ptr ptr) X11DRV_GetDCOrgEx
......
......@@ -211,7 +211,7 @@ extern BOOL X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y,
COLORREF color, UINT fillType );
extern BOOL X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y,
UINT flags, const RECT *lprect,
LPCWSTR str, UINT count, const INT *lpDx, INT breakExtra );
LPCWSTR str, UINT count, const INT *lpDx );
extern LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count );
extern void X11DRV_SetDeviceClipping( X11DRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn );
extern INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest,
......@@ -271,7 +271,7 @@ extern BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE*, HFONT);
extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE*);
extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR wstr,
UINT count, const INT *lpDx, INT breakExtra);
UINT count, const INT *lpDx);
extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev);
extern XVisualInfo *X11DRV_setup_opengl_visual(Display *display);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment