(Metal raster font) Fix severe font driver leaks
This commit is contained in:
parent
f7ad73b494
commit
6fe45a451d
|
@ -50,6 +50,7 @@
|
||||||
|
|
||||||
@property (readonly) struct font_atlas *atlas;
|
@property (readonly) struct font_atlas *atlas;
|
||||||
|
|
||||||
|
- (void)deinit;
|
||||||
- (instancetype)initWithDriver:(MetalDriver *)driver fontPath:(const char *)font_path fontSize:(unsigned)font_size;
|
- (instancetype)initWithDriver:(MetalDriver *)driver fontPath:(const char *)font_path fontSize:(unsigned)font_size;
|
||||||
|
|
||||||
- (int)getWidthForMessage:(const char *)msg length:(NSUInteger)length scale:(float)scale;
|
- (int)getWidthForMessage:(const char *)msg length:(NSUInteger)length scale:(float)scale;
|
||||||
|
@ -58,6 +59,12 @@
|
||||||
|
|
||||||
@implementation MetalRaster
|
@implementation MetalRaster
|
||||||
|
|
||||||
|
- (void)deinit
|
||||||
|
{
|
||||||
|
if (_font_driver && _font_data)
|
||||||
|
_font_driver->free(_font_data);
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)initWithDriver:(MetalDriver *)driver fontPath:(const char *)font_path fontSize:(unsigned)font_size
|
- (instancetype)initWithDriver:(MetalDriver *)driver fontPath:(const char *)font_path fontSize:(unsigned)font_size
|
||||||
{
|
{
|
||||||
if (self = [super init])
|
if (self = [super init])
|
||||||
|
@ -511,6 +518,8 @@ static void *metal_raster_font_init_font(void *data,
|
||||||
static void metal_raster_font_free_font(void *data, bool is_threaded)
|
static void metal_raster_font_free_font(void *data, bool is_threaded)
|
||||||
{
|
{
|
||||||
MetalRaster *r = (__bridge_transfer MetalRaster *)data;
|
MetalRaster *r = (__bridge_transfer MetalRaster *)data;
|
||||||
|
|
||||||
|
[r deinit];
|
||||||
r = nil;
|
r = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue