[cairo-commit] 4 commits - boilerplate/Makefile.win32 Makefile.win32 pixman/src src/cairoint.h src/cairo-win32-font.c src/cairo-win32-private.h src/cairo-win32-surface.c src/Makefile.win32 test/cairo-test.h test/Makefile.win32

Vladimir Vukicevic vladimir at kemper.freedesktop.org
Sat Sep 9 17:10:04 PDT 2006


 Makefile.win32             |   18 +++++++
 boilerplate/Makefile.win32 |   18 +++++++
 pixman/src/Makefile.win32  |   34 ++++++++++++++
 src/Makefile.win32         |  107 +++++++++++++++++++++++++++++++++++++++++++++
 src/cairo-win32-font.c     |   10 ++++
 src/cairo-win32-private.h  |    3 +
 src/cairo-win32-surface.c  |   29 ++++++++++--
 src/cairoint.h             |    5 ++
 test/Makefile.win32        |  102 ++++++++++++++++++++++++++++++++++++++++++
 test/cairo-test.h          |    6 ++
 10 files changed, 327 insertions(+), 5 deletions(-)

New commits:
diff-tree 97f26c523590dcb208a7c0e4d00fd66f4ca58605 (from parents)
Merge: 0e59041321e49e1eae330567e0c7d27e7d71699d 416e94532b1584b2ff23dd270c70ab900d55c326
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Sat Sep 9 17:09:03 2006 -0700

    Merge branch 'master' of git+ssh://git.cairographics.org/git/cairo into cairo-master

diff-tree 0e59041321e49e1eae330567e0c7d27e7d71699d (from 3c5a02c3edf300494cebfe746292b1eeeea08595)
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Sat Sep 9 17:08:18 2006 -0700

    [win32] win32-specific Makefiles for building with MSVC
    
    This patch adds a bunch of makefiles for building cairo with Visual C++.
    gnu make is still required, and make must be run from a command prompt
    that has the Visual C++ paths set up, as well as has the cygwin environment
    in the path.  Run 'make -f Makefile.win32'.

