gdiplus: Implement path gradient surround color accessors.
This commit is contained in:
parent
7a9f6abd85
commit
7e90dc3dc7
|
@ -83,17 +83,20 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
|
||||||
dest->blendcount = count;
|
dest->blendcount = count;
|
||||||
dest->blendfac = GdipAlloc(count * sizeof(REAL));
|
dest->blendfac = GdipAlloc(count * sizeof(REAL));
|
||||||
dest->blendpos = GdipAlloc(count * sizeof(REAL));
|
dest->blendpos = GdipAlloc(count * sizeof(REAL));
|
||||||
|
dest->surroundcolors = GdipAlloc(dest->surroundcolorcount * sizeof(ARGB));
|
||||||
|
|
||||||
if(!dest->blendfac || !dest->blendpos){
|
if(!dest->blendfac || !dest->blendpos || !dest->surroundcolors){
|
||||||
GdipDeletePath(dest->path);
|
GdipDeletePath(dest->path);
|
||||||
GdipFree(dest->blendfac);
|
GdipFree(dest->blendfac);
|
||||||
GdipFree(dest->blendpos);
|
GdipFree(dest->blendpos);
|
||||||
|
GdipFree(dest->surroundcolors);
|
||||||
GdipFree(dest);
|
GdipFree(dest);
|
||||||
return OutOfMemory;
|
return OutOfMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
|
memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
|
||||||
memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
|
memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
|
||||||
|
memcpy(dest->surroundcolors, src->surroundcolors, dest->surroundcolorcount * sizeof(ARGB));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -499,9 +502,11 @@ static GpStatus create_path_gradient(GpPath *path, GpPathGradient **grad)
|
||||||
|
|
||||||
(*grad)->blendfac = GdipAlloc(sizeof(REAL));
|
(*grad)->blendfac = GdipAlloc(sizeof(REAL));
|
||||||
(*grad)->blendpos = GdipAlloc(sizeof(REAL));
|
(*grad)->blendpos = GdipAlloc(sizeof(REAL));
|
||||||
if(!(*grad)->blendfac || !(*grad)->blendpos){
|
(*grad)->surroundcolors = GdipAlloc(sizeof(ARGB));
|
||||||
|
if(!(*grad)->blendfac || !(*grad)->blendpos || !(*grad)->surroundcolors){
|
||||||
GdipFree((*grad)->blendfac);
|
GdipFree((*grad)->blendfac);
|
||||||
GdipFree((*grad)->blendpos);
|
GdipFree((*grad)->blendpos);
|
||||||
|
GdipFree((*grad)->surroundcolors);
|
||||||
GdipFree(*grad);
|
GdipFree(*grad);
|
||||||
*grad = NULL;
|
*grad = NULL;
|
||||||
return OutOfMemory;
|
return OutOfMemory;
|
||||||
|
@ -521,6 +526,8 @@ static GpStatus create_path_gradient(GpPath *path, GpPathGradient **grad)
|
||||||
(*grad)->center.Y = bounds.Y + bounds.Height / 2;
|
(*grad)->center.Y = bounds.Y + bounds.Height / 2;
|
||||||
(*grad)->focus.X = 0.0;
|
(*grad)->focus.X = 0.0;
|
||||||
(*grad)->focus.Y = 0.0;
|
(*grad)->focus.Y = 0.0;
|
||||||
|
(*grad)->surroundcolors[0] = 0xffffffff;
|
||||||
|
(*grad)->surroundcolorcount = 1;
|
||||||
|
|
||||||
TRACE("<-- %p\n", *grad);
|
TRACE("<-- %p\n", *grad);
|
||||||
|
|
||||||
|
@ -870,6 +877,7 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
|
||||||
GdipDeletePath(((GpPathGradient*) brush)->path);
|
GdipDeletePath(((GpPathGradient*) brush)->path);
|
||||||
GdipFree(((GpPathGradient*) brush)->blendfac);
|
GdipFree(((GpPathGradient*) brush)->blendfac);
|
||||||
GdipFree(((GpPathGradient*) brush)->blendpos);
|
GdipFree(((GpPathGradient*) brush)->blendpos);
|
||||||
|
GdipFree(((GpPathGradient*) brush)->surroundcolors);
|
||||||
break;
|
break;
|
||||||
case BrushTypeLinearGradient:
|
case BrushTypeLinearGradient:
|
||||||
GdipFree(((GpLineGradient*)brush)->blendfac);
|
GdipFree(((GpLineGradient*)brush)->blendfac);
|
||||||
|
@ -1086,32 +1094,40 @@ GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect
|
||||||
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
|
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
|
||||||
*grad, ARGB *argb, INT *count)
|
*grad, ARGB *argb, INT *count)
|
||||||
{
|
{
|
||||||
static int calls;
|
INT i;
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n", grad, argb, count);
|
TRACE("(%p,%p,%p)\n", grad, argb, count);
|
||||||
|
|
||||||
if(!grad || !argb || !count || (*count < grad->path->pathdata.Count))
|
if(!grad || !argb || !count || (*count < grad->path->pathdata.Count))
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
if(!(calls++))
|
for (i=0; i<grad->path->pathdata.Count; i++)
|
||||||
FIXME("not implemented\n");
|
{
|
||||||
|
if (i < grad->surroundcolorcount)
|
||||||
|
argb[i] = grad->surroundcolors[i];
|
||||||
|
else
|
||||||
|
argb[i] = grad->surroundcolors[grad->surroundcolorcount-1];
|
||||||
|
}
|
||||||
|
|
||||||
return NotImplemented;
|
*count = grad->surroundcolorcount;
|
||||||
|
|
||||||
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
|
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
|
||||||
{
|
{
|
||||||
static int calls;
|
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", brush, count);
|
TRACE("(%p, %p)\n", brush, count);
|
||||||
|
|
||||||
if (!brush || !count)
|
if (!brush || !count)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
if(!(calls++))
|
/* Yes, this actually returns the number of points in the path (which is the
|
||||||
FIXME("not implemented\n");
|
* required size of a buffer to get the surround colors), rather than the
|
||||||
|
* number of surround colors. The real count is returned when getting the
|
||||||
|
* colors. */
|
||||||
|
*count = brush->path->pathdata.Count;
|
||||||
|
|
||||||
return NotImplemented;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
|
GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
|
||||||
|
@ -1503,7 +1519,7 @@ GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
|
||||||
GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
|
GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
|
||||||
*grad, GDIPCONST ARGB *argb, INT *count)
|
*grad, GDIPCONST ARGB *argb, INT *count)
|
||||||
{
|
{
|
||||||
static int calls;
|
ARGB *new_surroundcolors;
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n", grad, argb, count);
|
TRACE("(%p,%p,%p)\n", grad, argb, count);
|
||||||
|
|
||||||
|
@ -1511,10 +1527,18 @@ GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
|
||||||
(*count > grad->path->pathdata.Count))
|
(*count > grad->path->pathdata.Count))
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
if(!(calls++))
|
new_surroundcolors = GdipAlloc(*count * sizeof(ARGB));
|
||||||
FIXME("not implemented\n");
|
if (!new_surroundcolors)
|
||||||
|
return OutOfMemory;
|
||||||
|
|
||||||
return NotImplemented;
|
memcpy(new_surroundcolors, argb, *count * sizeof(ARGB));
|
||||||
|
|
||||||
|
GdipFree(grad->surroundcolors);
|
||||||
|
|
||||||
|
grad->surroundcolors = new_surroundcolors;
|
||||||
|
grad->surroundcolorcount = *count;
|
||||||
|
|
||||||
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
|
GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
|
||||||
|
|
|
@ -196,6 +196,8 @@ struct GpPathGradient{
|
||||||
REAL* blendfac; /* blend factors */
|
REAL* blendfac; /* blend factors */
|
||||||
REAL* blendpos; /* blend positions */
|
REAL* blendpos; /* blend positions */
|
||||||
INT blendcount;
|
INT blendcount;
|
||||||
|
ARGB *surroundcolors;
|
||||||
|
INT surroundcolorcount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpLineGradient{
|
struct GpLineGradient{
|
||||||
|
|
|
@ -781,25 +781,25 @@ static void test_gradientsurroundcolorcount(void)
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
status = GdipGetPathGradientSurroundColorCount(grad, &count);
|
status = GdipGetPathGradientSurroundColorCount(grad, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine expect(2, count);
|
expect(2, count);
|
||||||
|
|
||||||
color[0] = color[1] = color[2] = 0xdeadbeef;
|
color[0] = color[1] = color[2] = 0xdeadbeef;
|
||||||
count = 3;
|
count = 3;
|
||||||
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine expect(1, count);
|
expect(1, count);
|
||||||
todo_wine expect(0xffffffff, color[0]);
|
expect(0xffffffff, color[0]);
|
||||||
todo_wine expect(0xffffffff, color[1]);
|
expect(0xffffffff, color[1]);
|
||||||
expect(0xdeadbeef, color[2]);
|
expect(0xdeadbeef, color[2]);
|
||||||
|
|
||||||
color[0] = color[1] = color[2] = 0xdeadbeef;
|
color[0] = color[1] = color[2] = 0xdeadbeef;
|
||||||
count = 2;
|
count = 2;
|
||||||
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine expect(1, count);
|
expect(1, count);
|
||||||
todo_wine expect(0xffffffff, color[0]);
|
expect(0xffffffff, color[0]);
|
||||||
todo_wine expect(0xffffffff, color[1]);
|
expect(0xffffffff, color[1]);
|
||||||
expect(0xdeadbeef, color[2]);
|
expect(0xdeadbeef, color[2]);
|
||||||
|
|
||||||
color[0] = color[1] = color[2] = 0xdeadbeef;
|
color[0] = color[1] = color[2] = 0xdeadbeef;
|
||||||
|
@ -843,7 +843,7 @@ static void test_gradientsurroundcolorcount(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
expect(2, count);
|
expect(2, count);
|
||||||
|
|
||||||
status = GdipGetPathGradientSurroundColorCount(NULL, &count);
|
status = GdipGetPathGradientSurroundColorCount(NULL, &count);
|
||||||
|
@ -854,26 +854,31 @@ static void test_gradientsurroundcolorcount(void)
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
status = GdipGetPathGradientSurroundColorCount(grad, &count);
|
status = GdipGetPathGradientSurroundColorCount(grad, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine expect(2, count);
|
expect(2, count);
|
||||||
|
|
||||||
color[0] = color[1] = color[2] = 0xdeadbeef;
|
color[0] = color[1] = color[2] = 0xdeadbeef;
|
||||||
count = 2;
|
count = 2;
|
||||||
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
expect(2, count);
|
expect(2, count);
|
||||||
todo_wine expect(0x00ff0000, color[0]);
|
expect(0x00ff0000, color[0]);
|
||||||
todo_wine expect(0x0000ff00, color[1]);
|
expect(0x0000ff00, color[1]);
|
||||||
expect(0xdeadbeef, color[2]);
|
expect(0xdeadbeef, color[2]);
|
||||||
|
|
||||||
count = 1;
|
count = 1;
|
||||||
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
expect(1, count);
|
expect(1, count);
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
status = GdipGetPathGradientSurroundColorCount(grad, &count);
|
||||||
|
expect(Ok, status);
|
||||||
|
expect(2, count);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(InvalidParameter, status);
|
expect(InvalidParameter, status);
|
||||||
expect(0, count);
|
expect(0, count);
|
||||||
|
|
||||||
GdipDeleteBrush((GpBrush*)grad);
|
GdipDeleteBrush((GpBrush*)grad);
|
||||||
|
@ -884,11 +889,11 @@ static void test_gradientsurroundcolorcount(void)
|
||||||
color[0] = color[1] = color[2] = 0xdeadbeef;
|
color[0] = color[1] = color[2] = 0xdeadbeef;
|
||||||
count = 3;
|
count = 3;
|
||||||
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
status = GdipGetPathGradientSurroundColorsWithCount(grad, color, &count);
|
||||||
todo_wine expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine expect(1, count);
|
expect(1, count);
|
||||||
todo_wine expect(0xffffffff, color[0]);
|
expect(0xffffffff, color[0]);
|
||||||
todo_wine expect(0xffffffff, color[1]);
|
expect(0xffffffff, color[1]);
|
||||||
todo_wine expect(0xffffffff, color[2]);
|
expect(0xffffffff, color[2]);
|
||||||
|
|
||||||
color[0] = color[1] = color[2] = 0xdeadbeef;
|
color[0] = color[1] = color[2] = 0xdeadbeef;
|
||||||
count = 2;
|
count = 2;
|
||||||
|
@ -899,6 +904,11 @@ static void test_gradientsurroundcolorcount(void)
|
||||||
expect(0xdeadbeef, color[1]);
|
expect(0xdeadbeef, color[1]);
|
||||||
expect(0xdeadbeef, color[2]);
|
expect(0xdeadbeef, color[2]);
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
status = GdipGetPathGradientSurroundColorCount(grad, &count);
|
||||||
|
expect(Ok, status);
|
||||||
|
expect(3, count);
|
||||||
|
|
||||||
GdipDeleteBrush((GpBrush*)grad);
|
GdipDeleteBrush((GpBrush*)grad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue