Commit 561b25c4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Use NtGdiRestoreDC for RestoreDC.

parent 8eab13f3
......@@ -399,95 +399,6 @@ void DC_UpdateXforms( DC *dc )
*/
BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
{
DC *dcs, *first_dcs, *dc = get_nulldrv_dc( dev );
INT save_level;
/* find the state level to restore */
if (abs(level) > dc->attr->save_level || level == 0) return FALSE;
if (level < 0) level = dc->attr->save_level + level + 1;
first_dcs = dc->saved_dc;
for (dcs = first_dcs, save_level = dc->attr->save_level; save_level > level; save_level--)
dcs = dcs->saved_dc;
/* restore the state */
if (!PATH_RestorePath( dc, dcs )) return FALSE;
dc->attr->layout = dcs->attr->layout;
dc->attr->rop_mode = dcs->attr->rop_mode;
dc->attr->poly_fill_mode = dcs->attr->poly_fill_mode;
dc->attr->stretch_blt_mode = dcs->attr->stretch_blt_mode;
dc->attr->rel_abs_mode = dcs->attr->rel_abs_mode;
dc->attr->background_mode = dcs->attr->background_mode;
dc->attr->background_color = dcs->attr->background_color;
dc->attr->text_color = dcs->attr->text_color;
dc->attr->brush_color = dcs->attr->brush_color;
dc->attr->pen_color = dcs->attr->pen_color;
dc->attr->brush_org = dcs->attr->brush_org;
dc->attr->mapper_flags = dcs->attr->mapper_flags;
dc->attr->text_align = dcs->attr->text_align;
dc->attr->char_extra = dcs->attr->char_extra;
dc->breakExtra = dcs->breakExtra;
dc->breakRem = dcs->breakRem;
dc->attr->map_mode = dcs->attr->map_mode;
dc->attr->graphics_mode = dcs->attr->graphics_mode;
dc->attr->cur_pos = dcs->attr->cur_pos;
dc->attr->arc_direction = dcs->attr->arc_direction;
dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
dc->xformWorld2Vport = dcs->xformWorld2Vport;
dc->xformVport2World = dcs->xformVport2World;
dc->vport2WorldValid = dcs->vport2WorldValid;
dc->attr->wnd_org = dcs->attr->wnd_org;
dc->attr->wnd_ext = dcs->attr->wnd_ext;
dc->attr->vport_org = dcs->attr->vport_org;
dc->attr->vport_ext = dcs->attr->vport_ext;
dc->attr->virtual_res = dcs->attr->virtual_res;
dc->attr->virtual_size = dcs->attr->virtual_size;
if (dcs->hClipRgn)
{
if (!dc->hClipRgn) dc->hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
}
else
{
if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
dc->hClipRgn = 0;
}
if (dcs->hMetaRgn)
{
if (!dc->hMetaRgn) dc->hMetaRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( dc->hMetaRgn, dcs->hMetaRgn, 0, RGN_COPY );
}
else
{
if (dc->hMetaRgn) DeleteObject( dc->hMetaRgn );
dc->hMetaRgn = 0;
}
DC_UpdateXforms( dc );
update_dc_clipping( dc );
NtGdiSelectBitmap( dev->hdc, dcs->hBitmap );
NtGdiSelectBrush( dev->hdc, dcs->hBrush );
NtGdiSelectFont( dev->hdc, dcs->hFont );
NtGdiSelectPen( dev->hdc, dcs->hPen );
set_bk_color( dc, dcs->attr->background_color);
set_text_color( dc, dcs->attr->text_color);
GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
dc->saved_dc = dcs->saved_dc;
dcs->saved_dc = 0;
dc->attr->save_level = save_level - 1;
/* now destroy all the saved DCs */
while (first_dcs)
{
DC *next = first_dcs->saved_dc;
free_dc_state( first_dcs );
first_dcs = next;
}
return TRUE;
}
......@@ -594,23 +505,114 @@ INT WINAPI NtGdiSaveDC( HDC hdc )
/***********************************************************************
* RestoreDC (GDI32.@)
* NtGdiRestoreDC (win32u.@)
*/
BOOL WINAPI RestoreDC( HDC hdc, INT level )
BOOL WINAPI NtGdiRestoreDC( HDC hdc, INT level )
{
PHYSDEV physdev;
DC *dc;
BOOL success = FALSE;
DC *dc, *dcs, *first_dcs;
INT save_level;
TRACE("%p %d\n", hdc, level );
if ((dc = get_dc_ptr( hdc )))
if (!(dc = get_dc_ptr( hdc ))) return FALSE;
update_dc( dc );
/* find the state level to restore */
if (abs(level) > dc->attr->save_level || level == 0)
{
update_dc( dc );
physdev = GET_DC_PHYSDEV( dc, pRestoreDC );
success = physdev->funcs->pRestoreDC( physdev, level );
release_dc_ptr( dc );
return FALSE;
}
if (level < 0) level = dc->attr->save_level + level + 1;
first_dcs = dc->saved_dc;
for (dcs = first_dcs, save_level = dc->attr->save_level; save_level > level; save_level--)
dcs = dcs->saved_dc;
/* restore the state */
if (!PATH_RestorePath( dc, dcs ))
{
release_dc_ptr( dc );
return FALSE;
}
dc->attr->layout = dcs->attr->layout;
dc->attr->rop_mode = dcs->attr->rop_mode;
dc->attr->poly_fill_mode = dcs->attr->poly_fill_mode;
dc->attr->stretch_blt_mode = dcs->attr->stretch_blt_mode;
dc->attr->rel_abs_mode = dcs->attr->rel_abs_mode;
dc->attr->background_mode = dcs->attr->background_mode;
dc->attr->background_color = dcs->attr->background_color;
dc->attr->text_color = dcs->attr->text_color;
dc->attr->brush_color = dcs->attr->brush_color;
dc->attr->pen_color = dcs->attr->pen_color;
dc->attr->brush_org = dcs->attr->brush_org;
dc->attr->mapper_flags = dcs->attr->mapper_flags;
dc->attr->text_align = dcs->attr->text_align;
dc->attr->char_extra = dcs->attr->char_extra;
dc->attr->map_mode = dcs->attr->map_mode;
dc->attr->graphics_mode = dcs->attr->graphics_mode;
dc->attr->cur_pos = dcs->attr->cur_pos;
dc->attr->arc_direction = dcs->attr->arc_direction;
dc->attr->wnd_org = dcs->attr->wnd_org;
dc->attr->wnd_ext = dcs->attr->wnd_ext;
dc->attr->vport_org = dcs->attr->vport_org;
dc->attr->vport_ext = dcs->attr->vport_ext;
dc->attr->virtual_res = dcs->attr->virtual_res;
dc->attr->virtual_size = dcs->attr->virtual_size;
dc->breakExtra = dcs->breakExtra;
dc->breakRem = dcs->breakRem;
dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
dc->xformWorld2Vport = dcs->xformWorld2Vport;
dc->xformVport2World = dcs->xformVport2World;
dc->vport2WorldValid = dcs->vport2WorldValid;
if (dcs->hClipRgn)
{
if (!dc->hClipRgn) dc->hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
}
else
{
if (dc->hClipRgn) NtGdiDeleteObjectApp( dc->hClipRgn );
dc->hClipRgn = 0;
}
if (dcs->hMetaRgn)
{
if (!dc->hMetaRgn) dc->hMetaRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( dc->hMetaRgn, dcs->hMetaRgn, 0, RGN_COPY );
}
else
{
if (dc->hMetaRgn) NtGdiDeleteObjectApp( dc->hMetaRgn );
dc->hMetaRgn = 0;
}
return success;
DC_UpdateXforms( dc );
update_dc_clipping( dc );
NtGdiSelectBitmap( hdc, dcs->hBitmap );
NtGdiSelectBrush( hdc, dcs->hBrush );
NtGdiSelectFont( hdc, dcs->hFont );
NtGdiSelectPen( hdc, dcs->hPen );
set_bk_color( dc, dcs->attr->background_color);
set_text_color( dc, dcs->attr->text_color);
GDISelectPalette( hdc, dcs->hPalette, FALSE );
dc->saved_dc = dcs->saved_dc;
dcs->saved_dc = 0;
dc->attr->save_level = save_level - 1;
/* now destroy all the saved DCs */
while (first_dcs)
{
DC *next = first_dcs->saved_dc;
free_dc_state( first_dcs );
first_dcs = next;
}
release_dc_ptr( dc );
return TRUE;
}
......
......@@ -30,28 +30,19 @@ BOOL EMFDC_SaveDC( DC_ATTR *dc_attr )
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
BOOL CDECL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
BOOL EMFDC_RestoreDC( DC_ATTR *dc_attr, INT level )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRestoreDC );
EMFDRV_PDEVICE* physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRRESTOREDC emr;
BOOL ret;
if (abs(level) > dc_attr->save_level || level == 0) return FALSE;
emr.emr.iType = EMR_RESTOREDC;
emr.emr.nSize = sizeof(emr);
if (level < 0)
emr.iRelative = level;
else
emr.iRelative = level - dc->attr->save_level - 1;
physDev->restoring++;
ret = next->funcs->pRestoreDC( next, level );
physDev->restoring--;
if (ret) EMFDRV_WriteRecord( dev, &emr.emr );
return ret;
emr.iRelative = level - dc_attr->save_level - 1;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align )
......
......@@ -40,7 +40,6 @@ typedef struct
HANDLE hFile; /* Handle for disk based MetaFile */
HBRUSH dc_brush;
HPEN dc_pen;
INT restoring; /* RestoreDC counter */
BOOL path;
INT dev_caps[COLORMGMTCAPS + 1];
} EMFDRV_PDEVICE;
......@@ -90,7 +89,6 @@ extern BOOL CDECL EMFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const IN
extern BOOL CDECL EMFDRV_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* counts, DWORD polys) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_PolylineTo( PHYSDEV dev, const POINT* pt,INT count) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom,
......
......@@ -109,7 +109,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
NULL, /* pRealizePalette */
EMFDRV_Rectangle, /* pRectangle */
NULL, /* pResetDC */
EMFDRV_RestoreDC, /* pRestoreDC */
NULL, /* pRestoreDC */
EMFDRV_RoundRect, /* pRoundRect */
EMFDRV_SelectBitmap, /* pSelectBitmap */
NULL, /* pSelectBrush */
......@@ -335,7 +335,6 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->hFile = 0;
physDev->dc_brush = 0;
physDev->dc_pen = 0;
physDev->restoring = 0;
physDev->path = FALSE;
if (hdc) /* if no ref, use current display */
......
......@@ -83,6 +83,7 @@ extern BOOL METADC_Polygon( HDC hdc, const POINT *points, INT count ) DECLSPEC_H
extern BOOL METADC_Polyline( HDC hdc, const POINT *points,INT count) DECLSPEC_HIDDEN;
extern BOOL METADC_RealizePalette( HDC hdc ) DECLSPEC_HIDDEN;
extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern BOOL METADC_RestoreDC( HDC hdc, INT level ) DECLSPEC_HIDDEN;
extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL METADC_SaveDC( HDC hdc ) DECLSPEC_HIDDEN;
......@@ -173,6 +174,7 @@ extern BOOL EMFDC_Polyline( DC_ATTR *dc_attr, const POINT *points, INT count) DE
extern BOOL EMFDC_PolylineTo( DC_ATTR *dc_attr, const POINT *points, INT count ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom) DECLSPEC_HIDDEN;
extern BOOL EMFDC_RestoreDC( DC_ATTR *dc_attr, INT level ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SaveDC( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
......
......@@ -126,6 +126,19 @@ INT WINAPI SaveDC( HDC hdc )
}
/***********************************************************************
* RestoreDC (GDI32.@)
*/
BOOL WINAPI RestoreDC( HDC hdc, INT level )
{
DC_ATTR *dc_attr;
if (is_meta_dc( hdc )) return METADC_RestoreDC( hdc, level );
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_RestoreDC( dc_attr, level )) return FALSE;
return NtGdiRestoreDC( hdc, level );
}
/***********************************************************************
* GetDeviceCaps (GDI32.@)
*/
INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
......
......@@ -25,9 +25,9 @@ BOOL METADC_SaveDC( HDC hdc )
return metadc_param0( hdc, META_SAVEDC );
}
BOOL CDECL MFDRV_RestoreDC( PHYSDEV dev, INT level )
BOOL METADC_RestoreDC( HDC hdc, INT level )
{
return MFDRV_MetaParam1( dev, META_RESTOREDC, level );
return metadc_param1( hdc, META_RESTOREDC, level );
}
BOOL METADC_SetTextAlign( HDC hdc, UINT align )
......
......@@ -174,7 +174,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
NULL, /* pRealizePalette */
NULL, /* pRectangle */
NULL, /* pResetDC */
MFDRV_RestoreDC, /* pRestoreDC */
NULL, /* pRestoreDC */
NULL, /* pRoundRect */
NULL, /* pSelectBitmap */
NULL, /* pSelectBrush */
......
......@@ -90,7 +90,6 @@ extern BOOL CDECL MFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush ) DECLSPE
extern BOOL CDECL MFDRV_FlattenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_PolyBezier( PHYSDEV dev, const POINT* pt, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_PolyBezierTo( PHYSDEV dev, const POINT* pt, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) DECLSPEC_HIDDEN;
extern COLORREF CDECL MFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
......
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