Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8249174: Fix improper glyph cache initialization logic for text rende…
  • Loading branch information
jayathirthrao committed Jul 10, 2020
1 parent 33bf125 commit 1314319b0037693f8262d83dfc6cd42d74a6efb3
Showing with 6 additions and 8 deletions.
  1. +6 −8 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m
@@ -249,20 +249,18 @@
*/
static void
MTLTR_AddToGlyphCache(GlyphInfo *glyph, MTLContext *mtlc,
MTLPixelFormat pixelFormat)
jboolean lcdCache)
{
MTLCacheCellInfo *ccinfo;
MTLGlyphCacheInfo *gcinfo;
jboolean isLCD = JNI_FALSE;
jint w = glyph->width;
jint h = glyph->height;

J2dTraceLn(J2D_TRACE_INFO, "MTLTR_AddToGlyphCache");
if (pixelFormat == MTLPixelFormatA8Unorm) {
if (!lcdCache) {
gcinfo = glyphCacheAA;
} else {
gcinfo = glyphCacheLCD;
isLCD = JNI_TRUE;
}

if ((gcinfo == NULL) || (glyph->image == NULL)) {
@@ -272,7 +270,7 @@
bool isCacheFull = MTLGlyphCache_IsCacheFull(gcinfo, glyph);
if (isCacheFull) {
MTLGlyphCache_Free(gcinfo);
if (!isLCD) {
if (!lcdCache) {
MTLTR_InitGlyphCache(mtlc, JNI_FALSE);
gcinfo = glyphCacheAA;
} else {
@@ -289,7 +287,7 @@
{ccinfo->x, ccinfo->y, 0},
{w, h, 1}
};
if (!isLCD) {
if (!lcdCache) {
// Opengl uses GL_INTENSITY as internal pixel format to set number of
// color components in the texture for grayscale texture.
// It is mentioned that for GL_INTENSITY format,
@@ -553,7 +551,7 @@

if (ginfo->cellInfo == NULL) {
// attempt to add glyph to accelerated glyph cache
MTLTR_AddToGlyphCache(ginfo, mtlc, MTLPixelFormatA8Unorm);
MTLTR_AddToGlyphCache(ginfo, mtlc, JNI_FALSE);

if (ginfo->cellInfo == NULL) {
// we'll just no-op in the rare case that the cell is NULL
@@ -649,7 +647,7 @@
if (ginfo->cellInfo == NULL) {
// attempt to add glyph to accelerated glyph cache
// TODO : Handle RGB order
MTLTR_AddToGlyphCache(ginfo, mtlc, MTLPixelFormatRGBA8Unorm);
MTLTR_AddToGlyphCache(ginfo, mtlc, JNI_TRUE);

if (ginfo->cellInfo == NULL) {
// we'll just no-op in the rare case that the cell is NULL

0 comments on commit 1314319

Please sign in to comment.