mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Make glyph creation a tiny bit faster
This commit is contained in:
parent
383c3a6cb7
commit
2b93ccb12b
@ -470,15 +470,15 @@ static int ParseHost(void* dst, WCHAR* host, int port) {
|
||||
|
||||
Platform_Utf16ToAnsi(host);
|
||||
res = _gethostbyname((char*)host);
|
||||
if (!res || res->h_addrtype != AF_INET) return 0;
|
||||
if (!res || res->h_addrtype != AF_INET) return false;
|
||||
|
||||
/* Must have at least one IPv4 address */
|
||||
if (!res->h_addr_list[0]) return 0;
|
||||
if (!res->h_addr_list[0]) return false;
|
||||
|
||||
addr4->sin_family = AF_INET;
|
||||
addr4->sin_port = _htons(port);
|
||||
addr4->sin_addr = *(IN_ADDR*)res->h_addr_list[0];
|
||||
return AF_INET;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int Socket_ParseAddress(void* dst, INT* size, const cc_string* address, int port) {
|
||||
@ -488,15 +488,15 @@ static int Socket_ParseAddress(void* dst, INT* size, const cc_string* address, i
|
||||
Platform_EncodeUtf16(str, address);
|
||||
|
||||
*size = sizeof(*addr4);
|
||||
if (!_WSAStringToAddressW(str, AF_INET, NULL, addr4, size)) {
|
||||
if (!_WSAStringToAddressW(str, AF_INET, NULL, addr4, size)) {
|
||||
addr4->sin_port = _htons(port);
|
||||
return AF_INET;
|
||||
return true;
|
||||
}
|
||||
|
||||
*size = sizeof(*addr6);
|
||||
if (!_WSAStringToAddressW(str, AF_INET6, NULL, (SOCKADDR*)addr6, size)) {
|
||||
if (!_WSAStringToAddressW(str, AF_INET6, NULL, addr6, size)) {
|
||||
addr6->sin6_port = _htons(port);
|
||||
return AF_INET6;
|
||||
return true;
|
||||
}
|
||||
|
||||
*size = sizeof(*addr4);
|
||||
@ -510,16 +510,16 @@ int Socket_ValidAddress(const cc_string* address) {
|
||||
}
|
||||
|
||||
cc_result Socket_Connect(cc_socket* s, const cc_string* address, int port) {
|
||||
int family, blockingMode = -1; /* non-blocking mode */
|
||||
int blockingMode = -1; /* non-blocking mode */
|
||||
SOCKADDR_STORAGE addr;
|
||||
cc_result res;
|
||||
INT addrSize;
|
||||
|
||||
*s = -1;
|
||||
if (!(family = Socket_ParseAddress(&addr, &addrSize, address, port)))
|
||||
if (!Socket_ParseAddress(&addr, &addrSize, address, port))
|
||||
return ERR_INVALID_ARGUMENT;
|
||||
|
||||
*s = _socket(family, SOCK_STREAM, IPPROTO_TCP);
|
||||
*s = _socket(addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (*s == -1) return _WSAGetLastError();
|
||||
_ioctlsocket(*s, FIONBIO, &blockingMode);
|
||||
|
||||
|
@ -76,7 +76,7 @@ static int RunProgram(int argc, char** argv) {
|
||||
int argsCount = Platform_GetCommandLineArgs(argc, argv, args);
|
||||
#ifdef _MSC_VER
|
||||
/* NOTE: Make sure to comment this out before pushing a commit */
|
||||
//cc_string rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
|
||||
//cc_string rawArgs = String_FromConst("UnknownShadow200 fffff ::1 25565");
|
||||
//cc_string rawArgs = String_FromConst("UnknownShadow200");
|
||||
//argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
|
||||
#endif
|
||||
|
@ -2911,8 +2911,6 @@ FT_BEGIN_HEADER
|
||||
FT_RENDER_MODE_NORMAL = 0,
|
||||
FT_RENDER_MODE_LIGHT,
|
||||
FT_RENDER_MODE_MONO,
|
||||
FT_RENDER_MODE_LCD,
|
||||
FT_RENDER_MODE_LCD_V,
|
||||
|
||||
FT_RENDER_MODE_MAX
|
||||
|
||||
|
@ -172,8 +172,6 @@ FT_BEGIN_HEADER
|
||||
FT_PIXEL_MODE_GRAY,
|
||||
FT_PIXEL_MODE_GRAY2,
|
||||
FT_PIXEL_MODE_GRAY4,
|
||||
FT_PIXEL_MODE_LCD,
|
||||
FT_PIXEL_MODE_LCD_V,
|
||||
FT_PIXEL_MODE_BGRA,
|
||||
|
||||
FT_PIXEL_MODE_MAX /* do not remove */
|
||||
@ -673,21 +671,13 @@ FT_BEGIN_HEADER
|
||||
/* generally want to access the `outline' field of the */
|
||||
/* @FT_GlyphSlotRec structure to read it. */
|
||||
/* */
|
||||
/* FT_GLYPH_FORMAT_PLOTTER :: */
|
||||
/* The glyph image is a vectorial path with no inside and outside */
|
||||
/* contours. Some Type~1 fonts, like those in the Hershey family, */
|
||||
/* contain glyphs in this format. These are described as */
|
||||
/* @FT_Outline, but FreeType isn't currently capable of rendering */
|
||||
/* them correctly. */
|
||||
/* */
|
||||
typedef enum FT_Glyph_Format_
|
||||
{
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
|
||||
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' )
|
||||
|
||||
} FT_Glyph_Format;
|
||||
|
||||
|
@ -883,19 +883,7 @@
|
||||
/* now, transform the glyph image if needed */
|
||||
if ( internal->transform_flags )
|
||||
{
|
||||
/* get renderer */
|
||||
/* NOTE: Support for multiple renderers was removed */
|
||||
FT_Renderer renderer = library->cur_renderer;
|
||||
if ( renderer->glyph_format != slot->format )
|
||||
renderer = NULL;
|
||||
|
||||
|
||||
if ( renderer )
|
||||
error = renderer->clazz->transform_glyph(
|
||||
renderer, slot,
|
||||
&internal->transform_matrix,
|
||||
&internal->transform_delta );
|
||||
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
||||
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
||||
{
|
||||
/* apply `standard' transformation if no renderer is available */
|
||||
if ( internal->transform_flags & 1 )
|
||||
@ -2854,7 +2842,6 @@
|
||||
|
||||
|
||||
render->clazz = clazz;
|
||||
render->glyph_format = clazz->glyph_format;
|
||||
|
||||
render->raster_render = clazz->raster_class->raster_render;
|
||||
render->render = clazz->render_glyph;
|
||||
|
@ -659,8 +659,6 @@ FT_BEGIN_HEADER
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
FT_Renderer_Class* clazz;
|
||||
FT_Glyph_Format glyph_format;
|
||||
FT_Glyph_Class glyph_class;
|
||||
|
||||
FT_Raster_Render_Func raster_render;
|
||||
FT_Renderer_RenderFunc render;
|
||||
@ -925,11 +923,7 @@ FT_BEGIN_HEADER
|
||||
init_, \
|
||||
done_, \
|
||||
get_interface_, \
|
||||
glyph_format_, \
|
||||
render_glyph_, \
|
||||
transform_glyph_, \
|
||||
get_glyph_cbox_, \
|
||||
set_mode_, \
|
||||
raster_class_ ) \
|
||||
FT_CALLBACK_TABLE_DEF \
|
||||
const FT_Renderer_Class class_ = \
|
||||
@ -943,12 +937,7 @@ FT_BEGIN_HEADER
|
||||
init_, \
|
||||
done_, \
|
||||
get_interface_ ) \
|
||||
glyph_format_, \
|
||||
\
|
||||
render_glyph_, \
|
||||
transform_glyph_, \
|
||||
get_glyph_cbox_, \
|
||||
set_mode_, \
|
||||
\
|
||||
raster_class_ \
|
||||
};
|
||||
|
@ -78,12 +78,6 @@ FT_BEGIN_HEADER
|
||||
FT_Render_Mode mode,
|
||||
const FT_Vector* origin );
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Renderer_TransformFunc)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
const FT_Matrix* matrix,
|
||||
const FT_Vector* delta );
|
||||
|
||||
|
||||
typedef void
|
||||
(*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
|
||||
@ -91,12 +85,6 @@ FT_BEGIN_HEADER
|
||||
FT_BBox* cbox );
|
||||
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer mode_ptr );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
@ -108,18 +96,9 @@ FT_BEGIN_HEADER
|
||||
/* <Fields> */
|
||||
/* root :: The root @FT_Module_Class fields. */
|
||||
/* */
|
||||
/* glyph_format :: The glyph image format this renderer handles. */
|
||||
/* */
|
||||
/* render_glyph :: A method used to render the image that is in a */
|
||||
/* given glyph slot into a bitmap. */
|
||||
/* */
|
||||
/* transform_glyph :: A method used to transform the image that is in */
|
||||
/* a given glyph slot. */
|
||||
/* */
|
||||
/* get_glyph_cbox :: A method used to access the glyph's cbox. */
|
||||
/* */
|
||||
/* set_mode :: A method used to pass additional parameters. */
|
||||
/* */
|
||||
/* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
|
||||
/* This is a pointer to its raster's class. */
|
||||
/* */
|
||||
@ -127,12 +106,7 @@ FT_BEGIN_HEADER
|
||||
{
|
||||
FT_Module_Class root;
|
||||
|
||||
FT_Glyph_Format glyph_format;
|
||||
|
||||
FT_Renderer_RenderFunc render_glyph;
|
||||
FT_Renderer_TransformFunc transform_glyph;
|
||||
FT_Renderer_GetCBoxFunc get_glyph_cbox;
|
||||
FT_Renderer_SetModeFunc set_mode;
|
||||
|
||||
FT_Raster_Funcs* raster_class;
|
||||
|
||||
|
@ -34,55 +34,6 @@
|
||||
}
|
||||
|
||||
|
||||
/* sets render-specific mode */
|
||||
static FT_Error
|
||||
ft_smooth_set_mode( FT_Renderer render,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer data )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* transform a given glyph image */
|
||||
static FT_Error
|
||||
ft_smooth_transform( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
const FT_Matrix* matrix,
|
||||
const FT_Vector* delta )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
if ( slot->format != render->glyph_format )
|
||||
{
|
||||
error = FT_THROW( Invalid_Argument );
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( matrix )
|
||||
FT_Outline_Transform( &slot->outline, matrix );
|
||||
|
||||
if ( delta )
|
||||
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* return the glyph's control box */
|
||||
static void
|
||||
ft_smooth_get_cbox( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox* cbox )
|
||||
{
|
||||
FT_ZERO( cbox );
|
||||
|
||||
if ( slot->format == render->glyph_format )
|
||||
FT_Outline_Get_CBox( &slot->outline, cbox );
|
||||
}
|
||||
|
||||
|
||||
/* convert a slot's glyph image into a bitmap */
|
||||
static FT_Error
|
||||
ft_smooth_render_generic( FT_Renderer render,
|
||||
@ -102,7 +53,7 @@
|
||||
|
||||
|
||||
/* check glyph image format */
|
||||
if ( slot->format != render->glyph_format )
|
||||
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
|
||||
{
|
||||
error = FT_THROW( Invalid_Argument );
|
||||
goto Exit;
|
||||
@ -202,12 +153,7 @@
|
||||
(FT_Module_Destructor) NULL, /* module_done */
|
||||
(FT_Module_Requester) NULL, /* get_interface */
|
||||
|
||||
FT_GLYPH_FORMAT_OUTLINE,
|
||||
|
||||
(FT_Renderer_RenderFunc) ft_smooth_render, /* render_glyph */
|
||||
(FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */
|
||||
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
|
||||
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
|
||||
|
||||
(FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user