gdiplus: Implement GdipSetPathGradientBlend, with tests.
This commit is contained in:
parent
4a78d7c6b4
commit
b66fd44080
|
@ -1432,14 +1432,35 @@ GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
|
|||
GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
|
||||
GDIPCONST REAL *pos, INT count)
|
||||
{
|
||||
static int calls;
|
||||
REAL *new_blendfac, *new_blendpos;
|
||||
|
||||
TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
|
||||
|
||||
if(!(calls++))
|
||||
FIXME("not implemented\n");
|
||||
if(!brush || !blend || !pos || count <= 0 ||
|
||||
(count >= 2 && (pos[0] != 0.0f || pos[count-1] != 1.0f)))
|
||||
return InvalidParameter;
|
||||
|
||||
return NotImplemented;
|
||||
new_blendfac = GdipAlloc(count * sizeof(REAL));
|
||||
new_blendpos = GdipAlloc(count * sizeof(REAL));
|
||||
|
||||
if (!new_blendfac || !new_blendpos)
|
||||
{
|
||||
GdipFree(new_blendfac);
|
||||
GdipFree(new_blendpos);
|
||||
return OutOfMemory;
|
||||
}
|
||||
|
||||
memcpy(new_blendfac, blend, count * sizeof(REAL));
|
||||
memcpy(new_blendpos, pos, count * sizeof(REAL));
|
||||
|
||||
GdipFree(brush->blendfac);
|
||||
GdipFree(brush->blendpos);
|
||||
|
||||
brush->blendcount = count;
|
||||
brush->blendfac = new_blendfac;
|
||||
brush->blendpos = new_blendpos;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipSetPathGradientLinearBlend(GpPathGradient *brush,
|
||||
|
|
|
@ -1133,6 +1133,110 @@ static void test_pathgradientpresetblend(void)
|
|||
expect(Ok, status);
|
||||
}
|
||||
|
||||
static void test_pathgradientblend(void)
|
||||
{
|
||||
static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}};
|
||||
GpPathGradient *brush;
|
||||
GpStatus status;
|
||||
INT count, i;
|
||||
const REAL factors[5] = {0.0f, 0.1f, 0.5f, 0.9f, 1.0f};
|
||||
const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f};
|
||||
REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
status = GdipCreatePathGradient(path_points, 3, WrapModeClamp, &brush);
|
||||
expect(Ok, 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);
|
||||
|
||||
status = GdipGetPathGradientBlend(NULL, res_factors, res_positions, 1);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, NULL, res_positions, 1);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, NULL, 1);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 0);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, -1);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 1);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 2);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(NULL, factors, positions, 5);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(brush, NULL, positions, 5);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(brush, factors, NULL, 5);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(brush, factors, positions, 0);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(brush, factors, positions, -1);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
/* leave off the 0.0 position */
|
||||
status = GdipSetPathGradientBlend(brush, &factors[1], &positions[1], 4);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
/* leave off the 1.0 position */
|
||||
status = GdipSetPathGradientBlend(brush, factors, positions, 4);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(brush, factors, positions, 5);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetPathGradientBlendCount(brush, &count);
|
||||
expect(Ok, status);
|
||||
expect(5, count);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 4);
|
||||
expect(InsufficientBuffer, status);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 5);
|
||||
expect(Ok, status);
|
||||
|
||||
for (i=0; i<5; i++)
|
||||
{
|
||||
expectf(factors[i], res_factors[i]);
|
||||
expectf(positions[i], res_positions[i]);
|
||||
}
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 6);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipSetPathGradientBlend(brush, factors, positions, 1);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetPathGradientBlendCount(brush, &count);
|
||||
expect(Ok, status);
|
||||
expect(1, count);
|
||||
|
||||
status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 1);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipDeleteBrush((GpBrush*)brush);
|
||||
expect(Ok, status);
|
||||
}
|
||||
|
||||
START_TEST(brush)
|
||||
{
|
||||
struct GdiplusStartupInput gdiplusStartupInput;
|
||||
|
@ -1160,6 +1264,7 @@ START_TEST(brush)
|
|||
test_pathgradientpath();
|
||||
test_pathgradientcenterpoint();
|
||||
test_pathgradientpresetblend();
|
||||
test_pathgradientblend();
|
||||
|
||||
GdiplusShutdown(gdiplusToken);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue