gdi32: Move layout to DC_ATTR.

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-28 11:39:26 +02:00 committed by Alexandre Julliard
parent c00b231826
commit 148a2b60a5
13 changed files with 35 additions and 47 deletions

View File

@ -543,7 +543,7 @@ BOOL WINAPI PatBlt( HDC hdc, INT left, INT top, INT width, INT height, DWORD rop
dst.log_y = top;
dst.log_width = width;
dst.log_height = height;
dst.layout = dc->layout;
dst.layout = dc->attr->layout;
if (rop & NOMIRRORBITMAP)
{
dst.layout |= LAYOUT_BITMAPORIENTATIONPRESERVED;
@ -602,12 +602,12 @@ BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst, INT widthDst, INT height
src.log_y = ySrc;
src.log_width = widthSrc;
src.log_height = heightSrc;
src.layout = dcSrc->layout;
src.layout = dcSrc->attr->layout;
dst.log_x = xDst;
dst.log_y = yDst;
dst.log_width = widthDst;
dst.log_height = heightDst;
dst.layout = dcDst->layout;
dst.layout = dcDst->attr->layout;
if (rop & NOMIRRORBITMAP)
{
src.layout |= LAYOUT_BITMAPORIENTATIONPRESERVED;
@ -958,12 +958,12 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
src.log_y = ySrc;
src.log_width = widthSrc;
src.log_height = heightSrc;
src.layout = dcSrc->layout;
src.layout = dcSrc->attr->layout;
dst.log_x = xDst;
dst.log_y = yDst;
dst.log_width = widthDst;
dst.log_height = heightDst;
dst.layout = dcDst->layout;
dst.layout = dcDst->attr->layout;
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",

View File

@ -51,7 +51,7 @@ static inline RECT get_clip_rect( DC * dc, int left, int top, int right, int bot
rect.right = right;
rect.bottom = bottom;
lp_to_dp( dc, (POINT *)&rect, 2 );
if (dc->layout & LAYOUT_RTL)
if (dc->attr->layout & LAYOUT_RTL)
{
int tmp = rect.left;
rect.left = rect.right + 1;
@ -168,7 +168,7 @@ INT CDECL nulldrv_ExtSelectClipRgn( PHYSDEV dev, HRGN rgn, INT mode )
{
HRGN mirrored = 0;
if (dc->layout & LAYOUT_RTL)
if (dc->attr->layout & LAYOUT_RTL)
{
if (!(mirrored = NtGdiCreateRectRgn( 0, 0, 0, 0 ))) return ERROR;
mirror_region( mirrored, rgn, dc->vis_rect.right - dc->vis_rect.left );
@ -235,7 +235,7 @@ INT CDECL nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y )
{
x = MulDiv( x, dc->vport_ext.cx, dc->wnd_ext.cx );
y = MulDiv( y, dc->vport_ext.cy, dc->wnd_ext.cy );
if (dc->layout & LAYOUT_RTL) x = -x;
if (dc->attr->layout & LAYOUT_RTL) x = -x;
ret = NtGdiOffsetRgn( dc->hClipRgn, x, y );
update_dc_clipping( dc );
}
@ -432,7 +432,7 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect )
if (get_dc_device_rect( dc, &visrect ) && !intersect_rect( rect, rect, &visrect )) ret = NULLREGION;
if (dc->layout & LAYOUT_RTL)
if (dc->attr->layout & LAYOUT_RTL)
{
int tmp = rect->left;
rect->left = rect->right - 1;
@ -459,7 +459,7 @@ INT WINAPI GetClipRgn( HDC hdc, HRGN hRgn )
if (NtGdiCombineRgn( hRgn, dc->hClipRgn, 0, RGN_COPY ) != ERROR)
{
ret = 1;
if (dc->layout & LAYOUT_RTL)
if (dc->attr->layout & LAYOUT_RTL)
mirror_region( hRgn, hRgn, dc->vis_rect.right - dc->vis_rect.left );
}
}
@ -483,7 +483,7 @@ INT WINAPI GetMetaRgn( HDC hdc, HRGN hRgn )
if (dc->hMetaRgn && NtGdiCombineRgn( hRgn, dc->hMetaRgn, 0, RGN_COPY ) != ERROR)
{
ret = 1;
if (dc->layout & LAYOUT_RTL)
if (dc->attr->layout & LAYOUT_RTL)
mirror_region( hRgn, hRgn, dc->vis_rect.right - dc->vis_rect.left );
}
release_dc_ptr( dc );

View File

@ -80,7 +80,7 @@ static void set_initial_dc_state( DC *dc )
dc->vport_ext.cx = 1;
dc->vport_ext.cy = 1;
dc->miterLimit = 10.0f; /* 10.0 is the default, from MSDN */
dc->layout = 0;
dc->attr->layout = 0;
dc->font_code_page = CP_ACP;
dc->attr->rop_mode = R2_COPYPEN;
dc->polyFillMode = ALTERNATE;
@ -322,14 +322,14 @@ static void construct_window_to_viewport(DC *dc, XFORM *xform)
scaleX = (double)dc->vport_ext.cx / (double)dc->wnd_ext.cx;
scaleY = (double)dc->vport_ext.cy / (double)dc->wnd_ext.cy;
if (dc->layout & LAYOUT_RTL) scaleX = -scaleX;
if (dc->attr->layout & LAYOUT_RTL) scaleX = -scaleX;
xform->eM11 = scaleX;
xform->eM12 = 0.0;
xform->eM21 = 0.0;
xform->eM22 = scaleY;
xform->eDx = (double)dc->vport_org.x - scaleX * (double)dc->wnd_org.x;
xform->eDy = (double)dc->vport_org.y - scaleY * (double)dc->wnd_org.y;
if (dc->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx;
if (dc->attr->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx;
}
/***********************************************************************
@ -393,7 +393,6 @@ INT CDECL nulldrv_SaveDC( PHYSDEV dev )
return 0;
}
*newdc->attr = *dc->attr;
newdc->layout = dc->layout;
newdc->hPen = dc->hPen;
newdc->hBrush = dc->hBrush;
newdc->hFont = dc->hFont;
@ -470,7 +469,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
if (!PATH_RestorePath( dc, dcs )) return FALSE;
dc->layout = dcs->layout;
dc->attr->layout = dcs->attr->layout;
dc->attr->rop_mode = dcs->attr->rop_mode;
dc->polyFillMode = dcs->polyFillMode;
dc->stretchBltMode = dcs->stretchBltMode;
@ -1751,28 +1750,6 @@ BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
}
/***********************************************************************
* GetLayout (GDI32.@)
*
* Gets left->right or right->left text layout flags of a dc.
*
*/
DWORD WINAPI GetLayout(HDC hdc)
{
DWORD layout = GDI_ERROR;
DC * dc = get_dc_ptr( hdc );
if (dc)
{
layout = dc->layout;
release_dc_ptr( dc );
}
TRACE("hdc : %p, layout : %08x\n", hdc, layout);
return layout;
}
/***********************************************************************
* SetLayout (GDI32.@)
*

View File

@ -492,7 +492,7 @@ INT CDECL nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst,
dst.width = rect.right - rect.left;
dst.height = rect.bottom - rect.top;
if (dc->layout & LAYOUT_RTL && rop & NOMIRRORBITMAP)
if (dc->attr->layout & LAYOUT_RTL && rop & NOMIRRORBITMAP)
{
dst.x += dst.width;
dst.width = -dst.width;
@ -846,7 +846,7 @@ INT CDECL nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD cx
dst.y = pt.y;
dst.width = cx;
dst.height = cy;
if (dc->layout & LAYOUT_RTL) dst.x -= cx - 1;
if (dc->attr->layout & LAYOUT_RTL) dst.x -= cx - 1;
rect.left = dst.x;
rect.top = dst.y;

View File

@ -100,7 +100,7 @@ static RECT get_device_rect( DC *dc, int left, int top, int right, int bottom, B
rect.top = top;
rect.right = right;
rect.bottom = bottom;
if (rtl_correction && dc->layout & LAYOUT_RTL)
if (rtl_correction && dc->attr->layout & LAYOUT_RTL)
{
/* shift the rectangle so that the right border is included after mirroring */
/* it would be more correct to do this after LPtoDP but that's not what Windows does */

View File

@ -800,8 +800,8 @@ static DWORD CDECL nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
DC *dc = get_nulldrv_dc( dev );
DWORD old_layout;
old_layout = dc->layout;
dc->layout = layout;
old_layout = dc->attr->layout;
dc->attr->layout = layout;
if (layout != old_layout)
{
if (layout & LAYOUT_RTL) dc->MapMode = MM_ANISOTROPIC;

View File

@ -5951,7 +5951,7 @@ BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lpr
align = dc->attr->text_align;
breakRem = dc->breakRem;
layout = dc->layout;
layout = dc->attr->layout;
if (quietfixme == 0 && flags & (ETO_NUMERICSLOCAL | ETO_NUMERICSLATIN))
{

View File

@ -97,6 +97,15 @@ INT WINAPI SetBkMode( HDC hdc, INT mode )
return ret;
}
/***********************************************************************
* GetLayout (GDI32.@)
*/
DWORD WINAPI GetLayout( HDC hdc )
{
DC_ATTR *dc_attr = get_dc_attr( hdc );
return dc_attr ? dc_attr->layout : GDI_ERROR;
}
/***********************************************************************
* GetCurrentPositionEx (GDI32.@)
*/

View File

@ -203,7 +203,7 @@ INT CDECL nulldrv_SetMapMode( PHYSDEV dev, INT mode )
return 0;
}
/* RTL layout is always MM_ANISOTROPIC */
if (!(dc->layout & LAYOUT_RTL)) dc->MapMode = mode;
if (!(dc->attr->layout & LAYOUT_RTL)) dc->MapMode = mode;
DC_UpdateXforms( dc );
return ret;
}

View File

@ -101,7 +101,6 @@ typedef struct tagDC
WCHAR display[CCHDEVICENAME]; /* Display name when created for a specific display device */
int flags;
DWORD layout;
HRGN hClipRgn; /* Clip region */
HRGN hMetaRgn; /* Meta region */
HRGN hVisRgn; /* Visible region */

View File

@ -280,6 +280,8 @@ static void test_dc_layout(void)
ret = GetMapMode( hdc );
ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
ret = pGetLayout( hdc );
ok(ret == LAYOUT_RTL, "got %x\n", ret);
expect_viewport_ext(hdc, 1, 1);
expect_window_ext(hdc, 1, 1);
expect_world_transform(hdc, 1.0, 1.0);

View File

@ -6396,7 +6396,7 @@ static void test_mf_SetLayout(void)
layout = SetLayout(mf_dc, tests[i]);
ok(layout == LAYOUT_RTL, "Expected %#x, got %#x\n", tests[i], layout);
layout = GetLayout(mf_dc);
todo_wine ok(layout == GDI_ERROR, "Expected %#x, got %#x\n", GDI_ERROR, layout);
ok(layout == GDI_ERROR, "Expected %#x, got %#x\n", GDI_ERROR, layout);
winetest_pop_context();
}

View File

@ -101,6 +101,7 @@ typedef struct DC_ATTR
LONG disabled; /* disabled flag, controled by DCHF_(DISABLE|ENABLE)DC */
POINT cur_pos;
INT graphics_mode;
DWORD layout;
WORD text_align;
WORD background_mode;
WORD rop_mode;