Commit 01abb3d1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: implemeted GdipGetPathGradientBlendCount with test.

parent 5e3786f8
...@@ -75,6 +75,24 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone) ...@@ -75,6 +75,24 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF)); memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
memcpy(dest->pathdata.Types, src->pathdata.Types, count); 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; break;
} }
case BrushTypeLinearGradient: case BrushTypeLinearGradient:
...@@ -213,6 +231,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points, ...@@ -213,6 +231,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
*grad = GdipAlloc(sizeof(GpPathGradient)); *grad = GdipAlloc(sizeof(GpPathGradient));
if (!*grad) return OutOfMemory; 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.Count = count;
(*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF)); (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
(*grad)->pathdata.Types = GdipAlloc(count); (*grad)->pathdata.Types = GdipAlloc(count);
...@@ -284,6 +311,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, ...@@ -284,6 +311,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
*grad = GdipAlloc(sizeof(GpPathGradient)); *grad = GdipAlloc(sizeof(GpPathGradient));
if (!*grad) return OutOfMemory; 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.Count = path->pathdata.Count;
(*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF)); (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
(*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count); (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
...@@ -476,6 +512,8 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush) ...@@ -476,6 +512,8 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
case BrushTypePathGradient: case BrushTypePathGradient:
GdipFree(((GpPathGradient*) brush)->pathdata.Points); GdipFree(((GpPathGradient*) brush)->pathdata.Points);
GdipFree(((GpPathGradient*) brush)->pathdata.Types); GdipFree(((GpPathGradient*) brush)->pathdata.Types);
GdipFree(((GpPathGradient*) brush)->blendfac);
GdipFree(((GpPathGradient*) brush)->blendpos);
break; break;
case BrushTypeSolidColor: case BrushTypeSolidColor:
case BrushTypeLinearGradient: case BrushTypeLinearGradient:
...@@ -511,6 +549,16 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapm ...@@ -511,6 +549,16 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapm
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
{
if(!brush || !count)
return InvalidParameter;
*count = brush->blendcount;
return Ok;
}
GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad, GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
GpPointF *point) GpPointF *point)
{ {
......
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
@ stdcall GdipGetPathData(ptr ptr) @ stdcall GdipGetPathData(ptr ptr)
@ stdcall GdipGetPathFillMode(ptr ptr) @ stdcall GdipGetPathFillMode(ptr ptr)
@ stub GdipGetPathGradientBlend @ stub GdipGetPathGradientBlend
@ stub GdipGetPathGradientBlendCount @ stdcall GdipGetPathGradientBlendCount(ptr ptr)
@ stub GdipGetPathGradientCenterColor @ stub GdipGetPathGradientCenterColor
@ stdcall GdipGetPathGradientCenterPoint(ptr ptr) @ stdcall GdipGetPathGradientCenterPoint(ptr ptr)
@ stdcall GdipGetPathGradientCenterPointI(ptr ptr) @ stdcall GdipGetPathGradientCenterPointI(ptr ptr)
......
...@@ -105,6 +105,9 @@ struct GpPathGradient{ ...@@ -105,6 +105,9 @@ struct GpPathGradient{
BOOL gamma; BOOL gamma;
GpPointF center; GpPointF center;
GpPointF focus; GpPointF focus;
REAL* blendfac; /* blend factors */
REAL* blendpos; /* blend positions */
INT blendcount;
}; };
struct GpLineGradient{ struct GpLineGradient{
......
...@@ -54,6 +54,30 @@ static void test_type(void) ...@@ -54,6 +54,30 @@ static void test_type(void)
GdipDeleteBrush((GpBrush*) brush); 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) START_TEST(brush)
{ {
...@@ -69,6 +93,7 @@ START_TEST(brush) ...@@ -69,6 +93,7 @@ START_TEST(brush)
test_constructor_destructor(); test_constructor_destructor();
test_type(); test_type();
test_gradientblendcount();
GdiplusShutdown(gdiplusToken); GdiplusShutdown(gdiplusToken);
} }
...@@ -199,6 +199,7 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient*,GpWrapMode*); ...@@ -199,6 +199,7 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient*,GpWrapMode*);
GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient*,GpRectF*); GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient*,GpRectF*);
GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient*,GpRect*); GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient*,GpRect*);
GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient*,ARGB*); GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient*,ARGB*);
GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient*,INT*);
GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient*,ARGB*); GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient*,ARGB*);
GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient*,GpPointF*); GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient*,GpPointF*);
GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient*,GpPoint*); GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient*,GpPoint*);
......
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