summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-09-20 18:17:19 -0400
committerBehdad Esfahbod <behdad@behdad.org>2008-09-20 18:26:27 -0400
commit45609d840078288bf0fc096ee8bac642fed6674f (patch)
treecb6d2719f3d50d937b4ea087a71e87958c695769
parent9c2732395987a29ee764c575cce2b13e94152151 (diff)
Add cairo-system.c for platform system-specific code
This is where DLL initialization/finalization should be done for example. Moved the one for win32. For OS/2 just left a comment as the code needs more work. This change simplifies building shared and static libraries in the win32 makefiles.
-rw-r--r--src/Makefile.sources1
-rw-r--r--src/cairo-mutex-impl-private.h8
-rw-r--r--src/cairo-os2-surface.c6
-rw-r--r--src/cairo-system.c97
-rw-r--r--src/cairo-win32-surface.c28
5 files changed, 112 insertions, 28 deletions
diff --git a/src/Makefile.sources b/src/Makefile.sources
index ba747027..0e2e4870 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -134,6 +134,7 @@ cairo_sources = \
cairo-stroke-style.c \
cairo-surface.c \
cairo-surface-fallback.c \
+ cairo-system.c \
cairo-traps.c \
cairo-unicode.c \
cairo-user-font.c \
diff --git a/src/cairo-mutex-impl-private.h b/src/cairo-mutex-impl-private.h
index 95c666f7..d8b38891 100644
--- a/src/cairo-mutex-impl-private.h
+++ b/src/cairo-mutex-impl-private.h
@@ -74,6 +74,9 @@
* cairo_mutex_impl_t _cairo_some_mutex;
* </programlisting>
*
+ * - #define CAIRO_MUTEX_IMP_<NAME> 1 with suitable name for your platform. You
+ * can later use this symbol in cairo-system.c.
+ *
* - #define CAIRO_MUTEX_IMPL_LOCK(mutex) and CAIRO_MUTEX_IMPL_UNLOCK(mutex) to
* proper statement to lock/unlock the mutex object passed in.
* You can (and should) assume that the mutex is already
@@ -155,6 +158,7 @@
typedef int cairo_mutex_impl_t;
+# define CAIRO_MUTEX_IMPL_NO 1
# define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
# define CAIRO_MUTEX_IMPL_LOCK(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
@@ -166,6 +170,7 @@
typedef pthread_mutex_t cairo_mutex_impl_t;
+# define CAIRO_MUTEX_IMPL_PTHREAD 1
# define CAIRO_MUTEX_IMPL_LOCK(mutex) pthread_mutex_lock (&(mutex))
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
# define CAIRO_MUTEX_IMPL_FINI(mutex) pthread_mutex_destroy (&(mutex))
@@ -178,6 +183,7 @@
typedef CRITICAL_SECTION cairo_mutex_impl_t;
+# define CAIRO_MUTEX_IMPL_WIN32 1
# define CAIRO_MUTEX_IMPL_LOCK(mutex) EnterCriticalSection (&(mutex))
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) LeaveCriticalSection (&(mutex))
# define CAIRO_MUTEX_IMPL_INIT(mutex) InitializeCriticalSection (&(mutex))
@@ -192,6 +198,7 @@
typedef HMTX cairo_mutex_impl_t;
+# define CAIRO_MUTEX_IMPL_OS2 1
# define CAIRO_MUTEX_IMPL_LOCK(mutex) DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT)
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) DosReleaseMutexSem(mutex)
# define CAIRO_MUTEX_IMPL_INIT(mutex) DosCreateMutexSem (NULL, &(mutex), 0L, FALSE)
@@ -202,6 +209,7 @@
typedef BLocker* cairo_mutex_impl_t;
+# define CAIRO_MUTEX_IMPL_BEOS 1
# define CAIRO_MUTEX_IMPL_LOCK(mutex) (mutex)->Lock()
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) (mutex)->Unlock()
# define CAIRO_MUTEX_IMPL_INIT(mutex) (mutex) = new BLocker()
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index 80a1cd97..c55d6917 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -232,6 +232,12 @@ void _buffer_free (void *buffer)
#endif
}
+/* XXX
+ * The cairo_os2_init/fini() functions should be removed and the LibMain
+ * code moved to cairo-system.c. It should also call
+ * cairo_debug_reset_static_data() instead of duplicating its logic...
+ */
+
#ifdef BUILD_CAIRO_DLL
/* The main DLL entry for DLL initialization and uninitialization */
/* Only include this code if we're about to build a DLL. */
diff --git a/src/cairo-system.c b/src/cairo-system.c
new file mode 100644
index 00000000..9970fceb
--- /dev/null
+++ b/src/cairo-system.c
@@ -0,0 +1,97 @@
+/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
+/* Cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is Red Hat, Inc.
+ *
+ * Contributor(s):
+ * Owen Taylor <otaylor@redhat.com>
+ * Stuart Parmenter <stuart@mozilla.com>
+ * Vladimir Vukicevic <vladimir@pobox.com>
+ */
+
+/* This file should include code that is system-specific, not
+ * feature-specific. For example, the DLL initialization/finalization
+ * code on Win32 or OS/2 must live here (not in cairo-whatever-surface.c).
+ * Same about possible ELF-specific code.
+ *
+ * And no other function should live here.
+ */
+
+
+#include "cairoint.h"
+
+
+
+#if CAIRO_MUTEX_IMPL_WIN32
+#if !defined(CAIRO_WIN32_STATIC_BUILD)
+
+#define WIN32_LEAN_AND_MEAN
+/* We require Windows 2000 features such as ETO_PDY */
+#if !defined(WINVER) || (WINVER < 0x0500)
+# define WINVER 0x0500
+#endif
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
+# define _WIN32_WINNT 0x0500
+#endif
+
+#include "cairo-clip-private.h"
+#include "cairo-paginated-private.h"
+#include "cairo-win32-private.h"
+#include "cairo-scaled-font-subsets-private.h"
+
+#include <windows.h>
+
+/* declare to avoid "no previous prototype for 'DllMain'" warning */
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved);
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ CAIRO_MUTEX_INITIALIZE ();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ CAIRO_MUTEX_FINALIZE ();
+ break;
+ }
+
+ return TRUE;
+}
+
+#endif
+#endif
+
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 54c4ae41..395d818d 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -2013,34 +2013,6 @@ static const cairo_surface_backend_t cairo_win32_surface_backend = {
*/
-#if !defined(CAIRO_WIN32_STATIC_BUILD)
-
-/* declare to avoid "no previous prototype for 'DllMain'" warning */
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved);
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
-{
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
- CAIRO_MUTEX_INITIALIZE ();
- break;
-
- case DLL_PROCESS_DETACH:
- CAIRO_MUTEX_FINALIZE ();
- break;
- }
-
- return TRUE;
-}
-
-#endif
-
cairo_int_status_t
_cairo_win32_save_initial_clip (HDC hdc, cairo_win32_surface_t *surface)
{