mirror of
https://github.com/openjdk/jdk8u.git
synced 2025-12-12 00:34:09 -06:00
8360147: Better Glyph drawing redux
Reviewed-by: mbalao, andrew Backport-of: 141d7af9cd3c41de974c3d3f8017d6b21dc6d36c
This commit is contained in:
parent
d24f35dcef
commit
943a5ea328
@ -883,23 +883,28 @@ CGGlyphImages_GetGlyphImagePtrs(jlong glyphInfos[],
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// just do one malloc, and carve it up for all the buffers
|
CGRect *bboxes = (CGRect*)calloc(len, sizeof(CGRect));
|
||||||
void *buffer = malloc((sizeof(CGRect) + sizeof(CGSize) + sizeof(CGGlyph) + sizeof(UniChar)) * len);
|
CGSize *advances = (CGSize*)calloc(len, sizeof(CGSize));
|
||||||
if (buffer == NULL) {
|
CGGlyph *glyphs = (CGGlyph*)calloc(len, sizeof(CGGlyph));
|
||||||
|
UniChar *uniChars = (UniChar*)calloc(len, sizeof(UniChar));
|
||||||
|
|
||||||
|
if (bboxes == NULL || advances == NULL || glyphs == NULL || uniChars == NULL) {
|
||||||
|
free(bboxes);
|
||||||
|
free(advances);
|
||||||
|
free(glyphs);
|
||||||
|
free(uniChars);
|
||||||
[[NSException exceptionWithName:NSMallocException
|
[[NSException exceptionWithName:NSMallocException
|
||||||
reason:@"Failed to allocate memory for the temporary glyph strike and measurement buffers." userInfo:nil] raise];
|
reason:@"Failed to allocate memory for the temporary glyph strike and measurement buffers." userInfo:nil] raise];
|
||||||
}
|
}
|
||||||
|
|
||||||
CGRect *bboxes = (CGRect *)(buffer);
|
|
||||||
CGSize *advances = (CGSize *)(bboxes + sizeof(CGRect) * len);
|
|
||||||
CGGlyph *glyphs = (CGGlyph *)(advances + sizeof(CGGlyph) * len);
|
|
||||||
UniChar *uniChars = (UniChar *)(glyphs + sizeof(UniChar) * len);
|
|
||||||
|
|
||||||
CGGI_CreateGlyphsAndScanForComplexities(glyphInfos, strike, &mode,
|
CGGI_CreateGlyphsAndScanForComplexities(glyphInfos, strike, &mode,
|
||||||
rawGlyphCodes, uniChars, glyphs,
|
rawGlyphCodes, uniChars, glyphs,
|
||||||
advances, bboxes, len);
|
advances, bboxes, len);
|
||||||
|
|
||||||
free(buffer);
|
free(bboxes);
|
||||||
|
free(advances);
|
||||||
|
free(glyphs);
|
||||||
|
free(uniChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TX_FIXED_UNSAFE(v) (isinf(v) || isnan(v) || fabs(v) >= (1<<30))
|
#define TX_FIXED_UNSAFE(v) (isinf(v) || isnan(v) || fabs(v) >= (1<<30))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user