提交 2f327679 编写于 作者: P prr

8222690: Better Glyph Images

Reviewed-by: serb, psadhukhan, mschoene, rhalade
上级 8cfbc003
...@@ -323,6 +323,14 @@ public final class GlyphList { ...@@ -323,6 +323,14 @@ public final class GlyphList {
*/ */
public void setGlyphIndex(int i) { public void setGlyphIndex(int i) {
glyphindex = i; glyphindex = i;
if (images[i] == 0L) {
metrics[0] = (int)gposx;
metrics[1] = (int)gposy;
metrics[2] = 0;
metrics[3] = 0;
metrics[4] = 0;
return;
}
float gx = float gx =
StrikeCache.unsafe.getFloat(images[i]+StrikeCache.topLeftXOffset); StrikeCache.unsafe.getFloat(images[i]+StrikeCache.topLeftXOffset);
float gy = float gy =
...@@ -361,6 +369,9 @@ public final class GlyphList { ...@@ -361,6 +369,9 @@ public final class GlyphList {
graybits = new byte[len]; graybits = new byte[len];
} }
} }
if (images[glyphindex] == 0L) {
return graybits;
}
long pixelDataAddress = long pixelDataAddress =
StrikeCache.unsafe.getAddress(images[glyphindex] + StrikeCache.unsafe.getAddress(images[glyphindex] +
StrikeCache.pixelDataOffset); StrikeCache.pixelDataOffset);
...@@ -468,6 +479,9 @@ public final class GlyphList { ...@@ -468,6 +479,9 @@ public final class GlyphList {
char gw, gh; char gw, gh;
float gx, gy, gx0, gy0, gx1, gy1; float gx, gy, gx0, gy0, gx1, gy1;
for (int i=0; i<len; i++) { for (int i=0; i<len; i++) {
if (images[i] == 0L) {
continue;
}
gx = StrikeCache.unsafe.getFloat(images[i]+xOffset); gx = StrikeCache.unsafe.getFloat(images[i]+xOffset);
gy = StrikeCache.unsafe.getFloat(images[i]+yOffset); gy = StrikeCache.unsafe.getFloat(images[i]+yOffset);
gw = StrikeCache.unsafe.getChar(images[i]+wOffset); gw = StrikeCache.unsafe.getChar(images[i]+wOffset);
......
...@@ -532,6 +532,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) { ...@@ -532,6 +532,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) {
*/ */
if (subPixPos && len > 0) { if (subPixPos && len > 0) {
ginfo = (GlyphInfo*)imagePtrs[0]; ginfo = (GlyphInfo*)imagePtrs[0];
if (ginfo == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, glyphImages,
imagePtrs, JNI_ABORT);
free(gbv);
return (GlyphBlitVector*)NULL;
}
/* rowBytes==width tests if its a B&W or LCD glyph */ /* rowBytes==width tests if its a B&W or LCD glyph */
if (ginfo->width == ginfo->rowBytes) { if (ginfo->width == ginfo->rowBytes) {
subPixPos = JNI_FALSE; subPixPos = JNI_FALSE;
...@@ -561,6 +567,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) { ...@@ -561,6 +567,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) {
jfloat px, py; jfloat px, py;
ginfo = (GlyphInfo*)imagePtrs[g]; ginfo = (GlyphInfo*)imagePtrs[g];
if (ginfo == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, glyphImages,
imagePtrs, JNI_ABORT);
free(gbv);
return (GlyphBlitVector*)NULL;
}
gbv->glyphs[g].glyphInfo = ginfo; gbv->glyphs[g].glyphInfo = ginfo;
gbv->glyphs[g].pixels = ginfo->image; gbv->glyphs[g].pixels = ginfo->image;
gbv->glyphs[g].width = ginfo->width; gbv->glyphs[g].width = ginfo->width;
...@@ -636,6 +648,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) { ...@@ -636,6 +648,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) {
} else { } else {
for (g=0; g<len; g++) { for (g=0; g<len; g++) {
ginfo = (GlyphInfo*)imagePtrs[g]; ginfo = (GlyphInfo*)imagePtrs[g];
if (ginfo == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, glyphImages,
imagePtrs, JNI_ABORT);
free(gbv);
return (GlyphBlitVector*)NULL;
}
gbv->glyphs[g].glyphInfo = ginfo; gbv->glyphs[g].glyphInfo = ginfo;
gbv->glyphs[g].pixels = ginfo->image; gbv->glyphs[g].pixels = ginfo->image;
gbv->glyphs[g].width = ginfo->width; gbv->glyphs[g].width = ginfo->width;
......
...@@ -622,16 +622,17 @@ Java_sun_font_FreetypeFontScaler_getGlyphAdvanceNative( ...@@ -622,16 +622,17 @@ Java_sun_font_FreetypeFontScaler_getGlyphAdvanceNative(
to avoid unnecesary work with bitmaps. */ to avoid unnecesary work with bitmaps. */
GlyphInfo *info; GlyphInfo *info;
jfloat advance; jfloat advance = 0.0f;
jlong image; jlong image;
image = Java_sun_font_FreetypeFontScaler_getGlyphImageNative( image = Java_sun_font_FreetypeFontScaler_getGlyphImageNative(
env, scaler, font2D, pScalerContext, pScaler, glyphCode); env, scaler, font2D, pScalerContext, pScaler, glyphCode);
info = (GlyphInfo*) jlong_to_ptr(image); info = (GlyphInfo*) jlong_to_ptr(image);
advance = info->advanceX; if (info != NULL) {
advance = info->advanceX;
free(info); free(info);
}
return advance; return advance;
} }
......
...@@ -114,6 +114,9 @@ public class XRGlyphCache implements GlyphDisposedListener { ...@@ -114,6 +114,9 @@ public class XRGlyphCache implements GlyphDisposedListener {
for (int i = 0; i < glyphList.getNumGlyphs(); i++) { for (int i = 0; i < glyphList.getNumGlyphs(); i++) {
XRGlyphCacheEntry glyph; XRGlyphCacheEntry glyph;
if (imgPtrs[i] == 0L) {
continue;
}
// Find uncached glyphs and queue them for upload // Find uncached glyphs and queue them for upload
if ((glyph = getEntryForPointer(imgPtrs[i])) == null) { if ((glyph = getEntryForPointer(imgPtrs[i])) == null) {
glyph = new XRGlyphCacheEntry(imgPtrs[i], glyphList); glyph = new XRGlyphCacheEntry(imgPtrs[i], glyphList);
......
...@@ -88,6 +88,9 @@ public class XRTextRenderer extends GlyphListPipe { ...@@ -88,6 +88,9 @@ public class XRTextRenderer extends GlyphListPipe {
for (int i = 0; i < gl.getNumGlyphs(); i++) { for (int i = 0; i < gl.getNumGlyphs(); i++) {
gl.setGlyphIndex(i); gl.setGlyphIndex(i);
XRGlyphCacheEntry cacheEntry = cachedGlyphs[i]; XRGlyphCacheEntry cacheEntry = cachedGlyphs[i];
if (cacheEntry == null) {
continue;
}
eltList.getGlyphs().addInt(cacheEntry.getGlyphID()); eltList.getGlyphs().addInt(cacheEntry.getGlyphID());
int glyphSet = cacheEntry.getGlyphSet(); int glyphSet = cacheEntry.getGlyphSet();
......
...@@ -273,6 +273,7 @@ JNIEXPORT jlong JNICALL AWTFontGenerateImage(AWTFont pFont, AWTChar2b* xChar) { ...@@ -273,6 +273,7 @@ JNIEXPORT jlong JNICALL AWTFontGenerateImage(AWTFont pFont, AWTChar2b* xChar) {
unsigned int imageSize; unsigned int imageSize;
JNIEnv *env; JNIEnv *env;
FONT_AWT_LOCK(); FONT_AWT_LOCK();
/* XTextExtents16(xFont, xChar, 1, &direction, &ascent, &descent, &xcs); */ /* XTextExtents16(xFont, xChar, 1, &direction, &ascent, &descent, &xcs); */
XQueryTextExtents16(awt_display,xFont->fid, xChar, 1, XQueryTextExtents16(awt_display,xFont->fid, xChar, 1,
...@@ -280,8 +281,11 @@ JNIEXPORT jlong JNICALL AWTFontGenerateImage(AWTFont pFont, AWTChar2b* xChar) { ...@@ -280,8 +281,11 @@ JNIEXPORT jlong JNICALL AWTFontGenerateImage(AWTFont pFont, AWTChar2b* xChar) {
width = xcs.rbearing - xcs.lbearing; width = xcs.rbearing - xcs.lbearing;
height = xcs.ascent+xcs.descent; height = xcs.ascent+xcs.descent;
imageSize = width*height; imageSize = width*height;
glyphInfo = (GlyphInfo*)malloc(sizeof(GlyphInfo)+imageSize); glyphInfo = (GlyphInfo*)malloc(sizeof(GlyphInfo)+imageSize);
if (glyphInfo == NULL) {
AWT_UNLOCK();
return (jlong)(uintptr_t)NULL;
}
glyphInfo->cellInfo = NULL; glyphInfo->cellInfo = NULL;
glyphInfo->width = width; glyphInfo->width = width;
glyphInfo->height = height; glyphInfo->height = height;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册