[5/6] gdiplus: GdipGetDC/GdipReleaseDC partial stubs (bug 10903)
Nikolay Sivov
bunglehead at gmail.com
Mon May 19 11:34:48 CDT 2008
Changelog:
- GdipGetDC/GdipReleaseDC partial stubs with some tests
---
dlls/gdiplus/gdiplus_private.h | 1 +
dlls/gdiplus/graphics.c | 30 ++++++++++++++++++++++++------
dlls/gdiplus/tests/graphics.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 539254b..f809218 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -74,6 +74,7 @@ struct GpPen{
struct GpGraphics{
HDC hdc;
+ BOOL hdc_returned;
HWND hwnd;
SmoothingMode smoothing;
CompositingQuality compqual;
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 45794f0..376e3c3 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -773,6 +773,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
}
(*graphics)->hdc = hdc;
+ (*graphics)->hdc_returned = FALSE;
(*graphics)->hwnd = NULL;
(*graphics)->smoothing = SmoothingModeDefault;
(*graphics)->compqual = CompositingQualityDefault;
@@ -2427,20 +2428,37 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G
return ret;
}
-
+/* FIXME: every Graphics method should check hdc_returned and
+ return ObjectBusy on TRUE */
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
{
- FIXME("(%p, %p): stub\n", graphics, hdc);
+ FIXME("(%p, %p): semi stub\n", graphics, hdc);
- *hdc = NULL;
- return NotImplemented;
+ if(!graphics || !hdc)
+ return InvalidParameter;
+
+ if(graphics->hdc_returned)
+ return ObjectBusy;
+
+ *hdc = graphics->hdc;
+ graphics->hdc_returned = TRUE;
+
+ return Ok;
}
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
{
- FIXME("(%p, %p): stub\n", graphics, hdc);
+ FIXME("(%p, %p): semi stub\n", graphics, hdc);
- return NotImplemented;
+ if(!graphics)
+ return InvalidParameter;
+
+ if(!(graphics->hdc == hdc))
+ return InvalidParameter;
+
+ graphics->hdc_returned = 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 168eae3..e029da6 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -452,6 +452,43 @@ static void test_GdipDrawLinesI(void)
ReleaseDC(0, hdc);
}
+static void test_GetReleaseHDC(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ HDC hdc = GetDC(0);
+ HDC hdc2 = NULL;
+
+ /* make a graphics object */
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+ /* return HDC */
+ status = GdipGetDC(graphics, &hdc2);
+ expect(Ok, status);
+ ok(hdc2 == hdc, "Wrong HDC returned\n");
+
+ /* next GetHDC() call should return busy state */
+ status = GdipGetDC(graphics, &hdc2);
+ expect(ObjectBusy, status);
+
+ /* releasing, HDC passed by value */
+ status = GdipReleaseDC(graphics, NULL);
+ expect(InvalidParameter, status);
+
+ status = GdipReleaseDC(graphics, hdc2);
+ expect(Ok, status);
+
+ /* check that GetHDC() available again */
+ status = GdipGetDC(graphics, &hdc2);
+ expect(Ok, status);
+ ok(hdc2 == hdc, "Wrong HDC returned\n");
+
+ status = GdipReleaseDC(graphics, hdc2);
+ expect(Ok, status);
+}
+
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -466,6 +503,7 @@ START_TEST(graphics)
test_constructor_destructor();
test_save_restore();
+ test_GetReleaseHDC();
test_GdipDrawBezierI();
test_GdipDrawArc();
test_GdipDrawArcI();
--
1.4.4.4
More information about the wine-patches
mailing list