[2/3] add GDI+ pen, memory, startup implementation

Evan Stade estade at gmail.com
Fri Jun 1 19:47:38 CDT 2007


Hi,

Changelog:
*Added some minimum implementation for GDI+ pens, startup, memory

 dlls/gdiplus/Makefile.in       |    3 +
 dlls/gdiplus/gdiplus.c         |   40 ++++++++++++++++++-
 dlls/gdiplus/gdiplus.spec      |   12 +++---
 dlls/gdiplus/gdiplus_private.h |   41 +++++++++++++++++++
 dlls/gdiplus/pen.c             |   85 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 173 insertions(+), 8 deletions(-)

-Evan Stade
-------------- 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/gdiplus.c b/dlls/gdiplus/gdiplus.c
index 367fab5..7a5995c 100644
--- a/dlls/gdiplus/gdiplus.c
+++ b/dlls/gdiplus/gdiplus.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Evan Stade
+ * Copyright (C) 2007 Google (Evan Stade)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,9 @@ #include "windef.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "wine/debug.h"
+#include "wingdi.h"
+#include "gdiplus.h"
+#include "gdiplus_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
 
@@ -43,3 +46,38 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWO
     }
     return TRUE;
 }
+
+Status WINAPI GdiplusStartup(ULONG_PTR *token, const GdiplusStartupInput *input, 
+    GdiplusStartupOutput *output)
+{
+    if(!token)
+        return InvalidParameter;
+
+    if(input->GdiplusVersion != 1) {
+        return UnsupportedGdiplusVersion;
+    } else if ((input->DebugEventCallback) || 
+        (input->SuppressBackgroundThread) || (input->SuppressExternalCodecs)){
+        FIXME("Unimplemented for non-default GdiplusStartupInput");
+        return NotImplemented;
+    } else if(output) {
+        FIXME("Unimplemented for non-null GdiplusStartupOutput");
+        return NotImplemented;
+    }
+
+    return Ok;
+}
+
+void WINAPI GdiplusShutdown(ULONG_PTR token)
+{
+    /* FIXME: no object tracking */
+}
+
+void* WINGDIPAPI GdipAlloc(size_t size)
+{
+    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+}
+
+void WINGDIPAPI GdipFree(void* ptr)
+{
+    HeapFree(GetProcessHeap(), 0, ptr);
+}
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 863be69..2bb3ba9 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -31,7 +31,7 @@
 @ stub GdipAddPathRectanglesI
 @ stub GdipAddPathString
 @ stub GdipAddPathStringI
-@ stub GdipAlloc
+@ stdcall GdipAlloc(long)
 @ stub GdipBeginContainer2
 @ stub GdipBeginContainer
 @ stub GdipBeginContainerI
@@ -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
@@ -222,7 +222,7 @@
 @ stub GdipFillRegion
 @ stub GdipFlattenPath
 @ stub GdipFlush
-@ stub GdipFree
+@ stdcall GdipFree(ptr)
 @ stub GdipGetAdjustableArrowCapFillState
 @ stub GdipGetAdjustableArrowCapHeight
 @ stub GdipGetAdjustableArrowCapMiddleInset
@@ -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..9140a7d
--- /dev/null
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2007 Google (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 __WINE_GP_PRIVATE_H_
+#define __WINE_GP_PRIVATE_H_
+
+#include "windef.h"
+#include "winbase.h"
+#include "gdiplus.h"
+
+/* FIXME: this is just a guess, must check later */
+#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC)
+
+struct GpPen{
+    UINT style;
+    ARGB color;
+    GpUnit unit;
+    REAL width;
+    HPEN gdipen;
+};
+
+struct GpGraphics{
+    HDC hdc;
+};
+
+#endif
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
new file mode 100644
index 0000000..e1041f1
--- /dev/null
+++ b/dlls/gdiplus/pen.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2007 Google (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 <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "gdiplus.h"
+#include "gdiplus_private.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
+
+static 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*) GdipAlloc(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);
+    GdipFree(pen);
+    return Ok;
+}
-- 
1.4.1


More information about the wine-patches mailing list