gdi32: Store vis_rect in 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-08-02 10:03:33 +02:00 committed by Alexandre Julliard
parent 057b6404ba
commit 0d03c57d89
8 changed files with 47 additions and 49 deletions

View File

@ -977,8 +977,8 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
if (src.x < 0 || src.y < 0 || src.width < 0 || src.height < 0 ||
src.log_width < 0 || src.log_height < 0 ||
(!is_rect_empty( &dcSrc->device_rect ) &&
(src.width > dcSrc->device_rect.right - dcSrc->vis_rect.left - src.x ||
src.height > dcSrc->device_rect.bottom - dcSrc->vis_rect.top - src.y)))
(src.width > dcSrc->device_rect.right - dcSrc->attr->vis_rect.left - src.x ||
src.height > dcSrc->device_rect.bottom - dcSrc->attr->vis_rect.top - src.y)))
{
WARN( "Invalid src coords: (%d,%d), size %dx%d\n", src.x, src.y, src.width, src.height );
SetLastError( ERROR_INVALID_PARAMETER );

View File

@ -421,11 +421,11 @@ HGDIOBJ WINAPI NtGdiSelectBitmap( HDC hdc, HGDIOBJ handle )
dc->hBitmap = handle;
GDI_inc_ref_count( handle );
dc->dirty = 0;
dc->vis_rect.left = 0;
dc->vis_rect.top = 0;
dc->vis_rect.right = bitmap->dib.dsBm.bmWidth;
dc->vis_rect.bottom = bitmap->dib.dsBm.bmHeight;
dc->device_rect = dc->vis_rect;
dc->attr->vis_rect.left = 0;
dc->attr->vis_rect.top = 0;
dc->attr->vis_rect.right = bitmap->dib.dsBm.bmWidth;
dc->attr->vis_rect.bottom = bitmap->dib.dsBm.bmHeight;
dc->device_rect = dc->attr->vis_rect;
GDI_ReleaseObj( handle );
DC_InitDC( dc );
GDI_dec_ref_count( ret );

View File

@ -33,7 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipping);
static inline BOOL get_dc_device_rect( DC *dc, RECT *rect )
{
*rect = dc->device_rect;
offset_rect( rect, -dc->vis_rect.left, -dc->vis_rect.top );
offset_rect( rect, -dc->attr->vis_rect.left, -dc->attr->vis_rect.top );
return !is_rect_empty( rect );
}
@ -171,7 +171,7 @@ INT CDECL nulldrv_ExtSelectClipRgn( PHYSDEV dev, HRGN rgn, INT mode )
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 );
mirror_region( mirrored, rgn, dc->attr->vis_rect.right - dc->attr->vis_rect.left );
rgn = mirrored;
}
@ -289,7 +289,7 @@ void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect,
if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
dc->dirty = 0;
dc->vis_rect = *vis_rect;
dc->attr->vis_rect = *vis_rect;
dc->device_rect = *device_rect;
dc->hVisRgn = hrgn;
dibdrv_set_window_surface( dc, surface );
@ -426,8 +426,8 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect )
}
else
{
ret = is_rect_empty( &dc->vis_rect ) ? ERROR : SIMPLEREGION;
*rect = dc->vis_rect;
ret = is_rect_empty( &dc->attr->vis_rect ) ? ERROR : SIMPLEREGION;
*rect = dc->attr->vis_rect;
}
if (get_dc_device_rect( dc, &visrect ) && !intersect_rect( rect, rect, &visrect )) ret = NULLREGION;
@ -460,7 +460,7 @@ INT WINAPI GetClipRgn( HDC hdc, HRGN hRgn )
{
ret = 1;
if (dc->attr->layout & LAYOUT_RTL)
mirror_region( hRgn, hRgn, dc->vis_rect.right - dc->vis_rect.left );
mirror_region( hRgn, hRgn, dc->attr->vis_rect.right - dc->attr->vis_rect.left );
}
}
else ret = 0;
@ -484,7 +484,7 @@ INT WINAPI GetMetaRgn( HDC hdc, HRGN hRgn )
{
ret = 1;
if (dc->attr->layout & LAYOUT_RTL)
mirror_region( hRgn, hRgn, dc->vis_rect.right - dc->vis_rect.left );
mirror_region( hRgn, hRgn, dc->attr->vis_rect.right - dc->attr->vis_rect.left );
}
release_dc_ptr( dc );
}
@ -535,7 +535,8 @@ INT WINAPI GetRandomRgn(HDC hDC, HRGN hRgn, INT iCode)
{
NtGdiCombineRgn( hRgn, dc->hVisRgn, 0, RGN_COPY );
/* On Windows NT/2000, the SYSRGN returned is in screen coordinates */
if (!(GetVersion() & 0x80000000)) NtGdiOffsetRgn( hRgn, dc->vis_rect.left, dc->vis_rect.top );
if (!(GetVersion() & 0x80000000))
NtGdiOffsetRgn( hRgn, dc->attr->vis_rect.left, dc->attr->vis_rect.top );
}
else if (!is_rect_empty( &dc->device_rect ))
NtGdiSetRectRgn( hRgn, dc->device_rect.left, dc->device_rect.top,

View File

@ -329,7 +329,8 @@ static void construct_window_to_viewport(DC *dc, XFORM *xform)
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->attr->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->attr->vis_rect.right - dc->attr->vis_rect.left - 1 - xform->eDx;
}
/***********************************************************************
@ -672,10 +673,10 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
dc->display[p - display] = '\0';
}
dc->vis_rect.left = 0;
dc->vis_rect.top = 0;
dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
dc->attr->vis_rect.left = 0;
dc->attr->vis_rect.top = 0;
dc->attr->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
dc->attr->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
DC_InitDC( dc );
release_dc_ptr( dc );
@ -709,11 +710,11 @@ HDC WINAPI NtGdiCreateCompatibleDC( HDC hdc )
TRACE("(%p): returning %p\n", hdc, dc->hSelf );
dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
dc->vis_rect.left = 0;
dc->vis_rect.top = 0;
dc->vis_rect.right = 1;
dc->vis_rect.bottom = 1;
dc->device_rect = dc->vis_rect;
dc->attr->vis_rect.left = 0;
dc->attr->vis_rect.top = 0;
dc->attr->vis_rect.right = 1;
dc->attr->vis_rect.bottom = 1;
dc->device_rect = dc->attr->vis_rect;
ret = dc->hSelf;
@ -784,10 +785,10 @@ HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
if (ret) /* reset the visible region */
{
dc->dirty = 0;
dc->vis_rect.left = 0;
dc->vis_rect.top = 0;
dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
dc->attr->vis_rect.left = 0;
dc->attr->vis_rect.top = 0;
dc->attr->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
dc->attr->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
dc->hVisRgn = 0;
update_dc_clipping( dc );
@ -858,22 +859,6 @@ COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
}
/***********************************************************************
* GetDCOrgEx (GDI32.@)
*/
BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
{
DC * dc;
if (!lpp) return FALSE;
if (!(dc = get_dc_ptr( hDC ))) return FALSE;
lpp->x = dc->vis_rect.left;
lpp->y = dc->vis_rect.top;
release_dc_ptr( dc );
return TRUE;
}
/***********************************************************************
* SetGraphicsMode (GDI32.@)
*/
@ -1238,8 +1223,8 @@ UINT WINAPI NtGdiGetBoundsRect( HDC hdc, RECT *rect, UINT flags )
*rect = dc->bounds;
rect->left = max( rect->left, 0 );
rect->top = max( rect->top, 0 );
rect->right = min( rect->right, dc->vis_rect.right - dc->vis_rect.left );
rect->bottom = min( rect->bottom, dc->vis_rect.bottom - dc->vis_rect.top );
rect->right = min( rect->right, dc->attr->vis_rect.right - dc->attr->vis_rect.left );
rect->bottom = min( rect->bottom, dc->attr->vis_rect.bottom - dc->attr->vis_rect.top );
ret = DCB_SET;
}
dp_to_lp( dc, (POINT *)rect, 2 );

