GDI+: headers and one test

Evan Stade estade at gmail.com
Tue May 29 20:24:21 CDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in
index f1d5040..a4edb46 100644
--- a/dlls/gdiplus/Makefile.in
+++ b/dlls/gdiplus/Makefile.in
@@ -7,7 +7,8 @@ IMPORTLIB = libgdiplus.$(IMPLIBEXT)
 IMPORTS   = gdi32 advapi32 kernel32 ntdll
 
 C_SRCS = \
-	gdiplus.c
+	gdiplus.c \
+	pen.c
 
 @MAKE_DLL_RULES@
 
diff --git a/dlls/gdiplus/gdip_defines.h b/dlls/gdiplus/gdip_defines.h
new file mode 100644
index 0000000..fc12f52
--- /dev/null
+++ b/dlls/gdiplus/gdip_defines.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007 Evan Stade
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _GP_GPDEFINES_H_
+#define _GP_GPDEFINES_H_
+
+#include "enumerations.h"
+
+#define WINGDIPAPI WINAPI
+
+typedef Unit GpUnit;
+typedef Status GpStatus;
+typedef DWORD ARGB;
+typedef FLOAT REAL;
+
+typedef struct {
+    UINT style;
+    ARGB color;
+    GpUnit unit;
+    REAL width;
+    HPEN gdipen;
+} GpPen;
+
+typedef struct {
+    HDC hdc;
+} GpGraphics;
+
+#endif
diff --git a/dlls/gdiplus/gdip_enumerations.h b/dlls/gdiplus/gdip_enumerations.h
new file mode 100644
index 0000000..a7b860c
--- /dev/null
+++ b/dlls/gdiplus/gdip_enumerations.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007 Evan Stade
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _GP_ENUMERATIONS_H_
+#define _GP_ENUMERATIONS_H_
+
+typedef enum {
+    UnitWorld = 0,
+    UnitDisplay = 1,
+    UnitPixel = 2,
+    UnitPoint = 3,
+    UnitInch = 4,
+    UnitDocument = 5,
+    UnitMillimeter = 6
+} Unit;
+
+typedef enum {
+    Ok = 0,
+    GenericError = 1,
+    InvalidParameter = 2,
+    OutOfMemory = 3,
+    ObjectBusy = 4,
+    InsufficientBuffer = 5,
+    NotImplemented = 6,
+    Win32Error = 7,
+    WrongState = 8,
+    Aborted = 9,
+    FileNotFound = 10,
+    ValueOverflow = 11,
+    AccessDenied = 12,
+    UnknownImageFormat = 13,
+    FontFamilyNotFound = 14,
+    FontStyleNotFound = 15,
+    NotTrueTypeFont = 16,
+    UnsupportedGdiplusVersion = 17,
+    GdiplusNotInitialized = 18,
+    PropertyNotFound = 19,
+    PropertyNotSupported = 20,
+    ProfileNotFound = 21
+} Status;
+
+#endif
diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c
index 367fab5..ad2f1af 100644
--- a/dlls/gdiplus/gdiplus.c
+++ b/dlls/gdiplus/gdiplus.c
@@ -23,6 +23,10 @@ #include "winbase.h"
 #include "winerror.h"
 #include "wine/debug.h"
 
+#include "wingdi.h"
+#include "gdip_defines.h"
+#include "gdiplus_private.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
 
 /*****************************************************
@@ -43,3 +47,26 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWO
     }
     return TRUE;
 }
+
+Status GdiplusStartup(ULONG_PTR *token, const GdiplusStartupInput *input, 
+    GdiplusStartupOutput *output)
+{
+    if(!token)
+        return InvalidParameter;
+
+    if((input->GdiplusVersion != 1) || (input->DebugEventCallback) || 
+        (input->SuppressBackgroundThread) || (input->SuppressExternalCodecs)){
+        FIXME("Unimplemented for non-default GdiplusStartupInput");
+        return InvalidParameter;
+    } else if(output) {
+        FIXME("Unimplemented for non-null GdiplusStartupOutput");
+        return InvalidParameter;
+    }
+
+    return Ok;
+}
+
+void GdiplusShutdown(ULONG_PTR token)
+{
+    /* FIXME: no object tracking */
+}
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 863be69..b35da89 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -111,7 +111,7 @@
 @ stub GdipCreatePathGradientFromPath
 @ stub GdipCreatePathGradientI
 @ stub GdipCreatePathIter
-@ stub GdipCreatePen1
+@ stdcall GdipCreatePen1(long long long ptr)
 @ stub GdipCreatePen2
 @ stub GdipCreateRegion
 @ stub GdipCreateRegionHrgn
@@ -136,7 +136,7 @@
 @ stub GdipDeleteMatrix
 @ stub GdipDeletePath
 @ stub GdipDeletePathIter
-@ stub GdipDeletePen
+@ stdcall GdipDeletePen(ptr)
 @ stub GdipDeletePrivateFontCollection
 @ stub GdipDeleteRegion
 @ stub GdipDeleteStringFormat
