From 9c7b528b6f9a722a9e8fd1e37371002c8d63a1cf Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 11 Mar 2011 20:43:15 +0100 Subject: [PATCH] gdi32: Add null driver entry points for the path functions. --- dlls/gdi32/driver.c | 20 +- dlls/gdi32/gdi_private.h | 10 + dlls/gdi32/path.c | 384 +++++++++++++++++++++------------------ 3 files changed, 231 insertions(+), 183 deletions(-) diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index 0bd7bdb95b3..3ae5772793b 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -681,16 +681,16 @@ static BOOL CDECL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD co const DC_FUNCTIONS null_driver = { nulldrv_AbortDoc, /* pAbortDoc */ - NULL, /* pAbortPath */ + nulldrv_AbortPath, /* pAbortPath */ NULL, /* pAlphaBlend */ nulldrv_AngleArc, /* pAngleArc */ nulldrv_Arc, /* pArc */ nulldrv_ArcTo, /* pArcTo */ - NULL, /* pBeginPath */ + nulldrv_BeginPath, /* pBeginPath */ NULL, /* pBitBlt */ nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */ nulldrv_Chord, /* pChord */ - NULL, /* pCloseFigure */ + nulldrv_CloseFigure, /* pCloseFigure */ NULL, /* pCreateBitmap */ NULL, /* pCreateDC */ NULL, /* pCreateDIBSection */ @@ -702,7 +702,7 @@ const DC_FUNCTIONS null_driver = nulldrv_Ellipse, /* pEllipse */ nulldrv_EndDoc, /* pEndDoc */ nulldrv_EndPage, /* pEndPage */ - NULL, /* pEndPath */ + nulldrv_EndPath, /* pEndPath */ nulldrv_EnumICMProfiles, /* pEnumICMProfiles */ NULL, /* pEnumDeviceFonts */ nulldrv_ExcludeClipRect, /* pExcludeClipRect */ @@ -711,9 +711,9 @@ const DC_FUNCTIONS null_driver = nulldrv_ExtFloodFill, /* pExtFloodFill */ nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */ NULL, /* pExtTextOut */ - NULL, /* pFillPath */ + nulldrv_FillPath, /* pFillPath */ nulldrv_FillRgn, /* pFillRgn */ - NULL, /* pFlattenPath */ + nulldrv_FlattenPath, /* pFlattenPath */ nulldrv_FrameRgn, /* pFrameRgn */ nulldrv_GdiComment, /* pGdiComment */ NULL, /* pGetBitmapBits */ @@ -758,7 +758,7 @@ const DC_FUNCTIONS null_driver = nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */ nulldrv_SelectBitmap, /* pSelectBitmap */ nulldrv_SelectBrush, /* pSelectBrush */ - NULL, /* pSelectClipPath */ + nulldrv_SelectClipPath, /* pSelectClipPath */ nulldrv_SelectFont, /* pSelectFont */ nulldrv_SelectPalette, /* pSelectPalette */ nulldrv_SelectPen, /* pSelectPen */ @@ -795,11 +795,11 @@ const DC_FUNCTIONS null_driver = nulldrv_StartPage, /* pStartPage */ NULL, /* pStretchBlt */ NULL, /* pStretchDIBits */ - NULL, /* pStrokeAndFillPath */ - NULL, /* pStrokePath */ + nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */ + nulldrv_StrokePath, /* pStrokePath */ nulldrv_SwapBuffers, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ - NULL, /* pWidenPath */ + nulldrv_WidenPath, /* pWidenPath */ nulldrv_wglCopyContext, /* pwglCopyContext */ nulldrv_wglCreateContext, /* pwglCreateContext */ nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */ diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index db7fdc8a849..f3462001487 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -514,11 +514,17 @@ extern INT mirror_region( HRGN dst, HRGN src, INT width ) DECLSPEC_HIDDEN; extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y ) DECLSPEC_HIDDEN; /* null driver entry points */ +extern BOOL CDECL nulldrv_AbortPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT start, FLOAT sweep ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_BeginPath( PHYSDEV dev ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_CloseFigure( PHYSDEV dev ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_EndPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern INT CDECL nulldrv_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN; extern INT CDECL nulldrv_ExtSelectClipRgn( PHYSDEV dev, HRGN rgn, INT mode ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_FillPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_FillRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_FlattenPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, INT height ) DECLSPEC_HIDDEN; extern COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern INT CDECL nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN; @@ -532,11 +538,15 @@ extern BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE extern BOOL CDECL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_ScaleViewportExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_ScaleWindowExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN; extern INT CDECL nulldrv_SetMapMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN; extern BOOL CDECL nulldrv_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN; +extern BOOL CDECL nulldrv_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN; static inline DC *get_nulldrv_dc( PHYSDEV dev ) { diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index 37339e891f7..592affa5c8d 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -129,27 +129,15 @@ static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point) */ BOOL WINAPI BeginPath(HDC hdc) { - BOOL ret = TRUE; + BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pBeginPath) - ret = dc->funcs->pBeginPath(dc->physDev); - else + if (dc) { - /* If path is already open, do nothing */ - if(dc->path.state != PATH_Open) - { - /* Make sure that path is empty */ - PATH_EmptyPath(&dc->path); - - /* Initialize variables for new path */ - dc->path.newStroke=TRUE; - dc->path.state=PATH_Open; - } + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pBeginPath ); + ret = physdev->funcs->pBeginPath( physdev ); + release_dc_ptr( dc ); } - release_dc_ptr( dc ); return ret; } @@ -159,25 +147,15 @@ BOOL WINAPI BeginPath(HDC hdc) */ BOOL WINAPI EndPath(HDC hdc) { - BOOL ret = TRUE; + BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pEndPath) - ret = dc->funcs->pEndPath(dc->physDev); - else + if (dc) { - /* Check that path is currently being constructed */ - if(dc->path.state!=PATH_Open) - { - SetLastError(ERROR_CAN_NOT_COMPLETE); - ret = FALSE; - } - /* Set flag to indicate that path is finished */ - else dc->path.state=PATH_Closed; + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEndPath ); + ret = physdev->funcs->pEndPath( physdev ); + release_dc_ptr( dc ); } - release_dc_ptr( dc ); return ret; } @@ -198,16 +176,15 @@ BOOL WINAPI EndPath(HDC hdc) */ BOOL WINAPI AbortPath( HDC hdc ) { - BOOL ret = TRUE; + BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pAbortPath) - ret = dc->funcs->pAbortPath(dc->physDev); - else /* Remove all entries from the path */ - PATH_EmptyPath( &dc->path ); - release_dc_ptr( dc ); + if (dc) + { + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pAbortPath ); + ret = physdev->funcs->pAbortPath( physdev ); + release_dc_ptr( dc ); + } return ret; } @@ -219,33 +196,15 @@ BOOL WINAPI AbortPath( HDC hdc ) */ BOOL WINAPI CloseFigure(HDC hdc) { - BOOL ret = TRUE; + BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pCloseFigure) - ret = dc->funcs->pCloseFigure(dc->physDev); - else + if (dc) { - /* Check that path is open */ - if(dc->path.state!=PATH_Open) - { - SetLastError(ERROR_CAN_NOT_COMPLETE); - ret = FALSE; - } - else - { - /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */ - /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */ - if(dc->path.numEntriesUsed) - { - dc->path.pFlags[dc->path.numEntriesUsed-1]|=PT_CLOSEFIGURE; - dc->path.newStroke=TRUE; - } - } + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pCloseFigure ); + ret = physdev->funcs->pCloseFigure( physdev ); + release_dc_ptr( dc ); } - release_dc_ptr( dc ); return ret; } @@ -340,16 +299,6 @@ static BOOL PATH_FillPath(DC *dc, GdiPath *pPath) XFORM xform; HRGN hrgn; - if(dc->funcs->pFillPath) - return dc->funcs->pFillPath(dc->physDev); - - /* Check that path is closed */ - if(pPath->state!=PATH_Closed) - { - SetLastError(ERROR_CAN_NOT_COMPLETE); - return FALSE; - } - /* Construct a region from the path and fill it */ if(PATH_PathToRegion(pPath, dc->polyFillMode, &hrgn)) { @@ -414,25 +363,16 @@ static BOOL PATH_FillPath(DC *dc, GdiPath *pPath) */ BOOL WINAPI FillPath(HDC hdc) { + BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - BOOL bRet = FALSE; - if(!dc) return FALSE; - - if(dc->funcs->pFillPath) - bRet = dc->funcs->pFillPath(dc->physDev); - else + if (dc) { - bRet = PATH_FillPath(dc, &dc->path); - if(bRet) - { - /* FIXME: Should the path be emptied even if conversion - failed? */ - PATH_EmptyPath(&dc->path); - } + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFillPath ); + ret = physdev->funcs->pFillPath( physdev ); + release_dc_ptr( dc ); } - release_dc_ptr( dc ); - return bRet; + return ret; } @@ -443,36 +383,16 @@ BOOL WINAPI FillPath(HDC hdc) */ BOOL WINAPI SelectClipPath(HDC hdc, INT iMode) { - GdiPath *pPath; - HRGN hrgnPath; - BOOL success = FALSE; - DC *dc = get_dc_ptr( hdc ); + BOOL ret = FALSE; + DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pSelectClipPath) - success = dc->funcs->pSelectClipPath(dc->physDev, iMode); - else - { - pPath = &dc->path; - - /* Check that path is closed */ - if(pPath->state!=PATH_Closed) - SetLastError(ERROR_CAN_NOT_COMPLETE); - /* Construct a region from the path */ - else if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnPath)) - { - success = ExtSelectClipRgn( hdc, hrgnPath, iMode ) != ERROR; - DeleteObject(hrgnPath); - - /* Empty the path */ - if(success) - PATH_EmptyPath(pPath); - /* FIXME: Should this function delete the path even if it failed? */ - } - } - release_dc_ptr( dc ); - return success; + if (dc) + { + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectClipPath ); + ret = physdev->funcs->pSelectClipPath( physdev, iMode ); + release_dc_ptr( dc ); + } + return ret; } @@ -1688,16 +1608,12 @@ BOOL WINAPI FlattenPath(HDC hdc) BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pFlattenPath) ret = dc->funcs->pFlattenPath(dc->physDev); - else + if (dc) { - GdiPath *pPath = &dc->path; - if(pPath->state != PATH_Closed) - ret = PATH_FlattenPath(pPath); + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath ); + ret = physdev->funcs->pFlattenPath( physdev ); + release_dc_ptr( dc ); } - release_dc_ptr( dc ); return ret; } @@ -1712,12 +1628,6 @@ static BOOL PATH_StrokePath(DC *dc, GdiPath *pPath) XFORM xform; BOOL ret = TRUE; - if(dc->funcs->pStrokePath) - return dc->funcs->pStrokePath(dc->physDev); - - if(pPath->state != PATH_Closed) - return FALSE; - /* Save the mapping mode info */ mapMode=GetMapMode(dc->hSelf); GetViewportExtEx(dc->hSelf, &szViewportExt); @@ -1848,11 +1758,6 @@ static BOOL PATH_WidenPath(DC *dc) pPath = &dc->path; - if(pPath->state == PATH_Open) { - SetLastError(ERROR_CAN_NOT_COMPLETE); - return FALSE; - } - PATH_FlattenPath(pPath); size = GetObjectW( dc->hPen, 0, NULL ); @@ -2156,21 +2061,16 @@ static BOOL PATH_WidenPath(DC *dc) */ BOOL WINAPI StrokeAndFillPath(HDC hdc) { - DC *dc = get_dc_ptr( hdc ); - BOOL bRet = FALSE; + BOOL ret = FALSE; + DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pStrokeAndFillPath) - bRet = dc->funcs->pStrokeAndFillPath(dc->physDev); - else - { - bRet = PATH_FillPath(dc, &dc->path); - if(bRet) bRet = PATH_StrokePath(dc, &dc->path); - if(bRet) PATH_EmptyPath(&dc->path); - } - release_dc_ptr( dc ); - return bRet; + if (dc) + { + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath ); + ret = physdev->funcs->pStrokeAndFillPath( physdev ); + release_dc_ptr( dc ); + } + return ret; } @@ -2181,23 +2081,16 @@ BOOL WINAPI StrokeAndFillPath(HDC hdc) */ BOOL WINAPI StrokePath(HDC hdc) { + BOOL ret = FALSE; DC *dc = get_dc_ptr( hdc ); - GdiPath *pPath; - BOOL bRet = FALSE; - TRACE("(%p)\n", hdc); - if(!dc) return FALSE; - - if(dc->funcs->pStrokePath) - bRet = dc->funcs->pStrokePath(dc->physDev); - else + if (dc) { - pPath = &dc->path; - bRet = PATH_StrokePath(dc, pPath); - PATH_EmptyPath(pPath); + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath ); + ret = physdev->funcs->pStrokePath( physdev ); + release_dc_ptr( dc ); } - release_dc_ptr( dc ); - return bRet; + return ret; } @@ -2208,15 +2101,160 @@ BOOL WINAPI StrokePath(HDC hdc) */ BOOL WINAPI WidenPath(HDC hdc) { - DC *dc = get_dc_ptr( hdc ); - BOOL ret = FALSE; + BOOL ret = FALSE; + DC *dc = get_dc_ptr( hdc ); - if(!dc) return FALSE; - - if(dc->funcs->pWidenPath) - ret = dc->funcs->pWidenPath(dc->physDev); - else - ret = PATH_WidenPath(dc); - release_dc_ptr( dc ); - return ret; + if (dc) + { + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath ); + ret = physdev->funcs->pWidenPath( physdev ); + release_dc_ptr( dc ); + } + return ret; +} + + +/*********************************************************************** + * null driver fallback implementations + */ + +BOOL CDECL nulldrv_BeginPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + /* If path is already open, do nothing */ + if (dc->path.state != PATH_Open) + { + PATH_EmptyPath(&dc->path); + dc->path.newStroke = TRUE; + dc->path.state = PATH_Open; + } + return TRUE; +} + +BOOL CDECL nulldrv_EndPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state != PATH_Open) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + dc->path.state = PATH_Closed; + return TRUE; +} + +BOOL CDECL nulldrv_AbortPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + PATH_EmptyPath( &dc->path ); + return TRUE; +} + +BOOL CDECL nulldrv_CloseFigure( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state != PATH_Open) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */ + /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */ + if (dc->path.numEntriesUsed) + { + dc->path.pFlags[dc->path.numEntriesUsed - 1] |= PT_CLOSEFIGURE; + dc->path.newStroke = TRUE; + } + return TRUE; +} + +BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode ) +{ + BOOL ret; + HRGN hrgn; + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state != PATH_Closed) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + if (!PATH_PathToRegion( &dc->path, GetPolyFillMode(dev->hdc), &hrgn )) return FALSE; + ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR; + if (ret) PATH_EmptyPath( &dc->path ); + /* FIXME: Should this function delete the path even if it failed? */ + DeleteObject( hrgn ); + return ret; +} + +BOOL CDECL nulldrv_FillPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state != PATH_Closed) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + if (!PATH_FillPath( dc, &dc->path )) return FALSE; + /* FIXME: Should the path be emptied even if conversion failed? */ + PATH_EmptyPath( &dc->path ); + return TRUE; +} + +BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state != PATH_Closed) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + if (!PATH_FillPath( dc, &dc->path )) return FALSE; + if (!PATH_StrokePath( dc, &dc->path )) return FALSE; + PATH_EmptyPath( &dc->path ); + return TRUE; +} + +BOOL CDECL nulldrv_StrokePath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state != PATH_Closed) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + if (!PATH_StrokePath( dc, &dc->path )) return FALSE; + PATH_EmptyPath( &dc->path ); + return TRUE; +} + +BOOL CDECL nulldrv_FlattenPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state == PATH_Closed) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + return PATH_FlattenPath( &dc->path ); +} + +BOOL CDECL nulldrv_WidenPath( PHYSDEV dev ) +{ + DC *dc = get_nulldrv_dc( dev ); + + if (dc->path.state == PATH_Open) + { + SetLastError( ERROR_CAN_NOT_COMPLETE ); + return FALSE; + } + return PATH_WidenPath( dc ); }