gdiplus: Fix mismatched use of Begin/EndContainer and Save/RestoreGraphics.

Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vincent Povirk 2016-08-12 15:47:16 -05:00 committed by Alexandre Julliard
parent 8fbdd670ca
commit cc8cc65f79
2 changed files with 41 additions and 22 deletions

View File

@ -1924,9 +1924,15 @@ GpStatus trace_path(GpGraphics *graphics, GpPath *path)
return result; return result;
} }
typedef enum GraphicsContainerType {
BEGIN_CONTAINER,
SAVE_GRAPHICS
} GraphicsContainerType;
typedef struct _GraphicsContainerItem { typedef struct _GraphicsContainerItem {
struct list entry; struct list entry;
GraphicsContainer contid; GraphicsContainer contid;
GraphicsContainerType type;
SmoothingMode smoothing; SmoothingMode smoothing;
CompositingQuality compqual; CompositingQuality compqual;
@ -1943,7 +1949,7 @@ typedef struct _GraphicsContainerItem {
} GraphicsContainerItem; } GraphicsContainerItem;
static GpStatus init_container(GraphicsContainerItem** container, static GpStatus init_container(GraphicsContainerItem** container,
GDIPCONST GpGraphics* graphics){ GDIPCONST GpGraphics* graphics, GraphicsContainerType type){
GpStatus sts; GpStatus sts;
*container = heap_alloc_zero(sizeof(GraphicsContainerItem)); *container = heap_alloc_zero(sizeof(GraphicsContainerItem));
@ -1951,6 +1957,7 @@ static GpStatus init_container(GraphicsContainerItem** container,
return OutOfMemory; return OutOfMemory;
(*container)->contid = graphics->contid + 1; (*container)->contid = graphics->contid + 1;
(*container)->type = type;
(*container)->smoothing = graphics->smoothing; (*container)->smoothing = graphics->smoothing;
(*container)->compqual = graphics->compqual; (*container)->compqual = graphics->compqual;
@ -5148,11 +5155,6 @@ GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
return GdipSetMatrixElements(&graphics->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); return GdipSetMatrixElements(&graphics->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
} }
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
{
return GdipEndContainer(graphics, state);
}
GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle, GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle,
GpMatrixOrder order) GpMatrixOrder order)
{ {
@ -5176,23 +5178,16 @@ GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle,
return GdipRotateMatrix(&graphics->worldtrans, angle, order); return GdipRotateMatrix(&graphics->worldtrans, angle, order);
} }
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state) static GpStatus begin_container(GpGraphics *graphics,
{ GraphicsContainerType type, GraphicsContainer *state)
return GdipBeginContainer2(graphics, state);
}
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics,
GraphicsContainer *state)
{ {
GraphicsContainerItem *container; GraphicsContainerItem *container;
GpStatus sts; GpStatus sts;
TRACE("(%p, %p)\n", graphics, state);
if(!graphics || !state) if(!graphics || !state)
return InvalidParameter; return InvalidParameter;
sts = init_container(&container, graphics); sts = init_container(&container, graphics, type);
if(sts != Ok) if(sts != Ok)
return sts; return sts;
@ -5202,6 +5197,19 @@ GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics,
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
{
TRACE("(%p, %p)\n", graphics, state);
return begin_container(graphics, SAVE_GRAPHICS, state);
}
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics,
GraphicsContainer *state)
{
TRACE("(%p, %p)\n", graphics, state);
return begin_container(graphics, BEGIN_CONTAINER, state);
}
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state) GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state)
{ {
FIXME("(%p, %p, %p, %d, %p): stub\n", graphics, dstrect, srcrect, unit, state); FIXME("(%p, %p, %p, %d, %p): stub\n", graphics, dstrect, srcrect, unit, state);
@ -5220,18 +5228,17 @@ GpStatus WINGDIPAPI GdipComment(GpGraphics *graphics, UINT sizeData, GDIPCONST B
return NotImplemented; return NotImplemented;
} }
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state) static GpStatus end_container(GpGraphics *graphics, GraphicsContainerType type,
GraphicsContainer state)
{ {
GpStatus sts; GpStatus sts;
GraphicsContainerItem *container, *container2; GraphicsContainerItem *container, *container2;
TRACE("(%p, %x)\n", graphics, state);
if(!graphics) if(!graphics)
return InvalidParameter; return InvalidParameter;
LIST_FOR_EACH_ENTRY(container, &graphics->containers, GraphicsContainerItem, entry){ LIST_FOR_EACH_ENTRY(container, &graphics->containers, GraphicsContainerItem, entry){
if(container->contid == state) if(container->contid == state && container->type == type)
break; break;
} }
@ -5257,6 +5264,18 @@ GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer sta
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state)
{
TRACE("(%p, %x)\n", graphics, state);
return end_container(graphics, BEGIN_CONTAINER, state);
}
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
{
TRACE("(%p, %x)\n", graphics, state);
return end_container(graphics, SAVE_GRAPHICS, state);
}
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx,
REAL sy, GpMatrixOrder order) REAL sy, GpMatrixOrder order)
{ {

View File

@ -335,7 +335,7 @@ static void test_save_restore(void)
stat = GdipEndContainer(graphics1, state_a); stat = GdipEndContainer(graphics1, state_a);
expect(Ok, stat); expect(Ok, stat);
GdipGetInterpolationMode(graphics1, &mode); GdipGetInterpolationMode(graphics1, &mode);
todo_wine expect(InterpolationModeBicubic, mode); expect(InterpolationModeBicubic, mode);
stat = GdipRestoreGraphics(graphics1, state_a); stat = GdipRestoreGraphics(graphics1, state_a);
expect(Ok, stat); expect(Ok, stat);
GdipGetInterpolationMode(graphics1, &mode); GdipGetInterpolationMode(graphics1, &mode);
@ -353,7 +353,7 @@ static void test_save_restore(void)
stat = GdipRestoreGraphics(graphics1, state_a); stat = GdipRestoreGraphics(graphics1, state_a);
expect(Ok, stat); expect(Ok, stat);
GdipGetInterpolationMode(graphics1, &mode); GdipGetInterpolationMode(graphics1, &mode);
todo_wine expect(InterpolationModeBicubic, mode); expect(InterpolationModeBicubic, mode);
stat = GdipEndContainer(graphics1, state_a); stat = GdipEndContainer(graphics1, state_a);
expect(Ok, stat); expect(Ok, stat);
GdipGetInterpolationMode(graphics1, &mode); GdipGetInterpolationMode(graphics1, &mode);