View File

@ -820,7 +820,7 @@ void dibdrv_set_window_surface( DC *dc, struct window_surface *surface )
dibdrv = physdev->dibdrv;
bits = surface->funcs->get_info( surface, info );
init_dib_info_from_bitmapinfo( &dibdrv->dib, info, bits );
dibdrv->dib.rect = dc->vis_rect;
dibdrv->dib.rect = dc->attr->vis_rect;
offset_rect( &dibdrv->dib.rect, -dc->device_rect.left, -dc->device_rect.top );
dibdrv->bounds = surface->funcs->get_bounds( surface );
DC_InitDC( dc );

View File

@ -330,6 +330,18 @@ INT WINAPI GetStretchBltMode( HDC hdc )
return dc_attr ? dc_attr->stretch_blt_mode : 0;
}
/***********************************************************************
* GetDCOrgEx (GDI32.@)
*/
BOOL WINAPI GetDCOrgEx( HDC hdc, POINT *point )
{
DC_ATTR *dc_attr;
if (!point || !(dc_attr = get_dc_attr( hdc ))) return FALSE;
point->x = dc_attr->vis_rect.left;
point->y = dc_attr->vis_rect.top;
return TRUE;
}
/***********************************************************************
* SetStretchBltMode (GDI32.@)
*/

View File

@ -93,7 +93,6 @@ typedef struct tagDC
SIZE vport_ext; /* Viewport extent */
SIZE virtual_res; /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
RECT vis_rect; /* visible rectangle in screen coords */
RECT device_rect; /* rectangle for the whole device */
int pixel_format; /* pixel format (for memory DCs) */
UINT aa_flags; /* anti-aliasing flags to pass to GetGlyphOutline for current font */

View File

@ -114,6 +114,7 @@ typedef struct DC_ATTR
WORD rel_abs_mode;
WORD stretch_blt_mode;
INT map_mode;
RECT vis_rect; /* visible rectangle in screen coords */
FLOAT miter_limit;
void *emf;
} DC_ATTR;