@@ -605,5 +605,5 @@
 @ stub GdipWindingModeOutline
 @ stub GdiplusNotificationHook
 @ stub GdiplusNotificationUnhook
-@ stub GdiplusShutdown
-@ stub GdiplusStartup
+@ stdcall GdiplusShutdown(ptr)
+@ stdcall GdiplusStartup(ptr ptr ptr)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
new file mode 100644
index 0000000..e2b5a54
--- /dev/null
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007 Evan Stade
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _GP_PRIVATE_H_
+#define _GP_PRIVATE_H_
+
+#include "gdip_enumerations.h"
+#include "gdip_defines.h"
+
+typedef struct _GdiplusStartupInput
+{
+    UINT32 GdiplusVersion;
+    void * DebugEventCallback;  
+    BOOL SuppressBackgroundThread;
+    BOOL SuppressExternalCodecs;
+} GdiplusStartupInput;
+
+typedef struct _GdiplusStartupOutput
+{
+    ULONG_PTR NotificationHook;
+    ULONG_PTR NotificationUnhook;
+} GdiplusStartupOutput;
+
+Status GdiplusStartup(ULONG_PTR *token, const GdiplusStartupInput *input, 
+    GdiplusStartupOutput *output);
+void GdiplusShutdown(ULONG_PTR token);
+
+#endif
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
new file mode 100644
index 0000000..56e4061
--- /dev/null
+++ b/dlls/gdiplus/pen.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2007 Evan Stade
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+
+#include "windef.h"
+#include "wingdi.h"
+#include "gdiplus_private.h"
+#include "pen.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(gdip);
+
+COLORREF ARGB2COLORREF(ARGB color)
+{
+    /*
+    Packing of these color structures:
+    COLORREF:   00bbggrr
+    ARGB:       aarrggbb
+    FIXME:doesn't handle alpha channel
+    */
+    return (COLORREF)
+        ((color & 0x0000ff) << 16) + 
+        (color & 0x00ff00) + 
+        ((color & 0xff0000) >> 16);
+}
+
+GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, FLOAT width, GpUnit unit, 
+    GpPen **pen)
+{
+    LOGBRUSH lb;
+    GpPen *gp_pen;
+
+    gp_pen = (GpPen*) malloc(sizeof(GpPen));
+    if(!pen){ return OutOfMemory; }
+
+    gp_pen->style = GP_DEFAULT_PENSTYLE;
+    gp_pen->color = ARGB2COLORREF(color);
+    gp_pen->width = width;
+    gp_pen->unit = unit;
+
+    /* FIXME: Currently only solid lines supported. */
+    lb.lbStyle = BS_SOLID;
+    lb.lbColor = gp_pen->color;
+    lb.lbHatch = 0;
+
+    if((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel)) {
+        gp_pen->gdipen = ExtCreatePen(gp_pen->style, (INT) gp_pen->width, &lb, 
+            0, NULL);
+    } else {
+        FIXME("UnitWorld, UnitPixel only supported units");
+        return InvalidParameter;
+    }
+
+    if(!gp_pen)
+        return GenericError;
+
+    *pen = gp_pen;
+
+    return Ok;
+}
+
+GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
+{
+    if(!pen){ return InvalidParameter; }
+    DeleteObject( pen->gdipen );
+    free(pen);
+    return Ok;
+}
+
diff --git a/dlls/gdiplus/pen.h b/dlls/gdiplus/pen.h
new file mode 100644
index 0000000..a30ee88
--- /dev/null
+++ b/dlls/gdiplus/pen.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Evan Stade
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _GP_PEN_H_
+#define _GP_PEN_H_
+
+/* FIXME: this is just a guess, must check later */
+#define GP_DEFAULT_PENSTYLE (PS_SOLID | PS_GEOMETRIC | PS_ENDCAP_SQUARE | \
+        PS_JOIN_BEVEL)
+
+GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, 
+    GpPen **pen);
+GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen);
+
+#endif
diff --git a/dlls/gdiplus/tests/Makefile.in b/dlls/gdiplus/tests/Makefile.in
new file mode 100644
index 0000000..14bc936
--- /dev/null
+++ b/dlls/gdiplus/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = gdiplus.dll
+IMPORTS   = user32 gdi32 kernel32 gdiplus
+
+CTESTS = \
+	pen.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c
new file mode 100644
index 0000000..8a40008
--- /dev/null
+++ b/dlls/gdiplus/tests/pen.c
@@ -0,0 +1,44 @@
+#include <stdarg.h>
+#include <assert.h>
+
+#include "windows.h"
+#include "wingdi.h"
+#include "windef.h"
+#include "winbase.h"
+#include "Gdiplus.h"
+#include "wine/test.h"
+
+#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
+
+static void test_constructor_destructor(void)
+{
+    GpStatus status;
+    GpGraphics *pen;
+
+    status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
+    expect(Ok, status);
+    ok(pen, "Expected pen to be initialized");
+
+    status = GdipDeletePen(NULL);
+    expect(InvalidParameter, status);
+
+    status = GdipDeletePen(pen);
+    expect(Ok, status);
+}
+
+START_TEST(pen)
+{
+    GdiplusStartupInput gdiplusStartupInput;
+    ULONG_PTR gdiplusToken;
+
+    gdiplusStartupInput.GdiplusVersion=1;
+    gdiplusStartupInput.DebugEventCallback=NULL;
+    gdiplusStartupInput.SuppressBackgroundThread=0;
+    gdiplusStartupInput.SuppressExternalCodecs=0;
+
+    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+    test_constructor_destructor();
+
+    GdiplusShutdown(gdiplusToken);
+}
diff --git a/include/Gdiplus.h b/include/Gdiplus.h
new file mode 100644
index 0000000..23ba257
--- /dev/null
+++ b/include/Gdiplus.h
@@ -0,0 +1,10 @@
+#ifndef _GDIPLUS_H_
+#define _GDIPLUS_H_
+
+#include "GdiplusTypes.h"
+#include "GdiplusEnums.h"
+#include "GdiplusGpStubs.h"
+#include "GdiplusInit.h"
+#include "GdiplusFlat.h"
+
+#endif
diff --git a/include/GdiplusEnums.h b/include/GdiplusEnums.h
new file mode 100644
index 0000000..0f006b3
--- /dev/null
+++ b/include/GdiplusEnums.h
@@ -0,0 +1,39 @@
+#ifndef _GP_ENUMERATIONS_H_
+#define _GP_ENUMERATIONS_H_
+
+typedef enum {
+    UnitWorld = 0,  /* seemingly equivalent to notion of "logical unit" */
+    UnitDisplay = 1,
+    UnitPixel = 2,
+    UnitPoint = 3,
+    UnitInch = 4,
+    UnitDocument = 5,
+    UnitMillimeter = 6
+} Unit;
+
+typedef enum {
+    Ok = 0,
+    GenericError = 1,
+    InvalidParameter = 2,
+    OutOfMemory = 3,
+    ObjectBusy = 4,
+    InsufficientBuffer = 5,
+    NotImplemented = 6,
+    Win32Error = 7,
+    WrongState = 8,
+    Aborted = 9,
+    FileNotFound = 10,
+    ValueOverflow = 11,
+    AccessDenied = 12,
+    UnknownImageFormat = 13,
+    FontFamilyNotFound = 14,
+    FontStyleNotFound = 15,
+    NotTrueTypeFont = 16,
+    UnsupportedGdiplusVersion = 17,
+    GdiplusNotInitialized = 18,
+    PropertyNotFound = 19,
+    PropertyNotSupported = 20,
+    ProfileNotFound = 21
+} Status;
+
+#endif
diff --git a/include/GdiplusFlat.h b/include/GdiplusFlat.h
new file mode 100644
index 0000000..ce99369
--- /dev/null
+++ b/include/GdiplusFlat.h
@@ -0,0 +1,23 @@
+#ifndef _GP_FLATAPI_H_
+#define _GP_FLATAPI_H_
+
+#define WINGDIPAPI WINAPI
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics);
+GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics);
+
+GpStatus WINGDIPAPI
+GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen);
+GpStatus WINGDIPAPI
+GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1,
+                      INT x2, INT y2);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/GdiplusGpStubs.h b/include/GdiplusGpStubs.h
new file mode 100644
index 0000000..8b87a75
--- /dev/null
+++ b/include/GdiplusGpStubs.h
@@ -0,0 +1,10 @@
+#ifndef _GP_STUBS_H_
+#define _GP_STUBS_H_
+
+typedef Status GpStatus;
+typedef Unit GpUnit;
+
+typedef void GpGraphics;
+typedef void GpPen;
+
+#endif
diff --git a/include/GdiplusInit.h b/include/GdiplusInit.h
new file mode 100755
index 0000000..15a25bd
--- /dev/null
+++ b/include/GdiplusInit.h
@@ -0,0 +1,26 @@
+#ifndef _GP_INIT_H_
+#define _GP_INIT_H_
+
+typedef struct _GdiplusStartupInput
+{
+    UINT32 GdiplusVersion;
+    void * DebugEventCallback;	
+    BOOL SuppressBackgroundThread;
+    BOOL SuppressExternalCodecs;
+} GdiplusStartupInput;
+
+typedef struct _GdiplusStartupOutput
+{
+    ULONG_PTR NotificationHook;
+    ULONG_PTR NotificationUnhook;
+} GdiplusStartupOutput;
+
+
+Status WINAPI GdiplusStartup(
+    OUT ULONG_PTR *token,
+    const GdiplusStartupInput *input,
+    OUT GdiplusStartupOutput *output);
+
+VOID WINAPI GdiplusShutdown(ULONG_PTR token);
+
+#endif
diff --git a/include/GdiplusTypes.h b/include/GdiplusTypes.h
new file mode 100755
index 0000000..8ba74d8
--- /dev/null
+++ b/include/GdiplusTypes.h
@@ -0,0 +1,7 @@
+#ifndef _GP_TYPES_H_
+#define _GP_TYPES_H_
+
+typedef float REAL;
+typedef DWORD ARGB;
+
+#endif
-- 
1.4.1


More information about the wine-devel mailing list