[5/6] gdiplus: basic GdipGetDC/GdipReleaseDC implementation (try2)

Nikolay Sivov bunglehead at gmail.com
Sat Aug 23 16:29:23 CDT 2008


Changelog:
    - basic GdipGetDC/GdipReleaseDC implementation (no calls affected except GdipGetDC)

---
 dlls/gdiplus/gdiplus_private.h |    1 +
 dlls/gdiplus/graphics.c        |   20 ++++++++++++--------
 dlls/gdiplus/tests/graphics.c  |   24 ++++++++++++++----------
 3 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 5a18660..8df1c74 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -95,6 +95,7 @@ struct GpGraphics{
     GpUnit unit;    /* page unit */
     REAL scale;     /* page scale */
     GpMatrix * worldtrans; /* world transform */
+    BOOL busy;      /* hdc handle obtained by GdipGetDC */
 };
 
 struct GpBrush{
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index b852103..7bc0f03 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -752,6 +752,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
     (*graphics)->compmode = CompositingModeSourceOver;
     (*graphics)->unit = UnitDisplay;
     (*graphics)->scale = 1.0;
+    (*graphics)->busy = FALSE;
 
     return Ok;
 }
@@ -2679,26 +2680,29 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G
 
 GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
 {
-    FIXME("(%p, %p): stub\n", graphics, hdc);
-
     if(!graphics || !hdc)
         return InvalidParameter;
 
-    *hdc = NULL;
-    return NotImplemented;
+    if(graphics->busy)
+        return ObjectBusy;
+
+    *hdc = graphics->hdc;
+    graphics->busy = TRUE;
+
+    return Ok;
 }
 
 GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
 {
-    FIXME("(%p, %p): stub\n", graphics, hdc);
-
     if(!graphics)
         return InvalidParameter;
 
-    if(graphics->hdc != hdc)
+    if(graphics->hdc != hdc || !(graphics->busy))
         return InvalidParameter;
 
-    return NotImplemented;
+    graphics->busy = FALSE;
+
+    return Ok;
 }
 
 GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 5ebda10..964cbd4 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -532,26 +532,30 @@ static void test_Get_Release_DC(void)
 
     /* NULL arguments */
     status = GdipGetDC(NULL, NULL);
-    todo_wine expect(InvalidParameter, status);
+    expect(InvalidParameter, status);
     status = GdipGetDC(graphics, NULL);
-    todo_wine expect(InvalidParameter, status);
+    expect(InvalidParameter, status);
     status = GdipGetDC(NULL, &retdc);
-    todo_wine expect(InvalidParameter, status);
+    expect(InvalidParameter, status);
 
     status = GdipReleaseDC(NULL, (HDC)0);
-    todo_wine expect(InvalidParameter, status);
+    expect(InvalidParameter, status);
     status = GdipReleaseDC(graphics, (HDC)0);
-    todo_wine expect(InvalidParameter, status);
+    expect(InvalidParameter, status);
     status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
-    todo_wine expect(InvalidParameter, status);
+    expect(InvalidParameter, status);
+
+    /* Release without Get */
+    status = GdipReleaseDC(graphics, hdc);
+    expect(InvalidParameter, status);
 
     retdc = NULL;
     status = GdipGetDC(graphics, &retdc);
-    todo_wine expect(Ok, status);
-    todo_wine ok(retdc == hdc, "Invalid HDC returned\n");
+    expect(Ok, status);
+    ok(retdc == hdc, "Invalid HDC returned\n");
     /* call it once more */
     status = GdipGetDC(graphics, &retdc);
-    todo_wine expect(ObjectBusy, status);
+    expect(ObjectBusy, status);
 
     /* try all Graphics calls here */
     status = Ok;
@@ -712,7 +716,7 @@ static void test_Get_Release_DC(void)
     todo_wine expect(ObjectBusy, status); status = Ok;
 
     status = GdipReleaseDC(graphics, retdc);
-    todo_wine expect(Ok, status);
+    expect(Ok, status);
 
     GdipDeletePen(pen);
     GdipDeleteGraphics(graphics);
-- 
1.4.4.4






More information about the wine-patches mailing list