forked from minhngoc25a/freetype2
Store the rendering port's state in library.
Before this commit, the state of a rendering port was being held globally. Now, it'll be stored in library->svg_renderer_state.
This commit is contained in:
parent
e028be97b8
commit
de44a3fda8
|
@ -890,6 +890,10 @@ FT_BEGIN_HEADER
|
||||||
* created. @FT_Reference_Library increments this counter, and
|
* created. @FT_Reference_Library increments this counter, and
|
||||||
* @FT_Done_Library only destroys a library if the counter is~1,
|
* @FT_Done_Library only destroys a library if the counter is~1,
|
||||||
* otherwise it simply decrements it.
|
* otherwise it simply decrements it.
|
||||||
|
*
|
||||||
|
* svg_renderer_state ::
|
||||||
|
* A pointer to a state object that will have the state of the SVG
|
||||||
|
* Renderer. This will be totally managed by the renderer.
|
||||||
*/
|
*/
|
||||||
typedef struct FT_LibraryRec_
|
typedef struct FT_LibraryRec_
|
||||||
{
|
{
|
||||||
|
@ -917,6 +921,8 @@ FT_BEGIN_HEADER
|
||||||
|
|
||||||
FT_Int refcount;
|
FT_Int refcount;
|
||||||
|
|
||||||
|
void* svg_renderer_state;
|
||||||
|
|
||||||
} FT_LibraryRec;
|
} FT_LibraryRec;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,18 @@ FT_BEGIN_HEADER
|
||||||
* @description:
|
* @description:
|
||||||
* A callback used to initiate the SVG Rendering port
|
* A callback used to initiate the SVG Rendering port
|
||||||
*
|
*
|
||||||
|
* @input:
|
||||||
|
* library::
|
||||||
|
* A instance of library. This is required to initialize the renderer's
|
||||||
|
* state which will be held in the library.
|
||||||
|
*
|
||||||
|
*
|
||||||
* @return:
|
* @return:
|
||||||
* FreeType error code. 0 means success.
|
* FreeType error code. 0 means success.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef FT_Error
|
typedef FT_Error
|
||||||
(*SVG_Lib_Init)( );
|
(*SVG_Lib_Init)( FT_Library library );
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -55,12 +61,14 @@ FT_BEGIN_HEADER
|
||||||
* A callback used to free the SVG Rendering port. Calling this callback
|
* A callback used to free the SVG Rendering port. Calling this callback
|
||||||
* shall do all cleanups that the SVG Rendering port wants to do.
|
* shall do all cleanups that the SVG Rendering port wants to do.
|
||||||
*
|
*
|
||||||
* @return:
|
* @input:
|
||||||
* FreeType error code. 0 means success.
|
* library::
|
||||||
|
* A instance of library. This is required to free the renderer's state
|
||||||
|
* which will be held in the library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef FT_Error
|
typedef void
|
||||||
(*SVG_Lib_Free)( );
|
(*SVG_Lib_Free)( FT_Library library );
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -716,6 +716,7 @@
|
||||||
const FT_Glyph_Class* clazz;
|
const FT_Glyph_Class* clazz;
|
||||||
|
|
||||||
FT_Library library;
|
FT_Library library;
|
||||||
|
FT_Memory memory = library->memory;
|
||||||
|
|
||||||
|
|
||||||
/* check argument */
|
/* check argument */
|
||||||
|
@ -763,7 +764,13 @@
|
||||||
/* prepare dummy slot for rendering */
|
/* prepare dummy slot for rendering */
|
||||||
error = clazz->glyph_prepare( glyph, &dummy );
|
error = clazz->glyph_prepare( glyph, &dummy );
|
||||||
if ( !error )
|
if ( !error )
|
||||||
|
{
|
||||||
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
|
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
|
||||||
|
if ( clazz == &ft_svg_glyph_class )
|
||||||
|
{
|
||||||
|
FT_FREE( dummy.other );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if ( !destroy && origin )
|
if ( !destroy && origin )
|
||||||
|
|
|
@ -37,13 +37,20 @@
|
||||||
static FT_Error
|
static FT_Error
|
||||||
ft_svg_init( SVG_Renderer svg_module )
|
ft_svg_init( SVG_Renderer svg_module )
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
|
|
||||||
|
|
||||||
svg_module->loaded = FALSE;
|
svg_module->loaded = FALSE;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ft_svg_done( SVG_Renderer svg_module )
|
||||||
|
{
|
||||||
|
FT_Library library = svg_module->root.root.library;
|
||||||
|
if ( svg_module->loaded = TRUE )
|
||||||
|
svg_module->hooks.svg_lib_free( library );
|
||||||
|
svg_module->loaded = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static FT_Error
|
static FT_Error
|
||||||
ft_svg_render( FT_Renderer renderer,
|
ft_svg_render( FT_Renderer renderer,
|
||||||
FT_GlyphSlot slot,
|
FT_GlyphSlot slot,
|
||||||
|
@ -51,14 +58,13 @@
|
||||||
const FT_Vector* origin )
|
const FT_Vector* origin )
|
||||||
{
|
{
|
||||||
SVG_Renderer svg_renderer = (SVG_Renderer)renderer;
|
SVG_Renderer svg_renderer = (SVG_Renderer)renderer;
|
||||||
|
FT_Library library = renderer->root.library;
|
||||||
|
FT_Error error;
|
||||||
if( svg_renderer->loaded == FALSE )
|
if ( svg_renderer->loaded == FALSE )
|
||||||
{
|
{
|
||||||
|
error = svg_renderer->hooks.svg_lib_init( library );
|
||||||
svg_renderer->loaded = TRUE;
|
svg_renderer->loaded = TRUE;
|
||||||
svg_renderer->hooks.svg_lib_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return svg_renderer->hooks.svg_lib_render( slot );
|
return svg_renderer->hooks.svg_lib_render( slot );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +102,7 @@
|
||||||
0x20000L,
|
0x20000L,
|
||||||
(const void*)&svg_renderer_interface, /* module specific interface */
|
(const void*)&svg_renderer_interface, /* module specific interface */
|
||||||
(FT_Module_Constructor)ft_svg_init, /* module_init */
|
(FT_Module_Constructor)ft_svg_init, /* module_init */
|
||||||
NULL,
|
(FT_Module_Destructor)ft_svg_done, /* module_done */
|
||||||
NULL,
|
NULL,
|
||||||
FT_GLYPH_FORMAT_SVG,
|
FT_GLYPH_FORMAT_SVG,
|
||||||
(FT_Renderer_RenderFunc)ft_svg_render,
|
(FT_Renderer_RenderFunc)ft_svg_render,
|
||||||
|
|
Loading…
Reference in New Issue