gdi32: Access several more properties directly from the DC.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-07-29 15:09:35 +01:00 committed by Alexandre Julliard
parent aa4934783f
commit 199ca9258a
5 changed files with 41 additions and 31 deletions

View File

@ -300,7 +300,7 @@ BOOL nulldrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
((src->width != dst->width) || (src->height != dst->height))) ((src->width != dst->width) || (src->height != dst->height)))
{ {
copy_bitmapinfo( src_info, dst_info ); copy_bitmapinfo( src_info, dst_info );
err = stretch_bits( src_info, src, dst_info, dst, &bits, GetStretchBltMode( dst_dev->hdc )); err = stretch_bits( src_info, src, dst_info, dst, &bits, dc_dst->stretchBltMode );
if (!err) err = dst_dev->funcs->pPutImage( dst_dev, 0, dst_info, &bits, src, dst, rop ); if (!err) err = dst_dev->funcs->pPutImage( dst_dev, 0, dst_info, &bits, src, dst, rop );
} }
@ -933,12 +933,12 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
src.log_y = ySrc; src.log_y = ySrc;
src.log_width = widthSrc; src.log_width = widthSrc;
src.log_height = heightSrc; src.log_height = heightSrc;
src.layout = GetLayout( hdcSrc ); src.layout = dcSrc->layout;
dst.log_x = xDst; dst.log_x = xDst;
dst.log_y = yDst; dst.log_y = yDst;
dst.log_width = widthDst; dst.log_width = widthDst;
dst.log_height = heightDst; dst.log_height = heightDst;
dst.layout = GetLayout( hdcDst ); dst.layout = dcDst->layout;
ret = !get_vis_rectangles( dcDst, &dst, dcSrc, &src ); ret = !get_vis_rectangles( dcDst, &dst, dcSrc, &src );
TRACE("src %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s dst %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s blend=%02x/%02x/%02x/%02x\n", TRACE("src %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s dst %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s blend=%02x/%02x/%02x/%02x\n",

View File

@ -600,7 +600,7 @@ INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT he
if (err == ERROR_TRANSFORM_NOT_SUPPORTED) if (err == ERROR_TRANSFORM_NOT_SUPPORTED)
{ {
copy_bitmapinfo( src_info, dst_info ); copy_bitmapinfo( src_info, dst_info );
err = stretch_bits( src_info, &src, dst_info, &dst, &src_bits, GetStretchBltMode( dev->hdc ) ); err = stretch_bits( src_info, &src, dst_info, &dst, &src_bits, dc->stretchBltMode );
if (!err) err = dev->funcs->pPutImage( dev, NULL, dst_info, &src_bits, &src, &dst, rop ); if (!err) err = dev->funcs->pPutImage( dev, NULL, dst_info, &src_bits, &src, &dst, rop );
} }
if (err) ret = 0; if (err) ret = 0;
@ -853,7 +853,7 @@ INT nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD cx, DWOR
dst.y = pt.y; dst.y = pt.y;
dst.width = cx; dst.width = cx;
dst.height = cy; dst.height = cy;
if (GetLayout( dev->hdc ) & LAYOUT_RTL) dst.x -= cx - 1; if (dc->layout & LAYOUT_RTL) dst.x -= cx - 1;
rect.left = dst.x; rect.left = dst.x;
rect.top = dst.y; rect.top = dst.y;

View File

@ -69,16 +69,14 @@ static void *store_points( POINTL *dest, const POINT *pts, UINT count, BOOL shor
} }
/* compute the bounds of an array of points, optionally including the current position */ /* compute the bounds of an array of points, optionally including the current position */
static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, HDC hdc ) static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, DC *dc )
{ {
UINT i; UINT i;
if (hdc) if (dc)
{ {
POINT cur_pt; bounds->left = bounds->right = dc->cur_pos.x;
GetCurrentPositionEx( hdc, &cur_pt ); bounds->top = bounds->bottom = dc->cur_pos.y;
bounds->left = bounds->right = cur_pt.x;
bounds->top = bounds->bottom = cur_pt.y;
} }
else if (count) else if (count)
{ {
@ -143,6 +141,7 @@ BOOL EMFDRV_MoveTo(PHYSDEV dev, INT x, INT y)
BOOL EMFDRV_LineTo( PHYSDEV dev, INT x, INT y ) BOOL EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
POINT pt; POINT pt;
EMRLINETO emr; EMRLINETO emr;
RECTL bounds; RECTL bounds;
@ -155,7 +154,7 @@ BOOL EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
if(!EMFDRV_WriteRecord( dev, &emr.emr )) if(!EMFDRV_WriteRecord( dev, &emr.emr ))
return FALSE; return FALSE;
GetCurrentPositionEx( dev->hdc, &pt ); pt = dc->cur_pos;
bounds.left = min(x, pt.x); bounds.left = min(x, pt.x);
bounds.top = min(y, pt.y); bounds.top = min(y, pt.y);
@ -177,6 +176,7 @@ EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend, DWORD iType ) INT xstart, INT ystart, INT xend, INT yend, DWORD iType )
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
INT temp, xCentre, yCentre, i; INT temp, xCentre, yCentre, i;
double angleStart, angleEnd; double angleStart, angleEnd;
double xinterStart, yinterStart, xinterEnd, yinterEnd; double xinterStart, yinterStart, xinterEnd, yinterEnd;
@ -188,7 +188,7 @@ EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode(dev->hdc) == GM_COMPATIBLE) { if(dc->GraphicsMode == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -269,7 +269,7 @@ EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
if (iType == EMR_ARCTO) if (iType == EMR_ARCTO)
{ {
POINT pt; POINT pt;
GetCurrentPositionEx( dev->hdc, &pt ); pt = dc->cur_pos;
bounds.left = min( bounds.left, pt.x ); bounds.left = min( bounds.left, pt.x );
bounds.top = min( bounds.top, pt.y ); bounds.top = min( bounds.top, pt.y );
bounds.right = max( bounds.right, pt.x ); bounds.right = max( bounds.right, pt.x );
@ -348,6 +348,7 @@ BOOL EMFDRV_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT start, FLOA
BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRELLIPSE emr; EMRELLIPSE emr;
INT temp; INT temp;
@ -358,7 +359,7 @@ BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE) { if(dc->GraphicsMode == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -381,6 +382,7 @@ BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
BOOL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom) BOOL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRRECTANGLE emr; EMRRECTANGLE emr;
INT temp; INT temp;
@ -391,7 +393,7 @@ BOOL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE) { if(dc->GraphicsMode == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -415,6 +417,7 @@ BOOL EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height ) INT bottom, INT ell_width, INT ell_height )
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRROUNDRECT emr; EMRROUNDRECT emr;
INT temp; INT temp;
@ -423,7 +426,7 @@ BOOL EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE) { if(dc->GraphicsMode == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -474,6 +477,7 @@ static BOOL
EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType ) EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRPOLYLINE *emr; EMRPOLYLINE *emr;
DWORD size; DWORD size;
BOOL ret, use_small_emr = can_use_short_points( pt, count ); BOOL ret, use_small_emr = can_use_short_points( pt, count );
@ -489,7 +493,7 @@ EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
if (!physDev->path) if (!physDev->path)
get_points_bounds( &emr->rclBounds, pt, count, get_points_bounds( &emr->rclBounds, pt, count,
(iType == EMR_POLYBEZIERTO || iType == EMR_POLYLINETO) ? dev->hdc : 0 ); (iType == EMR_POLYBEZIERTO || iType == EMR_POLYLINETO) ? dc : 0 );
else else
emr->rclBounds = empty_bounds; emr->rclBounds = empty_bounds;
@ -799,13 +803,14 @@ BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprec
LPCWSTR str, UINT count, const INT *lpDx ) LPCWSTR str, UINT count, const INT *lpDx )
{ {
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMREXTTEXTOUTW *pemr; EMREXTTEXTOUTW *pemr;
DWORD nSize; DWORD nSize;
BOOL ret; BOOL ret;
int textHeight = 0; int textHeight = 0;
int textWidth = 0; int textWidth = 0;
const UINT textAlign = GetTextAlign( dev->hdc ); const UINT textAlign = dc->textAlign;
const INT graphicsMode = GetGraphicsMode( dev->hdc ); const INT graphicsMode = dc->GraphicsMode;
FLOAT exScale, eyScale; FLOAT exScale, eyScale;
nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT); nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT);

View File

@ -1961,7 +1961,7 @@ BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect
if (flags & ETO_OPAQUE) if (flags & ETO_OPAQUE)
{ {
RECT rc = *rect; RECT rc = *rect;
HBRUSH brush = CreateSolidBrush( GetNearestColor( dev->hdc, GetBkColor(dev->hdc) )); HBRUSH brush = CreateSolidBrush( GetNearestColor( dev->hdc, dc->backgroundColor ) );
if (brush) if (brush)
{ {
@ -2052,7 +2052,7 @@ BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect
} }
} }
pen = CreatePen( PS_SOLID, 1, GetTextColor(dev->hdc) ); pen = CreatePen( PS_SOLID, 1, dc->textColor );
orig = SelectObject( dev->hdc, pen ); orig = SelectObject( dev->hdc, pen );
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -2194,8 +2194,8 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
BOOL ret = FALSE; BOOL ret = FALSE;
LPWSTR reordered_str = (LPWSTR)str; LPWSTR reordered_str = (LPWSTR)str;
WORD *glyphs = NULL; WORD *glyphs = NULL;
UINT align = GetTextAlign( hdc ); UINT align;
DWORD layout = GetLayout( hdc ); DWORD layout;
POINT pt; POINT pt;
TEXTMETRICW tm; TEXTMETRICW tm;
LOGFONTW lf; LOGFONTW lf;
@ -2212,7 +2212,9 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
if (!dc) return FALSE; if (!dc) return FALSE;
align = dc->textAlign;
breakRem = dc->breakRem; breakRem = dc->breakRem;
layout = dc->layout;
if (quietfixme == 0 && flags & (ETO_NUMERICSLOCAL | ETO_NUMERICSLATIN)) if (quietfixme == 0 && flags & (ETO_NUMERICSLOCAL | ETO_NUMERICSLATIN))
{ {
@ -2259,11 +2261,11 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
TRACE("%p, %d, %d, %08x, %s, %s, %d, %p)\n", hdc, x, y, flags, TRACE("%p, %d, %d, %08x, %s, %s, %d, %p)\n", hdc, x, y, flags,
wine_dbgstr_rect(lprect), debugstr_wn(str, count), count, lpDx); wine_dbgstr_rect(lprect), debugstr_wn(str, count), count, lpDx);
TRACE("align = %x bkmode = %x mapmode = %x\n", align, GetBkMode(hdc), GetMapMode(hdc)); TRACE("align = %x bkmode = %x mapmode = %x\n", align, dc->backgroundMode, dc->MapMode);
if(align & TA_UPDATECP) if(align & TA_UPDATECP)
{ {
GetCurrentPositionEx( hdc, &pt ); pt = dc->cur_pos;
x = pt.x; x = pt.x;
y = pt.y; y = pt.y;
} }
@ -2463,7 +2465,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
break; break;
} }
if (GetBkMode(hdc) != TRANSPARENT) if (dc->backgroundMode != TRANSPARENT)
{ {
if(!((flags & ETO_CLIPPED) && (flags & ETO_OPAQUE))) if(!((flags & ETO_CLIPPED) && (flags & ETO_OPAQUE)))
{ {
@ -2502,7 +2504,7 @@ done:
OUTLINETEXTMETRICW* otm = NULL; OUTLINETEXTMETRICW* otm = NULL;
POINT pts[5]; POINT pts[5];
HPEN hpen = SelectObject(hdc, GetStockObject(NULL_PEN)); HPEN hpen = SelectObject(hdc, GetStockObject(NULL_PEN));
HBRUSH hbrush = CreateSolidBrush(GetTextColor(hdc)); HBRUSH hbrush = CreateSolidBrush(dc->textColor);
hbrush = SelectObject(hdc, hbrush); hbrush = SelectObject(hdc, hbrush);

View File

@ -124,12 +124,13 @@ BOOL nulldrv_PolyBezier( PHYSDEV dev, const POINT *points, DWORD count )
BOOL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count ) BOOL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count )
{ {
DC *dc = get_nulldrv_dc( dev );
BOOL ret = FALSE; BOOL ret = FALSE;
POINT *pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) ); POINT *pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) );
if (pts) if (pts)
{ {
GetCurrentPositionEx( dev->hdc, &pts[0] ); pts[0] = dc->cur_pos;
memcpy( pts + 1, points, sizeof(POINT) * count ); memcpy( pts + 1, points, sizeof(POINT) * count );
ret = PolyBezier( dev->hdc, pts, count + 1 ); ret = PolyBezier( dev->hdc, pts, count + 1 );
HeapFree( GetProcessHeap(), 0, pts ); HeapFree( GetProcessHeap(), 0, pts );
@ -139,6 +140,7 @@ BOOL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count )
BOOL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types, DWORD count ) BOOL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types, DWORD count )
{ {
DC *dc = get_nulldrv_dc( dev );
POINT *line_pts = NULL, *bzr_pts = NULL, bzr[4]; POINT *line_pts = NULL, *bzr_pts = NULL, bzr[4];
DWORD i; DWORD i;
INT num_pts, num_bzr_pts, space, size; INT num_pts, num_bzr_pts, space, size;
@ -167,7 +169,7 @@ BOOL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types, DWOR
line_pts = HeapAlloc( GetProcessHeap(), 0, space * sizeof(POINT) ); line_pts = HeapAlloc( GetProcessHeap(), 0, space * sizeof(POINT) );
num_pts = 1; num_pts = 1;
GetCurrentPositionEx( dev->hdc, &line_pts[0] ); line_pts[0] = dc->cur_pos;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
switch (types[i]) switch (types[i])
@ -211,13 +213,14 @@ BOOL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types, DWOR
BOOL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count ) BOOL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count )
{ {
DC *dc = get_nulldrv_dc( dev );
BOOL ret = FALSE; BOOL ret = FALSE;
POINT *pts; POINT *pts;
if (!count) return FALSE; if (!count) return FALSE;
if ((pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) ))) if ((pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) )))
{ {
GetCurrentPositionEx( dev->hdc, &pts[0] ); pts[0] = dc->cur_pos;
memcpy( pts + 1, points, sizeof(POINT) * count ); memcpy( pts + 1, points, sizeof(POINT) * count );
ret = Polyline( dev->hdc, pts, count + 1 ); ret = Polyline( dev->hdc, pts, count + 1 );
HeapFree( GetProcessHeap(), 0, pts ); HeapFree( GetProcessHeap(), 0, pts );