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

8222690: Better Glyph Images

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