parent
9d3de385a6
commit
4b5661c386
10 changed files with 1664 additions and 1853 deletions
@ -1,195 +0,0 @@ |
||||
#ifndef __FT_SYSTEM_IO_H__ |
||||
#define __FT_SYSTEM_IO_H__ |
||||
|
||||
/************************************************************************/ |
||||
/************************************************************************/ |
||||
/***** *****/ |
||||
/***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/ |
||||
/***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/ |
||||
/***** *****/ |
||||
/************************************************************************/ |
||||
/************************************************************************/ |
||||
|
||||
|
||||
/********************************************************************
|
||||
* |
||||
* designing custom streams is a bit different now |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
* |
||||
*/ |
||||
|
||||
#include <ft2build.h> |
||||
#include FT_INTERNAL_OBJECT_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/*@*******************************************************************
|
||||
* |
||||
* @type: FT_Stream |
||||
* |
||||
* @description: |
||||
* handle to an input stream object. These are also @FT_Object handles |
||||
*/ |
||||
typedef struct FT_StreamRec_* FT_Stream; |
||||
|
||||
|
||||
/*@*******************************************************************
|
||||
* |
||||
* @type: FT_Stream_Class |
||||
* |
||||
* @description: |
||||
* opaque handle to a @FT_Stream_ClassRec class structure describing |
||||
* the methods of input streams |
||||
*/ |
||||
typedef const struct FT_Stream_ClassRec_* FT_Stream_Class; |
||||
|
||||
|
||||
/*@*******************************************************************
|
||||
* |
||||
* @functype: FT_Stream_ReadFunc |
||||
* |
||||
* @description: |
||||
* a method used to read bytes from an input stream into memory |
||||
* |
||||
* @input: |
||||
* stream :: target stream handle |
||||
* buffer :: target buffer address |
||||
* size :: number of bytes to read |
||||
* |
||||
* @return: |
||||
* number of bytes effectively read. Must be <= 'size'. |
||||
*/ |
||||
typedef FT_ULong (*FT_Stream_ReadFunc)( FT_Stream stream, |
||||
FT_Byte* buffer, |
||||
FT_ULong size ); |
||||
|
||||
|
||||
/*@*******************************************************************
|
||||
* |
||||
* @functype: FT_Stream_SeekFunc |
||||
* |
||||
* @description: |
||||
* a method used to seek to a new position within a stream |
||||
* |
||||
* @input: |
||||
* stream :: target stream handle |
||||
* pos :: new read position, from start of stream |
||||
* |
||||
* @return: |
||||
* error code. 0 means success |
||||
*/ |
||||
typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream, |
||||
FT_ULong pos ); |
||||
|
||||
|
||||
/*@*******************************************************************
|
||||
* |
||||
* @struct: FT_Stream_ClassRec |
||||
* |
||||
* @description: |
||||
* a structure used to describe an input stream class |
||||
* |
||||
* @input: |
||||
* clazz :: root @FT_ClassRec fields |
||||
* stream_read :: stream byte read method |
||||
* stream_seek :: stream seek method |
||||
*/ |
||||
typedef struct FT_Stream_ClassRec_ |
||||
{ |
||||
FT_ClassRec clazz; |
||||
FT_Stream_ReadFunc stream_read; |
||||
FT_Stream_SeekFunc stream_seek; |
||||
|
||||
} FT_Stream_ClassRec; |
||||
|
||||
/* */ |
||||
|
||||
#define FT_STREAM_CLASS(x) ((FT_Stream_Class)(x)) |
||||
#define FT_STREAM_CLASS__READ(x) FT_STREAM_CLASS(x)->stream_read |
||||
#define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek; |
||||
|
||||
/*@*******************************************************************
|
||||
* |
||||
* @struct: FT_StreamRec |
||||
* |
||||
* @description: |
||||
* the input stream object structure. See @FT_Stream_ClassRec for |
||||
* its class descriptor |
||||
* |
||||
* @fields: |
||||
* object :: root @FT_ObjectRec fields |
||||
* size :: size of stream in bytes (0 if unknown) |
||||
* pos :: current position within stream |
||||
* base :: for memory-based streams, the address of the stream's |
||||
* first data byte in memory. NULL otherwise |
||||
* |
||||
* cursor :: the current cursor position within an input stream |
||||
* frame. Only valid within a FT_FRAME_ENTER .. FT_FRAME_EXIT |
||||
* block; NULL otherwise |
||||
* |
||||
* limit :: the current frame limit within a FT_FRAME_ENTER .. |
||||
* FT_FRAME_EXIT block. NULL otherwise |
||||
*/ |
||||
typedef struct FT_StreamRec_ |
||||
{ |
||||
FT_ObjectRec object; |
||||
FT_ULong size; |
||||
FT_ULong pos; |
||||
const FT_Byte* base; |
||||
const FT_Byte* cursor; |
||||
const FT_Byte* limit; |
||||
|
||||
} FT_StreamRec; |
||||
|
||||
/* some useful macros */ |
||||
#define FT_STREAM(x) ((FT_Stream)(x)) |
||||
#define FT_STREAM_P(x) ((FT_Stream*)(x)) |
||||
|
||||
#define FT_STREAM__READ(x) FT_STREAM_CLASS__READ(FT_OBJECT__CLASS(x)) |
||||
#define FT_STREAM__SEEK(x) FT_STREAM_CLASS__SEEK(FT_OBJECT__CLASS(x)) |
||||
|
||||
#define FT_STREAM_IS_BASED(x) ( FT_STREAM(x)->base != NULL ) |
||||
|
||||
/* */ |
||||
|
||||
/* create new memory-based stream */ |
||||
FT_BASE( FT_Error ) ft_stream_new_memory( const FT_Byte* stream_base, |
||||
FT_ULong stream_size, |
||||
FT_Memory memory, |
||||
FT_Stream *astream ); |
||||
|
||||
FT_BASE( FT_Error ) ft_stream_new_iso( const char* pathanme, |
||||
FT_Memory memory, |
||||
FT_Stream *astream ); |
||||
|
||||
|
||||
/* handle to default stream class implementation for a given build */ |
||||
/* this is used by "FT_New_Face" */ |
||||
/* */ |
||||
FT_APIVAR( FT_Type ) ft_stream_default_type; |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SYSTEM_STREAM_H__ */ |
@ -1,202 +0,0 @@ |
||||
#ifndef __FT_SYSTEM_MEMORY_H__ |
||||
#define __FT_SYSTEM_MEMORY_H__ |
||||
|
||||
#include <ft2build.h> |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/************************************************************************/ |
||||
/************************************************************************/ |
||||
/***** *****/ |
||||
/***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/ |
||||
/***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/ |
||||
/***** *****/ |
||||
/************************************************************************/ |
||||
/************************************************************************/ |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @type: FT_Memory |
||||
* |
||||
* @description: |
||||
* opaque handle to a memory manager handle. Note that since FreeType |
||||
* 2.2, the memory manager structure FT_MemoryRec is hidden to client |
||||
* applications. |
||||
* |
||||
* however, you can still define custom allocators easily using the |
||||
* @ft_memory_new API |
||||
*/ |
||||
typedef struct FT_MemoryRec_* FT_Memory; |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @functype: FT_Memory_AllocFunc |
||||
* |
||||
* @description: |
||||
* a function used to allocate a block of memory. |
||||
* |
||||
* @input: |
||||
* size :: size of blocks in bytes. Always > 0 !! |
||||
* mem_data :: memory-manager specific optional argument |
||||
* (see @ft_memory_new) |
||||
* |
||||
* @return: |
||||
* address of new block. NULL in case of memory exhaustion |
||||
*/ |
||||
typedef FT_Pointer (*FT_Memory_AllocFunc)( FT_ULong size, |
||||
FT_Pointer mem_data ); |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @functype: FT_Memory_FreeFunc |
||||
* |
||||
* @description: |
||||
* a function used to release a block of memory created through |
||||
* @FT_Memory_AllocFunc or @FT_Memory_ReallocFunc |
||||
* |
||||
* @input: |
||||
* block :: address of target memory block. cannot be NULL !! |
||||
* mem_data :: memory-manager specific optional argument |
||||
* (see @ft_memory_new) |
||||
*/ |
||||
typedef void (*FT_Memory_FreeFunc) ( FT_Pointer block, |
||||
FT_Pointer mem_data ); |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @functype: FT_Memory_ReallocFunc |
||||
* |
||||
* @description: |
||||
* a function used to reallocate a memory block. |
||||
* |
||||
* @input: |
||||
* block :: address of target memory block. cannot be NULL !! |
||||
* new_size :: new requested size in bytes |
||||
* cur_size :: current block size in bytes |
||||
* mem_data :: memory-manager specific optional argument |
||||
* (see @ft_memory_new) |
||||
*/ |
||||
typedef FT_Pointer (*FT_Memory_ReallocFunc)( FT_Pointer block, |
||||
FT_ULong new_size, |
||||
FT_ULong cur_size, |
||||
FT_Pointer mem_data ); |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @functype: FT_Memory_CreateFunc |
||||
* |
||||
* @description: |
||||
* a function used to create a @FT_Memory object to model a |
||||
* memory manager |
||||
* |
||||
* @input: |
||||
* size :: size of memory manager structure in bytes |
||||
* init_data :: optional initialisation argument |
||||
* |
||||
* @output: |
||||
* amem_data :: memory-manager specific argument to block management |
||||
* routines. |
||||
* |
||||
* @return: |
||||
* handle to new memory manager object. NULL in case of failure |
||||
*/ |
||||
typedef FT_Pointer (*FT_Memory_CreateFunc)( FT_UInt size, |
||||
FT_Pointer init_data, |
||||
FT_Pointer *amem_data ); |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @functype: FT_Memory_DestroyFunc |
||||
* |
||||
* @description: |
||||
* a function used to destroy a given @FT_Memory manager |
||||
* |
||||
* @input: |
||||
* memory :: target memory manager handle |
||||
* mem_data :: option manager-specific argument |
||||
*/ |
||||
typedef void (*FT_Memory_DestroyFunc)( FT_Memory memory, |
||||
FT_Pointer mem_data ); |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @struct: FT_Memory_FuncsRec |
||||
* |
||||
* @description: |
||||
* a function used to hold all methods of a given memory manager |
||||
* implementation. |
||||
* |
||||
* @fields: |
||||
* mem_alloc :: block allocation routine |
||||
* mem_free :: block release routine |
||||
* mem_realloc :: block re-allocation routine |
||||
* mem_create :: manager creation routine |
||||
* mem_destroy :: manager destruction routine |
||||
*/ |
||||
typedef struct FT_Memory_FuncsRec_ |
||||
{ |
||||
FT_Memory_AllocFunc mem_alloc; |
||||
FT_Memory_FreeFunc mem_free; |
||||
FT_Memory_ReallocFunc mem_realloc; |
||||
FT_Memory_CreateFunc mem_create; |
||||
FT_Memory_DestroyFunc mem_destroy; |
||||
|
||||
} FT_Memory_FuncsRec, *FT_Memory_Funcs; |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @type: FT_Memory_Funcs |
||||
* |
||||
* @description: |
||||
* a pointer to a constant @FT_Memory_FuncsRec structure used to |
||||
* describe a given memory manager implementation. |
||||
*/ |
||||
typedef const FT_Memory_FuncsRec* FT_Memory_Funcs; |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @function: ft_memory_new |
||||
* |
||||
* @description: |
||||
* create a new memory manager, given a set of memory methods |
||||
* |
||||
* @input: |
||||
* mem_funcs :: handle to memory manager implementation descriptor |
||||
* mem_init_data :: optional initialisation argument, passed to |
||||
* @FT_Memory_CreateFunc |
||||
* |
||||
* @return: |
||||
* new memory manager handle. NULL in case of failure |
||||
*/ |
||||
FT_BASE( FT_Memory ) |
||||
ft_memory_new( FT_Memory_Funcs mem_funcs, |
||||
FT_Pointer mem_init_data ); |
||||
|
||||
|
||||
/*@**********************************************************************
|
||||
* |
||||
* @function: ft_memory_destroy |
||||
* |
||||
* @description: |
||||
* destroy a given memory manager |
||||
* |
||||
* @input: |
||||
* memory :: handle to target memory manager |
||||
*/ |
||||
FT_BASE( void ) |
||||
ft_memory_destroy( FT_Memory memory ); |
||||
|
||||
/* */ |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SYSTEM_MEMORY_H__ */ |
Loading…
Reference in new issue