Commit 632aef3d authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

gdiplus: Implement GdipBeginContainer2 and GdipEndContainer.

parent 3484d46a
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "objbase.h" #include "objbase.h"
#include "ocidl.h" #include "ocidl.h"
#include "wine/list.h"
#include "gdiplus.h" #include "gdiplus.h"
...@@ -109,6 +110,8 @@ struct GpGraphics{ ...@@ -109,6 +110,8 @@ struct GpGraphics{
BOOL busy; /* hdc handle obtained by GdipGetDC */ BOOL busy; /* hdc handle obtained by GdipGetDC */
GpRegion *clip; GpRegion *clip;
UINT textcontrast; /* not used yet. get/set only */ UINT textcontrast; /* not used yet. get/set only */
struct list containers;
GraphicsContainer contid; /* last-issued container ID */
}; };
struct GpBrush{ struct GpBrush{
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "gdiplus.h" #include "gdiplus.h"
#include "gdiplus_private.h" #include "gdiplus_private.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
...@@ -941,6 +942,104 @@ GpStatus trace_path(GpGraphics *graphics, GpPath *path) ...@@ -941,6 +942,104 @@ GpStatus trace_path(GpGraphics *graphics, GpPath *path)
return result; return result;
} }
typedef struct _GraphicsContainerItem {
struct list entry;
GraphicsContainer contid;
SmoothingMode smoothing;
CompositingQuality compqual;
InterpolationMode interpolation;
CompositingMode compmode;
TextRenderingHint texthint;
REAL scale;
GpUnit unit;
PixelOffsetMode pixeloffset;
UINT textcontrast;
GpMatrix* worldtrans;
GpRegion* clip;
} GraphicsContainerItem;
static GpStatus init_container(GraphicsContainerItem** container,
GDIPCONST GpGraphics* graphics){
GpStatus sts;
*container = GdipAlloc(sizeof(GraphicsContainerItem));
if(!(*container))
return OutOfMemory;
(*container)->contid = graphics->contid + 1;
(*container)->smoothing = graphics->smoothing;
(*container)->compqual = graphics->compqual;
(*container)->interpolation = graphics->interpolation;
(*container)->compmode = graphics->compmode;
(*container)->texthint = graphics->texthint;
(*container)->scale = graphics->scale;
(*container)->unit = graphics->unit;
(*container)->textcontrast = graphics->textcontrast;
(*container)->pixeloffset = graphics->pixeloffset;
sts = GdipCloneMatrix(graphics->worldtrans, &(*container)->worldtrans);
if(sts != Ok){
GdipFree(*container);
*container = NULL;
return sts;
}
sts = GdipCloneRegion(graphics->clip, &(*container)->clip);
if(sts != Ok){
GdipDeleteMatrix((*container)->worldtrans);
GdipFree(*container);
*container = NULL;
return sts;
}
return Ok;
}
static void delete_container(GraphicsContainerItem* container){
GdipDeleteMatrix(container->worldtrans);
GdipDeleteRegion(container->clip);
GdipFree(container);
}
static GpStatus restore_container(GpGraphics* graphics,
GDIPCONST GraphicsContainerItem* container){
GpStatus sts;
GpMatrix *newTrans;
GpRegion *newClip;
sts = GdipCloneMatrix(container->worldtrans, &newTrans);
if(sts != Ok)
return sts;
sts = GdipCloneRegion(container->clip, &newClip);
if(sts != Ok){
GdipDeleteMatrix(newTrans);
return sts;
}
GdipDeleteMatrix(graphics->worldtrans);
graphics->worldtrans = newTrans;
GdipDeleteRegion(graphics->clip);
graphics->clip = newClip;
graphics->contid = container->contid - 1;
graphics->smoothing = container->smoothing;
graphics->compqual = container->compqual;
graphics->interpolation = container->interpolation;
graphics->compmode = container->compmode;
graphics->texthint = container->texthint;
graphics->scale = container->scale;
graphics->unit = container->unit;
graphics->textcontrast = container->textcontrast;
graphics->pixeloffset = container->pixeloffset;
return Ok;
}
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics) GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
{ {
TRACE("(%p, %p)\n", hdc, graphics); TRACE("(%p, %p)\n", hdc, graphics);
...@@ -991,6 +1090,8 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra ...@@ -991,6 +1090,8 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
(*graphics)->scale = 1.0; (*graphics)->scale = 1.0;
(*graphics)->busy = FALSE; (*graphics)->busy = FALSE;
(*graphics)->textcontrast = 4; (*graphics)->textcontrast = 4;
list_init(&(*graphics)->containers);
(*graphics)->contid = 0;
return Ok; return Ok;
} }
...@@ -1155,6 +1256,7 @@ GpStatus WINGDIPAPI GdipCreateStreamOnFile(GDIPCONST WCHAR * filename, ...@@ -1155,6 +1256,7 @@ GpStatus WINGDIPAPI GdipCreateStreamOnFile(GDIPCONST WCHAR * filename,
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics) GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
{ {
GraphicsContainerItem *cont, *next;
TRACE("(%p)\n", graphics); TRACE("(%p)\n", graphics);
if(!graphics) return InvalidParameter; if(!graphics) return InvalidParameter;
...@@ -1163,6 +1265,11 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics) ...@@ -1163,6 +1265,11 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
if(graphics->owndc) if(graphics->owndc)
ReleaseDC(graphics->hwnd, graphics->hdc); ReleaseDC(graphics->hwnd, graphics->hdc);
LIST_FOR_EACH_ENTRY_SAFE(cont, next, &graphics->containers, GraphicsContainerItem, entry){
list_remove(&cont->entry);
delete_container(cont);
}
GdipDeleteRegion(graphics->clip); GdipDeleteRegion(graphics->clip);
GdipDeleteMatrix(graphics->worldtrans); GdipDeleteMatrix(graphics->worldtrans);
GdipFree(graphics); GdipFree(graphics);
...@@ -3254,14 +3361,24 @@ GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state) ...@@ -3254,14 +3361,24 @@ GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state) GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics,
GraphicsContainer *state)
{ {
FIXME("(%p, %p)\n", graphics, state); GraphicsContainerItem *container;
GpStatus sts;
TRACE("(%p, %p)\n", graphics, state);
if(!graphics || !state) if(!graphics || !state)
return InvalidParameter; return InvalidParameter;
*state = 0xdeadbeef; sts = init_container(&container, graphics);
if(sts != Ok)
return sts;
list_add_head(&graphics->containers, &container->entry);
*state = graphics->contid = container->contid;
return Ok; return Ok;
} }
...@@ -3285,12 +3402,36 @@ GpStatus WINGDIPAPI GdipComment(GpGraphics *graphics, UINT sizeData, GDIPCONST B ...@@ -3285,12 +3402,36 @@ GpStatus WINGDIPAPI GdipComment(GpGraphics *graphics, UINT sizeData, GDIPCONST B
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsState state) GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsState state)
{ {
FIXME("(%p, 0x%x)\n", graphics, state); GpStatus sts;
GraphicsContainerItem *container, *container2;
if(!graphics || !state) TRACE("(%p, %x)\n", graphics, state);
if(!graphics)
return InvalidParameter; return InvalidParameter;
return Ok; LIST_FOR_EACH_ENTRY(container, &graphics->containers, GraphicsContainerItem, entry){
if(container->contid == state)
break;
}
/* did not find a matching container */
if(&container->entry == &graphics->containers)
return Ok;
/* remove all of the containers on top of the found container */
LIST_FOR_EACH_ENTRY_SAFE(container, container2, &graphics->containers, GraphicsContainerItem, entry){
if(container->contid == state)
break;
list_remove(&container->entry);
delete_container(container);
}
list_remove(&container->entry);
sts = restore_container(graphics, container);
delete_container(container);
return sts;
} }
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx,
......
...@@ -127,6 +127,7 @@ GpStatus WINGDIPAPI GdipFlush(GpGraphics*, GpFlushIntention); ...@@ -127,6 +127,7 @@ GpStatus WINGDIPAPI GdipFlush(GpGraphics*, GpFlushIntention);
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics*,GDIPCONST GpRectF*,GDIPCONST GpRectF*,GpUnit,GraphicsContainer*); GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics*,GDIPCONST GpRectF*,GDIPCONST GpRectF*,GpUnit,GraphicsContainer*);
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics*,GraphicsContainer*); GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics*,GraphicsContainer*);
GpStatus WINGDIPAPI GdipBeginContainerI(GpGraphics*,GDIPCONST GpRect*,GDIPCONST GpRect*,GpUnit,GraphicsContainer*); GpStatus WINGDIPAPI GdipBeginContainerI(GpGraphics*,GDIPCONST GpRect*,GDIPCONST GpRect*,GpUnit,GraphicsContainer*);
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics*,GraphicsContainer);
GpStatus WINGDIPAPI GdipComment(GpGraphics*,UINT,GDIPCONST BYTE*); GpStatus WINGDIPAPI GdipComment(GpGraphics*,UINT,GDIPCONST BYTE*);
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC,GpGraphics**); GpStatus WINGDIPAPI GdipCreateFromHDC(HDC,GpGraphics**);
GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC,HANDLE,GpGraphics**); GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC,HANDLE,GpGraphics**);
......
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