From 50a783f7345cb36272fdc242d07addc71f6bdc59 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 20 Jan 2004 22:04:00 +0000 Subject: [PATCH] Get rid of some direct accesses to the DC structure from outside GDI. --- dlls/wineps/builtin.c | 23 ++++++++++++++--------- dlls/wineps/ps.c | 9 ++++++--- dlls/x11drv/bitblt.c | 34 +++++++++++----------------------- dlls/x11drv/dib.c | 36 ++++++++++++++++++------------------ dlls/x11drv/graphics.c | 5 ++--- dlls/x11drv/palette.c | 5 ++--- dlls/x11drv/text.c | 30 +++++++++++++++--------------- dlls/x11drv/xfont.c | 10 +++++----- dlls/x11drv/xrender.c | 41 ++++++++++++++++++++++------------------- 9 files changed, 95 insertions(+), 98 deletions(-) diff --git a/dlls/wineps/builtin.c b/dlls/wineps/builtin.c index 378d5150104..863acc57aec 100644 --- a/dlls/wineps/builtin.c +++ b/dlls/wineps/builtin.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "windef.h" @@ -28,7 +29,6 @@ #include "wingdi.h" #include "winspool.h" -#include "gdi.h" #include "psdrv.h" #include "wine/debug.h" @@ -257,7 +257,6 @@ BOOL PSDRV_WriteBuiltinGlyphShow(PSDRV_PDEVICE *physDev, LPCWSTR str, INT count) */ BOOL PSDRV_GetTextMetrics(PSDRV_PDEVICE *physDev, TEXTMETRICW *metrics) { - assert(physDev->dc->gdiFont == 0); assert(physDev->font.fontloc == Builtin); memcpy(metrics, &(physDev->font.fontinfo.Builtin.tm), @@ -311,8 +310,8 @@ BOOL PSDRV_GetTextExtentPoint(PSDRV_PDEVICE *physDev, LPCWSTR str, INT count, LP { int i; float width = 0.0; + POINT pt[3]; - assert(physDev->dc->gdiFont == 0); assert(physDev->font.fontloc == Builtin); TRACE("%s %i\n", debugstr_wn(str, count), count); @@ -322,9 +321,16 @@ BOOL PSDRV_GetTextExtentPoint(PSDRV_PDEVICE *physDev, LPCWSTR str, INT count, LP width *= physDev->font.fontinfo.Builtin.scale; - size->cx = GDI_ROUND((FLOAT)width * physDev->dc->xformVport2World.eM11); - size->cy = GDI_ROUND((FLOAT)physDev->font.fontinfo.Builtin.tm.tmHeight * - physDev->dc->xformVport2World.eM22); + /* convert back to logical coords */ + pt[0].x = 0; + pt[0].y = 0; + pt[1].x = width; + pt[1].y = 0; + pt[2].x = 0; + pt[2].y = physDev->font.fontinfo.Builtin.tm.tmHeight; + DPtoLP( physDev->hdc, pt, 3 ); + size->cx = pt[1].x - pt[0].x; + size->cy = pt[2].y - pt[0].y; TRACE("cx=%li cy=%li\n", size->cx, size->cy); @@ -338,7 +344,6 @@ BOOL PSDRV_GetCharWidth(PSDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar, L { UINT i; - assert(physDev->dc->gdiFont == 0); assert(physDev->font.fontloc == Builtin); TRACE("U+%.4X U+%.4X\n", firstChar, lastChar); @@ -351,8 +356,8 @@ BOOL PSDRV_GetCharWidth(PSDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar, L for (i = firstChar; i <= lastChar; ++i) { - *buffer = GDI_ROUND(PSDRV_UVMetrics(i, physDev->font.fontinfo.Builtin.afm)->WX - * physDev->font.fontinfo.Builtin.scale); + *buffer = floor( PSDRV_UVMetrics(i, physDev->font.fontinfo.Builtin.afm)->WX + * physDev->font.fontinfo.Builtin.scale + 0.5 ); TRACE("U+%.4X: %i\n", i, *buffer); ++buffer; } diff --git a/dlls/wineps/ps.c b/dlls/wineps/ps.c index 42634b5f762..32185386038 100644 --- a/dlls/wineps/ps.c +++ b/dlls/wineps/ps.c @@ -21,10 +21,13 @@ #include #include #include +#include #define NONAMELESSUNION #define NONAMELESSSTRUCT -#include "gdi.h" +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" #include "psdrv.h" #include "winspool.h" #include "wine/debug.h" @@ -823,8 +826,8 @@ BOOL PSDRV_WriteDIBPatternDict(PSDRV_PDEVICE *physDev, BITMAPINFO *bmi, UINT usa sprintf(buf, start, w, h, w, h); PSDRV_WriteSpool(physDev, buf, strlen(buf)); PSDRV_WriteIndexColorSpaceBegin(physDev, 1); - map[0] = physDev->dc->textColor; - map[1] = physDev->dc->backgroundColor; + map[0] = GetTextColor( physDev->hdc ); + map[1] = GetBkColor( physDev->hdc ); PSDRV_WriteRGB(physDev, map, 2); PSDRV_WriteIndexColorSpaceEnd(physDev); ptr = buf; diff --git a/dlls/x11drv/bitblt.c b/dlls/x11drv/bitblt.c index add5e6516b7..ab58290637a 100644 --- a/dlls/x11drv/bitblt.c +++ b/dlls/x11drv/bitblt.c @@ -1126,13 +1126,15 @@ static int BITBLT_PutDstArea(X11DRV_PDEVICE *physDev, Pixmap pixmap, RECT *visRe * Get the source and destination visible rectangles for StretchBlt(). * Return FALSE if one of the rectangles is empty. */ -static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, +static BOOL BITBLT_GetVisRectangles( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst, INT widthDst, INT heightDst, - DC *dcSrc, INT xSrc, INT ySrc, + X11DRV_PDEVICE *physDevSrc, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, RECT *visRectSrc, RECT *visRectDst ) { RECT rect, clipRect; + DC *dcSrc = physDevSrc ? physDevSrc->dc : NULL; + DC *dcDst = physDevDst->dc; /* Get the destination visible rectangle */ @@ -1147,7 +1149,7 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, /* Get the source visible rectangle */ - if (!dcSrc) return TRUE; + if (!physDevSrc) return TRUE; rect.left = xSrc; rect.top = ySrc; rect.right = xSrc + widthSrc; @@ -1229,8 +1231,6 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT Pixmap pixmaps[3] = { 0, 0, 0 }; /* pixmaps for DST, SRC, TMP */ GC tmpGC = 0; POINT pts[2]; - DC *dcSrc = physDevSrc ? physDevSrc->dc : NULL; - DC *dcDst = physDevDst->dc; /* compensate for off-by-one shifting for negative widths and heights */ if (widthDst < 0) @@ -1245,7 +1245,7 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT usePat = (((rop >> 4) & 0x0f0000) != (rop & 0x0f0000)); useSrc = (((rop >> 2) & 0x330000) != (rop & 0x330000)); useDst = (((rop >> 1) & 0x550000) != (rop & 0x550000)); - if (!dcSrc && useSrc) return FALSE; + if (!physDevSrc && useSrc) return FALSE; /* Map the coordinates to device coords */ @@ -1259,11 +1259,6 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT widthDst = pts[1].x - pts[0].x; heightDst = pts[1].y - pts[0].y; - TRACE(" vportdst=%d,%d-%d,%d wnddst=%d,%d-%d,%d\n", - dcDst->vportOrgX, dcDst->vportOrgY, - dcDst->vportExtX, dcDst->vportExtY, - dcDst->wndOrgX, dcDst->wndOrgY, - dcDst->wndExtX, dcDst->wndExtY ); TRACE(" rectdst=%d,%d-%d,%d orgdst=%ld,%ld\n", xDst, yDst, widthDst, heightDst, physDevDst->org.x, physDevDst->org.y ); @@ -1281,16 +1276,11 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT heightSrc = pts[1].y - pts[0].y; fStretch = (widthSrc != widthDst) || (heightSrc != heightDst); - TRACE(" vportsrc=%d,%d-%d,%d wndsrc=%d,%d-%d,%d\n", - dcSrc->vportOrgX, dcSrc->vportOrgY, - dcSrc->vportExtX, dcSrc->vportExtY, - dcSrc->wndOrgX, dcSrc->wndOrgY, - dcSrc->wndExtX, dcSrc->wndExtY ); TRACE(" rectsrc=%d,%d-%d,%d orgsrc=%ld,%ld\n", xSrc, ySrc, widthSrc, heightSrc, physDevSrc->org.x, physDevSrc->org.y ); - if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst, - dcSrc, xSrc, ySrc, widthSrc, heightSrc, + if (!BITBLT_GetVisRectangles( physDevDst, xDst, yDst, widthDst, heightDst, + physDevSrc, xSrc, ySrc, widthSrc, heightSrc, &visRectSrc, &visRectDst )) return TRUE; TRACE(" vissrc=%ld,%ld-%ld,%ld visdst=%ld,%ld-%ld,%ld\n", @@ -1302,7 +1292,7 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT else { fStretch = FALSE; - if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst, + if (!BITBLT_GetVisRectangles( physDevDst, xDst, yDst, widthDst, heightDst, NULL, 0, 0, 0, 0, NULL, &visRectDst )) return TRUE; TRACE(" vissrc=none visdst=%ld,%ld-%ld,%ld\n", @@ -1551,8 +1541,6 @@ BOOL X11DRV_BitBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst, BOOL result = FALSE; INT sSrc, sDst; RECT visRectDst, visRectSrc; - DC *dcSrc = physDevSrc ? physDevSrc->dc : NULL; - DC *dcDst = physDevDst->dc; if (((rop >> 16) & 0x55) == ((rop >> 17) & 0x55)) { /* FIXME: seems the ROP doesn't include destination; @@ -1588,8 +1576,8 @@ BOOL X11DRV_BitBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst, yDst = pts[0].y; /* Perform basic clipping */ - if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, width, height, - dcSrc, xSrc, ySrc, width, height, + if (!BITBLT_GetVisRectangles( physDevDst, xDst, yDst, width, height, + physDevSrc, xSrc, ySrc, width, height, &visRectSrc, &visRectDst )) goto END; diff --git a/dlls/x11drv/dib.c b/dlls/x11drv/dib.c index 425da5e2f23..0a69883dec1 100644 --- a/dlls/x11drv/dib.c +++ b/dlls/x11drv/dib.c @@ -39,7 +39,6 @@ #include "bitmap.h" #include "x11drv.h" #include "wine/debug.h" -#include "gdi.h" WINE_DEFAULT_DEBUG_CHANNEL(bitmap); WINE_DECLARE_DEBUG_CHANNEL(x11drv); @@ -3786,9 +3785,8 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, PALETTEENTRY palette[256]; BITMAPOBJ *bmp; int height; - DC *dc = physDev->dc; - GetPaletteEntries( dc->hPalette, 0, 256, palette ); + GetPaletteEntries( GetCurrentObject( physDev->hdc, OBJ_PAL ), 0, 256, palette ); if (!(bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return 0; @@ -4007,11 +4005,10 @@ void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physD DWORD width, DWORD height) { BITMAPOBJ *bmp; - DC *dcSrc = physDevSrc->dc; - DC *dcDst = physDevDst->dc; + HBITMAP hBitmap; int nColorMap = 0, *colorMap = NULL, aColorMap = FALSE; - TRACE("(%p,%p,%ld,%ld,%ld,%ld,%ld,%ld)\n", dcSrc, dcDst, + TRACE("(%p,%p,%ld,%ld,%ld,%ld,%ld,%ld)\n", physDevSrc->hdc, physDevDst->hdc, xSrc, ySrc, xDest, yDest, width, height); /* this function is meant as an optimization for BitBlt, * not to be called otherwise */ @@ -4020,10 +4017,11 @@ void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physD return; } - bmp = (BITMAPOBJ *)GDI_GetObjPtr( dcSrc->hBitmap, BITMAP_MAGIC ); + hBitmap = GetCurrentObject( physDevSrc->hdc, OBJ_BITMAP ); + bmp = (BITMAPOBJ *)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC ); if (!(bmp && bmp->dib)) { ERR("called for non-DIBSection!?\n"); - GDI_ReleaseObj( dcSrc->hBitmap ); + GDI_ReleaseObj( hBitmap ); return; } /* while BitBlt should already have made sure we only get @@ -4038,8 +4036,8 @@ void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physD * DC's palette for color conversion (not the DIB color table) */ if (bmp->dib->dsBm.bmBitsPixel <= 8) { X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib; - if ((!dcSrc->hPalette) || - (dcSrc->hPalette == GetStockObject(DEFAULT_PALETTE))) { + HPALETTE hPalette = GetCurrentObject( physDevSrc->hdc, OBJ_PAL ); + if (!hPalette || (hPalette == GetStockObject(DEFAULT_PALETTE))) { /* HACK: no palette has been set in the source DC, * use the DIB colormap instead - this is necessary in some * cases since we need to do depth conversion in some places @@ -4063,7 +4061,7 @@ void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physD if (aColorMap) HeapFree(GetProcessHeap(), 0, colorMap); } - GDI_ReleaseObj( dcSrc->hBitmap ); + GDI_ReleaseObj( hBitmap ); } /*********************************************************************** @@ -4418,7 +4416,7 @@ void X11DRV_UnlockDIBSection2(HBITMAP hBmp, BOOL commit) INT X11DRV_CoerceDIBSection(X11DRV_PDEVICE *physDev, INT req, BOOL lossy) { if (!physDev) return DIB_Status_None; - return X11DRV_CoerceDIBSection2( physDev->dc->hBitmap, req, lossy ); + return X11DRV_CoerceDIBSection2( GetCurrentObject( physDev->hdc, OBJ_BITMAP ), req, lossy ); } /*********************************************************************** @@ -4429,7 +4427,7 @@ INT X11DRV_LockDIBSection(X11DRV_PDEVICE *physDev, INT req, BOOL lossy) if (!physDev) return DIB_Status_None; if (GetObjectType( physDev->hdc ) != OBJ_MEMDC) return DIB_Status_None; - return X11DRV_LockDIBSection2( physDev->dc->hBitmap, req, lossy ); + return X11DRV_LockDIBSection2( GetCurrentObject( physDev->hdc, OBJ_BITMAP ), req, lossy ); } /*********************************************************************** @@ -4440,7 +4438,7 @@ void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev, BOOL commit) if (!physDev) return; if (GetObjectType( physDev->hdc ) != OBJ_MEMDC) return; - X11DRV_UnlockDIBSection2( physDev->dc->hBitmap, commit ); + X11DRV_UnlockDIBSection2( GetCurrentObject( physDev->hdc, OBJ_BITMAP ), commit ); } @@ -4710,8 +4708,9 @@ UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, c BITMAPOBJ * bmp; X11DRV_DIBSECTION *dib; UINT ret = 0; + HBITMAP hBitmap = GetCurrentObject( physDev->hdc, OBJ_BITMAP ); - if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( physDev->dc->hBitmap, BITMAP_MAGIC ))) return 0; + if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC ))) return 0; dib = (X11DRV_DIBSECTION *) bmp->dib; if (dib && dib->colorMap) { @@ -4729,7 +4728,7 @@ UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, c X11DRV_DIB_Unlock(bmp, TRUE); ret = end - start; } - GDI_ReleaseObj( physDev->dc->hBitmap ); + GDI_ReleaseObj( hBitmap ); return ret; } @@ -4741,8 +4740,9 @@ UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, R BITMAPOBJ * bmp; X11DRV_DIBSECTION *dib; UINT ret = 0; + HBITMAP hBitmap = GetCurrentObject( physDev->hdc, OBJ_BITMAP ); - if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( physDev->dc->hBitmap, BITMAP_MAGIC ))) return 0; + if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC ))) return 0; dib = (X11DRV_DIBSECTION *) bmp->dib; if (dib && dib->colorMap) { @@ -4757,7 +4757,7 @@ UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, R } ret = end-start; } - GDI_ReleaseObj( physDev->dc->hBitmap ); + GDI_ReleaseObj( hBitmap ); return ret; } diff --git a/dlls/x11drv/graphics.c b/dlls/x11drv/graphics.c index fa09a229f0e..d1f2466591c 100644 --- a/dlls/x11drv/graphics.c +++ b/dlls/x11drv/graphics.c @@ -38,7 +38,6 @@ #include "x11drv.h" #include "x11font.h" -#include "gdi.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(graphics); @@ -1285,12 +1284,12 @@ X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y, COLORREF color, { XImage *image; RECT rect; - DC *dc = physDev->dc; TRACE("X11DRV_ExtFloodFill %d,%d %06lx %d\n", x, y, color, fillType ); if (!PtVisible( physDev->hdc, x, y )) return FALSE; - if (GetRgnBox( dc->hGCClipRgn, &rect ) == ERROR) return FALSE; + if (GetClipBox( physDev->hdc, &rect ) == ERROR) return FALSE; + LPtoDP( physDev->hdc, (LPPOINT)&rect, 2 ); wine_tsx11_lock(); image = XGetImage( gdi_display, physDev->drawable, diff --git a/dlls/x11drv/palette.c b/dlls/x11drv/palette.c index f6001f2087d..58f5924a7ff 100644 --- a/dlls/x11drv/palette.c +++ b/dlls/x11drv/palette.c @@ -848,9 +848,8 @@ static int X11DRV_SysPaletteLookupPixel( COLORREF col, BOOL skipReserved ) */ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color ) { - DC *dc = physDev ? physDev->dc : NULL; WORD index = 0; - HPALETTE hPal = (dc)? dc->hPalette: GetStockObject(DEFAULT_PALETTE); + HPALETTE hPal = physDev ? GetCurrentObject(physDev->hdc, OBJ_PAL ) : GetStockObject(DEFAULT_PALETTE); unsigned char spec_type = color >> 24; PALETTEOBJ* palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC ); @@ -935,7 +934,7 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color ) { if( !palPtr->mapping ) - WARN("Palette %p is not realized\n", dc->hPalette); + WARN("Palette %p is not realized\n", hPal); switch(spec_type) /* we have to peruse DC and system palette */ { diff --git a/dlls/x11drv/text.c b/dlls/x11drv/text.c index 593ad5ee434..c8d0d14e5bc 100644 --- a/dlls/x11drv/text.c +++ b/dlls/x11drv/text.c @@ -58,6 +58,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, BOOL result = TRUE; POINT pt; DC *dc = physDev->dc; + UINT align = GetTextAlign( physDev->hdc ); if(dc->gdiFont) return X11DRV_XRender_ExtTextOut(physDev, x, y, flags, lprect, wstr, count, @@ -76,7 +77,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, lfStrikeOut = (pfo->fo_flags & FO_SYNTH_STRIKEOUT) ? 1 : 0; TRACE("hdc=%p df=%04x %d,%d %s, %d flags=%d lpDx=%p\n", - dc->hSelf, (UINT16)(physDev->font), x, y, + physDev->hdc, (UINT16)(physDev->font), x, y, debugstr_wn (wstr, count), count, flags, lpDx); /* some strings sent here end in a newline for whatever reason. I have no @@ -89,10 +90,11 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, lprect->right, lprect->bottom ); /* Setup coordinates */ - if (dc->textAlign & TA_UPDATECP) + if (align & TA_UPDATECP) { - x = dc->CursPosX; - y = dc->CursPosY; + GetCurrentPositionEx( physDev->hdc, &pt ); + x = pt.x; + y = pt.y; } if (flags & (ETO_OPAQUE | ETO_CLIPPED)) /* there's a rectangle */ @@ -167,26 +169,24 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, ywidth = pfo->lpX11Trans ? width * pfo->lpX11Trans->b / pfo->lpX11Trans->pixelsize : 0; - switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) + switch( align & (TA_LEFT | TA_RIGHT | TA_CENTER) ) { case TA_LEFT: - if (dc->textAlign & TA_UPDATECP) { + if (align & TA_UPDATECP) { pt.x = x + xwidth; pt.y = y - ywidth; DPtoLP(physDev->hdc, &pt, 1); - dc->CursPosX = pt.x; - dc->CursPosY = pt.y; + MoveToEx(physDev->hdc, pt.x, pt.y, NULL); } break; case TA_RIGHT: x -= xwidth; y += ywidth; - if (dc->textAlign & TA_UPDATECP) { + if (align & TA_UPDATECP) { pt.x = x; pt.y = y; DPtoLP(physDev->hdc, &pt, 1); - dc->CursPosX = pt.x; - dc->CursPosY = pt.y; + MoveToEx(physDev->hdc, pt.x, pt.y, NULL); } break; case TA_CENTER: @@ -195,7 +195,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, break; } - switch( dc->textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) + switch( align & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) { case TA_TOP: x -= pfo->lpX11Trans ? ascent * pfo->lpX11Trans->c / @@ -217,8 +217,8 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, if (flags & ETO_CLIPPED) { - SaveVisRgn16( HDC_16(dc->hSelf) ); - IntersectVisRect16( HDC_16(dc->hSelf), lprect->left, lprect->top, lprect->right, lprect->bottom ); + SaveVisRgn16( HDC_16(physDev->hdc) ); + IntersectVisRect16( HDC_16(physDev->hdc), lprect->left, lprect->top, lprect->right, lprect->bottom ); } /* Draw the text background if necessary */ @@ -410,7 +410,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, } wine_tsx11_unlock(); - if (flags & ETO_CLIPPED) RestoreVisRgn16( HDC_16(dc->hSelf) ); + if (flags & ETO_CLIPPED) RestoreVisRgn16( HDC_16(physDev->hdc) ); goto END; FAIL: diff --git a/dlls/x11drv/xfont.c b/dlls/x11drv/xfont.c index 8ac604f1af8..c7e6102552c 100644 --- a/dlls/x11drv/xfont.c +++ b/dlls/x11drv/xfont.c @@ -42,6 +42,7 @@ #include "winnls.h" #include "winreg.h" #include "x11font.h" +#include "gdi.h" #include "wine/library.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -3258,15 +3259,14 @@ HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont ) { LOGFONTW logfont; LOGFONT16 lf; - DC *dc = physDev->dc; - TRACE("dc=%p, hfont=%p\n", dc, hfont); + TRACE("hdc=%p, hfont=%p\n", physDev->hdc, hfont); if (!GetObjectW( hfont, sizeof(logfont), &logfont )) return HGDI_ERROR; - TRACE("dc->gdiFont = %p\n", dc->gdiFont); + TRACE("dc->gdiFont = %p\n", physDev->dc->gdiFont); - if(dc->gdiFont && using_client_side_fonts) { + if(physDev->dc->gdiFont && using_client_side_fonts) { X11DRV_XRender_SelectFont(physDev, hfont); return FALSE; } @@ -3302,7 +3302,7 @@ HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont ) } if (!lf.lfHeight) - lf.lfHeight = -(DEF_POINT_SIZE * GetDeviceCaps(dc->hSelf,LOGPIXELSY) + (72>>1)) / 72; + lf.lfHeight = -(DEF_POINT_SIZE * GetDeviceCaps(physDev->hdc,LOGPIXELSY) + (72>>1)) / 72; { /* Fixup aliases before passing to RealizeFont */ diff --git a/dlls/x11drv/xrender.c b/dlls/x11drv/xrender.c index 8eedca9c2f8..38fdacd47af 100644 --- a/dlls/x11drv/xrender.c +++ b/dlls/x11drv/xrender.c @@ -32,6 +32,8 @@ #include "winbase.h" #include "wownt32.h" #include "x11drv.h" +#include "gdi.h" +#include "wine/library.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -492,7 +494,7 @@ void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev) XFreePixmap(gdi_display, physDev->xrender->tile_xpm); if(physDev->xrender->pict) { - TRACE("freeing pict = %lx dc = %p\n", physDev->xrender->pict, physDev->dc); + TRACE("freeing pict = %lx dc = %p\n", physDev->xrender->pict, physDev->hdc); pXRenderFreePicture(gdi_display, physDev->xrender->pict); } wine_tsx11_unlock(); @@ -517,7 +519,7 @@ void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev) { if(physDev->xrender->pict) { TRACE("freeing pict %08lx from dc %p drawable %08lx\n", physDev->xrender->pict, - physDev->dc, physDev->drawable); + physDev->hdc, physDev->drawable); wine_tsx11_lock(); XFlush(gdi_display); pXRenderFreePicture(gdi_display, physDev->xrender->pict); @@ -951,6 +953,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag int textPixel, backgroundPixel; INT *deltas = NULL; INT char_extra; + UINT align = GetTextAlign( hdc ); TRACE("%p, %d, %d, %08x, %p, %s, %d, %p)\n", hdc, x, y, flags, lprect, debugstr_wn(wstr, count), count, lpDx); @@ -965,11 +968,13 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag if(lprect) TRACE("rect: %ld,%ld - %ld,%ld\n", lprect->left, lprect->top, lprect->right, lprect->bottom); - TRACE("align = %x bkmode = %x mapmode = %x\n", dc->textAlign, GetBkMode(hdc), dc->MapMode); + TRACE("align = %x bkmode = %x mapmode = %x\n", align, GetBkMode(hdc), dc->MapMode); - if(dc->textAlign & TA_UPDATECP) { - x = dc->CursPosX; - y = dc->CursPosY; + if(align & TA_UPDATECP) + { + GetCurrentPositionEx( hdc, &pt ); + x = pt.x; + y = pt.y; } GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf); @@ -994,7 +999,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag rc = *lprect; } - LPtoDP(physDev->hdc, (POINT*)&rc, 2); + LPtoDP(hdc, (POINT*)&rc, 2); if(rc.left > rc.right) {INT tmp = rc.left; rc.left = rc.right; rc.right = tmp;} if(rc.top > rc.bottom) {INT tmp = rc.top; rc.top = rc.bottom; rc.bottom = tmp;} @@ -1038,13 +1043,13 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag pt.x = x; pt.y = y; - LPtoDP(physDev->hdc, &pt, 1); + LPtoDP(hdc, &pt, 1); x = pt.x; y = pt.y; TRACE("real x,y %d,%d\n", x, y); - if((char_extra = GetTextCharacterExtra(physDev->hdc)) != 0) { + if((char_extra = GetTextCharacterExtra(hdc)) != 0) { INT i; SIZE tmpsz; deltas = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT)); @@ -1080,12 +1085,11 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag tm.tmDescent = X11DRV_YWStoDS(physDev, tm.tmDescent); switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) { case TA_LEFT: - if (dc->textAlign & TA_UPDATECP) { + if (align & TA_UPDATECP) { pt.x = x + xwidth; pt.y = y - ywidth; - DPtoLP(physDev->hdc, &pt, 1); - dc->CursPosX = pt.x; - dc->CursPosY = pt.y; + DPtoLP(hdc, &pt, 1); + MoveToEx(hdc, pt.x, pt.y, NULL); } break; @@ -1097,17 +1101,16 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag case TA_RIGHT: x -= xwidth; y += ywidth; - if (dc->textAlign & TA_UPDATECP) { + if (align & TA_UPDATECP) { pt.x = x; pt.y = y; - DPtoLP(physDev->hdc, &pt, 1); - dc->CursPosX = pt.x; - dc->CursPosY = pt.y; + DPtoLP(hdc, &pt, 1); + MoveToEx(hdc, pt.x, pt.y, NULL); } break; } - switch( dc->textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) { + switch( align & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) { case TA_TOP: y += tm.tmAscent * cosEsc; x += tm.tmAscent * sinEsc; @@ -1125,7 +1128,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag if (flags & ETO_CLIPPED) { SaveVisRgn16( HDC_16(hdc) ); - IntersectVisRect16( HDC_16(dc->hSelf), lprect->left, lprect->top, lprect->right, lprect->bottom ); + IntersectVisRect16( HDC_16(hdc), lprect->left, lprect->top, lprect->right, lprect->bottom ); } if(X11DRV_XRender_Installed) { -- 2.11.4.GIT