diff --git a/Makefile.win32 b/Makefile.win32
new file mode 100644
index 0000000..79a1dad
--- /dev/null
+++ b/Makefile.win32
@@ -0,0 +1,18 @@
+
+SUBDIRS = pixman/src src
+
+TEST_SUBDIRS = boilerplate test
+
+all: cairo
+
+cairo: src/cairo-features.h
+	@list='$(SUBDIRS)'; for f in $$list ; do \
+		echo making all in $$f... ; \
+		(cd $$f ; make -f Makefile.win32) || exit 1 ; \
+	done
+
+test: cairo
+ 	@list='$(TEST_SUBDIRS)'; for f in $$list ; do \
+		echo making all in $$f... ; \
+		(cd $$f ; make -f Makefile.win32) || exit 1 ; \
+	done ;
diff --git a/boilerplate/Makefile.win32 b/boilerplate/Makefile.win32
new file mode 100644
index 0000000..c2696c7
--- /dev/null
+++ b/boilerplate/Makefile.win32
@@ -0,0 +1,18 @@
+CC = cl
+CFLAGS = /nologo /Zi /O2 /I../src /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
+
+SOURCES = \
+	cairo-boilerplate.c \
+	xmalloc.c \
+	$(NULL)
+
+OBJECTS = $(subst .c,.obj,$(SOURCES))
+
+all: boiler.lib
+
+%.obj: %.c
+	@$(CC) $(CFLAGS) /c /Fo"$@" $<
+
+boiler.lib: $(OBJECTS)
+	lib /NOLOGO /OUT:$@ $(OBJECTS)
+
diff --git a/pixman/src/Makefile.win32 b/pixman/src/Makefile.win32
new file mode 100644
index 0000000..8f9ad16
--- /dev/null
+++ b/pixman/src/Makefile.win32
@@ -0,0 +1,34 @@
+CC = cl
+CFLAGS = /nologo /Zi /O2 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
+
+SOURCES = \
+	fbcompose.c \
+	fbedge.c \
+	fbpict.c \
+	fbtrap.c \
+	icblt.c \
+	icbltone.c \
+	iccolor.c \
+	icformat.c \
+	icimage.c \
+	icpixels.c \
+	icrect.c \
+	icstipple.c \
+	ictransform.c \
+	ictrap.c \
+	ictri.c \
+	icutil.c \
+	pixregion.c \
+	renderedge.c \
+	$(NULL)
+
+OBJECTS = $(subst .c,.obj,$(SOURCES))
+
+all: pixman.lib
+
+%.obj: %.c
+	@$(CC) $(CFLAGS) /c /Fo"$@" $<
+
+pixman.lib: $(OBJECTS)
+	lib /NOLOGO /OUT:$@ $(OBJECTS)
+
diff --git a/src/Makefile.win32 b/src/Makefile.win32
new file mode 100644
index 0000000..50b419d
--- /dev/null
+++ b/src/Makefile.win32
@@ -0,0 +1,107 @@
+CC = cl
+LINK = link
+
+CFLAGS = /Zi /nologo /O2 /c /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /I../pixman/src /I. /DPACKAGE_VERSION="" /DPACKAGE_BUGREPORT=""
+
+DEFFILE = cairo.def
+srcdir = `pwd`
+
+SOURCES = \
+	cairo-arc.c \
+	cairo-array.c \
+	cairo-cache.c \
+	cairo-clip.c \
+	cairo-color.c \
+	cairo-debug.c \
+	cairo-fixed.c \
+	cairo-font-options.c \
+	cairo-font.c \
+	cairo-gstate.c \
+	cairo-hash.c \
+	cairo-hull.c \
+	cairo-image-surface.c \
+	cairo-lzw.c \
+	cairo-matrix.c \
+	cairo-meta-surface.c \
+	cairo-output-stream.c \
+	cairo-operator.c \
+	cairo-path-bounds.c \
+	cairo-path-data.c \
+	cairo-path-fill.c \
+	cairo-path-stroke.c \
+	cairo-path.c \
+	cairo-pattern.c \
+	cairo-pen.c \
+	cairo-polygon.c \
+	cairo-png.c \
+	cairo-rectangle.c \
+	cairo-region.c \
+	cairo-scaled-font.c \
+	cairo-slope.c \
+	cairo-spline.c \
+	cairo-stroke-style.c \
+	cairo-surface-fallback.c \
+	cairo-surface.c \
+	cairo-traps.c \
+	cairo-truetype-subset.c \
+	cairo-type1-fallback.c \
+	cairo-unicode.c \
+	cairo-wideint.c \
+	cairo-win32-font.c \
+	cairo.c \
+	cairo-svg-surface.c \
+	cairo-ps-surface.c \
+	cairo-pdf-surface.c \
+	cairo-scaled-font-subsets.c \
+	cairo-paginated-surface.c \
+	cairo-analysis-surface.c \
+	cairo-base85-stream.c \
+	$(NULL)
+
+STATIC_SOURCES = cairo-win32-surface.c 
+
+cairo_headers = \
+	cairo.h \
+	cairo-pdf.h \
+	cairo-ps.h \
+	cairo-svg.h \
+	cairo-win32.h \
+	cairo-pdf-test.h \
+	cairo-ps-test.h \
+	cairo-scaled-font-test.h \
+	cairo-svg-test.h \
+	$(NULL)
+
+OBJECTS = $(subst .c,.obj,$(SOURCES))
+SHARED_OBJECTS = $(subst .c,.obj,$(STATIC_SOURCES))
+STATIC_OBJECTS = $(subst .c,-static.obj,$(STATIC_SOURCES))
+
+all: cairo.dll cairo-static.lib
+
+%.obj: %.c
+	@$(CC) $(CFLAGS) /Fo"$@" $<
+
+%-static.obj: %.c
+	@$(CC) $(CFLAGS) /DCAIRO_WIN32_STATIC_BUILD=1 /Fo"$@" $<
+
+$(DEFFILE):
+	(echo EXPORTS; \
+	(cd $(srcdir); cat $(cairo_headers) || echo 'cairo_ERROR ()' ) | \
+	grep -v -E '^# *include' | \
+	( gcc -include cairo-features.h -E - || echo 'cairo_ERROR ()' ) | \
+	grep -E '^_?cairo_.* \(' | \
+	sed -e 's/[ 	].*//' | \
+	sort; \
+	echo LIBRARY cairo.dll; \
+	) >$@
+	@ ! grep -q cairo_ERROR $@ || ($(RM) $@; false)
+
+cairo.dll: $(OBJECTS) $(SHARED_OBJECTS) $(DEFFILE)
+	$(CC) /Zi /LD /Fe$@ ../pixman/src/pixman.lib $(OBJECTS) $(SHARED_OBJECTS) /link /DEF:$(DEFFILE) user32.lib gdi32.lib libpng.lib zlib.lib /NODEFAULTLIB:LIBCMT
+
+cairo-static.lib: $(OBJECTS) $(STATIC_OBJECTS)
+	lib /NOLOGO /OUT:$@ ../pixman/src/pixman.lib $(OBJECTS) $(STATIC_OBJECTS)
+
+
+clean:
+	@rm -f *.obj || rm -f *.dll || rm -f *.lib || rm -f *.exe || rm -f *.exe.manifest || rm -f *.pdb || rm -f *.ilk || exit 0
diff --git a/test/Makefile.win32 b/test/Makefile.win32
new file mode 100644
index 0000000..0f56bbd
--- /dev/null
+++ b/test/Makefile.win32
@@ -0,0 +1,102 @@
+CC = cl
+CFLAGS = /nologo /Zi /O2 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /I../src /I../pixman/src /I../boilerplate
+LDFLAGS = ../src/cairo.lib ../pixman/src/pixman.lib ../boilerplate/boiler.lib libpng.lib zlib.lib gdi32.lib msimg32.lib user32.lib
+
+TESTS = 			\
+a8-mask				\
+caps-joins			\
+caps-joins-alpha		\
+caps-sub-paths			\
+clip-all			\
+clip-fill-rule			\
+clip-fill-rule-pixel-aligned	\
+clip-nesting			\
+clip-operator			\
+clip-twice			\
+composite-integer-translate-source \
+composite-integer-translate-over \
+composite-integer-translate-over-repeat \
+create-for-stream		\
+create-from-png			\
+create-from-png-stream		\
+dash-caps-joins			\
+dash-no-dash			\
+dash-offset-negative		\
+dash-scale			\
+dash-zero-length		\
+degenerate-path			\
+device-offset			\
+device-offset-positive		\
+extend-reflect			\
+fill-and-stroke			\
+fill-and-stroke-alpha		\
+fill-and-stroke-alpha-add	\
+fill-rule			\
+filter-nearest-offset		\
+font-face-get-type		\
+font-matrix-translation		\
+glyph-cache-pressure		\
+get-and-set			\
+get-group-target		\
+gradient-alpha			\
+leaky-dash			\
+leaky-polygon			\
+line-width			\
+line-width-scale		\
+linear-gradient			\
+mask				\
+mask-ctm			\
+mask-surface-ctm		\
+move-to-show-surface		\
+new-sub-path			\
+nil-surface			\
+operator-clear			\
+operator-source			\
+paint				\
+paint-source-alpha		\
+paint-with-alpha		\
+path-data			\
+pattern-get-type		\
+pixman-rotate			\
+rectangle-rounding-error	\
+scale-source-surface-paint	\
+select-font-face		\
+select-font-no-show-text	\
+self-copy			\
+self-intersecting		\
+set-source			\
+show-text-current-point		\
+source-clip			\
+source-surface-scale-paint	\
+surface-finish-twice		\
+surface-pattern			\
+text-antialias-gray		\
+text-antialias-none		\
+text-antialias-subpixel		\
+text-cache-crash		\
+text-pattern			\
+text-rotate			\
+transforms			\
+translate-show-surface		\
+trap-clip			\
+unantialiased-shapes		\
+unbounded-operator		\
+user-data			\
+rel-path                        \
+push-group			\
+zero-alpha			\
+$(NULL)
+
+BOILER_LIB = ../boilerplate/boiler.lib
+
+TESTCORE_SOURCES = \
+	cairo-test.c \
+	buffer-diff.c \
+	$(NULL)
+
+TEST_EXE = $(addsuffix .exe,$(TESTS))
+
+all: $(TEST_EXE)
+
+%.exe: %.c
+	@$(CC) $(CFLAGS) /Fe"$@" $<  $(TESTCORE_SOURCES) $(LDFLAGS) $(BOILER_LIB)
diff-tree 3c5a02c3edf300494cebfe746292b1eeeea08595 (from dbd0fa193c77a6cb112b4862c72c3a18209a755e)
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Sat Sep 9 17:06:21 2006 -0700

    [win32] Misc win32 compilation fixes
    
    Fix win32/MSVC defines for snprintf, inline, and M_PI

