Commit 366ae1e6 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Basic GdipGetDC/GdipReleaseDC implementation.

parent 45705011
...@@ -95,6 +95,7 @@ struct GpGraphics{ ...@@ -95,6 +95,7 @@ struct GpGraphics{
GpUnit unit; /* page unit */ GpUnit unit; /* page unit */
REAL scale; /* page scale */ REAL scale; /* page scale */
GpMatrix * worldtrans; /* world transform */ GpMatrix * worldtrans; /* world transform */
BOOL busy; /* hdc handle obtained by GdipGetDC */
}; };
struct GpBrush{ struct GpBrush{
......
...@@ -752,6 +752,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra ...@@ -752,6 +752,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
(*graphics)->compmode = CompositingModeSourceOver; (*graphics)->compmode = CompositingModeSourceOver;
(*graphics)->unit = UnitDisplay; (*graphics)->unit = UnitDisplay;
(*graphics)->scale = 1.0; (*graphics)->scale = 1.0;
(*graphics)->busy = FALSE;
return Ok; return Ok;
} }
...@@ -2679,26 +2680,29 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G ...@@ -2679,26 +2680,29 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc) GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
{ {
FIXME("(%p, %p): stub\n", graphics, hdc);
if(!graphics || !hdc) if(!graphics || !hdc)
return InvalidParameter; return InvalidParameter;
*hdc = NULL; if(graphics->busy)
return NotImplemented; return ObjectBusy;
*hdc = graphics->hdc;
graphics->busy = TRUE;
return Ok;
} }
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc) GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
{ {
FIXME("(%p, %p): stub\n", graphics, hdc);
if(!graphics) if(!graphics)
return InvalidParameter; return InvalidParameter;
if(graphics->hdc != hdc) if(graphics->hdc != hdc || !(graphics->busy))
return InvalidParameter; return InvalidParameter;
return NotImplemented; graphics->busy = FALSE;
return Ok;
} }
GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region) GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
......
...@@ -545,13 +545,17 @@ static void test_Get_Release_DC(void) ...@@ -545,13 +545,17 @@ static void test_Get_Release_DC(void)
status = GdipReleaseDC(NULL, (HDC)0xdeadbeef); status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
expect(InvalidParameter, status); expect(InvalidParameter, status);
/* Release without Get */
status = GdipReleaseDC(graphics, hdc);
expect(InvalidParameter, status);
retdc = NULL; retdc = NULL;
status = GdipGetDC(graphics, &retdc); status = GdipGetDC(graphics, &retdc);
todo_wine expect(Ok, status); expect(Ok, status);
todo_wine ok(retdc == hdc, "Invalid HDC returned\n"); ok(retdc == hdc, "Invalid HDC returned\n");
/* call it once more */ /* call it once more */
status = GdipGetDC(graphics, &retdc); status = GdipGetDC(graphics, &retdc);
todo_wine expect(ObjectBusy, status); expect(ObjectBusy, status);
/* try all Graphics calls here */ /* try all Graphics calls here */
status = Ok; status = Ok;
...@@ -712,7 +716,7 @@ static void test_Get_Release_DC(void) ...@@ -712,7 +716,7 @@ static void test_Get_Release_DC(void)
todo_wine expect(ObjectBusy, status); status = Ok; todo_wine expect(ObjectBusy, status); status = Ok;
status = GdipReleaseDC(graphics, retdc); status = GdipReleaseDC(graphics, retdc);
todo_wine expect(Ok, status); expect(Ok, status);
GdipDeletePen(pen); GdipDeletePen(pen);
GdipDeleteGraphics(graphics); GdipDeleteGraphics(graphics);
......
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