Commit 5f327f78 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Implement GdipGetRegionScans.

parent 90edfe08
......@@ -380,9 +380,9 @@
@ stdcall GdipGetRegionData(ptr ptr long ptr)
@ stdcall GdipGetRegionDataSize(ptr ptr)
@ stdcall GdipGetRegionHRgn(ptr ptr ptr)
@ stub GdipGetRegionScans
@ stdcall GdipGetRegionScans(ptr ptr ptr ptr)
@ stdcall GdipGetRegionScansCount(ptr ptr ptr)
@ stub GdipGetRegionScansI
@ stdcall GdipGetRegionScansI(ptr ptr ptr ptr)
@ stdcall GdipGetRenderingOrigin(ptr ptr ptr)
@ stdcall GdipGetSmoothingMode(ptr ptr)
@ stdcall GdipGetSolidFillColor(ptr ptr)
......
......@@ -1441,3 +1441,71 @@ GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMat
return stat;
}
GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *region, GpRect *scans, INT *count, GpMatrix *matrix)
{
GpStatus stat;
INT i;
LPRGNDATA data;
RECT *rects;
if (!region || !count || !matrix)
return InvalidParameter;
stat = get_region_scans_data(region, matrix, &data);
if (stat == Ok)
{
*count = data->rdh.nCount;
rects = (RECT*)&data->Buffer;
if (scans)
{
for (i=0; i<data->rdh.nCount; i++)
{
scans[i].X = rects[i].left;
scans[i].Y = rects[i].top;
scans[i].Width = rects[i].right - rects[i].left;
scans[i].Height = rects[i].bottom - rects[i].top;
}
}
GdipFree(data);
}
return Ok;
}
GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *region, GpRectF *scans, INT *count, GpMatrix *matrix)
{
GpStatus stat;
INT i;
LPRGNDATA data;
RECT *rects;
if (!region || !count || !matrix)
return InvalidParameter;
stat = get_region_scans_data(region, matrix, &data);
if (stat == Ok)
{
*count = data->rdh.nCount;
rects = (RECT*)&data->Buffer;
if (scans)
{
for (i=0; i<data->rdh.nCount; i++)
{
scans[i].X = rects[i].left;
scans[i].Y = rects[i].top;
scans[i].Width = rects[i].right - rects[i].left;
scans[i].Height = rects[i].bottom - rects[i].top;
}
}
GdipFree(data);
}
return Ok;
}
......@@ -22,6 +22,7 @@
#include "gdiplus.h"
#include "wingdi.h"
#include "wine/test.h"
#include <math.h>
#define RGNDATA_RECT 0x10000000
#define RGNDATA_PATH 0x10000001
......@@ -33,6 +34,9 @@
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
#define expectf_(expected, got, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
#define expectf(expected, got) expectf_(expected, got, 0.0001)
#define expect_magic(value) ok(*value == RGNDATA_MAGIC || *value == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *value)
#define expect_dword(value, expected) ok(*(value) == expected, "expected %08x got %08x\n", expected, *(value))
......@@ -1237,6 +1241,9 @@ static void test_scans(void)
GpRectF rectf;
GpStatus status;
ULONG count=80085;
INT icount;
GpRectF scans[2];
GpRect scansi[2];
status = GdipCreateRegion(&region);
expect(Ok, status);
......@@ -1254,11 +1261,44 @@ static void test_scans(void)
status = GdipGetRegionScansCount(region, &count, NULL);
expect(InvalidParameter, status);
status = GdipGetRegionScans(NULL, scans, &icount, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScans(region, scans, NULL, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScans(region, scans, &icount, NULL);
expect(InvalidParameter, status);
/* infinite */
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(1, count);
status = GdipGetRegionScans(region, NULL, &icount, matrix);
expect(Ok, status);
expect(1, icount);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(1, icount);
status = GdipGetRegionScansI(region, scansi, &icount, matrix);
expect(Ok, status);
expect(1, icount);
expect(-0x400000, scansi[0].X);
expect(-0x400000, scansi[0].Y);
expect(0x800000, scansi[0].Width);
expect(0x800000, scansi[0].Height);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(1, icount);
expectf((double)-0x400000, scans[0].X);
expectf((double)-0x400000, scans[0].Y);
expectf((double)0x800000, scans[0].Width);
expectf((double)0x800000, scans[0].Height);
/* empty */
status = GdipSetEmpty(region);
expect(Ok, status);
......@@ -1267,6 +1307,10 @@ static void test_scans(void)
expect(Ok, status);
expect(0, count);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(0, icount);
/* single rectangle */
rectf.X = rectf.Y = 0.0;
rectf.Width = rectf.Height = 5.0;
......@@ -1277,6 +1321,14 @@ static void test_scans(void)
expect(Ok, status);
expect(1, count);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(1, icount);
expectf(0.0, scans[0].X);
expectf(0.0, scans[0].Y);
expectf(5.0, scans[0].Width);
expectf(5.0, scans[0].Height);
/* two rectangles */
rectf.X = rectf.Y = 5.0;
rectf.Width = rectf.Height = 5.0;
......@@ -1287,6 +1339,33 @@ static void test_scans(void)
expect(Ok, status);
expect(2, count);
/* Native ignores the initial value of count */
scans[1].X = scans[1].Y = scans[1].Width = scans[1].Height = 8.0;
icount = 1;
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(2, icount);
expectf(0.0, scans[0].X);
expectf(0.0, scans[0].Y);
expectf(5.0, scans[0].Width);
expectf(5.0, scans[0].Height);
expectf(5.0, scans[1].X);
expectf(5.0, scans[1].Y);
expectf(5.0, scans[1].Width);
expectf(5.0, scans[1].Height);
status = GdipGetRegionScansI(region, scansi, &icount, matrix);
expect(Ok, status);
expect(2, icount);
expect(0, scansi[0].X);
expect(0, scansi[0].Y);
expect(5, scansi[0].Width);
expect(5, scansi[0].Height);
expect(5, scansi[1].X);
expect(5, scansi[1].Y);
expect(5, scansi[1].Width);
expect(5, scansi[1].Height);
status = GdipDeleteRegion(region);
expect(Ok, status);
status = GdipDeleteMatrix(matrix);
......
......@@ -643,6 +643,8 @@ GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *, GpGraphics *, GpRect *);
GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *, BYTE *, UINT, UINT *);
GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *, UINT *);
GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *, GpGraphics *, HRGN *);
GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *, GpRectF *, INT *, GpMatrix *);
GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *, GpRect *, INT *, GpMatrix *);
GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *, UINT *, GpMatrix *);
GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *, GpGraphics *, BOOL *);
GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *, GpRegion *, GpGraphics *, BOOL *);
......
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