dwrite: Remove unixlib callbacks.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b1dc908aa5
commit
06742814ed
|
@ -717,18 +717,10 @@ extern HRESULT shape_check_typographic_feature(struct scriptshaping_context *con
|
||||||
struct font_data_context;
|
struct font_data_context;
|
||||||
extern HMODULE dwrite_module DECLSPEC_HIDDEN;
|
extern HMODULE dwrite_module DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct font_callback_funcs
|
|
||||||
{
|
|
||||||
int (CDECL *get_font_data)(void *key, const void **data_ptr, UINT64 *data_size, unsigned int *index,
|
|
||||||
struct font_data_context **context);
|
|
||||||
void (CDECL *release_font_data)(struct font_data_context *context);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct font_backend_funcs
|
struct font_backend_funcs
|
||||||
{
|
{
|
||||||
font_object_handle (CDECL *create_font_object)(const void *data_ptr, UINT64 data_size, unsigned int index);
|
font_object_handle (CDECL *create_font_object)(const void *data_ptr, UINT64 data_size, unsigned int index);
|
||||||
void (CDECL *release_font_object)(font_object_handle object);
|
void (CDECL *release_font_object)(font_object_handle object);
|
||||||
void (CDECL *notify_release)(void *key);
|
|
||||||
int (CDECL *get_glyph_outline)(font_object_handle object, float emsize, unsigned int simulations, UINT16 glyph,
|
int (CDECL *get_glyph_outline)(font_object_handle object, float emsize, unsigned int simulations, UINT16 glyph,
|
||||||
struct dwrite_outline *outline);
|
struct dwrite_outline *outline);
|
||||||
UINT16 (CDECL *get_glyph_count)(font_object_handle object);
|
UINT16 (CDECL *get_glyph_count)(font_object_handle object);
|
||||||
|
|
|
@ -837,7 +837,6 @@ static ULONG WINAPI dwritefontface_Release(IDWriteFontFace5 *iface)
|
||||||
for (i = 0; i < ARRAY_SIZE(fontface->glyphs); i++)
|
for (i = 0; i < ARRAY_SIZE(fontface->glyphs); i++)
|
||||||
free(fontface->glyphs[i]);
|
free(fontface->glyphs[i]);
|
||||||
|
|
||||||
font_funcs->notify_release(iface);
|
|
||||||
font_funcs->release_font_object(fontface->font_object);
|
font_funcs->release_font_object(fontface->font_object);
|
||||||
if (fontface->stream)
|
if (fontface->stream)
|
||||||
{
|
{
|
||||||
|
@ -8142,81 +8141,12 @@ HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct font_data_context
|
|
||||||
{
|
|
||||||
IDWriteFontFileStream *stream;
|
|
||||||
void *context;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int CDECL get_font_data_cb(void *key, const void **data_ptr, UINT64 *data_size,
|
|
||||||
unsigned int *index, struct font_data_context **ret_context)
|
|
||||||
{
|
|
||||||
IDWriteFontFace *fontface = key;
|
|
||||||
struct font_data_context *context;
|
|
||||||
IDWriteFontFileStream *stream;
|
|
||||||
IDWriteFontFile *file;
|
|
||||||
unsigned int count;
|
|
||||||
void *data_context;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
*ret_context = NULL;
|
|
||||||
|
|
||||||
count = 1;
|
|
||||||
if (FAILED(IDWriteFontFace_GetFiles(fontface, &count, &file))) return 1;
|
|
||||||
|
|
||||||
hr = get_filestream_from_file(file, &stream);
|
|
||||||
IDWriteFontFile_Release(file);
|
|
||||||
if (FAILED(hr)) return 1;
|
|
||||||
|
|
||||||
hr = IDWriteFontFileStream_GetFileSize(stream, data_size);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
IDWriteFontFileStream_Release(stream);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = IDWriteFontFileStream_ReadFileFragment(stream, data_ptr, 0, *data_size, &data_context);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
IDWriteFontFileStream_Release(stream);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(context = malloc(sizeof(*context))))
|
|
||||||
{
|
|
||||||
IDWriteFontFileStream_Release(stream);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
context->stream = stream;
|
|
||||||
context->context = data_context;
|
|
||||||
|
|
||||||
*ret_context = context;
|
|
||||||
*index = IDWriteFontFace_GetIndex(fontface);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CDECL release_font_data_cb(struct font_data_context *context)
|
|
||||||
{
|
|
||||||
if (!context) return;
|
|
||||||
IDWriteFontFileStream_ReleaseFileFragment(context->stream, context->context);
|
|
||||||
IDWriteFontFileStream_Release(context->stream);
|
|
||||||
free(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct font_callback_funcs callback_funcs =
|
|
||||||
{
|
|
||||||
get_font_data_cb,
|
|
||||||
release_font_data_cb,
|
|
||||||
};
|
|
||||||
|
|
||||||
void init_font_backend(void)
|
void init_font_backend(void)
|
||||||
{
|
{
|
||||||
__wine_init_unix_lib(dwrite_module, DLL_PROCESS_ATTACH, &callback_funcs, &font_funcs);
|
__wine_init_unix_lib(dwrite_module, DLL_PROCESS_ATTACH, NULL, &font_funcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_font_backend(void)
|
void release_font_backend(void)
|
||||||
{
|
{
|
||||||
__wine_init_unix_lib(dwrite_module, DLL_PROCESS_DETACH, &callback_funcs, NULL);
|
__wine_init_unix_lib(dwrite_module, DLL_PROCESS_DETACH, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#ifdef HAVE_FT2BUILD_H
|
#ifdef HAVE_FT2BUILD_H
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_CACHE_H
|
#include FT_GLYPH_H
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include FT_OUTLINE_H
|
#include FT_OUTLINE_H
|
||||||
#include FT_TRUETYPE_TABLES_H
|
#include FT_TRUETYPE_TABLES_H
|
||||||
|
@ -47,19 +47,8 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
||||||
|
|
||||||
static RTL_CRITICAL_SECTION freetype_cs;
|
|
||||||
static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
|
|
||||||
{
|
|
||||||
0, 0, &freetype_cs,
|
|
||||||
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
||||||
0, 0, { (DWORD_PTR)(__FILE__ ": freetype_cs") }
|
|
||||||
};
|
|
||||||
static RTL_CRITICAL_SECTION freetype_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
static void *ft_handle = NULL;
|
static void *ft_handle = NULL;
|
||||||
static FT_Library library = 0;
|
static FT_Library library = 0;
|
||||||
static FTC_Manager cache_manager = 0;
|
|
||||||
static FTC_ImageCache image_cache = 0;
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FT_Int major;
|
FT_Int major;
|
||||||
|
@ -67,8 +56,6 @@ typedef struct
|
||||||
FT_Int patch;
|
FT_Int patch;
|
||||||
} FT_Version_t;
|
} FT_Version_t;
|
||||||
|
|
||||||
static const struct font_callback_funcs *callback_funcs;
|
|
||||||
|
|
||||||
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
|
||||||
MAKE_FUNCPTR(FT_Activate_Size);
|
MAKE_FUNCPTR(FT_Activate_Size);
|
||||||
MAKE_FUNCPTR(FT_Done_Face);
|
MAKE_FUNCPTR(FT_Done_Face);
|
||||||
|
@ -98,53 +85,9 @@ MAKE_FUNCPTR(FT_Outline_New);
|
||||||
MAKE_FUNCPTR(FT_Outline_Transform);
|
MAKE_FUNCPTR(FT_Outline_Transform);
|
||||||
MAKE_FUNCPTR(FT_Outline_Translate);
|
MAKE_FUNCPTR(FT_Outline_Translate);
|
||||||
MAKE_FUNCPTR(FT_Set_Pixel_Sizes);
|
MAKE_FUNCPTR(FT_Set_Pixel_Sizes);
|
||||||
MAKE_FUNCPTR(FTC_ImageCache_Lookup);
|
|
||||||
MAKE_FUNCPTR(FTC_ImageCache_New);
|
|
||||||
MAKE_FUNCPTR(FTC_Manager_New);
|
|
||||||
MAKE_FUNCPTR(FTC_Manager_Done);
|
|
||||||
MAKE_FUNCPTR(FTC_Manager_LookupFace);
|
|
||||||
MAKE_FUNCPTR(FTC_Manager_LookupSize);
|
|
||||||
MAKE_FUNCPTR(FTC_Manager_RemoveFaceID);
|
|
||||||
#undef MAKE_FUNCPTR
|
#undef MAKE_FUNCPTR
|
||||||
static FT_Error (*pFT_Outline_EmboldenXY)(FT_Outline *, FT_Pos, FT_Pos);
|
static FT_Error (*pFT_Outline_EmboldenXY)(FT_Outline *, FT_Pos, FT_Pos);
|
||||||
|
|
||||||
static void face_finalizer(void *object)
|
|
||||||
{
|
|
||||||
FT_Face face = object;
|
|
||||||
callback_funcs->release_font_data((struct font_data_context *)face->generic.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FT_Error face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face)
|
|
||||||
{
|
|
||||||
struct font_data_context *context;
|
|
||||||
const void *data_ptr;
|
|
||||||
FT_Error fterror;
|
|
||||||
UINT64 data_size;
|
|
||||||
UINT32 index;
|
|
||||||
|
|
||||||
*face = NULL;
|
|
||||||
|
|
||||||
if (!face_id)
|
|
||||||
{
|
|
||||||
WARN("NULL fontface requested.\n");
|
|
||||||
return FT_Err_Ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback_funcs->get_font_data(face_id, &data_ptr, &data_size, &index, &context))
|
|
||||||
return FT_Err_Ok;
|
|
||||||
|
|
||||||
fterror = pFT_New_Memory_Face(library, data_ptr, data_size, index, face);
|
|
||||||
if (fterror == FT_Err_Ok)
|
|
||||||
{
|
|
||||||
(*face)->generic.data = context;
|
|
||||||
(*face)->generic.finalizer = face_finalizer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
callback_funcs->release_font_data(context);
|
|
||||||
|
|
||||||
return fterror;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FT_Size freetype_set_face_size(FT_Face face, FT_UInt emsize)
|
static FT_Size freetype_set_face_size(FT_Face face, FT_UInt emsize)
|
||||||
{
|
{
|
||||||
FT_Size size;
|
FT_Size size;
|
||||||
|
@ -207,13 +150,6 @@ static BOOL init_freetype(void)
|
||||||
LOAD_FUNCPTR(FT_Outline_Transform)
|
LOAD_FUNCPTR(FT_Outline_Transform)
|
||||||
LOAD_FUNCPTR(FT_Outline_Translate)
|
LOAD_FUNCPTR(FT_Outline_Translate)
|
||||||
LOAD_FUNCPTR(FT_Set_Pixel_Sizes)
|
LOAD_FUNCPTR(FT_Set_Pixel_Sizes)
|
||||||
LOAD_FUNCPTR(FTC_ImageCache_Lookup)
|
|
||||||
LOAD_FUNCPTR(FTC_ImageCache_New)
|
|
||||||
LOAD_FUNCPTR(FTC_Manager_New)
|
|
||||||
LOAD_FUNCPTR(FTC_Manager_Done)
|
|
||||||
LOAD_FUNCPTR(FTC_Manager_LookupFace)
|
|
||||||
LOAD_FUNCPTR(FTC_Manager_LookupSize)
|
|
||||||
LOAD_FUNCPTR(FTC_Manager_RemoveFaceID)
|
|
||||||
#undef LOAD_FUNCPTR
|
#undef LOAD_FUNCPTR
|
||||||
pFT_Outline_EmboldenXY = dlsym(ft_handle, "FT_Outline_EmboldenXY");
|
pFT_Outline_EmboldenXY = dlsym(ft_handle, "FT_Outline_EmboldenXY");
|
||||||
|
|
||||||
|
@ -225,18 +161,6 @@ static BOOL init_freetype(void)
|
||||||
}
|
}
|
||||||
pFT_Library_Version(library, &FT_Version.major, &FT_Version.minor, &FT_Version.patch);
|
pFT_Library_Version(library, &FT_Version.major, &FT_Version.minor, &FT_Version.patch);
|
||||||
|
|
||||||
/* init cache manager */
|
|
||||||
if (pFTC_Manager_New(library, 0, 0, 0, &face_requester, NULL, &cache_manager) != 0 ||
|
|
||||||
pFTC_ImageCache_New(cache_manager, &image_cache) != 0) {
|
|
||||||
|
|
||||||
ERR("Failed to init FreeType cache\n");
|
|
||||||
pFTC_Manager_Done(cache_manager);
|
|
||||||
pFT_Done_FreeType(library);
|
|
||||||
dlclose(ft_handle);
|
|
||||||
ft_handle = NULL;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("FreeType version is %d.%d.%d\n", FT_Version.major, FT_Version.minor, FT_Version.patch);
|
TRACE("FreeType version is %d.%d.%d\n", FT_Version.major, FT_Version.minor, FT_Version.patch);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -264,13 +188,6 @@ static void CDECL freetype_release_font_object(font_object_handle object)
|
||||||
pFT_Done_Face(object);
|
pFT_Done_Face(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CDECL freetype_notify_release(void *key)
|
|
||||||
{
|
|
||||||
RtlEnterCriticalSection(&freetype_cs);
|
|
||||||
pFTC_Manager_RemoveFaceID(cache_manager, key);
|
|
||||||
RtlLeaveCriticalSection(&freetype_cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CDECL freetype_get_design_glyph_metrics(font_object_handle object, UINT16 upem, UINT16 ascent,
|
static void CDECL freetype_get_design_glyph_metrics(font_object_handle object, UINT16 upem, UINT16 ascent,
|
||||||
unsigned int simulations, UINT16 glyph, DWRITE_GLYPH_METRICS *ret)
|
unsigned int simulations, UINT16 glyph, DWRITE_GLYPH_METRICS *ret)
|
||||||
{
|
{
|
||||||
|
@ -793,7 +710,6 @@ const static struct font_backend_funcs freetype_funcs =
|
||||||
{
|
{
|
||||||
freetype_create_font_object,
|
freetype_create_font_object,
|
||||||
freetype_release_font_object,
|
freetype_release_font_object,
|
||||||
freetype_notify_release,
|
|
||||||
freetype_get_glyph_outline,
|
freetype_get_glyph_outline,
|
||||||
freetype_get_glyph_count,
|
freetype_get_glyph_count,
|
||||||
freetype_get_glyph_advance,
|
freetype_get_glyph_advance,
|
||||||
|
@ -804,7 +720,6 @@ const static struct font_backend_funcs freetype_funcs =
|
||||||
|
|
||||||
static NTSTATUS init_freetype_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out)
|
static NTSTATUS init_freetype_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out)
|
||||||
{
|
{
|
||||||
callback_funcs = ptr_in;
|
|
||||||
if (!init_freetype()) return STATUS_DLL_NOT_FOUND;
|
if (!init_freetype()) return STATUS_DLL_NOT_FOUND;
|
||||||
*(const struct font_backend_funcs **)ptr_out = &freetype_funcs;
|
*(const struct font_backend_funcs **)ptr_out = &freetype_funcs;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -812,7 +727,6 @@ static NTSTATUS init_freetype_lib(HMODULE module, DWORD reason, const void *ptr_
|
||||||
|
|
||||||
static NTSTATUS release_freetype_lib(void)
|
static NTSTATUS release_freetype_lib(void)
|
||||||
{
|
{
|
||||||
pFTC_Manager_Done(cache_manager);
|
|
||||||
pFT_Done_FreeType(library);
|
pFT_Done_FreeType(library);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -828,10 +742,6 @@ static void CDECL null_release_font_object(font_object_handle object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CDECL null_notify_release(void *key)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static int CDECL null_get_glyph_outline(font_object_handle object, float emSize, unsigned int simulations,
|
static int CDECL null_get_glyph_outline(font_object_handle object, float emSize, unsigned int simulations,
|
||||||
UINT16 glyph, struct dwrite_outline *outline)
|
UINT16 glyph, struct dwrite_outline *outline)
|
||||||
{
|
{
|
||||||
|
@ -869,7 +779,6 @@ const static struct font_backend_funcs null_funcs =
|
||||||
{
|
{
|
||||||
null_create_font_object,
|
null_create_font_object,
|
||||||
null_release_font_object,
|
null_release_font_object,
|
||||||
null_notify_release,
|
|
||||||
null_get_glyph_outline,
|
null_get_glyph_outline,
|
||||||
null_get_glyph_count,
|
null_get_glyph_count,
|
||||||
null_get_glyph_advance,
|
null_get_glyph_advance,
|
||||||
|
|
Loading…
Reference in New Issue