gdiplus: implemeted GdipGetPathGradientBlendCount with test.

This commit is contained in:
Nikolay Sivov 2008-07-21 23:30:39 +04:00 committed by Alexandre Julliard
parent 5e3786f8da
commit 01abb3d1dc
5 changed files with 78 additions and 1 deletions

View file

@ -75,6 +75,24 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
memcpy(dest->pathdata.Types, src->pathdata.Types, count);
/* blending */
count = src->blendcount;
dest->blendcount = count;
dest->blendfac = GdipAlloc(count * sizeof(REAL));
dest->blendpos = GdipAlloc(count * sizeof(REAL));
if(!dest->blendfac || !dest->blendpos){
GdipFree(dest->pathdata.Points);
GdipFree(dest->pathdata.Types);
GdipFree(dest->blendfac);
GdipFree(dest->blendpos);
GdipFree(dest);
return OutOfMemory;
}
memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
break;
}
case BrushTypeLinearGradient:
@ -213,6 +231,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
*grad = GdipAlloc(sizeof(GpPathGradient));
if (!*grad) return OutOfMemory;
(*grad)->blendfac = GdipAlloc(sizeof(REAL));
if(!(*grad)->blendfac){
GdipFree(*grad);
return OutOfMemory;
}
(*grad)->blendfac[0] = 1.0;
(*grad)->blendpos = NULL;
(*grad)->blendcount = 1;
(*grad)->pathdata.Count = count;
(*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
(*grad)->pathdata.Types = GdipAlloc(count);
@ -284,6 +311,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
*grad = GdipAlloc(sizeof(GpPathGradient));
if (!*grad) return OutOfMemory;
(*grad)->blendfac = GdipAlloc(sizeof(REAL));
if(!(*grad)->blendfac){
GdipFree(*grad);
return OutOfMemory;
}
(*grad)->blendfac[0] = 1.0;
(*grad)->blendpos = NULL;
(*grad)->blendcount = 1;
(*grad)->pathdata.Count = path->pathdata.Count;
(*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
(*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
@ -476,6 +512,8 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
case BrushTypePathGradient:
GdipFree(((GpPathGradient*) brush)->pathdata.Points);
GdipFree(((GpPathGradient*) brush)->pathdata.Types);
GdipFree(((GpPathGradient*) brush)->blendfac);
GdipFree(((GpPathGradient*) brush)->blendpos);
break;
case BrushTypeSolidColor:
case BrushTypeLinearGradient:
@ -511,6 +549,16 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapm
return Ok;
}
GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
{
if(!brush || !count)
return InvalidParameter;
*count = brush->blendcount;
return Ok;
}
GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
GpPointF *point)
{

View file

@ -326,7 +326,7 @@
@ stdcall GdipGetPathData(ptr ptr)
@ stdcall GdipGetPathFillMode(ptr ptr)
@ stub GdipGetPathGradientBlend
@ stub GdipGetPathGradientBlendCount
@ stdcall GdipGetPathGradientBlendCount(ptr ptr)
@ stub GdipGetPathGradientCenterColor
@ stdcall GdipGetPathGradientCenterPoint(ptr ptr)
@ stdcall GdipGetPathGradientCenterPointI(ptr ptr)

View file

@ -105,6 +105,9 @@ struct GpPathGradient{
BOOL gamma;
GpPointF center;
GpPointF focus;
REAL* blendfac; /* blend factors */
REAL* blendpos; /* blend positions */
INT blendcount;
};
struct GpLineGradient{

View file

@ -54,6 +54,30 @@ static void test_type(void)
GdipDeleteBrush((GpBrush*) brush);
}
static GpPointF blendcount_ptf[] = {{0.0, 0.0},
{50.0, 50.0}};
static void test_gradientblendcount(void)
{
GpStatus status;
GpPathGradient *brush;
INT count;
status = GdipCreatePathGradient(blendcount_ptf, 2, WrapModeClamp, &brush);
expect(Ok, status);
status = GdipGetPathGradientBlendCount(NULL, NULL);
expect(InvalidParameter, status);
status = GdipGetPathGradientBlendCount(NULL, &count);
expect(InvalidParameter, status);
status = GdipGetPathGradientBlendCount(brush, NULL);
expect(InvalidParameter, status);
status = GdipGetPathGradientBlendCount(brush, &count);
expect(Ok, status);
expect(1, count);
GdipDeleteBrush((GpBrush*) brush);
}
START_TEST(brush)
{
@ -69,6 +93,7 @@ START_TEST(brush)
test_constructor_destructor();
test_type();
test_gradientblendcount();
GdiplusShutdown(gdiplusToken);
}

View file

@ -199,6 +199,7 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient*,GpWrapMode*);
GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient*,GpRectF*);
GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient*,GpRect*);
GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient*,ARGB*);
GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient*,INT*);
GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient*,ARGB*);
GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient*,GpPointF*);
GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient*,GpPoint*);