gdiplus: Implement GdipGetRegionScansCount.

This commit is contained in:
Vincent Povirk 2010-09-30 14:59:04 -05:00 committed by Alexandre Julliard
parent 40d8876fc4
commit 473afa4b8c
3 changed files with 137 additions and 4 deletions

View File

@ -1362,14 +1362,82 @@ GpStatus WINGDIPAPI GdipTranslateRegionI(GpRegion *region, INT dx, INT dy)
return GdipTranslateRegion(region, (REAL)dx, (REAL)dy); return GdipTranslateRegion(region, (REAL)dx, (REAL)dy);
} }
static GpStatus get_region_scans_data(GpRegion *region, GpMatrix *matrix, LPRGNDATA *data)
{
GpRegion *region_copy;
GpStatus stat;
HRGN hrgn;
DWORD data_size;
stat = GdipCloneRegion(region, &region_copy);
if (stat == Ok)
{
stat = GdipTransformRegion(region_copy, matrix);
if (stat == Ok)
stat = GdipGetRegionHRgn(region_copy, NULL, &hrgn);
if (stat == Ok)
{
if (hrgn)
{
data_size = GetRegionData(hrgn, 0, NULL);
*data = GdipAlloc(data_size);
if (*data)
GetRegionData(hrgn, data_size, *data);
else
stat = OutOfMemory;
DeleteObject(hrgn);
}
else
{
data_size = sizeof(RGNDATAHEADER) + sizeof(RECT);
*data = GdipAlloc(data_size);
if (*data)
{
(*data)->rdh.dwSize = sizeof(RGNDATAHEADER);
(*data)->rdh.iType = RDH_RECTANGLES;
(*data)->rdh.nCount = 1;
(*data)->rdh.nRgnSize = sizeof(RECT);
(*data)->rdh.rcBound.left = (*data)->rdh.rcBound.top = -0x400000;
(*data)->rdh.rcBound.right = (*data)->rdh.rcBound.bottom = 0x400000;
memcpy(&(*data)->Buffer, &(*data)->rdh.rcBound, sizeof(RECT));
}
else
stat = OutOfMemory;
}
}
GdipDeleteRegion(region_copy);
}
return stat;
}
GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMatrix *matrix) GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMatrix *matrix)
{ {
static int calls; GpStatus stat;
LPRGNDATA data;
TRACE("(%p, %p, %p)\n", region, count, matrix); TRACE("(%p, %p, %p)\n", region, count, matrix);
if (!(calls++)) if (!region || !count || !matrix)
FIXME("not implemented\n"); return InvalidParameter;
return NotImplemented; stat = get_region_scans_data(region, matrix, &data);
if (stat == Ok)
{
*count = data->rdh.nCount;
GdipFree(data);
}
return stat;
} }

View File

@ -1230,6 +1230,69 @@ static void test_transform(void)
ReleaseDC(0, hdc); ReleaseDC(0, hdc);
} }
static void test_scans(void)
{
GpRegion *region;
GpMatrix *matrix;
GpRectF rectf;
GpStatus status;
ULONG count=80085;
status = GdipCreateRegion(&region);
expect(Ok, status);
status = GdipCreateMatrix(&matrix);
expect(Ok, status);
/* test NULL values */
status = GdipGetRegionScansCount(NULL, &count, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScansCount(region, NULL, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScansCount(region, &count, NULL);
expect(InvalidParameter, status);
/* infinite */
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(1, count);
/* empty */
status = GdipSetEmpty(region);
expect(Ok, status);
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(0, count);
/* single rectangle */
rectf.X = rectf.Y = 0.0;
rectf.Width = rectf.Height = 5.0;
status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
expect(Ok, status);
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(1, count);
/* two rectangles */
rectf.X = rectf.Y = 5.0;
rectf.Width = rectf.Height = 5.0;
status = GdipCombineRegionRect(region, &rectf, CombineModeUnion);
expect(Ok, status);
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(2, count);
status = GdipDeleteRegion(region);
expect(Ok, status);
status = GdipDeleteMatrix(matrix);
expect(Ok, status);
}
static void test_getbounds(void) static void test_getbounds(void)
{ {
GpRegion *region; GpRegion *region;
@ -1742,6 +1805,7 @@ START_TEST(region)
test_isequal(); test_isequal();
test_translate(); test_translate();
test_transform(); test_transform();
test_scans();
test_getbounds(); test_getbounds();
test_isvisiblepoint(); test_isvisiblepoint();
test_isvisiblerect(); test_isvisiblerect();

View File

@ -643,6 +643,7 @@ GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *, GpGraphics *, GpRect *);
GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *, BYTE *, UINT, UINT *); GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *, BYTE *, UINT, UINT *);
GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *, UINT *); GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *, UINT *);
GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *, GpGraphics *, HRGN *); GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *, GpGraphics *, HRGN *);
GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *, UINT *, GpMatrix *);
GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *, GpGraphics *, BOOL *); GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *, GpGraphics *, BOOL *);
GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *, GpRegion *, GpGraphics *, BOOL *); GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *, GpRegion *, GpGraphics *, BOOL *);
GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *, GpGraphics *, BOOL *); GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *, GpGraphics *, BOOL *);