Commit 6acffba5 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Factor the matrix creation code out of GdipTransformPoints.

parent b689e63a
...@@ -147,6 +147,9 @@ static void restore_dc(GpGraphics *graphics, INT state) ...@@ -147,6 +147,9 @@ static void restore_dc(GpGraphics *graphics, INT state)
RestoreDC(graphics->hdc, state); RestoreDC(graphics->hdc, state);
} }
static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space,
GpCoordinateSpace src_space, GpMatrix **matrix);
/* This helper applies all the changes that the points listed in ptf need in /* This helper applies all the changes that the points listed in ptf need in
* order to be drawn on the device context. In the end, this should include at * order to be drawn on the device context. In the end, this should include at
* least: * least:
...@@ -4909,25 +4912,13 @@ GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region) ...@@ -4909,25 +4912,13 @@ GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace dst_space, static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space,
GpCoordinateSpace src_space, GpPointF *points, INT count) GpCoordinateSpace src_space, GpMatrix **matrix)
{ {
GpMatrix *matrix; GpStatus stat = GdipCreateMatrix(matrix);
GpStatus stat;
REAL unitscale; REAL unitscale;
if(!graphics || !points || count <= 0) if (dst_space != src_space && stat == Ok)
return InvalidParameter;
if(graphics->busy)
return ObjectBusy;
TRACE("(%p, %d, %d, %p, %d)\n", graphics, dst_space, src_space, points, count);
if (src_space == dst_space) return Ok;
stat = GdipCreateMatrix(&matrix);
if (stat == Ok)
{ {
unitscale = convert_unit(graphics_res(graphics), graphics->unit); unitscale = convert_unit(graphics_res(graphics), graphics->unit);
...@@ -4938,12 +4929,12 @@ GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace ...@@ -4938,12 +4929,12 @@ GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace
switch (src_space) switch (src_space)
{ {
case CoordinateSpaceWorld: case CoordinateSpaceWorld:
GdipMultiplyMatrix(matrix, graphics->worldtrans, MatrixOrderAppend); GdipMultiplyMatrix(*matrix, graphics->worldtrans, MatrixOrderAppend);
break; break;
case CoordinateSpacePage: case CoordinateSpacePage:
break; break;
case CoordinateSpaceDevice: case CoordinateSpaceDevice:
GdipScaleMatrix(matrix, 1.0/unitscale, 1.0/unitscale, MatrixOrderAppend); GdipScaleMatrix(*matrix, 1.0/unitscale, 1.0/unitscale, MatrixOrderAppend);
break; break;
} }
...@@ -4958,7 +4949,7 @@ GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace ...@@ -4958,7 +4949,7 @@ GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace
{ {
stat = GdipInvertMatrix(inverted_transform); stat = GdipInvertMatrix(inverted_transform);
if (stat == Ok) if (stat == Ok)
GdipMultiplyMatrix(matrix, inverted_transform, MatrixOrderAppend); GdipMultiplyMatrix(*matrix, inverted_transform, MatrixOrderAppend);
GdipDeleteMatrix(inverted_transform); GdipDeleteMatrix(inverted_transform);
} }
break; break;
...@@ -4966,12 +4957,34 @@ GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace ...@@ -4966,12 +4957,34 @@ GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace
case CoordinateSpacePage: case CoordinateSpacePage:
break; break;
case CoordinateSpaceDevice: case CoordinateSpaceDevice:
GdipScaleMatrix(matrix, unitscale, unitscale, MatrixOrderAppend); GdipScaleMatrix(*matrix, unitscale, unitscale, MatrixOrderAppend);
break; break;
} }
}
return stat;
}
if (stat == Ok) GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace dst_space,
stat = GdipTransformMatrixPoints(matrix, points, count); GpCoordinateSpace src_space, GpPointF *points, INT count)
{
GpMatrix *matrix;
GpStatus stat;
if(!graphics || !points || count <= 0)
return InvalidParameter;
if(graphics->busy)
return ObjectBusy;
TRACE("(%p, %d, %d, %p, %d)\n", graphics, dst_space, src_space, points, count);
if (src_space == dst_space) return Ok;
stat = get_graphics_transform(graphics, dst_space, src_space, &matrix);
if (stat == Ok)
{
stat = GdipTransformMatrixPoints(matrix, points, count);
GdipDeleteMatrix(matrix); GdipDeleteMatrix(matrix);
} }
......
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