Alexandre Julliard : gdi32: Allow removing a driver from the stack based on its function table.

Alexandre Julliard julliard at winehq.org
Tue Aug 21 13:40:18 CDT 2012


Module: wine
Branch: master
Commit: bf528c5e9cba7ee95427c924b7d1ae7af50d0a8c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bf528c5e9cba7ee95427c924b7d1ae7af50d0a8c

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Aug 21 12:59:18 2012 +0200

gdi32: Allow removing a driver from the stack based on its function table.

---

 dlls/gdi32/gdi_private.h |    7 ++++---
 dlls/gdi32/path.c        |   46 ++++++++++++++++------------------------------
 2 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 78ff1a7..bb1a5d1 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -170,11 +170,12 @@ static inline INT GDI_ROUND(double val)
 #define GET_DC_PHYSDEV(dc,func) \
     get_physdev_entry_point( (dc)->physDev, FIELD_OFFSET(struct gdi_dc_funcs,func))
 
-static inline PHYSDEV pop_dc_driver( DC *dc, PHYSDEV dev )
+static inline PHYSDEV pop_dc_driver( DC *dc, const struct gdi_dc_funcs *funcs )
 {
-    PHYSDEV *pdev = &dc->physDev;
-    while (*pdev && *pdev != dev) pdev = &(*pdev)->next;
+    PHYSDEV dev, *pdev = &dc->physDev;
+    while (*pdev && (*pdev)->funcs != funcs) pdev = &(*pdev)->next;
     if (!*pdev) return NULL;
+    dev = *pdev;
     *pdev = dev->next;
     return dev;
 }
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index a58f4e6..11e5e07 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -101,21 +101,6 @@ static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
     return (struct path_physdev *)dev;
 }
 
-static inline void pop_path_driver( DC *dc, struct path_physdev *physdev )
-{
-    pop_dc_driver( dc, &physdev->dev );
-    HeapFree( GetProcessHeap(), 0, physdev );
-}
-
-static inline struct path_physdev *find_path_physdev( DC *dc )
-{
-    PHYSDEV dev;
-
-    for (dev = dc->physDev; dev->funcs != &null_driver; dev = dev->next)
-        if (dev->funcs == &path_driver) return get_path_physdev( dev );
-    return NULL;
-}
-
 void free_gdi_path( struct gdi_path *path )
 {
     HeapFree( GetProcessHeap(), 0, path->points );
@@ -805,7 +790,8 @@ static BOOL pathdrv_AbortPath( PHYSDEV dev )
 
     if (!dc) return FALSE;
     free_gdi_path( physdev->path );
-    pop_path_driver( dc, physdev );
+    pop_dc_driver( dc, &path_driver );
+    HeapFree( GetProcessHeap(), 0, physdev );
     release_dc_ptr( dc );
     return TRUE;
 }
@@ -821,7 +807,8 @@ static BOOL pathdrv_EndPath( PHYSDEV dev )
 
     if (!dc) return FALSE;
     dc->path = physdev->path;
-    pop_path_driver( dc, physdev );
+    pop_dc_driver( dc, &path_driver );
+    HeapFree( GetProcessHeap(), 0, physdev );
     release_dc_ptr( dc );
     return TRUE;
 }
@@ -874,26 +861,25 @@ BOOL PATH_SavePath( DC *dst, DC *src )
 
 BOOL PATH_RestorePath( DC *dst, DC *src )
 {
-    struct path_physdev *physdev = find_path_physdev( dst );
+    PHYSDEV dev;
+    struct path_physdev *physdev;
 
-    if (src->path && src->path_open)
+    if ((dev = pop_dc_driver( dst, &path_driver )))
     {
-        if (!physdev)
-        {
-            if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
-            physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
-        }
-        else free_gdi_path( physdev->path );
+        physdev = get_path_physdev( dev );
+        free_gdi_path( physdev->path );
+        HeapFree( GetProcessHeap(), 0, physdev );
+    }
 
+    if (src->path && src->path_open)
+    {
+        if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
+        physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
         physdev->path = src->path;
         src->path_open = FALSE;
         src->path = NULL;
     }
-    else if (physdev)
-    {
-        free_gdi_path( physdev->path );
-        pop_path_driver( dst, physdev );
-    }
+
     if (dst->path) free_gdi_path( dst->path );
     dst->path = src->path;
     src->path = NULL;




More information about the wine-cvs mailing list