diff --git a/src/cairoint.h b/src/cairoint.h
old mode 100644
new mode 100755
index 0ee33dc..53a1130
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -65,6 +65,11 @@
 #include "cairo.h"
 #include <pixman.h>
 
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#define inline __inline
+#endif
+
 CAIRO_BEGIN_DECLS
 
 #if __GNUC__ >= 3 && defined(__ELF__)
diff --git a/test/cairo-test.h b/test/cairo-test.h
old mode 100644
new mode 100755
index 381709d..a2d0285
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -53,6 +53,12 @@ typedef unsigned __int64 uint64_t;
 #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, \etc.)
 #endif
 
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
+
+#include <math.h>
+
 typedef enum cairo_test_status {
     CAIRO_TEST_SUCCESS = 0,
     CAIRO_TEST_FAILURE,
diff-tree dbd0fa193c77a6cb112b4862c72c3a18209a755e (from 99360bd35d77e1a3f536e72f5729455580c980c2)
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Sat Sep 9 17:05:00 2006 -0700

    [win32] Make cairo as a win32 static library possible
    
    This adds a win32 initialization function that is called from all
    surface creation and font creation functions to ensure that the win32
    mutexes are initialized.

diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
old mode 100644
new mode 100755
index 62c0f46..d92987c
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -237,6 +237,8 @@ _win32_scaled_font_create (LOGFONTW     
     cairo_matrix_t scale;
     cairo_status_t status;
 
+    _cairo_win32_initialize ();
+
     f = malloc (sizeof(cairo_win32_scaled_font_t));
     if (f == NULL)
 	return NULL;
@@ -468,6 +470,8 @@ _cairo_win32_scaled_font_create_toy (cai
     int face_name_len;
     cairo_status_t status;
 
+    _cairo_win32_initialize ();
+
     status = _cairo_utf8_to_utf16 (toy_face->family, -1,
 				   &face_name, &face_name_len);
     if (status)
@@ -1489,6 +1493,8 @@ _cairo_win32_font_face_scaled_font_creat
 {
     cairo_win32_font_face_t *font_face = abstract_face;
 
+    _cairo_win32_initialize ();
+
     *font = _win32_scaled_font_create (&font_face->logfont,
 				       font_face->hfont,
 				       &font_face->base,
@@ -1526,6 +1532,8 @@ cairo_win32_font_face_create_for_logfont
 {
     cairo_win32_font_face_t *font_face;
 
+    _cairo_win32_initialize ();
+
     font_face = malloc (sizeof (cairo_win32_font_face_t));
     if (!font_face) {
 	_cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1559,6 +1567,8 @@ cairo_win32_font_face_create_for_hfont (
 {
     cairo_win32_font_face_t *font_face;
 
+    _cairo_win32_initialize ();
+
     font_face = malloc (sizeof (cairo_win32_font_face_t));
     if (!font_face) {
 	_cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-win32-private.h b/src/cairo-win32-private.h
old mode 100644
new mode 100755
index 8a8ccea..c16c7e9
--- a/src/cairo-win32-private.h
+++ b/src/cairo-win32-private.h
@@ -82,4 +82,7 @@ _cairo_win32_print_gdi_error (const char
 cairo_bool_t
 _cairo_surface_is_win32 (cairo_surface_t *surface);
 
+void
+_cairo_win32_initialize ();
+
 #endif /* CAIRO_WIN32_PRIVATE_H */
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
old mode 100644
new mode 100755
index 0554e43..27bdcfa
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -266,6 +266,8 @@ _cairo_win32_surface_create_for_dc (HDC 
     char *bits;
     int rowstride;
 
+    _cairo_win32_initialize ();
+
     surface = malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL) {
 	_cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1104,6 +1106,8 @@ cairo_win32_surface_create (HDC hdc)
     int depth;
     cairo_format_t format;
 
+    _cairo_win32_initialize ();
+
     /* Try to figure out the drawing bounds for the Device context
      */
     if (GetClipBox (hdc, &rect) == ERROR) {
@@ -1274,11 +1278,28 @@ static const cairo_surface_backend_t cai
  * threaded before any other function.
  * Initializing more than finally needed should not matter much.
  */
-#ifndef HAVE_PTHREAD_H
+#if !defined(HAVE_PTHREAD_H) 
+
 CRITICAL_SECTION cairo_toy_font_face_hash_table_mutex;
 CRITICAL_SECTION cairo_scaled_font_map_mutex;
 CRITICAL_SECTION cairo_ft_unscaled_font_map_mutex;
 
+static int _cairo_win32_initialized = 0;
+
+void
+_cairo_win32_initialize () {
+    if (_cairo_win32_initialized)
+        return;
+
+    /* every 'mutex' from CAIRO_MUTEX_DECALRE needs to be initialized here */
+    InitializeCriticalSection (&cairo_toy_font_face_hash_table_mutex);
+    InitializeCriticalSection (&cairo_scaled_font_map_mutex);
+    InitializeCriticalSection (&cairo_ft_unscaled_font_map_mutex);
+
+    _cairo_win32_initialized = 1;
+}
+
+#if !defined(CAIRO_WIN32_STATIC_BUILD)
 BOOL WINAPI
 DllMain (HINSTANCE hinstDLL,
 	 DWORD     fdwReason,
@@ -1287,10 +1308,7 @@ DllMain (HINSTANCE hinstDLL,
   switch (fdwReason)
   {
   case DLL_PROCESS_ATTACH:
-    /* every 'mutex' from CAIRO_MUTEX_DECALRE needs to be initialized here */
-    InitializeCriticalSection (&cairo_toy_font_face_hash_table_mutex);
-    InitializeCriticalSection (&cairo_scaled_font_map_mutex);
-    InitializeCriticalSection (&cairo_ft_unscaled_font_map_mutex);
+    _cairo_win32_initialize();
     break;
   case DLL_PROCESS_DETACH:
     DeleteCriticalSection (&cairo_toy_font_face_hash_table_mutex);
@@ -1301,3 +1319,4 @@ DllMain (HINSTANCE hinstDLL,
   return TRUE;
 }
 #endif
+#endif


More information about the cairo-commit mailing list