[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FreeType 1.3.1 on BeOS
From: |
Chris Herborth |
Subject: |
FreeType 1.3.1 on BeOS |
Date: |
Tue, 22 Feb 2000 14:44:48 -0500 |
Here's a small patch for FreeType 1.3.1 on BeOS (and presumably other
platforms that like thread-safe code) based on my work with FreeType as
part of Catharon's team... lib/ttraster.c uses (and eventually deletes) a
mutex it never creates. Also included in this patch are a BeOS mutex
implementation (lib/arch/beos/ttmutex-beos.c) and an ft_conf.h
(lib/arch/beos/ft_conf.h).
Index: freetype-1.3.1/lib/ttraster.c
===================================================================
RCS file: /cvsroot/vdelta/Libs/freetype-1.3.1/lib/ttraster.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 ttraster.c
*** freetype-1.3.1/lib/ttraster.c 2000/02/20 16:26:42 1.1.1.1
--- freetype-1.3.1/lib/ttraster.c 2000/02/22 20:33:22
***************
*** 2697,2702 ****
--- 2697,2705 ----
ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) );
ras->gray_width = RASTER_GRAY_LINES/2;
+ /* Who left this out? - [cjh] */
+ MUTEX_Create( engine->raster_lock );
+
/* Initialization of Count_Table */
for ( i = 0; i < 256; i++ )
Index: freetype-1.3.1/lib/arch/beos/ft_conf.h
===================================================================
RCS file: ft_conf.h
diff -N ft_conf.h
*** /dev/null Tue May 5 16:32:27 1998
--- ft_conf.h Tue Feb 22 15:33:22 2000
***************
*** 0 ****
--- 1,217 ----
+ /* ft_conf.h for BeOS */
+
+ /* This file is part of the FreeType project. */
+
+
+ /* we need the following because there are some typedefs in this file */
+
+ #ifndef FT_CONF_H
+ #define FT_CONF_H
+
+ #ifndef BEOS
+ #define BEOS
+ #endif
+
+ /* Define to empty if the keyword does not work. */
+ /* #undef const */
+
+ /* Define if you have a working `mmap' system call. */
+ #undef HAVE_MMAP
+
+ /* Define if you have the <stdlib.h> header file. */
+ #define HAVE_STDLIB_H
+
+ /* Define if the X Window System is missing or not being used. */
+ #define X_DISPLAY_MISSING
+
+ /* The number of bytes in a int. */
+ #define SIZEOF_INT 4
+
+ /* The number of bytes in a long. */
+ #define SIZEOF_LONG 4
+
+ /* Define if you have the getpagesize function. */
+ #undef HAVE_GETPAGESIZE
+
+ /* Define if you have the memcpy function. */
+ #define HAVE_MEMCPY
+
+ /* Define if you have the memmove function. */
+ #define HAVE_MEMMOVE
+
+ /* Define if you have the <fcntl.h> header file. */
+ #define HAVE_FCNTL_H
+
+ /* Define if you have the <unistd.h> header file. */
+ #define HAVE_UNISTD_H
+
+ /* Define if you have the <locale.h> header file. */
+ #define HAVE_LOCALE_H
+
+ /* Define if you have the <libintl.h> header file. */
+ #undef HAVE_LIBINTL_H
+
+ /* Define if you have the libintl library. */
+ #undef HAVE_LIBINTL
+
+ /**********************************************************************/
+ /* */
+ /* The following configuration macros can be tweaked manually by */
+ /* a developer to turn on or off certain features or options in the */
+ /* TrueType engine. This may be useful to tune it for specific */
+ /* purposes.. */
+ /* */
+ /**********************************************************************/
+
+ /*************************************************************************/
+ /* Define this if the underlying operating system uses a different */
+ /* character width than 8bit for file names. You must then also supply */
+ /* a typedef declaration for defining 'TT_Text'. Default is off. */
+
+ /* #undef HAVE_TT_TEXT */
+
+
+ /*************************************************************************/
+ /* Define this if you want to generate code to support engine extensions */
+ /* Default is on, but if you're satisfied by the basic services provided */
+ /* by the engine and need no extensions, undefine this configuration */
+ /* macro to save a few more bytes. */
+
+ #define TT_CONFIG_OPTION_EXTEND_ENGINE
+
+
+ /*************************************************************************/
+ /* Define this if you want to generate code to support gray-scaling, */
+ /* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */
+ /* disable it if you don't need it. */
+
+ #define TT_CONFIG_OPTION_GRAY_SCALING
+
+
+ /*************************************************************************/
+ /* Define this if you want to completely disable the use of the bytecode */
+ /* interpreter. Doing so will produce a much smaller library, but the */
+ /* quality of the rendered glyphs will enormously suffer from this. */
+ /* */
+ /* This switch was introduced due to the Apple patents issue which */
+ /* emerged recently on the FreeType lists. We still do not have Apple's */
+ /* opinion on the subject and will change this as soon as we have. */
+
+ #undef TT_CONFIG_OPTION_NO_INTERPRETER
+
+
+ /*************************************************************************/
+ /* Define this if you want to use a big 'switch' statement within the */
+ /* bytecode interpreter. Because some non-optimizing compilers are not */
+ /* able to produce jump tables from such statements, undefining this */
+ /* configuration macro will generate the appropriate C jump table in */
+ /* ttinterp.c. If you use an optimizing compiler, you should leave it */
+ /* defined for better performance and code compactness.. */
+
+ #define TT_CONFIG_OPTION_INTERPRETER_SWITCH
+
+
+ /*************************************************************************/
+ /* Define this if you want to build a 'static' version of the scan-line */
+ /* converter (the component which in charge of converting outlines into */
+ /* bitmaps). This will produce a bigger object file for "ttraster.c", */
+ /* which _may_ be faster on some architectures.. */
+ /* */
+ /* Do NOT DEFINE THIS is you build a thread-safe version of the engine */
+ /* */
+ #undef TT_CONFIG_OPTION_STATIC_RASTER
+
+
+ /*************************************************************************/
+ /* Define this if you want to build a 'static' version of the TrueType */
+ /* bytecode interpreter. This will produce much bigger code, which */
+ /* _may_ be faster on some architectures.. */
+ /* */
+ /* Do NOT DEFINE THIS is you build a thread-safe version of the engine */
+ /* */
+ #undef TT_CONFIG_OPTION_STATIC_INTERPRETER
+
+
+ /*************************************************************************/
+ /* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */
+ /* version of the library. */
+
+ #define TT_CONFIG_OPTION_THREAD_SAFE
+
+
+ /**********************************************************************/
+ /* */
+ /* The following macros are used to define the debug level, as well */
+ /* as individual tracing levels for each component. There are */
+ /* currently three modes of operation : */
+ /* */
+ /* - trace mode (define DEBUG_LEVEL_TRACE) */
+ /* */
+ /* The engine prints all error messages, as well as tracing */
+ /* ones, filtered by each component's level */
+ /* */
+ /* - debug mode (define DEBUG_LEVEL_ERROR) */
+ /* */
+ /* Disable tracing, but keeps error output and assertion */
+ /* checks. */
+ /* */
+ /* - release mode (don't define anything) */
+ /* */
+ /* Don't include error-checking or tracing code in the */
+ /* engine's code. Ideal for releases. */
+ /* */
+ /* NOTE : */
+ /* */
+ /* Each component's tracing level is defined in its own source. */
+ /* */
+ /**********************************************************************/
+
+ /* Define if you want to use the tracing debug mode */
+ #undef DEBUG_LEVEL_TRACE
+
+ /* Define if you want to use the error debug mode - ignored if */
+ /* DEBUG_LEVEL_TRACE is defined */
+ #undef DEBUG_LEVEL_ERROR
+
+
+ /**************************************************************************
/
+ /* Definition of various integer sizes. These types are used by ttcalc *
/
+ /* and ttinterp (for the 64-bit integers) only.. *
/
+
+ #if SIZEOF_INT == 4
+
+ typedef signed int TT_Int32;
+ typedef unsigned int TT_Word32;
+
+ #elif SIZEOF_LONG == 4
+
+ typedef signed long TT_Int32;
+ typedef unsigned long TT_Word32;
+
+ #else
+ #error "no 32bit type found"
+ #endif
+
+ #if SIZEOF_LONG == 8
+
+ /* LONG64 must be defined when a 64-bit type is available */
+ /* INT64 must then be defined to this type.. */
+ #define LONG64
+ #define INT64 long
+
+ #else
+
+ /* GCC provides the non-ANSI 'long long' 64-bit type. You can activate
*/
+ /* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this
*/
+ /* will produce many -ansi warnings during library compilation.
*/
+ #define TT_USE_LONG_LONG
+
+ #ifdef TT_USE_LONG_LONG
+
+ #define LONG64
+ #define INT64 long long
+
+ #endif /* TT_USE_LONG_LONG */
+ #endif
+
+ #endif /* FT_CONF_H */
Index: freetype-1.3.1/lib/arch/beos/ttmutex-beos.c
===================================================================
RCS file: ttmutex-beos.c
diff -N ttmutex-beos.c
*** /dev/null Tue May 5 16:32:27 1998
--- ttmutex-beos.c Tue Feb 22 15:33:22 2000
***************
*** 0 ****
--- 1,125 ----
+ /*******************************************************************
+ *
+ * ttmutex.c 1.0
+ *
+ * Mutual exclusion object, BeOS implementation
+ *
+ * Copyright 1999 by
+ * Catharon Productions, Inc.
+ *
+ * This file is part of the FreeType project, and may only be used
+ * modified and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ ******************************************************************/
+
+ #include "ttmutex.h"
+
+ #include <kernel/OS.h>
+ #include <support/SupportDefs.h>
+
+ /* required by the tracing mode */
+ #undef TT_COMPONENT
+ #define TT_COMPONENT trace_mutex
+
+
+ #ifdef TT_CONFIG_OPTION_THREAD_SAFE
+
+ // New and improved BeOS mutex in the form of a "benaphore".
+ typedef struct {
+ sem_id _sem;
+ int32 _atom;
+ } beos_mutex_t;
+
+ // Counter so the semaphores have unique names; access this with
+ // atomic_*() functions only!
+ static int32 _mutex_counter = 0;
+
+ // Allocate and initialize the mutex.
+ LOCAL_FUNC
+ void TT_Mutex_Create ( TMutex* mutex )
+ {
+ beos_mutex_t *m = NULL;
+
+ m = (beos_mutex_t *)malloc( sizeof( beos_mutex_t ) );
+ if( m ) {
+ char mutex_name[B_OS_NAME_LENGTH];
+ int32 prev = atomic_add( &_mutex_counter, 1 );
+
+ sprintf( mutex_name, "FreeType mutex (%d)", prev );
+
+ m->_atom = 0;
+ m->_sem = create_sem( 0, mutex_name );
+
+ if( m->_sem < B_NO_ERROR ) {
+ // Can't get a semaphore, so we're screwed.
+ free( m );
+ m = NULL;
+ }
+ }
+
+ // Send back the new mutex.
+ *mutex = (TMutex)m;
+ }
+
+ // Delete a mutex.
+ LOCAL_FUNC
+ void TT_Mutex_Delete ( TMutex* mutex )
+ {
+ if( mutex ) {
+ beos_mutex_t *m = (beos_mutex_t *)*mutex;
+
+ if( m->_sem >= B_NO_ERROR ) {
+ status_t retval = delete_sem( m->_sem );
+
+ // Make the compiler shut up...
+ retval = retval;
+ }
+
+ free( m );
+ }
+ }
+
+ // Attempt to lock a mutex; blocks until we can lock it or the semaphore
+ // is destroyed.
+ LOCAL_FUNC
+ void TT_Mutex_Lock ( TMutex* mutex )
+ {
+ int32 prev = 0;
+ beos_mutex_t *m = (beos_mutex_t *)*mutex;
+
+ if ( !mutex ) return;
+
+ prev = atomic_add( &(m->_atom), 1 );
+ if( prev > 0 ) {
+ status_t retval = acquire_sem( m->_sem );
+
+ // Make the compiler shut up...
+ retval = retval;
+ }
+ }
+
+ // Release a mutex.
+ LOCAL_FUNC
+ void TT_Mutex_Release( TMutex* mutex )
+ {
+ int32 prev = 0;
+ beos_mutex_t *m = (beos_mutex_t *)*mutex;
+
+ if ( !mutex ) return;
+
+ prev = atomic_add( &(m->_atom), -1 );
+ if( prev > 1 ) {
+ status_t retval = release_sem( m->_sem );
+
+ // Make the compiler shut up...
+ retval = retval;
+ }
+ }
+
+ #endif /* TT_CONFIG_OPTION_THREAD_SAFE */
+
+
+ /* END */
--
Chris Herborth (address@hidden), BeOS Hacker
Catharon Productions, Inc. (Ottawa office), http://www.catharon.com/
- FreeType 1.3.1 on BeOS,
Chris Herborth <=